[Mlir-commits] [mlir] [mlir][EmitC] Create a pass to add a reflection map to a class (PR #205464)
ioana ghiban
llvmlistbot at llvm.org
Thu Jun 25 06:06:07 PDT 2026
================
@@ -60,4 +60,56 @@ def WrapFuncInClassPass : Pass<"wrap-emitc-func-in-class", "ModuleOp"> {
];
}
+def AddReflectionMapPass : Pass<"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
+ `field-attr-name` option) that is an array containing a single string
+ attribute.
+
+
+ Example:
----------------
ioghiban wrote:
I'm aware other dialect transformations include complete IR as well, but that might not be the easiest to decipher to get a grasp of what this rewrite does. For the full input/output of the pass one might check its tests. My suggestion is simplifying the example to pseudocode to the essential details to the rewrite.
https://github.com/llvm/llvm-project/pull/205464
More information about the Mlir-commits
mailing list