<div dir="ltr">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.<div>
<br></div><div>Joe</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 5, 2013 at 2:01 PM, Joe Matarazzo <span dir="ltr"><<a href="mailto:joe.matarazzo@gmail.com" target="_blank">joe.matarazzo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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:<div>
<br></div><div>=========================================</div><div>class LookupTable {</div>
<div>  list<int> mapping = [0, 8, 16, 24, 32];</div><div>}</div><div><br></div><div>def LUT : LookupTable;</div><div><br></div><div>class MyRegister<name, index> : Register<name> {</div><div>   let HWEncoding = LUT.mapping[index];</div>

<div>   </div><div>   int otherVal = index;  // required as well, ie. 'unmapped'</div><div>}</div><div><br></div><div>foreach reg 0-32 in {</div><div>  def R#reg : MyRegister<!subst("X", reg, "rX"), reg>;</div>

<div>}</div><div>==========================================</div><div><br></div><div>TableGen complains that index is not an integer or bitrange in LUT.mapping[index].</div><div><br></div><div>Thanks,</div><div>Joe</div>
</div>
</blockquote></div><br></div>