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