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 = ":";
44 PrivateGlobalPrefix = "L";
45 InlineAsmStart = "APP";
46 InlineAsmEnd = "NO_APP";
47 Code16Directive = ".code16";
48 Code32Directive = ".code32";
49 Code64Directive = ".code64";
51 AllowAtInName = false;
52 UseDataRegionDirectives = false;
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;
67 GlobalDirective = "\t.globl\t";
68 HasSetDirective = true;
69 HasAggressiveSymbolFolding = true;
70 COMMDirectiveAlignmentIsInBytes = true;
71 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
72 HasDotTypeDotSizeDirective = true;
73 HasSingleParameterDotFile = true;
74 HasIdentDirective = false;
75 HasNoDeadStrip = false;
77 HasWeakDefDirective = false;
78 HasWeakDefCanBeHiddenDirective = false;
79 HasLinkOnceDirective = false;
80 HiddenVisibilityAttr = MCSA_Hidden;
81 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
82 ProtectedVisibilityAttr = MCSA_Protected;
84 SupportsDebugInformation = false;
85 ExceptionsType = ExceptionHandling::None;
86 DwarfUsesRelocationsAcrossSections = true;
87 DwarfRegNumForCFI = false;
88 NeedsDwarfSectionOffsetDirective = false;
89 UseParensForSymbolVariant = false;
92 MCAsmInfo::~MCAsmInfo() {
96 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
100 Size += sizeof(int8_t);
105 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
107 int Sign = Value >> (8 * sizeof(Value) - 1);
111 unsigned Byte = Value & 0x7f;
113 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
114 Size += sizeof(int8_t);
120 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
122 MCStreamer &Streamer) const {
123 return getExprForFDESymbol(Sym, Encoding, Streamer);
127 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
129 MCStreamer &Streamer) const {
130 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
131 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
133 MCContext &Context = Streamer.getContext();
134 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
135 MCSymbol *PCSym = Context.CreateTempSymbol();
136 Streamer.EmitLabel(PCSym);
137 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
138 return MCBinaryExpr::CreateSub(Res, PC, Context);