From 3a57627e59ba18b6f9f9aae7bb60c390c0d3575a Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sun, 9 Aug 2026 22:05:14 +0800 Subject: [MC] Implement RV64GC object emission --- backend/lib/AsmPrinter/AsmPrinter.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'backend/lib/AsmPrinter/AsmPrinter.cpp') 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 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 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; -- cgit v1.2.3