https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/165110

>From ffd07a7f7675e9c22d4048894bb2c9f01109d225 Mon Sep 17 00:00:00 2001
From: Amr Hesham <[email protected]>
Date: Fri, 5 Dec 2025 21:27:34 +0100
Subject: [PATCH 1/3] [CIR] Add structured CatchParamOp

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td | 27 +++++++++++++++++
 clang/test/CIR/IR/catch-param.cir            | 32 ++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 clang/test/CIR/IR/catch-param.cir

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 80c184e4f478c..8d6aa5db20b06 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -5134,6 +5134,33 @@ def CIR_TryOp : CIR_Op<"try",[
   let hasLLVMLowering = false;
 }
 
+//===----------------------------------------------------------------------===//
+// CatchParamOp
+//===----------------------------------------------------------------------===//
+
+def CIR_CatchParamOp : CIR_Op<"catch_param", [HasParent<"cir::TryOp">]> {
+  let summary = "Represents catch clause formal parameter";
+  let description = [{
+    The `cir.catch_param` operate in the catch 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
 
//===----------------------------------------------------------------------===//
diff --git a/clang/test/CIR/IR/catch-param.cir 
b/clang/test/CIR/IR/catch-param.cir
new file mode 100644
index 0000000000000..a16e8ec43c91b
--- /dev/null
+++ b/clang/test/CIR/IR/catch-param.cir
@@ -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 {
+      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:       cir.catch_param : !cir.ptr<!void> 
+// CHECK:       cir.yield
+// CHECK:     }
+// CHECK:   }
+// CHECK:   cir.return
+// CHECK: }
+
+}

>From 067962c61d807242057bb70c51272ee4f3437d8e Mon Sep 17 00:00:00 2001
From: Amr Hesham <[email protected]>
Date: Fri, 5 Dec 2025 21:32:42 +0100
Subject: [PATCH 2/3] Update op example to match the current format

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 8d6aa5db20b06..21b0dff9fc636 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -5148,7 +5148,7 @@ def CIR_CatchParamOp : CIR_Op<"catch_param", 
[HasParent<"cir::TryOp">]> {
     Example:
 
     ```mlir
-    %exception = cir.catch_param -> !cir.ptr<!void>
+    %exception = cir.catch_param : !cir.ptr<!void>
     ```
   }];
 

>From 264562491fe2ae2740b704f75132cdcb0ca21168 Mon Sep 17 00:00:00 2001
From: Amr Hesham <[email protected]>
Date: Fri, 5 Dec 2025 21:52:01 +0100
Subject: [PATCH 3/3] Update Op description

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 21b0dff9fc636..cdc416785856d 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -5139,9 +5139,10 @@ def CIR_TryOp : CIR_Op<"try",[
 
//===----------------------------------------------------------------------===//
 
 def CIR_CatchParamOp : CIR_Op<"catch_param", [HasParent<"cir::TryOp">]> {
-  let summary = "Represents catch clause formal parameter";
+  let summary = "Represents the catch clause formal parameter";
   let description = [{
-    The `cir.catch_param` operate in the catch regions of `cir.try`.
+    The `cir.catch_param` used to retrieves the exception object inside
+    the handler regions of `cir.try`.
 
     This operation is used only before the CFG flatterning pass.
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to