mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-12 14:17:59 +00:00
cebb4ee93a
Add some data structures to represent for loops. These will be referenced during object processing to do any needed iteration and instantiation. Add foreach keyword support to the lexer. Add a mode to indicate that we're parsing a foreach loop. This allows the value parser to early-out when processing the foreach value list. Add a routine to parse foreach iteration declarations. This is separate from ParseDeclaration because the type of the named value (the iterator) doesn't match the type of the initializer value (the value list). It also needs to add two values to the foreach record: the iterator and the value list. Add parsing support for foreach. Add the code to process foreach loops and create defs based on iterator values. Allow foreach loops to be matched at the top level. When parsing an IDValue check if it is a foreach loop iterator for one of the active loops. If so, return a VarInit for it. Add Emacs keyword support for foreach. Add VIM keyword support for foreach. Add tests to check foreach operation. Add TableGen documentation for foreach. Support foreach with multiple objects. Support non-braced foreach body with one object. Do not require types for the foreach declaration. Assume the iterator type from the iteration list element type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151164 91177308-0d34-0410-b5e6-96231b3b80d8
278 lines
4.9 KiB
TableGen
278 lines
4.9 KiB
TableGen
// RUN: llvm-tblgen %s | FileCheck %s
|
|
// XFAIL: vg_leak
|
|
|
|
class Set<int i = 0, int j = 0, int k = 0> {
|
|
int I = i;
|
|
int J = j;
|
|
int K = k;
|
|
}
|
|
|
|
foreach i = [1, 2, 3] in {
|
|
def I1_#i : Set<i>;
|
|
foreach j = [1, 2, 3] in {
|
|
def I1_#i#_J1_#j : Set<i, j>;
|
|
}
|
|
def I2_#i : Set<i>;
|
|
foreach j = [4, 5, 6] in {
|
|
foreach k = [1, 2, 3] in {
|
|
def I3_#i#_J2_#j#_K1_#k : Set<i, j, k>;
|
|
}
|
|
def I4_#i#_J3_#j : Set<i, j>;
|
|
}
|
|
}
|
|
|
|
// CHECK: def I1_1
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 0;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_1_J1_1
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 1;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_1_J1_2
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 2;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_1_J1_3
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 3;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_2
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 0;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_2_J1_1
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 1;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_2_J1_2
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 2;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_2_J1_3
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 3;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_3
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 0;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_3_J1_1
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 1;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_3_J1_2
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 2;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I1_3_J1_3
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 3;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I2_1
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 0;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I2_2
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 0;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I2_3
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 0;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I3_1_J2_4_K1_1
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_1_J2_4_K1_2
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_1_J2_4_K1_3
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_1_J2_5_K1_1
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_1_J2_5_K1_2
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_1_J2_5_K1_3
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_1_J2_6_K1_1
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_1_J2_6_K1_2
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_1_J2_6_K1_3
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_2_J2_4_K1_1
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_2_J2_4_K1_2
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_2_J2_4_K1_3
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_2_J2_5_K1_1
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_2_J2_5_K1_2
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_2_J2_5_K1_3
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_2_J2_6_K1_1
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_2_J2_6_K1_2
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_2_J2_6_K1_3
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_3_J2_4_K1_1
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_3_J2_4_K1_2
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_3_J2_4_K1_3
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_3_J2_5_K1_1
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_3_J2_5_K1_2
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_3_J2_5_K1_3
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I3_3_J2_6_K1_1
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 1;
|
|
|
|
// CHECK: def I3_3_J2_6_K1_2
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 2;
|
|
|
|
// CHECK: def I3_3_J2_6_K1_3
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 3;
|
|
|
|
// CHECK: def I4_1_J3_4
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_1_J3_5
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_1_J3_6
|
|
// CHECK: int I = 1;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_2_J3_4
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_2_J3_5
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_2_J3_6
|
|
// CHECK: int I = 2;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_3_J3_4
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 4;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_3_J3_5
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 5;
|
|
// CHECK: int K = 0;
|
|
|
|
// CHECK: def I4_3_J3_6
|
|
// CHECK: int I = 3;
|
|
// CHECK: int J = 6;
|
|
// CHECK: int K = 0;
|