[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

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

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-03 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/125619 Add support for lowering global variables of any pointer type to LLVM IR. >From dc7f71d511d2e13e527e0c8cd242a3ece82bcdfd Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 3 Feb 2025 13:20:51 -0800 Subjec

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-03 Thread Andy Kaylor via cfe-commits
andykaylor wrote: This patch includes an experimental attempt at a CIR attribute visitor along the lines that @erichkeane suggested in a previous PR review. Unfortunately, I wasn't able to use the new visitor in the place that he suggested it without an ugly shoehorn because different handlers

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-02-03 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125260 >From 4801886dd4c45d32891a7337ad7430a6c5137929 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 28 Jan 2025 12:28:58 -0800 Subject: [PATCH 1/9] [CIR] Initial implementation of CIR-to-LLVM IR lowering pa

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-02-03 Thread Andy Kaylor via cfe-commits
@@ -22,16 +35,164 @@ using namespace llvm; namespace cir { namespace direct { +// This pass requires the CIR to be in a "flat" state. All blocks in each +// function must belong to the parent region. Once scopes and control flow +// are implemented in CIR, a pass will be run b

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-02-03 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125260 >From 4801886dd4c45d32891a7337ad7430a6c5137929 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 28 Jan 2025 12:28:58 -0800 Subject: [PATCH 1/9] [CIR] Initial implementation of CIR-to-LLVM IR lowering pa

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-04 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125619 >From dc7f71d511d2e13e527e0c8cd242a3ece82bcdfd Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 3 Feb 2025 13:20:51 -0800 Subject: [PATCH 1/2] [CIR] Lowering to LLVM for global pointers Add support for

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/125260 This change introduces lowering from CIR to LLVM IR of global integer variables, using defaults for attributes that aren't yet implemented. >From 4801886dd4c45d32891a7337ad7430a6c5137929 Mon Sep 17 00:00:00

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,13 +34,127 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [CIR] Fix some clang-tidy problems in CIR (PR #125128)

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

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,13 +34,127 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -1,8 +1,10 @@ // Smoke test for ClangIR-to-LLVM IR code generation // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -// TODO: Add checks when proper lowering is implemented. -// For now, we're just creating an empty mod

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,13 +34,127 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,13 +34,127 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,13 +34,127 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -31,6 +33,24 @@ namespace direct { std::unique_ptr lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp mlirModule, llvm::LLVMContext &llvmCtx); + +class CIRToLLVMGlobalOpLowering +: public mlir::OpConversionPattern { + mlir::DataLayout const &dataLa

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -1,8 +1,10 @@ // Smoke test for ClangIR-to-LLVM IR code generation // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -// TODO: Add checks when proper lowering is implemented. -// For now, we're just creating an empty mod

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-04 Thread Andy Kaylor via cfe-commits
@@ -84,6 +138,19 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite( SmallVector attributes; if (init.has_value()) { +auto setupRegionInitializedLLVMGlobalOp = [&]() { andykaylor wrote: It's not quite as bad there because everything is

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-04 Thread Andy Kaylor via cfe-commits
@@ -84,6 +138,19 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite( SmallVector attributes; if (init.has_value()) { +auto setupRegionInitializedLLVMGlobalOp = [&]() { andykaylor wrote: https://github.com/llvm/clangir/blob/f8821e852168

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-05 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125619 >From dc7f71d511d2e13e527e0c8cd242a3ece82bcdfd Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 3 Feb 2025 13:20:51 -0800 Subject: [PATCH 1/3] [CIR] Lowering to LLVM for global pointers Add support for

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-05 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125619 >From dc7f71d511d2e13e527e0c8cd242a3ece82bcdfd Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 3 Feb 2025 13:20:51 -0800 Subject: [PATCH 1/4] [CIR] Lowering to LLVM for global pointers Add support for

[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-05 Thread Andy Kaylor via cfe-commits
andykaylor wrote: @lanza @bcardosolopes Do you want to look this over before I commit it? This change introduces some restructuring that I'll want to incorporate in the incubator, where it will have a somewhat bigger impact, so I'd like to get your buy-in or objections now before I start worki

[clang] [CIR] Fix some clang-tidy problems in CIR (PR #125128)

2025-01-30 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/125128 This adds a .clang-tidy file to the clang/lib/CIR/FrontendAction directory, moves and updates the incorrectly located include/clang/CIR/FrontendAction .clang-tidy file, and updates two files from a recent co

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -1,8 +1,10 @@ // Smoke test for ClangIR-to-LLVM IR code generation // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -// TODO: Add checks when proper lowering is implemented. -// For now, we're just creating an empty mod

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125260 >From 4801886dd4c45d32891a7337ad7430a6c5137929 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 28 Jan 2025 12:28:58 -0800 Subject: [PATCH 1/4] [CIR] Initial implementation of CIR-to-LLVM IR lowering pa

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,16 +34,156 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -31,6 +33,24 @@ namespace direct { std::unique_ptr lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp mlirModule, llvm::LLVMContext &llvmCtx); + +class CIRToLLVMGlobalOpLowering andykaylor wrote: I think that was an accident. This is a

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,16 +34,156 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125260 >From 4801886dd4c45d32891a7337ad7430a6c5137929 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 28 Jan 2025 12:28:58 -0800 Subject: [PATCH 1/6] [CIR] Initial implementation of CIR-to-LLVM IR lowering pa

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125260 >From 4801886dd4c45d32891a7337ad7430a6c5137929 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 28 Jan 2025 12:28:58 -0800 Subject: [PATCH 1/7] [CIR] Initial implementation of CIR-to-LLVM IR lowering pa

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -31,6 +33,24 @@ namespace direct { std::unique_ptr lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp mlirModule, llvm::LLVMContext &llvmCtx); + +class CIRToLLVMGlobalOpLowering +: public mlir::OpConversionPattern { + mlir::DataLayout const &dataLa

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/125260 >From 4801886dd4c45d32891a7337ad7430a6c5137929 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Tue, 28 Jan 2025 12:28:58 -0800 Subject: [PATCH 1/8] [CIR] Initial implementation of CIR-to-LLVM IR lowering pa

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

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

[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)

2025-01-31 Thread Andy Kaylor via cfe-commits
@@ -22,16 +34,156 @@ using namespace llvm; namespace cir { namespace direct { +struct ConvertCIRToLLVMPass +: public mlir::PassWrapper> { + void getDependentDialects(mlir::DialectRegistry ®istry) const override { +registry.insert(); + } + void runOnOperation() final

[clang] [NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize (PR #123433)

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

[clang] [NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize (PR #123433)

2025-01-21 Thread Andy Kaylor via cfe-commits
andykaylor wrote: > Shouldn't there be a pointer-vs-intty difference in the LLVM-IR here? No, because in this case tryEmitAbstract() is only using the size of the type that's passed in. After a few visits, it eventually calls this function: ``` llvm::Constant *ProduceIntToIntCast(const Expr *

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-21 Thread Andy Kaylor via cfe-commits
andykaylor wrote: > > My understanding of the attribute is that it only indicates that strict > > floating-point semantics are (potentially?) required at the call site. > > If strict floating-point semantics are required at this call site, they are > are required on every relevant call in this

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-17 Thread Andy Kaylor via cfe-commits
andykaylor wrote: What's the motivation for this change? Was the strictfp attribute blocking some optimization? My understanding of the attribute is that it only indicates that strict floating-point semantics are (potentially?) required at the call site. It doesn't indicate that the called fu

[clang] [NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize (PR #123433)

2025-01-17 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/123433 In EmitCXXNewAllocSize, when handling a constant array size, we were calling tryEmitAbstract with the type of the object being allocated. This worked out because the type was always a pointer and tryEmitAbst

[clang] [NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize (PR #123433)

2025-01-17 Thread Andy Kaylor via cfe-commits
andykaylor wrote: I ran into this while porting this code to the CIR generator because the constant emitter there was asserting that the destination type was an integer type. My motivation for posting this change here is to make sure my understanding of the expected destination type is correct

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-27 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/124650 Create the skeleton framework for lowering from ClangIR to LLVM IR. This initial implementation just creates an empty LLVM IR module. Actual lowering of even minimal ClangIR is deferred to a later patch. >F

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-27 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/124650 >From 41546e2d096310d8a1474539b5036152c7df3d11 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 27 Jan 2025 14:54:10 -0800 Subject: [PATCH 1/2] [CIR] Add framework for CIR to LLVM IR lowering Create the

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -44,7 +44,7 @@ class CIRGenerator : public clang::ASTConsumer { const clang::CodeGenOptions &codeGenOpts; protected: - std::unique_ptr mlirContext; + std::shared_ptr mlirContext; andykaylor wrote: Sorry, I thought shared pointer was what you were sugge

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -44,7 +44,7 @@ class CIRGenerator : public clang::ASTConsumer { const clang::CodeGenOptions &codeGenOpts; protected: - std::unique_ptr mlirContext; + std::shared_ptr mlirContext; andykaylor wrote: Perhaps it's also relevant to note that I don't seem to

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -55,6 +56,13 @@ class EmitCIRAction : public CIRGenAction { EmitCIRAction(mlir::MLIRContext *MLIRCtx = nullptr); }; +class EmitLLVMAction : public CIRGenAction { + virtual void anchor(); + +public: + EmitLLVMAction(mlir::MLIRContext *MLIRCtx = nullptr);

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -7,42 +7,56 @@ //===--===// #include "clang/CIR/FrontendAction/CIRGenAction.h" -#include "clang/CIR/CIRGenerator.h" -#include "clang/Frontend/CompilerInstance.h" - #include "mlir/IR/MLIRContext.h" #inclu

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -7,42 +7,56 @@ //===--===// #include "clang/CIR/FrontendAction/CIRGenAction.h" -#include "clang/CIR/CIRGenerator.h" -#include "clang/Frontend/CompilerInstance.h" - #include "mlir/IR/MLIRContext.h" #inclu

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,41 @@ +//- LowerToLLVM.cpp - Lowering from CIR to LLVMIR -===// +// +// 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 framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -55,6 +55,9 @@ class CIRGenerator : public clang::ASTConsumer { void Initialize(clang::ASTContext &astContext) override; bool HandleTopLevelDecl(clang::DeclGroupRef group) override; mlir::ModuleOp getModule() const; + std::unique_ptr takeContext() { a

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/124650 >From 41546e2d096310d8a1474539b5036152c7df3d11 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 27 Jan 2025 14:54:10 -0800 Subject: [PATCH 1/3] [CIR] Add framework for CIR to LLVM IR lowering Create the

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,41 @@ +//- LowerToLLVM.cpp - Lowering from CIR to LLVMIR -===// +// +// 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 framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,41 @@ +//- LowerToLLVM.cpp - Lowering from CIR to LLVMIR -===// +// +// 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 framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Andy Kaylor via cfe-commits
@@ -7,42 +7,56 @@ //===--===// #include "clang/CIR/FrontendAction/CIRGenAction.h" -#include "clang/CIR/CIRGenerator.h" -#include "clang/Frontend/CompilerInstance.h" - #include "mlir/IR/MLIRContext.h" #inclu

[clang] [NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize (PR #123433)

2025-01-21 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/123433 >From 25edfca991d195687afe4fb18c0ece6244d67497 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 17 Jan 2025 17:39:22 -0800 Subject: [PATCH 1/2] [NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAlloc

[clang] [NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize (PR #123433)

2025-01-21 Thread Andy Kaylor via cfe-commits
@@ -732,8 +732,8 @@ static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF, // Emit the array size expression. // We multiply the size of all dimensions for NumElements. // e.g for 'int[2][3]', ElemType is 'int' and NumElements is 6. - numElements = -ConstantE

[clang] [CIR] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-29 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/124650 >From 41546e2d096310d8a1474539b5036152c7df3d11 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Mon, 27 Jan 2025 14:54:10 -0800 Subject: [PATCH 1/4] [CIR] Add framework for CIR to LLVM IR lowering Create the

[clang] [CIR] Fix extra `;` warning, and replace `new` with emplaceBlock (NFC) (PR #127207)

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

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

2025-02-14 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/127249 Add frontend actions to support emitting assembly, bitcode, and object files when compiling with ClangIR. >From 62a33eb8f488bd2fcec8f155da2ec646b3562824 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri,

[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] 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] Initial implementation of lowering CIR to MLIR (PR #127835)

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

[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] Upstream simple function bodies (PR #127674)

2025-02-19 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: It looks like

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

2025-02-19 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor approved this pull request. I'm happy with the latest changes, so after the "standards" wording changes Erich and Aaron requested, this should be good to go. https://github.com/llvm/llvm-project/pull/127621 ___ cfe-commit

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

2025-02-19 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor approved this pull request. My unanswered questions are mostly simple style changes, which I'm happy to let David decide if he thinks they need to be addressed. https://github.com/llvm/llvm-project/pull/127674 ___ cfe-com

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

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

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

2025-02-21 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] Better handling of `void` function return (PR #128089)

2025-02-21 Thread Andy Kaylor via cfe-commits
@@ -2,12 +2,12 @@ // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s andykaylor wrote: It's definitely unfortunate that we're adding this parsing code but don't have any tests for it. I'm working on a PR

[clang] [CIR] Better handling of `void` function return (PR #128089)

2025-02-21 Thread Andy Kaylor via cfe-commits
@@ -331,9 +335,38 @@ FuncType FuncType::clone(TypeRange inputs, TypeRange results) const { return get(llvm::to_vector(inputs), results[0], isVarArg()); } -mlir::ParseResult parseFuncTypeArgs(mlir::AsmParser &p, -llvm::SmallVector ¶ms, -

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

2025-02-21 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,46 @@ +//===- cir-opt.cpp - CIR optimization and analysis driver -*- C++ -*-===// andykaylor wrote: Thanks, I wasn't aware of that. I'll update this. I see that I also missed the file header on one of the other files I'm adding. https://github.co

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

2025-02-21 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/128254 >From eaa4ca8f45d1a50d5a84ba4f701e6ad1957b549b Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 21 Feb 2025 15:47:32 -0800 Subject: [PATCH 1/2] [CIR] Add cir-opt tool to exercise CIR dialect parsing Par

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

2025-02-21 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,19 @@ +#ifndef CLANG_CIR_PASSES_H +#define CLANG_CIR_PASSES_H + +#include "mlir/Pass/Pass.h" + +#include + +namespace cir { +namespace direct { andykaylor wrote: There will eventually be things in this file that are in the cir namespace, but not in t

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

2025-02-21 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/128254 We need to be able to read in and parse files using the ClangIR dialect in order to test this part of the functionality. This change adds the minimum cir-opt tool needed to read and parse cir files and writ

[clang] [CIR] Better handling of `void` function return (PR #128089)

2025-02-21 Thread Andy Kaylor via cfe-commits
@@ -2,12 +2,12 @@ // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s andykaylor wrote: https://github.com/llvm/llvm-project/pull/128254 https://github.com/llvm/llvm-project/pull/128089 ___

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

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

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

2025-02-24 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,32 @@ +get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) +get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS) + +include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include) +include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include) + +add_clang

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

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

[clang] [CIR] Add cir-opt tool to exercise CIR dialect parsing (PR #128254)

2025-02-24 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/128254 >From eaa4ca8f45d1a50d5a84ba4f701e6ad1957b549b Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Fri, 21 Feb 2025 15:47:32 -0800 Subject: [PATCH 1/3] [CIR] Add cir-opt tool to exercise CIR dialect parsing Par

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

2025-02-20 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,79 @@ +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-core-mlir %s -o %t.mlir +// RUN: FileCheck --input-file=%t.mlir %s + +char c; +// CHECK: memref.global "public" @c : memref + +signed char sc; +// CHECK: memref.global "public" @sc :

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

2025-02-20 Thread Andy Kaylor via cfe-commits
@@ -55,6 +55,7 @@ class CIRGenerator : public clang::ASTConsumer { void Initialize(clang::ASTContext &astContext) override; bool HandleTopLevelDecl(clang::DeclGroupRef group) override; mlir::ModuleOp getModule() const; + mlir::MLIRContext &getMLIRContext() { return *mlir

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

2025-02-20 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] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-02-19 Thread Andy Kaylor via cfe-commits
@@ -55,6 +55,7 @@ class CIRGenerator : public clang::ASTConsumer { void Initialize(clang::ASTContext &astContext) override; bool HandleTopLevelDecl(clang::DeclGroupRef group) override; mlir::ModuleOp getModule() const; + mlir::MLIRContext &getContext() { return *mlirCont

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

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -117,6 +117,24 @@ static void printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer, /*printBlockTerminators=*/!omitRegionTerm(region)); } +//===--===// +// AllocaOp +//===

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

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 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/3] [CIR] Upstream basic alloca and load support This change i

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

2025-02-26 Thread Andy Kaylor via cfe-commits
andykaylor wrote: @AaronBallman , @erichkeane I think I've addressed the review comments. Is there anything else you'd like changed? https://github.com/llvm/llvm-project/pull/127835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists

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

2025-02-26 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -115,6 +115,149 @@ def ConstantOp : CIR_Op<"const", let hasFolder = 1; } +//===--===// +// AllocaOp +//===--===// + +class AllocaTypesMa

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

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s + +int f1(); andykaylor wrote: Probably no purpose. It was in the incubator test that I'm starting to bring over here. I had taken it out

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

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -75,3 +110,34 @@ mlir::Value CIRGenFunction::emitScalarExpr(const Expr *e) { return ScalarExprEmitter(*this, builder).Visit(const_cast(e)); } + +// Emit code for an explicit or implicit cast. Implicit +// casts have to handle a more broad range of conversions than explic

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

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -65,7 +80,27 @@ class ScalarExprEmitter : public StmtVisitor { cgf.getLoc(e->getExprLoc()), type, builder.getCIRBoolAttr(e->getValue())); } + + mlir::Value VisitCastExpr(CastExpr *E); + + /// Emit a conversion from the specified type to the specified des

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

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -117,6 +117,24 @@ static void printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer, /*printBlockTerminators=*/!omitRegionTerm(region)); } +//===--===// +// AllocaOp +//===

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

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,76 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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 basic alloca and load support (PR #128792)

2025-02-26 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,82 @@ +//===--===// +// +// 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

<    1   2   3   4   5   6   7   >