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;
38 SeparatorString = ";";
41 UseAssignmentForEHBegin = false;
42 NeedsLocalForSize = false;
43 PrivateGlobalPrefix = "L";
44 PrivateLabelPrefix = PrivateGlobalPrefix;
45 LinkerPrivateGlobalPrefix = "";
46 InlineAsmStart = "APP";
47 InlineAsmEnd = "NO_APP";
48 Code16Directive = ".code16";
49 Code32Directive = ".code32";
50 Code64Directive = ".code64";
52 AllowAtInName = false;
53 NoSymbolNameQuoting = false;
54 UseDataRegionDirectives = false;
55 ZeroDirective = "\t.zero\t";
56 AsciiDirective = "\t.ascii\t";
57 AscizDirective = "\t.asciz\t";
58 Data8bitsDirective = "\t.byte\t";
59 Data16bitsDirective = "\t.short\t";
60 Data32bitsDirective = "\t.long\t";
61 Data64bitsDirective = "\t.quad\t";
62 SunStyleELFSectionSwitchSyntax = false;
63 UsesELFSectionDirectiveForBSS = false;
64 AlignmentIsInBytes = true;
65 TextAlignFillValue = 0;
66 GPRel64Directive = nullptr;
67 GPRel32Directive = nullptr;
68 GlobalDirective = "\t.globl\t";
69 SetDirectiveSuppressesReloc = false;
70 HasAggressiveSymbolFolding = true;
71 COMMDirectiveAlignmentIsInBytes = true;
72 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
73 HasFunctionAlignment = true;
74 HasDotTypeDotSizeDirective = true;
75 HasSingleParameterDotFile = true;
76 HasIdentDirective = false;
77 HasNoDeadStrip = false;
78 WeakDirective = "\t.weak\t";
79 WeakRefDirective = nullptr;
80 HasWeakDefDirective = false;
81 HasWeakDefCanBeHiddenDirective = false;
82 HasLinkOnceDirective = false;
83 HiddenVisibilityAttr = MCSA_Hidden;
84 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
85 ProtectedVisibilityAttr = MCSA_Protected;
86 SupportsDebugInformation = false;
87 ExceptionsType = ExceptionHandling::None;
88 WinEHEncodingType = WinEH::EncodingType::Invalid;
89 DwarfUsesRelocationsAcrossSections = true;
90 DwarfFDESymbolsUseAbsDiff = false;
91 DwarfRegNumForCFI = false;
92 NeedsDwarfSectionOffsetDirective = false;
93 UseParensForSymbolVariant = false;
95 // FIXME: Clang's logic should be synced with the logic used to initialize
96 // this member and the two implementations should be merged.
98 // - Solaris always enables the integrated assembler by default
99 // - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
100 // - Windows always enables the integrated assembler by default
101 // - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
102 // - MachO targets always enables the integrated assembler by default
103 // - MCAsmInfoDarwin is handling this case
104 // - Generic_GCC toolchains enable the integrated assembler on a per
105 // architecture basis.
106 // - The target subclasses for AArch64, ARM, and X86 handle these cases
107 UseIntegratedAssembler = false;
109 CompressDebugSections = false;
112 MCAsmInfo::~MCAsmInfo() {
115 bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
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);