[LLVMdev] TableGen lookup table recipe?

Joe Matarazzo
Wed, 05 Jun 2013 21:01:06 -0000

Is it possible to define lookup tables as a list in tablegen, to map one
value to another? Here's the template I was working on:

========================================class LookupTable {
  list<int> mapping = [0, 8, 16, 24, 32];
}

def LUT : LookupTable;

class MyRegister<name, index> : Register<name> {
   let HWEncoding = LUT.mapping[index];

   int otherVal = index;  // required as well, ie. 'unmapped'
}

foreach reg 0-32 in {
  def R#reg : MyRegister<!subst("X", reg, "rX"), reg>;
}
=========================================
TableGen complains that index is not an integer or bitrange in
LUT.mapping[index].

Thanks,
Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130605/92864aff/attachment.html>