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