give MCAsmInfo a 'has little endian' bit. This is unfortunate, but
[oota-llvm.git] / lib / Target / X86 / X86MCAsmInfo.cpp
1 //===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
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 X86MCAsmInfo properties.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "X86MCAsmInfo.h"
15 #include "X86TargetMachine.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/Support/CommandLine.h"
18 using namespace llvm;
19
20 enum AsmWriterFlavorTy {
21   // Note: This numbering has to match the GCC assembler dialects for inline
22   // asm alternatives to work right.
23   ATT = 0, Intel = 1
24 };
25
26 static cl::opt<AsmWriterFlavorTy>
27 AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
28   cl::desc("Choose style of code to emit from X86 backend:"),
29   cl::values(clEnumValN(ATT,   "att",   "Emit AT&T-style assembly"),
30              clEnumValN(Intel, "intel", "Emit Intel-style assembly"),
31              clEnumValEnd));
32
33
34 static const char *const x86_asm_table[] = {
35   "{si}", "S",
36   "{di}", "D",
37   "{ax}", "a",
38   "{cx}", "c",
39   "{memory}", "memory",
40   "{flags}", "",
41   "{dirflag}", "",
42   "{fpsr}", "",
43   "{cc}", "cc",
44   0,0};
45
46 X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple)
47   : MCAsmInfoDarwin(true /*islittleendian*/) {
48   AsmTransCBE = x86_asm_table;
49   AssemblerDialect = AsmWriterFlavor;
50     
51   bool is64Bit = Triple.getArch() == Triple::x86_64;
52
53   TextAlignFillValue = 0x90;
54
55   if (!is64Bit)
56     Data64bitsDirective = 0;       // we can't emit a 64-bit unit
57
58   // Leopard and above support aligned common symbols.
59   COMMDirectiveTakesAlignment = Triple.getDarwinMajorNumber() >= 9;
60
61   CommentString = "##";
62   PCSymbol = ".";
63
64   SupportsDebugInformation = true;
65   DwarfUsesInlineInfoSection = true;
66
67   // Exceptions handling
68   ExceptionsType = ExceptionHandling::Dwarf;
69   AbsoluteEHSectionOffsets = false;
70 }
71
72 X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple)
73   : MCAsmInfo(true /*islittleendian*/) {
74   AsmTransCBE = x86_asm_table;
75   AssemblerDialect = AsmWriterFlavor;
76
77   PrivateGlobalPrefix = ".L";
78   WeakRefDirective = "\t.weak\t";
79   SetDirective = "\t.set\t";
80   PCSymbol = ".";
81
82   // Set up DWARF directives
83   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
84
85   // Debug Information
86   AbsoluteDebugSectionOffsets = true;
87   SupportsDebugInformation = true;
88
89   // Exceptions handling
90   ExceptionsType = ExceptionHandling::Dwarf;
91   AbsoluteEHSectionOffsets = false;
92
93   // On Linux we must declare when we can use a non-executable stack.
94   if (Triple.getOS() == Triple::Linux)
95     NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
96 }
97
98 X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple)
99   : MCAsmInfoCOFF(true /*islittleendian*/) {
100   AsmTransCBE = x86_asm_table;
101   AssemblerDialect = AsmWriterFlavor;
102 }
103
104
105 X86WinMCAsmInfo::X86WinMCAsmInfo(const Triple &Triple)
106   : MCAsmInfo(true /*islittleendian*/) {
107   AsmTransCBE = x86_asm_table;
108   AssemblerDialect = AsmWriterFlavor;
109
110   GlobalPrefix = "_";
111   CommentString = ";";
112
113   PrivateGlobalPrefix = "$";
114   AlignDirective = "\tALIGN\t";
115   ZeroDirective = "\tdb\t";
116   AsciiDirective = "\tdb\t";
117   AscizDirective = 0;
118   Data8bitsDirective = "\tdb\t";
119   Data16bitsDirective = "\tdw\t";
120   Data32bitsDirective = "\tdd\t";
121   Data64bitsDirective = "\tdq\t";
122   HasDotTypeDotSizeDirective = false;
123   HasSingleParameterDotFile = false;
124
125   AlignmentIsInBytes = true;
126 }