[Mlir-commits] [mlir] [mlir][emitc] Add ArrayType (PR #83386)
Simon Camphausen
llvmlistbot at llvm.org
Wed Mar 6 09:02:27 PST 2024
================
@@ -16,16 +16,64 @@
include "mlir/IR/AttrTypeBase.td"
include "mlir/Dialect/EmitC/IR/EmitCBase.td"
+include "mlir/IR/BuiltinTypeInterfaces.td"
//===----------------------------------------------------------------------===//
// EmitC type definitions
//===----------------------------------------------------------------------===//
-class EmitC_Type<string name, string typeMnemonic>
- : TypeDef<EmitC_Dialect, name> {
+class EmitC_Type<string name, string typeMnemonic, list<Trait> traits = []>
+ : TypeDef<EmitC_Dialect, name, traits> {
let mnemonic = typeMnemonic;
}
+def EmitC_ArrayType : EmitC_Type<"Array", "array", [ShapedTypeInterface]> {
+ let summary = "EmitC array type";
+
+ let description = [{
+ An array data type.
+
+ Example:
+
+ ```mlir
+ // Array emitted as `int32_t[10]`
+ !emitc.array<10xi32>
+ // Array emitted as `float[10][20]`
+ !emitc.ptr<10x20xf32>
+ ```
+ }];
+
+ let parameters = (ins
+ ArrayRefParameter<"int64_t">:$shape,
+ "Type":$elementType
+ );
+
+ let builders = [
+ TypeBuilderWithInferredContext<(ins
+ "ArrayRef<int64_t>":$shape,
+ "Type":$elementType
+ ), [{
+ return $_get(elementType.getContext(), shape, elementType);
+ }]>
+ ];
+ let extraClassDeclaration = [{
+ /// Returns if this type is ranked (always true).
+ bool hasRank() const { return true; }
+
+ /// Clone this vector type with the given shape and element type. If the
----------------
simon-camp wrote:
```suggestion
/// Clone this array type with the given shape and element type. If the
```
https://github.com/llvm/llvm-project/pull/83386
More information about the Mlir-commits
mailing list