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