[NVPTX] Do not emit .weak symbols for NVPTX
[oota-llvm.git] / 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   LinkerPrivateGlobalPrefix = "";
44   InlineAsmStart = "APP";
45   InlineAsmEnd = "NO_APP";
46   Code16Directive = ".code16";
47   Code32Directive = ".code32";
48   Code64Directive = ".code64";
49   AssemblerDialect = 0;
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;
63   GPRel64Directive = nullptr;
64   GPRel32Directive = nullptr;
65   GlobalDirective = "\t.globl\t";
66   SetDirectiveSuppressesReloc = false;
67   HasAggressiveSymbolFolding = true;
68   COMMDirectiveAlignmentIsInBytes = true;
69   LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
70   HasDotTypeDotSizeDirective = true;
71   HasSingleParameterDotFile = true;
72   HasIdentDirective = false;
73   HasNoDeadStrip = false;
74   WeakDirective = "\t.weak\t";
75   WeakRefDirective = nullptr;
76   HasWeakDefDirective = false;
77   HasWeakDefCanBeHiddenDirective = false;
78   HasLinkOnceDirective = false;
79   HiddenVisibilityAttr = MCSA_Hidden;
80   HiddenDeclarationVisibilityAttr = MCSA_Hidden;
81   ProtectedVisibilityAttr = MCSA_Protected;
82   SupportsDebugInformation = false;
83   ExceptionsType = ExceptionHandling::None;
84   WinEHEncodingType = WinEH::EncodingType::Invalid;
85   DwarfUsesRelocationsAcrossSections = true;
86   DwarfFDESymbolsUseAbsDiff = false;
87   DwarfRegNumForCFI = false;
88   NeedsDwarfSectionOffsetDirective = false;
89   UseParensForSymbolVariant = false;
90
91   // FIXME: Clang's logic should be synced with the logic used to initialize
92   //        this member and the two implementations should be merged.
93   // For reference:
94   // - Solaris always enables the integrated assembler by default
95   //   - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
96   // - Windows always enables the integrated assembler by default
97   //   - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
98   // - MachO targets always enables the integrated assembler by default
99   //   - MCAsmInfoDarwin is handling this case
100   // - Generic_GCC toolchains enable the integrated assembler on a per
101   //   architecture basis.
102   //   - The target subclasses for AArch64, ARM, and X86 handle these cases
103   UseIntegratedAssembler = false;
104
105   CompressDebugSections = false;
106 }
107
108 MCAsmInfo::~MCAsmInfo() {
109 }
110
111 const MCExpr *
112 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
113                                        unsigned Encoding,
114                                        MCStreamer &Streamer) const {
115   return getExprForFDESymbol(Sym, Encoding, Streamer);
116 }
117
118 const MCExpr *
119 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
120                                unsigned Encoding,
121                                MCStreamer &Streamer) const {
122   if (!(Encoding & dwarf::DW_EH_PE_pcrel))
123     return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
124
125   MCContext &Context = Streamer.getContext();
126   const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
127   MCSymbol *PCSym = Context.CreateTempSymbol();
128   Streamer.EmitLabel(PCSym);
129   const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
130   return MCBinaryExpr::CreateSub(Res, PC, Context);
131 }