Fix DWARF debugging information on x86/Linux and (hopefully)
[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   PCSymbol("$"),
28   SeparatorChar(';'),
29   CommentString("#"),
30   GlobalPrefix(""),
31   PrivateGlobalPrefix("."),
32   JumpTableSpecialLabelPrefix(0),
33   GlobalVarAddrPrefix(""),
34   GlobalVarAddrSuffix(""),
35   FunctionAddrPrefix(""),
36   FunctionAddrSuffix(""),
37   InlineAsmStart("#APP"),
38   InlineAsmEnd("#NO_APP"),
39   AssemblerDialect(0),
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"),
56   JumpTableDirective(0),
57   CStringSection(0),
58   StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
59   StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
60   FourByteConstantSection(0),
61   EightByteConstantSection(0),
62   SixteenByteConstantSection(0),
63   GlobalDirective(0),
64   SetDirective(0),
65   LCOMMDirective(0),
66   COMMDirective("\t.comm\t"),
67   COMMDirectiveTakesAlignment(true),
68   HasDotTypeDotSizeDirective(true),
69   UsedDirective(0),
70   WeakRefDirective(0),
71   HiddenDirective("\t.hidden\t"),
72   AbsoluteSectionOffsets(false),
73   HasLEB128(false),
74   HasDotLoc(false),
75   HasDotFile(false),
76   SupportsExceptionHandling(false),
77   DwarfRequiresFrameSection(true),
78   DwarfSectionOffsetDirective(0),
79   DwarfAbbrevSection(".debug_abbrev"),
80   DwarfInfoSection(".debug_info"),
81   DwarfLineSection(".debug_line"),
82   DwarfFrameSection(".debug_frame"),
83   DwarfPubNamesSection(".debug_pubnames"),
84   DwarfPubTypesSection(".debug_pubtypes"),
85   DwarfStrSection(".debug_str"),
86   DwarfLocSection(".debug_loc"),
87   DwarfARangesSection(".debug_aranges"),
88   DwarfRangesSection(".debug_ranges"),
89   DwarfMacInfoSection(".debug_macinfo"),
90   DwarfEHFrameSection(".eh_frame"),
91   DwarfExceptionSection(".gcc_except_table"),
92   AsmTransCBE(0) {
93 }
94
95 TargetAsmInfo::~TargetAsmInfo() {
96 }
97
98 /// Measure the specified inline asm to determine an approximation of its
99 /// length.
100 unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
101   // Count the number of instructions in the asm.
102   unsigned NumInsts = 0;
103   for (; *Str; ++Str) {
104     if (*Str == '\n' || *Str == SeparatorChar)
105       ++NumInsts;
106   }
107
108   // Multiply by the worst-case length for each instruction.
109   return NumInsts * MaxInstLength;
110 }
111