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