I am a newest to MLIR and want to get a pass that can deal with some control flows in mlir like:
source.mlir:
func.func @test(%arg0:i32)->i32{
%c1_i32 = arith.constant 1 : i32
%c2_i32 = arith.constant 2 : i32
%0 = arith.cmpi sle, %arg0, %c2_i32 : i32
%1 = scf.if %0 -> (i32) {
scf.yield %c1_i32 : i32
} else {
scf.yield %c2_i32 : i32
}
return %1:i32
}
source1.mlir
func.func @test(%arg0:i32)->i32{
%c1_i32 = arith.constant 1 : i32
%c2_i32 = arith.constant 2 : i32
%0 = arith.cmpi sle, %arg0, %c2_i32 : i32
%true = arith.constant true
%false = arith.constant false
cond_br %0, ^bb1, ^bb2
^bb1 :
return %c1_i32:i32;
^bb2 :
return %c2_i32:i32;
}
Is there a universal API to deal with them in a common way? Like deal with graph? Or I only can implement twice?