blob: b702cbfc44b252409087967c4b2e3773d43ed62e [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"
Reid Spencer7aa8a452007-01-12 23:22:14 +000017#include "llvm/DerivedTypes.h"
Chris Lattner625bd052006-11-29 01:14:06 +000018#include "llvm/InlineAsm.h"
19#include "llvm/Instructions.h"
Chris Lattner3e9f1d02007-04-01 20:49:36 +000020#include "llvm/Intrinsics.h"
Chris Lattner625bd052006-11-29 01:14:06 +000021#include "llvm/Module.h"
22#include "llvm/ADT/StringExtras.h"
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000023#include "llvm/Support/Dwarf.h"
Torok Edwinc25e7582009-07-11 20:10:48 +000024#include "llvm/Support/ErrorHandling.h"
Anton Korobeynikovcee750f2008-02-27 23:33:50 +000025
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
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000029const char *const llvm::x86_asm_table[] = {
30 "{si}", "S",
31 "{di}", "D",
32 "{ax}", "a",
33 "{cx}", "c",
34 "{memory}", "memory",
35 "{flags}", "",
36 "{dirflag}", "",
37 "{fpsr}", "",
38 "{cc}", "cc",
39 0,0};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000040
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000041X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000042 X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Bill Wendlingb6be1392009-07-13 18:48:39 +000043 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000044 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000045
46 AlignmentIsInBytes = false;
47 TextAlignFillValue = 0x90;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000048
49
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000050 if (!is64Bit)
51 Data64bitsDirective = 0; // we can't emit a 64-bit unit
52 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000053 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000054 LCOMMDirective = "\t.lcomm\t";
Bill Wendlingb6be1392009-07-13 18:48:39 +000055
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000056 // Leopard and above support aligned common symbols.
57 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000058 HasDotTypeDotSizeDirective = false;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000059
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000060 if (is64Bit) {
61 PersonalityPrefix = "";
62 PersonalitySuffix = "+4@GOTPCREL";
63 } else {
64 PersonalityPrefix = "L";
65 PersonalitySuffix = "$non_lazy_ptr";
66 }
Bill Wendlingb6be1392009-07-13 18:48:39 +000067
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000068 InlineAsmStart = "## InlineAsm Start";
69 InlineAsmEnd = "## InlineAsm End";
70 CommentString = "##";
71 SetDirective = "\t.set";
72 PCSymbol = ".";
73 UsedDirective = "\t.no_dead_strip\t";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000074 ProtectedDirective = "\t.globl\t";
75
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000076 SupportsDebugInformation = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000077 DwarfUsesInlineInfoSection = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000078
79 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000080 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000081 GlobalEHDirective = "\t.globl\t";
82 SupportsWeakOmittedEHFrame = false;
83 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000084}
85
Chris Lattnere3466942009-07-27 06:17:14 +000086X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) :
Chris Lattner8d4a0a32009-08-02 04:27:24 +000087 X86TargetAsmInfo<TargetAsmInfo>(TM) {
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000088
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000089 PrivateGlobalPrefix = ".L";
90 WeakRefDirective = "\t.weak\t";
91 SetDirective = "\t.set\t";
92 PCSymbol = ".";
93
94 // Set up DWARF directives
95 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
96
97 // Debug Information
98 AbsoluteDebugSectionOffsets = true;
99 SupportsDebugInformation = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000100
101 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000102 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000103 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000104
105 // On Linux we must declare when we can use a non-executable stack.
Dan Gohman8f092252008-11-03 18:22:42 +0000106 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +0000107 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
108}
109
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000110
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000111X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
Chris Lattner40412e72009-07-27 16:45:59 +0000112 X86TargetAsmInfo<TargetAsmInfo>(TM) {
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000113 GlobalPrefix = "_";
114 CommentString = ";";
115
Eli Friedmanaace4b12009-06-19 04:48:38 +0000116 InlineAsmStart = "; InlineAsm Start";
117 InlineAsmEnd = "; InlineAsm End";
118
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000119 PrivateGlobalPrefix = "$";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000120 AlignDirective = "\tALIGN\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000121 ZeroDirective = "\tdb\t";
122 ZeroDirectiveSuffix = " dup(0)";
123 AsciiDirective = "\tdb\t";
124 AscizDirective = 0;
125 Data8bitsDirective = "\tdb\t";
126 Data16bitsDirective = "\tdw\t";
127 Data32bitsDirective = "\tdd\t";
128 Data64bitsDirective = "\tdq\t";
129 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000130 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000131
Eli Friedmanaace4b12009-06-19 04:48:38 +0000132 AlignmentIsInBytes = true;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000133}
Anton Korobeynikov6381a132008-10-05 08:53:29 +0000134
Anton Korobeynikov6381a132008-10-05 08:53:29 +0000135// Instantiate default implementation.
136TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>);