diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /llvm/utils/TableGen/DAGISelMatcherGen.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'llvm/utils/TableGen/DAGISelMatcherGen.cpp')
-rw-r--r-- | llvm/utils/TableGen/DAGISelMatcherGen.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp index 6a86868a9bcdc..123ea3374c748 100644 --- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp +++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp @@ -311,7 +311,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N, // The "name" of a non-leaf complex pattern (MY_PAT $op1, $op2) is // "MY_PAT:op1:op2". We should already have validated that the uses are // consistent. - std::string PatternName = N->getOperator()->getName(); + std::string PatternName = std::string(N->getOperator()->getName()); for (unsigned i = 0; i < N->getNumChildren(); ++i) { PatternName += ":"; PatternName += N->getChild(i)->getName(); @@ -707,14 +707,36 @@ void MatcherGen::EmitResultLeafAsOperand(const TreePatternNode *N, if (Def->isSubClassOf("RegisterOperand")) Def = Def->getValueAsDef("RegClass"); if (Def->isSubClassOf("RegisterClass")) { - std::string Value = getQualifiedName(Def) + "RegClassID"; - AddMatcher(new EmitStringIntegerMatcher(Value, MVT::i32)); - ResultOps.push_back(NextRecordedOperandNo++); + // If the register class has an enum integer value greater than 127, the + // encoding overflows the limit of 7 bits, which precludes the use of + // StringIntegerMatcher. In this case, fallback to using IntegerMatcher. + const CodeGenRegisterClass &RC = + CGP.getTargetInfo().getRegisterClass(Def); + if (RC.EnumValue <= 127) { + std::string Value = getQualifiedName(Def) + "RegClassID"; + AddMatcher(new EmitStringIntegerMatcher(Value, MVT::i32)); + ResultOps.push_back(NextRecordedOperandNo++); + } else { + AddMatcher(new EmitIntegerMatcher(RC.EnumValue, MVT::i32)); + ResultOps.push_back(NextRecordedOperandNo++); + } return; } // Handle a subregister index. This is used for INSERT_SUBREG etc. if (Def->isSubClassOf("SubRegIndex")) { + const CodeGenRegBank &RB = CGP.getTargetInfo().getRegBank(); + // If we have more than 127 subreg indices the encoding can overflow + // 7 bit and we cannot use StringInteger. + if (RB.getSubRegIndices().size() > 127) { + const CodeGenSubRegIndex *I = RB.findSubRegIdx(Def); + assert(I && "Cannot find subreg index by name!"); + if (I->EnumValue > 127) { + AddMatcher(new EmitIntegerMatcher(I->EnumValue, MVT::i32)); + ResultOps.push_back(NextRecordedOperandNo++); + return; + } + } std::string Value = getQualifiedName(Def); AddMatcher(new EmitStringIntegerMatcher(Value, MVT::i32)); ResultOps.push_back(NextRecordedOperandNo++); |