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";
46 AllowQuotesInName = false;
47 AllowNameToStartWithDigit = false;
48 AllowPeriodsInName = true;
49 ZeroDirective = "\t.zero\t";
50 AsciiDirective = "\t.ascii\t";
51 AscizDirective = "\t.asciz\t";
52 Data8bitsDirective = "\t.byte\t";
53 Data16bitsDirective = "\t.short\t";
54 Data32bitsDirective = "\t.long\t";
55 Data64bitsDirective = "\t.quad\t";
56 SunStyleELFSectionSwitchSyntax = false;
57 UsesELFSectionDirectiveForBSS = false;
58 AlignDirective = "\t.align\t";
59 AlignmentIsInBytes = true;
60 TextAlignFillValue = 0;
62 GlobalDirective = "\t.globl\t";
63 HasSetDirective = true;
64 HasAggressiveSymbolFolding = true;
65 HasLCOMMDirective = false;
66 COMMDirectiveAlignmentIsInBytes = true;
67 HasDotTypeDotSizeDirective = true;
68 HasSingleParameterDotFile = true;
69 HasNoDeadStrip = false;
70 HasSymbolResolver = false;
73 LinkOnceDirective = 0;
74 HiddenVisibilityAttr = MCSA_Hidden;
75 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
76 ProtectedVisibilityAttr = MCSA_Protected;
78 SupportsDebugInformation = false;
79 ExceptionsType = ExceptionHandling::None;
80 DwarfUsesInlineInfoSection = false;
81 DwarfRequiresRelocationForSectionOffset = true;
82 DwarfSectionOffsetDirective = 0;
83 DwarfUsesLabelOffsetForRanges = true;
84 DwarfRegNumForCFI = false;
85 HasMicrosoftFastStdCallMangling = false;
90 MCAsmInfo::~MCAsmInfo() {
94 unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
98 Size += sizeof(int8_t);
103 unsigned MCAsmInfo::getSLEB128Size(int Value) {
105 int Sign = Value >> (8 * sizeof(Value) - 1);
109 unsigned Byte = Value & 0x7f;
111 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
112 Size += sizeof(int8_t);
118 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
120 MCStreamer &Streamer) const {
121 return getExprForFDESymbol(Sym, Encoding, Streamer);
125 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
127 MCStreamer &Streamer) const {
128 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
129 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
131 MCContext &Context = Streamer.getContext();
132 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
133 MCSymbol *PCSym = Context.CreateTempSymbol();
134 Streamer.EmitLabel(PCSym);
135 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
136 return MCBinaryExpr::CreateSub(Res, PC, Context);