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