blob: 75868d4a591037b449bbec776c1a37cc04038b9c [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
Jim Laskeybf111822006-12-21 20:26:09 +000022PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
Jim Laskey8e8de8f2006-09-07 22:05:02 +000023 bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
Jim Laskeybf111822006-12-21 20:26:09 +000024
Jim Laskey8e8de8f2006-09-07 22:05:02 +000025 ZeroDirective = "\t.space\t";
26 SetDirective = "\t.set";
Jim Laskeyf45c25f2006-09-08 13:06:56 +000027 Data64bitsDirective = isPPC64 ? "\t.quad\t" : 0;
Jim Laskey8e8de8f2006-09-07 22:05:02 +000028 AlignmentIsInBytes = false;
Jim Laskey8e8de8f2006-09-07 22:05:02 +000029 LCOMMDirective = "\t.lcomm\t";
Jim Laskey8e8de8f2006-09-07 22:05:02 +000030 InlineAsmStart = "# InlineAsm Start";
31 InlineAsmEnd = "# InlineAsm End";
Bill Wendlingcb900992007-01-16 09:29:17 +000032 AssemblerDialect = TM.getSubtargetImpl()->getAsmFlavor();
Jim Laskey8e8de8f2006-09-07 22:05:02 +000033}
Chris Lattnerb56dcc42006-10-05 00:35:50 +000034
Anton Korobeynikovbadd8df2008-07-19 21:44:57 +000035PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM)
Jim Laskeybf111822006-12-21 20:26:09 +000036: PPCTargetAsmInfo(TM)
37{
Jim Laskeyb82313f2007-02-01 16:31:34 +000038 PCSymbol = ".";
Jim Laskeybf111822006-12-21 20:26:09 +000039 CommentString = ";";
40 GlobalPrefix = "_";
41 PrivateGlobalPrefix = "L";
Dale Johannesen428ac542008-06-03 18:09:06 +000042 StringConstantPrefix = "\1LC";
Jim Laskeybf111822006-12-21 20:26:09 +000043 ConstantPoolSection = "\t.const\t";
44 JumpTableDataSection = ".const";
45 CStringSection = "\t.cstring";
Evan Cheng98ded762007-03-08 01:25:25 +000046 FourByteConstantSection = "\t.literal4\n";
47 EightByteConstantSection = "\t.literal8\n";
48 ReadOnlySection = "\t.const\n";
Evan Chengb267ca12007-01-30 08:04:53 +000049 if (TM.getRelocationModel() == Reloc::Static) {
50 StaticCtorsSection = ".constructor";
51 StaticDtorsSection = ".destructor";
52 } else {
53 StaticCtorsSection = ".mod_init_func";
54 StaticDtorsSection = ".mod_term_func";
55 }
Dale Johannesen4af34942008-01-15 23:24:56 +000056 SwitchToSectionDirective = "\t.section ";
Jim Laskeybf111822006-12-21 20:26:09 +000057 UsedDirective = "\t.no_dead_strip\t";
Dale Johannesen038129d2008-01-10 02:03:30 +000058 WeakDefDirective = "\t.weak_definition ";
59 WeakRefDirective = "\t.weak_reference ";
Dale Johannesenc7406ae2008-01-11 00:54:37 +000060 HiddenDirective = "\t.private_extern ";
Dale Johannesen696f7682007-12-19 21:54:36 +000061 SupportsExceptionHandling = true;
Bill Wendlingfe4afb12007-09-11 23:55:40 +000062 NeedsIndirectEncoding = true;
Nicolas Geoffray616585b2007-12-21 12:19:44 +000063 NeedsSet = true;
Nick Lewyckyf4c164c2007-11-04 17:32:10 +000064 BSSSection = 0;
Nicolas Geoffray616585b2007-12-21 12:19:44 +000065
66 DwarfEHFrameSection =
67 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
68 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
Dale Johannesen038129d2008-01-10 02:03:30 +000069 GlobalEHDirective = "\t.globl\t";
70 SupportsWeakOmittedEHFrame = false;
Nick Lewyckye2b90522007-07-25 03:48:45 +000071
72 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
73 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
74 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
75 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
76 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
77 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
78 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
79 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
80 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
81 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
82 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
Chris Lattnerb266ccd2007-01-18 01:15:58 +000083
84 // In non-PIC modes, emit a special label before jump tables so that the
85 // linker can perform more accurate dead code stripping.
86 if (TM.getRelocationModel() != Reloc::PIC_) {
87 // Emit a local label that is preserved until the linker runs.
88 JumpTableSpecialLabelPrefix = "l";
89 }
Jim Laskeybf111822006-12-21 20:26:09 +000090}
91
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000092/// PreferredEHDataFormat - This hook allows the target to select data
93/// format used for encoding pointers in exception handling data. Reason is
94/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
95/// if the symbol can be relocated.
Anton Korobeynikovbadd8df2008-07-19 21:44:57 +000096unsigned
97PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
98 bool Global) const {
Anton Korobeynikov8213f9c2008-02-29 22:09:08 +000099 if (Reason == DwarfEncoding::Functions && Global)
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000100 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
Anton Korobeynikov8213f9c2008-02-29 22:09:08 +0000101 else if (Reason == DwarfEncoding::CodeLabels || !Global)
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000102 return DW_EH_PE_pcrel;
103 else
104 return DW_EH_PE_absptr;
105}
106
107
Anton Korobeynikovbadd8df2008-07-19 21:44:57 +0000108PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM)
Jim Laskeybf111822006-12-21 20:26:09 +0000109: PPCTargetAsmInfo(TM)
110{
111 CommentString = "#";
112 GlobalPrefix = "";
113 PrivateGlobalPrefix = "";
Evan Cheng394d2802008-02-12 19:25:12 +0000114 ConstantPoolSection = "\t.section .rodata.cst4\t";
115 JumpTableDataSection = ".section .rodata.cst4";
Jim Laskeybf111822006-12-21 20:26:09 +0000116 CStringSection = "\t.section\t.rodata";
117 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
118 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
119 UsedDirective = "\t# .no_dead_strip\t";
120 WeakRefDirective = "\t.weak\t";
Nick Lewyckyf4c164c2007-11-04 17:32:10 +0000121 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
Nick Lewyckye2b90522007-07-25 03:48:45 +0000122
Nicolas Geoffray616585b2007-12-21 12:19:44 +0000123 // Debug Information
124 AbsoluteDebugSectionOffsets = true;
125 SupportsDebugInformation = true;
Nick Lewyckye2b90522007-07-25 03:48:45 +0000126 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
127 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
128 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
129 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
130 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
131 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
132 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
133 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
134 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
135 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
136 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
Nicolas Geoffray616585b2007-12-21 12:19:44 +0000137
138 ReadOnlySection = "\t.section\t.rodata";
139 FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4";
140 EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\",@progbits,8";
141 SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\",@progbits,16";
142 PCSymbol = ".";
143
144 // Set up DWARF directives
145 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
146
147 // Exceptions handling
148 if (!TM.getSubtargetImpl()->isPPC64())
149 SupportsExceptionHandling = true;
150 AbsoluteEHSectionOffsets = false;
151 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
152 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
Jim Laskeybf111822006-12-21 20:26:09 +0000153}
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000154
155/// PreferredEHDataFormat - This hook allows the target to select data
156/// format used for encoding pointers in exception handling data. Reason is
157/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
158/// if the symbol can be relocated.
Anton Korobeynikovbadd8df2008-07-19 21:44:57 +0000159unsigned
160PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
161 bool Global) const {
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000162 // We really need to write something here.
163 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
164}