blob: b6270108da236e98b9363c14d02a1a5099153f68 [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 Lattnera7ac47c2009-08-12 07:22:17 +000016#include "llvm/ADT/Triple.h"
Chris Lattnerce914b82009-08-11 23:01:09 +000017#include "llvm/Support/CommandLine.h"
Jim Laskey8e8de8f2006-09-07 22:05:02 +000018using namespace llvm;
Chris Lattnerce914b82009-08-11 23:01:09 +000019
20enum AsmWriterFlavorTy {
21 // Note: This numbering has to match the GCC assembler dialects for inline
22 // asm alternatives to work right.
23 ATT = 0, Intel = 1
24};
25
Chris Lattnerce914b82009-08-11 23:01:09 +000026static cl::opt<AsmWriterFlavorTy>
27AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
28 cl::desc("Choose style of code to emit from X86 backend:"),
29 cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
30 clEnumValN(Intel, "intel", "Emit Intel-style assembly"),
31 clEnumValEnd));
32
33
Chris Lattnera1a1f022009-08-11 21:57:08 +000034static const char *const x86_asm_table[] = {
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000035 "{si}", "S",
36 "{di}", "D",
37 "{ax}", "a",
38 "{cx}", "c",
39 "{memory}", "memory",
40 "{flags}", "",
41 "{dirflag}", "",
42 "{fpsr}", "",
43 "{cc}", "cc",
44 0,0};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000045
Chris Lattnerb2d31692009-08-13 05:30:22 +000046X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const Triple &Triple)
47 : DarwinTargetAsmInfo(Triple) {
Chris Lattnera1a1f022009-08-11 21:57:08 +000048 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +000049 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +000050
Chris Lattnera7ac47c2009-08-12 07:22:17 +000051 bool is64Bit = Triple.getArch() == Triple::x86_64;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000052
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000053 TextAlignFillValue = 0x90;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000054
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000055 if (!is64Bit)
56 Data64bitsDirective = 0; // we can't emit a 64-bit unit
Bill Wendlingb6be1392009-07-13 18:48:39 +000057
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000058 if (is64Bit) {
59 PersonalityPrefix = "";
60 PersonalitySuffix = "+4@GOTPCREL";
61 } else {
62 PersonalityPrefix = "L";
63 PersonalitySuffix = "$non_lazy_ptr";
64 }
Bill Wendlingb6be1392009-07-13 18:48:39 +000065
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000066 CommentString = "##";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000067 PCSymbol = ".";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000068
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000069 SupportsDebugInformation = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000070 DwarfUsesInlineInfoSection = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000071
72 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000073 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000074 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000075}
76
Chris Lattnera7ac47c2009-08-12 07:22:17 +000077X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const Triple &Triple) {
Chris Lattnera1a1f022009-08-11 21:57:08 +000078 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +000079 AssemblerDialect = AsmWriterFlavor;
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000080
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000081 PrivateGlobalPrefix = ".L";
82 WeakRefDirective = "\t.weak\t";
83 SetDirective = "\t.set\t";
84 PCSymbol = ".";
85
86 // Set up DWARF directives
87 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
88
89 // Debug Information
90 AbsoluteDebugSectionOffsets = true;
91 SupportsDebugInformation = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000092
93 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000094 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000095 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000096
97 // On Linux we must declare when we can use a non-executable stack.
Chris Lattnera7ac47c2009-08-12 07:22:17 +000098 if (Triple.getOS() == Triple::Linux)
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000099 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
100}
101
Chris Lattnera7ac47c2009-08-12 07:22:17 +0000102X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const Triple &Triple) {
Chris Lattnera1a1f022009-08-11 21:57:08 +0000103 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000104 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000105}
106
107
Chris Lattnera7ac47c2009-08-12 07:22:17 +0000108X86WinTargetAsmInfo::X86WinTargetAsmInfo(const Triple &Triple) {
Chris Lattnera1a1f022009-08-11 21:57:08 +0000109 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000110 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000111
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000112 GlobalPrefix = "_";
113 CommentString = ";";
114
115 PrivateGlobalPrefix = "$";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000116 AlignDirective = "\tALIGN\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000117 ZeroDirective = "\tdb\t";
118 ZeroDirectiveSuffix = " dup(0)";
119 AsciiDirective = "\tdb\t";
120 AscizDirective = 0;
121 Data8bitsDirective = "\tdb\t";
122 Data16bitsDirective = "\tdw\t";
123 Data32bitsDirective = "\tdd\t";
124 Data64bitsDirective = "\tdq\t";
125 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000126 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000127
Eli Friedmanaace4b12009-06-19 04:48:38 +0000128 AlignmentIsInBytes = true;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000129}