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
@@ -0,0 +1,52 @@
+//===- TypeConverter.h - Convert builtin to LLVM dialect types --*- C++
-*-===//
bcardosolopes wrote:
TypeConverter.h -> CIRAttrVisitor.h
https://github.com/llvm/llvm-project/pull/125619
___
cfe-comm
bcardosolopes 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
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 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/2] [CIR] Lowering to LLVM for global pointers
Add support for
@@ -84,6 +138,19 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
SmallVector attributes;
if (init.has_value()) {
+auto setupRegionInitializedLLVMGlobalOp = [&]() {
erichkeane wrote:
Ah, hrmph. That is unfortunately a much nicer ve
@@ -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
@@ -92,6 +159,16 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
mlir::dyn_cast(init.value())) {
// Initializer is a constant array: convert it to a compatible llvm init.
init = rewriter.getIntegerAttr(llvmType, intAttr.getValu
@@ -0,0 +1,51 @@
+#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+
+#include "clang/CIR/Dialect/IR/CIRAttrs.h"
+
+namespace cir {
+
+template class CirAttrVisitor {
+public:
+ // FIXME: Create a TableGen list to automatical
@@ -55,14 +104,19 @@ struct ConvertCIRToLLVMPass
StringRef getArgument() const override { return "cir-flat-to-llvm"; }
};
+/// Replace CIR global with a region initialized LLVM global and update
+/// insertion point to the end of the initializer block.
+
mlir::LogicalResult
@@ -0,0 +1,51 @@
+#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+
+#include "clang/CIR/Dialect/IR/CIRAttrs.h"
+
+namespace cir {
+
+template class CirAttrVisitor {
+public:
+ // FIXME: Create a TableGen list to automatical
@@ -35,6 +36,54 @@ using namespace llvm;
namespace cir {
namespace direct {
+class CIRAttrToValue : public CirAttrVisitor {
+public:
+ mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
+ mlir::Attribute attr,
+
@@ -0,0 +1,51 @@
+#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+
+#include "clang/CIR/Dialect/IR/CIRAttrs.h"
+
+namespace cir {
+
+template class CirAttrVisitor {
+public:
+ // FIXME: Create a TableGen list to automatical
@@ -35,6 +36,54 @@ using namespace llvm;
namespace cir {
namespace direct {
+class CIRAttrToValue : public CirAttrVisitor {
+public:
+ mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
+ mlir::Attribute attr,
+
@@ -84,6 +138,19 @@ mlir::LogicalResult
CIRToLLVMGlobalOpLowering::matchAndRewrite(
SmallVector attributes;
if (init.has_value()) {
+auto setupRegionInitializedLLVMGlobalOp = [&]() {
erichkeane wrote:
I think I'd prefer this get extracted to a functi
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
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Andy Kaylor (andykaylor)
Changes
Add support for lowering global variables of any pointer type to LLVM IR.
---
Full diff: https://github.com/llvm/llvm-project/pull/125619.diff
4 Files Affected:
- (added) clang/include/clang/CIR/Dialect/
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
20 matches
Mail list logo