summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-07-18 11:03:22 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-07-18 11:03:22 +0000
commit3ac65c443f7b55d542e531104a055e6ece6d502d (patch)
treeb11c66e5b393d85d27b20794fa70857c949ebb32
parent1cd41cb270935f71ca45d7d356bffe77dece8dcc (diff)
[Tablegen][PredicateExpander] Add the ability to define checks for invalid registers.
This was discussed in review D49436. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337378 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/TableGen/PredicateExpander.cpp9
-rw-r--r--utils/TableGen/PredicateExpander.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/utils/TableGen/PredicateExpander.cpp b/utils/TableGen/PredicateExpander.cpp
index 56ffa77e4ed..68eb32794a0 100644
--- a/utils/TableGen/PredicateExpander.cpp
+++ b/utils/TableGen/PredicateExpander.cpp
@@ -44,6 +44,12 @@ void PredicateExpander::expandCheckRegOperand(formatted_raw_ostream &OS,
OS << Reg->getName();
}
+void PredicateExpander::expandCheckInvalidRegOperand(formatted_raw_ostream &OS,
+ int OpIndex) {
+ OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex
+ << ").getReg() " << (shouldNegate() ? "!= " : "== ") << "0";
+}
+
void PredicateExpander::expandCheckSameRegOperand(formatted_raw_ostream &OS,
int First, int Second) {
OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << First
@@ -206,6 +212,9 @@ void PredicateExpander::expandPredicate(formatted_raw_ostream &OS,
return expandCheckRegOperand(OS, Rec->getValueAsInt("OpIndex"),
Rec->getValueAsDef("Reg"));
+ if (Rec->isSubClassOf("CheckInvalidRegOperand"))
+ return expandCheckInvalidRegOperand(OS, Rec->getValueAsInt("OpIndex"));
+
if (Rec->isSubClassOf("CheckImmOperand"))
return expandCheckImmOperand(OS, Rec->getValueAsInt("OpIndex"),
Rec->getValueAsInt("ImmVal"));
diff --git a/utils/TableGen/PredicateExpander.h b/utils/TableGen/PredicateExpander.h
index bc4de902fcc..398b376f7a8 100644
--- a/utils/TableGen/PredicateExpander.h
+++ b/utils/TableGen/PredicateExpander.h
@@ -73,6 +73,7 @@ public:
StringRef MethodName);
void expandCheckIsRegOperand(formatted_raw_ostream &OS, int OpIndex);
void expandCheckIsImmOperand(formatted_raw_ostream &OS, int OpIndex);
+ void expandCheckInvalidRegOperand(formatted_raw_ostream &OS, int OpIndex);
void expandCheckFunctionPredicate(formatted_raw_ostream &OS,
StringRef MCInstFn,
StringRef MachineInstrFn);