Path: blob/main/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h
35294 views
//===-- RISCVMCExpr.h - RISC-V specific MC expression classes----*- C++ -*-===//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 describes RISC-V specific MCExprs, used for modifiers like9// "%hi" or "%lo" etc.,10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H14#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H1516#include "llvm/MC/MCExpr.h"1718namespace llvm {1920class StringRef;2122class RISCVMCExpr : public MCTargetExpr {23public:24enum VariantKind {25VK_RISCV_None,26VK_RISCV_LO,27VK_RISCV_HI,28VK_RISCV_PCREL_LO,29VK_RISCV_PCREL_HI,30VK_RISCV_GOT_HI,31VK_RISCV_TPREL_LO,32VK_RISCV_TPREL_HI,33VK_RISCV_TPREL_ADD,34VK_RISCV_TLS_GOT_HI,35VK_RISCV_TLS_GD_HI,36VK_RISCV_CALL,37VK_RISCV_CALL_PLT,38VK_RISCV_32_PCREL,39VK_RISCV_TLSDESC_HI,40VK_RISCV_TLSDESC_LOAD_LO,41VK_RISCV_TLSDESC_ADD_LO,42VK_RISCV_TLSDESC_CALL,43VK_RISCV_Invalid // Must be the last item44};4546private:47const MCExpr *Expr;48const VariantKind Kind;4950int64_t evaluateAsInt64(int64_t Value) const;5152explicit RISCVMCExpr(const MCExpr *Expr, VariantKind Kind)53: Expr(Expr), Kind(Kind) {}5455public:56static const RISCVMCExpr *create(const MCExpr *Expr, VariantKind Kind,57MCContext &Ctx);5859VariantKind getKind() const { return Kind; }6061const MCExpr *getSubExpr() const { return Expr; }6263/// Get the corresponding PC-relative HI fixup that a VK_RISCV_PCREL_LO64/// points to, and optionally the fragment containing it.65///66/// \returns nullptr if this isn't a VK_RISCV_PCREL_LO pointing to a67/// known PC-relative HI fixup.68const MCFixup *getPCRelHiFixup(const MCFragment **DFOut) const;6970void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;71bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,72const MCFixup *Fixup) const override;73void visitUsedExpr(MCStreamer &Streamer) const override;74MCFragment *findAssociatedFragment() const override {75return getSubExpr()->findAssociatedFragment();76}7778void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;7980bool evaluateAsConstant(int64_t &Res) const;8182static bool classof(const MCExpr *E) {83return E->getKind() == MCExpr::Target;84}8586static VariantKind getVariantKindForName(StringRef name);87static StringRef getVariantKindName(VariantKind Kind);88};8990} // end namespace llvm.9192#endif939495