1 //===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines target asm properties related what form asm statements
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"
25 MCAsmInfo::MCAsmInfo() {
26 HasSubsectionsViaSymbols = false;
27 HasMachoZeroFillDirective = false;
28 HasMachoTBSSDirective = false;
29 HasStaticCtorDtorReferenceInStaticMode = false;
30 LinkerRequiresNonEmptyDwarfLines = false;
33 SeparatorString = ";";
38 PrivateGlobalPrefix = ".";
39 LinkerPrivateGlobalPrefix = "";
40 InlineAsmStart = "APP";
41 InlineAsmEnd = "NO_APP";
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;
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;
70 LinkOnceDirective = 0;
71 HiddenVisibilityAttr = MCSA_Hidden;
72 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
73 ProtectedVisibilityAttr = MCSA_Protected;
75 SupportsDebugInformation = false;
76 ExceptionsType = ExceptionHandling::None;
77 DwarfUsesInlineInfoSection = false;
78 DwarfRequiresRelocationForSectionOffset = true;
79 DwarfSectionOffsetDirective = 0;
80 DwarfUsesLabelOffsetForRanges = true;
81 HasMicrosoftFastStdCallMangling = false;
86 MCAsmInfo::~MCAsmInfo() {
90 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
94 Size += sizeof(int8_t);
99 unsigned MCAsmInfo::getSLEB128Size(int Value) {
101 int Sign = Value >> (8 * sizeof(Value) - 1);
105 unsigned Byte = Value & 0x7f;
107 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
108 Size += sizeof(int8_t);
114 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
116 MCStreamer &Streamer) const {
117 return getExprForFDESymbol(Sym, Encoding, Streamer);
121 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
123 MCStreamer &Streamer) const {
124 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
125 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
127 MCContext &Context = Streamer.getContext();
128 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
129 MCSymbol *PCSym = Context.CreateTempSymbol();
130 Streamer.EmitLabel(PCSym);
131 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
132 return MCBinaryExpr::CreateSub(Res, PC, Context);