[Mlir-commits] [mlir] mlir: add an operation to EmitC for function template instantiation (PR #100895)
Rohan Yadav
llvmlistbot at llvm.org
Sat Jul 27 17:37:13 PDT 2024
================
@@ -1260,5 +1260,20 @@ def EmitC_SubscriptOp : EmitC_Op<"subscript", []> {
let assemblyFormat = "$value `[` $indices `]` attr-dict `:` functional-type(operands, results)";
}
+def EmitC_InstantiateFunctionTemplateOp : EmitC_Op<"instantiate_function_template", []> {
+ let summary = "Instantiate template operation";
+ let description = [{
+ Instantiate a function template with a given set of types
+ (given by the values as argument to this operation) to obtain
+ a function pointer.
+ }];
+ let arguments = (ins
+ Arg<StrAttr, "the C++ function to instantiate">:$callee,
----------------
rohany wrote:
In the case where the types are known inside of emitc, this operation is not actually needed (use of verbatim and string formatting with a `TypeRange`) would suffice. In the case that I'm considering, we need to derive the types from the SSA values themselves. For example, consider generating code using the CuTe C++ library. After a few layout transformations, only the C++ compiler knows the exact types of a CuTe object. In such a case, a `decltype` is needed to correctly instantiate the function template.
https://github.com/llvm/llvm-project/pull/100895
More information about the Mlir-commits
mailing list