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