Jim Laskey | 7c95ad4 | 2006-09-06 19:21:41 +0000 | [diff] [blame] | 1 | //===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==// |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 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" |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 16 | #include <cctype> |
| 17 | #include <cstring> |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 18 | |
| 19 | using namespace llvm; |
| 20 | |
| 21 | TargetAsmInfo::TargetAsmInfo() : |
Dan Gohman | 9570165 | 2007-05-03 18:46:30 +0000 | [diff] [blame] | 22 | TextSection("\t.text"), |
| 23 | DataSection("\t.data"), |
| 24 | BSSSection("\t.bss"), |
Lauro Ramos Venancio | b3a0417 | 2007-04-20 21:38:10 +0000 | [diff] [blame] | 25 | TLSDataSection("\t.section .tdata,\"awT\",@progbits"), |
| 26 | TLSBSSSection("\t.section .tbss,\"awT\",@nobits"), |
Chris Lattner | 6f198df | 2007-01-17 17:42:42 +0000 | [diff] [blame] | 27 | ZeroFillDirective(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 28 | NeedsSet(false), |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 29 | MaxInstLength(4), |
Jim Laskey | b82313f | 2007-02-01 16:31:34 +0000 | [diff] [blame] | 30 | PCSymbol("$"), |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 31 | SeparatorChar(';'), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 32 | CommentString("#"), |
| 33 | GlobalPrefix(""), |
| 34 | PrivateGlobalPrefix("."), |
Chris Lattner | 393a8ee | 2007-01-18 01:12:56 +0000 | [diff] [blame] | 35 | JumpTableSpecialLabelPrefix(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 36 | GlobalVarAddrPrefix(""), |
| 37 | GlobalVarAddrSuffix(""), |
| 38 | FunctionAddrPrefix(""), |
| 39 | FunctionAddrSuffix(""), |
Bill Wendling | d60da49 | 2007-09-11 08:27:17 +0000 | [diff] [blame] | 40 | PersonalityPrefix(""), |
| 41 | PersonalitySuffix(""), |
Bill Wendling | ef4a661 | 2007-09-11 17:20:55 +0000 | [diff] [blame] | 42 | NeedsIndirectEncoding(false), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 43 | InlineAsmStart("#APP"), |
| 44 | InlineAsmEnd("#NO_APP"), |
Bill Wendling | eb9a42c | 2007-01-16 03:42:04 +0000 | [diff] [blame] | 45 | AssemblerDialect(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 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), |
Dan Gohman | af67ea7 | 2007-06-14 15:00:27 +0000 | [diff] [blame] | 60 | ConstantPoolSection("\t.section .rodata"), |
| 61 | JumpTableDataSection("\t.section .rodata"), |
Andrew Lenharth | beec30e | 2006-09-24 19:45:58 +0000 | [diff] [blame] | 62 | JumpTableDirective(0), |
Reid Spencer | c50209b | 2006-10-27 16:14:06 +0000 | [diff] [blame] | 63 | CStringSection(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 64 | StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"), |
| 65 | StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"), |
| 66 | FourByteConstantSection(0), |
| 67 | EightByteConstantSection(0), |
| 68 | SixteenByteConstantSection(0), |
Evan Cheng | be346c9 | 2007-03-08 01:00:38 +0000 | [diff] [blame] | 69 | ReadOnlySection(0), |
Gordon Henriksen | 81361d6 | 2007-12-23 20:58:16 +0000 | [diff] [blame^] | 70 | GlobalDirective("\t.globl\t"), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 71 | SetDirective(0), |
| 72 | LCOMMDirective(0), |
| 73 | COMMDirective("\t.comm\t"), |
| 74 | COMMDirectiveTakesAlignment(true), |
| 75 | HasDotTypeDotSizeDirective(true), |
Chris Lattner | cb05af8 | 2006-09-26 03:38:18 +0000 | [diff] [blame] | 76 | UsedDirective(0), |
Evan Cheng | 8752ce6 | 2006-12-01 20:47:11 +0000 | [diff] [blame] | 77 | WeakRefDirective(0), |
Dale Johannesen | 1d4ce2a | 2007-11-20 23:24:42 +0000 | [diff] [blame] | 78 | WeakDefDirective(0), |
Chris Lattner | 9784bc7 | 2007-01-14 06:27:21 +0000 | [diff] [blame] | 79 | HiddenDirective("\t.hidden\t"), |
Anton Korobeynikov | 6f9896f | 2007-04-29 18:35:00 +0000 | [diff] [blame] | 80 | ProtectedDirective("\t.protected\t"), |
Anton Korobeynikov | 79dda2b | 2007-05-01 22:23:12 +0000 | [diff] [blame] | 81 | AbsoluteDebugSectionOffsets(false), |
| 82 | AbsoluteEHSectionOffsets(false), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 83 | HasLEB128(false), |
Dan Gohman | 7225273 | 2007-09-24 21:09:53 +0000 | [diff] [blame] | 84 | HasDotLocAndDotFile(false), |
Anton Korobeynikov | 2a07e2f | 2007-05-05 09:04:50 +0000 | [diff] [blame] | 85 | SupportsDebugInformation(false), |
Jim Laskey | 072200c | 2007-01-29 18:51:14 +0000 | [diff] [blame] | 86 | SupportsExceptionHandling(false), |
Reid Spencer | 02b8511 | 2006-10-30 22:32:30 +0000 | [diff] [blame] | 87 | DwarfRequiresFrameSection(true), |
Dale Johannesen | 9305dcb | 2007-11-21 00:45:00 +0000 | [diff] [blame] | 88 | GlobalEHDirective(0), |
Anton Korobeynikov | a6199c8 | 2007-03-07 02:47:57 +0000 | [diff] [blame] | 89 | DwarfSectionOffsetDirective(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 90 | DwarfAbbrevSection(".debug_abbrev"), |
| 91 | DwarfInfoSection(".debug_info"), |
| 92 | DwarfLineSection(".debug_line"), |
| 93 | DwarfFrameSection(".debug_frame"), |
| 94 | DwarfPubNamesSection(".debug_pubnames"), |
| 95 | DwarfPubTypesSection(".debug_pubtypes"), |
| 96 | DwarfStrSection(".debug_str"), |
| 97 | DwarfLocSection(".debug_loc"), |
| 98 | DwarfARangesSection(".debug_aranges"), |
| 99 | DwarfRangesSection(".debug_ranges"), |
Andrew Lenharth | 3655de6 | 2006-11-28 19:52:20 +0000 | [diff] [blame] | 100 | DwarfMacInfoSection(".debug_macinfo"), |
Jim Laskey | b82313f | 2007-02-01 16:31:34 +0000 | [diff] [blame] | 101 | DwarfEHFrameSection(".eh_frame"), |
Jim Laskey | a15be8c | 2007-02-21 22:43:40 +0000 | [diff] [blame] | 102 | DwarfExceptionSection(".gcc_except_table"), |
Andrew Lenharth | 3655de6 | 2006-11-28 19:52:20 +0000 | [diff] [blame] | 103 | AsmTransCBE(0) { |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 104 | } |
Chris Lattner | f5b10ec | 2006-10-05 00:35:16 +0000 | [diff] [blame] | 105 | |
| 106 | TargetAsmInfo::~TargetAsmInfo() { |
| 107 | } |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 108 | |
| 109 | /// Measure the specified inline asm to determine an approximation of its |
| 110 | /// length. |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 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. |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 117 | unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const { |
| 118 | // Count the number of instructions in the asm. |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 119 | bool atInsnStart = true; |
| 120 | unsigned Length = 0; |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 121 | for (; *Str; ++Str) { |
| 122 | if (*Str == '\n' || *Str == SeparatorChar) |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 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; |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 132 | return Length; |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 133 | } |
Anton Korobeynikov | a6199c8 | 2007-03-07 02:47:57 +0000 | [diff] [blame] | 134 | |