Skip to content

Commit 51a9bbb

Browse files
smeenaiGroverkss
authored andcommittedNov 15, 2024
[clang][CIR] Move CIRGen types into clang::CIRGen (llvm#115385)
llvm/clangir#1025 explains why we want to move the CIR dialect from the `mlir::cir` to the `cir` namespace. To avoid overloading the `cir` namespace too much afterwards, move all symbols whose equivalents live inside the `clang::CodeGen` namespace to a new `clang::CIRGen` namespace, so that we match the original CodeGen's structure more closely.
1 parent 2941d39 commit 51a9bbb

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed
 

‎clang/include/clang/CIR/CIRGenerator.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
namespace clang {
2626
class DeclGroupRef;
2727
class DiagnosticsEngine;
28+
namespace CIRGen {
29+
class CIRGenModule;
30+
} // namespace CIRGen
2831
} // namespace clang
2932

3033
namespace mlir {
3134
class MLIRContext;
3235
} // namespace mlir
3336
namespace cir {
34-
class CIRGenModule;
35-
3637
class CIRGenerator : public clang::ASTConsumer {
3738
virtual void anchor();
3839
clang::DiagnosticsEngine &diags;
@@ -44,7 +45,7 @@ class CIRGenerator : public clang::ASTConsumer {
4445

4546
protected:
4647
std::unique_ptr<mlir::MLIRContext> mlirCtx;
47-
std::unique_ptr<CIRGenModule> cgm;
48+
std::unique_ptr<clang::CIRGen::CIRGenModule> cgm;
4849

4950
public:
5051
CIRGenerator(clang::DiagnosticsEngine &diags,

‎clang/lib/CIR/CodeGen/CIRGenModule.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#include "mlir/IR/Location.h"
2323
#include "mlir/IR/MLIRContext.h"
2424

25-
using namespace cir;
25+
using namespace clang;
26+
using namespace clang::CIRGen;
27+
2628
CIRGenModule::CIRGenModule(mlir::MLIRContext &context,
2729
clang::ASTContext &astctx,
2830
const clang::CodeGenOptions &cgo,

‎clang/lib/CIR/CodeGen/CIRGenModule.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ class LangOptions;
3131
class SourceLocation;
3232
class SourceRange;
3333
class TargetInfo;
34-
} // namespace clang
3534

36-
using namespace clang;
37-
namespace cir {
35+
namespace CIRGen {
3836

3937
/// This class organizes the cross-function state that is used while generating
4038
/// CIR code.
@@ -91,6 +89,8 @@ class CIRGenModule : public CIRGenTypeCache {
9189
DiagnosticBuilder errorNYI(SourceRange, llvm::StringRef);
9290
DiagnosticBuilder errorNYI(SourceRange, llvm::StringRef, llvm::StringRef);
9391
};
94-
} // namespace cir
92+
} // namespace CIRGen
93+
94+
} // namespace clang
9595

9696
#endif // LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENMODULE_H

‎clang/lib/CIR/CodeGen/CIRGenTypeCache.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#ifndef LLVM_CLANG_LIB_CIR_CIRGENTYPECACHE_H
1414
#define LLVM_CLANG_LIB_CIR_CIRGENTYPECACHE_H
1515

16-
namespace cir {
16+
namespace clang::CIRGen {
1717

1818
/// This structure provides a set of types that are commonly used
1919
/// during IR emission. It's initialized once in CodeGenModule's
@@ -22,6 +22,6 @@ struct CIRGenTypeCache {
2222
CIRGenTypeCache() = default;
2323
};
2424

25-
} // namespace cir
25+
} // namespace clang::CIRGen
2626

2727
#endif // LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENTYPECACHE_H

‎clang/lib/CIR/CodeGen/CIRGenerator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ void CIRGenerator::Initialize(ASTContext &astCtx) {
3636

3737
mlirCtx = std::make_unique<mlir::MLIRContext>();
3838
mlirCtx->loadDialect<mlir::cir::CIRDialect>();
39-
cgm = std::make_unique<CIRGenModule>(*mlirCtx.get(), astCtx, codeGenOpts,
40-
diags);
39+
cgm = std::make_unique<clang::CIRGen::CIRGenModule>(*mlirCtx.get(), astCtx,
40+
codeGenOpts, diags);
4141
}
4242

4343
mlir::ModuleOp CIRGenerator::getModule() const { return cgm->getModule(); }

0 commit comments

Comments
 (0)
Please sign in to comment.