llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clangir

Author: Amr Hesham (AmrDeveloper)

<details>
<summary>Changes</summary>

Add LandingpadOp for the new design of Exceptions

Issue https://github.com/llvm/llvm-project/issues/154992

---
Full diff: https://github.com/llvm/llvm-project/pull/173306.diff


3 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+27) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.td (+8) 
- (added) clang/test/CIR/IR/eh-landingpad.cir (+15) 


``````````diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 86ea5fca75200..370485e2fc97a 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -5516,6 +5516,33 @@ def CIR_EhInflightOp : CIR_Op<"eh.inflight_exception"> {
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// Exception related: EhLandingpadOp
+//===----------------------------------------------------------------------===//
+def CIR_EhLandingpadOp : CIR_Op<"eh.landingpad"> {
+  let summary = "Materialize the catch clause formal parameter";
+  let description = [{
+    This operation is expected to be the first operation in the unwind
+    destination basic blocks of a `cir.try_call` operation.
+
+    `cir.eh.landingpad` returns eh_token which lowered to exception_ptr and
+    type_id except for Windows platform it will be lowered to none to represent
+    funclet token.
+
+    Example:
+    ```mlir
+    %eh_token = cir.eh_landingpad
+    ```
+  }];
+
+  let results = (outs CIR_EhToken:$eh_token);
+  let assemblyFormat = [{
+    attr-dict
+  }];
+
+  let hasLLVMLowering = false;
+}
+
 
//===----------------------------------------------------------------------===//
 // Atomic operations
 
//===----------------------------------------------------------------------===//
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
index fe79e3a086d4e..f6a0348e9dfc8 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
@@ -735,4 +735,12 @@ def CIR_AnyType : AnyTypeOf<[
   CIR_ComplexType, CIR_VPtrType, CIR_DataMemberType
 ]>;
 
+//===----------------------------------------------------------------------===//
+// Exception related: EhToken type
+//===----------------------------------------------------------------------===//
+
+def CIR_EhToken : CIR_Type<"EhToken", "eh_token"> {
+  let summary = "CIR Exception handling token";
+}
+
 #endif // CLANG_CIR_DIALECT_IR_CIRTYPES_TD
diff --git a/clang/test/CIR/IR/eh-landingpad.cir 
b/clang/test/CIR/IR/eh-landingpad.cir
new file mode 100644
index 0000000000000..47325b3005820
--- /dev/null
+++ b/clang/test/CIR/IR/eh-landingpad.cir
@@ -0,0 +1,15 @@
+// RUN: cir-opt %s --verify-roundtrip | FileCheck %s
+
+module {
+
+cir.func dso_local @exception_landingpad() {
+  %eh_token = cir.eh.landingpad
+  cir.return
+}
+
+// CHECK: cir.func dso_local @exception_landingpad() {
+// CHECK:   %[[EH_TOKEN:.*]] = cir.eh.landingpad
+// CHECK:   cir.return
+// CHECK: }
+
+}

``````````

</details>


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

Reply via email to