Path: blob/main/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp
35294 views
//===-- RISCVMCAsmInfo.cpp - RISC-V Asm properties ------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file contains the declarations of the RISCVMCAsmInfo properties.9//10//===----------------------------------------------------------------------===//1112#include "RISCVMCAsmInfo.h"13#include "MCTargetDesc/RISCVMCExpr.h"14#include "llvm/BinaryFormat/Dwarf.h"15#include "llvm/MC/MCStreamer.h"16#include "llvm/TargetParser/Triple.h"17using namespace llvm;1819void RISCVMCAsmInfo::anchor() {}2021RISCVMCAsmInfo::RISCVMCAsmInfo(const Triple &TT) {22CodePointerSize = CalleeSaveStackSlotSize = TT.isArch64Bit() ? 8 : 4;23CommentString = "#";24AlignmentIsInBytes = false;25SupportsDebugInformation = true;26ExceptionsType = ExceptionHandling::DwarfCFI;27Data16bitsDirective = "\t.half\t";28Data32bitsDirective = "\t.word\t";29}3031const MCExpr *RISCVMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,32unsigned Encoding,33MCStreamer &Streamer) const {34if (!(Encoding & dwarf::DW_EH_PE_pcrel))35return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);3637// The default symbol subtraction results in an ADD/SUB relocation pair.38// Processing this relocation pair is problematic when linker relaxation is39// enabled, so we follow binutils in using the R_RISCV_32_PCREL relocation40// for the FDE initial location.41MCContext &Ctx = Streamer.getContext();42const MCExpr *ME =43MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, Ctx);44assert(Encoding & dwarf::DW_EH_PE_sdata4 && "Unexpected encoding");45return RISCVMCExpr::create(ME, RISCVMCExpr::VK_RISCV_32_PCREL, Ctx);46}474849