Identities are default now
[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 was developed by James M. Laskey and is distributed under the
6 // University of Illinois Open Source 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
18 using namespace llvm;
19
20 static const char* x86_asm_table[] = {"{si}", "S",
21                                       "{di}", "D",
22                                       "{ax}", "a",
23                                       "{cx}", "c",
24                                       "{memory}", "memory",
25                                       "{flags}", "",
26                                       "{dirflag}", "",
27                                       "{fpsr}", "",
28                                       "{cc}", "cc",
29                                       0,0};
30
31 X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
32   const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
33   
34   // FIXME - Should be simplified.
35
36   AsmTransCBE = x86_asm_table;
37   
38   switch (Subtarget->TargetType) {
39   case X86Subtarget::isDarwin:
40     AlignmentIsInBytes = false;
41     GlobalPrefix = "_";
42     if (!Subtarget->is64Bit())
43       Data64bitsDirective = 0;       // we can't emit a 64-bit unit
44     ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
45     PrivateGlobalPrefix = "L";     // Marker for constant pool idxs
46     ConstantPoolSection = "\t.const\n";
47     JumpTableDataSection = "\t.const\n";
48     CStringSection = "\t.cstring";
49     FourByteConstantSection = "\t.literal4\n";
50     EightByteConstantSection = "\t.literal8\n";
51     if (Subtarget->is64Bit())
52       SixteenByteConstantSection = "\t.literal16\n";
53     LCOMMDirective = "\t.lcomm\t";
54     COMMDirectiveTakesAlignment = false;
55     HasDotTypeDotSizeDirective = false;
56     StaticCtorsSection = ".mod_init_func";
57     StaticDtorsSection = ".mod_term_func";
58     InlineAsmStart = "# InlineAsm Start";
59     InlineAsmEnd = "# InlineAsm End";
60     SetDirective = "\t.set";
61     UsedDirective = "\t.no_dead_strip\t";
62     
63     NeedsSet = true;
64     DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
65     DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
66     DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
67     DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
68     DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
69     DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
70     DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
71     DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
72     DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
73     DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
74     DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
75     break;
76
77   case X86Subtarget::isELF:
78     // Set up DWARF directives
79     HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
80     // bool HasLEB128; // Defaults to false.
81     // hasDotLoc - True if target asm supports .loc directives.
82     // bool HasDotLoc; // Defaults to false.
83     // HasDotFile - True if target asm supports .file directives.
84     // bool HasDotFile; // Defaults to false.
85     PrivateGlobalPrefix = ".";  // Prefix for private global symbols
86     DwarfRequiresFrameSection = false;
87     DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits";
88     DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits";
89     DwarfLineSection =    "\t.section\t.debug_line,\"\",@progbits";
90     DwarfFrameSection =   "\t.section\t.debug_frame,\"\",@progbits";
91     DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
92     DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
93     DwarfStrSection =     "\t.section\t.debug_str,\"\",@progbits";
94     DwarfLocSection =     "\t.section\t.debug_loc,\"\",@progbits";
95     DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
96     DwarfRangesSection =  "\t.section\t.debug_ranges,\"\",@progbits";
97     DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
98     break;
99
100   case X86Subtarget::isCygwin:
101     GlobalPrefix = "_";
102     COMMDirectiveTakesAlignment = false;
103     HasDotTypeDotSizeDirective = false;
104     StaticCtorsSection = "\t.section .ctors,\"aw\"";
105     StaticDtorsSection = "\t.section .dtors,\"aw\"";
106
107     // Set up DWARF directives
108     HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
109     PrivateGlobalPrefix = "L";  // Prefix for private global symbols
110     DwarfRequiresFrameSection = false;
111     DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"dr\"";
112     DwarfInfoSection =    "\t.section\t.debug_info,\"dr\"";
113     DwarfLineSection =    "\t.section\t.debug_line,\"dr\"";
114     DwarfFrameSection =   "\t.section\t.debug_frame,\"dr\"";
115     DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
116     DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
117     DwarfStrSection =     "\t.section\t.debug_str,\"dr\"";
118     DwarfLocSection =     "\t.section\t.debug_loc,\"dr\"";
119     DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
120     DwarfRangesSection =  "\t.section\t.debug_ranges,\"dr\"";
121     DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
122     break;
123     
124     break;
125   case X86Subtarget::isWindows:
126     GlobalPrefix = "_";
127     HasDotTypeDotSizeDirective = false;
128     break;
129   default: break;
130   }
131   
132   if (Subtarget->isFlavorIntel()) {
133     GlobalPrefix = "_";
134     CommentString = ";";
135   
136     PrivateGlobalPrefix = "$";
137     AlignDirective = "\talign\t";
138     ZeroDirective = "\tdb\t";
139     ZeroDirectiveSuffix = " dup(0)";
140     AsciiDirective = "\tdb\t";
141     AscizDirective = 0;
142     Data8bitsDirective = "\tdb\t";
143     Data16bitsDirective = "\tdw\t";
144     Data32bitsDirective = "\tdd\t";
145     Data64bitsDirective = "\tdq\t";
146     HasDotTypeDotSizeDirective = false;
147     
148     TextSection = "_text";
149     DataSection = "_data";
150     SwitchToSectionDirective = "";
151     TextSectionStartSuffix = "\tsegment 'CODE'";
152     DataSectionStartSuffix = "\tsegment 'DATA'";
153     SectionEndDirectiveSuffix = "\tends\n";
154   }
155 }
156