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 = ";";
42 DebugLabelSuffix = ":";
43 PrivateGlobalPrefix = "L";
44 InlineAsmStart = "APP";
45 InlineAsmEnd = "NO_APP";
46 Code16Directive = ".code16";
47 Code32Directive = ".code32";
48 Code64Directive = ".code64";
50 AllowAtInName = false;
51 UseDataRegionDirectives = false;
52 ZeroDirective = "\t.zero\t";
53 AsciiDirective = "\t.ascii\t";
54 AscizDirective = "\t.asciz\t";
55 Data8bitsDirective = "\t.byte\t";
56 Data16bitsDirective = "\t.short\t";
57 Data32bitsDirective = "\t.long\t";
58 Data64bitsDirective = "\t.quad\t";
59 SunStyleELFSectionSwitchSyntax = false;
60 UsesELFSectionDirectiveForBSS = false;
61 AlignDirective = "\t.align\t";
62 AlignmentIsInBytes = true;
63 TextAlignFillValue = 0;
66 GlobalDirective = "\t.globl\t";
67 HasSetDirective = true;
68 HasAggressiveSymbolFolding = true;
69 COMMDirectiveAlignmentIsInBytes = true;
70 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
71 HasDotTypeDotSizeDirective = true;
72 HasSingleParameterDotFile = true;
73 HasIdentDirective = false;
74 HasNoDeadStrip = false;
76 HasWeakDefDirective = false;
77 HasWeakDefCanBeHiddenDirective = false;
78 HasLinkOnceDirective = false;
79 HiddenVisibilityAttr = MCSA_Hidden;
80 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
81 ProtectedVisibilityAttr = MCSA_Protected;
83 SupportsDebugInformation = false;
84 ExceptionsType = ExceptionHandling::None;
85 DwarfUsesRelocationsAcrossSections = true;
86 DwarfFDESymbolsUseAbsDiff = false;
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);