Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -5183,6 +5183,34 @@ def CIR_TryOp : CIR_Op<"try",[
let hasLLVMLowering = false;
}

//===----------------------------------------------------------------------===//
// CatchParamOp
//===----------------------------------------------------------------------===//

def CIR_CatchParamOp : CIR_Op<"catch_param", [HasParent<"cir::TryOp">]> {
let summary = "Represents the catch clause formal parameter";
let description = [{
The `cir.catch_param` is used to retrieves the exception object inside
the handler regions of `cir.try`.

This operation is used only before the CFG flatterning pass.

Example:

```mlir
%exception = cir.catch_param : !cir.ptr<!void>
```
}];

let results = (outs Optional<CIR_AnyType>:$param);
let assemblyFormat = [{
(`:` qualified(type($param))^)?
attr-dict
}];

let hasLLVMLowering = false;
}

//===----------------------------------------------------------------------===//
// Exception related: EhInflightOp
//===----------------------------------------------------------------------===//
Expand Down
32 changes: 32 additions & 0 deletions clang/test/CIR/IR/catch-param.cir
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// RUN: cir-opt %s --verify-roundtrip | FileCheck %s

!s32i = !cir.int<s, 32>
!void = !cir.void

module {

cir.func @catch_param_inside_catch() {
cir.scope {
cir.try {
cir.yield
} catch all {
%exception = cir.catch_param : !cir.ptr<!void>
cir.yield
}
}
cir.return
}

// CHECK: cir.func @catch_param_inside_catch() {
// CHECK: cir.scope {
// CHECK: cir.try {
// CHECK: cir.yield
// CHECK: } catch all {
// CHECK: %[[EXCEPTION:.*]] = cir.catch_param : !cir.ptr<!void>
// CHECK: cir.yield
// CHECK: }
// CHECK: }
// CHECK: cir.return
// CHECK: }

}
Loading