[PATCH] D42695: [TableGen] Make sure !if() is propagated across class inheritance.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 10:12:30 PST 2018


tra updated this revision to Diff 131996.
tra added a comment.

edited a comment.


https://reviews.llvm.org/D42695

Files:
  llvm/include/llvm/TableGen/Record.h
  llvm/test/TableGen/if.td


Index: llvm/test/TableGen/if.td
===================================================================
--- llvm/test/TableGen/if.td
+++ llvm/test/TableGen/if.td
@@ -56,6 +56,23 @@
 // CHECK: def D8
 // CHECK-NEXT: bits<2> val = { 0, 0 };
 
+// Make sure !if gets propagated across multiple layers of inheritance.
+class getInt<int c> {
+  int ret = !if(c, 0, 1);
+}
+class I1<int c> {
+  int i = getInt<c>.ret;
+}
+class I2<int c> : I1<c>;
+
+// CHECK: def DI1 {     // I1
+// CHECK-NEXT: int i = 0;
+def DI1: I1<1>;
+
+// CHECK: def DI2 {     // I1 I2
+// CHECK-NEXT: int i = 0;
+def DI2: I2<1>;
+
 // CHECK:      def One
 // CHECK-NEXT: list<int> first = [1, 2, 3];
 // CHECK-NEXT: list<int> rest = [1, 2, 3];
Index: llvm/include/llvm/TableGen/Record.h
===================================================================
--- llvm/include/llvm/TableGen/Record.h
+++ llvm/include/llvm/TableGen/Record.h
@@ -905,7 +905,9 @@
   // possible to fold.
   Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
 
-  bool isComplete() const override { return false; }
+  bool isComplete() const override {
+    return LHS->isComplete() && MHS->isComplete() && RHS->isComplete();
+  }
 
   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42695.131996.patch
Type: text/x-patch
Size: 1268 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180130/65637b77/attachment.bin>


More information about the llvm-commits mailing list