1 //===-- PPCTargetAsmInfo.cpp - PPC 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 DarwinTargetAsmInfo properties.
12 //===----------------------------------------------------------------------===//
14 #include "PPCTargetAsmInfo.h"
15 #include "PPCTargetMachine.h"
16 #include "llvm/Function.h"
17 #include "llvm/Support/Dwarf.h"
20 using namespace llvm::dwarf;
22 TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);
24 PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
25 PPCTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
29 PrivateGlobalPrefix = "L";
30 LessPrivateGlobalPrefix = "l";
31 StringConstantPrefix = "\1LC";
32 ConstantPoolSection = "\t.const\t";
33 JumpTableDataSection = ".const";
34 CStringSection = "\t.cstring";
35 if (TM.getRelocationModel() == Reloc::Static) {
36 StaticCtorsSection = ".constructor";
37 StaticDtorsSection = ".destructor";
39 StaticCtorsSection = ".mod_init_func";
40 StaticDtorsSection = ".mod_term_func";
42 SwitchToSectionDirective = "\t.section ";
43 UsedDirective = "\t.no_dead_strip\t";
44 WeakDefDirective = "\t.weak_definition ";
45 WeakRefDirective = "\t.weak_reference ";
46 HiddenDirective = "\t.private_extern ";
47 SupportsExceptionHandling = true;
48 NeedsIndirectEncoding = true;
53 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
54 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
55 GlobalEHDirective = "\t.globl\t";
56 SupportsWeakOmittedEHFrame = false;
58 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
59 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
60 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
61 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
62 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
63 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
64 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
65 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
66 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
67 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
68 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
70 // In non-PIC modes, emit a special label before jump tables so that the
71 // linker can perform more accurate dead code stripping.
72 if (TM.getRelocationModel() != Reloc::PIC_) {
73 // Emit a local label that is preserved until the linker runs.
74 JumpTableSpecialLabelPrefix = "l";
78 /// PreferredEHDataFormat - This hook allows the target to select data
79 /// format used for encoding pointers in exception handling data. Reason is
80 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
81 /// if the symbol can be relocated.
83 PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
85 if (Reason == DwarfEncoding::Functions && Global)
86 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
87 else if (Reason == DwarfEncoding::CodeLabels || !Global)
88 return DW_EH_PE_pcrel;
90 return DW_EH_PE_absptr;
94 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
95 PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
98 PrivateGlobalPrefix = "";
99 ConstantPoolSection = "\t.section .rodata.cst4\t";
100 JumpTableDataSection = ".section .rodata.cst4";
101 CStringSection = ".rodata.str";
102 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
103 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
104 UsedDirective = "\t# .no_dead_strip\t";
105 WeakRefDirective = "\t.weak\t";
106 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
108 // PPC/Linux normally uses named section for BSS.
109 BSSSection_ = getNamedSection("\t.bss",
110 SectionFlags::Writeable | SectionFlags::BSS,
111 /* Override */ true);
114 AbsoluteDebugSectionOffsets = true;
115 SupportsDebugInformation = true;
116 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
117 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
118 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
119 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
120 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
121 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
122 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
123 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
124 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
125 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
126 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
130 // Set up DWARF directives
131 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
133 // Exceptions handling
134 if (!TM.getSubtargetImpl()->isPPC64())
135 SupportsExceptionHandling = true;
136 AbsoluteEHSectionOffsets = false;
137 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
138 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
141 /// PreferredEHDataFormat - This hook allows the target to select data
142 /// format used for encoding pointers in exception handling data. Reason is
143 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
144 /// if the symbol can be relocated.
146 PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
148 // We really need to write something here.
149 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);