1 //===- SparcMCAsmInfo.cpp - Sparc asm properties --------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains the declarations of the SparcMCAsmInfo properties.
11 //===----------------------------------------------------------------------===//
13 #include "SparcMCAsmInfo.h"
14 #include "SparcMCExpr.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/BinaryFormat/Dwarf.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCStreamer.h"
19 #include "llvm/MC/MCTargetOptions.h"
23 void SparcELFMCAsmInfo::anchor() {}
25 SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Triple
&TheTriple
) {
26 bool isV9
= (TheTriple
.getArch() == Triple::sparcv9
);
27 IsLittleEndian
= (TheTriple
.getArch() == Triple::sparcel
);
30 CodePointerSize
= CalleeSaveStackSlotSize
= 8;
33 Data16bitsDirective
= "\t.half\t";
34 Data32bitsDirective
= "\t.word\t";
35 // .xword is only supported by V9.
36 Data64bitsDirective
= (isV9
) ? "\t.xword\t" : nullptr;
37 ZeroDirective
= "\t.skip\t";
39 SupportsDebugInformation
= true;
41 ExceptionsType
= ExceptionHandling::DwarfCFI
;
43 SunStyleELFSectionSwitchSyntax
= true;
44 UsesELFSectionDirectiveForBSS
= true;
46 UseIntegratedAssembler
= true;
50 SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol
*Sym
,
52 MCStreamer
&Streamer
) const {
53 if (Encoding
& dwarf::DW_EH_PE_pcrel
) {
54 MCContext
&Ctx
= Streamer
.getContext();
55 return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32
,
56 MCSymbolRefExpr::create(Sym
, Ctx
), Ctx
);
59 return MCAsmInfo::getExprForPersonalitySymbol(Sym
, Encoding
, Streamer
);
63 SparcELFMCAsmInfo::getExprForFDESymbol(const MCSymbol
*Sym
,
65 MCStreamer
&Streamer
) const {
66 if (Encoding
& dwarf::DW_EH_PE_pcrel
) {
67 MCContext
&Ctx
= Streamer
.getContext();
68 return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32
,
69 MCSymbolRefExpr::create(Sym
, Ctx
), Ctx
);
71 return MCAsmInfo::getExprForFDESymbol(Sym
, Encoding
, Streamer
);