tablegen foreach question

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

def StrList {
list ls = [“A”, “B”, “C”, “D”];

class Base0 {
int I = i;

class Base1 {
string S1 = s;

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

$ llvm-tblgen error: expected integer or bitrange
def D#i: Base0, Base1<[i]>;

Akira Hatanaka <> writes:

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

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

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

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