blob: 001ce8072863010aff155e1363a7b58193f287f0 [file] [log] [blame]
Chris Lattner621c44d2009-08-22 20:48:53 +00001//===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
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//
Chris Lattner621c44d2009-08-22 20:48:53 +000010// This file contains the declarations of the X86MCAsmInfo properties.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattner621c44d2009-08-22 20:48:53 +000014#include "X86MCAsmInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015#include "X86TargetMachine.h"
Chris Lattnerd88f9fd2009-08-12 07:22:17 +000016#include "llvm/ADT/Triple.h"
Chris Lattner2c048f22009-08-11 23:01:09 +000017#include "llvm/Support/CommandLine.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018using namespace llvm;
Chris Lattner2c048f22009-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 Lattner2c048f22009-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 Lattner4e765db2009-08-11 21:57:08 +000034static const char *const x86_asm_table[] = {
Anton Korobeynikov3829e8a2008-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};
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045
Chris Lattner50f82ef2010-01-20 06:34:14 +000046X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
Chris Lattner4e765db2009-08-11 21:57:08 +000047 AsmTransCBE = x86_asm_table;
Chris Lattner2c048f22009-08-11 23:01:09 +000048 AssemblerDialect = AsmWriterFlavor;
Chris Lattner4e765db2009-08-11 21:57:08 +000049
Chris Lattnerd88f9fd2009-08-12 07:22:17 +000050 bool is64Bit = Triple.getArch() == Triple::x86_64;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000051
Anton Korobeynikovf700e682008-07-09 13:20:48 +000052 TextAlignFillValue = 0x90;
Daniel Dunbar1e13b972009-07-24 08:24:36 +000053
Anton Korobeynikovf700e682008-07-09 13:20:48 +000054 if (!is64Bit)
55 Data64bitsDirective = 0; // we can't emit a 64-bit unit
Bill Wendling0ddb3862009-07-13 18:48:39 +000056
Daniel Dunbaree3b6c62009-08-13 17:03:38 +000057 // Leopard and above support aligned common symbols.
58 COMMDirectiveTakesAlignment = Triple.getDarwinMajorNumber() >= 9;
59
Anton Korobeynikovf700e682008-07-09 13:20:48 +000060 CommentString = "##";
Anton Korobeynikovf700e682008-07-09 13:20:48 +000061 PCSymbol = ".";
Anton Korobeynikovf700e682008-07-09 13:20:48 +000062
Anton Korobeynikovf700e682008-07-09 13:20:48 +000063 SupportsDebugInformation = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000064 DwarfUsesInlineInfoSection = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000065
66 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +000067 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000068 AbsoluteEHSectionOffsets = false;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000069}
70
Chris Lattner50f82ef2010-01-20 06:34:14 +000071X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) {
Chris Lattner4e765db2009-08-11 21:57:08 +000072 AsmTransCBE = x86_asm_table;
Chris Lattner2c048f22009-08-11 23:01:09 +000073 AssemblerDialect = AsmWriterFlavor;
Anton Korobeynikovc33a1ff2008-07-09 13:28:49 +000074
Anton Korobeynikovf700e682008-07-09 13:20:48 +000075 PrivateGlobalPrefix = ".L";
76 WeakRefDirective = "\t.weak\t";
77 SetDirective = "\t.set\t";
78 PCSymbol = ".";
79
80 // Set up DWARF directives
81 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
82
83 // Debug Information
84 AbsoluteDebugSectionOffsets = true;
85 SupportsDebugInformation = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000086
87 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +000088 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000089 AbsoluteEHSectionOffsets = false;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000090
91 // On Linux we must declare when we can use a non-executable stack.
Chris Lattnerd88f9fd2009-08-12 07:22:17 +000092 if (Triple.getOS() == Triple::Linux)
Anton Korobeynikovf700e682008-07-09 13:20:48 +000093 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
94}
95
Chris Lattner50f82ef2010-01-20 06:34:14 +000096X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) {
Chris Lattner4e765db2009-08-11 21:57:08 +000097 AsmTransCBE = x86_asm_table;
Chris Lattner2c048f22009-08-11 23:01:09 +000098 AssemblerDialect = AsmWriterFlavor;
Chris Lattner4e765db2009-08-11 21:57:08 +000099}
100
101
Chris Lattner50f82ef2010-01-20 06:34:14 +0000102X86WinMCAsmInfo::X86WinMCAsmInfo(const Triple &Triple) {
Chris Lattner4e765db2009-08-11 21:57:08 +0000103 AsmTransCBE = x86_asm_table;
Chris Lattner2c048f22009-08-11 23:01:09 +0000104 AssemblerDialect = AsmWriterFlavor;
Chris Lattner4e765db2009-08-11 21:57:08 +0000105
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000106 GlobalPrefix = "_";
107 CommentString = ";";
108
109 PrivateGlobalPrefix = "$";
Eli Friedman378ea832009-06-19 04:48:38 +0000110 AlignDirective = "\tALIGN\t";
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000111 ZeroDirective = "\tdb\t";
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000112 AsciiDirective = "\tdb\t";
113 AscizDirective = 0;
114 Data8bitsDirective = "\tdb\t";
115 Data16bitsDirective = "\tdw\t";
116 Data32bitsDirective = "\tdd\t";
117 Data64bitsDirective = "\tdq\t";
118 HasDotTypeDotSizeDirective = false;
Rafael Espindola5cf2e552008-12-03 11:01:37 +0000119 HasSingleParameterDotFile = false;
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000120
Eli Friedman378ea832009-06-19 04:48:38 +0000121 AlignmentIsInBytes = true;
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000122}