1//===- SparcMCAsmInfo.cpp - Sparc asm properties --------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the declarations of the SparcMCAsmInfo properties.
10//
11//===----------------------------------------------------------------------===//
12
13#include "SparcMCAsmInfo.h"
14#include "llvm/BinaryFormat/Dwarf.h"
15#include "llvm/BinaryFormat/ELF.h"
16#include "llvm/MC/MCExpr.h"
17#include "llvm/MC/MCStreamer.h"
18#include "llvm/MC/MCTargetOptions.h"
19#include "llvm/TargetParser/Triple.h"
20
21using namespace llvm;
22
23void SparcELFMCAsmInfo::anchor() {}
24
25SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Triple &TheTriple,
26 const MCTargetOptions &Options)
27 : MCAsmInfoELF(Options) {
28 bool isV9 = (TheTriple.getArch() == Triple::sparcv9);
29 IsLittleEndian = (TheTriple.getArch() == Triple::sparcel);
30
31 if (isV9) {
32 CodePointerSize = CalleeSaveStackSlotSize = 8;
33 }
34
35 Data16bitsDirective = "\t.half\t";
36 Data32bitsDirective = "\t.word\t";
37 // .xword is only supported by V9.
38 Data64bitsDirective = (isV9) ? "\t.xword\t" : nullptr;
39 ZeroDirective = "\t.skip\t";
40 CommentString = "!";
41 SupportsDebugInformation = true;
42
43 ExceptionsType = ExceptionHandling::DwarfCFI;
44
45 UsesELFSectionDirectiveForBSS = true;
46
47 DwarfFDERelSymbolSpec = ELF::R_SPARC_DISP32;
48}
49
50void SparcELFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,
51 const MCSpecifierExpr &Expr) const {
52 StringRef S = Sparc::getSpecifierName(S: Expr.getSpecifier());
53 if (!S.empty())
54 OS << '%' << S << '(';
55 printExpr(OS, *Expr.getSubExpr());
56 if (!S.empty())
57 OS << ')';
58}
59