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 DwarfRequiresFrameSection = true;
78 DwarfUsesInlineInfoSection = false;
79 DwarfRequiresRelocationForStmtList = true;
80 DwarfSectionOffsetDirective = 0;
81 DwarfUsesLabelOffsetForRanges = true;
82 HasMicrosoftFastStdCallMangling = false;
87 MCAsmInfo::~MCAsmInfo() {
91 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
95 Size += sizeof(int8_t);
100 unsigned MCAsmInfo::getSLEB128Size(int Value) {
102 int Sign = Value >> (8 * sizeof(Value) - 1);
106 unsigned Byte = Value & 0x7f;
108 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
109 Size += sizeof(int8_t);
115 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
117 MCStreamer &Streamer) const {
118 return getExprForFDESymbol(Sym, Encoding, Streamer);
122 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
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);