[llvm-dev] tablegen generated enums in tablegen
Nicolai Hähnle via llvm-dev
llvm-dev at lists.llvm.org
Mon Jun 29 04:05:14 PDT 2020
Hi Chris,
On Sun, Jun 28, 2020 at 9:37 AM Chris Sears via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I'd like to store a tablegen generated enumeration in a record field/value. Clearly this enumeration isn't available yet so it seems that a code fragment should be the escape mechanism I need.
I don't think this is clear at all. Maybe you can explain what you're
trying to do and why simply using the enumeration fails?
[snip]
> So I think that this would look something like:
>
> int reg_index = -1;
> ...
> let reg_index = [{ return XX::R8; }]; // or
> let reg_index = [{ {XX::R8} }];
>
> However, then I get errors of the form:
>
> error: Value 'reg_index' of type 'int' is incompatible with initializer '[{ {XX::R8} }]' of type 'code'
> error: Value 'reg_index' of type 'int' is incompatible with initializer '[{ return XX::R8; }]' of type 'code'
Well, yes. [{ }] is really just more convenient syntax for strings
that are meant to contain code snippets, and you can't assign a string
to an integer :) Those code snippets aren't executed by TableGen,
they're pasted into TableGen-generated C++ and only executed at
runtime.
Why doesn't
let reg_index = R8;
or whatever work, if R8 is an object known to TableGen?
Cheers,
Nicolai
>
> Is there a way of doing this? I don't understand TableGen casting but is that necessary?
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
Lerne, wie die Welt wirklich ist,
aber vergiss niemals, wie sie sein sollte.
More information about the llvm-dev
mailing list