https://github.com/andykaylor closed
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
andykaylor wrote:
> @Andres-Salamanca thanks for working on this. We usually write tests that
> exercise any possible different paths codegen can take. For next rounds: it's
> fine if you add less things in one go and make it more incremental with the
> use of (a) errorNYI and (b) assert on mi
@@ -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
@@ -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
@@ -54,6 +56,67 @@ struct CIRFlattenCFGPass : public
CIRFlattenCFGBase {
void runOnOperation() override;
};
+struct CIRIfFlattening : public mlir::OpRewritePattern {
+ using OpRewritePattern::OpRewritePattern;
+
+ mlir::LogicalResult
+ matchAndRewrite(cir::IfOp ifOp,
+
@@ -447,6 +448,133 @@ mlir::LogicalResult cir::ReturnOp::verify() {
return success();
}
+//===--===//
+// IfOp
+//===--===//
+
+ParseResult
@@ -447,6 +448,133 @@ mlir::LogicalResult cir::ReturnOp::verify() {
return success();
}
+//===--===//
+// IfOp
+//===--===//
+
+ParseResult
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/133966
___
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/132269
>From bee4e73e125c5643eb321ffef7b2b8e25f881267 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Thu, 20 Mar 2025 11:23:02 -0700
Subject: [PATCH 1/2] [CIR] Fix unary op folding
Unary ops had previously been o
https://github.com/andykaylor edited
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
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/132266
___
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/133100
___
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/134181
This adds ClangIR support for break and continue statements in loops.
Because only loops are currently implemented upstream in CIR, only breaks in
loops are supported here, but this same code will work (with
@@ -45,6 +45,41 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return false;
}
+ // Return true if this is the null value
andykaylor wrote:
This isn't quite the comment I wanted to see. It doesn't tell me any more than
the function name did
@@ -165,6 +165,25 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr
*e) {
return LValue();
}
+mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *e) {
andykaylor wrote:
I'm not sure `Bool` is ever used to represent an `i8`. Typically the
https://github.com/andykaylor created
https://github.com/llvm/llvm-project/pull/132996
Lowering of int-to-bool casts had been left as NYI because the incubator
implemented it by lowering to cir.cmp, which hasn't been upstreamed yet, but
there is no reason this cast can't be lowered directly to
https://github.com/andykaylor updated
https://github.com/llvm/llvm-project/pull/133829
>From 92d711c92b89e08d47d7f617a222d982040a4f19 Mon Sep 17 00:00:00 2001
From: Andy Kaylor
Date: Mon, 31 Mar 2025 17:02:08 -0700
Subject: [PATCH] [CIR] Upstream support for promoted types with unary
plus/minu
@@ -265,3 +265,125 @@ void test_empty_while_true() {
// OGCG: br label %[[WHILE_BODY:.*]]
// OGCG: [[WHILE_BODY]]:
// OGCG: ret void
+
+void unreachable_after_continue() {
+ for (;;) {
+continue;
+int x = 1;
+ }
+}
+
+// CIR: cir.func @unreachable_after_continue
+
@@ -103,6 +113,36 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
getContext(), mlir::cast(type), valueAttr);
}
+ mlir::TypedAttr getConstNullPtrAttr(mlir::Type t) {
+assert(mlir::isa(t) && "expected cir.ptr");
+return getConstPtrAttr(t, 0);
+ }
+
+ m
@@ -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:
https://github.com/andykaylor closed
https://github.com/llvm/llvm-project/pull/134181
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -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
@@ -135,6 +135,55 @@ mlir::Location CIRGenFunction::getLoc(mlir::Location lhs,
mlir::Location rhs) {
return mlir::FusedLoc::get(locs, metadata, &getMLIRContext());
}
+bool CIRGenFunction::ContainsLabel(const Stmt *s, bool ignoreCaseStmts) {
+ // Null statement, not a label
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be
@@ -198,6 +198,19 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return create(loc, cir::BinOpKind::Div, lhs, rhs);
}
+
+ /// Create a cir.ptr_stride operation to get access to an array element.
+ /// idx is the index of the element to access, shouldDecay is
@@ -157,6 +157,15 @@ class ScalarExprEmitter : public
StmtVisitor {
mlir::Value VisitCastExpr(CastExpr *e);
+ mlir::Value VisitArraySubscriptExpr(ArraySubscriptExpr *e) {
+if (e->getBase()->getType()->isVectorType()) {
+ assert(!cir::MissingFeatures::scalableVect
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be
@@ -29,8 +29,15 @@ int f[5] = {1, 2};
void func() {
int arr[10];
-
// CHECK: %[[ARR:.*]] = cir.alloca !cir.array,
!cir.ptr>, ["arr"]
+
+ int e = arr[1];
andykaylor wrote:
Can you add a test case for `arr[0]`? That's a special case in terms of
resultin
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be
@@ -232,6 +233,161 @@ LValue CIRGenFunction::emitUnaryOpLValue(const
UnaryOperator *e) {
llvm_unreachable("Unknown unary operator kind!");
}
+/// If the specified expr is a simple decay from an array to pointer,
+/// return the array subexpression.
+/// FIXME: this could be
@@ -198,6 +198,19 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
return create(loc, cir::BinOpKind::Div, lhs, rhs);
}
+
+ /// Create a cir.ptr_stride operation to get access to an array element.
+ /// idx is the index of the element to access, shouldDecay is
601 - 635 of 635 matches
Mail list logo