[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] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-30 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. 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] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-30 Thread Aaron Ballman 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-30 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM! 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] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-30 Thread Aaron Ballman 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-30 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited 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] 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] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Bruno Cardoso Lopes 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 Bruno Cardoso Lopes 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; bcardosolopes wrote: We run passes post CIRGen (LLVM lowering is one exam

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

2025-01-28 Thread Bruno Cardoso Lopes 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() { b

[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 Nathan Lanza 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; lanza wrote: > Could CIRGenerator own this and just share it with lowerFr

[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 Aaron Ballman 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 Aaron Ballman 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 Aaron Ballman 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
@@ -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] [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
@@ -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 Erich Keane 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; erichkeane wrote: Could `CIRGenerator` own this and just share it with `l

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

2025-01-28 Thread Aaron Ballman 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
@@ -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 Aaron Ballman 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 Aaron Ballman 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::shared_ptr getContext() { Aa

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

2025-01-28 Thread Aaron Ballman 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 Aaron Ballman via cfe-commits
@@ -66,6 +81,17 @@ class CIRGenConsumer : public clang::ASTConsumer { MlirModule->print(*OutputStream, Flags); } break; +case CIRGenAction::OutputType::EmitLLVM: { + llvm::LLVMContext LLVMCtx; + auto LLVMModule = lowerFromCIRToLLVMIR(CI.getFron

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

2025-01-28 Thread Aaron Ballman 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 Aaron Ballman 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
@@ -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 Erich Keane 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; erichkeane wrote: Hmm... I don't think the shared pointer is the way here

[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
@@ -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 Erich Keane via cfe-commits
@@ -0,0 +1,36 @@ +//- LowerToLLVM.h- Lowering from CIR to LLVM --===// +// +// 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 Erich Keane 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() { e

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

2025-01-28 Thread Erich Keane via cfe-commits
@@ -0,0 +1 @@ +add_subdirectory(DirectToLLVM) erichkeane wrote: newline at end of file here too, because github. https://github.com/llvm/llvm-project/pull/124650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

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

2025-01-28 Thread Erich Keane via cfe-commits
https://github.com/erichkeane edited 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] Add framework for CIR to LLVM IR lowering (PR #124650)

2025-01-28 Thread Erich Keane via cfe-commits
https://github.com/erichkeane commented: I have concerns about `takeContext`, else everything else is a NIT. https://github.com/llvm/llvm-project/pull/124650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[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-27 Thread Nathan Lanza 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-27 Thread Bruno Cardoso Lopes via cfe-commits
https://github.com/bcardosolopes approved this pull request. Seems like there are some CI failures (format related?) but LGTM once those are fixed https://github.com/llvm/llvm-project/pull/124650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

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

2025-01-27 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 3861b9db882d5637725ceeccb801c2bb837e8fc5 41546e2d096310d8a1474539b5036152c7df3d11 --e

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

2025-01-27 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Andy Kaylor (andykaylor) Changes 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.

[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