Major calling convention code refactoring.
[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   DwarfUsesInlineInfoSection = true;
78
79   // Exceptions handling
80   SupportsExceptionHandling = true;
81   GlobalEHDirective = "\t.globl\t";
82   SupportsWeakOmittedEHFrame = false;
83   AbsoluteEHSectionOffsets = false;
84 }
85
86 X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) :
87   X86TargetAsmInfo<TargetAsmInfo>(TM) {
88
89   PrivateGlobalPrefix = ".L";
90   WeakRefDirective = "\t.weak\t";
91   SetDirective = "\t.set\t";
92   PCSymbol = ".";
93
94   // Set up DWARF directives
95   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
96
97   // Debug Information
98   AbsoluteDebugSectionOffsets = true;
99   SupportsDebugInformation = true;
100
101   // Exceptions handling
102   SupportsExceptionHandling = true;
103   AbsoluteEHSectionOffsets = false;
104
105   // On Linux we must declare when we can use a non-executable stack.
106   if (TM.getSubtarget<X86Subtarget>().isLinux())
107     NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
108 }
109
110
111 X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
112   X86TargetAsmInfo<TargetAsmInfo>(TM) {
113   GlobalPrefix = "_";
114   CommentString = ";";
115
116   InlineAsmStart = "; InlineAsm Start";
117   InlineAsmEnd   = "; InlineAsm End";
118
119   PrivateGlobalPrefix = "$";
120   AlignDirective = "\tALIGN\t";
121   ZeroDirective = "\tdb\t";
122   ZeroDirectiveSuffix = " dup(0)";
123   AsciiDirective = "\tdb\t";
124   AscizDirective = 0;
125   Data8bitsDirective = "\tdb\t";
126   Data16bitsDirective = "\tdw\t";
127   Data32bitsDirective = "\tdd\t";
128   Data64bitsDirective = "\tdq\t";
129   HasDotTypeDotSizeDirective = false;
130   HasSingleParameterDotFile = false;
131
132   AlignmentIsInBytes = true;
133
134   SwitchToSectionDirective = "";
135   TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'";
136   DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'";
137 }
138
139 // Instantiate default implementation.
140 TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>);