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