Index: llvm/utils/TableGen/PredicateExpander.cpp =================================================================== --- llvm/utils/TableGen/PredicateExpander.cpp +++ llvm/utils/TableGen/PredicateExpander.cpp @@ -44,6 +44,18 @@ OS << (shouldNegate() ? " != " : " == ") << ImmVal; } +void PredicateExpander::expandCheckImmOperandSimple(raw_ostream &OS, + int OpIndex, + StringRef FunctionMapper) { + if (shouldNegate()) + OS << "!"; + if (!FunctionMapper.empty()) + OS << FunctionMapper << "("; + OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex + << ").getImm()"; + OS << (FunctionMapper.empty() ? " " : ") "); +} + void PredicateExpander::expandCheckRegOperand(raw_ostream &OS, int OpIndex, const Record *Reg, StringRef FunctionMapper) { @@ -63,6 +75,20 @@ OS << Reg->getName(); } + +void PredicateExpander::expandCheckRegOperandSimple(raw_ostream &OS, + int OpIndex, + StringRef FunctionMapper) { + if (shouldNegate()) + OS << "!"; + if (!FunctionMapper.empty()) + OS << FunctionMapper << "("; + OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex + << ").getReg()"; + if (!FunctionMapper.empty()) + OS << ")"; +} + void PredicateExpander::expandCheckInvalidRegOperand(raw_ostream &OS, int OpIndex) { OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex @@ -290,9 +316,8 @@ Rec->getValueAsString("FunctionMapper")); if (Rec->isSubClassOf("CheckRegOperandSimple")) - return expandCheckRegOperand(OS, Rec->getValueAsInt("OpIndex"), - nullptr, - Rec->getValueAsString("FunctionMapper")); + return expandCheckRegOperandSimple(OS, Rec->getValueAsInt("OpIndex"), + Rec->getValueAsString("FunctionMapper")); if (Rec->isSubClassOf("CheckInvalidRegOperand")) return expandCheckInvalidRegOperand(OS, Rec->getValueAsInt("OpIndex")); @@ -308,8 +333,8 @@ Rec->getValueAsString("FunctionMapper")); if (Rec->isSubClassOf("CheckImmOperandSimple")) - return expandCheckImmOperand(OS, Rec->getValueAsInt("OpIndex"), "", - Rec->getValueAsString("FunctionMapper")); + return expandCheckImmOperandSimple(OS, Rec->getValueAsInt("OpIndex"), + Rec->getValueAsString("FunctionMapper")); if (Rec->isSubClassOf("CheckSameRegOperand")) return expandCheckSameRegOperand(OS, Rec->getValueAsInt("FirstIndex"),