Add a target asm info hook to specify that particular bits of data in the FDE
[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 <cctype>
17 #include <cstring>
18 using namespace llvm;
19
20 MCAsmInfo::MCAsmInfo() {
21   ZeroFillDirective = 0;
22   NonexecutableStackDirective = 0;
23   NeedsSet = false;
24   MaxInstLength = 4;
25   PCSymbol = "$";
26   SeparatorChar = ';';
27   CommentColumn = 60;
28   CommentString = "#";
29   GlobalPrefix = "";
30   PrivateGlobalPrefix = ".";
31   LinkerPrivateGlobalPrefix = "";
32   JumpTableSpecialLabelPrefix = 0;
33   GlobalVarAddrPrefix = "";
34   GlobalVarAddrSuffix = "";
35   FunctionAddrPrefix = "";
36   FunctionAddrSuffix = "";
37   PersonalityPrefix = "";
38   PersonalitySuffix = "";
39   NeedsIndirectEncoding = false;
40   InlineAsmStart = "APP";
41   InlineAsmEnd = "NO_APP";
42   AssemblerDialect = 0;
43   AllowQuotesInName = false;
44   ZeroDirective = "\t.zero\t";
45   ZeroDirectiveSuffix = 0;
46   AsciiDirective = "\t.ascii\t";
47   AscizDirective = "\t.asciz\t";
48   Data8bitsDirective = "\t.byte\t";
49   Data16bitsDirective = "\t.short\t";
50   Data32bitsDirective = "\t.long\t";
51   Data64bitsDirective = "\t.quad\t";
52   SunStyleELFSectionSwitchSyntax = false;
53   UsesELFSectionDirectiveForBSS = false;
54   AlignDirective = "\t.align\t";
55   AlignmentIsInBytes = true;
56   TextAlignFillValue = 0;
57   JumpTableDirective = 0;
58   PICJumpTableDirective = 0;
59   GlobalDirective = "\t.globl\t";
60   SetDirective = 0;
61   LCOMMDirective = 0;
62   COMMDirective = "\t.comm\t";
63   COMMDirectiveTakesAlignment = true;
64   HasDotTypeDotSizeDirective = true;
65   HasSingleParameterDotFile = true;
66   UsedDirective = 0;
67   WeakRefDirective = 0;
68   WeakDefDirective = 0;
69   // FIXME: These are ELFish - move to ELFMAI.
70   HiddenDirective = "\t.hidden\t";
71   ProtectedDirective = "\t.protected\t";
72   AbsoluteDebugSectionOffsets = false;
73   AbsoluteEHSectionOffsets = false;
74   HasLEB128 = false;
75   HasDotLocAndDotFile = false;
76   SupportsDebugInformation = false;
77   ExceptionsType = ExceptionHandling::None;
78   DwarfRequiresFrameSection = true;
79   DwarfUsesInlineInfoSection = false;
80   Is_EHSymbolPrivate = true;
81   ForceEncodingOfFDETo32Bits = 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 }