blob: 89800247589e9a0a90a92a05096851c534275380 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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"
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000017#include "llvm/Support/Dwarf.h"
18
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019using namespace llvm;
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000020using namespace llvm::dwarf;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021
22PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
23 bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
Anton Korobeynikov248e9c52008-08-08 18:23:25 +000024
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025 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();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033}
34
Anton Korobeynikov248e9c52008-08-08 18:23:25 +000035PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
36 PPCTargetAsmInfo(TM), DarwinTargetAsmInfo(TM) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037 PCSymbol = ".";
38 CommentString = ";";
39 GlobalPrefix = "_";
40 PrivateGlobalPrefix = "L";
Dale Johannesen2d34f9f2008-09-09 01:21:22 +000041 LessPrivateGlobalPrefix = "l";
Dale Johannesen8f03a202008-06-03 18:09:06 +000042 StringConstantPrefix = "\1LC";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043 ConstantPoolSection = "\t.const\t";
44 JumpTableDataSection = ".const";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045 CStringSection = "\t.cstring";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046 ReadOnlySection = "\t.const\n";
47 if (TM.getRelocationModel() == Reloc::Static) {
48 StaticCtorsSection = ".constructor";
49 StaticDtorsSection = ".destructor";
50 } else {
51 StaticCtorsSection = ".mod_init_func";
52 StaticDtorsSection = ".mod_term_func";
53 }
Dale Johannesen4670be42008-01-15 23:24:56 +000054 SwitchToSectionDirective = "\t.section ";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055 UsedDirective = "\t.no_dead_strip\t";
Dale Johannesenf09b5992008-01-10 02:03:30 +000056 WeakDefDirective = "\t.weak_definition ";
57 WeakRefDirective = "\t.weak_reference ";
Dale Johannesen3c788322008-01-11 00:54:37 +000058 HiddenDirective = "\t.private_extern ";
Dale Johannesen15e8f532007-12-19 21:54:36 +000059 SupportsExceptionHandling = true;
Bill Wendling909ec562007-09-11 23:55:40 +000060 NeedsIndirectEncoding = true;
Nicolas Geoffray61864762007-12-21 12:19:44 +000061 NeedsSet = true;
Nick Lewyckyc6583752007-11-04 17:32:10 +000062 BSSSection = 0;
Nicolas Geoffray61864762007-12-21 12:19:44 +000063
64 DwarfEHFrameSection =
65 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
66 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
Dale Johannesenf09b5992008-01-10 02:03:30 +000067 GlobalEHDirective = "\t.globl\t";
68 SupportsWeakOmittedEHFrame = false;
Nick Lewycky3246a9c2007-07-25 03:48:45 +000069
70 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
71 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
72 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
73 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
74 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
75 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
76 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
77 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
78 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
79 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
80 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081
82 // In non-PIC modes, emit a special label before jump tables so that the
83 // linker can perform more accurate dead code stripping.
84 if (TM.getRelocationModel() != Reloc::PIC_) {
85 // Emit a local label that is preserved until the linker runs.
86 JumpTableSpecialLabelPrefix = "l";
87 }
88}
89
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000090/// PreferredEHDataFormat - This hook allows the target to select data
91/// format used for encoding pointers in exception handling data. Reason is
92/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
93/// if the symbol can be relocated.
Anton Korobeynikovd15bc312008-07-19 21:44:57 +000094unsigned
95PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
96 bool Global) const {
Anton Korobeynikov8750d7c2008-02-29 22:09:08 +000097 if (Reason == DwarfEncoding::Functions && Global)
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000098 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
Anton Korobeynikov8750d7c2008-02-29 22:09:08 +000099 else if (Reason == DwarfEncoding::CodeLabels || !Global)
Anton Korobeynikov0aeac602008-02-27 23:49:15 +0000100 return DW_EH_PE_pcrel;
101 else
102 return DW_EH_PE_absptr;
103}
104
105
Anton Korobeynikov894be4b2008-08-08 18:23:49 +0000106PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
107 PPCTargetAsmInfo(TM), ELFTargetAsmInfo(TM) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108 CommentString = "#";
109 GlobalPrefix = "";
110 PrivateGlobalPrefix = "";
Evan Chengbde1bfc2008-02-12 19:25:12 +0000111 ConstantPoolSection = "\t.section .rodata.cst4\t";
112 JumpTableDataSection = ".section .rodata.cst4";
asl7e07ea52008-08-16 12:58:46 +0000113 CStringSection = ".rodata.str";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
115 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
116 UsedDirective = "\t# .no_dead_strip\t";
117 WeakRefDirective = "\t.weak\t";
Nick Lewyckyc6583752007-11-04 17:32:10 +0000118 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
Nick Lewycky3246a9c2007-07-25 03:48:45 +0000119
asl4d8bcfd2008-08-16 12:59:02 +0000120 // PPC/Linux normally uses named section for BSS.
121 BSSSection_ = getNamedSection("\t.bss",
122 SectionFlags::Writeable | SectionFlags::BSS,
123 /* Override */ true);
124
Nicolas Geoffray61864762007-12-21 12:19:44 +0000125 // Debug Information
126 AbsoluteDebugSectionOffsets = true;
127 SupportsDebugInformation = true;
Nick Lewycky3246a9c2007-07-25 03:48:45 +0000128 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
129 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
130 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
131 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
132 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
133 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
134 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
135 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
136 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
137 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
138 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
Nicolas Geoffray61864762007-12-21 12:19:44 +0000139
140 ReadOnlySection = "\t.section\t.rodata";
Nicolas Geoffray61864762007-12-21 12:19:44 +0000141 PCSymbol = ".";
142
143 // Set up DWARF directives
144 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
145
146 // Exceptions handling
147 if (!TM.getSubtargetImpl()->isPPC64())
148 SupportsExceptionHandling = true;
149 AbsoluteEHSectionOffsets = false;
150 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
151 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152}
Anton Korobeynikov0aeac602008-02-27 23:49:15 +0000153
154/// PreferredEHDataFormat - This hook allows the target to select data
155/// format used for encoding pointers in exception handling data. Reason is
156/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
157/// if the symbol can be relocated.
Anton Korobeynikovd15bc312008-07-19 21:44:57 +0000158unsigned
159PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
160 bool Global) const {
Anton Korobeynikov0aeac602008-02-27 23:49:15 +0000161 // We really need to write something here.
162 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
163}