[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 11:31:14 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL323807: [TableGen] Make sure !if is evaluated throughout class inheritance. (authored by tra, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42695?vs=131996&id=132012#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42695

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


Index: llvm/trunk/include/llvm/TableGen/Record.h
===================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h
+++ llvm/trunk/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;
 
Index: llvm/trunk/test/TableGen/if.td
===================================================================
--- llvm/trunk/test/TableGen/if.td
+++ llvm/trunk/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];


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


More information about the llvm-commits mailing list