[clang] [CIR] Add Minimal Destructor Definition Support (PR #144719)

2025-06-18 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/144719 >From 278750574dd72831347bbba144bd49ded9daaa3c Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Wed, 18 Jun 2025 15:09:21 +0100 Subject: [PATCH 1/2] [CIR] Add Minimal Destructor Definition Support This patch upst

[clang] [CIR] Add Minimal Destructor Definition Support (PR #144719)

2025-06-18 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/144719 This patch upstreams support for writing inline and out of line C++ destructor definitions. Calling a destructor implcitly or explicitly is left for a future patch. Because of that restriction complete destructors

[clang] [CIR][NFCI] Represent Complex RValues As Single Value (PR #144519)

2025-06-17 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/144519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Handle global string literals as char array initializer (PR #144384)

2025-06-17 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM, just a request for three more test cases. I'm not sure if they work upstream already. If they don't, let's just skip over them for now. ```c++ char oversized[100] = "123"; char exact[4] = "123"; decltype(auto) returns_literal() { re

[clang] [CIR][NFC] Fix build problems with [[maybe_unused]] (PR #143994)

2025-06-12 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. This fixes the build on my machine with clang 19.1. Thanks! https://github.com/llvm/llvm-project/pull/143994 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [CIR] Add Support For Library Builtins (PR #143984)

2025-06-12 Thread Morris Hafner via cfe-commits
@@ -76,3 +76,21 @@ float constant_fp_builtin_single() { // OGCG: define {{.*}}float @_Z26constant_fp_builtin_singlev() // OGCG: ret float 0x3FB9A000 // OGCG: } + +void library_builtins() { + __builtin_printf(nullptr); mmha wrote: I added `builtin_prin

[clang] [CIR] Add Support For Library Builtins (PR #143984)

2025-06-12 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/143984 >From c60378591a7d8d156306ff9c840aa319396c4f00 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 13 Jun 2025 00:04:24 +0200 Subject: [PATCH 1/3] [CIR] Add Support For Library Builtins This patch upstreams sup

[clang] [CIR] Add Support For Library Builtins (PR #143984)

2025-06-12 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/143984 >From c60378591a7d8d156306ff9c840aa319396c4f00 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 13 Jun 2025 00:04:24 +0200 Subject: [PATCH 1/2] [CIR] Add Support For Library Builtins This patch upstreams sup

[clang] [CIR] Add Support For Library Builtins (PR #143984)

2025-06-12 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/143984 This patch upstreams support for builtins that map to a standard library function. Examples would be abort() and printf(). It also fixes a minor issue with the errorNYI for all remaining unimplemented builtins usi

[clang] [CIR] Upstream minimal builtin function call support (PR #142981)

2025-06-11 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/142981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream minimal builtin function call support (PR #142981)

2025-06-11 Thread Morris Hafner via cfe-commits
@@ -229,6 +231,19 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { cir::IntType getUInt32Ty() { return typeCache.UInt32Ty; } cir::IntType getUInt64Ty() { return typeCache.UInt64Ty; } + cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal); + + cir

[clang] [CIR] Upstream minimal builtin function call support (PR #142981)

2025-06-11 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/142981 >From 1faee59aebae98bf01ecac07a7a5d70f2f9ca2db Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Mon, 9 Jun 2025 14:52:55 +0200 Subject: [PATCH 1/6] [CIR] Upstream minimal builtin function call support This patch

[clang] [CIR] Upstream minimal builtin function call support (PR #142981)

2025-06-10 Thread Morris Hafner via cfe-commits
@@ -0,0 +1,453 @@ +//===--===// +// +// 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 builtin function call support (PR #142981)

2025-06-10 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/142981 >From 1e759f0ec3b010e64c44cc4e5f87ffbe8f4e3d21 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Mon, 9 Jun 2025 14:52:55 +0200 Subject: [PATCH 1/5] [CIR] Upstream minimal builtin function call support This patch

[clang] [CIR] Upstream minimal builtin function call support (PR #142981)

2025-06-09 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/142981 >From 939ad27d0d0dacc5b796e36ca9bca32d26f6b714 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Mon, 9 Jun 2025 14:52:55 +0200 Subject: [PATCH 1/4] [CIR] Upstream minimal builtin function call support This patch

[clang] [CIR][NFCI] Update RValue class to reflect changes in classic CodeGen (PR #142779)

2025-06-05 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/142779 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Update RValue class to reflect changes in classic CodeGen (PR #142779)

2025-06-04 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/142779 This changes clang::CIRGen::RValue to look like current clang::CodeGen::RValue which was changed in 84780a/[#86923](https://github.com/llvm/llvm-project/issues/86923). This should be NFC and is preliminary work fo

[clang] [CIR] Fix missing return value warning in maybePromoteBoolResult (PR #142673)

2025-06-04 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/142673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR][NFS] Fix dead code return statement warning (PR #142591)

2025-06-03 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM (and thanks!) https://github.com/llvm/llvm-project/pull/142591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Fix missing return value warning in maybePromoteBoolResult (PR #142673)

2025-06-03 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/142673 This is NFC and simply adds an llvm_unreachable >From 5e67287af5e55e3792e359812e539d8375d32f10 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 3 Jun 2025 23:19:50 +0200 Subject: [PATCH] [CIR] Fix missing re

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-06-03 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/138156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Skip generation of a continue block when flattening TernaryOp (PR #142165)

2025-05-30 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/142165 >From f62994df24f912a3815cabb7fc4a47fa8c8c948e Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 30 May 2025 16:29:05 +0200 Subject: [PATCH 1/2] [CIR] Skip generation of a continue block when flattening Terna

[clang] [CIR] Skip generation of a continue block when flattening TernaryOp (PR #142165)

2025-05-30 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/142165 We used to insert a continue Block at the end of a flattened ternary op that only contained a branch to the remaing operation of the remaining Block. This patch removes that continue block and changes the true/fals

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-29 Thread Morris Hafner via cfe-commits
@@ -540,3 +540,171 @@ void long_shift_example(long long a, short b) { // OGCG: store i64 %[[SHL]], ptr %[[X]] // OGCG: ret void + +void b1(bool a, bool b) { + bool x = a && b; + x = x || b; +} + +// CIR-LABEL: cir.func @_Z2b1bb( +// CIR-SAME: %[[ARG0:.*]]: !c

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-27 Thread Morris Hafner via cfe-commits
@@ -948,6 +950,165 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) { emitLValue(e); } +// Handle the case where the condition is a constant evaluatable simple integer, +// which means we don't have to separately handle the true/false blocks. +static std::optional han

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-27 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/138156 >From 66cea1ef63965b27617a6b6995ac1c5f8d8b8ed6 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 1 May 2025 17:27:23 +0200 Subject: [PATCH 1/4] [CIR] Upstream lowering of lvalue conditional operators to Terna

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-27 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/138156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-27 Thread Morris Hafner via cfe-commits
@@ -948,6 +950,165 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) { emitLValue(e); } +// Handle the case where the condition is a constant evaluatable simple integer, +// which means we don't have to separately handle the true/false blocks. +static std::optional han

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-20 Thread Morris Hafner via cfe-commits
@@ -1658,6 +1828,170 @@ mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( cgf.cgm.UInt64Ty, e->EvaluateKnownConstInt(cgf.getContext(; } +/// Return true if the specified expression is cheap enough and side-effect-free +/// enough to evaluate un

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-19 Thread Morris Hafner via cfe-commits
@@ -1658,6 +1828,170 @@ mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( cgf.cgm.UInt64Ty, e->EvaluateKnownConstInt(cgf.getContext(; } +/// Return true if the specified expression is cheap enough and side-effect-free +/// enough to evaluate un

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/138156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/138156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-19 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/138156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-19 Thread Morris Hafner via cfe-commits
@@ -948,6 +950,165 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) { emitLValue(e); } +// Handle the case where the condition is a constant evaluatable simple integer, +// which means we don't have to separately handle the true/false blocks. +static std::optional han

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-19 Thread Morris Hafner via cfe-commits
@@ -948,6 +950,165 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) { emitLValue(e); } +// Handle the case where the condition is a constant evaluatable simple integer, +// which means we don't have to separately handle the true/false blocks. +static std::optional han

[clang] [CIR] Add cir-simplify pass (PR #138317)

2025-05-07 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/138317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add cir-simplify pass (PR #138317)

2025-05-06 Thread Morris Hafner via cfe-commits
mmha wrote: @bcardosolopes Adding a test for C++ -> CIR depends on #138003 which adds lowering for `?:`, `&&` and `||`. Since this one's ready to be merged apart from your remark IMO I'd add that test in #138003 https://github.com/llvm/llvm-project/pull/138317 _

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/138368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
@@ -365,10 +365,15 @@ mlir::Attribute ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &d) { if (!d.hasLocalStorage()) { QualType ty = cgm.getASTContext().getBaseElementType(d.getType()); if (ty->isRecordType()) - if (d.getInit() && isa(d.getInit())) { -

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
@@ -177,18 +177,26 @@ void CIRRecordLowering::lower() { return; } - if (isa(recordDecl)) { -cirGenTypes.getCGModule().errorNYI(recordDecl->getSourceRange(), - "lower: class"); -return; - } - assert(!cir::MissingFeatures:

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
@@ -237,8 +237,11 @@ mlir::Type CIRGenTypes::convertRecordDeclType(const clang::RecordDecl *rd) { assert(insertResult && "isSafeToCovert() should have caught this."); // Force conversion of non-virtual base classes recursively. - if (isa(rd)) { -cgm.errorNYI(rd->getS

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
@@ -12,6 +12,17 @@ IncompleteS *p; // LLVM: @p = dso_local global ptr null // OGCG: @p = global ptr null, align 8 +struct CompleteS { mmha wrote: Do simple union work with this? If so, can you add a test for those, too? https://github.com/llvm/llvm-project/p

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM, just a few nits https://github.com/llvm/llvm-project/pull/138368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/138368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Unblock simple C++ structure support (PR #138368)

2025-05-03 Thread Morris Hafner via cfe-commits
@@ -365,10 +365,15 @@ mlir::Attribute ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &d) { if (!d.hasLocalStorage()) { QualType ty = cgm.getASTContext().getBaseElementType(d.getType()); if (ty->isRecordType()) - if (d.getInit() && isa(d.getInit())) { -

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-02 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/136807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -247,9 +247,35 @@ size_type max_size(void) { // CIR: %3 = cir.cast(integral, %2 : !s32i), !u64i // CIR: %4 = cir.const #cir.int<8> : !u64i // CIR: %5 = cir.binop(div, %3, %4) : !u64i +// CIR: cir.store %5, %0 : !u64i, !cir.ptr +// CIR: %6 = cir.load %0 : !cir.ptr,

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-02 Thread Morris Hafner via cfe-commits
https://github.com/mmha approved this pull request. LGTM, just two nits https://github.com/llvm/llvm-project/pull/136807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -417,6 +417,19 @@ mlir::Type CIRGenTypes::convertType(QualType type) { break; } + case Type::Enum: { +// TODO(cir): Implement updateCompletedType for enums. +assert(!cir.MissingFeatures::updateCompletedType()); +const EnumDecl *ED = cast(ty)->getDecl(); +

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-02 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/136807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

2025-05-02 Thread Morris Hafner via cfe-commits
https://github.com/mmha commented: Mostly a few nits. https://github.com/llvm/llvm-project/pull/138222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -365,46 +406,108 @@ mlir::Value CIRGenModule::getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty, void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd, bool isTentative) { const QualType astTy = vd->getType(); - c

[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -118,7 +210,26 @@ class ConstExprEmitter } mlir::Attribute VisitInitListExpr(InitListExpr *ile, QualType t) { -cgm.errorNYI(ile->getBeginLoc(), "ConstExprEmitter::VisitInitListExpr"); +if (ile->isTransparent()) + return Visit(ile->getInit(0), t); + +if

[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -365,46 +406,108 @@ mlir::Value CIRGenModule::getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty, void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd, bool isTentative) { const QualType astTy = vd->getType(); - c

[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -31,6 +31,15 @@ class ConstantEmitter { private: bool abstract = false; + /// Whether non-abstract components of the emitter have been initialized. + bool initializedNonAbstract = false; mmha wrote: Is this just for sanity checking? Should this be wrap

[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -90,8 +90,100 @@ class ConstExprEmitter } mlir::Attribute VisitCastExpr(CastExpr *e, QualType destType) { -cgm.errorNYI(e->getBeginLoc(), "ConstExprEmitter::VisitCastExpr"); -return {}; +if (const auto *ece = dyn_cast(e)) + cgm.errorNYI(e->getBeginLoc()

[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

2025-05-02 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/138222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add cir-simplify pass (PR #138317)

2025-05-02 Thread Morris Hafner via cfe-commits
@@ -27,6 +27,8 @@ def CIR_Dialect : Dialect { let useDefaultAttributePrinterParser = 0; let useDefaultTypePrinterParser = 0; + let hasConstantMaterializer = 1; mmha wrote: There's some documentation here: https://mlir.llvm.org/docs/Canonicalization/#gen

[clang] [CIR] Add cir-simplify pass (PR #138317)

2025-05-02 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/138317 This patch adds the cir-simplify pass for SelectOp and TernaryOp. It also adds the SelectOp folder and adds the constant materializer for the CIR dialect. >From 2b6ecd77c4fac0a2982172294d12ae858f0a2b34 Mon Sep 17 0

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-01 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/138156 >From 09763c19421acdb9896bab13f29679dbb38b9043 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 1 May 2025 17:27:23 +0200 Subject: [PATCH 1/2] [CIR] Upstream lowering of lvalue conditional operators to Terna

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-01 Thread Morris Hafner via cfe-commits
@@ -948,6 +950,165 @@ void CIRGenFunction::emitIgnoredExpr(const Expr *e) { emitLValue(e); } +// Handle the case where the condition is a constant evaluatable simple integer, +// which means we don't have to separately handle the true/false blocks. +static std::optional han

[clang] [CIR] Upstream lowering of conditional operators to TernaryOp (PR #138156)

2025-05-01 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/138156 This patch adds visitors for BinLAnd, BinLOr and AbstractConditionalOperator. Note that this patch still lacks visitation of OpaqueValueExpr which is needed for the GNU ?: operator. >From 09763c19421acdb9896bab13f

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-30 Thread Morris Hafner via cfe-commits
https://github.com/mmha closed https://github.com/llvm/llvm-project/pull/137184 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-25 Thread Morris Hafner via cfe-commits
@@ -609,8 +609,8 @@ def ConditionOp : CIR_Op<"condition", [ //===--===// def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator, - ParentOneOf<["IfOp", "ScopeOp", "WhileOp", -

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-25 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/137184 >From 1eed90e3859c2ad8d703708f89976cad8f0faeec Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 24 Apr 2025 16:12:37 +0200 Subject: [PATCH 1/3] [CIR] Upstream TernaryOp This patch adds TernaryOp to CIR plus

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-25 Thread Morris Hafner via cfe-commits
@@ -1246,6 +1246,59 @@ def SelectOp : CIR_Op<"select", [Pure, }]; } +//===--===// +// TernaryOp +//===--===// + +def TernaryOp : CIR_Op<"te

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-24 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/137184 >From 1eed90e3859c2ad8d703708f89976cad8f0faeec Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 24 Apr 2025 16:12:37 +0200 Subject: [PATCH 1/2] [CIR] Upstream TernaryOp This patch adds TernaryOp to CIR plus

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-24 Thread Morris Hafner via cfe-commits
@@ -1246,6 +1246,59 @@ def SelectOp : CIR_Op<"select", [Pure, }]; } +//===--===// +// TernaryOp +//===--===// + +def TernaryOp : CIR_Op<"te

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-24 Thread Morris Hafner via cfe-commits
@@ -609,8 +609,8 @@ def ConditionOp : CIR_Op<"condition", [ //===--===// def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator, - ParentOneOf<["IfOp", "ScopeOp", "WhileOp", -

[clang] [CIR] Upstream TernaryOp (PR #137184)

2025-04-24 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/137184 This patch adds TernaryOp to CIR plus a pass that flattens the operator in FlattenCFG. This is the first PR out of (probably) 3 wrt. TernaryOp. I split the patches up to make reviewing them easier. As such, this P

[clang] [OpenACC][CIR] Implement 'async' lowering. (PR #136626)

2025-04-22 Thread Morris Hafner via cfe-commits
@@ -639,6 +639,9 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause( OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause( SemaOpenACC::OpenACCParsedClause &Clause) { + if (DisallowSinceLastDeviceType(Clause)) mmha wrote: Can you u

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

2025-04-17 Thread Morris Hafner via cfe-commits
@@ -1294,6 +1296,90 @@ mlir::LogicalResult CIRToLLVMCmpOpLowering::matchAndRewrite( return mlir::success(); } +mlir::LogicalResult CIRToLLVMShiftOpLowering::matchAndRewrite( +cir::ShiftOp op, OpAdaptor adaptor, +mlir::ConversionPatternRewriter &rewriter) const { +

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

2025-04-14 Thread Morris Hafner via cfe-commits
@@ -1294,6 +1296,90 @@ mlir::LogicalResult CIRToLLVMCmpOpLowering::matchAndRewrite( return mlir::success(); } +mlir::LogicalResult CIRToLLVMShiftOpLowering::matchAndRewrite( +cir::ShiftOp op, OpAdaptor adaptor, +mlir::ConversionPatternRewriter &rewriter) const { +

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

2025-04-14 Thread Morris Hafner via cfe-commits
@@ -759,6 +762,46 @@ LogicalResult cir::BinOp::verify() { return mlir::success(); } +//===--===// +// ShiftOp +//===--===// +LogicalResult

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

2025-04-14 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/133405 >From 13833779faad62f95ef3fc0e2de3ed9b7c44d2f5 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 11 Apr 2025 17:46:00 +0200 Subject: [PATCH 1/2] [CIR] Upstream SelectOp and ShiftOp Since SelectOp will only ge

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-11 Thread Morris Hafner via cfe-commits
@@ -219,6 +219,13 @@ void CIRGenFunction::emitStoreOfScalar(mlir::Value value, Address addr, assert(!cir::MissingFeatures::opTBAA()); } +void CIRGenFunction::emitStoreThroughBitfieldLValue(RValue src, LValue dst, +mlir::Va

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-11 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/135115 >From 2a9a282dc3227710ce6462d2847876565ba5eb49 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 11 Apr 2025 16:17:45 +0200 Subject: [PATCH 1/4] [CIR] Upstream binary assignments and comma This patch adds `Vi

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-11 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/135115 >From 2a9a282dc3227710ce6462d2847876565ba5eb49 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 11 Apr 2025 16:17:45 +0200 Subject: [PATCH 1/4] [CIR] Upstream binary assignments and comma This patch adds `Vi

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-11 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/135115 >From 2a9a282dc3227710ce6462d2847876565ba5eb49 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 11 Apr 2025 16:17:45 +0200 Subject: [PATCH 1/3] [CIR] Upstream binary assignments and comma This patch adds `Vi

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-11 Thread Morris Hafner via cfe-commits
@@ -807,6 +808,65 @@ class ScalarExprEmitter : public StmtVisitor { VISITCOMP(EQ) VISITCOMP(NE) #undef VISITCOMP + + mlir::Value VisitBinAssign(const BinaryOperator *e) { +const bool ignore = std::exchange(ignoreResultAssign, false); + +mlir::Value rhs; +LValu

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-11 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/135115 >From bcaeadf7fff01d2d92b0d234b40f8d5884974e4c Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 10 Apr 2025 03:53:43 +0200 Subject: [PATCH 1/3] [CIR] Upstream binary assignments and comma This patch adds `Vi

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-10 Thread Morris Hafner via cfe-commits
@@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -std=c23 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir +// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR +// RUN: %clang_cc1 -std=c23 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-10 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/135115 >From bcaeadf7fff01d2d92b0d234b40f8d5884974e4c Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 10 Apr 2025 03:53:43 +0200 Subject: [PATCH 1/2] [CIR] Upstream binary assignments and comma This patch adds `Vi

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-09 Thread Morris Hafner via cfe-commits
mmha wrote: cc @erichkeane @andykaylor @dkolsen-pgi https://github.com/llvm/llvm-project/pull/135115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Upstream binary assignments and comma (PR #135115)

2025-04-09 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/135115 This patch adds `VisitBinAssign` and `VisitBinComma` to the ClangIR `ScalarExprEmitter` to enable assignments and the comma operator. >From bcaeadf7fff01d2d92b0d234b40f8d5884974e4c Mon Sep 17 00:00:00 2001 From: Mo

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

2025-04-08 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/133159 >From 57b1d4e30ab61c1723b34fea137e2e900b53e30e Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Tue, 8 Apr 2025 15:02:12 +0200 Subject: [PATCH 1/5] [CIR] Upstream CmpOp This patch adds support for comparison oper

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

2025-04-05 Thread Morris Hafner via cfe-commits
mmha wrote: cc @andykaylor @erichkeane @dkolsen-pgi 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

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

2025-04-05 Thread Morris Hafner via cfe-commits
@@ -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

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

2025-03-28 Thread Morris Hafner via cfe-commits
mmha wrote: cc @andykaylor @erichkeane @dkolsen-pgi https://github.com/llvm/llvm-project/pull/133405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-03-28 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/133405 Since SelectOp will only generated by a future pass that transforms a TernaryOp this only includes the lowering bits. This patch also improves the testing of the existing binary operators. >From fc549133df0092c9c2

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

2025-03-27 Thread Morris Hafner via cfe-commits
@@ -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 %

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

2025-03-27 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/133159 >From 6db5880fa7cdf6363d7e0025f811f42ec273df52 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Wed, 26 Mar 2025 20:50:57 + Subject: [PATCH 1/4] [CIR] Upstream CmpOp This patch adds support for comparison ope

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

2025-03-27 Thread Morris Hafner via cfe-commits
https://github.com/mmha 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

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

2025-03-27 Thread Morris Hafner 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] Upstream CmpOp (PR #133159)

2025-03-27 Thread Morris Hafner 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] Upstream CmpOp (PR #133159)

2025-03-27 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/133159 >From 6db5880fa7cdf6363d7e0025f811f42ec273df52 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Wed, 26 Mar 2025 20:50:57 + Subject: [PATCH 1/3] [CIR] Upstream CmpOp This patch adds support for comparison ope

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

2025-03-27 Thread Morris Hafner 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] [CIR] Upstream CmpOp (PR #133159)

2025-03-26 Thread Morris Hafner via cfe-commits
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/133159 >From 6db5880fa7cdf6363d7e0025f811f42ec273df52 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Wed, 26 Mar 2025 20:50:57 + Subject: [PATCH 1/2] [CIR] Upstream CmpOp This patch adds support for comparison ope

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

2025-03-26 Thread Morris Hafner via cfe-commits
https://github.com/mmha created https://github.com/llvm/llvm-project/pull/133159 This patch adds support for comparison operators with ClangIR, both integral and floating point. >From 6db5880fa7cdf6363d7e0025f811f42ec273df52 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Wed, 26 Mar 2025 2

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

2025-03-26 Thread Morris Hafner via cfe-commits
@@ -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()) { -

  1   2   >