Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 1 | //===-- X86TargetAsmInfo.cpp - X86 asm properties ---------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 7 | // |
| 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 Spencer | 7aa8a45 | 2007-01-12 23:22:14 +0000 | [diff] [blame] | 17 | #include "llvm/DerivedTypes.h" |
Chris Lattner | 625bd05 | 2006-11-29 01:14:06 +0000 | [diff] [blame] | 18 | #include "llvm/InlineAsm.h" |
| 19 | #include "llvm/Instructions.h" |
Chris Lattner | 3e9f1d0 | 2007-04-01 20:49:36 +0000 | [diff] [blame] | 20 | #include "llvm/Intrinsics.h" |
Chris Lattner | 625bd05 | 2006-11-29 01:14:06 +0000 | [diff] [blame] | 21 | #include "llvm/Module.h" |
| 22 | #include "llvm/ADT/StringExtras.h" |
Anton Korobeynikov | cee750f | 2008-02-27 23:33:50 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Dwarf.h" |
Torok Edwin | c25e758 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ErrorHandling.h" |
Anton Korobeynikov | cee750f | 2008-02-27 23:33:50 +0000 | [diff] [blame] | 25 | |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 26 | using namespace llvm; |
Anton Korobeynikov | cee750f | 2008-02-27 23:33:50 +0000 | [diff] [blame] | 27 | using namespace llvm::dwarf; |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 28 | |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 29 | const 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 Lenharth | 6c0695f | 2006-11-28 19:52:49 +0000 | [diff] [blame] | 40 | |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 41 | X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM): |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 42 | X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) { |
Bill Wendling | b6be139 | 2009-07-13 18:48:39 +0000 | [diff] [blame] | 43 | const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>(); |
Anton Korobeynikov | 16b7f51 | 2008-08-08 18:25:52 +0000 | [diff] [blame] | 44 | bool is64Bit = Subtarget->is64Bit(); |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 45 | |
| 46 | AlignmentIsInBytes = false; |
| 47 | TextAlignFillValue = 0x90; |
Daniel Dunbar | f6ccee5 | 2009-07-24 08:24:36 +0000 | [diff] [blame] | 48 | |
| 49 | |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 50 | if (!is64Bit) |
| 51 | Data64bitsDirective = 0; // we can't emit a 64-bit unit |
| 52 | ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 53 | ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 54 | LCOMMDirective = "\t.lcomm\t"; |
Bill Wendling | b6be139 | 2009-07-13 18:48:39 +0000 | [diff] [blame] | 55 | |
Anton Korobeynikov | 16b7f51 | 2008-08-08 18:25:52 +0000 | [diff] [blame] | 56 | // Leopard and above support aligned common symbols. |
| 57 | COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9); |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 58 | HasDotTypeDotSizeDirective = false; |
Daniel Dunbar | f6ccee5 | 2009-07-24 08:24:36 +0000 | [diff] [blame] | 59 | |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 60 | if (is64Bit) { |
| 61 | PersonalityPrefix = ""; |
| 62 | PersonalitySuffix = "+4@GOTPCREL"; |
| 63 | } else { |
| 64 | PersonalityPrefix = "L"; |
| 65 | PersonalitySuffix = "$non_lazy_ptr"; |
| 66 | } |
Bill Wendling | b6be139 | 2009-07-13 18:48:39 +0000 | [diff] [blame] | 67 | |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 68 | InlineAsmStart = "## InlineAsm Start"; |
| 69 | InlineAsmEnd = "## InlineAsm End"; |
| 70 | CommentString = "##"; |
| 71 | SetDirective = "\t.set"; |
| 72 | PCSymbol = "."; |
| 73 | UsedDirective = "\t.no_dead_strip\t"; |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 74 | ProtectedDirective = "\t.globl\t"; |
| 75 | |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 76 | SupportsDebugInformation = true; |
Devang Patel | 0f7fef3 | 2009-04-13 17:02:03 +0000 | [diff] [blame] | 77 | DwarfDebugInlineSection = ".section __DWARF,__debug_inlined,regular,debug"; |
| 78 | DwarfUsesInlineInfoSection = true; |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 79 | |
| 80 | // Exceptions handling |
| 81 | SupportsExceptionHandling = true; |
| 82 | GlobalEHDirective = "\t.globl\t"; |
| 83 | SupportsWeakOmittedEHFrame = false; |
| 84 | AbsoluteEHSectionOffsets = false; |
| 85 | DwarfEHFrameSection = |
| 86 | ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support"; |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 87 | } |
| 88 | |
Chris Lattner | e346694 | 2009-07-27 06:17:14 +0000 | [diff] [blame] | 89 | X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) : |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 90 | X86TargetAsmInfo<ELFTargetAsmInfo>(TM) { |
Anton Korobeynikov | 0d44ba8 | 2008-07-09 13:28:49 +0000 | [diff] [blame] | 91 | |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 92 | PrivateGlobalPrefix = ".L"; |
| 93 | WeakRefDirective = "\t.weak\t"; |
| 94 | SetDirective = "\t.set\t"; |
| 95 | PCSymbol = "."; |
| 96 | |
| 97 | // Set up DWARF directives |
| 98 | HasLEB128 = true; // Target asm supports leb128 directives (little-endian) |
| 99 | |
| 100 | // Debug Information |
| 101 | AbsoluteDebugSectionOffsets = true; |
| 102 | SupportsDebugInformation = true; |
| 103 | DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits"; |
| 104 | DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits"; |
| 105 | DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits"; |
| 106 | DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits"; |
| 107 | DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits"; |
| 108 | DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits"; |
| 109 | DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits"; |
| 110 | DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits"; |
| 111 | DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits"; |
| 112 | DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits"; |
Chris Lattner | b839c3f | 2009-06-18 23:31:37 +0000 | [diff] [blame] | 113 | DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits"; |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 114 | |
| 115 | // Exceptions handling |
Anton Korobeynikov | c4da15a | 2008-09-08 21:13:08 +0000 | [diff] [blame] | 116 | SupportsExceptionHandling = true; |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 117 | AbsoluteEHSectionOffsets = false; |
| 118 | DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits"; |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 119 | |
| 120 | // On Linux we must declare when we can use a non-executable stack. |
Dan Gohman | 8f09225 | 2008-11-03 18:22:42 +0000 | [diff] [blame] | 121 | if (TM.getSubtarget<X86Subtarget>().isLinux()) |
Anton Korobeynikov | 4468b7a | 2008-07-09 13:20:48 +0000 | [diff] [blame] | 122 | NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits"; |
| 123 | } |
| 124 | |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 125 | |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 126 | X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM): |
Chris Lattner | 40412e7 | 2009-07-27 16:45:59 +0000 | [diff] [blame] | 127 | X86TargetAsmInfo<TargetAsmInfo>(TM) { |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 128 | GlobalPrefix = "_"; |
| 129 | CommentString = ";"; |
| 130 | |
Eli Friedman | aace4b1 | 2009-06-19 04:48:38 +0000 | [diff] [blame] | 131 | InlineAsmStart = "; InlineAsm Start"; |
| 132 | InlineAsmEnd = "; InlineAsm End"; |
| 133 | |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 134 | PrivateGlobalPrefix = "$"; |
Eli Friedman | aace4b1 | 2009-06-19 04:48:38 +0000 | [diff] [blame] | 135 | AlignDirective = "\tALIGN\t"; |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 136 | ZeroDirective = "\tdb\t"; |
| 137 | ZeroDirectiveSuffix = " dup(0)"; |
| 138 | AsciiDirective = "\tdb\t"; |
| 139 | AscizDirective = 0; |
| 140 | Data8bitsDirective = "\tdb\t"; |
| 141 | Data16bitsDirective = "\tdw\t"; |
| 142 | Data32bitsDirective = "\tdd\t"; |
| 143 | Data64bitsDirective = "\tdq\t"; |
| 144 | HasDotTypeDotSizeDirective = false; |
Rafael Espindola | 952b839 | 2008-12-03 11:01:37 +0000 | [diff] [blame] | 145 | HasSingleParameterDotFile = false; |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 146 | |
Eli Friedman | aace4b1 | 2009-06-19 04:48:38 +0000 | [diff] [blame] | 147 | AlignmentIsInBytes = true; |
| 148 | |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 149 | SwitchToSectionDirective = ""; |
Eli Friedman | aace4b1 | 2009-06-19 04:48:38 +0000 | [diff] [blame] | 150 | TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'"; |
| 151 | DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'"; |
Anton Korobeynikov | f447e3d | 2008-07-09 13:21:49 +0000 | [diff] [blame] | 152 | SectionEndDirectiveSuffix = "\tends\n"; |
| 153 | } |
Anton Korobeynikov | 6381a13 | 2008-10-05 08:53:29 +0000 | [diff] [blame] | 154 | |
Anton Korobeynikov | 6381a13 | 2008-10-05 08:53:29 +0000 | [diff] [blame] | 155 | // Instantiate default implementation. |
| 156 | TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>); |