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 PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
23 bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
25 ZeroDirective = "\t.space\t";
26 SetDirective = "\t.set";
27 Data64bitsDirective = isPPC64 ? "\t.quad\t" : 0;
28 AlignmentIsInBytes = false;
29 LCOMMDirective = "\t.lcomm\t";
30 InlineAsmStart = "# InlineAsm Start";
31 InlineAsmEnd = "# InlineAsm End";
32 AssemblerDialect = TM.getSubtargetImpl()->getAsmFlavor();
35 PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
36 PPCTargetAsmInfo(TM), DarwinTargetAsmInfo(TM) {
40 PrivateGlobalPrefix = "L";
41 LessPrivateGlobalPrefix = "l";
42 StringConstantPrefix = "\1LC";
43 ConstantPoolSection = "\t.const\t";
44 JumpTableDataSection = ".const";
45 CStringSection = "\t.cstring";
46 ReadOnlySection = "\t.const\n";
47 if (TM.getRelocationModel() == Reloc::Static) {
48 StaticCtorsSection = ".constructor";
49 StaticDtorsSection = ".destructor";
51 StaticCtorsSection = ".mod_init_func";
52 StaticDtorsSection = ".mod_term_func";
54 SwitchToSectionDirective = "\t.section ";
55 UsedDirective = "\t.no_dead_strip\t";
56 WeakDefDirective = "\t.weak_definition ";
57 WeakRefDirective = "\t.weak_reference ";
58 HiddenDirective = "\t.private_extern ";
59 SupportsExceptionHandling = true;
60 NeedsIndirectEncoding = true;
65 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
66 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
67 GlobalEHDirective = "\t.globl\t";
68 SupportsWeakOmittedEHFrame = false;
70 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
71 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
72 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
73 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
74 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
75 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
76 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
77 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
78 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
79 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
80 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
82 // In non-PIC modes, emit a special label before jump tables so that the
83 // linker can perform more accurate dead code stripping.
84 if (TM.getRelocationModel() != Reloc::PIC_) {
85 // Emit a local label that is preserved until the linker runs.
86 JumpTableSpecialLabelPrefix = "l";
90 /// PreferredEHDataFormat - This hook allows the target to select data
91 /// format used for encoding pointers in exception handling data. Reason is
92 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
93 /// if the symbol can be relocated.
95 PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
97 if (Reason == DwarfEncoding::Functions && Global)
98 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
99 else if (Reason == DwarfEncoding::CodeLabels || !Global)
100 return DW_EH_PE_pcrel;
102 return DW_EH_PE_absptr;
106 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
107 PPCTargetAsmInfo(TM), ELFTargetAsmInfo(TM) {
110 PrivateGlobalPrefix = "";
111 ConstantPoolSection = "\t.section .rodata.cst4\t";
112 JumpTableDataSection = ".section .rodata.cst4";
113 CStringSection = ".rodata.str";
114 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
115 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
116 UsedDirective = "\t# .no_dead_strip\t";
117 WeakRefDirective = "\t.weak\t";
118 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
120 // PPC/Linux normally uses named section for BSS.
121 BSSSection_ = getNamedSection("\t.bss",
122 SectionFlags::Writeable | SectionFlags::BSS,
123 /* Override */ true);
126 AbsoluteDebugSectionOffsets = true;
127 SupportsDebugInformation = true;
128 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
129 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
130 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
131 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
132 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
133 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
134 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
135 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
136 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
137 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
138 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
140 ReadOnlySection = "\t.section\t.rodata";
143 // Set up DWARF directives
144 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
146 // Exceptions handling
147 if (!TM.getSubtargetImpl()->isPPC64())
148 SupportsExceptionHandling = true;
149 AbsoluteEHSectionOffsets = false;
150 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
151 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
154 /// PreferredEHDataFormat - This hook allows the target to select data
155 /// format used for encoding pointers in exception handling data. Reason is
156 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
157 /// if the symbol can be relocated.
159 PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
161 // We really need to write something here.
162 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);