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 | // |
| 5 | // This file was developed by James M. Laskey and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 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" |
Andrew Lenharth | 6c0695f | 2006-11-28 19:52:49 +0000 | [diff] [blame^] | 17 | #include <iostream> |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 18 | |
| 19 | using namespace llvm; |
| 20 | |
Andrew Lenharth | 6c0695f | 2006-11-28 19:52:49 +0000 | [diff] [blame^] | 21 | static const char* x86_asm_table[] = {"{si}", "S", |
| 22 | "{di}", "D", |
| 23 | "{ax}", "a", |
| 24 | "{cx}", "c", |
| 25 | "q", "q", |
| 26 | "r", "r", |
| 27 | "m", "m", |
| 28 | "{memory}", "memory", |
| 29 | "{flags}", "", |
| 30 | "{dirflag}", "", |
| 31 | "{fpsr}", "", |
| 32 | "{cc}", "cc", |
| 33 | 0,0}; |
| 34 | |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 35 | X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) { |
| 36 | const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>(); |
| 37 | |
Chris Lattner | afbfded | 2006-10-05 02:43:52 +0000 | [diff] [blame] | 38 | // FIXME - Should be simplified. |
Andrew Lenharth | 6c0695f | 2006-11-28 19:52:49 +0000 | [diff] [blame^] | 39 | |
| 40 | AsmTransCBE = x86_asm_table; |
| 41 | |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 42 | switch (Subtarget->TargetType) { |
| 43 | case X86Subtarget::isDarwin: |
| 44 | AlignmentIsInBytes = false; |
| 45 | GlobalPrefix = "_"; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 46 | if (!Subtarget->is64Bit()) |
| 47 | Data64bitsDirective = 0; // we can't emit a 64-bit unit |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 48 | ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. |
| 49 | PrivateGlobalPrefix = "L"; // Marker for constant pool idxs |
| 50 | ConstantPoolSection = "\t.const\n"; |
Chris Lattner | afbfded | 2006-10-05 02:43:52 +0000 | [diff] [blame] | 51 | JumpTableDataSection = "\t.const\n"; |
Evan Cheng | 8910c1c | 2006-10-26 19:18:18 +0000 | [diff] [blame] | 52 | CStringSection = "\t.cstring"; |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 53 | FourByteConstantSection = "\t.literal4\n"; |
| 54 | EightByteConstantSection = "\t.literal8\n"; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 55 | if (Subtarget->is64Bit()) |
| 56 | SixteenByteConstantSection = "\t.literal16\n"; |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 57 | LCOMMDirective = "\t.lcomm\t"; |
| 58 | COMMDirectiveTakesAlignment = false; |
| 59 | HasDotTypeDotSizeDirective = false; |
| 60 | StaticCtorsSection = ".mod_init_func"; |
| 61 | StaticDtorsSection = ".mod_term_func"; |
| 62 | InlineAsmStart = "# InlineAsm Start"; |
| 63 | InlineAsmEnd = "# InlineAsm End"; |
| 64 | SetDirective = "\t.set"; |
Chris Lattner | a53115b | 2006-09-26 03:39:53 +0000 | [diff] [blame] | 65 | UsedDirective = "\t.no_dead_strip\t"; |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 66 | |
| 67 | NeedsSet = true; |
| 68 | DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; |
| 69 | DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; |
| 70 | DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; |
| 71 | DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; |
| 72 | DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; |
| 73 | DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; |
| 74 | DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; |
| 75 | DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; |
| 76 | DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; |
| 77 | DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; |
| 78 | DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; |
| 79 | break; |
Reid Spencer | 02b8511 | 2006-10-30 22:32:30 +0000 | [diff] [blame] | 80 | |
| 81 | case X86Subtarget::isELF: |
| 82 | // Set up DWARF directives |
| 83 | HasLEB128 = true; // Target asm supports leb128 directives (little-endian) |
| 84 | // bool HasLEB128; // Defaults to false. |
| 85 | // hasDotLoc - True if target asm supports .loc directives. |
| 86 | // bool HasDotLoc; // Defaults to false. |
| 87 | // HasDotFile - True if target asm supports .file directives. |
| 88 | // bool HasDotFile; // Defaults to false. |
| 89 | PrivateGlobalPrefix = "."; // Prefix for private global symbols |
| 90 | DwarfRequiresFrameSection = false; |
| 91 | DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits"; |
| 92 | DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits"; |
| 93 | DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits"; |
| 94 | DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits"; |
| 95 | DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits"; |
| 96 | DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits"; |
| 97 | DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits"; |
| 98 | DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits"; |
| 99 | DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits"; |
| 100 | DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits"; |
| 101 | DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits"; |
| 102 | break; |
| 103 | |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 104 | case X86Subtarget::isCygwin: |
| 105 | GlobalPrefix = "_"; |
| 106 | COMMDirectiveTakesAlignment = false; |
| 107 | HasDotTypeDotSizeDirective = false; |
| 108 | StaticCtorsSection = "\t.section .ctors,\"aw\""; |
| 109 | StaticDtorsSection = "\t.section .dtors,\"aw\""; |
Anton Korobeynikov | ab4022f | 2006-10-31 08:31:24 +0000 | [diff] [blame] | 110 | |
| 111 | // Set up DWARF directives |
| 112 | HasLEB128 = true; // Target asm supports leb128 directives (little-endian) |
| 113 | PrivateGlobalPrefix = "L"; // Prefix for private global symbols |
| 114 | DwarfRequiresFrameSection = false; |
| 115 | DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\""; |
| 116 | DwarfInfoSection = "\t.section\t.debug_info,\"dr\""; |
| 117 | DwarfLineSection = "\t.section\t.debug_line,\"dr\""; |
| 118 | DwarfFrameSection = "\t.section\t.debug_frame,\"dr\""; |
| 119 | DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\""; |
| 120 | DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\""; |
| 121 | DwarfStrSection = "\t.section\t.debug_str,\"dr\""; |
| 122 | DwarfLocSection = "\t.section\t.debug_loc,\"dr\""; |
| 123 | DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\""; |
| 124 | DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\""; |
| 125 | DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\""; |
| 126 | break; |
| 127 | |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 128 | break; |
| 129 | case X86Subtarget::isWindows: |
| 130 | GlobalPrefix = "_"; |
| 131 | HasDotTypeDotSizeDirective = false; |
| 132 | break; |
| 133 | default: break; |
| 134 | } |
| 135 | |
| 136 | if (Subtarget->isFlavorIntel()) { |
| 137 | GlobalPrefix = "_"; |
| 138 | CommentString = ";"; |
| 139 | |
| 140 | PrivateGlobalPrefix = "$"; |
| 141 | AlignDirective = "\talign\t"; |
| 142 | ZeroDirective = "\tdb\t"; |
| 143 | ZeroDirectiveSuffix = " dup(0)"; |
| 144 | AsciiDirective = "\tdb\t"; |
| 145 | AscizDirective = 0; |
| 146 | Data8bitsDirective = "\tdb\t"; |
| 147 | Data16bitsDirective = "\tdw\t"; |
| 148 | Data32bitsDirective = "\tdd\t"; |
| 149 | Data64bitsDirective = "\tdq\t"; |
| 150 | HasDotTypeDotSizeDirective = false; |
| 151 | |
| 152 | TextSection = "_text"; |
| 153 | DataSection = "_data"; |
| 154 | SwitchToSectionDirective = ""; |
| 155 | TextSectionStartSuffix = "\tsegment 'CODE'"; |
| 156 | DataSectionStartSuffix = "\tsegment 'DATA'"; |
| 157 | SectionEndDirectiveSuffix = "\tends\n"; |
| 158 | } |
| 159 | } |
Chris Lattner | afbfded | 2006-10-05 02:43:52 +0000 | [diff] [blame] | 160 | |