================
@@ -3864,4 +3864,63 @@ def CIR_VAArgOp : CIR_Op<"va_arg"> {
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// ThrowOp
+//===----------------------------------------------------------------------===//
+
+def CIR_ThrowOp : CIR_Op<"throw"> {
+  let summary = "(Re)Throws an exception";
+  let description = [{
+    It's equivalent __cxa_throw:
+
+    ```
+    void __cxa_throw(void *thrown_exception, std::type_info *tinfo,
+                     void (*dest) (void *));
+    ```
+
+    The absense of arguments for `cir.throw` means it rethrows.
+
+    For the no-rethrow version, it must have at least two operands, the RTTI
+    information, a pointer to the exception object (likely allocated via
+    `cir.alloc_exception`) and finally an optional dtor, which might run as
+    part of this operation.
+
+    Example:
+    ```mlir
+    // throw;
+    cir.throw
+
+    // if (b == 0)
+    //   throw "Division by zero condition!";
+    cir.if %cond {
----------------
andykaylor wrote:

```suggestion
     // Type info for char const*
     cir.global "private" constant external @_ZTIPKc : !cir.ptr<!u8i>
    cir.if %cond {
```

https://github.com/llvm/llvm-project/pull/154994
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to