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
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
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
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
@@ -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
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
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
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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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
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
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
@@ -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
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
@@ -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
@@ -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
@@ -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
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
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
@@ -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
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
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
@@ -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
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
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 *
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
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
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
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
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
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
@@ -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
@@ -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
@@ -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);
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
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
@@ -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
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
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
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,
@@ -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<["-"],
@@ -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<["-"],
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
@@ -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<["-"],
@@ -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
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
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
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
@@ -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<["-"],
@@ -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
@@ -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,
-
@@ -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
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
@@ -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
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
@@ -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
___
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
@@ -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
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
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
@@ -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 :
@@ -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
@@ -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<["-"],
@@ -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
@@ -117,6 +117,24 @@ static void
printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer,
/*printBlockTerminators=*/!omitRegionTerm(region));
}
+//===--===//
+// AllocaOp
+//===
@@ -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
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
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
@@ -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
@@ -115,6 +115,149 @@ def ConstantOp : CIR_Op<"const",
let hasFolder = 1;
}
+//===--===//
+// AllocaOp
+//===--===//
+
+class AllocaTypesMa
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -117,6 +117,24 @@ static void
printOmittedTerminatorRegion(mlir::OpAsmPrinter &printer,
/*printBlockTerminators=*/!omitRegionTerm(region));
}
+//===--===//
+// AllocaOp
+//===
@@ -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
@@ -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
@@ -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
@@ -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
201 - 300 of 635 matches
Mail list logo