blob: 0459f18c24a861a04b9db6b2ad3a4d4991aadccd [file] [log] [blame]
Jim Laskey8e8de8f2006-09-07 22:05:02 +00001//===-- 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
18using namespace llvm;
19
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000020static const char* x86_asm_table[] = {"{si}", "S",
21 "{di}", "D",
22 "{ax}", "a",
23 "{cx}", "c",
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000024 "{memory}", "memory",
25 "{flags}", "",
26 "{dirflag}", "",
27 "{fpsr}", "",
28 "{cc}", "cc",
29 0,0};
30
Jim Laskey8e8de8f2006-09-07 22:05:02 +000031X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
32 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
33
Chris Lattnerafbfded2006-10-05 02:43:52 +000034 // FIXME - Should be simplified.
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000035
36 AsmTransCBE = x86_asm_table;
37
Jim Laskey8e8de8f2006-09-07 22:05:02 +000038 switch (Subtarget->TargetType) {
39 case X86Subtarget::isDarwin:
40 AlignmentIsInBytes = false;
41 GlobalPrefix = "_";
Evan Cheng25ab6902006-09-08 06:48:29 +000042 if (!Subtarget->is64Bit())
43 Data64bitsDirective = 0; // we can't emit a 64-bit unit
Jim Laskey8e8de8f2006-09-07 22:05:02 +000044 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
45 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
46 ConstantPoolSection = "\t.const\n";
Chris Lattnerafbfded2006-10-05 02:43:52 +000047 JumpTableDataSection = "\t.const\n";
Evan Cheng8910c1c2006-10-26 19:18:18 +000048 CStringSection = "\t.cstring";
Jim Laskey8e8de8f2006-09-07 22:05:02 +000049 FourByteConstantSection = "\t.literal4\n";
50 EightByteConstantSection = "\t.literal8\n";
Evan Cheng25ab6902006-09-08 06:48:29 +000051 if (Subtarget->is64Bit())
52 SixteenByteConstantSection = "\t.literal16\n";
Jim Laskey8e8de8f2006-09-07 22:05:02 +000053 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";
Chris Lattnera53115b2006-09-26 03:39:53 +000061 UsedDirective = "\t.no_dead_strip\t";
Jim Laskey8e8de8f2006-09-07 22:05:02 +000062
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;
Reid Spencer02b85112006-10-30 22:32:30 +000076
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
Jim Laskey8e8de8f2006-09-07 22:05:02 +0000100 case X86Subtarget::isCygwin:
101 GlobalPrefix = "_";
102 COMMDirectiveTakesAlignment = false;
103 HasDotTypeDotSizeDirective = false;
104 StaticCtorsSection = "\t.section .ctors,\"aw\"";
105 StaticDtorsSection = "\t.section .dtors,\"aw\"";
Anton Korobeynikovab4022f2006-10-31 08:31:24 +0000106
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
Jim Laskey8e8de8f2006-09-07 22:05:02 +0000124 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}
Chris Lattnerafbfded2006-10-05 02:43:52 +0000156