Get rid of ReadOnlySection duplicate
[oota-llvm.git] / lib / Target / PowerPC / PPCTargetAsmInfo.cpp
1 //===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declarations of the DarwinTargetAsmInfo properties.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "PPCTargetAsmInfo.h"
15 #include "PPCTargetMachine.h"
16 #include "llvm/Function.h"
17 #include "llvm/Support/Dwarf.h"
18
19 using namespace llvm;
20 using namespace llvm::dwarf;
21
22 PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
23   bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
24
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();
33 }
34
35 PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
36   PPCTargetAsmInfo(TM), DarwinTargetAsmInfo(TM) {
37   PCSymbol = ".";
38   CommentString = ";";
39   GlobalPrefix = "_";
40   PrivateGlobalPrefix = "L";
41   LessPrivateGlobalPrefix = "l";
42   StringConstantPrefix = "\1LC";
43   ConstantPoolSection = "\t.const\t";
44   JumpTableDataSection = ".const";
45   CStringSection = "\t.cstring";
46   if (TM.getRelocationModel() == Reloc::Static) {
47     StaticCtorsSection = ".constructor";
48     StaticDtorsSection = ".destructor";
49   } else {
50     StaticCtorsSection = ".mod_init_func";
51     StaticDtorsSection = ".mod_term_func";
52   }
53   SwitchToSectionDirective = "\t.section ";
54   UsedDirective = "\t.no_dead_strip\t";
55   WeakDefDirective = "\t.weak_definition ";
56   WeakRefDirective = "\t.weak_reference ";
57   HiddenDirective = "\t.private_extern ";
58   SupportsExceptionHandling = true;
59   NeedsIndirectEncoding = true;
60   NeedsSet = true;
61   BSSSection = 0;
62   
63   DwarfEHFrameSection =
64   ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
65   DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
66   GlobalEHDirective = "\t.globl\t";
67   SupportsWeakOmittedEHFrame = false;
68
69   DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
70   DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
71   DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
72   DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
73   DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
74   DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
75   DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
76   DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
77   DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
78   DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
79   DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
80   
81   // In non-PIC modes, emit a special label before jump tables so that the
82   // linker can perform more accurate dead code stripping.
83   if (TM.getRelocationModel() != Reloc::PIC_) {
84     // Emit a local label that is preserved until the linker runs.
85     JumpTableSpecialLabelPrefix = "l";
86   }
87 }
88
89 /// PreferredEHDataFormat - This hook allows the target to select data
90 /// format used for encoding pointers in exception handling data. Reason is
91 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
92 /// if the symbol can be relocated.
93 unsigned
94 PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
95                                               bool Global) const {
96   if (Reason == DwarfEncoding::Functions && Global)
97     return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
98   else if (Reason == DwarfEncoding::CodeLabels || !Global)
99     return DW_EH_PE_pcrel;
100   else
101     return DW_EH_PE_absptr;
102 }
103
104
105 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
106   PPCTargetAsmInfo(TM), ELFTargetAsmInfo(TM) {
107   CommentString = "#";
108   GlobalPrefix = "";
109   PrivateGlobalPrefix = "";
110   ConstantPoolSection = "\t.section .rodata.cst4\t";
111   JumpTableDataSection = ".section .rodata.cst4";
112   CStringSection = ".rodata.str";
113   StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
114   StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
115   UsedDirective = "\t# .no_dead_strip\t";
116   WeakRefDirective = "\t.weak\t";
117   BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
118
119   // PPC/Linux normally uses named section for BSS.
120   BSSSection_  = getNamedSection("\t.bss",
121                                  SectionFlags::Writeable | SectionFlags::BSS,
122                                  /* Override */ true);
123
124   // Debug Information
125   AbsoluteDebugSectionOffsets = true;
126   SupportsDebugInformation = true;
127   DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits";
128   DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits";
129   DwarfLineSection =    "\t.section\t.debug_line,\"\",@progbits";
130   DwarfFrameSection =   "\t.section\t.debug_frame,\"\",@progbits";
131   DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
132   DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
133   DwarfStrSection =     "\t.section\t.debug_str,\"\",@progbits";
134   DwarfLocSection =     "\t.section\t.debug_loc,\"\",@progbits";
135   DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
136   DwarfRangesSection =  "\t.section\t.debug_ranges,\"\",@progbits";
137   DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
138
139   PCSymbol = ".";
140
141   // Set up DWARF directives
142   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
143
144   // Exceptions handling
145   if (!TM.getSubtargetImpl()->isPPC64())
146     SupportsExceptionHandling = true;
147   AbsoluteEHSectionOffsets = false;
148   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
149   DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
150 }
151
152 /// PreferredEHDataFormat - This hook allows the target to select data
153 /// format used for encoding pointers in exception handling data. Reason is
154 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
155 /// if the symbol can be relocated.
156 unsigned
157 PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
158                                              bool Global) const {
159   // We really need to write something here.
160   return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
161 }