Revert last patch. We need to put this into TargetLowering. There will be a lot
[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   GlobalEHDirective = 0;
83   SupportsWeakOmittedEHFrame = true;
84   DwarfSectionOffsetDirective = 0;
85
86   AsmTransCBE = 0;
87 }
88
89 MCAsmInfo::~MCAsmInfo() {
90 }
91
92
93 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
94   unsigned Size = 0;
95   do {
96     Value >>= 7;
97     Size += sizeof(int8_t);
98   } while (Value);
99   return Size;
100 }
101
102 unsigned MCAsmInfo::getSLEB128Size(int Value) {
103   unsigned Size = 0;
104   int Sign = Value >> (8 * sizeof(Value) - 1);
105   bool IsMore;
106
107   do {
108     unsigned Byte = Value & 0x7f;
109     Value >>= 7;
110     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
111     Size += sizeof(int8_t);
112   } while (IsMore);
113   return Size;
114 }