blob: 0c5e4b60201b173999bd274f54a1d0cdbfbb1bf5 [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"
16#include "X86Subtarget.h"
Chris Lattnerce914b82009-08-11 23:01:09 +000017#include "llvm/Support/CommandLine.h"
Reid Spencer7aa8a452007-01-12 23:22:14 +000018#include "llvm/DerivedTypes.h"
Chris Lattner625bd052006-11-29 01:14:06 +000019#include "llvm/InlineAsm.h"
20#include "llvm/Instructions.h"
Chris Lattner3e9f1d02007-04-01 20:49:36 +000021#include "llvm/Intrinsics.h"
Chris Lattner625bd052006-11-29 01:14:06 +000022#include "llvm/Module.h"
23#include "llvm/ADT/StringExtras.h"
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000024#include "llvm/Support/Dwarf.h"
Torok Edwinc25e7582009-07-11 20:10:48 +000025#include "llvm/Support/ErrorHandling.h"
Jim Laskey8e8de8f2006-09-07 22:05:02 +000026using namespace llvm;
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000027using namespace llvm::dwarf;
Jim Laskey8e8de8f2006-09-07 22:05:02 +000028
Chris Lattnerce914b82009-08-11 23:01:09 +000029
30enum AsmWriterFlavorTy {
31 // Note: This numbering has to match the GCC assembler dialects for inline
32 // asm alternatives to work right.
33 ATT = 0, Intel = 1
34};
35
36
37static cl::opt<AsmWriterFlavorTy>
38AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
39 cl::desc("Choose style of code to emit from X86 backend:"),
40 cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
41 clEnumValN(Intel, "intel", "Emit Intel-style assembly"),
42 clEnumValEnd));
43
44
Chris Lattnera1a1f022009-08-11 21:57:08 +000045static const char *const x86_asm_table[] = {
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000046 "{si}", "S",
47 "{di}", "D",
48 "{ax}", "a",
49 "{cx}", "c",
50 "{memory}", "memory",
51 "{flags}", "",
52 "{dirflag}", "",
53 "{fpsr}", "",
54 "{cc}", "cc",
55 0,0};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000056
Chris Lattnera1a1f022009-08-11 21:57:08 +000057X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM) {
58 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +000059 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +000060
Bill Wendlingb6be1392009-07-13 18:48:39 +000061 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000062 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000063
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000064 TextAlignFillValue = 0x90;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000065
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000066 if (!is64Bit)
67 Data64bitsDirective = 0; // we can't emit a 64-bit unit
Bill Wendlingb6be1392009-07-13 18:48:39 +000068
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000069 // Leopard and above support aligned common symbols.
70 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000071
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000072 if (is64Bit) {
73 PersonalityPrefix = "";
74 PersonalitySuffix = "+4@GOTPCREL";
75 } else {
76 PersonalityPrefix = "L";
77 PersonalitySuffix = "$non_lazy_ptr";
78 }
Bill Wendlingb6be1392009-07-13 18:48:39 +000079
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000080 CommentString = "##";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000081 PCSymbol = ".";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000082
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000083 SupportsDebugInformation = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000084 DwarfUsesInlineInfoSection = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000085
86 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000087 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000088 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000089}
90
Chris Lattnera1a1f022009-08-11 21:57:08 +000091X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) {
92 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +000093 AssemblerDialect = AsmWriterFlavor;
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000094
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000095 PrivateGlobalPrefix = ".L";
96 WeakRefDirective = "\t.weak\t";
97 SetDirective = "\t.set\t";
98 PCSymbol = ".";
99
100 // Set up DWARF directives
101 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
102
103 // Debug Information
104 AbsoluteDebugSectionOffsets = true;
105 SupportsDebugInformation = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000106
107 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000108 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000109 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000110
111 // On Linux we must declare when we can use a non-executable stack.
Dan Gohman8f092252008-11-03 18:22:42 +0000112 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000113 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
114}
115
Chris Lattnera1a1f022009-08-11 21:57:08 +0000116X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM) {
117 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000118 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000119}
120
121
122X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM) {
123 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000124 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000125
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000126 GlobalPrefix = "_";
127 CommentString = ";";
128
129 PrivateGlobalPrefix = "$";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000130 AlignDirective = "\tALIGN\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000131 ZeroDirective = "\tdb\t";
132 ZeroDirectiveSuffix = " dup(0)";
133 AsciiDirective = "\tdb\t";
134 AscizDirective = 0;
135 Data8bitsDirective = "\tdb\t";
136 Data16bitsDirective = "\tdw\t";
137 Data32bitsDirective = "\tdd\t";
138 Data64bitsDirective = "\tdq\t";
139 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000140 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000141
Eli Friedmanaace4b12009-06-19 04:48:38 +0000142 AlignmentIsInBytes = true;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000143}