There are two reasons why we might want to use
[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   HasSubsectionsViaSymbols = false;
23   HasMachoZeroFillDirective = false;
24   HasMachoTBSSDirective = false;
25   HasStaticCtorDtorReferenceInStaticMode = false;
26   LinkerRequiresNonEmptyDwarfLines = false;
27   MaxInstLength = 4;
28   PCSymbol = "$";
29   SeparatorChar = ';';
30   CommentColumn = 40;
31   CommentString = "#";
32   LabelSuffix = ":";
33   GlobalPrefix = "";
34   PrivateGlobalPrefix = ".";
35   LinkerPrivateGlobalPrefix = "";
36   InlineAsmStart = "APP";
37   InlineAsmEnd = "NO_APP";
38   AssemblerDialect = 0;
39   AllowQuotesInName = false;
40   AllowNameToStartWithDigit = false;
41   AllowPeriodsInName = true;
42   ZeroDirective = "\t.zero\t";
43   AsciiDirective = "\t.ascii\t";
44   AscizDirective = "\t.asciz\t";
45   Data8bitsDirective = "\t.byte\t";
46   Data16bitsDirective = "\t.short\t";
47   Data32bitsDirective = "\t.long\t";
48   Data64bitsDirective = "\t.quad\t";
49   SunStyleELFSectionSwitchSyntax = false;
50   UsesELFSectionDirectiveForBSS = false;
51   AlignDirective = "\t.align\t";
52   AlignmentIsInBytes = true;
53   TextAlignFillValue = 0;
54   GPRel32Directive = 0;
55   GlobalDirective = "\t.globl\t";
56   HasSetDirective = true;
57   NeedsSetToChangeDiffSize = false;
58   HasLCOMMDirective = false;
59   COMMDirectiveAlignmentIsInBytes = true;
60   HasDotTypeDotSizeDirective = true;
61   HasSingleParameterDotFile = true;
62   HasNoDeadStrip = false;
63   HasSymbolResolver = false;
64   WeakRefDirective = 0;
65   WeakDefDirective = 0;
66   LinkOnceDirective = 0;
67   HiddenVisibilityAttr = MCSA_Hidden;
68   ProtectedVisibilityAttr = MCSA_Protected;
69   HasLEB128 = false;
70   SupportsDebugInformation = false;
71   ExceptionsType = ExceptionHandling::None;
72   DwarfRequiresFrameSection = true;
73   DwarfUsesInlineInfoSection = false;
74   DwarfUsesAbsoluteLabelForStmtList = true;
75   DwarfSectionOffsetDirective = 0;
76   DwarfUsesLabelOffsetForRanges = true;
77   HasMicrosoftFastStdCallMangling = false;
78
79   AsmTransCBE = 0;
80 }
81
82 MCAsmInfo::~MCAsmInfo() {
83 }
84
85
86 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
87   unsigned Size = 0;
88   do {
89     Value >>= 7;
90     Size += sizeof(int8_t);
91   } while (Value);
92   return Size;
93 }
94
95 unsigned MCAsmInfo::getSLEB128Size(int Value) {
96   unsigned Size = 0;
97   int Sign = Value >> (8 * sizeof(Value) - 1);
98   bool IsMore;
99
100   do {
101     unsigned Byte = Value & 0x7f;
102     Value >>= 7;
103     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
104     Size += sizeof(int8_t);
105   } while (IsMore);
106   return Size;
107 }