blob: 7712b0225010d281229e7b05ddb3c674382fd8d6 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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"
Anton Korobeynikov65c0d872008-02-27 23:33:50 +000023#include "llvm/Support/Dwarf.h"
Edwin Török675d5622009-07-11 20:10:48 +000024#include "llvm/Support/ErrorHandling.h"
Anton Korobeynikov65c0d872008-02-27 23:33:50 +000025
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026using namespace llvm;
Anton Korobeynikov65c0d872008-02-27 23:33:50 +000027using namespace llvm::dwarf;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028
Chris Lattner4e765db2009-08-11 21:57:08 +000029static const char *const x86_asm_table[] = {
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000030 "{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};
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Chris Lattner4e765db2009-08-11 21:57:08 +000041X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM) {
42 AsmTransCBE = x86_asm_table;
43 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
44
Bill Wendling0ddb3862009-07-13 18:48:39 +000045 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16876eb2008-08-08 18:25:52 +000046 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikovf700e682008-07-09 13:20:48 +000047
48 AlignmentIsInBytes = false;
49 TextAlignFillValue = 0x90;
Daniel Dunbar1e13b972009-07-24 08:24:36 +000050
51
Anton Korobeynikovf700e682008-07-09 13:20:48 +000052 if (!is64Bit)
53 Data64bitsDirective = 0; // we can't emit a 64-bit unit
54 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
Anton Korobeynikovf700e682008-07-09 13:20:48 +000055 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Anton Korobeynikovf700e682008-07-09 13:20:48 +000056 LCOMMDirective = "\t.lcomm\t";
Bill Wendling0ddb3862009-07-13 18:48:39 +000057
Anton Korobeynikov16876eb2008-08-08 18:25:52 +000058 // Leopard and above support aligned common symbols.
59 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Anton Korobeynikovf700e682008-07-09 13:20:48 +000060 HasDotTypeDotSizeDirective = false;
Daniel Dunbar1e13b972009-07-24 08:24:36 +000061
Anton Korobeynikovf700e682008-07-09 13:20:48 +000062 if (is64Bit) {
63 PersonalityPrefix = "";
64 PersonalitySuffix = "+4@GOTPCREL";
65 } else {
66 PersonalityPrefix = "L";
67 PersonalitySuffix = "$non_lazy_ptr";
68 }
Bill Wendling0ddb3862009-07-13 18:48:39 +000069
Anton Korobeynikovf700e682008-07-09 13:20:48 +000070 InlineAsmStart = "## InlineAsm Start";
71 InlineAsmEnd = "## InlineAsm End";
72 CommentString = "##";
73 SetDirective = "\t.set";
74 PCSymbol = ".";
75 UsedDirective = "\t.no_dead_strip\t";
Anton Korobeynikovf700e682008-07-09 13:20:48 +000076 ProtectedDirective = "\t.globl\t";
77
Anton Korobeynikovf700e682008-07-09 13:20:48 +000078 SupportsDebugInformation = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000079 DwarfUsesInlineInfoSection = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000080
81 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +000082 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000083 GlobalEHDirective = "\t.globl\t";
84 SupportsWeakOmittedEHFrame = false;
85 AbsoluteEHSectionOffsets = false;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000086}
87
Chris Lattner4e765db2009-08-11 21:57:08 +000088X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) {
89 AsmTransCBE = x86_asm_table;
90 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
Anton Korobeynikovc33a1ff2008-07-09 13:28:49 +000091
Anton Korobeynikovf700e682008-07-09 13:20:48 +000092 PrivateGlobalPrefix = ".L";
93 WeakRefDirective = "\t.weak\t";
94 SetDirective = "\t.set\t";
95 PCSymbol = ".";
96
97 // Set up DWARF directives
98 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
99
100 // Debug Information
101 AbsoluteDebugSectionOffsets = true;
102 SupportsDebugInformation = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000103
104 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +0000105 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000106 AbsoluteEHSectionOffsets = false;
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000107
108 // On Linux we must declare when we can use a non-executable stack.
Dan Gohmana004d7b2008-11-03 18:22:42 +0000109 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000110 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
111}
112
Chris Lattner4e765db2009-08-11 21:57:08 +0000113X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM) {
114 AsmTransCBE = x86_asm_table;
115 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000116
Chris Lattner4e765db2009-08-11 21:57:08 +0000117}
118
119
120X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM) {
121 AsmTransCBE = x86_asm_table;
122 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
123
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000124 GlobalPrefix = "_";
125 CommentString = ";";
126
Eli Friedman378ea832009-06-19 04:48:38 +0000127 InlineAsmStart = "; InlineAsm Start";
128 InlineAsmEnd = "; InlineAsm End";
129
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000130 PrivateGlobalPrefix = "$";
Eli Friedman378ea832009-06-19 04:48:38 +0000131 AlignDirective = "\tALIGN\t";
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000132 ZeroDirective = "\tdb\t";
133 ZeroDirectiveSuffix = " dup(0)";
134 AsciiDirective = "\tdb\t";
135 AscizDirective = 0;
136 Data8bitsDirective = "\tdb\t";
137 Data16bitsDirective = "\tdw\t";
138 Data32bitsDirective = "\tdd\t";
139 Data64bitsDirective = "\tdq\t";
140 HasDotTypeDotSizeDirective = false;
Rafael Espindola5cf2e552008-12-03 11:01:37 +0000141 HasSingleParameterDotFile = false;
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000142
Eli Friedman378ea832009-06-19 04:48:38 +0000143 AlignmentIsInBytes = true;
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000144}