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 AlignmentIsInBytes = true;
62 TextAlignFillValue = 0;
65 GlobalDirective = "\t.globl\t";
66 HasSetDirective = true;
67 HasAggressiveSymbolFolding = true;
68 COMMDirectiveAlignmentIsInBytes = true;
69 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
70 HasDotTypeDotSizeDirective = true;
71 HasSingleParameterDotFile = true;
72 HasIdentDirective = false;
73 HasNoDeadStrip = false;
75 HasWeakDefDirective = false;
76 HasWeakDefCanBeHiddenDirective = false;
77 HasLinkOnceDirective = false;
78 HiddenVisibilityAttr = MCSA_Hidden;
79 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
80 ProtectedVisibilityAttr = MCSA_Protected;
82 SupportsDebugInformation = false;
83 ExceptionsType = ExceptionHandling::None;
84 DwarfUsesRelocationsAcrossSections = true;
85 DwarfFDESymbolsUseAbsDiff = false;
86 DwarfRegNumForCFI = false;
87 NeedsDwarfSectionOffsetDirective = false;
88 UseParensForSymbolVariant = false;
91 MCAsmInfo::~MCAsmInfo() {
95 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
99 Size += sizeof(int8_t);
104 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
106 int Sign = Value >> (8 * sizeof(Value) - 1);
110 unsigned Byte = Value & 0x7f;
112 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
113 Size += sizeof(int8_t);
119 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
121 MCStreamer &Streamer) const {
122 return getExprForFDESymbol(Sym, Encoding, Streamer);
126 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
128 MCStreamer &Streamer) const {
129 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
130 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
132 MCContext &Context = Streamer.getContext();
133 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
134 MCSymbol *PCSym = Context.CreateTempSymbol();
135 Streamer.EmitLabel(PCSym);
136 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
137 return MCBinaryExpr::CreateSub(Res, PC, Context);