tablegen foreach question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

tablegen foreach question

Akira Hatanaka
What's the best (most concise) way to create the following four defs?

D0 = (0, "A")
D1 = (1, "B")
D2 = (2, "C")
D3 = (3, "D")

I tried to use list of strings and the foreach construct, but apparently tablegen doesn't allow using identifiers to access array elements.

$ cat tbl3.td

def StrList {
  list<string> ls = ["A", "B", "C", "D"];
}

class Base0<int i> {
  int I = i;
}

class Base1<string s> {
  string S1 = s;
}

foreach i = 0-3 in
def D#i: Base0<i>, Base1<StrList.ls[i]>;

$ llvm-tblgen tbl3.td
tbl3.td:15:37: error: expected integer or bitrange
def D#i: Base0<i>, Base1<StrList.ls[i]>;


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: tablegen foreach question

greened
Akira Hatanaka <[hidden email]> writes:

> foreach i = 0-3 in
> def D#i: Base0<i>, Base1<StrList.ls[i]>;

I can't recall if this works but you might try:

def D#i: Base0<i>, Base1<StrList.ls[#i]>;

That is, paste the value of i against an empty string.

                       -David
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev