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;
90 // FIXME: Clang's logic should be synced with the logic used to initialize
91 // this member and the two implementations should be merged.
93 // - Solaris always enables the integrated assembler by default
94 // - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
95 // - Windows always enables the integrated assembler by default
96 // - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
97 // - MachO targets always enables the integrated assembler by default
98 // - MCAsmInfoDarwin is handling this case
99 // - Generic_GCC toolchains enable the integrated assembler on a per
100 // architecture basis.
101 // - The target subclasses for AArch64, ARM, and X86 handle these cases
102 UseIntegratedAssembler = false;
105 MCAsmInfo::~MCAsmInfo() {
109 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
113 Size += sizeof(int8_t);
118 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
120 int Sign = Value >> (8 * sizeof(Value) - 1);
124 unsigned Byte = Value & 0x7f;
126 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
127 Size += sizeof(int8_t);
133 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
135 MCStreamer &Streamer) const {
136 return getExprForFDESymbol(Sym, Encoding, Streamer);
140 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
142 MCStreamer &Streamer) const {
143 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
144 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
146 MCContext &Context = Streamer.getContext();
147 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
148 MCSymbol *PCSym = Context.CreateTempSymbol();
149 Streamer.EmitLabel(PCSym);
150 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
151 return MCBinaryExpr::CreateSub(Res, PC, Context);