[PATCH] XCore target: Handle common linkage
robert lytton
robert at xmos.com
Wed Jan 29 09:46:24 PST 2014
implement common linkage for the xcore target
http://llvm-reviews.chandlerc.com/D2650
Files:
lib/Target/XCore/XCoreAsmPrinter.cpp
lib/Target/XCore/XCoreTargetObjectFile.cpp
test/CodeGen/XCore/linkage.ll
Index: lib/Target/XCore/XCoreAsmPrinter.cpp
===================================================================
--- lib/Target/XCore/XCoreAsmPrinter.cpp
+++ lib/Target/XCore/XCoreAsmPrinter.cpp
@@ -87,9 +87,9 @@
}
void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) {
- assert(((GV->hasExternalLinkage() ||
- GV->hasWeakLinkage()) ||
- GV->hasLinkOnceLinkage()) && "Unexpected linkage");
+ assert((GV->hasExternalLinkage() || GV->hasWeakLinkage() ||
+ GV->hasLinkOnceLinkage() || GV->hasCommonLinkage())
+ && "Unexpected linkage");
if (ArrayType *ATy = dyn_cast<ArrayType>(
cast<PointerType>(GV->getType())->getElementType())) {
@@ -99,7 +99,8 @@
OutStreamer.EmitAssignment(SymGlob,
MCConstantExpr::Create(ATy->getNumElements(),
OutContext));
- if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
+ if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()
+ || GV->hasCommonLinkage()) {
// TODO Use COMDAT groups for LinkOnceLinkage
OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Weak);
}
@@ -131,11 +132,13 @@
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
case GlobalValue::ExternalLinkage:
+ case GlobalValue::CommonLinkage:
emitArrayBound(GVSym, GV);
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
// TODO Use COMDAT groups for LinkOnceLinkage
- if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())
+ if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()
+ || GV->hasCommonLinkage())
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Weak);
// FALL THROUGH
case GlobalValue::InternalLinkage:
Index: lib/Target/XCore/XCoreTargetObjectFile.cpp
===================================================================
--- lib/Target/XCore/XCoreTargetObjectFile.cpp
+++ lib/Target/XCore/XCoreTargetObjectFile.cpp
@@ -149,13 +149,13 @@
TM.getDataLayout()->getTypeAllocSize(ObjType) < CodeModelLargeSize) {
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySection
: DataRelROSection;
- if (Kind.isBSS()) return BSSSection;
+ if (Kind.isBSS() || Kind.isCommon())return BSSSection;
if (Kind.isDataRel()) return DataSection;
if (Kind.isReadOnlyWithRel()) return DataRelROSection;
} else {
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySectionLarge
: DataRelROSectionLarge;
- if (Kind.isBSS()) return BSSSectionLarge;
+ if (Kind.isBSS() || Kind.isCommon())return BSSSectionLarge;
if (Kind.isDataRel()) return DataSectionLarge;
if (Kind.isReadOnlyWithRel()) return DataRelROSectionLarge;
}
Index: test/CodeGen/XCore/linkage.ll
===================================================================
--- test/CodeGen/XCore/linkage.ll
+++ test/CodeGen/XCore/linkage.ll
@@ -25,9 +25,21 @@
; CHECK: .weak array
@array = weak global [2 x i32] zeroinitializer
+; CHECK: .globl ac.globound
+; CHECK: ac.globound = 2
+; CHECK: .weak ac.globound
+; CHECK: .globl ac
+; CHECK: .weak ac
+ at ac = common global [2 x i32] zeroinitializer
+
+; CHECK: .globl gd
; CHECK: .weak gd
@gd = weak global i32 0
+; CHECK: .globl gc
+; CHECK: .weak gc
+ at gc = common global i32 0
+
; CHECK-NOT: .hidden test_hidden_declaration
; CHECK: .weak gr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2650.1.patch
Type: text/x-patch
Size: 3568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140129/5bc2ae05/attachment.bin>
More information about the llvm-commits
mailing list