summaryrefslogtreecommitdiffstats
path: root/llvm/test/TableGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/TableGen')
-rw-r--r--llvm/test/TableGen/foreach-range-parse-errors0.td19
-rw-r--r--llvm/test/TableGen/foreach-range-parse-errors1.td8
-rw-r--r--llvm/test/TableGen/foreach-range-parse-errors2.td13
-rw-r--r--llvm/test/TableGen/foreach-range-parse-errors3.td8
-rw-r--r--llvm/test/TableGen/foreach-range-parse-errors4.td9
-rw-r--r--llvm/test/TableGen/foreach-range-parse-errors5.td8
-rw-r--r--llvm/test/TableGen/foreach-variable-range.td128
7 files changed, 193 insertions, 0 deletions
diff --git a/llvm/test/TableGen/foreach-range-parse-errors0.td b/llvm/test/TableGen/foreach-range-parse-errors0.td
new file mode 100644
index 00000000000..a3e6a9eb975
--- /dev/null
+++ b/llvm/test/TableGen/foreach-range-parse-errors0.td
@@ -0,0 +1,19 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck -DFILE=%s %s
+
+class ConstantsImpl {
+ int Zero = 0;
+ int One = 1;
+ int Two = 2;
+ int Three = 3;
+ int Five = 5;
+}
+
+def Constants : ConstantsImpl;
+
+// CHECK-NOT: error: Unknown token when parsing a value
+// CHECK: [[FILE]]:[[@LINE+3]]:22: error: Unknown token when parsing a value
+// CHECK: [[FILE]]:[[@LINE+2]]:22: error: expected integer value as end of range
+// CHECK: [[FILE]]:[[@LINE+1]]:22: error: expected declaration in for
+foreach Index = 0 - in {
+
+}
diff --git a/llvm/test/TableGen/foreach-range-parse-errors1.td b/llvm/test/TableGen/foreach-range-parse-errors1.td
new file mode 100644
index 00000000000..5461a77703b
--- /dev/null
+++ b/llvm/test/TableGen/foreach-range-parse-errors1.td
@@ -0,0 +1,8 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck -DFILE=%s %s
+
+// CHECK: [[FILE]]:[[@LINE+2]]:20: error: invalid range, cannot be negative
+// CHECK: [[FILE]]:[[@LINE+1]]:20: error: expected declaration in for
+foreach Index = -1 - 0 in {
+
+}
+
diff --git a/llvm/test/TableGen/foreach-range-parse-errors2.td b/llvm/test/TableGen/foreach-range-parse-errors2.td
new file mode 100644
index 00000000000..7717c10aaf6
--- /dev/null
+++ b/llvm/test/TableGen/foreach-range-parse-errors2.td
@@ -0,0 +1,13 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck -DFILE=%s %s
+
+class ConstantsImpl {
+ int NegOne = -1;
+}
+
+def Constants : ConstantsImpl;
+
+// CHECK: [[FILE]]:[[@LINE+2]]:38: error: invalid range, cannot be negative
+// CHECK: [[FILE]]:[[@LINE+1]]:38: error: expected declaration in for
+foreach Index = 0 - Constants.NegOne in {
+
+}
diff --git a/llvm/test/TableGen/foreach-range-parse-errors3.td b/llvm/test/TableGen/foreach-range-parse-errors3.td
new file mode 100644
index 00000000000..0a282c36099
--- /dev/null
+++ b/llvm/test/TableGen/foreach-range-parse-errors3.td
@@ -0,0 +1,8 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck -DFILE=%s %s
+
+// CHECK: [[FILE]]:[[@LINE+2]]:21: error: expected integer or bitrange
+// CHECK: [[FILE]]:[[@LINE+1]]:21: error: expected declaration in for
+foreach Index = "0" - 1 in {
+
+}
+
diff --git a/llvm/test/TableGen/foreach-range-parse-errors4.td b/llvm/test/TableGen/foreach-range-parse-errors4.td
new file mode 100644
index 00000000000..6072b9b589d
--- /dev/null
+++ b/llvm/test/TableGen/foreach-range-parse-errors4.td
@@ -0,0 +1,9 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck -DFILE=%s %s
+// Make sure there is no crash on undefined variable
+
+// CHECK: [[FILE]]:[[@LINE+2]]:17: error: Variable not defined: 'foo'
+// CHECK: [[FILE]]:[[@LINE+1]]:21: error: expected declaration in for
+foreach Index = foo in {
+ def arst#Index;
+}
+
diff --git a/llvm/test/TableGen/foreach-range-parse-errors5.td b/llvm/test/TableGen/foreach-range-parse-errors5.td
new file mode 100644
index 00000000000..835bb7a74be
--- /dev/null
+++ b/llvm/test/TableGen/foreach-range-parse-errors5.td
@@ -0,0 +1,8 @@
+// RUN: not llvm-tblgen %s 2>&1 | FileCheck -DFILE=%s %s
+
+// CHECK: [[FILE]]:[[@LINE+2]]:23: error: expected integer or bitrange
+// CHECK: [[FILE]]:[[@LINE+1]]:23: error: expected declaration in for
+foreach Index = 0b110 - 0b111 in {
+
+}
+
diff --git a/llvm/test/TableGen/foreach-variable-range.td b/llvm/test/TableGen/foreach-variable-range.td
new file mode 100644
index 00000000000..3ddb2c08ff2
--- /dev/null
+++ b/llvm/test/TableGen/foreach-variable-range.td
@@ -0,0 +1,128 @@
+// RUN: llvm-tblgen %s
+
+class ConstantsImpl {
+ int Zero = 0;
+ int One = 1;
+ int Two = 2;
+ int Three = 3;
+ int Five = 5;
+}
+
+def Constants : ConstantsImpl;
+
+// CHECK-DAG: def var_bound_whitespaceA0
+// CHECK-DAG: def var_bound_whitespaceA1
+// CHECK-DAG: def var_bound_whitespaceA2
+foreach Index = Constants.Zero - Constants.Two in {
+ def var_bound_whitespaceA#Index;
+}
+
+// CHECK-DAG: def var_bound_whitespaceB0
+// CHECK-DAG: def var_bound_whitespaceB1
+// CHECK-DAG: def var_bound_whitespaceB2
+foreach Index = Constants.Zero-Constants.Two in {
+ def var_bounds_whitespaceB#Index;
+}
+
+// CHECK-DAG: def var_bound_whitespaceC0
+// CHECK-DAG: def var_bound_whitespaceC1
+// CHECK-DAG: def var_bound_whitespaceC2
+foreach Index = Constants.Zero -Constants.Two in {
+ def var_bounds_whitespaceC#Index;
+}
+
+// CHECK-DAG: def var_bound_whitespaceD0
+// CHECK-DAG: def var_bound_whitespaceD1
+// CHECK-DAG: def var_bound_whitespaceD2
+foreach Index = Constants.Zero- Constants.Two in {
+ def var_bounds_whitespaceD#Index;
+}
+
+// CHECK-DAG: def const_lower_whitespaceA0
+// CHECK-DAG: def const_lower_whitespaceA1
+// CHECK-DAG: def const_lower_whitespaceA2
+foreach Index = 0 - Constants.Two in {
+ def const_lower_whitespaceA#Index;
+}
+
+// CHECK-DAG: def const_lower_whitespaceB0
+// CHECK-DAG: def const_lower_whitespaceB1
+// CHECK-DAG: def const_lower_whitespaceB2
+foreach Index = 0-Constants.Two in {
+ def const_lower_whitespaceB#Index;
+}
+
+// CHECK-DAG: def const_lower_whitespaceC0
+// CHECK-DAG: def const_lower_whitespaceC1
+// CHECK-DAG: def const_lower_whitespaceC2
+foreach Index = 0 -Constants.Two in {
+ def const_lower_whitespaceC#Index;
+}
+
+// CHECK-DAG: def const_lower_whitespaceD0
+// CHECK-DAG: def const_lower_whitespaceD1
+// CHECK-DAG: def const_lower_whitespaceD2
+foreach Index = 0- Constants.Two in {
+ def const_lower_whitespaceD#Index;
+}
+
+// CHECK-DAG: def const_upper_whitespaceA0
+// CHECK-DAG: def const_upper_whitespaceA1
+// CHECK-DAG: def const_upper_whitespaceA2
+foreach Index = Constants.Zero - 2 in {
+ def const_upper_whitespaceA#Index;
+}
+
+// CHECK-DAG: def const_upper_whitespaceB0
+// CHECK-DAG: def const_upper_whitespaceB1
+// CHECK-DAG: def const_upper_whitespaceB2
+foreach Index = Constants.Zero-2 in {
+ def const_upper_whitespaceB#Index;
+}
+
+// CHECK-DAG: def const_upper_whitespaceC0
+// CHECK-DAG: def const_upper_whitespaceC1
+// CHECK-DAG: def const_upper_whitespaceC2
+foreach Index = Constants.Zero -2 in {
+ def const_upper_whitespaceC#Index;
+}
+
+// CHECK-DAG: def const_upper_whitespaceD0
+// CHECK-DAG: def const_upper_whitespaceD1
+// CHECK-DAG: def const_upper_whitespaceD2
+foreach Index = Constants.Zero- 2 in {
+ def const_upper_whitespaceD#Index;
+}
+
+// CHECK-DAG: def multi_rangeA0
+// CHECK-DAG: def multi_rangeA1
+// CHECK-DAG: def multi_rangeA2
+// CHECK-DAG: def multi_rangeA3
+foreach Index = {Constants.Zero-Constants.One, Constants.Two-Constants.Three} in {
+ def multi_rangeA#Index;
+}
+
+// CHECK-DAG: def multi_rangeB0
+// CHECK-DAG: def multi_rangeB1
+// CHECK-DAG: def multi_rangeB3
+// CHECK-DAG: def multi_rangeB4
+// CHECK-DAG: def multi_rangeB5
+foreach Index = {0-Constants.One, Constants.Three-Constants.Five} in {
+ def multi_rangeB#Index;
+}
+
+// CHECK-DAG: def multi_rangeC0
+// CHECK-DAG: def multi_rangeC1
+// CHECK-DAG: def multi_rangeC2
+// CHECK-DAG: def multi_rangeC3
+foreach Index = {0-Constants.One, 2-Constants.Three} in {
+ def multi_rangeC#Index;
+}
+
+// CHECK-DAG: def multi_rangeD0
+// CHECK-DAG: def multi_rangeD1
+// CHECK-DAG: def multi_rangeD2
+// CHECK-DAG: def multi_rangeD3
+foreach Index = {0-1, Constants.Two-3} in {
+ def multi_rangeD#Index;
+}
OpenPOWER on IntegriCloud