[LLVMdev] tablegen foreach question

Akira Hatanaka ahatanak at gmail.com
Fri Jun 7 15:41:03 PDT 2013


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]>;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130607/2be845d2/attachment.html>


More information about the llvm-dev mailing list