1 //===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines target asm properties related what form asm statements
11 // should take.
12 //
13 //===----------------------------------------------------------------------===//
14
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"
21 #include <cctype>
22 #include <cstring>
23 using namespace llvm;
24
MCAsmInfo()25 MCAsmInfo::MCAsmInfo() {
26 PointerSize = 4;
27 CalleeSaveStackSlotSize = 4;
28
29 IsLittleEndian = true;
30 StackGrowsUp = false;
31 HasSubsectionsViaSymbols = false;
32 HasMachoZeroFillDirective = false;
33 HasMachoTBSSDirective = false;
34 HasStaticCtorDtorReferenceInStaticMode = false;
35 MaxInstLength = 4;
36 MinInstAlignment = 1;
37 DollarIsPC = false;
38 SeparatorString = ";";
39 CommentString = "#";
40 LabelSuffix = ":";
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";
51 AssemblerDialect = 0;
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 HasFunctionAlignment = true;
73 HasDotTypeDotSizeDirective = true;
74 HasSingleParameterDotFile = true;
75 HasIdentDirective = false;
76 HasNoDeadStrip = false;
77 WeakDirective = "\t.weak\t";
78 WeakRefDirective = nullptr;
79 HasWeakDefDirective = false;
80 HasWeakDefCanBeHiddenDirective = false;
81 HasLinkOnceDirective = false;
82 HiddenVisibilityAttr = MCSA_Hidden;
83 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
84 ProtectedVisibilityAttr = MCSA_Protected;
85 SupportsDebugInformation = false;
86 ExceptionsType = ExceptionHandling::None;
87 WinEHEncodingType = WinEH::EncodingType::Invalid;
88 DwarfUsesRelocationsAcrossSections = true;
89 DwarfFDESymbolsUseAbsDiff = false;
90 DwarfRegNumForCFI = false;
91 NeedsDwarfSectionOffsetDirective = false;
92 UseParensForSymbolVariant = false;
93
94 // FIXME: Clang's logic should be synced with the logic used to initialize
95 // this member and the two implementations should be merged.
96 // For reference:
97 // - Solaris always enables the integrated assembler by default
98 // - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
99 // - Windows always enables the integrated assembler by default
100 // - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
101 // - MachO targets always enables the integrated assembler by default
102 // - MCAsmInfoDarwin is handling this case
103 // - Generic_GCC toolchains enable the integrated assembler on a per
104 // architecture basis.
105 // - The target subclasses for AArch64, ARM, and X86 handle these cases
106 UseIntegratedAssembler = false;
107
108 CompressDebugSections = false;
109 }
110
~MCAsmInfo()111 MCAsmInfo::~MCAsmInfo() {
112 }
113
isSectionAtomizableBySymbols(const MCSection & Section) const114 bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
115 return false;
116 }
117
118 const MCExpr *
getExprForPersonalitySymbol(const MCSymbol * Sym,unsigned Encoding,MCStreamer & Streamer) const119 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
120 unsigned Encoding,
121 MCStreamer &Streamer) const {
122 return getExprForFDESymbol(Sym, Encoding, Streamer);
123 }
124
125 const MCExpr *
getExprForFDESymbol(const MCSymbol * Sym,unsigned Encoding,MCStreamer & Streamer) const126 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
127 unsigned Encoding,
128 MCStreamer &Streamer) const {
129 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
130 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
131
132 MCContext &Context = Streamer.getContext();
133 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
134 MCSymbol *PCSym = Context.CreateTempSymbol();
135 Streamer.EmitLabel(PCSym);
136 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
137 return MCBinaryExpr::CreateSub(Res, PC, Context);
138 }
139