Skip to content

Conversation

@makslevental
Copy link
Contributor

@makslevental makslevental commented Jan 18, 2026

This is kind of a niche PR so I don't expect anyone to really closely review but I'm describing it anyway just to capture some findings.

The basic feature added in this PR is the ability to recover from an instantiated def which template args were used in the class call/invocation/thing. E.g.,

class Test_Op<string mnemonic, list<Trait> traits = []>
    : Op<Test_Dialect, mnemonic, traits>;

def Test_AndOp : Test_Op<"and"> { ... }

With this PR you can recover that the mnemonic passed as the first argument to Test_Op when instantiating Test_AndOp is "and". This sounds like something that should've been always possible but turns out tablegen literally doesn't keep that information in any way/shape/form. In order to make this work I had to hack the parser to keep it around (note, this isn't completely straightforward because arguments can have unevaluated bang operators).

For context, I intended on using this functionality to translate LLVM Intrinsics into MLIR OpDefs but turns out it didn't really work out (not because the feature doesn't work but because I have ~30k Intrinsics lol).

@makslevental makslevental force-pushed the users/makslevental/extend-eudl-tblgen branch 8 times, most recently from e4def7a to d8c910b Compare January 22, 2026 02:22
@makslevental makslevental force-pushed the users/makslevental/extend-eudl-tblgen branch from d8c910b to 5447a34 Compare January 26, 2026 02:58
@makslevental makslevental force-pushed the users/makslevental/extend-eudl-tblgen branch from 5447a34 to a2ab271 Compare January 26, 2026 03:23
@makslevental makslevental marked this pull request as ready for review January 26, 2026 03:23
@makslevental makslevental merged commit c349c34 into main Jan 26, 2026
175 of 176 checks passed
@makslevental makslevental deleted the users/makslevental/extend-eudl-tblgen branch January 26, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants