1 //===-- SparcMCAsmInfo.cpp - Sparc asm properties -------------------------===//
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 contains the declarations of the SparcMCAsmInfo properties.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "SparcMCAsmInfo.h"
15 #include "SparcMCExpr.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/MC/MCStreamer.h"
18
19 using namespace llvm;
20
anchor()21 void SparcELFMCAsmInfo::anchor() { }
22
SparcELFMCAsmInfo(StringRef TT)23 SparcELFMCAsmInfo::SparcELFMCAsmInfo(StringRef TT) {
24 IsLittleEndian = false;
25 Triple TheTriple(TT);
26 bool isV9 = (TheTriple.getArch() == Triple::sparcv9);
27
28 if (isV9) {
29 PointerSize = CalleeSaveStackSlotSize = 8;
30 }
31
32 Data16bitsDirective = "\t.half\t";
33 Data32bitsDirective = "\t.word\t";
34 // .xword is only supported by V9.
35 Data64bitsDirective = (isV9) ? "\t.xword\t" : nullptr;
36 ZeroDirective = "\t.skip\t";
37 CommentString = "!";
38 SupportsDebugInformation = true;
39
40 ExceptionsType = ExceptionHandling::DwarfCFI;
41
42 SunStyleELFSectionSwitchSyntax = true;
43 UsesELFSectionDirectiveForBSS = true;
44
45 UseIntegratedAssembler = true;
46 }
47
48 const MCExpr*
getExprForPersonalitySymbol(const MCSymbol * Sym,unsigned Encoding,MCStreamer & Streamer) const49 SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
50 unsigned Encoding,
51 MCStreamer &Streamer) const {
52 if (Encoding & dwarf::DW_EH_PE_pcrel) {
53 MCContext &Ctx = Streamer.getContext();
54 return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32,
55 MCSymbolRefExpr::Create(Sym, Ctx), Ctx);
56 }
57
58 return MCAsmInfo::getExprForPersonalitySymbol(Sym, Encoding, Streamer);
59 }
60
61 const MCExpr*
getExprForFDESymbol(const MCSymbol * Sym,unsigned Encoding,MCStreamer & Streamer) const62 SparcELFMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
63 unsigned Encoding,
64 MCStreamer &Streamer) const {
65 if (Encoding & dwarf::DW_EH_PE_pcrel) {
66 MCContext &Ctx = Streamer.getContext();
67 return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32,
68 MCSymbolRefExpr::Create(Sym, Ctx), Ctx);
69 }
70 return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);
71 }
72