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

    <tr>
        <th>Summary</th>
        <td>
            how to define a 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/eJy8WN1u47oRfhr6hoghU1bsXPhC8U8RIHvOYuOi6FVASyOLPRSpkpQd9-mLISVZyiYn3hY4wCIrUcP54_fNDM2tFUcFsCLJI0k2E964UpvVS8n_3Qgp4e4fzeSg88uqBCk1YWsq5aki7L6SwlB4q8E4S6L0iZb8BJR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