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