LLVM Discussion Forums

MLIR: Using types defined in C++ in tablegen

Hi, I have declared a type SomeType using the C++ API, in a file sometype.h in MLIR.

How can I use this type in a tablegen file? I can’t figure out how to include the declaration.

You need to define an instance of a Type class in tablegen, https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/IR/OpBase.td#L288. Here’s for example how it is done for FunctionType https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/IR/OpBase.td#L484.

Thank you, exactly what I was looking for! I was digging around in that file but couldn’t find it exactly.