brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 3636559 Raw
78 lines · cpp
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-exception6//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  bool isV9 = (TheTriple.getArch() == Triple::sparcv9);27  IsLittleEndian = (TheTriple.getArch() == Triple::sparcel);28 29  if (isV9) {30    CodePointerSize = CalleeSaveStackSlotSize = 8;31  }32 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";38  CommentString = "!";39  SupportsDebugInformation = true;40 41  ExceptionsType = ExceptionHandling::DwarfCFI;42 43  UsesELFSectionDirectiveForBSS = true;44}45 46const MCExpr*47SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,48                                               unsigned Encoding,49                                               MCStreamer &Streamer) const {50  if (Encoding & dwarf::DW_EH_PE_pcrel) {51    MCContext &Ctx = Streamer.getContext();52    return MCSpecifierExpr::create(Sym, ELF::R_SPARC_DISP32, Ctx);53  }54 55  return MCAsmInfo::getExprForPersonalitySymbol(Sym, Encoding, Streamer);56}57 58const MCExpr*59SparcELFMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,60                                       unsigned Encoding,61                                       MCStreamer &Streamer) const {62  if (Encoding & dwarf::DW_EH_PE_pcrel) {63    MCContext &Ctx = Streamer.getContext();64    return MCSpecifierExpr::create(Sym, ELF::R_SPARC_DISP32, Ctx);65  }66  return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);67}68 69void SparcELFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,70                                           const MCSpecifierExpr &Expr) const {71  StringRef S = Sparc::getSpecifierName(Expr.getSpecifier());72  if (!S.empty())73    OS << '%' << S << '(';74  printExpr(OS, *Expr.getSubExpr());75  if (!S.empty())76    OS << ')';77}78