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