[Mlir-commits] [mlir] [mlir][EmitC] Create a pass to add a reflection map to a class (PR #205464)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Thu Jul 16 11:48:36 PDT 2026
================
@@ -60,4 +60,49 @@ def WrapFuncInClassPass : Pass<"wrap-emitc-func-in-class", "ModuleOp"> {
];
}
+def MLGOAddReflectionMapPass : Pass<"mlgo-add-reflection-map", "ModuleOp"> {
+ let summary = "Add a reflection map and a helper method to EmitC classes for runtime field lookup.";
+ let description = [{
+ This pass adds a `reflectionMap` field and an accompanying `getBufferForName` method to
+ EmitC classes, enabling runtime lookup of class fields by name.
+ This requires that the class has fields with attributes.
+ Each `emitc.field` is expected to have an attribute (configured by the
+ `included-field-attrs` option) that is an array containing a single string
+ attribute. If a field possesses both an attribute specified by
+ `included-field-attrs` and an attribute specified in `excluded-field-attrs`,
+ the `included-field-attrs` attribute takes precedence and the field will be
+ included in the reflection map.
----------------
banach-space wrote:
This is a bit confusing.
1. Why is `included-field-attrs` given precedence? That's very arbitrary. Why doesn't the pass prioritise in the order of specification? Or, select the right-most one (i.e. the last one that was added).
2. Do we really need both attributes? I would expect `included-field-attrs` to be sufficient to model everything that is required.
My suggestion - remove `excluded-field-attrs` and keep `included-field-attrs`. Based on the tests taht I have seen, one set should be enough. Everything else that is not listed in `included-field-attrs` should be ignored. Will that work?
https://github.com/llvm/llvm-project/pull/205464
More information about the Mlir-commits
mailing list