Path: blob/main/contrib/llvm-project/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
35294 views
//===-- PPCMCExpr.h - PPC 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//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H9#define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H1011#include "llvm/MC/MCExpr.h"12#include "llvm/MC/MCValue.h"1314namespace llvm {1516class PPCMCExpr : public MCTargetExpr {17public:18enum VariantKind {19VK_PPC_None,20VK_PPC_LO,21VK_PPC_HI,22VK_PPC_HA,23VK_PPC_HIGH,24VK_PPC_HIGHA,25VK_PPC_HIGHER,26VK_PPC_HIGHERA,27VK_PPC_HIGHEST,28VK_PPC_HIGHESTA29};3031private:32const VariantKind Kind;33const MCExpr *Expr;3435int64_t evaluateAsInt64(int64_t Value) const;3637explicit PPCMCExpr(VariantKind Kind, const MCExpr *Expr)38: Kind(Kind), Expr(Expr) {}3940public:41/// @name Construction42/// @{4344static const PPCMCExpr *create(VariantKind Kind, const MCExpr *Expr,45MCContext &Ctx);4647static const PPCMCExpr *createLo(const MCExpr *Expr, MCContext &Ctx) {48return create(VK_PPC_LO, Expr, Ctx);49}5051static const PPCMCExpr *createHi(const MCExpr *Expr, MCContext &Ctx) {52return create(VK_PPC_HI, Expr, Ctx);53}5455static const PPCMCExpr *createHa(const MCExpr *Expr, MCContext &Ctx) {56return create(VK_PPC_HA, Expr, Ctx);57}5859/// @}60/// @name Accessors61/// @{6263/// getOpcode - Get the kind of this expression.64VariantKind getKind() const { return Kind; }6566/// getSubExpr - Get the child of this expression.67const MCExpr *getSubExpr() const { return Expr; }6869/// @}7071void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;72bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,73const MCFixup *Fixup) const override;74void visitUsedExpr(MCStreamer &Streamer) const override;75MCFragment *findAssociatedFragment() const override {76return getSubExpr()->findAssociatedFragment();77}7879// There are no TLS PPCMCExprs at the moment.80void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}8182bool evaluateAsConstant(int64_t &Res) const;8384static bool classof(const MCExpr *E) {85return E->getKind() == MCExpr::Target;86}87};88} // end namespace llvm8990#endif919293