Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 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. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines target asm properties related what form asm statements |
| 11 | // should take. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm/Target/TargetAsmInfo.h" |
Anton Korobeynikov | 65c0d87 | 2008-02-27 23:33:50 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Dwarf.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 17 | #include <cctype> |
| 18 | #include <cstring> |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
| 22 | TargetAsmInfo::TargetAsmInfo() : |
| 23 | TextSection("\t.text"), |
| 24 | DataSection("\t.data"), |
| 25 | BSSSection("\t.bss"), |
| 26 | TLSDataSection("\t.section .tdata,\"awT\",@progbits"), |
| 27 | TLSBSSSection("\t.section .tbss,\"awT\",@nobits"), |
| 28 | ZeroFillDirective(0), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 29 | NeedsSet(false), |
| 30 | MaxInstLength(4), |
| 31 | PCSymbol("$"), |
| 32 | SeparatorChar(';'), |
| 33 | CommentString("#"), |
| 34 | GlobalPrefix(""), |
| 35 | PrivateGlobalPrefix("."), |
| 36 | JumpTableSpecialLabelPrefix(0), |
| 37 | GlobalVarAddrPrefix(""), |
| 38 | GlobalVarAddrSuffix(""), |
| 39 | FunctionAddrPrefix(""), |
| 40 | FunctionAddrSuffix(""), |
Bill Wendling | d1bda4f | 2007-09-11 08:27:17 +0000 | [diff] [blame] | 41 | PersonalityPrefix(""), |
| 42 | PersonalitySuffix(""), |
Bill Wendling | 2d36992 | 2007-09-11 17:20:55 +0000 | [diff] [blame] | 43 | NeedsIndirectEncoding(false), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 44 | InlineAsmStart("#APP"), |
| 45 | InlineAsmEnd("#NO_APP"), |
| 46 | AssemblerDialect(0), |
| 47 | ZeroDirective("\t.zero\t"), |
| 48 | ZeroDirectiveSuffix(0), |
| 49 | AsciiDirective("\t.ascii\t"), |
| 50 | AscizDirective("\t.asciz\t"), |
| 51 | Data8bitsDirective("\t.byte\t"), |
| 52 | Data16bitsDirective("\t.short\t"), |
| 53 | Data32bitsDirective("\t.long\t"), |
| 54 | Data64bitsDirective("\t.quad\t"), |
| 55 | AlignDirective("\t.align\t"), |
| 56 | AlignmentIsInBytes(true), |
Lauro Ramos Venancio | 9190bc4 | 2008-02-28 22:14:09 +0000 | [diff] [blame] | 57 | TextAlignFillValue(0), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 58 | SwitchToSectionDirective("\t.section\t"), |
| 59 | TextSectionStartSuffix(""), |
| 60 | DataSectionStartSuffix(""), |
| 61 | SectionEndDirectiveSuffix(0), |
| 62 | ConstantPoolSection("\t.section .rodata"), |
| 63 | JumpTableDataSection("\t.section .rodata"), |
| 64 | JumpTableDirective(0), |
| 65 | CStringSection(0), |
| 66 | StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"), |
| 67 | StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"), |
| 68 | FourByteConstantSection(0), |
| 69 | EightByteConstantSection(0), |
| 70 | SixteenByteConstantSection(0), |
| 71 | ReadOnlySection(0), |
Gordon Henriksen | e383f2a | 2007-12-23 20:58:16 +0000 | [diff] [blame] | 72 | GlobalDirective("\t.globl\t"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 73 | SetDirective(0), |
| 74 | LCOMMDirective(0), |
| 75 | COMMDirective("\t.comm\t"), |
| 76 | COMMDirectiveTakesAlignment(true), |
| 77 | HasDotTypeDotSizeDirective(true), |
| 78 | UsedDirective(0), |
| 79 | WeakRefDirective(0), |
Dale Johannesen | fb3ac73 | 2007-11-20 23:24:42 +0000 | [diff] [blame] | 80 | WeakDefDirective(0), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 81 | HiddenDirective("\t.hidden\t"), |
| 82 | ProtectedDirective("\t.protected\t"), |
| 83 | AbsoluteDebugSectionOffsets(false), |
| 84 | AbsoluteEHSectionOffsets(false), |
| 85 | HasLEB128(false), |
Dan Gohman | 307ad20 | 2007-09-24 21:09:53 +0000 | [diff] [blame] | 86 | HasDotLocAndDotFile(false), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 87 | SupportsDebugInformation(false), |
| 88 | SupportsExceptionHandling(false), |
| 89 | DwarfRequiresFrameSection(true), |
Dale Johannesen | 23b89a6 | 2007-11-21 00:45:00 +0000 | [diff] [blame] | 90 | GlobalEHDirective(0), |
Dale Johannesen | f09b599 | 2008-01-10 02:03:30 +0000 | [diff] [blame] | 91 | SupportsWeakOmittedEHFrame(true), |
Dale Johannesen | bc56bc3 | 2008-01-15 23:25:27 +0000 | [diff] [blame] | 92 | ShortenEHDataOn64Bit(false), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 93 | DwarfSectionOffsetDirective(0), |
| 94 | DwarfAbbrevSection(".debug_abbrev"), |
| 95 | DwarfInfoSection(".debug_info"), |
| 96 | DwarfLineSection(".debug_line"), |
| 97 | DwarfFrameSection(".debug_frame"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 98 | DwarfPubNamesSection(".debug_pubnames"), |
| 99 | DwarfPubTypesSection(".debug_pubtypes"), |
| 100 | DwarfStrSection(".debug_str"), |
| 101 | DwarfLocSection(".debug_loc"), |
| 102 | DwarfARangesSection(".debug_aranges"), |
| 103 | DwarfRangesSection(".debug_ranges"), |
| 104 | DwarfMacInfoSection(".debug_macinfo"), |
| 105 | DwarfEHFrameSection(".eh_frame"), |
| 106 | DwarfExceptionSection(".gcc_except_table"), |
| 107 | AsmTransCBE(0) { |
| 108 | } |
| 109 | |
| 110 | TargetAsmInfo::~TargetAsmInfo() { |
| 111 | } |
| 112 | |
| 113 | /// Measure the specified inline asm to determine an approximation of its |
| 114 | /// length. |
| 115 | /// Comments (which run till the next SeparatorChar or newline) do not |
| 116 | /// count as an instruction. |
| 117 | /// Any other non-whitespace text is considered an instruction, with |
| 118 | /// multiple instructions separated by SeparatorChar or newlines. |
| 119 | /// Variable-length instructions are not handled here; this function |
| 120 | /// may be overloaded in the target code to do that. |
| 121 | unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const { |
| 122 | // Count the number of instructions in the asm. |
| 123 | bool atInsnStart = true; |
| 124 | unsigned Length = 0; |
| 125 | for (; *Str; ++Str) { |
| 126 | if (*Str == '\n' || *Str == SeparatorChar) |
| 127 | atInsnStart = true; |
| 128 | if (atInsnStart && !isspace(*Str)) { |
| 129 | Length += MaxInstLength; |
| 130 | atInsnStart = false; |
| 131 | } |
| 132 | if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0) |
| 133 | atInsnStart = false; |
| 134 | } |
| 135 | |
| 136 | return Length; |
| 137 | } |
| 138 | |
Anton Korobeynikov | 8750d7c | 2008-02-29 22:09:08 +0000 | [diff] [blame] | 139 | unsigned TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason, |
Anton Korobeynikov | 65c0d87 | 2008-02-27 23:33:50 +0000 | [diff] [blame] | 140 | bool Global) const { |
| 141 | return dwarf::DW_EH_PE_absptr; |
| 142 | } |
| 143 | |