File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
include/clang/CIR/Dialect/IR Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -5183,6 +5183,34 @@ def CIR_TryOp : CIR_Op<"try",[
51835183 let hasLLVMLowering = false;
51845184}
51855185
5186+ //===----------------------------------------------------------------------===//
5187+ // CatchParamOp
5188+ //===----------------------------------------------------------------------===//
5189+
5190+ def CIR_CatchParamOp : CIR_Op<"catch_param", [HasParent<"cir::TryOp">]> {
5191+ let summary = "Represents the catch clause formal parameter";
5192+ let description = [{
5193+ The `cir.catch_param` is used to retrieves the exception object inside
5194+ the handler regions of `cir.try`.
5195+
5196+ This operation is used only before the CFG flatterning pass.
5197+
5198+ Example:
5199+
5200+ ```mlir
5201+ %exception = cir.catch_param : !cir.ptr<!void>
5202+ ```
5203+ }];
5204+
5205+ let results = (outs Optional<CIR_AnyType>:$param);
5206+ let assemblyFormat = [{
5207+ (`:` qualified(type($param))^)?
5208+ attr-dict
5209+ }];
5210+
5211+ let hasLLVMLowering = false;
5212+ }
5213+
51865214//===----------------------------------------------------------------------===//
51875215// Exception related: EhInflightOp
51885216//===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change 1+ // RUN: cir-opt %s --verify-roundtrip | FileCheck %s
2+
3+ !s32i = !cir.int<s, 32>
4+ !void = !cir.void
5+
6+ module {
7+
8+ cir.func @catch_param_inside_catch() {
9+ cir.scope {
10+ cir.try {
11+ cir.yield
12+ } catch all {
13+ %exception = cir.catch_param : !cir.ptr<!void>
14+ cir.yield
15+ }
16+ }
17+ cir.return
18+ }
19+
20+ // CHECK: cir.func @catch_param_inside_catch() {
21+ // CHECK: cir.scope {
22+ // CHECK: cir.try {
23+ // CHECK: cir.yield
24+ // CHECK: } catch all {
25+ // CHECK: %[[EXCEPTION:.*]] = cir.catch_param : !cir.ptr<!void>
26+ // CHECK: cir.yield
27+ // CHECK: }
28+ // CHECK: }
29+ // CHECK: cir.return
30+ // CHECK: }
31+
32+ }
You can’t perform that action at this time.
0 commit comments