blob: 91c0fbb356700e1bbc472dfd6436dbe0bb62cf26 [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 Lattner2dc6ddd2010-01-23 07:21:06 +000017#include "llvm/MC/MCSectionELF.h"
Chris Lattner2c048f22009-08-11 23:01:09 +000018#include "llvm/Support/CommandLine.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019using namespace llvm;
Chris Lattner2c048f22009-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 Lattner2c048f22009-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 Lattner4e765db2009-08-11 21:57:08 +000035static const char *const x86_asm_table[] = {
Anton Korobeynikov3829e8a2008-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};
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046
Chris Lattner50f82ef2010-01-20 06:34:14 +000047X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
Chris Lattner4e765db2009-08-11 21:57:08 +000048 AsmTransCBE = x86_asm_table;
Chris Lattner2c048f22009-08-11 23:01:09 +000049 AssemblerDialect = AsmWriterFlavor;
Chris Lattner4e765db2009-08-11 21:57:08 +000050
Chris Lattnerd88f9fd2009-08-12 07:22:17 +000051 bool is64Bit = Triple.getArch() == Triple::x86_64;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000052
Anton Korobeynikovf700e682008-07-09 13:20:48 +000053 TextAlignFillValue = 0x90;
Daniel Dunbar1e13b972009-07-24 08:24:36 +000054
Anton Korobeynikovf700e682008-07-09 13:20:48 +000055 if (!is64Bit)
56 Data64bitsDirective = 0; // we can't emit a 64-bit unit
Bill Wendling0ddb3862009-07-13 18:48:39 +000057
Anton Korobeynikovf700e682008-07-09 13:20:48 +000058 CommentString = "##";
Anton Korobeynikovf700e682008-07-09 13:20:48 +000059 PCSymbol = ".";
Anton Korobeynikovf700e682008-07-09 13:20:48 +000060
Anton Korobeynikovf700e682008-07-09 13:20:48 +000061 SupportsDebugInformation = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000062 DwarfUsesInlineInfoSection = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000063
64 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +000065 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000066 AbsoluteEHSectionOffsets = false;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000067}
68
Chris Lattner50f82ef2010-01-20 06:34:14 +000069X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) {
Chris Lattner4e765db2009-08-11 21:57:08 +000070 AsmTransCBE = x86_asm_table;
Chris Lattner2c048f22009-08-11 23:01:09 +000071 AssemblerDialect = AsmWriterFlavor;
Anton Korobeynikovc33a1ff2008-07-09 13:28:49 +000072
Anton Korobeynikovf700e682008-07-09 13:20:48 +000073 PrivateGlobalPrefix = ".L";
74 WeakRefDirective = "\t.weak\t";
Anton Korobeynikovf700e682008-07-09 13:20:48 +000075 PCSymbol = ".";
76
77 // Set up DWARF directives
78 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
79
80 // Debug Information
81 AbsoluteDebugSectionOffsets = true;
82 SupportsDebugInformation = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000083
84 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +000085 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000086 AbsoluteEHSectionOffsets = false;
Chris Lattner2dc6ddd2010-01-23 07:21:06 +000087}
Anton Korobeynikovf700e682008-07-09 13:20:48 +000088
Chris Lattner2dc6ddd2010-01-23 07:21:06 +000089MCSection *X86ELFMCAsmInfo::getNonexecutableStackSection(MCContext &Ctx) const {
90 return MCSectionELF::Create(".note.GNU-stack", MCSectionELF::SHT_PROGBITS,
91 0, SectionKind::getMetadata(), false, Ctx);
Anton Korobeynikovf700e682008-07-09 13:20:48 +000092}
93
Chris Lattner50f82ef2010-01-20 06:34:14 +000094X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) {
Chris Lattner4e765db2009-08-11 21:57:08 +000095 AsmTransCBE = x86_asm_table;
Chris Lattner2c048f22009-08-11 23:01:09 +000096 AssemblerDialect = AsmWriterFlavor;
Anton Korobeynikov6afbe282010-02-14 15:19:54 +000097}