give MCAsmInfo a 'has little endian' bit. This is unfortunate, but
[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(bool isLittleEndian) {
22   IsLittleEndian = isLittleEndian;
23   HasMachoZeroFillDirective = false;
24   HasStaticCtorDtorReferenceInStaticMode = false;
25   NonexecutableStackDirective = 0;
26   NeedsSet = false;
27   MaxInstLength = 4;
28   PCSymbol = "$";
29   SeparatorChar = ';';
30   CommentColumn = 60;
31   CommentString = "#";
32   GlobalPrefix = "";
33   PrivateGlobalPrefix = ".";
34   LinkerPrivateGlobalPrefix = "";
35   InlineAsmStart = "APP";
36   InlineAsmEnd = "NO_APP";
37   AssemblerDialect = 0;
38   AllowQuotesInName = false;
39   AllowNameToStartWithDigit = false;
40   ZeroDirective = "\t.zero\t";
41   AsciiDirective = "\t.ascii\t";
42   AscizDirective = "\t.asciz\t";
43   Data8bitsDirective = "\t.byte\t";
44   Data16bitsDirective = "\t.short\t";
45   Data32bitsDirective = "\t.long\t";
46   Data64bitsDirective = "\t.quad\t";
47   SunStyleELFSectionSwitchSyntax = false;
48   UsesELFSectionDirectiveForBSS = false;
49   AlignDirective = "\t.align\t";
50   AlignmentIsInBytes = true;
51   TextAlignFillValue = 0;
52   JumpTableDirective = 0;
53   PICJumpTableDirective = 0;
54   GlobalDirective = "\t.globl\t";
55   SetDirective = 0;
56   LCOMMDirective = 0;
57   COMMDirective = "\t.comm\t";
58   COMMDirectiveTakesAlignment = true;
59   HasDotTypeDotSizeDirective = true;
60   HasSingleParameterDotFile = true;
61   UsedDirective = 0;
62   WeakRefDirective = 0;
63   WeakDefDirective = 0;
64   LinkOnceDirective = 0;
65   // FIXME: These are ELFish - move to ELFMAI.
66   HiddenDirective = "\t.hidden\t";
67   ProtectedDirective = "\t.protected\t";
68   AbsoluteDebugSectionOffsets = false;
69   AbsoluteEHSectionOffsets = false;
70   HasLEB128 = false;
71   HasDotLocAndDotFile = false;
72   SupportsDebugInformation = false;
73   ExceptionsType = ExceptionHandling::None;
74   DwarfRequiresFrameSection = true;
75   DwarfUsesInlineInfoSection = false;
76   Is_EHSymbolPrivate = true;
77   GlobalEHDirective = 0;
78   SupportsWeakOmittedEHFrame = true;
79   DwarfSectionOffsetDirective = 0;
80
81   AsmTransCBE = 0;
82 }
83
84 MCAsmInfo::~MCAsmInfo() {
85 }
86
87
88 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
89   unsigned Size = 0;
90   do {
91     Value >>= 7;
92     Size += sizeof(int8_t);
93   } while (Value);
94   return Size;
95 }
96
97 unsigned MCAsmInfo::getSLEB128Size(int Value) {
98   unsigned Size = 0;
99   int Sign = Value >> (8 * sizeof(Value) - 1);
100   bool IsMore;
101
102   do {
103     unsigned Byte = Value & 0x7f;
104     Value >>= 7;
105     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
106     Size += sizeof(int8_t);
107   } while (IsMore);
108   return Size;
109 }