Use BranchProbability instead of floating points in IfConverter.
[llvm/stm8.git] / lib / MC / MCAsmInfo.cpp
blobb8ce24b78f4ca8d18434cf7dbf85662dfc9c3628
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.
13 //===----------------------------------------------------------------------===//
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;
25 MCAsmInfo::MCAsmInfo() {
26 HasSubsectionsViaSymbols = false;
27 HasMachoZeroFillDirective = false;
28 HasMachoTBSSDirective = false;
29 HasStaticCtorDtorReferenceInStaticMode = false;
30 LinkerRequiresNonEmptyDwarfLines = false;
31 MaxInstLength = 4;
32 PCSymbol = "$";
33 SeparatorString = ";";
34 CommentColumn = 40;
35 CommentString = "#";
36 LabelSuffix = ":";
37 GlobalPrefix = "";
38 PrivateGlobalPrefix = ".";
39 LinkerPrivateGlobalPrefix = "";
40 InlineAsmStart = "APP";
41 InlineAsmEnd = "NO_APP";
42 AssemblerDialect = 0;
43 AllowQuotesInName = false;
44 AllowNameToStartWithDigit = false;
45 AllowPeriodsInName = true;
46 ZeroDirective = "\t.zero\t";
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 GPRel32Directive = 0;
59 GlobalDirective = "\t.globl\t";
60 HasSetDirective = true;
61 HasAggressiveSymbolFolding = true;
62 HasLCOMMDirective = false;
63 COMMDirectiveAlignmentIsInBytes = true;
64 HasDotTypeDotSizeDirective = true;
65 HasSingleParameterDotFile = true;
66 HasNoDeadStrip = false;
67 HasSymbolResolver = false;
68 WeakRefDirective = 0;
69 WeakDefDirective = 0;
70 LinkOnceDirective = 0;
71 HiddenVisibilityAttr = MCSA_Hidden;
72 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
73 ProtectedVisibilityAttr = MCSA_Protected;
74 HasLEB128 = false;
75 SupportsDebugInformation = false;
76 ExceptionsType = ExceptionHandling::None;
77 DwarfUsesInlineInfoSection = false;
78 DwarfRequiresRelocationForSectionOffset = true;
79 DwarfSectionOffsetDirective = 0;
80 DwarfUsesLabelOffsetForRanges = true;
81 DwarfRegNumForCFI = false;
82 HasMicrosoftFastStdCallMangling = false;
84 AsmTransCBE = 0;
87 MCAsmInfo::~MCAsmInfo() {
91 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
92 unsigned Size = 0;
93 do {
94 Value >>= 7;
95 Size += sizeof(int8_t);
96 } while (Value);
97 return Size;
100 unsigned MCAsmInfo::getSLEB128Size(int Value) {
101 unsigned Size = 0;
102 int Sign = Value >> (8 * sizeof(Value) - 1);
103 bool IsMore;
105 do {
106 unsigned Byte = Value & 0x7f;
107 Value >>= 7;
108 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
109 Size += sizeof(int8_t);
110 } while (IsMore);
111 return Size;
114 const MCExpr *
115 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
116 unsigned Encoding,
117 MCStreamer &Streamer) const {
118 return getExprForFDESymbol(Sym, Encoding, Streamer);
121 const MCExpr *
122 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
123 unsigned Encoding,
124 MCStreamer &Streamer) const {
125 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
126 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
128 MCContext &Context = Streamer.getContext();
129 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
130 MCSymbol *PCSym = Context.CreateTempSymbol();
131 Streamer.EmitLabel(PCSym);
132 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
133 return MCBinaryExpr::CreateSub(Res, PC, Context);