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 CalleeSaveStackSlotSize = 4;
29 IsLittleEndian = true;
31 HasSubsectionsViaSymbols = false;
32 HasMachoZeroFillDirective = false;
33 HasMachoTBSSDirective = false;
34 HasStaticCtorDtorReferenceInStaticMode = false;
35 LinkerRequiresNonEmptyDwarfLines = false;
39 SeparatorString = ";";
43 DebugLabelSuffix = ":";
45 PrivateGlobalPrefix = ".";
46 LinkerPrivateGlobalPrefix = "";
47 InlineAsmStart = "APP";
48 InlineAsmEnd = "NO_APP";
49 Code16Directive = ".code16";
50 Code32Directive = ".code32";
51 Code64Directive = ".code64";
53 AllowQuotesInName = false;
54 AllowNameToStartWithDigit = false;
55 AllowPeriodsInName = true;
56 AllowAtInName = false;
58 UseDataRegionDirectives = false;
59 ZeroDirective = "\t.zero\t";
60 AsciiDirective = "\t.ascii\t";
61 AscizDirective = "\t.asciz\t";
62 Data8bitsDirective = "\t.byte\t";
63 Data16bitsDirective = "\t.short\t";
64 Data32bitsDirective = "\t.long\t";
65 Data64bitsDirective = "\t.quad\t";
66 SunStyleELFSectionSwitchSyntax = false;
67 UsesELFSectionDirectiveForBSS = false;
68 AlignDirective = "\t.align\t";
69 AlignmentIsInBytes = true;
70 TextAlignFillValue = 0;
73 GlobalDirective = "\t.globl\t";
74 HasSetDirective = true;
75 HasAggressiveSymbolFolding = true;
76 COMMDirectiveAlignmentIsInBytes = true;
77 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
78 HasDotTypeDotSizeDirective = true;
79 HasSingleParameterDotFile = true;
80 HasIdentDirective = false;
81 HasNoDeadStrip = false;
82 HasSymbolResolver = false;
85 LinkOnceDirective = 0;
86 HiddenVisibilityAttr = MCSA_Hidden;
87 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
88 ProtectedVisibilityAttr = MCSA_Protected;
90 SupportsDebugInformation = false;
91 ExceptionsType = ExceptionHandling::None;
92 DwarfUsesRelocationsAcrossSections = true;
93 DwarfRegNumForCFI = false;
94 HasMicrosoftFastStdCallMangling = false;
95 NeedsDwarfSectionOffsetDirective = false;
98 MCAsmInfo::~MCAsmInfo() {
102 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
106 Size += sizeof(int8_t);
111 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
113 int Sign = Value >> (8 * sizeof(Value) - 1);
117 unsigned Byte = Value & 0x7f;
119 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
120 Size += sizeof(int8_t);
126 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
128 MCStreamer &Streamer) const {
129 return getExprForFDESymbol(Sym, Encoding, Streamer);
133 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
135 MCStreamer &Streamer) const {
136 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
137 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
139 MCContext &Context = Streamer.getContext();
140 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
141 MCSymbol *PCSym = Context.CreateTempSymbol();
142 Streamer.EmitLabel(PCSym);
143 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
144 return MCBinaryExpr::CreateSub(Res, PC, Context);