Reimplement rip-relative addressing in the X86-64 backend. The new
[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   ConstantPoolSection = "\t.const\t";
27   UsedDirective = "\t.no_dead_strip\t";
28   SupportsExceptionHandling = true;
29   
30   DwarfEHFrameSection =
31    ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
32   DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
33   GlobalEHDirective = "\t.globl\t";
34   SupportsWeakOmittedEHFrame = false;
35 }
36
37 /// PreferredEHDataFormat - This hook allows the target to select data
38 /// format used for encoding pointers in exception handling data. Reason is
39 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
40 /// if the symbol can be relocated.
41 unsigned
42 PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
43                                               bool Global) const {
44   if (Reason == DwarfEncoding::Functions && Global)
45     return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
46   else if (Reason == DwarfEncoding::CodeLabels || !Global)
47     return DW_EH_PE_pcrel;
48   else
49     return DW_EH_PE_absptr;
50 }
51
52 const char *
53 PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const
54 {
55   const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
56   if (Subtarget->getDarwinVers() > 9)
57     return PrivateGlobalPrefix;
58   else
59     return "";
60 }
61
62 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
63   PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
64   CommentString = "#";
65   GlobalPrefix = "";
66   PrivateGlobalPrefix = ".L";
67   ConstantPoolSection = "\t.section .rodata.cst4\t";
68   JumpTableDataSection = ".section .rodata.cst4";
69   CStringSection = ".rodata.str";
70   StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
71   StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
72   UsedDirective = "\t# .no_dead_strip\t";
73   WeakRefDirective = "\t.weak\t";
74   BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
75
76   // PPC/Linux normally uses named section for BSS.
77   BSSSection_  = getNamedSection("\t.bss",
78                                  SectionFlags::Writeable | SectionFlags::BSS,
79                                  /* Override */ true);
80
81   // Debug Information
82   AbsoluteDebugSectionOffsets = true;
83   SupportsDebugInformation = true;
84   DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits";
85   DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits";
86   DwarfLineSection =    "\t.section\t.debug_line,\"\",@progbits";
87   DwarfFrameSection =   "\t.section\t.debug_frame,\"\",@progbits";
88   DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
89   DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
90   DwarfStrSection =     "\t.section\t.debug_str,\"\",@progbits";
91   DwarfLocSection =     "\t.section\t.debug_loc,\"\",@progbits";
92   DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
93   DwarfRangesSection =  "\t.section\t.debug_ranges,\"\",@progbits";
94   DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
95
96   PCSymbol = ".";
97
98   // Set up DWARF directives
99   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
100
101   // Exceptions handling
102   if (!TM.getSubtargetImpl()->isPPC64())
103     SupportsExceptionHandling = true;
104   AbsoluteEHSectionOffsets = false;
105   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
106   DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
107 }
108
109 /// PreferredEHDataFormat - This hook allows the target to select data
110 /// format used for encoding pointers in exception handling data. Reason is
111 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
112 /// if the symbol can be relocated.
113 unsigned
114 PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
115                                              bool Global) const {
116   // We really need to write something here.
117   return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
118 }
119
120 // Instantiate default implementation.
121 TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);