This dialect is intended to model lower level/branch based control-flow constructs. The initial set of operations are: AssertOp, BranchOp, CondBranchOp, SwitchOp; all split out from the current standard dialect. See https://discourse.llvm.org/t/standard-dialect-the-final-chapter/6061 Differential Revision: https://reviews.llvm.org/D118966
41 lines
891 B
MLIR
41 lines
891 B
MLIR
// RUN: mlir-opt %s | mlir-opt | FileCheck %s
|
|
// RUN: mlir-opt %s --mlir-print-op-generic | mlir-opt | FileCheck %s
|
|
|
|
// CHECK-LABEL: @assert
|
|
func @assert(%arg : i1) {
|
|
cf.assert %arg, "Some message in case this assertion fails."
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: func @switch(
|
|
func @switch(%flag : i32, %caseOperand : i32) {
|
|
cf.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
|
|
}
|
|
|
|
// CHECK-LABEL: func @switch_i64(
|
|
func @switch_i64(%flag : i64, %caseOperand : i32) {
|
|
cf.switch %flag : i64, [
|
|
default: ^bb1(%caseOperand : i32),
|
|
42: ^bb2(%caseOperand : i32),
|
|
43: ^bb3(%caseOperand : i32)
|
|
]
|
|
|
|
^bb1(%bb1arg : i32):
|
|
return
|
|
^bb2(%bb2arg : i32):
|
|
return
|
|
^bb3(%bb3arg : i32):
|
|
return
|
|
}
|