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(const Triple & TheTriple)23 SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Triple &TheTriple) {
24 bool isV9 = (TheTriple.getArch() == Triple::sparcv9);
25 IsLittleEndian = (TheTriple.getArch() == Triple::sparcel);
26
27 if (isV9) {
28 PointerSize = CalleeSaveStackSlotSize = 8;
29 }
30
31 Data16bitsDirective = "\t.half\t";
32 Data32bitsDirective = "\t.word\t";
33 // .xword is only supported by V9.
34 Data64bitsDirective = (isV9) ? "\t.xword\t" : nullptr;
35 ZeroDirective = "\t.skip\t";
36 CommentString = "!";
37 SupportsDebugInformation = true;
38
39 ExceptionsType = ExceptionHandling::DwarfCFI;
40
41 SunStyleELFSectionSwitchSyntax = true;
42 UsesELFSectionDirectiveForBSS = true;
43
44 UseIntegratedAssembler = true;
45 }
46
47 const MCExpr*
getExprForPersonalitySymbol(const MCSymbol * Sym,unsigned Encoding,MCStreamer & Streamer) const48 SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
49 unsigned Encoding,
50 MCStreamer &Streamer) const {
51 if (Encoding & dwarf::DW_EH_PE_pcrel) {
52 MCContext &Ctx = Streamer.getContext();
53 return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
54 MCSymbolRefExpr::create(Sym, Ctx), Ctx);
55 }
56
57 return MCAsmInfo::getExprForPersonalitySymbol(Sym, Encoding, Streamer);
58 }
59
60 const MCExpr*
getExprForFDESymbol(const MCSymbol * Sym,unsigned Encoding,MCStreamer & Streamer) const61 SparcELFMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
62 unsigned Encoding,
63 MCStreamer &Streamer) const {
64 if (Encoding & dwarf::DW_EH_PE_pcrel) {
65 MCContext &Ctx = Streamer.getContext();
66 return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
67 MCSymbolRefExpr::create(Sym, Ctx), Ctx);
68 }
69 return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);
70 }
71