Skip to content

Commit 1791b25

Browse files
authoredNov 12, 2024··
[clang][CIR] Change buildX functions to emitX (#115568)
The buildX naming convention originated when the CIRGen implementation was planned to be substantially different from original CodeGen. CIRGen is now a much closer adaption of CodeGen, and the emitX to buildX renaming just makes things more confusing, since CodeGen also has some helper functions whose names start with build or Build, so it's not immediately clear which CodeGen function corresponds to a CIRGen buildX function. Rename the buildX functions back to emitX to fix this.
1 parent ae7392b commit 1791b25

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed
 

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mlir::Location CIRGenModule::getLoc(SourceRange cRange) {
5050
return mlir::FusedLoc::get({begin, end}, metadata, builder.getContext());
5151
}
5252

53-
void CIRGenModule::buildGlobal(clang::GlobalDecl gd) {
53+
void CIRGenModule::emitGlobal(clang::GlobalDecl gd) {
5454
const auto *global = cast<ValueDecl>(gd.getDecl());
5555

5656
if (const auto *fd = dyn_cast<FunctionDecl>(global)) {
@@ -71,19 +71,19 @@ void CIRGenModule::buildGlobal(clang::GlobalDecl gd) {
7171
}
7272

7373
// TODO(CIR): Defer emitting some global definitions until later
74-
buildGlobalDefinition(gd);
74+
emitGlobalDefinition(gd);
7575
}
7676

77-
void CIRGenModule::buildGlobalFunctionDefinition(clang::GlobalDecl gd,
78-
mlir::Operation *op) {
77+
void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd,
78+
mlir::Operation *op) {
7979
auto const *funcDecl = cast<FunctionDecl>(gd.getDecl());
8080
auto funcOp = builder.create<cir::FuncOp>(
8181
getLoc(funcDecl->getSourceRange()), funcDecl->getIdentifier()->getName());
8282
theModule.push_back(funcOp);
8383
}
8484

85-
void CIRGenModule::buildGlobalDefinition(clang::GlobalDecl gd,
86-
mlir::Operation *op) {
85+
void CIRGenModule::emitGlobalDefinition(clang::GlobalDecl gd,
86+
mlir::Operation *op) {
8787
const auto *decl = cast<ValueDecl>(gd.getDecl());
8888
if (const auto *fd = dyn_cast<FunctionDecl>(decl)) {
8989
// TODO(CIR): Skip generation of CIR for functions with available_externally
@@ -99,15 +99,15 @@ void CIRGenModule::buildGlobalDefinition(clang::GlobalDecl gd,
9999

100100
if (fd->isMultiVersion())
101101
errorNYI(fd->getSourceRange(), "multiversion functions");
102-
buildGlobalFunctionDefinition(gd, op);
102+
emitGlobalFunctionDefinition(gd, op);
103103
return;
104104
}
105105

106-
llvm_unreachable("Invalid argument to CIRGenModule::buildGlobalDefinition");
106+
llvm_unreachable("Invalid argument to CIRGenModule::emitGlobalDefinition");
107107
}
108108

109109
// Emit code for a single top level declaration.
110-
void CIRGenModule::buildTopLevelDecl(Decl *decl) {
110+
void CIRGenModule::emitTopLevelDecl(Decl *decl) {
111111

112112
// Ignore dependent declarations.
113113
if (decl->isTemplated())
@@ -123,7 +123,7 @@ void CIRGenModule::buildTopLevelDecl(Decl *decl) {
123123
auto *fd = cast<FunctionDecl>(decl);
124124
// Consteval functions shouldn't be emitted.
125125
if (!fd->isConsteval())
126-
buildGlobal(fd);
126+
emitGlobal(fd);
127127
break;
128128
}
129129
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ class CIRGenModule : public CIRGenTypeCache {
7272
mlir::Location getLoc(clang::SourceLocation cLoc);
7373
mlir::Location getLoc(clang::SourceRange cRange);
7474

75-
void buildTopLevelDecl(clang::Decl *decl);
75+
void emitTopLevelDecl(clang::Decl *decl);
7676

7777
/// Emit code for a single global function or variable declaration. Forward
7878
/// declarations are emitted lazily.
79-
void buildGlobal(clang::GlobalDecl gd);
79+
void emitGlobal(clang::GlobalDecl gd);
8080

81-
void buildGlobalDefinition(clang::GlobalDecl gd,
82-
mlir::Operation *op = nullptr);
83-
void buildGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op);
81+
void emitGlobalDefinition(clang::GlobalDecl gd,
82+
mlir::Operation *op = nullptr);
83+
void emitGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op);
8484

8585
/// Helpers to emit "not yet implemented" error diagnostics
8686
DiagnosticBuilder errorNYI(llvm::StringRef);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mlir::ModuleOp CIRGenerator::getModule() const { return cgm->getModule(); }
4545
bool CIRGenerator::HandleTopLevelDecl(DeclGroupRef group) {
4646

4747
for (Decl *decl : group)
48-
cgm->buildTopLevelDecl(decl);
48+
cgm->emitTopLevelDecl(decl);
4949

5050
return true;
5151
}

0 commit comments

Comments
 (0)
Please sign in to comment.