<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/125174>125174</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            how to define an array in mlir?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Shaquille-Wu
      </td>
    </tr>
</table>

<pre>
    hello, llvm&mlir experts
I have a trouble about defining a array in mlir.
first, I define a Dialect named as lunar, it is very simple dialect like this in .td file:
```
#ifndef LIB_DIALECT_LUNAR_LUNARDIALECT_TD_
#define LIB_DIALECT_LUNAR_LUNARDIALECT_TD_

include "mlir/IR/OpBase.td"

def Lunar_Dialect : Dialect {
  let name = "lunar";
  let summary = "A dialect for elementwise math";
  let description = [{
    The lunar dialect defines types and operations for elementwise computation.
  }];

 let cppNamespace = "::mlir::lunar";
  let useDefaultTypePrinterParser = 1;
}

#endif  // LIB_DIALECT_LUNAR_LUNARDIALECT_TD_
```
second, I define a datatype named as "array" in another .td file, like this:
```
#ifndef LIB_DIALECT_LUNAR_LUNARTYPES_TD_
#define LIB_DIALECT_LUNAR_LUNARTYPES_TD_

include "LunarDialect.td"
include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/BuiltinTypes.td"
include "mlir/IR/BuiltinTypeInterfaces.td"

// A base class for all types in this dialect
class Lunar_Type<string name, string typeMnemonic, list<Trait> traits = []> : TypeDef<Lunar_Dialect, name, traits> {
  let mnemonic = typeMnemonic;
}

def ArrayData : Lunar_Type<"ArrayData", "array"> {
 let summary = "A array data";

  let description = [{
    A type for array.
  }];

  let parameters = (ins "Type":$dataType, "int":$size);
  let assemblyFormat = [{ `<` $dataType `x` $size `>` }];
}

#endif  // LIB_DIALECT_LUNAR_LUNARTYPES_TD_
```
the third, I modify my the .cpp file about LunarDialect like this:
```
#include "LunarDialect.h"
#include "LunarTypes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/TypeSwitch.h"
#include "Dialect/Lunar/LunarDialect.cpp.inc"

#define GET_TYPEDEF_CLASSES
#include "Dialect/Lunar/LunarTypes.cpp.inc"

namespace mlir {
namespace lunar {

void LunarDialect::initialize() {
  addTypes<
#define GET_TYPEDEF_LIST
#include "Dialect/Lunar/LunarTypes.cpp.inc"
 >();
}

} // namespace poly
} // namespace mlir

```
the forth, I modify my verify tool(named as "lunar-opt"), and the .cpp file like this:
```
#include "mlir/InitAllDialects.h"
#include "mlir/InitAllPasses.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Pass/PassRegistry.h"
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
#include "Dialect/Lunar/LunarDialect.h"

int main(int argc, char **argv) {
 mlir::DialectRegistry registry;
 registry.insert<mlir::lunar::LunarDialect>();
 mlir::registerAllDialects(registry);
  mlir::registerAllPasses();

 return mlir::asMainReturnCode(
      mlir::MlirOptMain(argc, argv, "lunar_opt Pass Driver", registry));
}
```
at last, I execute the "lunar-opt", and it throws the errors as following:
```
lunar_test_0.mlir:2:39: error: expected non-function type
 func.func @main(%arg0: !lunar.array<i32x10>) -> !lunar.array<i32x10> {
 ^
lunar_test_0.mlir:2:39: error: failed to parse ArrayData parameter 'dataType' which is to be a `Type`
  func.func @main(%arg0: !lunar.array<i32x10>) -> !lunar.array<i32x10> {
```

I guess the "i32" is not in the enums of mlir.Type according to above errors, 
I don't know why the mlir cannot accept the "i32"

So, is there anyone would like to teach me how to fix this trouble?


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8WN1u47oRfhr6hoghU3FsX_hC8U8RIHvOYuOi6FVAiyOLPRSpkpQd9-mLISVbyiYn3hY4wCIrUcP54_fNDM2dkwcNsCTTRzJdj3jjS2OXLyX_dyOVgrt_NKO9EedlCUoZwlZUqWNF2EOlpKXwVoP1jiTZEy35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