[llvm-branch-commits] [clang] [clang][CIR] Merge the mlir::cir namespace into cir (PR #115386)
Shoaib Meenai via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Nov 7 14:36:33 PST 2024
https://github.com/smeenai created https://github.com/llvm/llvm-project/pull/115386
https://github.com/llvm/clangir/issues/1025 discusses the motivation.
The mechanical parts of this change were done via:
find clang \( -name '*.h' -o -name '*.cpp' -o -name '*.td' \) -print0 | xargs -0 perl -pi -e 's/mlir::cir/cir/g'
find clang \( -name '*.h' -o -name '*.cpp' \) -print0 | xargs -0 perl -pi -e 's/::cir/cir/g'
There were some manual fixups and a clang-format run afterwards.
>From d6f7f57e206c39be3af09a2fbfb84ae8759bce99 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai <smeenai at fb.com>
Date: Thu, 7 Nov 2024 14:36:25 -0800
Subject: [PATCH] Update
[ghstack-poisoned]
---
clang/include/clang/CIR/Dialect/IR/CIRDialect.td | 14 ++++++++------
clang/include/clang/CIR/Dialect/IR/CIROps.td | 8 ++++----
clang/lib/CIR/CodeGen/CIRGenModule.cpp | 2 +-
clang/lib/CIR/CodeGen/CIRGenerator.cpp | 2 +-
clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 2 +-
clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 10 +++++-----
clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 2 +-
.../lib/FrontendTool/ExecuteCompilerInvocation.cpp | 2 +-
8 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td
index 69d6e9774942b9d..305a06427ed0e0e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td
@@ -22,7 +22,7 @@ def CIR_Dialect : Dialect {
let summary = "A high-level dialect for analyzing and optimizing Clang "
"supported languages";
- let cppNamespace = "::mlir::cir";
+ let cppNamespace = "::cir";
let useDefaultAttributePrinterParser = 0;
let useDefaultTypePrinterParser = 0;
@@ -31,13 +31,15 @@ def CIR_Dialect : Dialect {
void registerAttributes();
void registerTypes();
- Type parseType(DialectAsmParser &parser) const override;
- void printType(Type type, DialectAsmPrinter &printer) const override;
+ mlir::Type parseType(mlir::DialectAsmParser &parser) const override;
+ void printType(mlir::Type type,
+ mlir::DialectAsmPrinter &printer) const override;
- Attribute parseAttribute(DialectAsmParser &parser,
- Type type) const override;
+ mlir::Attribute parseAttribute(mlir::DialectAsmParser &parser,
+ mlir::Type type) const override;
- void printAttribute(Attribute attr, DialectAsmPrinter &os) const override;
+ void printAttribute(mlir::Attribute attr,
+ mlir::DialectAsmPrinter &os) const override;
}];
}
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index c0440faa3c7b17e..4462eb6fc00bae4 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -51,12 +51,12 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
// following:
//
// class CIRFooOpLowering
-// : public mlir::OpConversionPattern<mlir::cir::FooOp> {
+// : public mlir::OpConversionPattern<cir::FooOp> {
// public:
-// using OpConversionPattern<mlir::cir::FooOp>::OpConversionPattern;
+// using OpConversionPattern<cir::FooOp>::OpConversionPattern;
//
// mlir::LogicalResult matchAndRewrite(
-// mlir::cir::FooOp op,
+// cir::FooOp op,
// OpAdaptor adaptor,
// mlir::ConversionPatternRewriter &rewriter) const override {
// rewriter.replaceOpWithNewOp<mlir::LLVM::BarOp>(
@@ -92,7 +92,7 @@ def FuncOp : CIR_Op<"func"> {
let skipDefaultBuilders = 1;
- let builders = [OpBuilder<(ins "StringRef":$name)>];
+ let builders = [OpBuilder<(ins "llvm::StringRef":$name)>];
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 5a6fc27a130c8f1..4e8a8cc3f4c524f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -77,7 +77,7 @@ void CIRGenModule::buildGlobal(clang::GlobalDecl gd) {
void CIRGenModule::buildGlobalFunctionDefinition(clang::GlobalDecl gd,
mlir::Operation *op) {
auto const *funcDecl = cast<FunctionDecl>(gd.getDecl());
- auto funcOp = builder.create<mlir::cir::FuncOp>(
+ auto funcOp = builder.create<cir::FuncOp>(
getLoc(funcDecl->getSourceRange()), funcDecl->getIdentifier()->getName());
theModule.push_back(funcOp);
}
diff --git a/clang/lib/CIR/CodeGen/CIRGenerator.cpp b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
index 825f78d32e76f04..85367a916ef7830 100644
--- a/clang/lib/CIR/CodeGen/CIRGenerator.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenerator.cpp
@@ -35,7 +35,7 @@ void CIRGenerator::Initialize(ASTContext &astCtx) {
this->astCtx = &astCtx;
mlirCtx = std::make_unique<mlir::MLIRContext>();
- mlirCtx->loadDialect<mlir::cir::CIRDialect>();
+ mlirCtx->loadDialect<cir::CIRDialect>();
cgm = std::make_unique<clang::CIRGen::CIRGenModule>(*mlirCtx.get(), astCtx,
codeGenOpts, diags);
}
diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
index 6d74d72b77dca76..7d42da1ab20d76b 100644
--- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
@@ -13,7 +13,7 @@
#include "clang/CIR/Dialect/IR/CIRDialect.h"
using namespace mlir;
-using namespace mlir::cir;
+using namespace cir;
//===----------------------------------------------------------------------===//
// General CIR parsing / printing
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index e0b38a2902bdbb2..f666e5ab4b9990c 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -17,13 +17,13 @@
#include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc"
using namespace mlir;
-using namespace mlir::cir;
+using namespace cir;
//===----------------------------------------------------------------------===//
// CIR Dialect
//===----------------------------------------------------------------------===//
-void mlir::cir::CIRDialect::initialize() {
+void cir::CIRDialect::initialize() {
registerTypes();
registerAttributes();
addOperations<
@@ -36,8 +36,8 @@ void mlir::cir::CIRDialect::initialize() {
// FuncOp
//===----------------------------------------------------------------------===//
-void mlir::cir::FuncOp::build(OpBuilder &builder, OperationState &result,
- StringRef name) {
+void cir::FuncOp::build(OpBuilder &builder, OperationState &result,
+ StringRef name) {
result.addAttribute(SymbolTable::getSymbolAttrName(),
builder.getStringAttr(name));
}
@@ -56,7 +56,7 @@ void cir::FuncOp::print(OpAsmPrinter &p) {
p.printSymbolName(getSymName());
}
-mlir::LogicalResult mlir::cir::FuncOp::verify() { return success(); }
+mlir::LogicalResult cir::FuncOp::verify() { return success(); }
//===----------------------------------------------------------------------===//
// TableGen'd op method definitions
diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
index 167c237ae5515c2..4eeb70f06f5f760 100644
--- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
@@ -13,7 +13,7 @@
#include "clang/CIR/Dialect/IR/CIRDialect.h"
using namespace mlir;
-using namespace mlir::cir;
+using namespace cir;
//===----------------------------------------------------------------------===//
// General CIR parsing / printing
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 60fde03289cf354..3f95a1efb2eed70 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -67,7 +67,7 @@ CreateFrontendBaseAction(CompilerInstance &CI) {
case EmitBC: return std::make_unique<EmitBCAction>();
case EmitCIR:
#if CLANG_ENABLE_CIR
- return std::make_unique<::cir::EmitCIRAction>();
+ return std::make_unique<cir::EmitCIRAction>();
#else
llvm_unreachable("CIR suppport not built into clang");
#endif
More information about the llvm-branch-commits
mailing list