[globalisel][tablegen] Post-commit review nits for r306388. NFC

One early exit and a missing assert string.

llvm-svn: 306552
This commit is contained in:
Daniel Sanders 2017-06-28 15:16:03 +00:00
parent ce65982ea1
commit 320390bab8
1 changed files with 28 additions and 34 deletions

View File

@ -1891,45 +1891,39 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
if (!Dst->getChild(0)->isLeaf()) if (!Dst->getChild(0)->isLeaf())
return failedImport("EXTRACT_SUBREG child #1 is not a leaf"); return failedImport("EXTRACT_SUBREG child #1 is not a leaf");
if (DefInit *SubRegInit = DefInit *SubRegInit = dyn_cast<DefInit>(Dst->getChild(1)->getLeafValue());
dyn_cast<DefInit>(Dst->getChild(1)->getLeafValue())) { if (!SubRegInit)
// Constrain the result to the same register bank as the operand. return failedImport("EXTRACT_SUBREG child #1 is not a subreg index");
Record *DstIOpRec =
getInitValueAsRegClass(Dst->getChild(0)->getLeafValue());
if (DstIOpRec == nullptr) // Constrain the result to the same register bank as the operand.
return failedImport("EXTRACT_SUBREG operand #1 isn't a register class"); Record *DstIOpRec =
getInitValueAsRegClass(Dst->getChild(0)->getLeafValue());
CodeGenSubRegIndex *SubIdx = CGRegs.getSubRegIdx(SubRegInit->getDef()); if (DstIOpRec == nullptr)
CodeGenRegisterClass *SrcRC = CGRegs.getRegClass( return failedImport("EXTRACT_SUBREG operand #1 isn't a register class");
getInitValueAsRegClass(Dst->getChild(0)->getLeafValue()));
// It would be nice to leave this constraint implicit but we're required CodeGenSubRegIndex *SubIdx = CGRegs.getSubRegIdx(SubRegInit->getDef());
// to pick a register class so constrain the result to a register class CodeGenRegisterClass *SrcRC = CGRegs.getRegClass(
// that can hold the correct MVT. getInitValueAsRegClass(Dst->getChild(0)->getLeafValue()));
//
// FIXME: This may introduce an extra copy if the chosen class doesn't
// actually contain the subregisters.
assert(Src->getExtTypes().size() == 1);
const auto &SrcRCDstRCPair = // It would be nice to leave this constraint implicit but we're required
SrcRC->getMatchingSubClassWithSubRegs(CGRegs, SubIdx); // to pick a register class so constrain the result to a register class
assert(SrcRCDstRCPair->second && "Couldn't find a matching subclass"); // that can hold the correct MVT.
M.addAction<ConstrainOperandToRegClassAction>("NewI", 0, //
*SrcRCDstRCPair->second); // FIXME: This may introduce an extra copy if the chosen class doesn't
M.addAction<ConstrainOperandToRegClassAction>("NewI", 1, // actually contain the subregisters.
*SrcRCDstRCPair->first); assert(Src->getExtTypes().size() == 1 &&
"Expected Src of EXTRACT_SUBREG to have one result type");
// We're done with this pattern! It's eligible for GISel emission; return const auto &SrcRCDstRCPair =
// it. SrcRC->getMatchingSubClassWithSubRegs(CGRegs, SubIdx);
++NumPatternImported; assert(SrcRCDstRCPair->second && "Couldn't find a matching subclass");
return std::move(M); M.addAction<ConstrainOperandToRegClassAction>("NewI", 0,
} *SrcRCDstRCPair->second);
M.addAction<ConstrainOperandToRegClassAction>("NewI", 1,
return failedImport("EXTRACT_SUBREG child #1 is not a subreg index"); *SrcRCDstRCPair->first);
} } else
M.addAction<ConstrainOperandsToDefinitionAction>("NewI");
M.addAction<ConstrainOperandsToDefinitionAction>("NewI");
// We're done with this pattern! It's eligible for GISel emission; return it. // We're done with this pattern! It's eligible for GISel emission; return it.
++NumPatternImported; ++NumPatternImported;