[LLVMdev] TableGen lookup table recipe?

Joe Matarazzo
Wed, 05 Jun 2013 21:03:27 -0000

Oh, I botched my example when I tried to simplify it for the mail list.
Presume instead that the foreach loop is 0..4 so that you stay in-bounds on
the LUT mapping. You can see how it could be expanded for a larger range,
of course.

Joe


On Wed, Jun 5, 2013 at 2:01 PM, Joe Matarazzo <joe.matarazzo at
gmail.com>wrote:

> 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/6684c901/attachment.html>