[llvm] r337378 - [Tablegen][PredicateExpander] Add the ability to define checks for invalid registers.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 18 04:03:22 PDT 2018


Author: adibiagio
Date: Wed Jul 18 04:03:22 2018
New Revision: 337378

URL: http://llvm.org/viewvc/llvm-project?rev=337378&view=rev
Log:
[Tablegen][PredicateExpander] Add the ability to define checks for invalid registers.

This was discussed in review D49436.

Modified:
    llvm/trunk/utils/TableGen/PredicateExpander.cpp
    llvm/trunk/utils/TableGen/PredicateExpander.h

Modified: llvm/trunk/utils/TableGen/PredicateExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PredicateExpander.cpp?rev=337378&r1=337377&r2=337378&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/PredicateExpander.cpp (original)
+++ llvm/trunk/utils/TableGen/PredicateExpander.cpp Wed Jul 18 04:03:22 2018
@@ -44,6 +44,12 @@ void PredicateExpander::expandCheckRegOp
   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(
     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"));

Modified: llvm/trunk/utils/TableGen/PredicateExpander.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PredicateExpander.h?rev=337378&r1=337377&r2=337378&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/PredicateExpander.h (original)
+++ llvm/trunk/utils/TableGen/PredicateExpander.h Wed Jul 18 04:03:22 2018
@@ -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);




More information about the llvm-commits mailing list