bcardosolopes wrote:
> The git history says the FIXME about "Pure" was added when @cmarcelo
> introduced `UnaryOp` in the incubator, but there is no PR associated with the
> commit so I don't know what discussions may have taken place.
We floated the idea of implementing operators as part of `
https://github.com/bcardosolopes approved this pull request.
https://github.com/llvm/llvm-project/pull/131369
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
andykaylor wrote:
The git history says the FIXME about "Pure" was added when @cmarcelo introduced
`UnaryOp` in the incubator, but there is no PR associated with the commit so I
don't know what discussions may have taken place.
https://github.com/llvm/llvm-project/pull/131369
__
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
}];
}
+//===--===//
+// UnaryOp
+//===--===//
+
+def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir
-Wno-unused-value -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir
-Wno-unused-value -emit-llvm %s -o %t-cir.ll
+// RUN
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/131369
This adds support for the cir.unary operation.
>From d51bb762224f70b2b879198e2466ca0d258f9eae Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Mon, 10 Mar 2025 15:07:50 -0700
Subject: [PATCH] [CIR] Upstream
@@ -92,6 +92,222 @@ class ScalarExprEmitter : public
StmtVisitor {
mlir::Value VisitCastExpr(CastExpr *E);
+ // Unary Operators.
+ mlir::Value VisitUnaryPostDec(const UnaryOperator *e) {
+LValue lv = cgf.emitLValue(e->getSubExpr());
+return emitScalarPrePostIncDe
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Andy Kaylor (andykaylor)
Changes
This adds support for the cir.unary operation.
---
Patch is 40.74 KiB, truncated to 20.00 KiB below, full version:
https://github.com/llvm/llvm-project/pull/131369.diff
11 Files Affected:
- (modified)
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir
-Wno-unused-value -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir
-Wno-unused-value -emit-llvm %s -o %t-cir.ll
+// RUN
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
}];
}
+//===--===//
+// UnaryOp
+//===--===//
+
+def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"
@@ -568,6 +568,128 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
+cir::UnaryOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+
@@ -568,6 +568,128 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
+cir::UnaryOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+
@@ -92,6 +92,222 @@ class ScalarExprEmitter : public
StmtVisitor {
mlir::Value VisitCastExpr(CastExpr *E);
+ // Unary Operators.
+ mlir::Value VisitUnaryPostDec(const UnaryOperator *e) {
+LValue lv = cgf.emitLValue(e->getSubExpr());
+return emitScalarPrePostIncDe
@@ -568,6 +568,128 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
+cir::UnaryOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+
@@ -568,6 +568,128 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
+cir::UnaryOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+
https://github.com/erichkeane commented:
I still have the open question on that comment I'd like an answer to, but 1
suggestion here. Else this LGTM.
https://github.com/llvm/llvm-project/pull/131369
___
cfe-commits mailing list
cfe-commits@lists.llvm
@@ -165,6 +165,54 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr
*e) {
return LValue();
}
+LValue CIRGenFunction::emitUnaryOpLValue(const UnaryOperator *e) {
+ UnaryOperatorKind op = e->getOpcode();
+
+ // __extension__ doesn't affect lvalue-ness.
+ if (op
@@ -165,6 +165,54 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr
*e) {
return LValue();
}
+LValue CIRGenFunction::emitUnaryOpLValue(const UnaryOperator *e) {
+ UnaryOperatorKind op = e->getOpcode();
+
+ // __extension__ doesn't affect lvalue-ness.
+ if (op
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
}];
}
+//===--===//
+// UnaryOp
+//===--===//
+
+def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"
https://github.com/erichkeane edited
https://github.com/llvm/llvm-project/pull/131369
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/andykaylor updated
https://github.com/llvm/llvm-project/pull/131369
>From d51bb762224f70b2b879198e2466ca0d258f9eae Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Mon, 10 Mar 2025 15:07:50 -0700
Subject: [PATCH 1/2] [CIR] Upstream initial support for unary op
This adds supp
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
}];
}
+//===--===//
+// UnaryOp
+//===--===//
+
+def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
}];
}
+//===--===//
+// UnaryOp
+//===--===//
+
+def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
}];
}
+//===--===//
+// UnaryOp
+//===--===//
+
+def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"
@@ -92,6 +92,222 @@ class ScalarExprEmitter : public
StmtVisitor {
mlir::Value VisitCastExpr(CastExpr *E);
+ // Unary Operators.
+ mlir::Value VisitUnaryPostDec(const UnaryOperator *e) {
+LValue lv = cgf.emitLValue(e->getSubExpr());
+return emitScalarPrePostIncDe
@@ -92,6 +92,222 @@ class ScalarExprEmitter : public
StmtVisitor {
mlir::Value VisitCastExpr(CastExpr *E);
+ // Unary Operators.
+ mlir::Value VisitUnaryPostDec(const UnaryOperator *e) {
+LValue lv = cgf.emitLValue(e->getSubExpr());
+return emitScalarPrePostIncDe
@@ -568,6 +568,128 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
+cir::UnaryOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
}];
}
+//===--===//
+// UnaryOp
+//===--===//
+
+def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"
llvmbot wrote:
@llvm/pr-subscribers-clangir
Author: Andy Kaylor (andykaylor)
Changes
This adds support for the cir.unary operation.
---
Patch is 40.74 KiB, truncated to 20.00 KiB below, full version:
https://github.com/llvm/llvm-project/pull/131369.diff
11 Files Affected:
- (modified
29 matches
Mail list logo