[clang] [CIR] Upstream ComplexImagPtrOp for ComplexType (PR #144236)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 14 07:17:16 PDT 2025


================
@@ -2642,6 +2642,36 @@ def ComplexRealPtrOp : CIR_Op<"complex.real_ptr", [Pure]> {
   let hasVerifier = 1;
 }
 
+//===----------------------------------------------------------------------===//
+// ComplexImagPtrOp
+//===----------------------------------------------------------------------===//
+
+def ComplexImagPtrOp : CIR_Op<"complex.imag_ptr", [Pure]> {
+  let summary = "Derive a pointer to the imaginary part of a complex value";
+  let description = [{
+    `cir.complex.imag_ptr` operation takes a pointer operand that points to a
+    complex value of type `!cir.complex` and yields a pointer to the imaginary
+    part of the operand.
+
+    Example:
+
+    ```mlir
+    %1 = cir.complex.imag_ptr %0 : !cir.ptr<!cir.complex<!cir.double>>
+      -> !cir.ptr<!cir.double>
+    ```
+  }];
+
+  let results = (outs CIR_PtrToIntOrFloatType:$result);
+  let arguments = (ins CIR_PtrToComplexType:$operand);
----------------
xlauko wrote:

I would like us to try to have consistent order in operation definitions i.e.: 
`summary`, `description`, `arguments`, `results`, `assemblyFormat`, `extra` ...

https://github.com/llvm/llvm-project/pull/144236


More information about the cfe-commits mailing list