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 DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
36 : PPCTargetAsmInfo(TM)
41 PrivateGlobalPrefix = "L";
42 ConstantPoolSection = "\t.const\t";
43 JumpTableDataSection = ".const";
44 CStringSection = "\t.cstring";
45 FourByteConstantSection = "\t.literal4\n";
46 EightByteConstantSection = "\t.literal8\n";
47 ReadOnlySection = "\t.const\n";
48 if (TM.getRelocationModel() == Reloc::Static) {
49 StaticCtorsSection = ".constructor";
50 StaticDtorsSection = ".destructor";
52 StaticCtorsSection = ".mod_init_func";
53 StaticDtorsSection = ".mod_term_func";
55 SwitchToSectionDirective = "\t.section ";
56 UsedDirective = "\t.no_dead_strip\t";
57 WeakDefDirective = "\t.weak_definition ";
58 WeakRefDirective = "\t.weak_reference ";
59 HiddenDirective = "\t.private_extern ";
60 SupportsExceptionHandling = true;
61 NeedsIndirectEncoding = true;
66 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
67 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
68 GlobalEHDirective = "\t.globl\t";
69 SupportsWeakOmittedEHFrame = false;
71 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
72 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
73 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
74 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
75 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
76 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
77 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
78 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
79 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
80 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
81 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
83 // In non-PIC modes, emit a special label before jump tables so that the
84 // linker can perform more accurate dead code stripping.
85 if (TM.getRelocationModel() != Reloc::PIC_) {
86 // Emit a local label that is preserved until the linker runs.
87 JumpTableSpecialLabelPrefix = "l";
91 /// PreferredEHDataFormat - This hook allows the target to select data
92 /// format used for encoding pointers in exception handling data. Reason is
93 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
94 /// if the symbol can be relocated.
95 unsigned DarwinTargetAsmInfo::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 LinuxTargetAsmInfo::LinuxTargetAsmInfo(const PPCTargetMachine &TM)
107 : PPCTargetAsmInfo(TM)
111 PrivateGlobalPrefix = "";
112 ConstantPoolSection = "\t.section .rodata.cst4\t";
113 JumpTableDataSection = ".section .rodata.cst4";
114 CStringSection = "\t.section\t.rodata";
115 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
116 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
117 UsedDirective = "\t# .no_dead_strip\t";
118 WeakRefDirective = "\t.weak\t";
119 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
122 AbsoluteDebugSectionOffsets = true;
123 SupportsDebugInformation = true;
124 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
125 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
126 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
127 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
128 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
129 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
130 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
131 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
132 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
133 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
134 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
136 ReadOnlySection = "\t.section\t.rodata";
137 FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4";
138 EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\",@progbits,8";
139 SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\",@progbits,16";
142 // Set up DWARF directives
143 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
145 // Exceptions handling
146 if (!TM.getSubtargetImpl()->isPPC64())
147 SupportsExceptionHandling = true;
148 AbsoluteEHSectionOffsets = false;
149 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
150 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
153 /// PreferredEHDataFormat - This hook allows the target to select data
154 /// format used for encoding pointers in exception handling data. Reason is
155 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
156 /// if the symbol can be relocated.
157 unsigned LinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
159 // We really need to write something here.
160 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);