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 = "L";
46 LinkerPrivateGlobalPrefix = "";
47 InlineAsmStart = "APP";
48 InlineAsmEnd = "NO_APP";
49 Code16Directive = ".code16";
50 Code32Directive = ".code32";
51 Code64Directive = ".code64";
53 AllowAtInName = false;
54 UseDataRegionDirectives = false;
55 ZeroDirective = "\t.zero\t";
56 AsciiDirective = "\t.ascii\t";
57 AscizDirective = "\t.asciz\t";
58 Data8bitsDirective = "\t.byte\t";
59 Data16bitsDirective = "\t.short\t";
60 Data32bitsDirective = "\t.long\t";
61 Data64bitsDirective = "\t.quad\t";
62 SunStyleELFSectionSwitchSyntax = false;
63 UsesELFSectionDirectiveForBSS = false;
64 AlignDirective = "\t.align\t";
65 AlignmentIsInBytes = true;
66 TextAlignFillValue = 0;
69 GlobalDirective = "\t.globl\t";
70 HasSetDirective = true;
71 HasAggressiveSymbolFolding = true;
72 COMMDirectiveAlignmentIsInBytes = true;
73 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
74 HasDotTypeDotSizeDirective = true;
75 HasSingleParameterDotFile = true;
76 HasIdentDirective = false;
77 HasNoDeadStrip = false;
79 HasWeakDefDirective = false;
80 HasLinkOnceDirective = false;
81 HiddenVisibilityAttr = MCSA_Hidden;
82 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
83 ProtectedVisibilityAttr = MCSA_Protected;
85 SupportsDebugInformation = false;
86 ExceptionsType = ExceptionHandling::None;
87 DwarfUsesRelocationsAcrossSections = true;
88 DwarfRegNumForCFI = false;
89 HasMicrosoftFastStdCallMangling = false;
90 NeedsDwarfSectionOffsetDirective = false;
91 UseParensForSymbolVariant = false;
94 MCAsmInfo::~MCAsmInfo() {
98 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
102 Size += sizeof(int8_t);
107 unsigned MCAsmInfo::getSLEB128Size(int64_t 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);