blob: 859ced7728fe4b4cbbbc721cb84a40aff16d56f3 [file] [log] [blame]
Jim Laskey8e8de8f2006-09-07 22:05:02 +00001//===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey8e8de8f2006-09-07 22:05:02 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the declarations of the X86TargetAsmInfo properties.
11//
12//===----------------------------------------------------------------------===//
13
14#include "X86TargetAsmInfo.h"
15#include "X86TargetMachine.h"
Chris Lattnerce914b82009-08-11 23:01:09 +000016#include "llvm/Support/CommandLine.h"
Jim Laskey8e8de8f2006-09-07 22:05:02 +000017using namespace llvm;
Chris Lattnerce914b82009-08-11 23:01:09 +000018
19enum AsmWriterFlavorTy {
20 // Note: This numbering has to match the GCC assembler dialects for inline
21 // asm alternatives to work right.
22 ATT = 0, Intel = 1
23};
24
Chris Lattnerce914b82009-08-11 23:01:09 +000025static cl::opt<AsmWriterFlavorTy>
26AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
27 cl::desc("Choose style of code to emit from X86 backend:"),
28 cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
29 clEnumValN(Intel, "intel", "Emit Intel-style assembly"),
30 clEnumValEnd));
31
32
Chris Lattnera1a1f022009-08-11 21:57:08 +000033static const char *const x86_asm_table[] = {
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000034 "{si}", "S",
35 "{di}", "D",
36 "{ax}", "a",
37 "{cx}", "c",
38 "{memory}", "memory",
39 "{flags}", "",
40 "{dirflag}", "",
41 "{fpsr}", "",
42 "{cc}", "cc",
43 0,0};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000044
Chris Lattnera1a1f022009-08-11 21:57:08 +000045X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM) {
46 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +000047 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +000048
Bill Wendlingb6be1392009-07-13 18:48:39 +000049 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000050 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000051
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000052 TextAlignFillValue = 0x90;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000053
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000054 if (!is64Bit)
55 Data64bitsDirective = 0; // we can't emit a 64-bit unit
Bill Wendlingb6be1392009-07-13 18:48:39 +000056
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000057 // Leopard and above support aligned common symbols.
58 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000059
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000060 if (is64Bit) {
61 PersonalityPrefix = "";
62 PersonalitySuffix = "+4@GOTPCREL";
63 } else {
64 PersonalityPrefix = "L";
65 PersonalitySuffix = "$non_lazy_ptr";
66 }
Bill Wendlingb6be1392009-07-13 18:48:39 +000067
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000068 CommentString = "##";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000069 PCSymbol = ".";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000070
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000071 SupportsDebugInformation = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000072 DwarfUsesInlineInfoSection = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000073
74 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000075 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000076 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000077}
78
Chris Lattnera1a1f022009-08-11 21:57:08 +000079X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) {
80 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +000081 AssemblerDialect = AsmWriterFlavor;
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000082
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000083 PrivateGlobalPrefix = ".L";
84 WeakRefDirective = "\t.weak\t";
85 SetDirective = "\t.set\t";
86 PCSymbol = ".";
87
88 // Set up DWARF directives
89 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
90
91 // Debug Information
92 AbsoluteDebugSectionOffsets = true;
93 SupportsDebugInformation = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000094
95 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000096 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000097 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000098
99 // On Linux we must declare when we can use a non-executable stack.
Dan Gohman8f092252008-11-03 18:22:42 +0000100 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000101 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
102}
103
Chris Lattnera1a1f022009-08-11 21:57:08 +0000104X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM) {
105 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000106 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000107}
108
109
110X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM) {
111 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000112 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000113
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000114 GlobalPrefix = "_";
115 CommentString = ";";
116
117 PrivateGlobalPrefix = "$";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000118 AlignDirective = "\tALIGN\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000119 ZeroDirective = "\tdb\t";
120 ZeroDirectiveSuffix = " dup(0)";
121 AsciiDirective = "\tdb\t";
122 AscizDirective = 0;
123 Data8bitsDirective = "\tdb\t";
124 Data16bitsDirective = "\tdw\t";
125 Data32bitsDirective = "\tdd\t";
126 Data64bitsDirective = "\tdq\t";
127 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000128 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000129
Eli Friedmanaace4b12009-06-19 04:48:38 +0000130 AlignmentIsInBytes = true;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000131}