Remove always true flag.
[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   CommentColumn = 40;
41   CommentString = "#";
42   LabelSuffix = ":";
43   DebugLabelSuffix = ":";
44   GlobalPrefix = "";
45   PrivateGlobalPrefix = ".";
46   LinkerPrivateGlobalPrefix = "";
47   InlineAsmStart = "APP";
48   InlineAsmEnd = "NO_APP";
49   Code16Directive = ".code16";
50   Code32Directive = ".code32";
51   Code64Directive = ".code64";
52   AssemblerDialect = 0;
53   AllowQuotesInName = false;
54   AllowNameToStartWithDigit = false;
55   AllowPeriodsInName = true;
56   AllowAtInName = false;
57   UseDataRegionDirectives = false;
58   ZeroDirective = "\t.zero\t";
59   AsciiDirective = "\t.ascii\t";
60   AscizDirective = "\t.asciz\t";
61   Data8bitsDirective = "\t.byte\t";
62   Data16bitsDirective = "\t.short\t";
63   Data32bitsDirective = "\t.long\t";
64   Data64bitsDirective = "\t.quad\t";
65   SunStyleELFSectionSwitchSyntax = false;
66   UsesELFSectionDirectiveForBSS = false;
67   AlignDirective = "\t.align\t";
68   AlignmentIsInBytes = true;
69   TextAlignFillValue = 0;
70   GPRel64Directive = 0;
71   GPRel32Directive = 0;
72   GlobalDirective = "\t.globl\t";
73   HasSetDirective = true;
74   HasAggressiveSymbolFolding = true;
75   COMMDirectiveAlignmentIsInBytes = true;
76   LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
77   HasDotTypeDotSizeDirective = true;
78   HasSingleParameterDotFile = true;
79   HasIdentDirective = false;
80   HasNoDeadStrip = false;
81   WeakRefDirective = 0;
82   WeakDefDirective = 0;
83   LinkOnceDirective = 0;
84   HiddenVisibilityAttr = MCSA_Hidden;
85   HiddenDeclarationVisibilityAttr = MCSA_Hidden;
86   ProtectedVisibilityAttr = MCSA_Protected;
87   HasLEB128 = false;
88   SupportsDebugInformation = false;
89   ExceptionsType = ExceptionHandling::None;
90   DwarfUsesRelocationsAcrossSections = true;
91   DwarfRegNumForCFI = false;
92   HasMicrosoftFastStdCallMangling = false;
93   NeedsDwarfSectionOffsetDirective = false;
94 }
95
96 MCAsmInfo::~MCAsmInfo() {
97 }
98
99
100 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
101   unsigned Size = 0;
102   do {
103     Value >>= 7;
104     Size += sizeof(int8_t);
105   } while (Value);
106   return Size;
107 }
108
109 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
110   unsigned Size = 0;
111   int Sign = Value >> (8 * sizeof(Value) - 1);
112   bool IsMore;
113
114   do {
115     unsigned Byte = Value & 0x7f;
116     Value >>= 7;
117     IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
118     Size += sizeof(int8_t);
119   } while (IsMore);
120   return Size;
121 }
122
123 const MCExpr *
124 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
125                                        unsigned Encoding,
126                                        MCStreamer &Streamer) const {
127   return getExprForFDESymbol(Sym, Encoding, Streamer);
128 }
129
130 const MCExpr *
131 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
132                                unsigned Encoding,
133                                MCStreamer &Streamer) const {
134   if (!(Encoding & dwarf::DW_EH_PE_pcrel))
135     return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
136
137   MCContext &Context = Streamer.getContext();
138   const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
139   MCSymbol *PCSym = Context.CreateTempSymbol();
140   Streamer.EmitLabel(PCSym);
141   const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
142   return MCBinaryExpr::CreateSub(Res, PC, Context);
143 }