[clang] [OpenACC][CIR] Implement 'device_type' clause lowering for 'init'/'sh… (PR #135102)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -57,31 +75,90 @@ class OpenACCClauseCIREmitter final } } + mlir::acc::DeviceType decodeDeviceType(const IdentifierInfo *II) { + andykaylor wrote: I've been telling people not to put a blank line here because it seemed inconsistent with the prevaili

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -400,13 +400,126 @@ def VoidPtr : Type< "cir::VoidType::get($_builder.getContext()))"> { } +//===--===// +// StructType +// +// The base type for all RecordDecls. +//===---

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: cir-opt %s | FileCheck %s + +!s32i = !cir.int andykaylor wrote: Oops! That was a copy-paste error. https://github.com/llvm/llvm-project/pull/135105 ___ cfe-commits mailing list cfe-commits@list

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -37,6 +50,32 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { llvm_unreachable("Unsupported format for long double"); } + /// Get a CIR record kind from a AST declaration tag. + cir::StructType::RecordKind getRecordKind(const clang::TagTypeKind kind) { +

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,116 @@ +//===--===// +// +// 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: Apa

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -86,10 +86,80 @@ mlir::Type CIRGenTypes::convertFunctionTypeInternal(QualType qft) { return cir::FuncType::get(SmallVector{}, cgm.VoidTy); } +// This is CIR's version of CodeGenTypes::addRecordTypeName. It isn't shareable +// because CIR has different uniquing requiremen

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -37,6 +50,32 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { llvm_unreachable("Unsupported format for long double"); } + /// Get a CIR record kind from a AST declaration tag. + cir::StructType::RecordKind getRecordKind(const clang::TagTypeKind kind) { +

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -400,13 +400,126 @@ def VoidPtr : Type< "cir::VoidType::get($_builder.getContext()))"> { } +//===--===// +// StructType +// +// The base type for all RecordDecls. +//===---

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -86,10 +86,80 @@ mlir::Type CIRGenTypes::convertFunctionTypeInternal(QualType qft) { return cir::FuncType::get(SmallVector{}, cgm.VoidTy); } +// This is CIR's version of CodeGenTypes::addRecordTypeName. It isn't shareable +// because CIR has different uniquing requiremen

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -400,13 +400,126 @@ def VoidPtr : Type< "cir::VoidType::get($_builder.getContext()))"> { } +//===--===// +// StructType +// +// The base type for all RecordDecls. +//===---

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -400,13 +400,126 @@ def VoidPtr : Type< "cir::VoidType::get($_builder.getContext()))"> { } +//===--===// +// StructType +// +// The base type for all RecordDecls. +//===---

[clang] [OpenACC][CIR] Implement 'device_type' clause lowering for 'init'/'sh… (PR #135102)

2025-04-10 Thread Andy Kaylor via cfe-commits
@@ -96,18 +173,21 @@ mlir::LogicalResult CIRGenFunction::emitOpenACCOpAssociatedStmt( template mlir::LogicalResult -CIRGenFunction::emitOpenACCOp(mlir::Location start, +CIRGenFunction::emitOpenACCOp(OpenACCDirectiveKind dirKind, + SourceLocation

[clang] [OpenACC][CIR] Implement 'device_type' clause lowering for 'init'/'sh… (PR #135102)

2025-04-10 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor approved this pull request. lgtm https://github.com/llvm/llvm-project/pull/135102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream support for promoted types with unary plus/minus (PR #133829)

2025-03-31 Thread Andy Kaylor via cfe-commits
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.

[clang] [CIR] Upstream support for promoted types with unary plus/minus (PR #133829)

2025-03-31 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Generate the nsw flag correctly for unary ops (PR #133815)

2025-03-31 Thread Andy Kaylor via 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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via 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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] Fix complex long double division with -mno-x87. (PR #133152)

2025-03-31 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream support for while and do..while loops (PR #133157)

2025-03-31 Thread Andy Kaylor via 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

[clang] [CIR] Upstream CmpOp (PR #133159)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Generate the nsw flag correctly for unary ops (PR #133815)

2025-03-31 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream SelectOp and ShiftOp (PR #133405)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream SelectOp and ShiftOp (PR #133405)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream SelectOp and ShiftOp (PR #133405)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -759,6 +762,46 @@ LogicalResult cir::BinOp::verify() { return mlir::success(); } +//===--===// +// ShiftOp +//===--===// +LogicalResult

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-04-01 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream basic support for ArrayType (PR #130502)

2025-03-15 Thread Andy Kaylor via 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

[clang] [CIR] Upstream CastOp and scalar conversions (PR #130690)

2025-03-15 Thread Andy Kaylor via 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

[clang] [CIR] Upstream initial support for unary op (PR #131369)

2025-03-15 Thread Andy Kaylor via cfe-commits
@@ -568,6 +568,128 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite( return mlir::success(); } +mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite( +cir::UnaryOp op, OpAdaptor adaptor, +mlir::ConversionPatternRewriter &rewriter) const { +

[clang] [CIR] Upstream CastOp and scalar conversions (PR #130690)

2025-03-14 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream initial support for unary op (PR #131369)

2025-03-14 Thread Andy Kaylor via cfe-commits
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br", }]; } +//===--===// +// UnaryOp +//===--===// + +def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"

[clang] [CIR] Upstream initial support for unary op (PR #131369)

2025-03-14 Thread Andy Kaylor via cfe-commits
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br", }]; } +//===--===// +// UnaryOp +//===--===// + +def UnaryOpKind_Inc : I32EnumAttrCase<"Inc"

[clang] [CIR] Upstream initial support for unary op (PR #131369)

2025-03-15 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream CastOp and scalar conversions (PR #130690)

2025-03-15 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Handle NullStmt (PR #134889)

2025-04-08 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/134889 The handling for NullStmt was going to an error saying the statement handling wasn't implemented. It doesn't need any implementation. It is sufficient for emitSimpleStmt to just return success for that state

[clang] [CIR] Upstream ArraySubscriptExpr for fixed size array (PR #134536)

2025-04-08 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Handle NullStmt (PR #134889)

2025-04-08 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/134889 >From efbec15d42a83cd2f4980418a939a88af7c7b92a Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 8 Apr 2025 10:01:21 -0700 Subject: [PATCH 1/2] [CIR] Handle NullStmt The handling for NullStmt was going t

[clang] [CIR] Upstream ArraySubscriptExpr for fixed size array (PR #134536)

2025-04-08 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream ArraySubscriptExpr for fixed size array (PR #134536)

2025-04-08 Thread Andy Kaylor via cfe-commits
@@ -232,6 +233,152 @@ 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

[clang] [CIR] Upstream ArraySubscriptExpr for fixed size array (PR #134536)

2025-04-08 Thread Andy Kaylor via cfe-commits
@@ -232,6 +233,152 @@ 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

[clang] [CIR] Handle NullStmt (PR #134889)

2025-04-08 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor closed https://github.com/llvm/llvm-project/pull/134889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR][NFC] Upstream LValueBaseInfo handling (PR #134928)

2025-04-08 Thread Andy Kaylor via cfe-commits
@@ -27,7 +27,8 @@ 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) { +Address CIRGenFunction::emitPointerWithAlignment(cons

[clang] [CIR] Add if statement support (PR #134333)

2025-04-08 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream support for address of and dereference (PR #134317)

2025-04-08 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor closed 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

[clang] [CIR] Add if statement support (PR #134333)

2025-04-08 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor closed 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

[clang] [CIR] Fix warnings, again! (PR #135284)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor closed https://github.com/llvm/llvm-project/pull/135284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/135105 >From 80fa219739a4a6424ec55047fecb41f04d3cf844 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 9 Apr 2025 12:45:57 -0700 Subject: [PATCH 1/3] [CIR] Upstream minimal support for structure types This cha

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
@@ -37,6 +50,32 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { llvm_unreachable("Unsupported format for long double"); } + /// Get a CIR record kind from a AST declaration tag. + cir::StructType::RecordKind getRecordKind(const clang::TagTypeKind kind) { +

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
andykaylor wrote: I'm going to make the change to rename `cir.struct` to `cir.record` separately, since that's a bigger change and I'm still waiting for input from @bcardosolopes. Everything else has been addressed, I think. https://github.com/llvm/llvm-project/pull/135105

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,116 @@ +//===--===// +// +// 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: Apa

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
@@ -86,10 +86,64 @@ mlir::Type CIRGenTypes::convertFunctionTypeInternal(QualType qft) { return cir::FuncType::get(SmallVector{}, cgm.VoidTy); } +// This is CIR's version of CodeGenTypes::addRecordTypeName. It isn't shareable +// because CIR has different uniquing requiremen

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor edited https://github.com/llvm/llvm-project/pull/135105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,116 @@ +//===--===// +// +// 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: Apa

[clang] [CIR] Make LLVM & OGCG variables match the same pattern (PR #135427)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor approved this pull request. To clarify I wasn't saying that the LLVM checks and OGCG checks needed to use the same patterns/names (though it's nice that they do now). The important thing was not to have the value identifiers hard-corded in the checks. Thanks for t

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,116 @@ +//===--===// +// +// 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: Apa

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
@@ -400,13 +400,126 @@ def VoidPtr : Type< "cir::VoidType::get($_builder.getContext()))"> { } +//===--===// +// StructType +// +// The base type for all RecordDecls. +//===---

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/135105 >From 80fa219739a4a6424ec55047fecb41f04d3cf844 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 9 Apr 2025 12:45:57 -0700 Subject: [PATCH 1/5] [CIR] Upstream minimal support for structure types This cha

[clang] [CIR] Make LLVM & OGCG variables match the same pattern (PR #135427)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor closed https://github.com/llvm/llvm-project/pull/135427 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/135105 >From 3b19527073c656b631a990397a00030487b3f595 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 9 Apr 2025 12:45:57 -0700 Subject: [PATCH 1/5] [CIR] Upstream minimal support for structure types This cha

[clang] [CIR] Upstream minimal support for structure types (PR #135105)

2025-04-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/135105 >From 3b19527073c656b631a990397a00030487b3f595 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 9 Apr 2025 12:45:57 -0700 Subject: [PATCH 1/6] [CIR] Upstream minimal support for structure types This cha

[clang] [CIR] Add if statement support (PR #134333)

2025-04-07 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] Fix complex long double division with -mno-x87. (PR #133152)

2025-03-31 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][NFC] Fix warnings in ClangIR code (PR #133134)

2025-03-31 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream CmpOp (PR #133159)

2025-03-31 Thread Andy Kaylor via 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

[clang] [clang][NFC] Refactor CodeGen's hasBooleanRepresentation (PR #134159)

2025-04-02 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Generate the nsw flag correctly for unary ops (PR #133815)

2025-04-04 Thread Andy Kaylor via 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

[clang] [CIR] Upstream support for address of and dereference (PR #134317)

2025-04-04 Thread Andy Kaylor via 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(); +

[clang] [CIR] Upstream support for address of and dereference (PR #134317)

2025-04-04 Thread Andy Kaylor via 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

[clang] [CIR] Upstream support for break and continue statements (PR #134181)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -569,6 +569,36 @@ def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator, ]; } +//===--===// +// BreakOp +//===--===// + +def BreakOp : C

[clang] [CIR] Upstream initial for-loop support (PR #132266)

2025-03-20 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Emit allocas into the proper lexical scope (PR #132468)

2025-03-25 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-04-03 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

2025-04-03 Thread Andy Kaylor via 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

[clang] [CIR] Upstream support for logical not operations (PR #133966)

2025-04-03 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream support for address of and dereference (PR #134317)

2025-04-03 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream support for address of and dereference (PR #134317)

2025-04-03 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream support for logical not operations (PR #133966)

2025-04-03 Thread Andy Kaylor via 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:

[clang] [CIR] Upstream support for logical not operations (PR #133966)

2025-04-03 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Upstream support for break and continue statements (PR #134181)

2025-04-03 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream support for address of and dereference (PR #134317)

2025-04-03 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream support for break and continue statements (PR #134181)

2025-04-03 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream global initialization for ArrayType (PR #131657)

2025-03-26 Thread Andy Kaylor via cfe-commits
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

[clang] [CIR] Upstream CmpOp (PR #133159)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Add binary operators (PR #132420)

2025-04-04 Thread Andy Kaylor via 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(

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -462,6 +462,58 @@ def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "DoWhileOp", let hasVerifier = 1; } +//===--===// +// IfOp +//===-

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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, +

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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, +

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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, +

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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, +

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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, +

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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

[clang] [CIR] Add if statement support (PR #134333)

2025-04-04 Thread Andy Kaylor via cfe-commits
@@ -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, +

<    2   3   4   5   6   7   8   9   10   11   >