blob: a8eaf5cf64e237befa0a944d53924e3f53dec637 [file] [log] [blame]
Jim Laskey8e8de8f2006-09-07 22:05:02 +00001//===-- X86TargetAsmInfo.cpp - X86 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 X86TargetAsmInfo properties.
11//
12//===----------------------------------------------------------------------===//
13
14#include "X86TargetAsmInfo.h"
15#include "X86TargetMachine.h"
16#include "X86Subtarget.h"
Reid Spencer7aa8a452007-01-12 23:22:14 +000017#include "llvm/DerivedTypes.h"
Chris Lattner625bd052006-11-29 01:14:06 +000018#include "llvm/InlineAsm.h"
19#include "llvm/Instructions.h"
Chris Lattner3e9f1d02007-04-01 20:49:36 +000020#include "llvm/Intrinsics.h"
Chris Lattner625bd052006-11-29 01:14:06 +000021#include "llvm/Module.h"
22#include "llvm/ADT/StringExtras.h"
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000023#include "llvm/Support/Dwarf.h"
Torok Edwinc25e7582009-07-11 20:10:48 +000024#include "llvm/Support/ErrorHandling.h"
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000025
Jim Laskey8e8de8f2006-09-07 22:05:02 +000026using namespace llvm;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000027using namespace llvm::dwarf;
Jim Laskey8e8de8f2006-09-07 22:05:02 +000028
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000029const char *const llvm::x86_asm_table[] = {
30 "{si}", "S",
31 "{di}", "D",
32 "{ax}", "a",
33 "{cx}", "c",
34 "{memory}", "memory",
35 "{flags}", "",
36 "{dirflag}", "",
37 "{fpsr}", "",
38 "{cc}", "cc",
39 0,0};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000040
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000041X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000042 X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Bill Wendlingb6be1392009-07-13 18:48:39 +000043 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000044 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000045
46 AlignmentIsInBytes = false;
47 TextAlignFillValue = 0x90;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000048
49
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000050 if (!is64Bit)
51 Data64bitsDirective = 0; // we can't emit a 64-bit unit
52 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000053 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000054 LCOMMDirective = "\t.lcomm\t";
Bill Wendlingb6be1392009-07-13 18:48:39 +000055
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000056 // Leopard and above support aligned common symbols.
57 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000058 HasDotTypeDotSizeDirective = false;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000059
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000060 if (is64Bit) {
61 PersonalityPrefix = "";
62 PersonalitySuffix = "+4@GOTPCREL";
63 } else {
64 PersonalityPrefix = "L";
65 PersonalitySuffix = "$non_lazy_ptr";
66 }
Bill Wendlingb6be1392009-07-13 18:48:39 +000067
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000068 InlineAsmStart = "## InlineAsm Start";
69 InlineAsmEnd = "## InlineAsm End";
70 CommentString = "##";
71 SetDirective = "\t.set";
72 PCSymbol = ".";
73 UsedDirective = "\t.no_dead_strip\t";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000074 ProtectedDirective = "\t.globl\t";
75
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000076 SupportsDebugInformation = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000077 DwarfDebugInlineSection = ".section __DWARF,__debug_inlined,regular,debug";
78 DwarfUsesInlineInfoSection = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000079
80 // Exceptions handling
81 SupportsExceptionHandling = true;
82 GlobalEHDirective = "\t.globl\t";
83 SupportsWeakOmittedEHFrame = false;
84 AbsoluteEHSectionOffsets = false;
85 DwarfEHFrameSection =
86 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000087}
88
Chris Lattnere3466942009-07-27 06:17:14 +000089X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) :
Chris Lattner8d4a0a32009-08-02 04:27:24 +000090 X86TargetAsmInfo<TargetAsmInfo>(TM) {
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000091
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000092 PrivateGlobalPrefix = ".L";
93 WeakRefDirective = "\t.weak\t";
94 SetDirective = "\t.set\t";
95 PCSymbol = ".";
96
97 // Set up DWARF directives
98 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
99
100 // Debug Information
101 AbsoluteDebugSectionOffsets = true;
102 SupportsDebugInformation = true;
103 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
104 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
105 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
106 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
107 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
108 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
109 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
110 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
111 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
112 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
Chris Lattnerb839c3f2009-06-18 23:31:37 +0000113 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000114
115 // Exceptions handling
Anton Korobeynikovc4da15a2008-09-08 21:13:08 +0000116 SupportsExceptionHandling = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000117 AbsoluteEHSectionOffsets = false;
118 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000119
120 // On Linux we must declare when we can use a non-executable stack.
Dan Gohman8f092252008-11-03 18:22:42 +0000121 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000122 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
123}
124
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000125
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000126X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
Chris Lattner40412e72009-07-27 16:45:59 +0000127 X86TargetAsmInfo<TargetAsmInfo>(TM) {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000128 GlobalPrefix = "_";
129 CommentString = ";";
130
Eli Friedmanaace4b12009-06-19 04:48:38 +0000131 InlineAsmStart = "; InlineAsm Start";
132 InlineAsmEnd = "; InlineAsm End";
133
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000134 PrivateGlobalPrefix = "$";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000135 AlignDirective = "\tALIGN\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000136 ZeroDirective = "\tdb\t";
137 ZeroDirectiveSuffix = " dup(0)";
138 AsciiDirective = "\tdb\t";
139 AscizDirective = 0;
140 Data8bitsDirective = "\tdb\t";
141 Data16bitsDirective = "\tdw\t";
142 Data32bitsDirective = "\tdd\t";
143 Data64bitsDirective = "\tdq\t";
144 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000145 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000146
Eli Friedmanaace4b12009-06-19 04:48:38 +0000147 AlignmentIsInBytes = true;
148
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000149 SwitchToSectionDirective = "";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000150 TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'";
151 DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000152 SectionEndDirectiveSuffix = "\tends\n";
153}
Anton Korobeynikov6381a132008-10-05 08:53:29 +0000154
Anton Korobeynikov6381a132008-10-05 08:53:29 +0000155// Instantiate default implementation.
156TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>);