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