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