blob: 1738d495842169e41ceab252d694a140ef21bd37 [file] [log] [blame]
Chris Lattneraf76e592009-08-22 20:48:53 +00001//===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
Jim Laskey8e8de8f2006-09-07 22:05:02 +00002//
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//
Chris Lattneraf76e592009-08-22 20:48:53 +000010// This file contains the declarations of the X86MCAsmInfo properties.
Jim Laskey8e8de8f2006-09-07 22:05:02 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattneraf76e592009-08-22 20:48:53 +000014#include "X86MCAsmInfo.h"
Jim Laskey8e8de8f2006-09-07 22:05:02 +000015#include "X86TargetMachine.h"
Chris Lattnera7ac47c2009-08-12 07:22:17 +000016#include "llvm/ADT/Triple.h"
Chris Lattnerf9f93e42010-01-23 07:21:06 +000017#include "llvm/MC/MCSectionELF.h"
Chris Lattnerce914b82009-08-11 23:01:09 +000018#include "llvm/Support/CommandLine.h"
Jim Laskey8e8de8f2006-09-07 22:05:02 +000019using namespace llvm;
Chris Lattnerce914b82009-08-11 23:01:09 +000020
21enum AsmWriterFlavorTy {
22 // Note: This numbering has to match the GCC assembler dialects for inline
23 // asm alternatives to work right.
24 ATT = 0, Intel = 1
25};
26
Chris Lattnerce914b82009-08-11 23:01:09 +000027static cl::opt<AsmWriterFlavorTy>
28AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
29 cl::desc("Choose style of code to emit from X86 backend:"),
30 cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
31 clEnumValN(Intel, "intel", "Emit Intel-style assembly"),
32 clEnumValEnd));
33
34
Chris Lattnera1a1f022009-08-11 21:57:08 +000035static const char *const x86_asm_table[] = {
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000036 "{si}", "S",
37 "{di}", "D",
38 "{ax}", "a",
39 "{cx}", "c",
40 "{memory}", "memory",
41 "{flags}", "",
42 "{dirflag}", "",
43 "{fpsr}", "",
44 "{cc}", "cc",
45 0,0};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000046
Chris Lattner8eeba352010-01-20 06:34:14 +000047X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &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
Daniel Dunbarb42dad42009-08-13 17:03:38 +000058 // Leopard and above support aligned common symbols.
59 COMMDirectiveTakesAlignment = Triple.getDarwinMajorNumber() >= 9;
60
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000061 CommentString = "##";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000062 PCSymbol = ".";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000063
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000064 SupportsDebugInformation = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000065 DwarfUsesInlineInfoSection = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000066
67 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000068 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000069 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000070}
71
Chris Lattner8eeba352010-01-20 06:34:14 +000072X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) {
Chris Lattnera1a1f022009-08-11 21:57:08 +000073 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +000074 AssemblerDialect = AsmWriterFlavor;
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000075
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000076 PrivateGlobalPrefix = ".L";
77 WeakRefDirective = "\t.weak\t";
78 SetDirective = "\t.set\t";
79 PCSymbol = ".";
80
81 // Set up DWARF directives
82 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
83
84 // Debug Information
85 AbsoluteDebugSectionOffsets = true;
86 SupportsDebugInformation = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000087
88 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000089 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000090 AbsoluteEHSectionOffsets = false;
Chris Lattnerf9f93e42010-01-23 07:21:06 +000091}
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000092
Chris Lattnerf9f93e42010-01-23 07:21:06 +000093MCSection *X86ELFMCAsmInfo::getNonexecutableStackSection(MCContext &Ctx) const {
94 return MCSectionELF::Create(".note.GNU-stack", MCSectionELF::SHT_PROGBITS,
95 0, SectionKind::getMetadata(), false, Ctx);
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000096}
97
Chris Lattner8eeba352010-01-20 06:34:14 +000098X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) {
Chris Lattnera1a1f022009-08-11 21:57:08 +000099 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000100 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000101}
102
103
Chris Lattner8eeba352010-01-20 06:34:14 +0000104X86WinMCAsmInfo::X86WinMCAsmInfo(const Triple &Triple) {
Chris Lattnera1a1f022009-08-11 21:57:08 +0000105 AsmTransCBE = x86_asm_table;
Chris Lattnerce914b82009-08-11 23:01:09 +0000106 AssemblerDialect = AsmWriterFlavor;
Chris Lattnera1a1f022009-08-11 21:57:08 +0000107
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000108 GlobalPrefix = "_";
109 CommentString = ";";
110
111 PrivateGlobalPrefix = "$";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000112 AlignDirective = "\tALIGN\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000113 ZeroDirective = "\tdb\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000114 AsciiDirective = "\tdb\t";
115 AscizDirective = 0;
116 Data8bitsDirective = "\tdb\t";
117 Data16bitsDirective = "\tdw\t";
118 Data32bitsDirective = "\tdd\t";
119 Data64bitsDirective = "\tdq\t";
120 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000121 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000122
Eli Friedmanaace4b12009-06-19 04:48:38 +0000123 AlignmentIsInBytes = true;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000124}