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;
38 SeparatorString = ";";
42 DebugLabelSuffix = ":";
44 PrivateGlobalPrefix = ".";
45 LinkerPrivateGlobalPrefix = "";
46 InlineAsmStart = "APP";
47 InlineAsmEnd = "NO_APP";
48 Code16Directive = ".code16";
49 Code32Directive = ".code32";
50 Code64Directive = ".code64";
52 AllowQuotesInName = false;
53 AllowNameToStartWithDigit = false;
54 AllowPeriodsInName = true;
56 UseDataRegionDirectives = false;
57 ZeroDirective = "\t.zero\t";
58 AsciiDirective = "\t.ascii\t";
59 AscizDirective = "\t.asciz\t";
60 Data8bitsDirective = "\t.byte\t";
61 Data16bitsDirective = "\t.short\t";
62 Data32bitsDirective = "\t.long\t";
63 Data64bitsDirective = "\t.quad\t";
64 SunStyleELFSectionSwitchSyntax = false;
65 UsesELFSectionDirectiveForBSS = false;
66 AlignDirective = "\t.align\t";
67 AlignmentIsInBytes = true;
68 TextAlignFillValue = 0;
71 GlobalDirective = "\t.globl\t";
72 HasSetDirective = true;
73 HasAggressiveSymbolFolding = true;
74 COMMDirectiveAlignmentIsInBytes = true;
75 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
76 HasDotTypeDotSizeDirective = true;
77 HasSingleParameterDotFile = true;
78 HasNoDeadStrip = false;
79 HasSymbolResolver = false;
82 LinkOnceDirective = 0;
83 HiddenVisibilityAttr = MCSA_Hidden;
84 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
85 ProtectedVisibilityAttr = MCSA_Protected;
87 SupportsDebugInformation = false;
88 ExceptionsType = ExceptionHandling::None;
89 DwarfUsesRelocationsAcrossSections = true;
90 DwarfRegNumForCFI = false;
91 HasMicrosoftFastStdCallMangling = false;
92 NeedsDwarfSectionOffsetDirective = false;
95 MCAsmInfo::~MCAsmInfo() {
99 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
103 Size += sizeof(int8_t);
108 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
110 int Sign = Value >> (8 * sizeof(Value) - 1);
114 unsigned Byte = Value & 0x7f;
116 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
117 Size += sizeof(int8_t);
123 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
125 MCStreamer &Streamer) const {
126 return getExprForFDESymbol(Sym, Encoding, Streamer);
130 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
132 MCStreamer &Streamer) const {
133 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
134 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
136 MCContext &Context = Streamer.getContext();
137 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
138 MCSymbol *PCSym = Context.CreateTempSymbol();
139 Streamer.EmitLabel(PCSym);
140 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
141 return MCBinaryExpr::CreateSub(Res, PC, Context);