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" |
| 16 | |
| 17 | using namespace llvm; |
| 18 | |
| 19 | TargetAsmInfo::TargetAsmInfo() : |
| 20 | TextSection(".text"), |
| 21 | DataSection(".data"), |
| 22 | AddressSize(4), |
| 23 | NeedsSet(false), |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 24 | MaxInstLength(4), |
| 25 | SeparatorChar(';'), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 26 | CommentString("#"), |
| 27 | GlobalPrefix(""), |
| 28 | PrivateGlobalPrefix("."), |
| 29 | GlobalVarAddrPrefix(""), |
| 30 | GlobalVarAddrSuffix(""), |
| 31 | FunctionAddrPrefix(""), |
| 32 | FunctionAddrSuffix(""), |
| 33 | InlineAsmStart("#APP"), |
| 34 | InlineAsmEnd("#NO_APP"), |
| 35 | ZeroDirective("\t.zero\t"), |
| 36 | ZeroDirectiveSuffix(0), |
| 37 | AsciiDirective("\t.ascii\t"), |
| 38 | AscizDirective("\t.asciz\t"), |
| 39 | Data8bitsDirective("\t.byte\t"), |
| 40 | Data16bitsDirective("\t.short\t"), |
| 41 | Data32bitsDirective("\t.long\t"), |
| 42 | Data64bitsDirective("\t.quad\t"), |
| 43 | AlignDirective("\t.align\t"), |
| 44 | AlignmentIsInBytes(true), |
| 45 | SwitchToSectionDirective("\t.section\t"), |
| 46 | TextSectionStartSuffix(""), |
| 47 | DataSectionStartSuffix(""), |
| 48 | SectionEndDirectiveSuffix(0), |
| 49 | ConstantPoolSection("\t.section .rodata\n"), |
| 50 | JumpTableDataSection("\t.section .rodata\n"), |
Andrew Lenharth | beec30e | 2006-09-24 19:45:58 +0000 | [diff] [blame] | 51 | JumpTableDirective(0), |
Reid Spencer | c50209b | 2006-10-27 16:14:06 +0000 | [diff] [blame] | 52 | CStringSection(0), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 53 | StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"), |
| 54 | StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"), |
| 55 | FourByteConstantSection(0), |
| 56 | EightByteConstantSection(0), |
| 57 | SixteenByteConstantSection(0), |
| 58 | SetDirective(0), |
| 59 | LCOMMDirective(0), |
| 60 | COMMDirective("\t.comm\t"), |
| 61 | COMMDirectiveTakesAlignment(true), |
| 62 | HasDotTypeDotSizeDirective(true), |
Chris Lattner | cb05af8 | 2006-09-26 03:38:18 +0000 | [diff] [blame] | 63 | UsedDirective(0), |
Evan Cheng | 8752ce6 | 2006-12-01 20:47:11 +0000 | [diff] [blame] | 64 | WeakRefDirective(0), |
Chris Lattner | 9784bc7 | 2007-01-14 06:27:21 +0000 | [diff] [blame^] | 65 | HiddenDirective("\t.hidden\t"), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 66 | HasLEB128(false), |
| 67 | HasDotLoc(false), |
| 68 | HasDotFile(false), |
Reid Spencer | 02b8511 | 2006-10-30 22:32:30 +0000 | [diff] [blame] | 69 | DwarfRequiresFrameSection(true), |
Jim Laskey | ec0d9fe | 2006-09-06 18:35:33 +0000 | [diff] [blame] | 70 | DwarfAbbrevSection(".debug_abbrev"), |
| 71 | DwarfInfoSection(".debug_info"), |
| 72 | DwarfLineSection(".debug_line"), |
| 73 | DwarfFrameSection(".debug_frame"), |
| 74 | DwarfPubNamesSection(".debug_pubnames"), |
| 75 | DwarfPubTypesSection(".debug_pubtypes"), |
| 76 | DwarfStrSection(".debug_str"), |
| 77 | DwarfLocSection(".debug_loc"), |
| 78 | DwarfARangesSection(".debug_aranges"), |
| 79 | DwarfRangesSection(".debug_ranges"), |
Andrew Lenharth | 3655de6 | 2006-11-28 19:52:20 +0000 | [diff] [blame] | 80 | DwarfMacInfoSection(".debug_macinfo"), |
| 81 | AsmTransCBE(0) { |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 82 | } |
Chris Lattner | f5b10ec | 2006-10-05 00:35:16 +0000 | [diff] [blame] | 83 | |
| 84 | TargetAsmInfo::~TargetAsmInfo() { |
| 85 | } |
Chris Lattner | 4c7b07a | 2006-10-13 17:50:07 +0000 | [diff] [blame] | 86 | |
| 87 | /// Measure the specified inline asm to determine an approximation of its |
| 88 | /// length. |
| 89 | unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const { |
| 90 | // Count the number of instructions in the asm. |
| 91 | unsigned NumInsts = 0; |
| 92 | for (; *Str; ++Str) { |
| 93 | if (*Str == '\n' || *Str == SeparatorChar) |
| 94 | ++NumInsts; |
| 95 | } |
| 96 | |
| 97 | // Multiply by the worst-case length for each instruction. |
| 98 | return NumInsts * MaxInstLength; |
| 99 | } |