aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/AsmPrinter
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 22:05:14 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 22:05:14 +0800
commit3a57627e59ba18b6f9f9aae7bb60c390c0d3575a (patch)
tree736ca062bfffbd68177a512dfe145b06c16d11b1 /backend/lib/AsmPrinter
parent379ff50dcc7ccf977379aee68fa9d10f69065d23 (diff)
downloadrcc-project-3a57627e59ba18b6f9f9aae7bb60c390c0d3575a.tar.gz
rcc-project-3a57627e59ba18b6f9f9aae7bb60c390c0d3575a.tar.xz
[MC] Implement RV64GC object emission
Diffstat (limited to 'backend/lib/AsmPrinter')
-rw-r--r--backend/lib/AsmPrinter/AsmPrinter.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/backend/lib/AsmPrinter/AsmPrinter.cpp b/backend/lib/AsmPrinter/AsmPrinter.cpp
index cebd6b8..49388e1 100644
--- a/backend/lib/AsmPrinter/AsmPrinter.cpp
+++ b/backend/lib/AsmPrinter/AsmPrinter.cpp
@@ -318,7 +318,7 @@ Expected<void> AsmPrinter::emitGlobalObjects(const CompilationUnit &Unit) {
const GlobalObjectDesc *Object = Unit.globalObjectAt(Index);
if (Object == nullptr)
return makeUnexpected(ErrorCode::InternalError, "compilation unit contains a null global");
- if (Object->isDeclaration() || Object->Linkage == GlobalLinkage::AvailableExternally)
+ if (Object->Linkage == GlobalLinkage::AvailableExternally)
continue;
const mc::MCSymbolRef Symbol = Context->globalSymbol(*Object);
@@ -327,14 +327,11 @@ Expected<void> AsmPrinter::emitGlobalObjects(const CompilationUnit &Unit) {
auto Attributes = emitGlobalAttributes(*Object, Symbol, *Streamer);
if (!Attributes)
return std::unexpected(Attributes.error());
+ if (Object->isDeclaration())
+ continue;
if (Object->Linkage == GlobalLinkage::Common) {
- auto Name = mc::printMCSymbolName(Symbol->name());
- if (!Name)
- return std::unexpected(Name.error());
- auto Common =
- Streamer->emitDirective("comm", *Name + "," + std::to_string(Object->Size) + "," +
- std::to_string(Object->Align.bytes()));
+ auto Common = Streamer->emitCommonSymbol(Symbol, Object->Size, Object->Align.bytes());
if (!Common)
return std::unexpected(Common.error());
continue;