[llvm-dev] Accessing TableGen defined variable in the cpp code

Sky Flyer via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 26 06:57:42 PST 2015


Hello all,

I would like to assign some bits in the instructions, based on the order of
mnemonics that appear in a special order. I can do it in TableGen itself,
but it will not be well maintainable based on the things I want to
accomplish.

Therefor, I would like to do it in the c++ file which is waaay easier (at
least in the concept!!).

Imagine I have this in my base class in TableGen:


*bits<4> bitpattern = 0;*
*let Inst{10-7} = bitpattern;*

Then, at the moment that I am parsing the instruction, I would like to
assign a value to "bitpattern" variable!
for example:

->ParseInstruction(...)
   if (Mnemonic == "X")
     Mnemonic = getLexer().getTok().getString();
     if (Mnemonic == "Y")
       *** let bitpattern = 0b1010" **  // How can I do this?*


How can I do this? Is it possible?

Cheers,
ES
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151126/354ac081/attachment.html>


More information about the llvm-dev mailing list