summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Belevich <tra@google.com>2018-01-30 19:29:21 +0000
committerArtem Belevich <tra@google.com>2018-01-30 19:29:21 +0000
commit7d8f6fa86c1d10a8f01b2bec00c250b8acea1862 (patch)
tree1727476842216d2bbccb103d68e452bcfa831254
parentffb37a29d1a933a3755265d6a4c8af96f55b1440 (diff)
downloadbcm5719-llvm-7d8f6fa86c1d10a8f01b2bec00c250b8acea1862.tar.gz
bcm5719-llvm-7d8f6fa86c1d10a8f01b2bec00c250b8acea1862.zip
[TableGen] Make sure !if is evaluated throughout class inheritance.
Without the patch !if() is only evaluated if it's used directly. If it's passed through more than one level of class inheritance, we end up with a reference to an anonymous record with unresolved references to the original arguments !if may have used. The root cause of the problem is that TernOpInit::isComplete() was always returning false and that prevented use of the folded value of !if() as an initializer for the record at the next level of inheritance. Differential Revision: https://reviews.llvm.org/D42695 llvm-svn: 323807
-rw-r--r--llvm/include/llvm/TableGen/Record.h4
-rw-r--r--llvm/test/TableGen/if.td17
2 files changed, 20 insertions, 1 deletions
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 9736e015008..50477402a89 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -905,7 +905,9 @@ public:
// 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;
diff --git a/llvm/test/TableGen/if.td b/llvm/test/TableGen/if.td
index 05a2d992856..019e4dd1585 100644
--- a/llvm/test/TableGen/if.td
+++ b/llvm/test/TableGen/if.td
@@ -56,6 +56,23 @@ def D128: S<128>;
// 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];
OpenPOWER on IntegriCloud