blob: c44703835c8996882feb8d61fea6a744d4015201 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===//
2//
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//
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"
17#include "llvm/DerivedTypes.h"
18#include "llvm/InlineAsm.h"
19#include "llvm/Instructions.h"
20#include "llvm/Intrinsics.h"
21#include "llvm/Module.h"
22#include "llvm/ADT/StringExtras.h"
Anton Korobeynikov65c0d872008-02-27 23:33:50 +000023#include "llvm/Support/Dwarf.h"
Edwin Török675d5622009-07-11 20:10:48 +000024#include "llvm/Support/ErrorHandling.h"
Anton Korobeynikov65c0d872008-02-27 23:33:50 +000025
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026using namespace llvm;
Anton Korobeynikov65c0d872008-02-27 23:33:50 +000027using namespace llvm::dwarf;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028
Chris Lattner4e765db2009-08-11 21:57:08 +000029static const char *const x86_asm_table[] = {
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000030 "{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};
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Chris Lattner4e765db2009-08-11 21:57:08 +000041X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM) {
42 AsmTransCBE = x86_asm_table;
43 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
44
Bill Wendling0ddb3862009-07-13 18:48:39 +000045 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16876eb2008-08-08 18:25:52 +000046 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikovf700e682008-07-09 13:20:48 +000047
48 AlignmentIsInBytes = false;
49 TextAlignFillValue = 0x90;
Daniel Dunbar1e13b972009-07-24 08:24:36 +000050
Anton Korobeynikovf700e682008-07-09 13:20:48 +000051 if (!is64Bit)
52 Data64bitsDirective = 0; // we can't emit a 64-bit unit
53 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
Anton Korobeynikovf700e682008-07-09 13:20:48 +000054 ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill
Bill Wendling0ddb3862009-07-13 18:48:39 +000055
Anton Korobeynikov16876eb2008-08-08 18:25:52 +000056 // Leopard and above support aligned common symbols.
57 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Anton Korobeynikovf700e682008-07-09 13:20:48 +000058 HasDotTypeDotSizeDirective = false;
Daniel Dunbar1e13b972009-07-24 08:24:36 +000059
Anton Korobeynikovf700e682008-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 Wendling0ddb3862009-07-13 18:48:39 +000067
Anton Korobeynikovf700e682008-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 Korobeynikovf700e682008-07-09 13:20:48 +000074 ProtectedDirective = "\t.globl\t";
75
Anton Korobeynikovf700e682008-07-09 13:20:48 +000076 SupportsDebugInformation = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000077 DwarfUsesInlineInfoSection = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000078
79 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +000080 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000081 GlobalEHDirective = "\t.globl\t";
82 SupportsWeakOmittedEHFrame = false;
83 AbsoluteEHSectionOffsets = false;
Anton Korobeynikovf700e682008-07-09 13:20:48 +000084}
85
Chris Lattner4e765db2009-08-11 21:57:08 +000086X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) {
87 AsmTransCBE = x86_asm_table;
88 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
Anton Korobeynikovc33a1ff2008-07-09 13:28:49 +000089
Anton Korobeynikovf700e682008-07-09 13:20:48 +000090 PrivateGlobalPrefix = ".L";
91 WeakRefDirective = "\t.weak\t";
92 SetDirective = "\t.set\t";
93 PCSymbol = ".";
94
95 // Set up DWARF directives
96 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
97
98 // Debug Information
99 AbsoluteDebugSectionOffsets = true;
100 SupportsDebugInformation = true;
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000101
102 // Exceptions handling
Jim Grosbach29feb6a2009-08-11 00:09:57 +0000103 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000104 AbsoluteEHSectionOffsets = false;
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000105
106 // On Linux we must declare when we can use a non-executable stack.
Dan Gohmana004d7b2008-11-03 18:22:42 +0000107 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikovf700e682008-07-09 13:20:48 +0000108 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
109}
110
Chris Lattner4e765db2009-08-11 21:57:08 +0000111X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM) {
112 AsmTransCBE = x86_asm_table;
113 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000114
Chris Lattner4e765db2009-08-11 21:57:08 +0000115}
116
117
118X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM) {
119 AsmTransCBE = x86_asm_table;
120 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
121
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000122 GlobalPrefix = "_";
123 CommentString = ";";
124
Eli Friedman378ea832009-06-19 04:48:38 +0000125 InlineAsmStart = "; InlineAsm Start";
126 InlineAsmEnd = "; InlineAsm End";
127
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000128 PrivateGlobalPrefix = "$";
Eli Friedman378ea832009-06-19 04:48:38 +0000129 AlignDirective = "\tALIGN\t";
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000130 ZeroDirective = "\tdb\t";
131 ZeroDirectiveSuffix = " dup(0)";
132 AsciiDirective = "\tdb\t";
133 AscizDirective = 0;
134 Data8bitsDirective = "\tdb\t";
135 Data16bitsDirective = "\tdw\t";
136 Data32bitsDirective = "\tdd\t";
137 Data64bitsDirective = "\tdq\t";
138 HasDotTypeDotSizeDirective = false;
Rafael Espindola5cf2e552008-12-03 11:01:37 +0000139 HasSingleParameterDotFile = false;
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000140
Eli Friedman378ea832009-06-19 04:48:38 +0000141 AlignmentIsInBytes = true;
Anton Korobeynikov49881c52008-07-09 13:21:49 +0000142}