Chris Sears via llvm-dev
2020-Jun-27 17:49 UTC
[llvm-dev] tablegen generated enums in tablegen
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. Looking at the other backends for examples, I see things like [{ return Imm >= 0 && Imm < 64; }] // promising code Requires = [{ {} }]; // this looks like a string let Requires = [{ {AArch64::FeatureETE} }]. // which is not promising 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' Is there a way of doing this? I don't understand TableGen casting but is that necessary? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200627/d3708019/attachment.html>
Chris Sears via llvm-dev
2020-Jun-28 16:06 UTC
[llvm-dev] tablegen generated enums in tablegen
I figured out the answer to my problem. I use const MCInstrDesc desc MCII->get(x) to get the same information. It's just that I was writing TableGen descriptions and so I thought the answer would be in TableGen. On Sat, Jun 27, 2020 at 10:49 AM Chris Sears <chris.sears at gmail.com> 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. Looking at the other > backends for examples, I see things like > > [{ return Imm >= 0 && Imm < 64; }] // promising > code Requires = [{ {} }]; // this looks > like a string > let Requires = [{ {AArch64::FeatureETE} }]. // which is not promising > > 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' > > Is there a way of doing this? I don't understand TableGen casting but is > that necessary? >-- Ite Ursi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200628/506e3390/attachment-0001.html>
Nicolai Hähnle via llvm-dev
2020-Jun-29 11:05 UTC
[llvm-dev] tablegen generated enums in tablegen
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.
Hal Finkel via llvm-dev
2020-Jun-30 02:39 UTC
[llvm-dev] tablegen generated enums in tablegen
As a generic note, I don't believe that there are many places within TableGen's set of code generators that handle 'code' values as pass-through in the way you hint at below. One place that does is SearchableTable/GenericTable field values, and that is pretty useful. -Hal On 6/28/20 11:06 AM, Chris Sears via llvm-dev wrote:> I figured out the answer to my problem. I use const MCInstrDesc desc > = MCII->get(x) to get the same information. It's just that I was > writing TableGen descriptions and so I thought the answer would be in > TableGen. > > On Sat, Jun 27, 2020 at 10:49 AM Chris Sears <chris.sears at gmail.com > <mailto:chris.sears at gmail.com>> 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. > Looking at the other backends for examples, I see things like > > [{ return Imm >= 0 && Imm < 64; }] // promising > code Requires = [{ {} }]; // this > looks like a string > let Requires = [{ {AArch64::FeatureETE} }]. // which is not promising > > So I thinkthat this would look something like: > > int reg_index = -1; > ... > let reg_index = [{ return XX::R8; }]; // or > let reg_index = [{ {XX::R8} }]; > > However, thenIget 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' > > Is there a way of doing this? I don't understand TableGen casting > but is that necessary? > > > > -- > Ite Ursi > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- Hal Finkel Lead, Compiler Technology and Programming Languages Leadership Computing Facility Argonne National Laboratory -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200629/495eda59/attachment.html>