@@ -165,6 +165,33 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr
*e) {
return LValue();
}
+/// Emit code to compute the specified expression which
+/// can have any type. The result is returned as an RValue struct.
+RValue CIRGenFunction::emitAnyExpr(const E
andykaylor wrote:
@bcardosolopes Do you have any comments on this before I merge it?
https://github.com/llvm/llvm-project/pull/130861
___
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/130869
>From a4e8aa13f97a6c73389822f6fdcf6f5970792462 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Tue, 11 Mar 2025 17:01:44 -0700
Subject: [PATCH 1/5] [CIR] Upstream support for emitting ignored statements
Thi
https://github.com/andykaylor updated
https://github.com/llvm/llvm-project/pull/130869
>From a4e8aa13f97a6c73389822f6fdcf6f5970792462 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Tue, 11 Mar 2025 17:01:44 -0700
Subject: [PATCH 1/2] [CIR] Upstream support for emitting ignored statements
Thi
@@ -33,6 +33,14 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
llvm_unreachable("NYI: PPC double-double format for long double");
llvm_unreachable("Unsupported format for long double");
}
+
+ bool isSized(mlir::Type ty) {
+if (mlir::isa(ty))
+ r
@@ -33,6 +33,14 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
llvm_unreachable("NYI: PPC double-double format for long double");
llvm_unreachable("Unsupported format for long double");
}
+
+ bool isSized(mlir::Type ty) {
+if (mlir::isa(ty))
+ r
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/130869
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/andykaylor commented:
Can you also add a test for lowering to LLVM IR?
https://github.com/llvm/llvm-project/pull/130502
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi
@@ -121,29 +364,173 @@ mlir::Value CIRGenFunction::emitScalarExpr(const Expr
*e) {
return ScalarExprEmitter(*this, builder).Visit(const_cast(e));
}
+[[maybe_unused]] static bool MustVisitNullValue(const Expr *e) {
+ // If a null pointer expression's type is the C++0x nullp
@@ -568,6 +568,128 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
+cir::UnaryOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir
-emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+unsigned char cxxstaticcast_0(unsigned int x) {
+ return static_cast(x);
+}
+
+// CHECK: cir.func @cxxstaticcast_0
+// C
@@ -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
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir
-emit-cir %s -o %t.cir
andykaylor wrote:
It looks like floating casts are still missing. Can you add float-to-double and
double-to-float test?
https://github.com/llvm/ll
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/131181
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -121,29 +364,173 @@ mlir::Value CIRGenFunction::emitScalarExpr(const Expr
*e) {
return ScalarExprEmitter(*this, builder).Visit(const_cast(e));
}
+[[maybe_unused]] static bool MustVisitNullValue(const Expr *e) {
+ // If a null pointer expression's type is the C++0x nullp
@@ -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/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
@@ -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"
@@ -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
https://github.com/andykaylor edited
https://github.com/llvm/llvm-project/pull/130690
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,100 @@
+// 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 %
https://github.com/andykaylor approved this pull request.
LGTM with one very minor nit
https://github.com/llvm/llvm-project/pull/130690
___
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/131891
This change introduces the cir-canonicalize pass. This is a simple cir-to-cir
transformation that eliminates empty scopes and redundant branches. It will be
expanded in future changes to simplify other redun
andykaylor wrote:
cc: @mmha
https://github.com/llvm/llvm-project/pull/131912
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -31,6 +31,20 @@ struct CIROpAsmDialectInterface : public
OpAsmDialectInterface {
using OpAsmDialectInterface::OpAsmDialectInterface;
AliasResult getAlias(Type type, raw_ostream &os) const final {
+if (auto intType = dyn_cast(type)) {
+ // We only provide alias
andykaylor wrote:
The `CIR/Lowering/func-simple.cpp` test is failing after this merge because of
my change to introduce the canonicalize pass. I'll update the test as part of
my type alias patch.
https://github.com/llvm/llvm-project/pull/131945
___
c
@@ -271,16 +314,61 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const
APValue &value,
cgm.getASTContext().getTargetInfo().useFP16ConversionIntrinsics()) {
cgm.errorNYI("ConstExprEmitter::tryEmitPrivate half");
return {};
-} else {
- mlir::Typ
@@ -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) {
+ auto llvmTy =
@@ -89,6 +89,7 @@ list(APPEND CLANG_TEST_DEPS
if(CLANG_ENABLE_CIR)
list(APPEND CLANG_TEST_DEPS
cir-opt
+cir-translate
andykaylor wrote:
That won't be needed until we upstream one of the tests that uses it. Those are
all in the Lowering/ThroughMLIR d
@@ -158,13 +158,56 @@ class ConstExprEmitter
// TODO(cir): this can be shared with LLVM's codegen
static QualType getNonMemoryType(CIRGenModule &cgm, QualType type) {
- if (auto at = type->getAs()) {
+ if (const auto *at = type->getAs()) {
return cgm.getASTContext().get
https://github.com/andykaylor edited
https://github.com/llvm/llvm-project/pull/131657
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/andykaylor commented:
I have just a few more issues.
https://github.com/llvm/llvm-project/pull/131657
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -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
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/131912
CIR uses aliases for standard integer types and void. This change adds upstream
support for those aliases and updates existing tests.
>From 7871276b608f4a9bf5e5a48180b9e10dc564ce8a Mon Sep 17 00:00:00 2001
F
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
__
https://github.com/andykaylor approved this pull request.
lgtm
https://github.com/llvm/llvm-project/pull/132093
___
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/131912
>From a635a7d62251eb1b33218d5ba9fa34ad7a8f5567 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Tue, 18 Mar 2025 13:48:03 -0700
Subject: [PATCH 1/2] [CIR] Upstream support for type aliases and clean up
tests
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/132269
Unary ops had previously been omitted from the list of ops handled in the
CIRCanonicalizePass. Although the incubator code doesn't use them directly, the
mlir folding code does.
This change enables folding
andykaylor wrote:
@mmha This fixes the problem you noticed earlier.
https://github.com/llvm/llvm-project/pull/132269
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -165,6 +165,25 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr
*e) {
return LValue();
}
+mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *e) {
andykaylor wrote:
Even for C, we want to generate a cir.bool value. The classic codege
@@ -52,6 +52,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
return cir::BoolAttr::get(getContext(), getBoolTy(), state);
}
+ /// Create a for operation.
+ cir::ForOp createFor(
+ mlir::Location loc,
+ llvm::function_ref condBuilder,
andykaylor wrote:
CC: @mmha
https://github.com/llvm/llvm-project/pull/132468
___
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,
andykaylor wrote:
```suggestion
mlir::Value createBi
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/132468
Alloca operations were being emitted into the entry block of the current
function unconditionally, even if the variable they represented was
declared in a different scope. This change upstreams the code for ha
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
@@ -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
@@ -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; }
+ static bool pointerOverflowS
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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(
@@ -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
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
@@ -280,3 +313,77 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const
ReturnStmt &s) {
return mlir::success();
}
+
+mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &s) {
+ cir::ForOp forOp;
+
+ // TODO: pass in an array of attributes.
+ auto forStmt
@@ -2997,6 +2997,7 @@ static void RenderFloatingPointOptions(const ToolChain
&TC, const Driver &D,
LangOptions::ComplexRangeKind Range = LangOptions::ComplexRangeKind::CX_None;
std::string ComplexRangeStr = "";
std::string GccRangeComplexOption = "";
+ std::string LastC
@@ -177,14 +177,45 @@
// RUN: %clang -### -target x86_64 -ffast-math -fcomplex-arithmetic=basic -c
%s 2>&1 \
// RUN: | FileCheck --check-prefix=BASIC %s
-// BASIC: -complex-range=basic
-// FULL: -complex-range=full
-// PRMTD: -complex-range=promoted
-// BASIC-NOT: -complex-
@@ -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
@@ -293,7 +294,8 @@ void CIRGenFunction::startFunction(GlobalDecl gd, QualType
returnType,
mlir::Value addrVal =
emitAlloca(cast(paramVar)->getName(),
- convertType(paramVar->getType()), paramLoc, alignment);
+ convertType(param
@@ -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
@@ -0,0 +1,49 @@
+// RUN %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
+// RUN -verify -complex-range=promoted -o - | FileCheck %s
+
+// RUN %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
+// RUN -verify=nopromotion -complex-range=promoted -target-fe
https://github.com/andykaylor closed
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
@@ -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 created
https://github.com/llvm/llvm-project/pull/134159
The ClangIR upstreaming project needs the same logic for
hasBooleanRepresentation() that is currently implemented in the standard clang
codegen. In order to share this code, this change moves the implementat
@@ -280,3 +313,77 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const
ReturnStmt &s) {
return mlir::success();
}
+
+mlir::LogicalResult CIRGenFunction::emitForStmt(const ForStmt &s) {
+ cir::ForOp forOp;
+
+ // TODO: pass in an array of attributes.
+ auto forStmt
andykaylor wrote:
@mmha
https://github.com/llvm/llvm-project/pull/134333
___
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/133815
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -193,8 +334,23 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
switch (op) {
case UO_Deref: {
-cgm.errorNYI(e->getSourceRange(), "UnaryOp dereference");
-return LValue();
+QualType t = e->getSubExpr()->getType()->getPointeeType();
+
@@ -25,6 +25,147 @@ using namespace clang;
using namespace clang::CIRGen;
using namespace cir;
+/// Given an expression of pointer type, try to
+/// derive a more accurate bound on the alignment of the pointer.
+Address CIRGenFunction::emitPointerWithAlignment(const Expr *expr
@@ -569,6 +569,36 @@ def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator,
];
}
+//===--===//
+// BreakOp
+//===--===//
+
+def BreakOp : C
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/132266
This change adds support for empty for-loops. This will be the infrastructre
needed for complete for loops, but that depends on compare operations, which
have not been upstreamed yet.
>From 20c016291947451b
@@ -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
https://github.com/andykaylor approved this pull request.
This looks ready.
https://github.com/llvm/llvm-project/pull/132974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -110,6 +110,8 @@ class CIRGenFunction : public CIRGenTypeCache {
public:
mlir::Value createDummyValue(mlir::Location loc, clang::QualType qt);
+ void emitNullInitialization(mlir::Location loc, Address destPtr, QualType
ty);
andykaylor wrote:
The two em
@@ -1358,6 +1360,33 @@ mlir::Value
CIRGenFunction::emitScalarConversion(mlir::Value src,
.emitScalarConversion(src, srcTy, dstTy, loc);
}
+mlir::Value ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *e) {
+ // Perform vector logical not on comparison with zero ve
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/134317
This adds support for handling the address of and dereference unary operations
in ClangIR code generation. This also adds handling for nullptr and proper
initialization via the NullToPointer cast.
>From d13
andykaylor wrote:
@mmha
https://github.com/llvm/llvm-project/pull/134317
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1320,7 +1322,7 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr
*ce) {
"fixed point casts");
return {};
}
-cgf.getCIRGenModule().errorNYI(subExpr->getSourceRange(), "fp options");
+assert(!cir::MissingFeatures:
@@ -1358,6 +1360,33 @@ mlir::Value
CIRGenFunction::emitScalarConversion(mlir::Value src,
.emitScalarConversion(src, srcTy, dstTy, loc);
}
+mlir::Value ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *e) {
+ // Perform vector logical not on comparison with zero ve
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/3] [CIR] Upstream support for break and continue statements
T
andykaylor wrote:
I'm starting to be uncomfortable with the amount of alignment and
LValueBaseInfo support we've skipped over. I tried to add markers in this PR
where I wasn't adding support for those. I intend to fill in that support in a
separate PR soon.
https://github.com/llvm/llvm-projec
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/2] [CIR] Upstream support for break and continue statements
T
https://github.com/andykaylor approved this pull request.
Looks good. Thanks for the updates!
https://github.com/llvm/llvm-project/pull/131657
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c
@@ -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
@@ -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(
@@ -462,6 +462,58 @@ def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp",
"ScopeOp", "DoWhileOp",
let hasVerifier = 1;
}
+//===--===//
+// IfOp
+//===-
@@ -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,
+
@@ -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,
+
@@ -164,6 +165,20 @@ class CIRGenFunction : public CIRGenTypeCache {
/// that it requires no code to be generated.
bool isTrivialInitializer(const Expr *init);
+ /// If the specified expression does not fold to a constant, or if it does
but
+ /// contains a label, retur
@@ -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,
+
401 - 500 of 635 matches
Mail list logo