Add the #include here.
[oota-llvm.git] / lib / MC / MCAsmInfo.cpp
1 //===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // 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/MC/MCAsmInfo.h"
16 #include "llvm/Support/DataTypes.h"
17 #include <cctype>
18 #include <cstring>
19 using namespace llvm;
20
21 MCAsmInfo::MCAsmInfo() {
22   ZeroFillDirective = 0;
23   NonexecutableStackDirective = 0;
24   NeedsSet = false;
25   MaxInstLength = 4;
26   PCSymbol = "$";
27   SeparatorChar = ';';
28   CommentColumn = 60;
29   CommentString = "#";
30   GlobalPrefix = "";
31   PrivateGlobalPrefix = ".";
32   LinkerPrivateGlobalPrefix = "";
33   JumpTableSpecialLabelPrefix = 0;
34   GlobalVarAddrPrefix = "";
35   GlobalVarAddrSuffix = "";
36   FunctionAddrPrefix = "";
37   FunctionAddrSuffix = "";
38   PersonalityPrefix = "";
39   PersonalitySuffix = "";
40   NeedsIndirectEncoding = false;
41   InlineAsmStart = "APP";
42   InlineAsmEnd = "NO_APP";
43   AssemblerDialect = 0;
44   AllowQuotesInName = false;
45   ZeroDirective = "\t.zero\t";
46   ZeroDirectiveSuffix = 0;
47   AsciiDirective = "\t.ascii\t";
48   AscizDirective = "\t.asciz\t";
49   Data8bitsDirective = "\t.byte\t";
50   Data16bitsDirective = "\t.short\t";
51   Data32bitsDirective = "\t.long\t";
52   Data64bitsDirective = "\t.quad\t";
53   SunStyleELFSectionSwitchSyntax = false;
54   UsesELFSectionDirectiveForBSS = false;
55   AlignDirective = "\t.align\t";
56   AlignmentIsInBytes = true;
57   TextAlignFillValue = 0;
58   JumpTableDirective = 0;
59   PICJumpTableDirective = 0;
60   GlobalDirective = "\t.globl\t";
61   SetDirective = 0;
62   LCOMMDirective = 0;
63   COMMDirective = "\t.comm\t";
64   COMMDirectiveTakesAlignment = true;
65   HasDotTypeDotSizeDirective = true;
66   HasSingleParameterDotFile = true;
67   UsedDirective = 0;
68   WeakRefDirective = 0;
69   WeakDefDirective = 0;
70   // FIXME: These are ELFish - move to ELFMAI.
71   HiddenDirective = "\t.hidden\t";
72   ProtectedDirective = "\t.protected\t";
73   AbsoluteDebugSectionOffsets = false;
74   AbsoluteEHSectionOffsets = false;
75   HasLEB128 = false;
76   HasDotLocAndDotFile = false;
77   SupportsDebugInformation = false;
78   ExceptionsType = ExceptionHandling::None;
79   DwarfRequiresFrameSection = true;
80   DwarfUsesInlineInfoSection = false;
81   Is_EHSymbolPrivate = true;
82   ForceEncodingOfFDETo32Bits = true;
83   GlobalEHDirective = 0;
84   SupportsWeakOmittedEHFrame = true;
85   DwarfSectionOffsetDirective = 0;
86
87   AsmTransCBE = 0;
88 }
89
90 MCAsmInfo::~MCAsmInfo() {
91 }
92
93
94 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
95   unsigned Size = 0;
96   do {
97     Value >>= 7;
98     Size += sizeof(int8_t);
99   } while (Value);
100   return Size;
101 }
102
103 unsigned MCAsmInfo::getSLEB128Size(int Value) {
104   unsigned Size = 0;
105   int Sign = Value >> (8 * sizeof(Value) - 1);
106   bool IsMore;
107
108   do {
109     unsigned Byte = Value & 0x7f;
110     Value >>= 7;
111     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
112     Size += sizeof(int8_t);
113   } while (IsMore);
114   return Size;
115 }