b685c1a264c28702280092ea5fd07f37b4dc7754
[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/MC/MCExpr.h"
17 #include "llvm/MC/MCStreamer.h"
18 #include "llvm/Support/DataTypes.h"
19 #include <cctype>
20 #include <cstring>
21 using namespace llvm;
22
23 MCAsmInfo::MCAsmInfo() {
24   HasSubsectionsViaSymbols = false;
25   HasMachoZeroFillDirective = false;
26   HasMachoTBSSDirective = false;
27   HasStaticCtorDtorReferenceInStaticMode = false;
28   LinkerRequiresNonEmptyDwarfLines = false;
29   MaxInstLength = 4;
30   PCSymbol = "$";
31   SeparatorString = ";";
32   CommentColumn = 40;
33   CommentString = "#";
34   LabelSuffix = ":";
35   GlobalPrefix = "";
36   PrivateGlobalPrefix = ".";
37   LinkerPrivateGlobalPrefix = "";
38   InlineAsmStart = "APP";
39   InlineAsmEnd = "NO_APP";
40   AssemblerDialect = 0;
41   AllowQuotesInName = false;
42   AllowNameToStartWithDigit = false;
43   AllowPeriodsInName = true;
44   ZeroDirective = "\t.zero\t";
45   AsciiDirective = "\t.ascii\t";
46   AscizDirective = "\t.asciz\t";
47   Data8bitsDirective = "\t.byte\t";
48   Data16bitsDirective = "\t.short\t";
49   Data32bitsDirective = "\t.long\t";
50   Data64bitsDirective = "\t.quad\t";
51   SunStyleELFSectionSwitchSyntax = false;
52   UsesELFSectionDirectiveForBSS = false;
53   AlignDirective = "\t.align\t";
54   AlignmentIsInBytes = true;
55   TextAlignFillValue = 0;
56   GPRel32Directive = 0;
57   GlobalDirective = "\t.globl\t";
58   HasSetDirective = true;
59   HasAggressiveSymbolFolding = true;
60   HasLCOMMDirective = false;
61   COMMDirectiveAlignmentIsInBytes = true;
62   HasDotTypeDotSizeDirective = true;
63   HasSingleParameterDotFile = true;
64   HasNoDeadStrip = false;
65   HasSymbolResolver = false;
66   WeakRefDirective = 0;
67   WeakDefDirective = 0;
68   LinkOnceDirective = 0;
69   HiddenVisibilityAttr = MCSA_Hidden;
70   HiddenDeclarationVisibilityAttr = MCSA_Hidden;
71   ProtectedVisibilityAttr = MCSA_Protected;
72   HasLEB128 = false;
73   SupportsDebugInformation = false;
74   ExceptionsType = ExceptionHandling::None;
75   DwarfRequiresFrameSection = true;
76   DwarfUsesInlineInfoSection = false;
77   DwarfUsesAbsoluteLabelForStmtList = true;
78   DwarfSectionOffsetDirective = 0;
79   DwarfUsesLabelOffsetForRanges = true;
80   HasMicrosoftFastStdCallMangling = false;
81
82   AsmTransCBE = 0;
83 }
84
85 MCAsmInfo::~MCAsmInfo() {
86 }
87
88
89 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
90   unsigned Size = 0;
91   do {
92     Value >>= 7;
93     Size += sizeof(int8_t);
94   } while (Value);
95   return Size;
96 }
97
98 unsigned MCAsmInfo::getSLEB128Size(int Value) {
99   unsigned Size = 0;
100   int Sign = Value >> (8 * sizeof(Value) - 1);
101   bool IsMore;
102
103   do {
104     unsigned Byte = Value & 0x7f;
105     Value >>= 7;
106     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
107     Size += sizeof(int8_t);
108   } while (IsMore);
109   return Size;
110 }
111
112 const MCExpr *
113 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
114                                        MCStreamer &Streamer) const {
115   return getExprForFDESymbol(Sym, Streamer);
116 }
117
118 const MCExpr *
119 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
120                                MCStreamer &Streamer) const {
121   return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
122 }