Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang][CIR] Merge the mlir::cir namespace into cir #115386

Merged
merged 3 commits into from
Nov 8, 2024
Merged

Conversation

smeenai
Copy link
Collaborator

@smeenai smeenai commented Nov 7, 2024

llvm/clangir#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.

Update

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
[ghstack-poisoned]
Update
[ghstack-poisoned]
@smeenai
Copy link
Collaborator Author

smeenai commented Nov 7, 2024

smeenai added a commit that referenced this pull request Nov 7, 2024
llvm/clangir#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.

ghstack-source-id: fe96b10e812e6316d15e2a7864131f1e7ac60c1c
ghstack-comment-id: 2463364322
Pull Request resolved: #115386
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Nov 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2024

@llvm/pr-subscribers-clangir

@llvm/pr-subscribers-clang

Author: Shoaib Meenai (smeenai)

Changes

llvm/clangir#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.


Full diff: https://github.com/llvm/llvm-project/pull/115386.diff

8 Files Affected:

  • (modified) clang/include/clang/CIR/Dialect/IR/CIRDialect.td (+8-6)
  • (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+4-4)
  • (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+1-1)
  • (modified) clang/lib/CIR/CodeGen/CIRGenerator.cpp (+1-1)
  • (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+1-1)
  • (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+5-5)
  • (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (+1-1)
  • (modified) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+1-1)
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

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this is following what Flang/FIR does, for consistency among projects. Thanks for putting some sanity on this Shoaib.

LGTM, pending Aaron's and others feedback.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from users/smeenai/1/head to main November 8, 2024 18:41
@smeenai smeenai merged commit c72389d into main Nov 8, 2024
5 of 6 checks passed
@smeenai smeenai deleted the users/smeenai/2/head branch November 8, 2024 18:43
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
llvm/clangir#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.
bcardosolopes pushed a commit to bcardosolopes/llvm-project that referenced this pull request Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants