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

Gil Rapaport llvmlistbot at llvm.org
Tue Jul 30 08:07:23 PDT 2024


================
@@ -1260,5 +1260,32 @@ 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.
+
+    Example:
+
+    ```mlir
+    %c1 = "emitc.constant"() <{value = 7 : i32}> : () -> i32
+    %0 = emitc.instantiate_function_template "func_template"<%c1> : (i32) -> !emitc.ptr<!emitc.opaque<"void">>
+    ```
+    Translates to the C++:
+    ```c++
+    int32_t v1 = 7;
+    void* v2 = &func_template<decltype(v1)>;
----------------
aniragil wrote:

Could we separate the application of template instantiation from taking its address (which emitc has an op for)?

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


More information about the Mlir-commits mailing list