Hi,
I want to use mlir-opt
pass and mlir-translate
pass to convert a mlir dialect to LLVM IR,but there are some problems so I need your help.
In short,the problem is how to convert an op named ‘switch’ to llvm dialect.
the source code is:
func @switch(%flag : i32, %caseOperand : i32) {
switch %flag : i32, [
default: ^bb1(%caseOperand : i32),
42: ^bb2(%caseOperand : i32),
43: ^bb3(%caseOperand : i32)
]
^bb1(%bb1arg : i32):
return
^bb2(%bb2arg : i32):
return
^bb3(%bb3arg : i32):
return
}
and I get it from llvm-project/mlir/test/Dialect/Standard.
So, I use ./mlir-opt --convert-std-to-llvm
and I get:
module attributes {llvm.data_layout = ""} {
llvm.func @switch(%arg0: i32, %arg1: i32) {
switch %arg0 : i32, [
default: ^bb1(%arg1 : i32),
42: ^bb2(%arg1 : i32),
43: ^bb3(%arg1 : i32)
]
^bb1(%0: i32): // pred: ^bb0
llvm.return
^bb2(%1: i32): // pred: ^bb0
llvm.return
^bb3(%2: i32): // pred: ^bb0
llvm.return
}
}
The ’switch’ op doesn’t change and I find it is llvm dialect op, but I don’t know which pass can I use.;(