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;
57 UseDataRegionDirectives = false;
58 ZeroDirective = "\t.zero\t";
59 AsciiDirective = "\t.ascii\t";
60 AscizDirective = "\t.asciz\t";
61 Data8bitsDirective = "\t.byte\t";
62 Data16bitsDirective = "\t.short\t";
63 Data32bitsDirective = "\t.long\t";
64 Data64bitsDirective = "\t.quad\t";
65 SunStyleELFSectionSwitchSyntax = false;
66 UsesELFSectionDirectiveForBSS = false;
67 AlignDirective = "\t.align\t";
68 AlignmentIsInBytes = true;
69 TextAlignFillValue = 0;
72 GlobalDirective = "\t.globl\t";
73 HasSetDirective = true;
74 HasAggressiveSymbolFolding = true;
75 COMMDirectiveAlignmentIsInBytes = true;
76 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
77 HasDotTypeDotSizeDirective = true;
78 HasSingleParameterDotFile = true;
79 HasNoDeadStrip = false;
80 HasSymbolResolver = false;
83 LinkOnceDirective = 0;
84 HiddenVisibilityAttr = MCSA_Hidden;
85 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
86 ProtectedVisibilityAttr = MCSA_Protected;
88 SupportsDebugInformation = false;
89 ExceptionsType = ExceptionHandling::None;
90 DwarfUsesInlineInfoSection = false;
91 DwarfUsesRelocationsAcrossSections = true;
92 DwarfRegNumForCFI = false;
93 HasMicrosoftFastStdCallMangling = false;
94 NeedsDwarfSectionOffsetDirective = false;
97 MCAsmInfo::~MCAsmInfo() {
101 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
105 Size += sizeof(int8_t);
110 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
112 int Sign = Value >> (8 * sizeof(Value) - 1);
116 unsigned Byte = Value & 0x7f;
118 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
119 Size += sizeof(int8_t);
125 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
127 MCStreamer &Streamer) const {
128 return getExprForFDESymbol(Sym, Encoding, Streamer);
132 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
134 MCStreamer &Streamer) const {
135 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
136 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
138 MCContext &Context = Streamer.getContext();
139 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
140 MCSymbol *PCSym = Context.CreateTempSymbol();
141 Streamer.EmitLabel(PCSym);
142 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
143 return MCBinaryExpr::CreateSub(Res, PC, Context);