blob: 1d9a4c2aaa62d37cdea3bba1f73e3b7cce1d7d6d [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
Chris Lattnera1a1f022009-08-11 21:57:08 +000029static const char *const x86_asm_table[] = {
Anton Korobeynikov32b952a2008-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};
Andrew Lenharth6c0695f2006-11-28 19:52:49 +000040
Chris Lattnera1a1f022009-08-11 21:57:08 +000041X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM) {
42 AsmTransCBE = x86_asm_table;
43 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
44
Bill Wendlingb6be1392009-07-13 18:48:39 +000045 const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000046 bool is64Bit = Subtarget->is64Bit();
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000047
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000048 TextAlignFillValue = 0x90;
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000049
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000050 if (!is64Bit)
51 Data64bitsDirective = 0; // we can't emit a 64-bit unit
Bill Wendlingb6be1392009-07-13 18:48:39 +000052
Anton Korobeynikov16b7f512008-08-08 18:25:52 +000053 // Leopard and above support aligned common symbols.
54 COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
Daniel Dunbarf6ccee52009-07-24 08:24:36 +000055
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000056 if (is64Bit) {
57 PersonalityPrefix = "";
58 PersonalitySuffix = "+4@GOTPCREL";
59 } else {
60 PersonalityPrefix = "L";
61 PersonalitySuffix = "$non_lazy_ptr";
62 }
Bill Wendlingb6be1392009-07-13 18:48:39 +000063
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000064 CommentString = "##";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000065 PCSymbol = ".";
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000066
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000067 SupportsDebugInformation = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000068 DwarfUsesInlineInfoSection = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000069
70 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000071 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000072 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000073}
74
Chris Lattnera1a1f022009-08-11 21:57:08 +000075X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) {
76 AsmTransCBE = x86_asm_table;
77 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
Anton Korobeynikov0d44ba82008-07-09 13:28:49 +000078
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000079 PrivateGlobalPrefix = ".L";
80 WeakRefDirective = "\t.weak\t";
81 SetDirective = "\t.set\t";
82 PCSymbol = ".";
83
84 // Set up DWARF directives
85 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
86
87 // Debug Information
88 AbsoluteDebugSectionOffsets = true;
89 SupportsDebugInformation = true;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000090
91 // Exceptions handling
Jim Grosbach1b747ad2009-08-11 00:09:57 +000092 ExceptionsType = ExceptionHandling::Dwarf;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000093 AbsoluteEHSectionOffsets = false;
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000094
95 // On Linux we must declare when we can use a non-executable stack.
Dan Gohman8f092252008-11-03 18:22:42 +000096 if (TM.getSubtarget<X86Subtarget>().isLinux())
Anton Korobeynikov4468b7a2008-07-09 13:20:48 +000097 NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits";
98}
99
Chris Lattnera1a1f022009-08-11 21:57:08 +0000100X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM) {
101 AsmTransCBE = x86_asm_table;
102 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000103
Chris Lattnera1a1f022009-08-11 21:57:08 +0000104}
105
106
107X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM) {
108 AsmTransCBE = x86_asm_table;
109 AssemblerDialect = TM.getSubtarget<X86Subtarget>().getAsmFlavor();
110
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000111 GlobalPrefix = "_";
112 CommentString = ";";
113
114 PrivateGlobalPrefix = "$";
Eli Friedmanaace4b12009-06-19 04:48:38 +0000115 AlignDirective = "\tALIGN\t";
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000116 ZeroDirective = "\tdb\t";
117 ZeroDirectiveSuffix = " dup(0)";
118 AsciiDirective = "\tdb\t";
119 AscizDirective = 0;
120 Data8bitsDirective = "\tdb\t";
121 Data16bitsDirective = "\tdw\t";
122 Data32bitsDirective = "\tdd\t";
123 Data64bitsDirective = "\tdq\t";
124 HasDotTypeDotSizeDirective = false;
Rafael Espindola952b8392008-12-03 11:01:37 +0000125 HasSingleParameterDotFile = false;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000126
Eli Friedmanaace4b12009-06-19 04:48:38 +0000127 AlignmentIsInBytes = true;
Anton Korobeynikovf447e3d2008-07-09 13:21:49 +0000128}