diff options
author | Evandro Menezes <e.menezes@samsung.com> | 2018-11-30 21:03:24 +0000 |
---|---|---|
committer | Evandro Menezes <e.menezes@samsung.com> | 2018-11-30 21:03:24 +0000 |
commit | 58e94f91a8d0cc7de31f91cfb5ccdb134bfa5d0a (patch) | |
tree | 7274559fc8afedebddad9dd6bac4ca3f57179217 /llvm/utils/TableGen/PredicateExpander.cpp | |
parent | 3b6fb6e846c5c1d0c2e56f3a7897b4cfc9e838d4 (diff) | |
download | bcm5719-llvm-58e94f91a8d0cc7de31f91cfb5ccdb134bfa5d0a.tar.gz bcm5719-llvm-58e94f91a8d0cc7de31f91cfb5ccdb134bfa5d0a.zip |
[TableGen] Fix negation of simple predicates
Simple predicates, such as those defined by `CheckRegOperandSimple` or
`CheckImmOperandSimple`, were not being negated when used with `CheckNot`.
This change fixes this issue by defining the previously declared methods to
handle simple predicates.
Differential revision: https://reviews.llvm.org/D55089
llvm-svn: 348034
Diffstat (limited to 'llvm/utils/TableGen/PredicateExpander.cpp')
-rw-r--r-- | llvm/utils/TableGen/PredicateExpander.cpp | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/llvm/utils/TableGen/PredicateExpander.cpp b/llvm/utils/TableGen/PredicateExpander.cpp index 4af544e6e25..2e01b7c3138 100644 --- a/llvm/utils/TableGen/PredicateExpander.cpp +++ b/llvm/utils/TableGen/PredicateExpander.cpp @@ -26,24 +26,39 @@ void PredicateExpander::expandCheckImmOperand(raw_ostream &OS, int OpIndex, OS << FunctionMapper << "("; OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex << ").getImm()"; - OS << (FunctionMapper.empty() ? " " : ") "); - OS << (shouldNegate() ? "!= " : "== ") << ImmVal; + if (!FunctionMapper.empty()) + OS << ")"; + OS << (shouldNegate() ? " != " : " == ") << ImmVal; } void PredicateExpander::expandCheckImmOperand(raw_ostream &OS, int OpIndex, StringRef ImmVal, StringRef FunctionMapper) { + if (ImmVal.empty()) + expandCheckImmOperandSimple(OS, OpIndex, FunctionMapper); + if (!FunctionMapper.empty()) OS << FunctionMapper << "("; OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex << ").getImm()"; - - OS << (FunctionMapper.empty() ? "" : ")"); - if (ImmVal.empty()) - return; + if (!FunctionMapper.empty()) + OS << ")"; 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()"; + if (!FunctionMapper.empty()) + OS << ")"; +} + void PredicateExpander::expandCheckRegOperand(raw_ostream &OS, int OpIndex, const Record *Reg, StringRef FunctionMapper) { @@ -53,9 +68,8 @@ void PredicateExpander::expandCheckRegOperand(raw_ostream &OS, int OpIndex, OS << FunctionMapper << "("; OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex << ").getReg()"; - OS << (FunctionMapper.empty() ? "" : ")"); - if (!Reg) - return; + if (!FunctionMapper.empty()) + OS << ")"; OS << (shouldNegate() ? " != " : " == "); const StringRef Str = Reg->getValueAsString("Namespace"); if (!Str.empty()) @@ -63,6 +77,20 @@ void PredicateExpander::expandCheckRegOperand(raw_ostream &OS, int OpIndex, 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 +318,8 @@ void PredicateExpander::expandPredicate(raw_ostream &OS, const Record *Rec) { 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 +335,8 @@ void PredicateExpander::expandPredicate(raw_ostream &OS, const Record *Rec) { 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"), |