113 lines · cpp
1//===- VEMCAsmInfo.cpp - VE 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 VEMCAsmInfo properties.10//11//===----------------------------------------------------------------------===//12 13#include "VEMCAsmInfo.h"14#include "llvm/MC/MCExpr.h"15#include "llvm/MC/MCStreamer.h"16#include "llvm/MC/MCValue.h"17#include "llvm/TargetParser/Triple.h"18 19using namespace llvm;20 21const MCAsmInfo::AtSpecifier atSpecifiers[] = {22 {VE::S_HI32, "hi"},23 {VE::S_LO32, "lo"},24 {VE::S_PC_HI32, "pc_hi"},25 {VE::S_PC_LO32, "pc_lo"},26 {VE::S_GOT_HI32, "got_hi"},27 {VE::S_GOT_LO32, "got_lo"},28 {VE::S_GOTOFF_HI32, "gotoff_hi"},29 {VE::S_GOTOFF_LO32, "gotoff_lo"},30 {VE::S_PLT_HI32, "plt_hi"},31 {VE::S_PLT_LO32, "plt_lo"},32 {VE::S_TLS_GD_HI32, "tls_gd_hi"},33 {VE::S_TLS_GD_LO32, "tls_gd_lo"},34 {VE::S_TPOFF_HI32, "tpoff_hi"},35 {VE::S_TPOFF_LO32, "tpoff_lo"},36};37 38VE::Fixups VE::getFixupKind(uint8_t S) {39 switch (S) {40 default:41 llvm_unreachable("Unhandled VEMCExpr::Specifier");42 case VE::S_REFLONG:43 return VE::fixup_ve_reflong;44 case VE::S_HI32:45 return VE::fixup_ve_hi32;46 case VE::S_LO32:47 return VE::fixup_ve_lo32;48 case VE::S_PC_HI32:49 return VE::fixup_ve_pc_hi32;50 case VE::S_PC_LO32:51 return VE::fixup_ve_pc_lo32;52 case VE::S_GOT_HI32:53 return VE::fixup_ve_got_hi32;54 case VE::S_GOT_LO32:55 return VE::fixup_ve_got_lo32;56 case VE::S_GOTOFF_HI32:57 return VE::fixup_ve_gotoff_hi32;58 case VE::S_GOTOFF_LO32:59 return VE::fixup_ve_gotoff_lo32;60 case VE::S_PLT_HI32:61 return VE::fixup_ve_plt_hi32;62 case VE::S_PLT_LO32:63 return VE::fixup_ve_plt_lo32;64 case VE::S_TLS_GD_HI32:65 return VE::fixup_ve_tls_gd_hi32;66 case VE::S_TLS_GD_LO32:67 return VE::fixup_ve_tls_gd_lo32;68 case VE::S_TPOFF_HI32:69 return VE::fixup_ve_tpoff_hi32;70 case VE::S_TPOFF_LO32:71 return VE::fixup_ve_tpoff_lo32;72 }73}74 75void VEELFMCAsmInfo::anchor() {}76 77VEELFMCAsmInfo::VEELFMCAsmInfo(const Triple &TheTriple) {78 79 CodePointerSize = CalleeSaveStackSlotSize = 8;80 MaxInstLength = MinInstAlignment = 8;81 82 // VE uses ".*byte" directive for unaligned data.83 Data8bitsDirective = "\t.byte\t";84 Data16bitsDirective = "\t.2byte\t";85 Data32bitsDirective = "\t.4byte\t";86 Data64bitsDirective = "\t.8byte\t";87 88 // Uses '.section' before '.bss' directive. VE requires this although89 // assembler manual says sinple '.bss' is supported.90 UsesELFSectionDirectiveForBSS = true;91 92 SupportsDebugInformation = true;93 94 initializeAtSpecifiers(atSpecifiers);95}96 97void VEELFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,98 const MCSpecifierExpr &Expr) const {99 printExpr(OS, *Expr.getSubExpr());100 auto specifier = Expr.getSpecifier();101 if (specifier && specifier != VE::S_REFLONG)102 OS << '@' << getSpecifierName(specifier);103}104 105bool VEELFMCAsmInfo::evaluateAsRelocatableImpl(const MCSpecifierExpr &Expr,106 MCValue &Res,107 const MCAssembler *Asm) const {108 if (!Expr.getSubExpr()->evaluateAsRelocatable(Res, Asm))109 return false;110 Res.setSpecifier(Expr.getSpecifier());111 return true;112}113