Llvm dialect lowering and constantOp

hey folks, I was reading 'llvm' Dialect - MLIR , it says modules can contain any operations but when I use the following IR:

module @user  {
  %0 = llvm.mlir.constant(4 : i64) : i64
  %1 = llvm.mlir.constant(80 : i64) : i64

I get:

'llvm.mlir.constant' op unsupported module-level operation

What am I missing here?

The module can indeed contain any operation. Anything at all really, it might be "my_crazy_dialect.do_rm_rf"() : () -> ().

The translation to LLVM IR (which is what you actually ran, this IR is perfectly valid and would roundtrip just fine) only supports certain operations and requires a structure that matches both MLIR and LLVM IR expectations. In MLIR, constants are defined as SSA values and are translated locally within each function.

1 Like