convert EHFrameSection to be managed by TLOF instead of TAI.
[oota-llvm.git] / lib / Target / X86 / X86TargetAsmInfo.cpp
1 //===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
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"
17 #include "llvm/DerivedTypes.h"
18 #include "llvm/InlineAsm.h"
19 #include "llvm/Instructions.h"
20 #include "llvm/Intrinsics.h"
21 #include "llvm/Module.h"
22 #include "llvm/ADT/StringExtras.h"
23 #include "llvm/Support/Dwarf.h"
24 #include "llvm/Support/ErrorHandling.h"
25
26 using namespace llvm;
27 using namespace llvm::dwarf;
28
29 const 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};
40
41 X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
42   X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
43   const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
44   bool is64Bit = Subtarget->is64Bit();
45
46   AlignmentIsInBytes = false;
47   TextAlignFillValue = 0x90;
48
49
50   if (!is64Bit)
51     Data64bitsDirective = 0;       // we can't emit a 64-bit unit
52   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
53   ZeroFillDirective = "\t.zerofill\t";  // Uses .zerofill
54   LCOMMDirective = "\t.lcomm\t";
55
56   // Leopard and above support aligned common symbols.
57   COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
58   HasDotTypeDotSizeDirective = false;
59
60   if (is64Bit) {
61     PersonalityPrefix = "";
62     PersonalitySuffix = "+4@GOTPCREL";
63   } else {
64     PersonalityPrefix = "L";
65     PersonalitySuffix = "$non_lazy_ptr";
66   }
67
68   InlineAsmStart = "## InlineAsm Start";
69   InlineAsmEnd = "## InlineAsm End";
70   CommentString = "##";
71   SetDirective = "\t.set";
72   PCSymbol = ".";
73   UsedDirective = "\t.no_dead_strip\t";
74   ProtectedDirective = "\t.globl\t";
75
76   SupportsDebugInformation = true;
77   DwarfDebugInlineSection = ".section __DWARF,__debug_inlined,regular,debug";
78   DwarfUsesInlineInfoSection = true;
79
80   // Exceptions handling
81   SupportsExceptionHandling = true;
82   GlobalEHDirective = "\t.globl\t";
83   SupportsWeakOmittedEHFrame = false;
84   AbsoluteEHSectionOffsets = false;
85 }
86
87 X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) :
88   X86TargetAsmInfo<TargetAsmInfo>(TM) {
89
90   PrivateGlobalPrefix = ".L";
91   WeakRefDirective = "\t.weak\t";
92   SetDirective = "\t.set\t";
93   PCSymbol = ".";
94
95   // Set up DWARF directives
96   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
97
98   // Debug Information
99   AbsoluteDebugSectionOffsets = true;
100   SupportsDebugInformation = true;
101   DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits";
102   DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits";
103   DwarfLineSection =    "\t.section\t.debug_line,\"\",@progbits";
104   DwarfFrameSection =   "\t.section\t.debug_frame,\"\",@progbits";
105   DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
106   DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
107   DwarfStrSection =     "\t.section\t.debug_str,\"\",@progbits";
108   DwarfLocSection =     "\t.section\t.debug_loc,\"\",@progbits";
109   DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
110   DwarfRangesSection =  "\t.section\t.debug_ranges,\"\",@progbits";
111   DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
112
113   // Exceptions handling
114   SupportsExceptionHandling = true;
115   AbsoluteEHSectionOffsets = false;
116
117   // On Linux we must declare when we can use a non-executable stack.
118   if (TM.getSubtarget<X86Subtarget>().isLinux())
119     NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
120 }
121
122
123 X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
124   X86TargetAsmInfo<TargetAsmInfo>(TM) {
125   GlobalPrefix = "_";
126   CommentString = ";";
127
128   InlineAsmStart = "; InlineAsm Start";
129   InlineAsmEnd   = "; InlineAsm End";
130
131   PrivateGlobalPrefix = "$";
132   AlignDirective = "\tALIGN\t";
133   ZeroDirective = "\tdb\t";
134   ZeroDirectiveSuffix = " dup(0)";
135   AsciiDirective = "\tdb\t";
136   AscizDirective = 0;
137   Data8bitsDirective = "\tdb\t";
138   Data16bitsDirective = "\tdw\t";
139   Data32bitsDirective = "\tdd\t";
140   Data64bitsDirective = "\tdq\t";
141   HasDotTypeDotSizeDirective = false;
142   HasSingleParameterDotFile = false;
143
144   AlignmentIsInBytes = true;
145
146   SwitchToSectionDirective = "";
147   TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'";
148   DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'";
149   SectionEndDirectiveSuffix = "\tends\n";
150 }
151
152 // Instantiate default implementation.
153 TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>);