[Mlir-commits] [mlir] [mlir][LLVM] Add operand bundle support (PR #108933)

Markus Böck llvmlistbot at llvm.org
Thu Sep 19 07:48:31 PDT 2024


================
@@ -1875,21 +1888,33 @@ def LLVM_InlineAsmOp : LLVM_Op<"inline_asm", [DeclareOpInterfaceMethods<MemoryEf
 
 def LLVM_CallIntrinsicOp
     : LLVM_Op<"call_intrinsic",
-              [DeclareOpInterfaceMethods<FastmathFlagsInterface>]> {
+              [AttrSizedOperandSegments,
+               DeclareOpInterfaceMethods<FastmathFlagsInterface>]> {
   let summary = "Call to an LLVM intrinsic function.";
   let description = [{
     Call the specified llvm intrinsic. If the intrinsic is overloaded, use
     the MLIR function type of this op to determine which intrinsic to call.
   }];
   let arguments = (ins StrAttr:$intrin, Variadic<LLVM_Type>:$args,
                        DefaultValuedAttr<LLVM_FastmathFlagsAttr,
-                                         "{}">:$fastmathFlags);
+                                         "{}">:$fastmathFlags,
+                       VariadicOfVariadic<LLVM_Type,
+                                          "op_bundle_sizes">:$op_bundle_operands,
+                       DenseI32ArrayAttr:$op_bundle_sizes,
+                       OptionalProperty<
+                         ArrayProperty<StringProperty, "operand bundle tags">
+                       >:$op_bundle_tags);
   let results = (outs Optional<LLVM_Type>:$results);
   let llvmBuilder = [{
     return convertCallLLVMIntrinsicOp(op, builder, moduleTranslation);
   }];
   let assemblyFormat = [{
-    $intrin `(` $args `)` `:` functional-type($args, $results) attr-dict
+    $intrin `(` $args `)`
+    ( `bundlearg` `(` $op_bundle_operands^ `)` )?
+    ( `bundletag` `(` $op_bundle_tags^ `)` )?
+    `:` functional-type($args, $results)
+    ( `bundletype` `(` type($op_bundle_operands)^ `)` )?
----------------
zero9178 wrote:

Not sure how others feel about this, but I think I'd be nice to align the syntax relatively close to LLVM IR syntax and less error prone. Changing the syntax later would be somewhat difficult as well, so we probably want to get this right from the beginning.

What are your thoughts about the syntax:
```
operand bundle set ::= '[' operand bundle (, operand bundle )* ']'
operand bundle ::= $op_bundle_tags[i] '(' $op_bundle_operands[i] ':' type($op_bundle_operands[i]) ')'
```
I would place this right after the call arguments.
We could achieve this here in the assembly format using:
```suggestion
    $intrin `(` $args `)`
    (custom<OpBundles>($op_bundle_operands, $op_bundle_tags)^)?
    `:` functional-type($args, $results)
```
The `printOpBundles` and `parseOpBundles` (returning `OptionalResult`) functions that will need to be implemented can also be used in the implementations of call and invoke op for their syntax.

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


More information about the Mlir-commits mailing list