mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
finish simplifying DarwinTargetAsmInfo::SelectSectionForGlobal
for now. Make the section switching directives more consistent by not including \n and including \t for them all. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77107 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c993250dd2
commit
30c4a3b9a8
@ -66,6 +66,12 @@ namespace llvm {
|
|||||||
K == RODataMergeConst || K == RODataMergeStr;
|
K == RODataMergeConst || K == RODataMergeStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// isReadOnlyWithDynamicInit - Return true if this data is readonly, but
|
||||||
|
/// the dynamic linker has to write to it to apply relocations.
|
||||||
|
bool isReadOnlyWithDynamicInit() const {
|
||||||
|
return K == DataRelRO || K == DataRelROLocal;
|
||||||
|
}
|
||||||
|
|
||||||
bool isBSS() const {
|
bool isBSS() const {
|
||||||
return K == BSS || K == ThreadBSS;
|
return K == BSS || K == ThreadBSS;
|
||||||
}
|
}
|
||||||
@ -87,6 +93,9 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isMergableString() const { return K == RODataMergeStr; }
|
bool isMergableString() const { return K == RODataMergeStr; }
|
||||||
|
bool isMergableConstant() const {
|
||||||
|
return K == RODataMergeStr || K == RODataMergeConst;
|
||||||
|
}
|
||||||
|
|
||||||
static SectionKind get(Kind K) {
|
static SectionKind get(Kind K) {
|
||||||
SectionKind Res = { K };
|
SectionKind Res = { K };
|
||||||
|
@ -39,7 +39,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
|
|||||||
// there, if needed.
|
// there, if needed.
|
||||||
SixteenByteConstantSection = 0;
|
SixteenByteConstantSection = 0;
|
||||||
|
|
||||||
ReadOnlySection = getUnnamedSection("\t.const\n", SectionFlags::None);
|
ReadOnlySection = getUnnamedSection("\t.const", SectionFlags::None);
|
||||||
|
|
||||||
TextCoalSection =
|
TextCoalSection =
|
||||||
getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
|
getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions",
|
||||||
@ -48,7 +48,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
|
|||||||
SectionFlags::None);
|
SectionFlags::None);
|
||||||
ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced",
|
ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced",
|
||||||
SectionFlags::None);
|
SectionFlags::None);
|
||||||
ConstDataSection = getUnnamedSection(".const_data", SectionFlags::None);
|
ConstDataSection = getUnnamedSection("\t.const_data", SectionFlags::None);
|
||||||
DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced",
|
DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced",
|
||||||
SectionFlags::Writable);
|
SectionFlags::Writable);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)
|
|||||||
|
|
||||||
// Sections:
|
// Sections:
|
||||||
CStringSection = "\t.cstring";
|
CStringSection = "\t.cstring";
|
||||||
JumpTableDataSection = "\t.const\n";
|
JumpTableDataSection = "\t.const";
|
||||||
BSSSection = 0;
|
BSSSection = 0;
|
||||||
|
|
||||||
if (TM.getRelocationModel() == Reloc::Static) {
|
if (TM.getRelocationModel() == Reloc::Static) {
|
||||||
@ -131,7 +131,6 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
|
|||||||
|
|
||||||
// FIXME: Use sectionflags:linkonce instead of isWeakForLinker() here.
|
// FIXME: Use sectionflags:linkonce instead of isWeakForLinker() here.
|
||||||
bool isWeak = GV->isWeakForLinker();
|
bool isWeak = GV->isWeakForLinker();
|
||||||
bool isNonStatic = TM.getRelocationModel() != Reloc::Static;
|
|
||||||
|
|
||||||
if (Kind.isCode())
|
if (Kind.isCode())
|
||||||
return isWeak ? TextCoalSection : TextSection;
|
return isWeak ? TextCoalSection : TextSection;
|
||||||
@ -148,30 +147,24 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
|
|||||||
if (Kind.isMergableString())
|
if (Kind.isMergableString())
|
||||||
return MergeableStringSection(cast<GlobalVariable>(GV));
|
return MergeableStringSection(cast<GlobalVariable>(GV));
|
||||||
|
|
||||||
switch (Kind.getKind()) {
|
if (Kind.isMergableConstant()) {
|
||||||
case SectionKind::Data:
|
|
||||||
case SectionKind::DataRelLocal:
|
|
||||||
case SectionKind::DataRel:
|
|
||||||
case SectionKind::BSS:
|
|
||||||
if (cast<GlobalVariable>(GV)->isConstant())
|
|
||||||
return ConstDataSection;
|
|
||||||
return DataSection;
|
|
||||||
|
|
||||||
case SectionKind::ROData:
|
|
||||||
case SectionKind::DataRelRO:
|
|
||||||
case SectionKind::DataRelROLocal:
|
|
||||||
return isNonStatic ? ConstDataSection : getReadOnlySection();
|
|
||||||
case SectionKind::RODataMergeConst: {
|
|
||||||
const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType();
|
const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType();
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
|
return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
llvm_unreachable("Unsuported section kind for global");
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Do we have any extra special weird cases?
|
// If this is marked const, put it into a const section. But if the dynamic
|
||||||
return NULL;
|
// linker needs to write to it, put it in the data segment.
|
||||||
|
if (Kind.isReadOnlyWithDynamicInit())
|
||||||
|
return ConstDataSection;
|
||||||
|
|
||||||
|
// FIXME: ROData -> const in -static mode that is relocatable but they happen
|
||||||
|
// by the static linker. Why not mergable?
|
||||||
|
if (Kind.isReadOnly())
|
||||||
|
return getReadOnlySection();
|
||||||
|
|
||||||
|
// Otherwise, just drop the variable in the normal data section.
|
||||||
|
return DataSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Section*
|
const Section*
|
||||||
|
@ -23,3 +23,20 @@
|
|||||||
; DARWIN: .section __TEXT,__const_coal,coalesced
|
; DARWIN: .section __TEXT,__const_coal,coalesced
|
||||||
; DARWIN: _G2:
|
; DARWIN: _G2:
|
||||||
; DARWIN: .long 42
|
; DARWIN: .long 42
|
||||||
|
|
||||||
|
|
||||||
|
; int * const G3 = &G1;
|
||||||
|
@G3 = constant i32* @G1
|
||||||
|
|
||||||
|
; DARWIN: .const_data
|
||||||
|
; DARWIN: .globl _G3
|
||||||
|
; DARWIN: _G3:
|
||||||
|
; DARWIN: .long _G1
|
||||||
|
|
||||||
|
|
||||||
|
; _Complex long long const G4 = 34;
|
||||||
|
@G4 = constant {i64,i64} { i64 34, i64 0 }
|
||||||
|
|
||||||
|
; DARWIN: .const
|
||||||
|
; DARWIN: _G4:
|
||||||
|
; .long 34
|
||||||
|
Loading…
Reference in New Issue
Block a user