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 IsLittleEndian = true;
29 HasSubsectionsViaSymbols = false;
30 HasMachoZeroFillDirective = false;
31 HasMachoTBSSDirective = false;
32 HasStaticCtorDtorReferenceInStaticMode = false;
33 LinkerRequiresNonEmptyDwarfLines = false;
36 SeparatorString = ";";
41 PrivateGlobalPrefix = ".";
42 LinkerPrivateGlobalPrefix = "";
43 InlineAsmStart = "APP";
44 InlineAsmEnd = "NO_APP";
45 Code16Directive = ".code16";
46 Code32Directive = ".code32";
47 Code64Directive = ".code64";
49 AllowQuotesInName = false;
50 AllowNameToStartWithDigit = false;
51 AllowPeriodsInName = true;
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;
65 GlobalDirective = "\t.globl\t";
66 HasSetDirective = true;
67 HasAggressiveSymbolFolding = true;
68 HasLCOMMDirective = false;
69 COMMDirectiveAlignmentIsInBytes = true;
70 HasDotTypeDotSizeDirective = true;
71 HasSingleParameterDotFile = true;
72 HasNoDeadStrip = false;
73 HasSymbolResolver = false;
76 LinkOnceDirective = 0;
77 HiddenVisibilityAttr = MCSA_Hidden;
78 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
79 ProtectedVisibilityAttr = MCSA_Protected;
81 SupportsDebugInformation = false;
82 ExceptionsType = ExceptionHandling::None;
83 DwarfUsesInlineInfoSection = false;
84 DwarfRequiresRelocationForSectionOffset = true;
85 DwarfSectionOffsetDirective = 0;
86 DwarfUsesLabelOffsetForRanges = true;
87 DwarfRegNumForCFI = false;
88 HasMicrosoftFastStdCallMangling = false;
93 MCAsmInfo::~MCAsmInfo() {
97 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
101 Size += sizeof(int8_t);
106 unsigned MCAsmInfo::getSLEB128Size(int Value) {
108 int Sign = Value >> (8 * sizeof(Value) - 1);
112 unsigned Byte = Value & 0x7f;
114 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
115 Size += sizeof(int8_t);
121 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
123 MCStreamer &Streamer) const {
124 return getExprForFDESymbol(Sym, Encoding, Streamer);
128 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
130 MCStreamer &Streamer) const {
131 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
132 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
134 MCContext &Context = Streamer.getContext();
135 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
136 MCSymbol *PCSym = Context.CreateTempSymbol();
137 Streamer.EmitLabel(PCSym);
138 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
139 return MCBinaryExpr::CreateSub(Res, PC, Context);