]> git.proxmox.com Git - rustc.git/blob - src/llvm/lib/MC/MCAsmInfo.cpp
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / lib / MC / MCAsmInfo.cpp
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
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 PrivateGlobalPrefix = "L";
43 PrivateLabelPrefix = PrivateGlobalPrefix;
44 LinkerPrivateGlobalPrefix = "";
45 InlineAsmStart = "APP";
46 InlineAsmEnd = "NO_APP";
47 Code16Directive = ".code16";
48 Code32Directive = ".code32";
49 Code64Directive = ".code64";
50 AssemblerDialect = 0;
51 AllowAtInName = false;
52 UseDataRegionDirectives = false;
53 ZeroDirective = "\t.zero\t";
54 AsciiDirective = "\t.ascii\t";
55 AscizDirective = "\t.asciz\t";
56 Data8bitsDirective = "\t.byte\t";
57 Data16bitsDirective = "\t.short\t";
58 Data32bitsDirective = "\t.long\t";
59 Data64bitsDirective = "\t.quad\t";
60 SunStyleELFSectionSwitchSyntax = false;
61 UsesELFSectionDirectiveForBSS = false;
62 AlignmentIsInBytes = true;
63 TextAlignFillValue = 0;
64 GPRel64Directive = nullptr;
65 GPRel32Directive = nullptr;
66 GlobalDirective = "\t.globl\t";
67 SetDirectiveSuppressesReloc = false;
68 HasAggressiveSymbolFolding = true;
69 COMMDirectiveAlignmentIsInBytes = true;
70 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
71 HasDotTypeDotSizeDirective = true;
72 HasSingleParameterDotFile = true;
73 HasIdentDirective = false;
74 HasNoDeadStrip = false;
75 WeakDirective = "\t.weak\t";
76 WeakRefDirective = nullptr;
77 HasWeakDefDirective = false;
78 HasWeakDefCanBeHiddenDirective = false;
79 HasLinkOnceDirective = false;
80 HiddenVisibilityAttr = MCSA_Hidden;
81 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
82 ProtectedVisibilityAttr = MCSA_Protected;
83 SupportsDebugInformation = false;
84 ExceptionsType = ExceptionHandling::None;
85 WinEHEncodingType = WinEH::EncodingType::Invalid;
86 DwarfUsesRelocationsAcrossSections = true;
87 DwarfFDESymbolsUseAbsDiff = false;
88 DwarfRegNumForCFI = false;
89 NeedsDwarfSectionOffsetDirective = false;
90 UseParensForSymbolVariant = false;
91
92 // FIXME: Clang's logic should be synced with the logic used to initialize
93 // this member and the two implementations should be merged.
94 // For reference:
95 // - Solaris always enables the integrated assembler by default
96 // - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
97 // - Windows always enables the integrated assembler by default
98 // - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
99 // - MachO targets always enables the integrated assembler by default
100 // - MCAsmInfoDarwin is handling this case
101 // - Generic_GCC toolchains enable the integrated assembler on a per
102 // architecture basis.
103 // - The target subclasses for AArch64, ARM, and X86 handle these cases
104 UseIntegratedAssembler = false;
105
106 CompressDebugSections = false;
107 }
108
109 MCAsmInfo::~MCAsmInfo() {
110 }
111
112 bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
113 return false;
114 }
115
116 const MCExpr *
117 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
118 unsigned Encoding,
119 MCStreamer &Streamer) const {
120 return getExprForFDESymbol(Sym, Encoding, Streamer);
121 }
122
123 const MCExpr *
124 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
125 unsigned Encoding,
126 MCStreamer &Streamer) const {
127 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
128 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
129
130 MCContext &Context = Streamer.getContext();
131 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
132 MCSymbol *PCSym = Context.CreateTempSymbol();
133 Streamer.EmitLabel(PCSym);
134 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
135 return MCBinaryExpr::CreateSub(Res, PC, Context);
136 }