Revert r201237+r201238: Demote EmitRawText call in AsmPrinter::EmitInlineAsm() and...
[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/MCContext.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCStreamer.h"
19 #include "llvm/Support/DataTypes.h"
20 #include "llvm/Support/Dwarf.h"
21 #include <cctype>
22 #include <cstring>
23 using namespace llvm;
24
25 MCAsmInfo::MCAsmInfo() {
26   PointerSize = 4;
27   CalleeSaveStackSlotSize = 4;
28
29   IsLittleEndian = true;
30   StackGrowsUp = false;
31   HasSubsectionsViaSymbols = false;
32   HasMachoZeroFillDirective = false;
33   HasMachoTBSSDirective = false;
34   HasStaticCtorDtorReferenceInStaticMode = false;
35   LinkerRequiresNonEmptyDwarfLines = false;
36   MaxInstLength = 4;
37   MinInstAlignment = 1;
38   DollarIsPC = false;
39   SeparatorString = ";";
40   CommentString = "#";
41   LabelSuffix = ":";
42   DebugLabelSuffix = ":";
43   PrivateGlobalPrefix = "L";
44   InlineAsmStart = "APP";
45   InlineAsmEnd = "NO_APP";
46   Code16Directive = ".code16";
47   Code32Directive = ".code32";
48   Code64Directive = ".code64";
49   AssemblerDialect = 0;
50   AllowAtInName = false;
51   UseDataRegionDirectives = false;
52   ZeroDirective = "\t.zero\t";
53   AsciiDirective = "\t.ascii\t";
54   AscizDirective = "\t.asciz\t";
55   Data8bitsDirective = "\t.byte\t";
56   Data16bitsDirective = "\t.short\t";
57   Data32bitsDirective = "\t.long\t";
58   Data64bitsDirective = "\t.quad\t";
59   SunStyleELFSectionSwitchSyntax = false;
60   UsesELFSectionDirectiveForBSS = false;
61   AlignmentIsInBytes = true;
62   TextAlignFillValue = 0;
63   GPRel64Directive = 0;
64   GPRel32Directive = 0;
65   GlobalDirective = "\t.globl\t";
66   HasSetDirective = true;
67   HasAggressiveSymbolFolding = true;
68   COMMDirectiveAlignmentIsInBytes = true;
69   LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
70   HasDotTypeDotSizeDirective = true;
71   HasSingleParameterDotFile = true;
72   HasIdentDirective = false;
73   HasNoDeadStrip = false;
74   WeakRefDirective = 0;
75   HasWeakDefDirective = false;
76   HasWeakDefCanBeHiddenDirective = false;
77   HasLinkOnceDirective = false;
78   HiddenVisibilityAttr = MCSA_Hidden;
79   HiddenDeclarationVisibilityAttr = MCSA_Hidden;
80   ProtectedVisibilityAttr = MCSA_Protected;
81   HasLEB128 = false;
82   SupportsDebugInformation = false;
83   ExceptionsType = ExceptionHandling::None;
84   DwarfUsesRelocationsAcrossSections = true;
85   DwarfFDESymbolsUseAbsDiff = false;
86   DwarfRegNumForCFI = false;
87   NeedsDwarfSectionOffsetDirective = false;
88   UseParensForSymbolVariant = false;
89 }
90
91 MCAsmInfo::~MCAsmInfo() {
92 }
93
94
95 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
96   unsigned Size = 0;
97   do {
98     Value >>= 7;
99     Size += sizeof(int8_t);
100   } while (Value);
101   return Size;
102 }
103
104 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
105   unsigned Size = 0;
106   int Sign = Value >> (8 * sizeof(Value) - 1);
107   bool IsMore;
108
109   do {
110     unsigned Byte = Value & 0x7f;
111     Value >>= 7;
112     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
113     Size += sizeof(int8_t);
114   } while (IsMore);
115   return Size;
116 }
117
118 const MCExpr *
119 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
120                                        unsigned Encoding,
121                                        MCStreamer &Streamer) const {
122   return getExprForFDESymbol(Sym, Encoding, Streamer);
123 }
124
125 const MCExpr *
126 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
127                                unsigned Encoding,
128                                MCStreamer &Streamer) const {
129   if (!(Encoding & dwarf::DW_EH_PE_pcrel))
130     return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
131
132   MCContext &Context = Streamer.getContext();
133   const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
134   MCSymbol *PCSym = Context.CreateTempSymbol();
135   Streamer.EmitLabel(PCSym);
136   const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
137   return MCBinaryExpr::CreateSub(Res, PC, Context);
138 }