9cf4019e31232af7bee6846440973c9071734f6a
[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   HasLCOMMDirective = false;
58   COMMDirectiveAlignmentIsInBytes = true;
59   HasDotTypeDotSizeDirective = true;
60   HasSingleParameterDotFile = true;
61   HasNoDeadStrip = false;
62   HasSymbolResolver = false;
63   WeakRefDirective = 0;
64   WeakDefDirective = 0;
65   LinkOnceDirective = 0;
66   HiddenVisibilityAttr = MCSA_Hidden;
67   ProtectedVisibilityAttr = MCSA_Protected;
68   HasLEB128 = false;
69   SupportsDebugInformation = false;
70   ExceptionsType = ExceptionHandling::None;
71   DwarfRequiresFrameSection = true;
72   DwarfUsesInlineInfoSection = false;
73   DwarfUsesAbsoluteLabelForStmtList = true;
74   DwarfSectionOffsetDirective = 0;
75   DwarfUsesLabelOffsetForRanges = true;
76   HasMicrosoftFastStdCallMangling = false;
77
78   AsmTransCBE = 0;
79 }
80
81 MCAsmInfo::~MCAsmInfo() {
82 }
83
84
85 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
86   unsigned Size = 0;
87   do {
88     Value >>= 7;
89     Size += sizeof(int8_t);
90   } while (Value);
91   return Size;
92 }
93
94 unsigned MCAsmInfo::getSLEB128Size(int Value) {
95   unsigned Size = 0;
96   int Sign = Value >> (8 * sizeof(Value) - 1);
97   bool IsMore;
98
99   do {
100     unsigned Byte = Value & 0x7f;
101     Value >>= 7;
102     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
103     Size += sizeof(int8_t);
104   } while (IsMore);
105   return Size;
106 }