@@ -127,6 +136,8 @@ struct MissingFeatures {
static bool ternaryOp() { return false; }
static bool tryOp() { return false; }
static bool zextOp() { return false; }
+ static bool opPtrStride() { return false; }
+ static bool opPtrDiff() { return false; }
@@ -994,6 +992,127 @@ mlir::LogicalResult
CIRToLLVMUnaryOpLowering::matchAndRewrite(
<< elementType;
}
+mlir::LLVM::IntegerOverflowFlags
+CIRToLLVMBinOpLowering::getIntOverflowFlag(cir::BinOp op) const {
+ if (op.getNoUnsignedWrap())
+return mlir:
@@ -558,8 +624,225 @@ class ScalarExprEmitter : public
StmtVisitor {
return res;
}
+
+ BinOpInfo emitBinOps(const BinaryOperator *e,
+ QualType promotionType = QualType()) {
+BinOpInfo result;
+result.lhs = cgf.emitPromotedScalarExpr(e->ge
https://github.com/bcardosolopes edited
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -558,8 +624,225 @@ class ScalarExprEmitter : public
StmtVisitor {
return res;
}
+
+ BinOpInfo emitBinOps(const BinaryOperator *e,
+ QualType promotionType = QualType()) {
+BinOpInfo result;
+result.lhs = cgf.emitPromotedScalarExpr(e->ge
@@ -35,6 +83,22 @@ class ScalarExprEmitter : public
StmtVisitor {
ScalarExprEmitter(CIRGenFunction &cgf, CIRGenBuilderTy &builder)
: cgf(cgf), builder(builder) {}
+
//======//
+ //
https://github.com/andykaylor commented:
This looks good to me except for a few nits and the need to defer the
ASTContext refactoring change.
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/andykaylor approved this pull request.
lgtm
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1133,6 +1252,7 @@ void ConvertCIRToLLVMPass::runOnOperation() {
patterns.add<
// clang-format off
CIRToLLVMBrCondOpLowering,
+ CIRToLLVMBinOpLowering,
andykaylor wrote:
This list is alphabetical (for consistency in reba
@@ -168,24 +168,9 @@ static bool MustVisitNullValue(const Expr *E) {
return E->getType()->isNullPtrType();
}
-/// If \p E is a widened promoted integer, get its base (unpromoted) type.
-static std::optional getUnwidenedIntegerType(const ASTContext &Ctx,
-
@@ -127,6 +135,8 @@ struct MissingFeatures {
static bool ternaryOp() { return false; }
static bool tryOp() { return false; }
static bool zextOp() { return false; }
+ static bool ptrStrideOp() { return false; }
andykaylor wrote:
@AmrDeveloper Be sure to
@@ -35,6 +83,22 @@ class ScalarExprEmitter : public
StmtVisitor {
ScalarExprEmitter(CIRGenFunction &cgf, CIRGenBuilderTy &builder)
: cgf(cgf), builder(builder) {}
+
//======//
+ //
https://github.com/andykaylor edited
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -200,7 +200,7 @@ class ASTContext : public RefCountedBase {
mutable llvm::ContextualFoldingSet
ConstantArrayTypes;
mutable llvm::FoldingSet IncompleteArrayTypes;
- mutable std::vector VariableArrayTypes;
+ mutable std::vector VariableArrayTypes;
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -93,16 +96,20 @@ struct MissingFeatures {
static bool stackSaveOp() { return false; }
static bool aggValueSlot() { return false; }
static bool generateDebugInfo() { return false; }
+ static bool getFPFeaturesInEffect() { return false; }
+ static bool pointerOverflowS
https://github.com/bcardosolopes edited
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
mmha wrote:
As @andykaylor suggested, I'm going to split off `BinOpOverflowOp` and the
pointer arithmetic bits into a separate patch next.
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https:/
@@ -93,16 +96,20 @@ struct MissingFeatures {
static bool stackSaveOp() { return false; }
static bool aggValueSlot() { return false; }
static bool generateDebugInfo() { return false; }
+ static bool getFPFeaturesInEffect() { return false; }
+ static bool pointerOverflowS
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -826,6 +826,129 @@ def ForOp : CIR_Op<"for", [LoopOpInterface,
NoRegionArguments]> {
}];
}
+//===--===//
+// BinOp
+//===--===//
+
+//
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
You can test this locally with the following command:
``bash
git-clang-format --diff b858ba0f6597c66e5c276ca9e2564ca27e7e28e7
9b98af6a70fe6327270d983492b11f9cb9cd9f8f --e
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/132420
>From 594005c964b5c1e6605dc8ac170f1b43aa018bea Mon Sep 17 00:00:00 2001
From: Morris Hafner
Date: Fri, 21 Mar 2025 17:55:00 +0100
Subject: [PATCH 1/6] [CIR] Add binary operators
This patch adds upstreams support fo
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/132420
>From 594005c964b5c1e6605dc8ac170f1b43aa018bea Mon Sep 17 00:00:00 2001
From: Morris Hafner
Date: Fri, 21 Mar 2025 17:55:00 +0100
Subject: [PATCH 1/5] [CIR] Add binary operators
This patch adds upstreams support fo
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/132420
>From 594005c964b5c1e6605dc8ac170f1b43aa018bea Mon Sep 17 00:00:00 2001
From: Morris Hafner
Date: Fri, 21 Mar 2025 17:55:00 +0100
Subject: [PATCH 1/4] [CIR] Add binary operators
This patch adds upstreams support fo
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/132420
>From 594005c964b5c1e6605dc8ac170f1b43aa018bea Mon Sep 17 00:00:00 2001
From: Morris Hafner
Date: Fri, 21 Mar 2025 17:55:00 +0100
Subject: [PATCH 1/3] [CIR] Add binary operators
This patch adds upstreams support fo
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/132420
>From 594005c964b5c1e6605dc8ac170f1b43aa018bea Mon Sep 17 00:00:00 2001
From: Morris Hafner
Date: Fri, 21 Mar 2025 17:55:00 +0100
Subject: [PATCH 1/2] [CIR] Add binary operators
This patch adds upstreams support fo
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
andykaylor wrote:
```suggestion
mlir::Value createBi
https://github.com/andykaylor commented:
This is an awful lot to digest in one review. Can you split out the
BinOpOverflowOp and pointer arithmetic?
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.o
@@ -72,22 +74,126 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
if (const auto arrayVal = mlir::dyn_cast(attr)) {
if (mlir::isa(arrayVal.getElts()))
return false;
- for (const auto elt : mlir::cast(arrayVal.getElts())) {
-if (!isNullVa
@@ -570,13 +853,425 @@ mlir::Value CIRGenFunction::emitScalarExpr(const Expr
*e) {
return ScalarExprEmitter(*this, builder).Visit(const_cast(e));
}
-[[maybe_unused]] static bool MustVisitNullValue(const Expr *e) {
+mlir::Value CIRGenFunction::emitPromotedScalarExpr(const Ex
@@ -558,8 +624,225 @@ class ScalarExprEmitter : public
StmtVisitor {
return res;
}
+
+ BinOpInfo emitBinOps(const BinaryOperator *e,
+ QualType promotionType = QualType()) {
+BinOpInfo result;
+result.lhs = cgf.emitPromotedScalarExpr(e->ge
@@ -558,8 +624,225 @@ class ScalarExprEmitter : public
StmtVisitor {
return res;
}
+
+ BinOpInfo emitBinOps(const BinaryOperator *e,
+ QualType promotionType = QualType()) {
+BinOpInfo result;
+result.lhs = cgf.emitPromotedScalarExpr(e->ge
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -570,13 +853,425 @@ mlir::Value CIRGenFunction::emitScalarExpr(const Expr
*e) {
return ScalarExprEmitter(*this, builder).Visit(const_cast(e));
}
-[[maybe_unused]] static bool MustVisitNullValue(const Expr *e) {
+mlir::Value CIRGenFunction::emitPromotedScalarExpr(const Ex
@@ -93,16 +96,20 @@ struct MissingFeatures {
static bool stackSaveOp() { return false; }
static bool aggValueSlot() { return false; }
static bool generateDebugInfo() { return false; }
+ static bool getFPFeaturesInEffect() { return false; }
+ static bool pointerOverflowS
@@ -232,6 +231,61 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+LValue CIRGenFunction::emitBinaryOperatorLValue(const BinaryOperator *e) {
+ // Comma expressions just emit their LHS then their RHS
@@ -826,6 +826,129 @@ def ForOp : CIR_Op<"for", [LoopOpInterface,
NoRegionArguments]> {
}];
}
+//===--===//
+// BinOp
+//===--===//
+
+//
@@ -93,16 +96,20 @@ struct MissingFeatures {
static bool stackSaveOp() { return false; }
static bool aggValueSlot() { return false; }
static bool generateDebugInfo() { return false; }
+ static bool getFPFeaturesInEffect() { return false; }
andykaylor wro
https://github.com/andykaylor edited
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -26,6 +26,53 @@ using namespace clang::CIRGen;
namespace {
+struct BinOpInfo {
+ mlir::Value lhs;
+ mlir::Value rhs;
+ SourceRange loc;
+ QualType fullType; // Type of operands and result
+ QualType compType; // Type used for computations. Elem
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -143,6 +147,114 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return createCast(loc, cir::CastKind::bitcast, src, newTy);
}
+ mlir::Value createBinop(mlir::Value lhs, cir::BinOpKind kind,
+ const llvm::APInt &rhs) {
+return create(
@@ -826,6 +826,129 @@ def ForOp : CIR_Op<"for", [LoopOpInterface,
NoRegionArguments]> {
}];
}
+//===--===//
+// BinOp
+//===--===//
+
+//
llvmbot wrote:
@llvm/pr-subscribers-clangir
@llvm/pr-subscribers-clang
Author: Morris Hafner (mmha)
Changes
This patch adds upstreams support for BinOp and BinOverflowOp including lvalue
assignments and rudimentary support for pointer arithmetic. Note that this does
not include ternary o
mmha wrote:
@erichkeane @dkolsen-pgi @andykaylor
https://github.com/llvm/llvm-project/pull/132420
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/132420
This patch adds upstreams support for BinOp and BinOverflowOp including lvalue
assignments and rudimentary support for pointer arithmetic. Note that this does
not include ternary ops, ShiftOp and SelectOp which are
55 matches
Mail list logo