diff options
| author | Daniel Sanders <daniel_l_sanders@apple.com> | 2017-06-28 15:16:03 +0000 |
|---|---|---|
| committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2017-06-28 15:16:03 +0000 |
| commit | 320390bab894c287bbbf2b1949752bcb152b37a2 (patch) | |
| tree | ba3517b8499cd7980795017c241027f426b66bb4 | |
| parent | ce65982ea149775a18ab26baa3d94751e8ffa160 (diff) | |
| download | bcm5719-llvm-320390bab894c287bbbf2b1949752bcb152b37a2.tar.gz bcm5719-llvm-320390bab894c287bbbf2b1949752bcb152b37a2.zip | |
[globalisel][tablegen] Post-commit review nits for r306388. NFC
One early exit and a missing assert string.
llvm-svn: 306552
| -rw-r--r-- | llvm/utils/TableGen/GlobalISelEmitter.cpp | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index 79fb350ca34..924ed8f65c2 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -1891,45 +1891,39 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { if (!Dst->getChild(0)->isLeaf()) return failedImport("EXTRACT_SUBREG child #1 is not a leaf"); - if (DefInit *SubRegInit = - dyn_cast<DefInit>(Dst->getChild(1)->getLeafValue())) { - // Constrain the result to the same register bank as the operand. - Record *DstIOpRec = - getInitValueAsRegClass(Dst->getChild(0)->getLeafValue()); - - if (DstIOpRec == nullptr) - return failedImport("EXTRACT_SUBREG operand #1 isn't a register class"); - - CodeGenSubRegIndex *SubIdx = CGRegs.getSubRegIdx(SubRegInit->getDef()); - CodeGenRegisterClass *SrcRC = CGRegs.getRegClass( - getInitValueAsRegClass(Dst->getChild(0)->getLeafValue())); - - // It would be nice to leave this constraint implicit but we're required - // to pick a register class so constrain the result to a register class - // that can hold the correct MVT. - // - // 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 = - SrcRC->getMatchingSubClassWithSubRegs(CGRegs, SubIdx); - assert(SrcRCDstRCPair->second && "Couldn't find a matching subclass"); - M.addAction<ConstrainOperandToRegClassAction>("NewI", 0, - *SrcRCDstRCPair->second); - M.addAction<ConstrainOperandToRegClassAction>("NewI", 1, - *SrcRCDstRCPair->first); - - // We're done with this pattern! It's eligible for GISel emission; return - // it. - ++NumPatternImported; - return std::move(M); - } + DefInit *SubRegInit = dyn_cast<DefInit>(Dst->getChild(1)->getLeafValue()); + if (!SubRegInit) + return failedImport("EXTRACT_SUBREG child #1 is not a subreg index"); - return failedImport("EXTRACT_SUBREG child #1 is not a subreg index"); - } + // Constrain the result to the same register bank as the operand. + Record *DstIOpRec = + getInitValueAsRegClass(Dst->getChild(0)->getLeafValue()); - M.addAction<ConstrainOperandsToDefinitionAction>("NewI"); + if (DstIOpRec == nullptr) + return failedImport("EXTRACT_SUBREG operand #1 isn't a register class"); + + CodeGenSubRegIndex *SubIdx = CGRegs.getSubRegIdx(SubRegInit->getDef()); + CodeGenRegisterClass *SrcRC = CGRegs.getRegClass( + getInitValueAsRegClass(Dst->getChild(0)->getLeafValue())); + + // It would be nice to leave this constraint implicit but we're required + // to pick a register class so constrain the result to a register class + // that can hold the correct MVT. + // + // FIXME: This may introduce an extra copy if the chosen class doesn't + // actually contain the subregisters. + assert(Src->getExtTypes().size() == 1 && + "Expected Src of EXTRACT_SUBREG to have one result type"); + + const auto &SrcRCDstRCPair = + SrcRC->getMatchingSubClassWithSubRegs(CGRegs, SubIdx); + assert(SrcRCDstRCPair->second && "Couldn't find a matching subclass"); + M.addAction<ConstrainOperandToRegClassAction>("NewI", 0, + *SrcRCDstRCPair->second); + M.addAction<ConstrainOperandToRegClassAction>("NewI", 1, + *SrcRCDstRCPair->first); + } else + M.addAction<ConstrainOperandsToDefinitionAction>("NewI"); // We're done with this pattern! It's eligible for GISel emission; return it. ++NumPatternImported; |

