[PATCH] D55089: [TableGen] Fix negation of simple predicates
Evandro Menezes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 29 16:14:11 PST 2018
evandro created this revision.
evandro added a reviewer: andreadb.
Herald added a subscriber: llvm-commits.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D55089
Files:
llvm/utils/TableGen/PredicateExpander.cpp
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"),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55089.175985.patch
Type: text/x-patch
Size: 2911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181130/0bb5c22a/attachment.bin>
More information about the llvm-commits
mailing list