@@ -442,6 +457,25 @@ class CIRGenFunction : public CIRGenTypeCache {
mlir::LogicalResult emitDeclStmt(const clang::DeclStmt &s);
LValue emitDeclRefLValue(const clang::DeclRefExpr *e);
+ /// Emit an if on a boolean condition to the specified blocks.
+ /// FIXME: Based on
@@ -316,6 +316,106 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) {
emitLValue(e);
}
+/// Emit an `if` on a boolean condition, filling `then` and `else` into
+/// appropriated regions.
+mlir::LogicalResult CIRGenFunction::emitIfOnBoolExpr(const Expr *cond,
+
@@ -263,6 +264,72 @@ static void terminateBody(CIRGenBuilderTy &builder,
mlir::Region &r,
b->erase();
}
+mlir::LogicalResult CIRGenFunction::emitIfStmt(const IfStmt &s) {
+ mlir::LogicalResult res = mlir::success();
+ // The else branch of a consteval if statement is al
@@ -263,6 +264,72 @@ static void terminateBody(CIRGenBuilderTy &builder,
mlir::Region &r,
b->erase();
}
+mlir::LogicalResult CIRGenFunction::emitIfStmt(const IfStmt &s) {
+ mlir::LogicalResult res = mlir::success();
+ // The else branch of a consteval if statement is al
@@ -316,6 +316,106 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) {
emitLValue(e);
}
+/// Emit an `if` on a boolean condition, filling `then` and `else` into
+/// appropriated regions.
+mlir::LogicalResult CIRGenFunction::emitIfOnBoolExpr(const Expr *cond,
+
@@ -316,6 +316,106 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) {
emitLValue(e);
}
+/// Emit an `if` on a boolean condition, filling `then` and `else` into
+/// appropriated regions.
+mlir::LogicalResult CIRGenFunction::emitIfOnBoolExpr(const Expr *cond,
+
@@ -316,6 +316,106 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) {
emitLValue(e);
}
+/// Emit an `if` on a boolean condition, filling `then` and `else` into
+/// appropriated regions.
+mlir::LogicalResult CIRGenFunction::emitIfOnBoolExpr(const Expr *cond,
+
https://github.com/andykaylor updated
https://github.com/llvm/llvm-project/pull/134181
>From 54454e4d52570f29c493c41fc9bf95cbaf9e0886 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Fri, 21 Mar 2025 09:46:27 -0700
Subject: [PATCH 1/4] [CIR] Upstream support for break and continue statements
T
https://github.com/andykaylor updated
https://github.com/llvm/llvm-project/pull/133966
>From 4c71a107d174b24b4515554c4be57a2a318f5fb9 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Tue, 1 Apr 2025 11:47:49 -0700
Subject: [PATCH] [CIR] Upstream support for logical not operations
When unary op
@@ -0,0 +1,81 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apac
@@ -35,6 +83,22 @@ class ScalarExprEmitter : public
StmtVisitor {
ScalarExprEmitter(CIRGenFunction &cgf, CIRGenBuilderTy &builder)
: cgf(cgf), builder(builder) {}
+
//======//
+ //
@@ -0,0 +1,150 @@
+//- LoweringHelpers.cpp - Lowering helper functions
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -246,8 +246,8 @@ OpFoldResult cir::ConstantOp::fold(FoldAdaptor /*adaptor*/)
{
//===--===//
LogicalResult cir::CastOp::verify() {
- auto resType = getResult().getType();
- auto srcType = getSrc().getTyp
@@ -540,6 +542,68 @@ mlir::LogicalResult
CIRToLLVMCastOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMPtrStrideOpLowering::matchAndRewrite(
+cir::PtrStrideOp ptrStrideOp, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewri
@@ -254,3 +254,27 @@ mlir::Type CIRGenTypes::convertTypeForMem(clang::QualType
qualType,
return convertedType;
}
+
+bool CIRGenTypes::isZeroInitializable(clang::QualType t) {
+ if (t->getAs())
+return astContext.getTargetNullPointerValue(t) == 0;
+
+ if (const auto *a
@@ -412,3 +412,26 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const
APValue &value,
}
llvm_unreachable("Unknown APValue kind");
}
+
+mlir::Value CIRGenModule::emitNullConstant(QualType t, mlir::Location loc) {
+ if (t->getAs()) {
+return builder.getNullPtr(getT
@@ -0,0 +1,273 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,273 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -113,6 +113,11 @@ class CIRGenModule : public CIRGenTypeCache {
void emitGlobalVarDefinition(const clang::VarDecl *vd,
bool isTentative = false);
+ // Return the result of value-initializing the given type, i.e. a null
+ /// expression of
@@ -449,4 +449,48 @@ LValue CIRGenFunction::emitLValue(const Expr *e) {
}
}
+void CIRGenFunction::emitNullInitialization(mlir::Location loc, Address
destPtr,
+QualType ty) {
+ // Ignore empty classes in C++.
+ if (getLangOpts().
@@ -449,4 +449,48 @@ LValue CIRGenFunction::emitLValue(const Expr *e) {
}
}
+void CIRGenFunction::emitNullInitialization(mlir::Location loc, Address
destPtr,
+QualType ty) {
+ // Ignore empty classes in C++.
+ if (getLangOpts().
@@ -196,6 +196,21 @@ class CIRToLLVMTrapOpLowering : public
mlir::OpConversionPattern {
mlir::ConversionPatternRewriter &) const override;
};
+class CIRToLLVMPtrStrideOpLowering
+: public mlir::OpConversionPattern {
+ mlir::DataLayout const &dataLayout;
@@ -620,6 +684,28 @@ mlir::LogicalResult
CIRToLLVMStoreOpLowering::matchAndRewrite(
return mlir::LogicalResult::success();
}
+/// Switches on the type of attribute and calls the appropriate conversion.
+mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
+
@@ -658,6 +744,27 @@ mlir::LogicalResult
CIRToLLVMConstantOpLowering::matchAndRewrite(
}
assert(!cir::MissingFeatures::opGlobalViewAttr());
attr = op.getValue();
+ } else if (const auto arrTy = mlir::dyn_cast(op.getType())) {
+const auto constArr = mlir::dyn_c
@@ -540,6 +542,68 @@ mlir::LogicalResult
CIRToLLVMCastOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMPtrStrideOpLowering::matchAndRewrite(
+cir::PtrStrideOp ptrStrideOp, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewri
@@ -412,3 +412,26 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const
APValue &value,
}
llvm_unreachable("Unknown APValue kind");
}
+
+mlir::Value CIRGenModule::emitNullConstant(QualType t, mlir::Location loc) {
+ if (t->getAs()) {
+return builder.getNullPtr(getT
@@ -0,0 +1,150 @@
+//- LoweringHelpers.cpp - Lowering helper functions
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -620,6 +684,28 @@ mlir::LogicalResult
CIRToLLVMStoreOpLowering::matchAndRewrite(
return mlir::LogicalResult::success();
}
+/// Switches on the type of attribute and calls the appropriate conversion.
+mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
+
@@ -0,0 +1,273 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,273 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
andykaylor wrote:
> I already removed some parts like TypeSizeInfoAttr and AddrSpace before
> creating the PR for that reason, I will double check again if I can remove
> anything else
I'm not sure it's worth splitting up now, but you probably could have
implemented the zero-initialization ca
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
andykaylor wrote:
@mmha I missed one thing in your binop PR.
https://github.com/llvm/llvm-project/pull/133001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
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
@@ -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
@@ -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,
-
https://github.com/andykaylor updated
https://github.com/llvm/llvm-project/pull/132468
>From 9e84f55c840890befed2720e498c068ff4ca36cd Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Fri, 21 Mar 2025 13:11:11 -0700
Subject: [PATCH 1/4] [CIR] Emit allocas into the proper lexical scope
Alloca op
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/133001
When CIR binop support was commited, it accidentally included a test for
functionality that was removed during the review process (cir.binop.overflow).
This test, of course, fails.
This change removes the f
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/132996
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/133134
This fixes unused variable warnings that have crept into the ClangIR code. In
some cases the variable will be needed later, but all unused variables are
being removed here. They can be reintroduced when they
andykaylor wrote:
@mmha
https://github.com/llvm/llvm-project/pull/133134
___
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/133017
>From ea61ece2a4111d41e653acde3936bc6086e248ff Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Tue, 25 Mar 2025 13:12:58 -0700
Subject: [PATCH 1/2] [CIR][NFC] Organize emit functions in CIRGenFunction.h
To
andykaylor wrote:
@mmha I should have copied you on this earlier.
https://github.com/llvm/llvm-project/pull/133017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/133017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
andykaylor wrote:
@mmha
https://github.com/llvm/llvm-project/pull/133157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -514,9 +515,17 @@ mlir::LogicalResult
CIRToLLVMCastOpLowering::matchAndRewrite(
assert(!MissingFeatures::cxxABI());
assert(!MissingFeatures::dataMemberType());
break;
- case cir::CastKind::ptr_to_bool:
-assert(!cir::MissingFeatures::opCmp());
+ case cir::C
https://github.com/andykaylor commented:
This looks really good. I have just a few minor comments and a request for more
tests.
https://github.com/llvm/llvm-project/pull/133159
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm
@@ -710,6 +710,89 @@ class ScalarExprEmitter : public
StmtVisitor {
HANDLEBINOP(Xor)
HANDLEBINOP(Or)
#undef HANDLEBINOP
+
+ mlir::Value emitCmp(const BinaryOperator *e) {
+mlir::Value result;
+QualType lhsTy = e->getLHS()->getType();
+QualType rhsTy = e->getRH
@@ -710,6 +710,89 @@ class ScalarExprEmitter : public
StmtVisitor {
HANDLEBINOP(Xor)
HANDLEBINOP(Or)
#undef HANDLEBINOP
+
+ mlir::Value emitCmp(const BinaryOperator *e) {
+mlir::Value result;
+QualType lhsTy = e->getLHS()->getType();
+QualType rhsTy = e->getRH
@@ -710,6 +710,89 @@ class ScalarExprEmitter : public
StmtVisitor {
HANDLEBINOP(Xor)
HANDLEBINOP(Or)
#undef HANDLEBINOP
+
+ mlir::Value emitCmp(const BinaryOperator *e) {
+mlir::Value result;
+QualType lhsTy = e->getLHS()->getType();
+QualType rhsTy = e->getRH
https://github.com/andykaylor edited
https://github.com/llvm/llvm-project/pull/133159
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1402,3 +1501,23 @@ mlir::Value
CIRGenFunction::emitScalarPrePostIncDec(const UnaryOperator *e,
return ScalarExprEmitter(*this, builder)
.emitScalarPrePostIncDec(e, lv, isInc, isPre);
}
+
+mlir::Value CIRGenFunction::emitCheckedInBoundsGEP(
+mlir::Type elemTy, m
@@ -658,6 +742,27 @@ mlir::LogicalResult
CIRToLLVMConstantOpLowering::matchAndRewrite(
}
assert(!cir::MissingFeatures::opGlobalViewAttr());
attr = op.getValue();
+ } else if (const auto arrTy = mlir::dyn_cast(op.getType())) {
+const auto constArr = mlir::dyn_c
@@ -620,6 +682,28 @@ mlir::LogicalResult
CIRToLLVMStoreOpLowering::matchAndRewrite(
return mlir::LogicalResult::success();
}
+/// Switches on the type of attribute and calls the appropriate conversion.
+mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
@@ -658,6 +742,27 @@ mlir::LogicalResult
CIRToLLVMConstantOpLowering::matchAndRewrite(
}
assert(!cir::MissingFeatures::opGlobalViewAttr());
attr = op.getValue();
+ } else if (const auto arrTy = mlir::dyn_cast(op.getType())) {
+const auto constArr = mlir::dyn_c
@@ -0,0 +1,150 @@
+//- LoweringHelpers.cpp - Lowering helper functions
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/133157
This adds basic support for while and do..while loops. Support for break and
continue are left for a subsequent patch.
>From ecaf51cd128e9045b9926ecafc918ec3e35a9908 Mon Sep 17 00:00:00 2001
From: Andy Kaylo
@@ -170,7 +170,7 @@ mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr
*e) {
SourceLocation loc = e->getExprLoc();
assert(!cir::MissingFeatures::pgoUse());
- if (const MemberPointerType *MPT = e->getType()->getAs())
{
+ if (e->getType()->getAs()) {
-
@@ -1251,13 +1236,12 @@ void ConvertCIRToLLVMPass::runOnOperation() {
patterns.add(converter, patterns.getContext(), dl);
patterns.add(converter, patterns.getContext(),
dl);
patterns.add(converter, patterns.getContext(), dl);
- patterns.add(converter, patterns.getContex
@@ -759,6 +761,84 @@ def BrCondOp : CIR_Op<"brcond",
}];
}
+//===--===//
+// While & DoWhileOp
+//===--===//
+
+class WhileOpBase : CIR_Op
@@ -1366,8 +1366,7 @@ mlir::Value
ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr(
const mlir::Location loc = cgf.getLoc(e->getSourceRange());
if (auto kind = e->getKind();
kind == UETT_SizeOf || kind == UETT_DataSizeOf) {
-if (const VariableArrayType *variableA
@@ -223,6 +223,16 @@ class CIRGenFunction : public CIRGenTypeCache {
void emitDecl(const clang::Decl &d);
+ /// Same as IRBuilder::CreateInBoundsGEP, but additionally emits a check to
+ /// detect undefined behavior when the pointer overflow sanitizer is enabled.
+ /// \
@@ -67,6 +67,40 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return create(loc, attr.getType(), attr);
}
+ mlir::TypedAttr getConstNullPtrAttr(mlir::Type t) {
+assert(mlir::isa(t) && "expected cir.ptr");
+return getConstPtrAttr(t, 0);
+ }
+
+ mlir::Typ
@@ -67,6 +67,40 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return create(loc, attr.getType(), attr);
}
+ mlir::TypedAttr getConstNullPtrAttr(mlir::Type t) {
+assert(mlir::isa(t) && "expected cir.ptr");
+return getConstPtrAttr(t, 0);
+ }
+
+ mlir::Typ
@@ -1117,6 +1118,122 @@ mlir::LogicalResult
CIRToLLVMBinOpLowering::matchAndRewrite(
return mlir::LogicalResult::success();
}
+mlir::LogicalResult CIRToLLVMBinOpOverflowOpLowering::matchAndRewrite(
+cir::BinOpOverflowOp op, OpAdaptor adaptor,
+mlir::ConversionPatter
@@ -936,8 +936,107 @@ getUnwidenedIntegerType(const ASTContext &astContext,
const Expr *e) {
static mlir::Value emitPointerArithmetic(CIRGenFunction &cgf,
const BinOpInfo &op,
bool isSubtraction)
https://github.com/andykaylor commented:
I don't see the value of this PR right now. The pointer arithmetic isn't
performing the correct arithmetic, and nothing generates the binop.overflow op.
It would be more useful to remove the binop.overflow part and add PtrDiffOp.
https://github.com/llvm
@@ -936,8 +936,107 @@ getUnwidenedIntegerType(const ASTContext &astContext,
const Expr *e) {
static mlir::Value emitPointerArithmetic(CIRGenFunction &cgf,
const BinOpInfo &op,
bool isSubtraction)
@@ -936,8 +936,107 @@ getUnwidenedIntegerType(const ASTContext &astContext,
const Expr *e) {
static mlir::Value emitPointerArithmetic(CIRGenFunction &cgf,
const BinOpInfo &op,
bool isSubtraction)
https://github.com/andykaylor edited
https://github.com/llvm/llvm-project/pull/133118
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -936,8 +936,107 @@ getUnwidenedIntegerType(const ASTContext &astContext,
const Expr *e) {
static mlir::Value emitPointerArithmetic(CIRGenFunction &cgf,
const BinOpInfo &op,
bool isSubtraction)
@@ -0,0 +1,233 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir
-emit-cir -DCIR_ONLY %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value
-fclangir -emit-llvm %
@@ -228,6 +257,42 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::FPAttr
fltAttr) {
loc, converter->convertType(fltAttr.getType()), fltAttr.getValue());
}
+// ConstArrayAttr visitor
+mlir::Value CIRAttrToValue::visitCirAttr(cir::ConstArrayAttr attr) {
+ mlir::Type llv
@@ -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/andykaylor created
https://github.com/llvm/llvm-project/pull/133829
The initial upstreaming of unary operations left promoted types unhandled for
the unary plus and minus operators. This change implements support for promoted
types and performs a bit of related code cleanup.
andykaylor wrote:
@mmha
https://github.com/llvm/llvm-project/pull/133829
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
andykaylor wrote:
@mmha
https://github.com/llvm/llvm-project/pull/133815
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -327,4 +337,4 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
} // namespace cir
-#endif
+#endif
andykaylor wrote:
This indicates that you (or some tool you're using) removed the newline
character at the end of the file. It's a good practice to conf
@@ -0,0 +1,274 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,274 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,274 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,274 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,274 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,274 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
@@ -0,0 +1,274 @@
+//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Ap
https://github.com/andykaylor approved this pull request.
lgtm
https://github.com/llvm/llvm-project/pull/133152
___
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/133157
>From ecaf51cd128e9045b9926ecafc918ec3e35a9908 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Mon, 24 Mar 2025 14:07:34 -0700
Subject: [PATCH 1/2] [CIR] Upstream support for while and do..while loops
This
@@ -710,6 +710,85 @@ class ScalarExprEmitter : public
StmtVisitor {
HANDLEBINOP(Xor)
HANDLEBINOP(Or)
#undef HANDLEBINOP
+
+ mlir::Value emitCmp(const BinaryOperator *e) {
+const mlir::Location loc = cgf.getLoc(e->getExprLoc());
+mlir::Value result;
+QualType l
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/133815
A previous checkin used a workaround to generate the nsw flag where needed for
unary ops. This change upstreams a subsequent change that was made in the
incubator to generate the flag correctly.
>From a96e0
@@ -12,22 +16,307 @@ void b0(int a, int b) {
x = x | b;
}
-// CHECK: %{{.+}} = cir.binop(mul, %{{.+}}, %{{.+}}) nsw : !s32i
-// CHECK: %{{.+}} = cir.binop(div, %{{.+}}, %{{.+}}) : !s32i
-// CHECK: %{{.+}} = cir.binop(rem, %{{.+}}, %{{.+}}) : !s32i
-// CHECK: %{{.+}} = cir.bi
@@ -1138,8 +1138,9 @@ mlir::Value ScalarExprEmitter::emitShl(const BinOpInfo
&ops) {
mlir::isa(ops.lhs.getType()))
cgf.cgm.errorNYI("sanitizers");
- cgf.cgm.errorNYI("shift ops");
- return {};
+ return builder.create(cgf.getLoc(ops.loc),
and
@@ -759,6 +762,46 @@ LogicalResult cir::BinOp::verify() {
return mlir::success();
}
+//===--===//
+// ShiftOp
+//===--===//
+LogicalResult
@@ -110,6 +110,10 @@ class CIRGenFunction : public CIRGenTypeCache {
public:
mlir::Value createDummyValue(mlir::Location loc, clang::QualType qt);
+ void emitAggExpr(const clang::Expr *e, AggValueSlot slot);
andykaylor wrote:
These should be moved to the p
https://github.com/andykaylor updated
https://github.com/llvm/llvm-project/pull/132468
>From 6e84a91e4721d066ff3b79d5cb3535ac92f05af1 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Fri, 21 Mar 2025 13:11:11 -0700
Subject: [PATCH 1/4] [CIR] Emit allocas into the proper lexical scope
Alloca op
@@ -710,6 +710,89 @@ class ScalarExprEmitter : public
StmtVisitor {
HANDLEBINOP(Xor)
HANDLEBINOP(Or)
#undef HANDLEBINOP
+
+ mlir::Value emitCmp(const BinaryOperator *e) {
+mlir::Value result;
+QualType lhsTy = e->getLHS()->getType();
+QualType rhsTy = e->getRH
@@ -462,6 +462,58 @@ def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp",
"ScopeOp", "DoWhileOp",
let hasVerifier = 1;
}
+//===--===//
+// IfOp
+//===-
501 - 600 of 635 matches
Mail list logo