1 //===-- XCoreTargetAsmInfo.cpp - XCore asm properties -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declarations of the XCoreTargetAsmInfo properties.
11 // We use the small section flag for the CP relative and DP relative
12 // flags. If a section is small and writable then it is DP relative. If a
13 // section is small and not writable then it is CP relative.
15 //===----------------------------------------------------------------------===//
17 #include "XCoreTargetAsmInfo.h"
18 #include "XCoreTargetMachine.h"
19 #include "llvm/GlobalVariable.h"
20 #include "llvm/ADT/StringExtras.h"
24 XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM)
25 : ELFTargetAsmInfo(TM),
26 Subtarget(TM.getSubtargetImpl()) {
27 SupportsDebugInformation = true;
28 TextSection = getUnnamedSection("\t.text", SectionFlags::Code);
29 DataSection = getNamedSection("\t.dp.data", SectionFlags::Writeable |
31 BSSSection_ = getNamedSection("\t.dp.bss", SectionFlags::Writeable |
32 SectionFlags::BSS | SectionFlags::Small);
33 if (Subtarget->isXS1A()) {
34 ReadOnlySection = getNamedSection("\t.dp.rodata", SectionFlags::None |
35 SectionFlags::Writeable |
38 ReadOnlySection = getNamedSection("\t.cp.rodata", SectionFlags::None |
41 Data16bitsDirective = "\t.short\t";
42 Data32bitsDirective = "\t.long\t";
43 Data64bitsDirective = 0;
44 ZeroDirective = "\t.space\t";
46 ConstantPoolSection = "\t.section\t.cp.rodata,\"ac\",@progbits";
47 JumpTableDataSection = "\t.section\t.dp.data,\"awd\",@progbits";
48 PrivateGlobalPrefix = ".L";
49 AscizDirective = ".asciiz";
50 WeakDefDirective = "\t.weak\t";
51 WeakRefDirective = "\t.weak\t";
52 SetDirective = "\t.set\t";
56 AbsoluteDebugSectionOffsets = true;
58 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
59 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
60 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
61 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
62 DwarfPubNamesSection = "\t.section\t.debug_pubnames,\"\",@progbits";
63 DwarfPubTypesSection = "\t.section\t.debug_pubtypes,\"\",@progbits";
64 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
65 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
66 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
67 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
68 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
72 XCoreTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
73 SectionKind::Kind Kind = SectionKindForGlobal(GV);
75 if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) {
76 if (!GVar->isWeakForLinker()) {
78 case SectionKind::RODataMergeConst:
79 return getReadOnlySection();
80 case SectionKind::ThreadData:
82 case SectionKind::ThreadBSS:
83 return getBSSSection_();
89 return ELFTargetAsmInfo::SelectSectionForGlobal(GV);
93 XCoreTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
94 const TargetData *TD = TM.getTargetData();
96 unsigned Size = TD->getTypeAllocSize(Ty);
97 if (Size == 4 || Size == 8 || Size == 16) {
98 std::string Name = ".cp.const" + utostr(Size);
100 return getNamedSection(Name.c_str(),
101 SectionFlags::setEntitySize(SectionFlags::Mergeable |
106 return getReadOnlySection();
109 unsigned XCoreTargetAsmInfo::
110 SectionFlagsForGlobal(const GlobalValue *GV, const char* Name) const {
111 unsigned Flags = ELFTargetAsmInfo::SectionFlagsForGlobal(GV, Name);
112 // Mask out unsupported flags
113 Flags &= ~(SectionFlags::Small | SectionFlags::TLS);
115 // Set CP / DP relative flags
117 SectionKind::Kind Kind = SectionKindForGlobal(GV);
119 case SectionKind::ThreadData:
120 case SectionKind::ThreadBSS:
121 case SectionKind::Data:
122 case SectionKind::BSS:
123 case SectionKind::SmallData:
124 case SectionKind::SmallBSS:
125 Flags |= SectionFlags::Small;
127 case SectionKind::ROData:
128 case SectionKind::RODataMergeStr:
129 case SectionKind::SmallROData:
130 if (Subtarget->isXS1A()) {
131 Flags |= SectionFlags::Writeable;
133 Flags |=SectionFlags::Small;
135 case SectionKind::RODataMergeConst:
136 Flags |=SectionFlags::Small;