blob: c8d1132314e38b17b2cd2b6f1874663c5e378c03 [file] [log] [blame]
Jim Laskey8e8de8f2006-09-07 22:05:02 +00001//===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey8e8de8f2006-09-07 22:05:02 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the declarations of the DarwinTargetAsmInfo properties.
11//
12//===----------------------------------------------------------------------===//
13
14#include "PPCTargetAsmInfo.h"
15#include "PPCTargetMachine.h"
Chris Lattnerb56dcc42006-10-05 00:35:50 +000016#include "llvm/Function.h"
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000017#include "llvm/Support/Dwarf.h"
18
Jim Laskey8e8de8f2006-09-07 22:05:02 +000019using namespace llvm;
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000020using namespace llvm::dwarf;
Jim Laskey8e8de8f2006-09-07 22:05:02 +000021
Anton Korobeynikovbc331a82008-08-08 18:23:25 +000022PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000023 PPCTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Jim Laskeyb82313f2007-02-01 16:31:34 +000024 PCSymbol = ".";
Jim Laskeybf111822006-12-21 20:26:09 +000025 CommentString = ";";
26 GlobalPrefix = "_";
27 PrivateGlobalPrefix = "L";
Dale Johannesenb2dfb892008-09-09 01:21:22 +000028 LessPrivateGlobalPrefix = "l";
Dale Johannesen428ac542008-06-03 18:09:06 +000029 StringConstantPrefix = "\1LC";
Jim Laskeybf111822006-12-21 20:26:09 +000030 ConstantPoolSection = "\t.const\t";
31 JumpTableDataSection = ".const";
32 CStringSection = "\t.cstring";
Evan Chengb267ca12007-01-30 08:04:53 +000033 if (TM.getRelocationModel() == Reloc::Static) {
34 StaticCtorsSection = ".constructor";
35 StaticDtorsSection = ".destructor";
36 } else {
37 StaticCtorsSection = ".mod_init_func";
38 StaticDtorsSection = ".mod_term_func";
39 }
Rafael Espindola952b8392008-12-03 11:01:37 +000040 HasSingleParameterDotFile = false;
Dale Johannesen4af34942008-01-15 23:24:56 +000041 SwitchToSectionDirective = "\t.section ";
Jim Laskeybf111822006-12-21 20:26:09 +000042 UsedDirective = "\t.no_dead_strip\t";
Dale Johannesen038129d2008-01-10 02:03:30 +000043 WeakDefDirective = "\t.weak_definition ";
44 WeakRefDirective = "\t.weak_reference ";
Dale Johannesenc7406ae2008-01-11 00:54:37 +000045 HiddenDirective = "\t.private_extern ";
Dale Johannesen696f7682007-12-19 21:54:36 +000046 SupportsExceptionHandling = true;
Bill Wendlingfe4afb12007-09-11 23:55:40 +000047 NeedsIndirectEncoding = true;
Nicolas Geoffray616585b2007-12-21 12:19:44 +000048 NeedsSet = true;
Nick Lewyckyf4c164c2007-11-04 17:32:10 +000049 BSSSection = 0;
Nicolas Geoffray616585b2007-12-21 12:19:44 +000050
51 DwarfEHFrameSection =
52 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
53 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
Dale Johannesen038129d2008-01-10 02:03:30 +000054 GlobalEHDirective = "\t.globl\t";
55 SupportsWeakOmittedEHFrame = false;
Nick Lewyckye2b90522007-07-25 03:48:45 +000056
57 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
58 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
59 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
60 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
61 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
62 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
63 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
64 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
65 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
66 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
67 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
Chris Lattnerb266ccd2007-01-18 01:15:58 +000068
69 // In non-PIC modes, emit a special label before jump tables so that the
70 // linker can perform more accurate dead code stripping.
Evan Chengb13bafe2009-06-18 20:37:15 +000071 // We do not check the relocation model here since it can be overridden
72 // later.
73 JumpTableSpecialLabelPrefix = "l";
Jim Laskeybf111822006-12-21 20:26:09 +000074}
75
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000076/// 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.
Anton Korobeynikovbadd8df2008-07-19 21:44:57 +000080unsigned
81PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
82 bool Global) const {
Anton Korobeynikov8213f9c2008-02-29 22:09:08 +000083 if (Reason == DwarfEncoding::Functions && Global)
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000084 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
Anton Korobeynikov8213f9c2008-02-29 22:09:08 +000085 else if (Reason == DwarfEncoding::CodeLabels || !Global)
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000086 return DW_EH_PE_pcrel;
87 else
88 return DW_EH_PE_absptr;
89}
90
Rafael Espindola2f6fea92008-12-19 10:55:56 +000091const char *
92PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const
93{
94 const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
95 if (Subtarget->getDarwinVers() > 9)
96 return PrivateGlobalPrefix;
97 else
98 return "";
99}
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000100
Anton Korobeynikov7396e592008-08-08 18:23:49 +0000101PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
Anton Korobeynikov32b952a2008-09-25 21:00:33 +0000102 PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
Jim Laskeybf111822006-12-21 20:26:09 +0000103 CommentString = "#";
104 GlobalPrefix = "";
Rafael Espindola2f6fea92008-12-19 10:55:56 +0000105 PrivateGlobalPrefix = ".L";
Evan Cheng394d2802008-02-12 19:25:12 +0000106 ConstantPoolSection = "\t.section .rodata.cst4\t";
107 JumpTableDataSection = ".section .rodata.cst4";
Anton Korobeynikov888839e2008-08-16 12:58:46 +0000108 CStringSection = ".rodata.str";
Jim Laskeybf111822006-12-21 20:26:09 +0000109 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
110 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
111 UsedDirective = "\t# .no_dead_strip\t";
112 WeakRefDirective = "\t.weak\t";
Nick Lewyckyf4c164c2007-11-04 17:32:10 +0000113 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
Nick Lewyckye2b90522007-07-25 03:48:45 +0000114
Anton Korobeynikovafc20ae2008-08-16 12:59:02 +0000115 // PPC/Linux normally uses named section for BSS.
116 BSSSection_ = getNamedSection("\t.bss",
117 SectionFlags::Writeable | SectionFlags::BSS,
118 /* Override */ true);
119
Nicolas Geoffray616585b2007-12-21 12:19:44 +0000120 // Debug Information
121 AbsoluteDebugSectionOffsets = true;
122 SupportsDebugInformation = true;
Nick Lewyckye2b90522007-07-25 03:48:45 +0000123 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
124 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
125 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
126 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
127 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
128 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
129 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
130 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
131 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
132 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
133 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
Nicolas Geoffray616585b2007-12-21 12:19:44 +0000134
Nicolas Geoffray616585b2007-12-21 12:19:44 +0000135 PCSymbol = ".";
136
137 // Set up DWARF directives
138 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
139
140 // Exceptions handling
141 if (!TM.getSubtargetImpl()->isPPC64())
142 SupportsExceptionHandling = true;
143 AbsoluteEHSectionOffsets = false;
144 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
145 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
Jim Laskeybf111822006-12-21 20:26:09 +0000146}
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000147
148/// PreferredEHDataFormat - This hook allows the target to select data
149/// format used for encoding pointers in exception handling data. Reason is
150/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
151/// if the symbol can be relocated.
Anton Korobeynikovbadd8df2008-07-19 21:44:57 +0000152unsigned
153PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
154 bool Global) const {
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000155 // We really need to write something here.
156 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
157}
Anton Korobeynikov6381a132008-10-05 08:53:29 +0000158
159// Instantiate default implementation.
160TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);