Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame^] | 1 | //===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by James M. Laskey and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 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), |
| 28 | AddressSize(4), |
| 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(""), |
| 41 | InlineAsmStart("#APP"), |
| 42 | InlineAsmEnd("#NO_APP"), |
| 43 | AssemblerDialect(0), |
| 44 | ZeroDirective("\t.zero\t"), |
| 45 | ZeroDirectiveSuffix(0), |
| 46 | AsciiDirective("\t.ascii\t"), |
| 47 | AscizDirective("\t.asciz\t"), |
| 48 | Data8bitsDirective("\t.byte\t"), |
| 49 | Data16bitsDirective("\t.short\t"), |
| 50 | Data32bitsDirective("\t.long\t"), |
| 51 | Data64bitsDirective("\t.quad\t"), |
| 52 | AlignDirective("\t.align\t"), |
| 53 | AlignmentIsInBytes(true), |
| 54 | SwitchToSectionDirective("\t.section\t"), |
| 55 | TextSectionStartSuffix(""), |
| 56 | DataSectionStartSuffix(""), |
| 57 | SectionEndDirectiveSuffix(0), |
| 58 | ConstantPoolSection("\t.section .rodata"), |
| 59 | JumpTableDataSection("\t.section .rodata"), |
| 60 | JumpTableDirective(0), |
| 61 | CStringSection(0), |
| 62 | StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"), |
| 63 | StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"), |
| 64 | FourByteConstantSection(0), |
| 65 | EightByteConstantSection(0), |
| 66 | SixteenByteConstantSection(0), |
| 67 | ReadOnlySection(0), |
| 68 | GlobalDirective(0), |
| 69 | SetDirective(0), |
| 70 | LCOMMDirective(0), |
| 71 | COMMDirective("\t.comm\t"), |
| 72 | COMMDirectiveTakesAlignment(true), |
| 73 | HasDotTypeDotSizeDirective(true), |
| 74 | UsedDirective(0), |
| 75 | WeakRefDirective(0), |
| 76 | HiddenDirective("\t.hidden\t"), |
| 77 | ProtectedDirective("\t.protected\t"), |
| 78 | AbsoluteDebugSectionOffsets(false), |
| 79 | AbsoluteEHSectionOffsets(false), |
| 80 | HasLEB128(false), |
| 81 | HasDotLoc(false), |
| 82 | HasDotFile(false), |
| 83 | SupportsDebugInformation(false), |
| 84 | SupportsExceptionHandling(false), |
| 85 | DwarfRequiresFrameSection(true), |
| 86 | DwarfSectionOffsetDirective(0), |
| 87 | DwarfAbbrevSection(".debug_abbrev"), |
| 88 | DwarfInfoSection(".debug_info"), |
| 89 | DwarfLineSection(".debug_line"), |
| 90 | DwarfFrameSection(".debug_frame"), |
| 91 | DwarfPubNamesSection(".debug_pubnames"), |
| 92 | DwarfPubTypesSection(".debug_pubtypes"), |
| 93 | DwarfStrSection(".debug_str"), |
| 94 | DwarfLocSection(".debug_loc"), |
| 95 | DwarfARangesSection(".debug_aranges"), |
| 96 | DwarfRangesSection(".debug_ranges"), |
| 97 | DwarfMacInfoSection(".debug_macinfo"), |
| 98 | DwarfEHFrameSection(".eh_frame"), |
| 99 | DwarfExceptionSection(".gcc_except_table"), |
| 100 | AsmTransCBE(0) { |
| 101 | } |
| 102 | |
| 103 | TargetAsmInfo::~TargetAsmInfo() { |
| 104 | } |
| 105 | |
| 106 | /// Measure the specified inline asm to determine an approximation of its |
| 107 | /// length. |
| 108 | /// Comments (which run till the next SeparatorChar or newline) do not |
| 109 | /// count as an instruction. |
| 110 | /// Any other non-whitespace text is considered an instruction, with |
| 111 | /// multiple instructions separated by SeparatorChar or newlines. |
| 112 | /// Variable-length instructions are not handled here; this function |
| 113 | /// may be overloaded in the target code to do that. |
| 114 | unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const { |
| 115 | // Count the number of instructions in the asm. |
| 116 | bool atInsnStart = true; |
| 117 | unsigned Length = 0; |
| 118 | for (; *Str; ++Str) { |
| 119 | if (*Str == '\n' || *Str == SeparatorChar) |
| 120 | atInsnStart = true; |
| 121 | if (atInsnStart && !isspace(*Str)) { |
| 122 | Length += MaxInstLength; |
| 123 | atInsnStart = false; |
| 124 | } |
| 125 | if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0) |
| 126 | atInsnStart = false; |
| 127 | } |
| 128 | |
| 129 | return Length; |
| 130 | } |
| 131 | |