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() : |
| 22 | TextSection(".text"), |
| 23 | DataSection(".data"), |
Anton Korobeynikov | 5032e5a | 2007-01-17 10:33:08 +0000 | [diff] [blame] | 24 | BSSSection(".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 | AddressSize(4), |
| 29 | NeedsSet(false), |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 30 | MaxInstLength(4), |
Jim Laskey | b82313f | 2007-02-01 16:31:34 +0000 | [diff] [blame] | 31 | PCSymbol("$"), |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 32 | SeparatorChar(';'), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 33 | CommentString("#"), |
| 34 | GlobalPrefix(""), |
| 35 | PrivateGlobalPrefix("."), |
Chris Lattner | 393a8ee | 2007-01-18 01:12:56 +0000 | [diff] [blame] | 36 | JumpTableSpecialLabelPrefix(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 37 | GlobalVarAddrPrefix(""), |
| 38 | GlobalVarAddrSuffix(""), |
| 39 | FunctionAddrPrefix(""), |
| 40 | FunctionAddrSuffix(""), |
| 41 | InlineAsmStart("#APP"), |
| 42 | InlineAsmEnd("#NO_APP"), |
Bill Wendling | eb9a42c | 2007-01-16 03:42:04 +0000 | [diff] [blame] | 43 | AssemblerDialect(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 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\n"), |
| 59 | JumpTableDataSection("\t.section .rodata\n"), |
Andrew Lenharth | beec30e | 2006-09-24 19:45:58 +0000 | [diff] [blame] | 60 | JumpTableDirective(0), |
Reid Spencer | c50209b | 2006-10-27 16:14:06 +0000 | [diff] [blame] | 61 | CStringSection(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 62 | StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"), |
| 63 | StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"), |
| 64 | FourByteConstantSection(0), |
| 65 | EightByteConstantSection(0), |
| 66 | SixteenByteConstantSection(0), |
Evan Cheng | be346c9 | 2007-03-08 01:00:38 +0000 | [diff] [blame] | 67 | ReadOnlySection(0), |
Jim Laskey | 072200c | 2007-01-29 18:51:14 +0000 | [diff] [blame] | 68 | GlobalDirective(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 69 | SetDirective(0), |
| 70 | LCOMMDirective(0), |
| 71 | COMMDirective("\t.comm\t"), |
| 72 | COMMDirectiveTakesAlignment(true), |
| 73 | HasDotTypeDotSizeDirective(true), |
Chris Lattner | cb05af8 | 2006-09-26 03:38:18 +0000 | [diff] [blame] | 74 | UsedDirective(0), |
Evan Cheng | 8752ce6 | 2006-12-01 20:47:11 +0000 | [diff] [blame] | 75 | WeakRefDirective(0), |
Chris Lattner | 9784bc7 | 2007-01-14 06:27:21 +0000 | [diff] [blame] | 76 | HiddenDirective("\t.hidden\t"), |
Anton Korobeynikov | 6f9896f | 2007-04-29 18:35:00 +0000 | [diff] [blame] | 77 | ProtectedDirective("\t.protected\t"), |
Anton Korobeynikov | 79dda2b | 2007-05-01 22:23:12 +0000 | [diff] [blame^] | 78 | AbsoluteDebugSectionOffsets(false), |
| 79 | AbsoluteEHSectionOffsets(false), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 80 | HasLEB128(false), |
| 81 | HasDotLoc(false), |
| 82 | HasDotFile(false), |
Jim Laskey | 072200c | 2007-01-29 18:51:14 +0000 | [diff] [blame] | 83 | SupportsExceptionHandling(false), |
Reid Spencer | 02b8511 | 2006-10-30 22:32:30 +0000 | [diff] [blame] | 84 | DwarfRequiresFrameSection(true), |
Anton Korobeynikov | a6199c8 | 2007-03-07 02:47:57 +0000 | [diff] [blame] | 85 | DwarfSectionOffsetDirective(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 86 | DwarfAbbrevSection(".debug_abbrev"), |
| 87 | DwarfInfoSection(".debug_info"), |
| 88 | DwarfLineSection(".debug_line"), |
| 89 | DwarfFrameSection(".debug_frame"), |
| 90 | DwarfPubNamesSection(".debug_pubnames"), |
| 91 | DwarfPubTypesSection(".debug_pubtypes"), |
| 92 | DwarfStrSection(".debug_str"), |
| 93 | DwarfLocSection(".debug_loc"), |
| 94 | DwarfARangesSection(".debug_aranges"), |
| 95 | DwarfRangesSection(".debug_ranges"), |
Andrew Lenharth | 3655de6 | 2006-11-28 19:52:20 +0000 | [diff] [blame] | 96 | DwarfMacInfoSection(".debug_macinfo"), |
Jim Laskey | b82313f | 2007-02-01 16:31:34 +0000 | [diff] [blame] | 97 | DwarfEHFrameSection(".eh_frame"), |
Jim Laskey | a15be8c | 2007-02-21 22:43:40 +0000 | [diff] [blame] | 98 | DwarfExceptionSection(".gcc_except_table"), |
Andrew Lenharth | 3655de6 | 2006-11-28 19:52:20 +0000 | [diff] [blame] | 99 | AsmTransCBE(0) { |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 100 | } |
Chris Lattner | f5b10ec | 2006-10-05 00:35:16 +0000 | [diff] [blame] | 101 | |
| 102 | TargetAsmInfo::~TargetAsmInfo() { |
| 103 | } |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 104 | |
| 105 | /// Measure the specified inline asm to determine an approximation of its |
| 106 | /// length. |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 107 | /// Comments (which run till the next SeparatorChar or newline) do not |
| 108 | /// count as an instruction. |
| 109 | /// Any other non-whitespace text is considered an instruction, with |
| 110 | /// multiple instructions separated by SeparatorChar or newlines. |
| 111 | /// Variable-length instructions are not handled here; this function |
| 112 | /// may be overloaded in the target code to do that. |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 113 | unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const { |
| 114 | // Count the number of instructions in the asm. |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 115 | bool atInsnStart = true; |
| 116 | unsigned Length = 0; |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 117 | for (; *Str; ++Str) { |
| 118 | if (*Str == '\n' || *Str == SeparatorChar) |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 119 | atInsnStart = true; |
| 120 | if (atInsnStart && !isspace(*Str)) { |
| 121 | Length += MaxInstLength; |
| 122 | atInsnStart = false; |
| 123 | } |
| 124 | if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0) |
| 125 | atInsnStart = false; |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Dale Johannesen | 3bb6283 | 2007-04-23 20:00:17 +0000 | [diff] [blame] | 128 | return Length; |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 129 | } |
Anton Korobeynikov | a6199c8 | 2007-03-07 02:47:57 +0000 | [diff] [blame] | 130 | |