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() {
27 IsLittleEndian = true;
29 HasSubsectionsViaSymbols = false;
30 HasMachoZeroFillDirective = false;
31 HasMachoTBSSDirective = false;
32 StructorOutputOrder = Structors::ReversePriorityOrder;
33 HasStaticCtorDtorReferenceInStaticMode = false;
34 LinkerRequiresNonEmptyDwarfLines = false;
37 SeparatorString = ";";
42 PrivateGlobalPrefix = ".";
43 LinkerPrivateGlobalPrefix = "";
44 InlineAsmStart = "APP";
45 InlineAsmEnd = "NO_APP";
46 Code16Directive = ".code16";
47 Code32Directive = ".code32";
48 Code64Directive = ".code64";
50 AllowQuotesInName = false;
51 AllowNameToStartWithDigit = false;
52 AllowPeriodsInName = true;
53 ZeroDirective = "\t.zero\t";
54 AsciiDirective = "\t.ascii\t";
55 AscizDirective = "\t.asciz\t";
56 Data8bitsDirective = "\t.byte\t";
57 Data16bitsDirective = "\t.short\t";
58 Data32bitsDirective = "\t.long\t";
59 Data64bitsDirective = "\t.quad\t";
60 SunStyleELFSectionSwitchSyntax = false;
61 UsesELFSectionDirectiveForBSS = false;
62 AlignDirective = "\t.align\t";
63 AlignmentIsInBytes = true;
64 TextAlignFillValue = 0;
66 GlobalDirective = "\t.globl\t";
67 HasSetDirective = true;
68 HasAggressiveSymbolFolding = true;
69 LCOMMDirectiveType = LCOMM::None;
70 COMMDirectiveAlignmentIsInBytes = true;
71 HasDotTypeDotSizeDirective = true;
72 HasSingleParameterDotFile = true;
73 HasNoDeadStrip = false;
74 HasSymbolResolver = false;
77 LinkOnceDirective = 0;
78 HiddenVisibilityAttr = MCSA_Hidden;
79 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
80 ProtectedVisibilityAttr = MCSA_Protected;
82 SupportsDebugInformation = false;
83 ExceptionsType = ExceptionHandling::None;
84 DwarfUsesInlineInfoSection = false;
85 DwarfRequiresRelocationForSectionOffset = true;
86 DwarfSectionOffsetDirective = 0;
87 DwarfUsesLabelOffsetForRanges = true;
88 DwarfRegNumForCFI = false;
89 HasMicrosoftFastStdCallMangling = false;
94 MCAsmInfo::~MCAsmInfo() {
98 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
102 Size += sizeof(int8_t);
107 unsigned MCAsmInfo::getSLEB128Size(int Value) {
109 int Sign = Value >> (8 * sizeof(Value) - 1);
113 unsigned Byte = Value & 0x7f;
115 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
116 Size += sizeof(int8_t);
122 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
124 MCStreamer &Streamer) const {
125 return getExprForFDESymbol(Sym, Encoding, Streamer);
129 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
131 MCStreamer &Streamer) const {
132 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
133 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
135 MCContext &Context = Streamer.getContext();
136 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
137 MCSymbol *PCSym = Context.CreateTempSymbol();
138 Streamer.EmitLabel(PCSym);
139 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
140 return MCBinaryExpr::CreateSub(Res, PC, Context);