[Mlir-commits] [mlir] mlir: add an operation to EmitC for function template instantiation (PR #100895)

Christopher Bate llvmlistbot at llvm.org
Sat Jul 27 13:07:18 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,
----------------
christopherbate wrote:

Why do you need to derive the type from an SSA value? Why not instead use an ArrayAttr (of TypeAttr) directly here? Is there really a use case where it is difficult to infer that information? When you create this operation, you would could just have a builder with an API like ` b.create<InstatiateFunctionTemplateOp>(loc, TypeRange(args))` in order to create an ArrayAttr containing all the types.

https://github.com/llvm/llvm-project/pull/100895


More information about the Mlir-commits mailing list