llvm.org GIT mirror llvm / 6381a13
Fix weird think-o and unbreak build on all gcc-3.4.x-based platforms (e.g. mingw) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57106 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 11 years ago
3 changed file(s) with 318 addition(s) and 325 deletion(s). Raw diff Collapse all Expand all
1515 #include
1616 #include
1717 using namespace llvm;
18
1819
1920 const char *const llvm::arm_asm_table[] = {
2021 "{r0}", "r0",
4041 "{memory}", "memory",
4142 "{cc}", "cc",
4243 0,0};
43
44 // Instantiate 'common' cases.
45 TEMPLATE_INSTANTIATION(class ARMTargetAsmInfo);
46 TEMPLATE_INSTANTIATION(
47 unsigned ARMTargetAsmInfo::getInlineAsmLength(const char*) const);
48 TEMPLATE_INSTANTIATION(
49 unsigned ARMTargetAsmInfo::countArguments(const char*) const);
50 TEMPLATE_INSTANTIATION(
51 unsigned ARMTargetAsmInfo::countString(const char*) const);
5244
5345 ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
5446 ARMTargetAsmInfo(TM) {
287279 free(s_copy);
288280 return Length;
289281 }
282
283 // Instantiate default implementation.
284 TEMPLATE_INSTANTIATION(class ARMTargetAsmInfo);
1717
1818 using namespace llvm;
1919 using namespace llvm::dwarf;
20
21 TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo);
2220
2321 PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
2422 PPCTargetAsmInfo(TM) {
147145 // We really need to write something here.
148146 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
149147 }
148
149 // Instantiate default implementation.
150 TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo);
3636 "{cc}", "cc",
3737 0,0};
3838
39 TEMPLATE_INSTANTIATION(class X86TargetAsmInfo);
40 TEMPLATE_INSTANTIATION(
41 bool X86TargetAsmInfo::ExpandInlineAsm(CallInst*) const);
42 TEMPLATE_INSTANTIATION(
43 bool X86TargetAsmInfo::LowerToBSwap(CallInst*) const);
39 X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
40 X86TargetAsmInfo(TM) {
41 const X86Subtarget* Subtarget = &DTM->getSubtarget();
42 bool is64Bit = Subtarget->is64Bit();
43
44 AlignmentIsInBytes = false;
45 TextAlignFillValue = 0x90;
46 GlobalPrefix = "_";
47 if (!is64Bit)
48 Data64bitsDirective = 0; // we can't emit a 64-bit unit
49 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
50 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
51 LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
52 BSSSection = 0; // no BSS section.
53 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
54 if (DTM->getRelocationModel() != Reloc::Static)
55 ConstantPoolSection = "\t.const_data";
56 else
57 ConstantPoolSection = "\t.const\n";
58 JumpTableDataSection = "\t.const\n";
59 CStringSection = "\t.cstring";
60 // FIXME: Why don't always use this section?
61 if (is64Bit) {
62 SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
63 SectionFlags::Mergeable);
64 }
65 LCOMMDirective = "\t.lcomm\t";
66 SwitchToSectionDirective = "\t.section ";
67 StringConstantPrefix = "\1LC";
68 // Leopard and above support aligned common symbols.
69 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
70 HasDotTypeDotSizeDirective = false;
71 if (TM.getRelocationModel() == Reloc::Static) {
72 StaticCtorsSection = ".constructor";
73 StaticDtorsSection = ".destructor";
74 } else {
75 StaticCtorsSection = ".mod_init_func";
76 StaticDtorsSection = ".mod_term_func";
77 }
78 if (is64Bit) {
79 PersonalityPrefix = "";
80 PersonalitySuffix = "+4@GOTPCREL";
81 } else {
82 PersonalityPrefix = "L";
83 PersonalitySuffix = "$non_lazy_ptr";
84 }
85 NeedsIndirectEncoding = true;
86 InlineAsmStart = "## InlineAsm Start";
87 InlineAsmEnd = "## InlineAsm End";
88 CommentString = "##";
89 SetDirective = "\t.set";
90 PCSymbol = ".";
91 UsedDirective = "\t.no_dead_strip\t";
92 WeakDefDirective = "\t.weak_definition ";
93 WeakRefDirective = "\t.weak_reference ";
94 HiddenDirective = "\t.private_extern ";
95 ProtectedDirective = "\t.globl\t";
96
97 // In non-PIC modes, emit a special label before jump tables so that the
98 // linker can perform more accurate dead code stripping.
99 if (TM.getRelocationModel() != Reloc::PIC_) {
100 // Emit a local label that is preserved until the linker runs.
101 JumpTableSpecialLabelPrefix = "l";
102 }
103
104 SupportsDebugInformation = true;
105 NeedsSet = true;
106 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
107 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
108 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
109 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
110 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
111 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
112 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
113 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
114 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
115 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
116 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
117
118 // Exceptions handling
119 SupportsExceptionHandling = true;
120 GlobalEHDirective = "\t.globl\t";
121 SupportsWeakOmittedEHFrame = false;
122 AbsoluteEHSectionOffsets = false;
123 DwarfEHFrameSection =
124 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
125 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
126 }
127
128 unsigned
129 X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
130 bool Global) const {
131 if (Reason == DwarfEncoding::Functions && Global)
132 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
133 else if (Reason == DwarfEncoding::CodeLabels || !Global)
134 return DW_EH_PE_pcrel;
135 else
136 return DW_EH_PE_absptr;
137 }
138
139 X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
140 X86TargetAsmInfo(TM) {
141
142 CStringSection = ".rodata.str";
143 PrivateGlobalPrefix = ".L";
144 WeakRefDirective = "\t.weak\t";
145 SetDirective = "\t.set\t";
146 PCSymbol = ".";
147
148 // Set up DWARF directives
149 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
150
151 // Debug Information
152 AbsoluteDebugSectionOffsets = true;
153 SupportsDebugInformation = true;
154 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
155 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
156 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
157 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
158 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
159 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
160 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
161 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
162 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
163 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
164 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
165
166 // Exceptions handling
167 SupportsExceptionHandling = true;
168 AbsoluteEHSectionOffsets = false;
169 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
170 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
171
172 // On Linux we must declare when we can use a non-executable stack.
173 if (ETM->getSubtarget().isLinux())
174 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
175 }
176
177 unsigned
178 X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
179 bool Global) const {
180 CodeModel::Model CM = ETM->getCodeModel();
181 bool is64Bit = ETM->getSubtarget().is64Bit();
182
183 if (ETM->getRelocationModel() == Reloc::PIC_) {
184 unsigned Format = 0;
185
186 if (!is64Bit)
187 // 32 bit targets always encode pointers as 4 bytes
188 Format = DW_EH_PE_sdata4;
189 else {
190 // 64 bit targets encode pointers in 4 bytes iff:
191 // - code model is small OR
192 // - code model is medium and we're emitting externally visible symbols
193 // or any code symbols
194 if (CM == CodeModel::Small ||
195 (CM == CodeModel::Medium && (Global ||
196 Reason != DwarfEncoding::Data)))
197 Format = DW_EH_PE_sdata4;
198 else
199 Format = DW_EH_PE_sdata8;
200 }
201
202 if (Global)
203 Format |= DW_EH_PE_indirect;
204
205 return (Format | DW_EH_PE_pcrel);
206 } else {
207 if (is64Bit &&
208 (CM == CodeModel::Small ||
209 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
210 return DW_EH_PE_udata4;
211 else
212 return DW_EH_PE_absptr;
213 }
214 }
215
216 X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
217 X86GenericTargetAsmInfo(TM) {
218 X86TM = &TM;
219
220 GlobalPrefix = "_";
221 LCOMMDirective = "\t.lcomm\t";
222 COMMDirectiveTakesAlignment = false;
223 HasDotTypeDotSizeDirective = false;
224 StaticCtorsSection = "\t.section .ctors,\"aw\"";
225 StaticDtorsSection = "\t.section .dtors,\"aw\"";
226 HiddenDirective = NULL;
227 PrivateGlobalPrefix = "L"; // Prefix for private global symbols
228 WeakRefDirective = "\t.weak\t";
229 SetDirective = "\t.set\t";
230
231 // Set up DWARF directives
232 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
233 AbsoluteDebugSectionOffsets = true;
234 AbsoluteEHSectionOffsets = false;
235 SupportsDebugInformation = true;
236 DwarfSectionOffsetDirective = "\t.secrel32\t";
237 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
238 DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
239 DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
240 DwarfFrameSection = "\t.section\t.debug_frame,\"dr\"";
241 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
242 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
243 DwarfStrSection = "\t.section\t.debug_str,\"dr\"";
244 DwarfLocSection = "\t.section\t.debug_loc,\"dr\"";
245 DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
246 DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\"";
247 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
248 }
249
250 unsigned
251 X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
252 bool Global) const {
253 CodeModel::Model CM = X86TM->getCodeModel();
254 bool is64Bit = X86TM->getSubtarget().is64Bit();
255
256 if (X86TM->getRelocationModel() == Reloc::PIC_) {
257 unsigned Format = 0;
258
259 if (!is64Bit)
260 // 32 bit targets always encode pointers as 4 bytes
261 Format = DW_EH_PE_sdata4;
262 else {
263 // 64 bit targets encode pointers in 4 bytes iff:
264 // - code model is small OR
265 // - code model is medium and we're emitting externally visible symbols
266 // or any code symbols
267 if (CM == CodeModel::Small ||
268 (CM == CodeModel::Medium && (Global ||
269 Reason != DwarfEncoding::Data)))
270 Format = DW_EH_PE_sdata4;
271 else
272 Format = DW_EH_PE_sdata8;
273 }
274
275 if (Global)
276 Format |= DW_EH_PE_indirect;
277
278 return (Format | DW_EH_PE_pcrel);
279 } else {
280 if (is64Bit &&
281 (CM == CodeModel::Small ||
282 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
283 return DW_EH_PE_udata4;
284 else
285 return DW_EH_PE_absptr;
286 }
287 }
288
289 std::string
290 X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
291 SectionKind::Kind kind) const {
292 switch (kind) {
293 case SectionKind::Text:
294 return ".text$linkonce" + GV->getName();
295 case SectionKind::Data:
296 case SectionKind::BSS:
297 case SectionKind::ThreadData:
298 case SectionKind::ThreadBSS:
299 return ".data$linkonce" + GV->getName();
300 case SectionKind::ROData:
301 case SectionKind::RODataMergeConst:
302 case SectionKind::RODataMergeStr:
303 return ".rdata$linkonce" + GV->getName();
304 default:
305 assert(0 && "Unknown section kind");
306 }
307 }
308
309 std::string X86COFFTargetAsmInfo::printSectionFlags(unsigned flags) const {
310 std::string Flags = ",\"";
311
312 if (flags & SectionFlags::Code)
313 Flags += 'x';
314 if (flags & SectionFlags::Writeable)
315 Flags += 'w';
316
317 Flags += "\"";
318
319 return Flags;
320 }
321
322 X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
323 X86GenericTargetAsmInfo(TM) {
324 GlobalPrefix = "_";
325 CommentString = ";";
326
327 PrivateGlobalPrefix = "$";
328 AlignDirective = "\talign\t";
329 ZeroDirective = "\tdb\t";
330 ZeroDirectiveSuffix = " dup(0)";
331 AsciiDirective = "\tdb\t";
332 AscizDirective = 0;
333 Data8bitsDirective = "\tdb\t";
334 Data16bitsDirective = "\tdw\t";
335 Data32bitsDirective = "\tdd\t";
336 Data64bitsDirective = "\tdq\t";
337 HasDotTypeDotSizeDirective = false;
338
339 TextSection = getUnnamedSection("_text", SectionFlags::Code);
340 DataSection = getUnnamedSection("_data", SectionFlags::Writeable);
341
342 JumpTableDataSection = NULL;
343 SwitchToSectionDirective = "";
344 TextSectionStartSuffix = "\tsegment 'CODE'";
345 DataSectionStartSuffix = "\tsegment 'DATA'";
346 SectionEndDirectiveSuffix = "\tends\n";
347 }
44348
45349 template
46350 bool X86TargetAsmInfo::LowerToBSwap(CallInst *CI) const {
123427 return false;
124428 }
125429
126 X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
127 X86TargetAsmInfo(TM) {
128 const X86Subtarget* Subtarget = &DTM->getSubtarget();
129 bool is64Bit = Subtarget->is64Bit();
130
131 AlignmentIsInBytes = false;
132 TextAlignFillValue = 0x90;
133 GlobalPrefix = "_";
134 if (!is64Bit)
135 Data64bitsDirective = 0; // we can't emit a 64-bit unit
136 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
137 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
138 LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
139 BSSSection = 0; // no BSS section.
140 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
141 if (DTM->getRelocationModel() != Reloc::Static)
142 ConstantPoolSection = "\t.const_data";
143 else
144 ConstantPoolSection = "\t.const\n";
145 JumpTableDataSection = "\t.const\n";
146 CStringSection = "\t.cstring";
147 // FIXME: Why don't always use this section?
148 if (is64Bit) {
149 SixteenByteConstantSection = getUnnamedSection("\t.literal16\n",
150 SectionFlags::Mergeable);
151 }
152 LCOMMDirective = "\t.lcomm\t";
153 SwitchToSectionDirective = "\t.section ";
154 StringConstantPrefix = "\1LC";
155 // Leopard and above support aligned common symbols.
156 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
157 HasDotTypeDotSizeDirective = false;
158 if (TM.getRelocationModel() == Reloc::Static) {
159 StaticCtorsSection = ".constructor";
160 StaticDtorsSection = ".destructor";
161 } else {
162 StaticCtorsSection = ".mod_init_func";
163 StaticDtorsSection = ".mod_term_func";
164 }
165 if (is64Bit) {
166 PersonalityPrefix = "";
167 PersonalitySuffix = "+4@GOTPCREL";
168 } else {
169 PersonalityPrefix = "L";
170 PersonalitySuffix = "$non_lazy_ptr";
171 }
172 NeedsIndirectEncoding = true;
173 InlineAsmStart = "## InlineAsm Start";
174 InlineAsmEnd = "## InlineAsm End";
175 CommentString = "##";
176 SetDirective = "\t.set";
177 PCSymbol = ".";
178 UsedDirective = "\t.no_dead_strip\t";
179 WeakDefDirective = "\t.weak_definition ";
180 WeakRefDirective = "\t.weak_reference ";
181 HiddenDirective = "\t.private_extern ";
182 ProtectedDirective = "\t.globl\t";
183
184 // In non-PIC modes, emit a special label before jump tables so that the
185 // linker can perform more accurate dead code stripping.
186 if (TM.getRelocationModel() != Reloc::PIC_) {
187 // Emit a local label that is preserved until the linker runs.
188 JumpTableSpecialLabelPrefix = "l";
189 }
190
191 SupportsDebugInformation = true;
192 NeedsSet = true;
193 DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
194 DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
195 DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
196 DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
197 DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
198 DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
199 DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
200 DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
201 DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
202 DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
203 DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
204
205 // Exceptions handling
206 SupportsExceptionHandling = true;
207 GlobalEHDirective = "\t.globl\t";
208 SupportsWeakOmittedEHFrame = false;
209 AbsoluteEHSectionOffsets = false;
210 DwarfEHFrameSection =
211 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
212 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
213 }
214
215 unsigned
216 X86DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
217 bool Global) const {
218 if (Reason == DwarfEncoding::Functions && Global)
219 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
220 else if (Reason == DwarfEncoding::CodeLabels || !Global)
221 return DW_EH_PE_pcrel;
222 else
223 return DW_EH_PE_absptr;
224 }
225
226 X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM):
227 X86TargetAsmInfo(TM) {
228
229 CStringSection = ".rodata.str";
230 PrivateGlobalPrefix = ".L";
231 WeakRefDirective = "\t.weak\t";
232 SetDirective = "\t.set\t";
233 PCSymbol = ".";
234
235 // Set up DWARF directives
236 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
237
238 // Debug Information
239 AbsoluteDebugSectionOffsets = true;
240 SupportsDebugInformation = true;
241 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
242 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
243 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
244 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
245 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
246 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
247 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
248 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
249 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
250 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
251 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
252
253 // Exceptions handling
254 SupportsExceptionHandling = true;
255 AbsoluteEHSectionOffsets = false;
256 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
257 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
258
259 // On Linux we must declare when we can use a non-executable stack.
260 if (ETM->getSubtarget().isLinux())
261 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
262 }
263
264 unsigned
265 X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
266 bool Global) const {
267 CodeModel::Model CM = ETM->getCodeModel();
268 bool is64Bit = ETM->getSubtarget().is64Bit();
269
270 if (ETM->getRelocationModel() == Reloc::PIC_) {
271 unsigned Format = 0;
272
273 if (!is64Bit)
274 // 32 bit targets always encode pointers as 4 bytes
275 Format = DW_EH_PE_sdata4;
276 else {
277 // 64 bit targets encode pointers in 4 bytes iff:
278 // - code model is small OR
279 // - code model is medium and we're emitting externally visible symbols
280 // or any code symbols
281 if (CM == CodeModel::Small ||
282 (CM == CodeModel::Medium && (Global ||
283 Reason != DwarfEncoding::Data)))
284 Format = DW_EH_PE_sdata4;
285 else
286 Format = DW_EH_PE_sdata8;
287 }
288
289 if (Global)
290 Format |= DW_EH_PE_indirect;
291
292 return (Format | DW_EH_PE_pcrel);
293 } else {
294 if (is64Bit &&
295 (CM == CodeModel::Small ||
296 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
297 return DW_EH_PE_udata4;
298 else
299 return DW_EH_PE_absptr;
300 }
301 }
302
303 X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
304 X86GenericTargetAsmInfo(TM) {
305 X86TM = &TM;
306
307 GlobalPrefix = "_";
308 LCOMMDirective = "\t.lcomm\t";
309 COMMDirectiveTakesAlignment = false;
310 HasDotTypeDotSizeDirective = false;
311 StaticCtorsSection = "\t.section .ctors,\"aw\"";
312 StaticDtorsSection = "\t.section .dtors,\"aw\"";
313 HiddenDirective = NULL;
314 PrivateGlobalPrefix = "L"; // Prefix for private global symbols
315 WeakRefDirective = "\t.weak\t";
316 SetDirective = "\t.set\t";
317
318 // Set up DWARF directives
319 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
320 AbsoluteDebugSectionOffsets = true;
321 AbsoluteEHSectionOffsets = false;
322 SupportsDebugInformation = true;
323 DwarfSectionOffsetDirective = "\t.secrel32\t";
324 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
325 DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
326 DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
327 DwarfFrameSection = "\t.section\t.debug_frame,\"dr\"";
328 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
329 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
330 DwarfStrSection = "\t.section\t.debug_str,\"dr\"";
331 DwarfLocSection = "\t.section\t.debug_loc,\"dr\"";
332 DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
333 DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\"";
334 DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
335 }
336
337 unsigned
338 X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
339 bool Global) const {
340 CodeModel::Model CM = X86TM->getCodeModel();
341 bool is64Bit = X86TM->getSubtarget().is64Bit();
342
343 if (X86TM->getRelocationModel() == Reloc::PIC_) {
344 unsigned Format = 0;
345
346 if (!is64Bit)
347 // 32 bit targets always encode pointers as 4 bytes
348 Format = DW_EH_PE_sdata4;
349 else {
350 // 64 bit targets encode pointers in 4 bytes iff:
351 // - code model is small OR
352 // - code model is medium and we're emitting externally visible symbols
353 // or any code symbols
354 if (CM == CodeModel::Small ||
355 (CM == CodeModel::Medium && (Global ||
356 Reason != DwarfEncoding::Data)))
357 Format = DW_EH_PE_sdata4;
358 else
359 Format = DW_EH_PE_sdata8;
360 }
361
362 if (Global)
363 Format |= DW_EH_PE_indirect;
364
365 return (Format | DW_EH_PE_pcrel);
366 } else {
367 if (is64Bit &&
368 (CM == CodeModel::Small ||
369 (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
370 return DW_EH_PE_udata4;
371 else
372 return DW_EH_PE_absptr;
373 }
374 }
375
376 std::string
377 X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
378 SectionKind::Kind kind) const {
379 switch (kind) {
380 case SectionKind::Text:
381 return ".text$linkonce" + GV->getName();
382 case SectionKind::Data:
383 case SectionKind::BSS:
384 case SectionKind::ThreadData:
385 case SectionKind::ThreadBSS:
386 return ".data$linkonce" + GV->getName();
387 case SectionKind::ROData:
388 case SectionKind::RODataMergeConst:
389 case SectionKind::RODataMergeStr:
390 return ".rdata$linkonce" + GV->getName();
391 default:
392 assert(0 && "Unknown section kind");
393 }
394 }
395
396 std::string X86COFFTargetAsmInfo::printSectionFlags(unsigned flags) const {
397 std::string Flags = ",\"";
398
399 if (flags & SectionFlags::Code)
400 Flags += 'x';
401 if (flags & SectionFlags::Writeable)
402 Flags += 'w';
403
404 Flags += "\"";
405
406 return Flags;
407 }
408
409 X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
410 X86GenericTargetAsmInfo(TM) {
411 GlobalPrefix = "_";
412 CommentString = ";";
413
414 PrivateGlobalPrefix = "$";
415 AlignDirective = "\talign\t";
416 ZeroDirective = "\tdb\t";
417 ZeroDirectiveSuffix = " dup(0)";
418 AsciiDirective = "\tdb\t";
419 AscizDirective = 0;
420 Data8bitsDirective = "\tdb\t";
421 Data16bitsDirective = "\tdw\t";
422 Data32bitsDirective = "\tdd\t";
423 Data64bitsDirective = "\tdq\t";
424 HasDotTypeDotSizeDirective = false;
425
426 TextSection = getUnnamedSection("_text", SectionFlags::Code);
427 DataSection = getUnnamedSection("_data", SectionFlags::Writeable);
428
429 JumpTableDataSection = NULL;
430 SwitchToSectionDirective = "";
431 TextSectionStartSuffix = "\tsegment 'CODE'";
432 DataSectionStartSuffix = "\tsegment 'DATA'";
433 SectionEndDirectiveSuffix = "\tends\n";
434 }
430 // Instantiate default implementation.
431 TEMPLATE_INSTANTIATION(class X86TargetAsmInfo);