[Mlir-commits] [mlir] [MLIR] EmitC: Add subscript operator (PR #84783)

Simon Camphausen llvmlistbot at llvm.org
Thu Mar 14 02:35:00 PDT 2024


================
@@ -1125,4 +1125,36 @@ def EmitC_IfOp : EmitC_Op<"if",
   let hasCustomAssemblyFormat = 1;
 }
 
+def EmitC_SubscriptOp : EmitC_Op<"subscript",
+  [TypesMatchWith<"result type matches element type of 'array'",
+                  "array", "result",
+                  "::llvm::cast<ArrayType>($_self).getElementType()">]> {
+  let summary = "Array subscript operation";
+  let description = [{
+    With the `subscript` operation the subscript operator `[]` can be applied
+    to variables or arguments of array type.
+
+    Example:
+
+    ```mlir
+    %i = index.constant 1
+    %j = index.constant 7
+    %0 = emitc.subscript %arg0[%i][%j] : (!emitc.array<4x8xf32>) -> f32
+    ```
+  }];
+  let arguments = (ins Arg<EmitC_ArrayType, "the reference to load from">:$array,
+                       Variadic<Index>:$indices);
----------------
simon-camp wrote:

Use `IntegerIndexOrOpaqueType` here.

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


More information about the Mlir-commits mailing list