[clang] [CIR] Upstream basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -52,6 +54,19 @@ class ScalarExprEmitter : public StmtVisitor { return {}; } + /// Emits the address of the l-value, then loads and returns the result. + mlir::Value emitLoadOfLValue(const Expr *e) { +LValue lv = cgf.emitLValue(e); +// FIXME: add some akin t

[clang] [CIR] Upstream basic alloca and load support (PR #128792)

2025-02-25 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/128792 >From 235ef9e23a314f8946b48143294da367b80f7d14 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 25 Feb 2025 12:31:08 -0800 Subject: [PATCH 1/2] [CIR] Upstream basic alloca and load support This change i

[clang] [CIR] Upstream basic alloca and load support (PR #128792)

2025-02-25 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/128792 This change implements basic support in ClangIR for local variables using the cir.alloca and cir.load operations. >From 235ef9e23a314f8946b48143294da367b80f7d14 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Da

[clang] [Clang][doc] -ffp-contract options and standard compliance (PR #127621)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -1681,19 +1681,25 @@ for more details. permitted to produce more precise results than performing the same operations separately. - The C standard permits intermediate floating-point results within an + The C/C++ standard permits intermediate floating-point results

[clang] [Clang][doc] -ffp-contract options and standard compliance (PR #127621)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -1681,19 +1681,25 @@ for more details. permitted to produce more precise results than performing the same operations separately. - The C standard permits intermediate floating-point results within an + The C/C++ standard permits intermediate floating-point results

[clang] [Clang][doc] -ffp-contract options and standard compliance (PR #127621)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -1681,19 +1681,25 @@ for more details. permitted to produce more precise results than performing the same operations separately. - The C standard permits intermediate floating-point results within an + The C/C++ standard permits intermediate floating-point results

[clang] [CIR] Upstream simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -78,16 +82,37 @@ class CIRGenModule : public CIRGenTypeCache { void emitTopLevelDecl(clang::Decl *decl); + /// Return the address of the given function. If funcType is non-null, then + /// this function will use the specified type if it has to create it. + // TODO: th

[clang] [CIR] Upstream simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,128 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,128 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,134 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,203 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,134 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -11,8 +11,8 @@ /// //===--===// -#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIROPS -#define LLVM_CLANG_CIR_DIALECT_IR_CIROPS +#ifndef CLANG_CIR_DIALECT_IR_CIROPS_TD andykaylor wrote: Why is the LL

[clang] [CIR] Upstream simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,134 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,134 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,134 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,203 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,203 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,134 @@ +//===--===// +// +// 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] Add additional frontend actions (PR #127249)

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

[clang] [CIR] Upstream simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -61,6 +64,13 @@ class CIRGenTypes { /// Convert a Clang type into a mlir::Type. mlir::Type convertType(clang::QualType type); + + /// Convert type T into an mlir::Type. This differs from convertType in that + /// it is used to convert to the memory representation for

[clang] [Clang][doc] -ffp-contract options and standard compliance (PR #127621)

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

[clang] [CIR] Upstream simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,203 @@ +//===--===// +// +// 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 simple function bodies (PR #127674)

2025-02-18 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,53 @@ +// Simple functions +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s + +void empty() { } +// CHECK: cir.func @empty() -> !cir.void { andykaylor wrote: Why aren't the function names mang

[clang] [Clang][doc] -ffp-contract options and standard compliance (PR #127621)

2025-02-18 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor commented: This is an improvement. I have a few minor comments. https://github.com/llvm/llvm-project/pull/127621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] [CIR] Add additional frontend actions (PR #127249)

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

[clang] [CIR] Add additional frontend actions (PR #127249)

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

[clang] [CIR] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-02-19 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/127835 Add support for lowering CIR to more general MLIR and emitting an MLIR text file, including a new command-line option for emitting MLIR via ClangIR. This does not yet support lowering to LLVM IR or other tar

[clang] [CIR] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-02-19 Thread Andy Kaylor via cfe-commits
@@ -2958,6 +2958,8 @@ defm clangir : BoolFOption<"clangir", BothFlags<[], [ClangOption, CC1Option], "">>; def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Build ASTs and then lower to ClangIR">; +def emit_cir_mlir : Flag<["-"],

[clang] [CIR] Realign CIR-to-LLVM IR lowering code with incubator (PR #129293)

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

[clang] [CIR] Upstream func args alloca handling (PR #129167)

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

[clang] [CIR] Realign CIR-to-LLVM IR lowering code with incubator (PR #129293)

2025-02-28 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/129293 The previously upstreamed lowering from ClangIR to LLVM IR diverged from the incubator implementation, but when the incubator was updated to incorporate these changes some issues arose which require the upst

[clang] [CIR] Upstream floating point literal expressions (PR #129304)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -57,3 +57,15 @@ bool boolfunc() { return true; } // CHECK: %0 = cir.const #true // CHECK: cir.return %0 : !cir.bool // CHECK: } + +float floatfunc() { return 42.42f; } +// CHECK: cir.func @floatfunc() -> !cir.float { +// CHECK: %0 = cir.const #cir.fp<4.242000e+01> : !c

[clang] [CIR] Realign CIR-to-LLVM IR lowering code with incubator (PR #129293)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -37,63 +37,78 @@ using namespace llvm; namespace cir { namespace direct { -class CIRAttrToValue : public CirAttrVisitor { +class CIRAttrToValue { public: CIRAttrToValue(mlir::Operation *parentOp, mlir::ConversionPatternRewriter &rewriter,

[clang] [CIR] Realign CIR-to-LLVM IR lowering code with incubator (PR #129293)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -218,12 +221,31 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite( SmallVector attributes; if (init.has_value()) { -GlobalInitAttrRewriter initRewriter(llvmType, rewriter); -init = initRewriter.rewriteInitAttr(init.value()); -// If initRewri

[clang] [CIR] Realign CIR-to-LLVM IR lowering code with incubator (PR #129293)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -218,12 +221,31 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite( SmallVector attributes; if (init.has_value()) { -GlobalInitAttrRewriter initRewriter(llvmType, rewriter); -init = initRewriter.rewriteInitAttr(init.value()); -// If initRewri

[clang] [CIR] Realign CIR-to-LLVM IR lowering code with incubator (PR #129293)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -218,12 +221,31 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite( SmallVector attributes; if (init.has_value()) { -GlobalInitAttrRewriter initRewriter(llvmType, rewriter); -init = initRewriter.rewriteInitAttr(init.value()); -// If initRewri

[clang] [CIR] Realign CIR-to-LLVM IR lowering code with incubator (PR #129293)

2025-03-02 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/129293 >From bb41af68d0d0f66c5610c69d6deb8a615d644fe5 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 28 Feb 2025 10:54:09 -0800 Subject: [PATCH 1/3] [CIR] Replace CIRAttrVisitor with TypeSwitch We previously

[clang] [CIR] Upstream global variable linkage types (PR #129072)

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

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,119 @@ +//===- CIROpsEnumsDialect.h - MLIR Dialect for CIR --*- C++ andykaylor wrote: Also, the coding guidelines have changed recently, so the filename doesn't need to be in this line. ```suggestion //===--

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -176,6 +177,18 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd, } varOp.setInitialValueAttr(initializer); } + +// Set CIR's linkage type as appropriate. +cir::GlobalLinkageKind linkage = +getCIRLinkageVarDefinition(vd,

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor commented: Can you also update `clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp` to use the linkage? There are two places marked by `cir::MissingFeatures::opGlobalLinkage()` that would need to be updated, plus (hopefully) test changes. It would also be good t

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -36,6 +36,10 @@ struct MissingFeatures { static bool opGlobalConstant() { return false; } static bool opGlobalAlignment() { return false; } static bool opGlobalLinkage() { return false; } andykaylor wrote: Can this be removed now? https://github.com/

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,29 @@ +//===- CIROpInterfaces.h - CIR Op Interfaces *- C++ -*-===// andykaylor wrote: ```suggestion //===--===// ``` https://github.com/llvm/llvm-project/pull/129

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,22 @@ +//- CIROpInterfaces.cpp - Interface to AST Attributes ---===// +// +// 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: Apache

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,119 @@ +//===- CIROpsEnumsDialect.h - MLIR Dialect for CIR --*- C++ +//-*-===// +// +// 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-Iden

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,63 @@ +//===- CIROpInterfaces.td - CIR Op Interface Definitions *- C++ -*-===// +// +// 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] Emit init of local variables (PR #130164)

2025-03-06 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,322 @@ +//===--===// +// +// 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] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-03-06 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/127835 >From 4f69f1700f9f982e9271157c5b870eda71e0c0f2 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 14 Feb 2025 17:30:54 -0800 Subject: [PATCH 1/6] [CIR] Initial implementation of lowering CIR to MLIR Add s

[clang] [CIR] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-03-06 Thread Andy Kaylor via cfe-commits
andykaylor wrote: I've rebased this PR to bring in recent changes, fixed a few problems that were caused by recent changes, and generally refactored the command-line handling to align with a similar change that was made in the incubator. This doesn't lower the ops and types that have been adde

[clang] [CIR] Disable gcc partially overloaded virtual warning (PR #130322)

2025-03-07 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/130322 GCC, unlike clang, issues a warning when one virtual function is overridden in a derived class but one or more other virtual functions with the same name and different signature from a base class are not ove

[clang] [CIR] Emit init of local variables (PR #130164)

2025-03-07 Thread Andy Kaylor via cfe-commits
@@ -46,21 +52,124 @@ void CIRGenFunction::emitAutoVarAlloca(const VarDecl &d) { address = createTempAlloca(allocaTy, alignment, loc, d.getName()); declare(address.getPointer(), &d, ty, getLoc(d.getSourceRange()), alignment); + emission.Addr = address; setAddrOfLocalVar

[clang] [CIR] Emit init of local variables (PR #130164)

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

[clang] [CIR] Disable gcc partially overloaded virtual warning (PR #130322)

2025-03-07 Thread Andy Kaylor via cfe-commits
andykaylor wrote: > Someone better equipped to review cmake should review this, but looks ok to > me. I'm not sure who is well-versed in the dark art of cmake. I made this same change in the incubator, and it's working there, so I'm confident that it works as intended. https://github.com/llv

[clang] [CIR] Emit init of local variables (PR #130164)

2025-03-06 Thread Andy Kaylor via cfe-commits
@@ -94,10 +203,59 @@ void CIRGenFunction::emitVarDecl(const VarDecl &d) { assert(d.hasLocalStorage()); - assert(!cir::MissingFeatures::opAllocaVarDeclContext()); + CIRGenFunction::VarDeclContext varDeclCtx{*this, &d}; return emitAutoVarDecl(d); } +void CIRGenFunctio

[clang] [CIR] Emit init of local variables (PR #130164)

2025-03-06 Thread Andy Kaylor via cfe-commits
@@ -46,21 +52,124 @@ void CIRGenFunction::emitAutoVarAlloca(const VarDecl &d) { address = createTempAlloca(allocaTy, alignment, loc, d.getName()); declare(address.getPointer(), &d, ty, getLoc(d.getSourceRange()), alignment); + emission.Addr = address; setAddrOfLocalVar

[clang] [CIR] Upstream global variable linkage types (PR #129072)

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

[clang] [CIR] Emit init of local variables (PR #130164)

2025-03-06 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/130164 Local variable initialization was previously being ignored. This change adds support for initialization of scalar variables with constant values and introduces the constant emitter framework. >From 69c71043

[clang] [CIR] Emit init of local variables (PR #130164)

2025-03-06 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/130164 >From 69c7104391ff9b6ae1dbcb6275a3070da4f8dd02 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 4 Mar 2025 10:21:24 -0800 Subject: [PATCH 1/2] [CIR] Emit init of local variables Local variable initializ

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

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

[clang] [CIR] Disable gcc partially overloaded virtual warning (PR #130322)

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

[clang] [CIR] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-03-11 Thread Andy Kaylor via cfe-commits
andykaylor wrote: We agreed at the clangir upstreaming meeting today that this PR should be put on hold. We don't intend to keep lowering to MLIR standard dialects up-to-date as we upstream the rest of the implementation, and it is currently missing a lot of functionality in the incubator, so

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -386,7 +405,7 @@ def VoidPtr : Type< //===--===// def CIR_AnyType : AnyTypeOf<[ - CIR_VoidType, CIR_BoolType, CIR_IntType, CIR_AnyFloat, CIR_PointerType, + CIR_VoidType, CIR_BoolType, CIR_ArrayType, CIR_

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - 2>&1 | FileCheck %s andykaylor wrote: Will multidimensional arrays and array function arguments work at this point? If so, can you add tests for those?

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

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

[clang] [CIR] Upstream initial support for CIR flattening (PR #130648)

2025-03-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/130648 The ClangIR CFG has to be flat before it can be lowered to LLVM IR. That is, there can be no nested regions and all blocks in a region must belong to the parent region. Currently only cir.scope operations vi

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -166,6 +166,9 @@ static LogicalResult checkConstantTypes(mlir::Operation *op, mlir::Type opType, return success(); } + if (mlir::isa(opType)) andykaylor wrote: I don't see this in the incubator implementation of this function. Why is this here? h

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -369,6 +369,22 @@ BoolType::getABIAlignment(const ::mlir::DataLayout &dataLayout, return 1; } +//===--===// +// Definitions +//===--==

[clang] [CIR] Emit init of local variables (PR #130164)

2025-03-11 Thread Andy Kaylor via cfe-commits
andykaylor wrote: Apparently the code formatting checker won't even let me mention "undef" in a comment. https://github.com/llvm/llvm-project/pull/130164 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/li

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -210,6 +223,193 @@ void CIRGenModule::emitGlobalDefinition(clang::GlobalDecl gd, llvm_unreachable("Invalid argument to CIRGenModule::emitGlobalDefinition"); } +static bool shouldBeInCOMDAT(CIRGenModule &cgm, const Decl &d) { + assert(!cir::MissingFeatures::supportComdat

[clang] [CIR] Upstream basic alloca and load support (PR #128792)

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

[clang] [CIR] Upstream global variable linkage types (PR #129072)

2025-02-27 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,29 @@ +//===- CIROpInterfaces.h - CIR Op Interfaces *- C++ -*-===// +// +// 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 func args alloca handling (PR #129167)

2025-02-27 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/129167 This change adds support for collecting function arguments and storing them in alloca memory slots. >From d1fa2629b5786befa8ca8f839cf948df4644d615 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 25 Fe

[clang] [CIR] Upstream func args alloca handling (PR #129167)

2025-02-28 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/129167 >From d1fa2629b5786befa8ca8f839cf948df4644d615 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 25 Feb 2025 16:52:18 -0800 Subject: [PATCH 1/2] [CIR] Upstream func args alloca handling This change adds

[clang] [CIR] Upstream func args alloca handling (PR #129167)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -234,6 +273,29 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn, return fn; } +clang::QualType CIRGenFunction::buildFunctionArgList(clang::GlobalDecl gd, + FunctionArgList &args) { + con

[clang] [CIR] Upstream func args alloca handling (PR #129167)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -149,16 +153,49 @@ mlir::LogicalResult CIRGenFunction::declare(Address addr, const Decl *var, void CIRGenFunction::startFunction(GlobalDecl gd, QualType returnType, cir::FuncOp fn, cir::FuncType funcType, -

[clang] [CIR] Upstream func args alloca handling (PR #129167)

2025-02-28 Thread Andy Kaylor via cfe-commits
@@ -52,6 +52,14 @@ class Address { elementType); } + Address(mlir::Value pointer, clang::CharUnits alignment) + : Address(pointer, +mlir::cast(pointer.getType()).getPointee(), andykaylor wrote: The thing that's being cast is

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -36,6 +36,18 @@ class ScalarExprEmitter : public StmtVisitor { bool ira = false) : cgf(cgf), builder(builder), ignoreResultAssign(ira) {} + //======// + //

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -84,26 +96,266 @@ class ScalarExprEmitter : public StmtVisitor { } mlir::Value VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *e) { -mlir::Type type = cgf.convertType(e->getType()); +mlir::Type type = convertType(e->getType()); return builder.create(

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

2025-03-11 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 +// 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 CastOp and scalar conversions (PR #130690)

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -36,6 +36,18 @@ class ScalarExprEmitter : public StmtVisitor { bool ira = false) : cgf(cgf), builder(builder), ignoreResultAssign(ira) {} + //======// + //

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -84,26 +96,266 @@ class ScalarExprEmitter : public StmtVisitor { } mlir::Value VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *e) { -mlir::Type type = cgf.convertType(e->getType()); +mlir::Type type = convertType(e->getType()); return builder.create(

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

2025-03-11 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: Can you expand this test to cover all the cast types you're adding (or remove any that can't be supported yet)? https://github.c

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

2025-03-11 Thread Andy Kaylor via cfe-commits
@@ -78,6 +79,67 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { return create(loc, val, dst); } + //======// + // Cast/Conversion Operators + //===--

[clang] [CIR] Upstream emitAndUpdateRetAlloca (PR #129933)

2025-03-05 Thread Andy Kaylor via cfe-commits
@@ -13,8 +13,9 @@ void voidret() { return; } int intfunc() { return 42; } // CHECK: cir.func @intfunc() -> !cir.int { -// CHECK: %0 = cir.const #cir.int<42> : !cir.int -// CHECK: cir.return %0 : !cir.int +// CHECK: %0 = cir.alloca !cir.int, !cir.ptr>, ["__retval"] {alig

[clang] [CIR] Upstream emitAndUpdateRetAlloca (PR #129933)

2025-03-05 Thread Andy Kaylor via cfe-commits
@@ -13,8 +13,9 @@ void voidret() { return; } int intfunc() { return 42; } // CHECK: cir.func @intfunc() -> !cir.int { -// CHECK: %0 = cir.const #cir.int<42> : !cir.int -// CHECK: cir.return %0 : !cir.int +// CHECK: %0 = cir.alloca !cir.int, !cir.ptr>, ["__retval"] {alig

[clang] [CIR] Upstream emitAndUpdateRetAlloca (PR #129933)

2025-03-05 Thread Andy Kaylor via cfe-commits
@@ -195,7 +195,16 @@ void CIRGenFunction::startFunction(GlobalDecl gd, QualType returnType, mlir::Location fnBodyBegin = getLoc(fd->getBody()->getBeginLoc()); builder.CIRBaseBuilderTy::createStore(fnBodyBegin, paramVal, addrVal); } + assert(builder.getInsertionBlo

[clang] [CIR] Upstream emitAndUpdateRetAlloca (PR #129933)

2025-03-05 Thread Andy Kaylor via cfe-commits
@@ -312,4 +326,12 @@ LValue CIRGenFunction::emitLValue(const Expr *e) { } } +void CIRGenFunction::emitAndUpdateRetAlloca(QualType ty, mlir::Location loc, +CharUnits alignment) { + if (ty->isVoidType()) { +return; + } + --

[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)

2025-03-12 Thread Andy Kaylor via cfe-commits
@@ -1,7 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %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 %s -o %

[clang] [CIR] Add transform test for cir-flatten-cfg (PR #130861)

2025-03-12 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,58 @@ +// RUN: cir-opt %s -cir-flatten-cfg -o - | FileCheck %s + +module { + cir.func @foo() { +cir.scope { + %0 = cir.alloca !cir.int, !cir.ptr>, ["a", init] {alignment = 4 : i64} + %1 = cir.const #cir.int<4> : !cir.int + cir.store %1, %0 : !cir.in

[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)

2025-03-12 Thread Andy Kaylor via 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/3] [CIR] Upstream support for emitting ignored statements Thi

[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)

2025-03-12 Thread Andy Kaylor via cfe-commits
@@ -1,7 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %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 %s -o %

[clang] [CIR] Upstream initial support for CIR flattening (PR #130648)

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

[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)

2025-03-12 Thread Andy Kaylor via cfe-commits
@@ -55,10 +55,154 @@ mlir::LogicalResult CIRGenFunction::emitStmt(const Stmt *s, if (mlir::succeeded(emitSimpleStmt(s, useCurrentScope))) return mlir::success(); - // Only a subset of simple statements are supported at the moment. When more - // kinds of statements ar

[clang] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)

2025-03-12 Thread Andy Kaylor via cfe-commits
andykaylor wrote: > Hello @andykaylor , > > I am working on this pragma operation, with a different scenario. For > example: https://godbolt.org/z/nTfYW64j4 > > Is it ok to merge this patch? As mentioned [here](https://discourse.llvm.org/t/rfc-honor-pragmas-with-ffp-contract-fast/80797/14),

[clang] [CIR] Add transform test for cir-flatten-cfg (PR #130861)

2025-03-12 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,58 @@ +// RUN: cir-opt %s -cir-flatten-cfg -o - | FileCheck %s + +module { + cir.func @foo() { +cir.scope { + %0 = cir.alloca !cir.int, !cir.ptr>, ["a", init] {alignment = 4 : i64} + %1 = cir.const #cir.int<4> : !cir.int + cir.store %1, %0 : !cir.in

[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)

2025-03-12 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %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 %s -o

[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)

2025-03-12 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %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 %s -o

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

2025-03-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor edited 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-commits

[clang] [CIR] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-03-11 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/127835 >From 02218dfb3cdc1282b474b5f0fde3c6cc8791e0a0 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 14 Feb 2025 17:30:54 -0800 Subject: [PATCH 1/7] [CIR] Initial implementation of lowering CIR to MLIR Add s

<    1   2   3   4   5   6   7   >