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

Sky Flyer via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 27 03:55:40 PST 2015


Hi Tom,

each "X" has a unique bitpattern that should be assigned to the Inst.
e.g:
X1 = 0001
X2 = 0010
....

Imagine X as a predicate and Y as the Instruction Mnemonic.
If this is the answer to your question.

On Thu, Nov 26, 2015 at 4:15 PM, Tom Stellard <tom at stellard.net> wrote:

> On Thu, Nov 26, 2015 at 03:57:42PM +0100, Sky Flyer via llvm-dev wrote:
> > 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?
> >
>
> One thing you might be able to do is add 'bitpattern' as an instruction
> operand.
> Does each instruction always have the same bitpattern?
>
> -Tom
>
> > Cheers,
> > ES
>
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151127/75252d87/attachment.html>


More information about the llvm-dev mailing list