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