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