[llvm-branch-commits] [llvm] release/20.x: [llvm-objcopy] Fix prints wrong path when dump-section output path doesn't exist (#125345) (PR #126367)

2025-02-10 Thread Amr Hesham via llvm-branch-commits

AmrDeveloper wrote:

> LGTM.
> 
> Regarding the release note, you'll need one on the release branch. IIUC, you 
> won't then need one on `main`, because the release branch is still in RC 
> mode, so not a final release yet.

Not sure if I can push release note on this PR only, but I will create a 
follow-up PR to add release note on release branch @jh7370 

https://github.com/llvm/llvm-project/pull/126367
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [llvm-objcopy] Fix prints wrong path when dump-section output path doesn't exist (#125345) (PR #126367)

2025-02-10 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper approved this pull request.


https://github.com/llvm/llvm-project/pull/126367
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [llvm-objcopy][ReleaseNotes] Fix prints wrong path when dump-section output path doesn't exist #125345 (PR #126607)

2025-02-10 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/126607

Add release note for llvm-objcopy fixing prints wrong path when dump-section 
output path doesn't exist in #125345

>From 8886b33981f73da04adadb3e02a740b8e376e042 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Mon, 10 Feb 2025 23:03:15 +0100
Subject: [PATCH] release/20.x: [llvm-objcopy][ReleaseNotes] Fix prints wrong
 path when dump-section output path doesn't exist #125345

---
 llvm/docs/ReleaseNotes.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 44a0b17d6a07b97..c92338345f1cb6d 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -460,6 +460,8 @@ Changes to the LLVM tools
   `--localize-symbol`, `--localize-symbols`,
   `--skip-symbol`, `--skip-symbols`.
 
+* llvm-objcopy now prints the correct file path in the error message when the 
output file specified by --dump-section cannot be opened.
+
 Changes to LLDB
 -
 

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [llvm-objcopy][ReleaseNotes] Fix prints wrong path when dump-section output path doesn't exist #125345 (PR #126607)

2025-02-11 Thread Amr Hesham via llvm-branch-commits

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

>From 8886b33981f73da04adadb3e02a740b8e376e042 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Mon, 10 Feb 2025 23:03:15 +0100
Subject: [PATCH 1/2] release/20.x: [llvm-objcopy][ReleaseNotes] Fix prints
 wrong path when dump-section output path doesn't exist #125345

---
 llvm/docs/ReleaseNotes.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 44a0b17d6a07b..c92338345f1cb 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -460,6 +460,8 @@ Changes to the LLVM tools
   `--localize-symbol`, `--localize-symbols`,
   `--skip-symbol`, `--skip-symbols`.
 
+* llvm-objcopy now prints the correct file path in the error message when the 
output file specified by --dump-section cannot be opened.
+
 Changes to LLDB
 -
 

>From 6f5ced04f9fb5769f367a26b306a3ca961324926 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 11 Feb 2025 17:53:03 +0100
Subject: [PATCH 2/2] Add quote around option name

---
 llvm/docs/ReleaseNotes.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index c92338345f1cb..28908490b8f7c 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -460,7 +460,7 @@ Changes to the LLVM tools
   `--localize-symbol`, `--localize-symbols`,
   `--skip-symbol`, `--skip-symbols`.
 
-* llvm-objcopy now prints the correct file path in the error message when the 
output file specified by --dump-section cannot be opened.
+* llvm-objcopy now prints the correct file path in the error message when the 
output file specified by `--dump-section` cannot be opened.
 
 Changes to LLDB
 -

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [llvm-objcopy][ReleaseNotes] Fix prints wrong path when dump-section output path doesn't exist #125345 (PR #126607)

2025-02-11 Thread Amr Hesham via llvm-branch-commits


@@ -460,6 +460,8 @@ Changes to the LLVM tools
   `--localize-symbol`, `--localize-symbols`,
   `--skip-symbol`, `--skip-symbols`.
 
+* llvm-objcopy now prints the correct file path in the error message when the 
output file specified by --dump-section cannot be opened.

AmrDeveloper wrote:

I made it `--dump-section` to be similar to all other options in the same file

https://github.com/llvm/llvm-project/pull/126607
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __imag__ for ComplexType (PR #144262)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

AmrDeveloper wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/144262?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#144262** https://app.graphite.dev/github/pr/llvm/llvm-project/144262?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/144262?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#144261** https://app.graphite.dev/github/pr/llvm/llvm-project/144261?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#144236** https://app.graphite.dev/github/pr/llvm/llvm-project/144236?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#144235** https://app.graphite.dev/github/pr/llvm/llvm-project/144235?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


https://github.com/llvm/llvm-project/pull/144262
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __real__ for ComplexType (PR #144261)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/144261

None

>From 9cbbfd20f045ca71e51d5bddd5e2bbe5a8ddd22f Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sun, 15 Jun 2025 14:44:11 +0200
Subject: [PATCH] [CIR] Upstream __real__ for ComplexType

---
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 21 
 clang/test/CIR/CodeGen/complex.cpp | 23 ++
 2 files changed, 44 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 75b4d2a637e6e..615a0e7bef556 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -603,6 +603,8 @@ class ScalarExprEmitter : public 
StmtVisitor {
 
   mlir::Value VisitUnaryLNot(const UnaryOperator *e);
 
+  mlir::Value VisitUnaryReal(const UnaryOperator *e);
+
   mlir::Value VisitCXXThisExpr(CXXThisExpr *te) { return cgf.loadCXXThis(); }
 
   /// Emit a conversion from the specified type to the specified destination
@@ -1891,6 +1893,25 @@ mlir::Value ScalarExprEmitter::VisitUnaryLNot(const 
UnaryOperator *e) {
   return maybePromoteBoolResult(boolVal, cgf.convertType(e->getType()));
 }
 
+mlir::Value ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *e) {
+  // TODO(cir): handle scalar promotion.
+  Expr *op = e->getSubExpr();
+  if (op->getType()->isAnyComplexType()) {
+// If it's an l-value, load through the appropriate subobject l-value.
+// Note that we have to ask E because Op might be an l-value that
+// this won't work for, e.g. an Obj-C property.
+if (e->isGLValue())
+  return cgf.emitLoadOfLValue(cgf.emitLValue(e), e->getExprLoc())
+  .getScalarVal();
+
+// Otherwise, calculate and project.
+cgf.cgm.errorNYI(e->getSourceRange(),
+ "VisitUnaryReal calculate and project");
+  }
+
+  return Visit(op);
+}
+
 /// Return the size or alignment of the type of argument of the sizeof
 /// expression as an integer.
 mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
diff --git a/clang/test/CIR/CodeGen/complex.cpp 
b/clang/test/CIR/CodeGen/complex.cpp
index 4bccf65cceb13..3d1e395d7613c 100644
--- a/clang/test/CIR/CodeGen/complex.cpp
+++ b/clang/test/CIR/CodeGen/complex.cpp
@@ -203,3 +203,26 @@ void foo11() {
 
 // OGCG: %[[COMPLEX:.*]] = alloca { double, double }, align 8
 // OGCG: %[[IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr 
%[[COMPLEX]], i32 0, i32 1
+
+void foo12() {
+  double _Complex c;
+  double real = __real__ c;
+}
+
+// CIR: %[[COMPLEX:.*]] = cir.alloca !cir.complex, 
!cir.ptr>, ["c"]
+// CIR: %[[INIT:.*]] = cir.alloca !cir.double, !cir.ptr, ["real", 
init]
+// CIR: %[[REAL_PTR:.*]] = cir.complex.real_ptr %[[COMPLEX]] : 
!cir.ptr> -> !cir.ptr
+// CIR: %[[REAL:.*]] = cir.load{{.*}} %[[REAL_PTR]] : !cir.ptr, 
!cir.double
+// CIR: cir.store{{.*}} %[[REAL]], %[[INIT]] : !cir.double, 
!cir.ptr
+
+// LLVM: %[[COMPLEX:.*]] = alloca { double, double }, i64 1, align 8
+// LLVM: %[[INIT:.*]] = alloca double, i64 1, align 8
+// LLVM: %[[REAL_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr 
%[[COMPLEX]], i32 0, i32 0
+// LLVM: %[[REAL:.*]] = load double, ptr %[[REAL_PTR]], align 8
+// LLVM: store double %[[REAL]], ptr %[[INIT]], align 8
+
+// OGCG: %[[COMPLEX:.*]] = alloca { double, double }, align 8
+// OGCG: %[[INIT:.*]] = alloca double, align 8
+// OGCG: %[[REAL_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr 
%[[COMPLEX]], i32 0, i32 0
+// OGCG: %[[REAL:.*]] = load double, ptr %[[REAL_PTR]], align 8
+// OGCG: store double %[[REAL]], ptr %[[INIT]], align 8

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __imag__ for ComplexType (PR #144262)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/144262

None

>From fa6756886c5e0d432445d2364d92ff38ad0127ae Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sun, 15 Jun 2025 14:45:12 +0200
Subject: [PATCH] [CIR] Upstream __imag__ for ComplexType

---
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 20 +++
 clang/test/CIR/CodeGen/complex.cpp | 23 ++
 2 files changed, 43 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 615a0e7bef556..a1896c5e7f7e5 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -604,6 +604,7 @@ class ScalarExprEmitter : public 
StmtVisitor {
   mlir::Value VisitUnaryLNot(const UnaryOperator *e);
 
   mlir::Value VisitUnaryReal(const UnaryOperator *e);
+  mlir::Value VisitUnaryImag(const UnaryOperator *e);
 
   mlir::Value VisitCXXThisExpr(CXXThisExpr *te) { return cgf.loadCXXThis(); }
 
@@ -1912,6 +1913,25 @@ mlir::Value ScalarExprEmitter::VisitUnaryReal(const 
UnaryOperator *e) {
   return Visit(op);
 }
 
+mlir::Value ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *e) {
+  // TODO(cir): handle scalar promotion.
+  Expr *op = e->getSubExpr();
+  if (op->getType()->isAnyComplexType()) {
+// If it's an l-value, load through the appropriate subobject l-value.
+// Note that we have to ask E because Op might be an l-value that
+// this won't work for, e.g. an Obj-C property.
+if (e->isGLValue())
+  return cgf.emitLoadOfLValue(cgf.emitLValue(e), e->getExprLoc())
+  .getScalarVal();
+
+// Otherwise, calculate and project.
+cgf.cgm.errorNYI(e->getSourceRange(),
+ "VisitUnaryImag calculate and project");
+  }
+
+  return Visit(op);
+}
+
 /// Return the size or alignment of the type of argument of the sizeof
 /// expression as an integer.
 mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
diff --git a/clang/test/CIR/CodeGen/complex.cpp 
b/clang/test/CIR/CodeGen/complex.cpp
index 3d1e395d7613c..6c29dc3e1b7fe 100644
--- a/clang/test/CIR/CodeGen/complex.cpp
+++ b/clang/test/CIR/CodeGen/complex.cpp
@@ -226,3 +226,26 @@ void foo12() {
 // OGCG: %[[REAL_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr 
%[[COMPLEX]], i32 0, i32 0
 // OGCG: %[[REAL:.*]] = load double, ptr %[[REAL_PTR]], align 8
 // OGCG: store double %[[REAL]], ptr %[[INIT]], align 8
+
+void foo13() {
+  double _Complex c;
+  double imag = __imag__ c;
+}
+
+// CIR: %[[COMPLEX:.*]] = cir.alloca !cir.complex, 
!cir.ptr>, ["c"]
+// CIR: %[[INIT:.*]] = cir.alloca !cir.double, !cir.ptr, ["imag", 
init]
+// CIR: %[[IMAG_PTR:.*]] = cir.complex.imag_ptr %[[COMPLEX]] : 
!cir.ptr> -> !cir.ptr
+// CIR: %[[IMAG:.*]] = cir.load{{.*}} %[[REAL_PTR]] : !cir.ptr, 
!cir.double
+// CIR: cir.store{{.*}} %[[IMAG]], %[[INIT]] : !cir.double, 
!cir.ptr
+
+// LLVM: %[[COMPLEX:.*]] = alloca { double, double }, i64 1, align 8
+// LLVM: %[[INIT:.*]] = alloca double, i64 1, align 8
+// LLVM: %[[IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr 
%[[COMPLEX]], i32 0, i32 1
+// LLVM: %[[IMAG:.*]] = load double, ptr %[[IMAG_PTR]], align 8
+// LLVM: store double %[[IMAG]], ptr %[[INIT]], align 8
+
+// OGCG: %[[COMPLEX:.*]] = alloca { double, double }, align 8
+// OGCG: %[[INIT:.*]] = alloca double, align 8
+// OGCG: %[[IMAG_PTR:.*]] = getelementptr inbounds nuw { double, double }, ptr 
%[[COMPLEX]], i32 0, i32 1
+// OGCG: %[[IMAG:.*]] = load double, ptr %[[IMAG_PTR]], align 8
+// OGCG: store double %[[IMAG]], ptr %[[INIT]], align 8

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __real__ for ComplexType (PR #144261)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

AmrDeveloper wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/144261?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#144262** https://app.graphite.dev/github/pr/llvm/llvm-project/144262?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#144261** https://app.graphite.dev/github/pr/llvm/llvm-project/144261?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/144261?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#144236** https://app.graphite.dev/github/pr/llvm/llvm-project/144236?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#144235** https://app.graphite.dev/github/pr/llvm/llvm-project/144235?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


https://github.com/llvm/llvm-project/pull/144261
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __imag__ for ComplexType (PR #144262)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper edited 
https://github.com/llvm/llvm-project/pull/144262
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __real__ for ComplexType (PR #144261)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper edited 
https://github.com/llvm/llvm-project/pull/144261
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __imag__ for ComplexType (PR #144262)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper ready_for_review 
https://github.com/llvm/llvm-project/pull/144262
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __real__ for ComplexType (PR #144261)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper ready_for_review 
https://github.com/llvm/llvm-project/pull/144261
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream __imag__ for ComplexType (PR #144262)

2025-06-15 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper edited 
https://github.com/llvm/llvm-project/pull/144262
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream ComplexImagPtrOp for ComplexType (PR #144236)

2025-06-14 Thread Amr Hesham via llvm-branch-commits

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

None

>From dc824e4ff23a7ff5124de5a21362e5b543c55d27 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 14 Jun 2025 22:19:08 +0200
Subject: [PATCH] [CIR] Upstream ComplexImagPtrOp for ComplexType

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td  | 29 +++
 clang/lib/CIR/CodeGen/CIRGenBuilder.h | 14 +
 clang/lib/CIR/CodeGen/CIRGenExpr.cpp  |  9 ++
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp   | 19 
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 20 -
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.h   | 10 +++
 clang/test/CIR/CodeGen/complex.cpp| 14 +
 7 files changed, 108 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 17279f0a9985a..f90784c99602c 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -2414,4 +2414,33 @@ 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.ptr
+```
+  }];
+
+  let results = (outs CIR_PtrToIntOrFloatType:$result);
+  let arguments = (ins CIR_PtrToComplexType:$operand);
+
+  let assemblyFormat = [{
+$operand `:`
+qualified(type($operand)) `->` qualified(type($result)) attr-dict
+  }];
+
+  let hasVerifier = 1;
+}
+
 #endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h 
b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
index 3f7ea5bccb6d5..df3f4d65610a6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
@@ -379,6 +379,20 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
 return Address{createRealPtr(loc, addr.getPointer()), addr.getAlignment()};
   }
 
+  /// Create a cir.complex.imag_ptr operation that derives a pointer to the
+  /// imaginary part of the complex value pointed to by the specified pointer
+  /// value.
+  mlir::Value createImagPtr(mlir::Location loc, mlir::Value value) {
+auto srcPtrTy = mlir::cast(value.getType());
+auto srcComplexTy = mlir::cast(srcPtrTy.getPointee());
+return create(
+loc, getPointerTo(srcComplexTy.getElementType()), value);
+  }
+
+  Address createImagPtr(mlir::Location loc, Address addr) {
+return Address{createImagPtr(loc, addr.getPointer()), addr.getAlignment()};
+  }
+
   /// Create a cir.ptr_stride operation to get access to an array element.
   /// \p idx is the index of the element to access, \p shouldDecay is true if
   /// the result should decay to a pointer to the element type.
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index a682586562e04..8e3d9ab620621 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -541,11 +541,6 @@ LValue CIRGenFunction::emitUnaryOpLValue(const 
UnaryOperator *e) {
   }
   case UO_Real:
   case UO_Imag: {
-if (op == UO_Imag) {
-  cgm.errorNYI(e->getSourceRange(), "UnaryOp real/imag");
-  return LValue();
-}
-
 LValue lv = emitLValue(e->getSubExpr());
 assert(lv.isSimple() && "real/imag on non-ordinary l-value");
 
@@ -560,7 +555,9 @@ LValue CIRGenFunction::emitUnaryOpLValue(const 
UnaryOperator *e) {
 QualType exprTy = 
getContext().getCanonicalType(e->getSubExpr()->getType());
 QualType elemTy = exprTy->castAs()->getElementType();
 mlir::Location loc = getLoc(e->getExprLoc());
-Address component = builder.createRealPtr(loc, lv.getAddress());
+Address component = op == UO_Real
+? builder.createRealPtr(loc, lv.getAddress())
+: builder.createImagPtr(loc, lv.getAddress());
 LValue elemLV = makeAddrLValue(component, elemTy);
 elemLV.getQuals().addQualifiers(lv.getQuals());
 return elemLV;
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index 99ae4dd59120a..40488f6af5676 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -1794,6 +1794,25 @@ LogicalResult cir::ComplexRealPtrOp::verify() {
   return success();
 }
 
+//===--===//
+// ComplexImagPtrOp
+

[llvm-branch-commits] [clang] [CIR] Upstream ComplexImagPtrOp for ComplexType (PR #144236)

2025-06-14 Thread Amr Hesham via llvm-branch-commits

AmrDeveloper wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/144236?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#144236** https://app.graphite.dev/github/pr/llvm/llvm-project/144236?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/144236?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#144235** https://app.graphite.dev/github/pr/llvm/llvm-project/144235?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


https://github.com/llvm/llvm-project/pull/144236
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream ComplexImagPtrOp for ComplexType (PR #144236)

2025-06-14 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper ready_for_review 
https://github.com/llvm/llvm-project/pull/144236
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Upstream ComplexImagPtrOp for ComplexType (PR #144236)

2025-06-14 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper edited 
https://github.com/llvm/llvm-project/pull/144236
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Untie Type and Attribute definitions (PR #146663)

2025-07-02 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper approved this pull request.


https://github.com/llvm/llvm-project/pull/146663
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CIR] Clean up FPAttr (PR #146662)

2025-07-02 Thread Amr Hesham via llvm-branch-commits

https://github.com/AmrDeveloper approved this pull request.


https://github.com/llvm/llvm-project/pull/146662
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits