1 //===-- PPCMCExpr.h - PPC specific MC expression classes --------*- C++ -*-===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
10 #define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
12 #include "llvm/MC/MCExpr.h"
13 #include "llvm/MC/MCValue.h"
17 class PPCMCExpr
: public MCTargetExpr
{
33 const VariantKind Kind
;
36 int64_t evaluateAsInt64(int64_t Value
) const;
38 explicit PPCMCExpr(VariantKind Kind
, const MCExpr
*Expr
)
39 : Kind(Kind
), Expr(Expr
) {}
42 /// @name Construction
45 static const PPCMCExpr
*create(VariantKind Kind
, const MCExpr
*Expr
,
48 static const PPCMCExpr
*createLo(const MCExpr
*Expr
, MCContext
&Ctx
) {
49 return create(VK_PPC_LO
, Expr
, Ctx
);
52 static const PPCMCExpr
*createHi(const MCExpr
*Expr
, MCContext
&Ctx
) {
53 return create(VK_PPC_HI
, Expr
, Ctx
);
56 static const PPCMCExpr
*createHa(const MCExpr
*Expr
, MCContext
&Ctx
) {
57 return create(VK_PPC_HA
, Expr
, Ctx
);
64 /// getOpcode - Get the kind of this expression.
65 VariantKind
getKind() const { return Kind
; }
67 /// getSubExpr - Get the child of this expression.
68 const MCExpr
*getSubExpr() const { return Expr
; }
72 void printImpl(raw_ostream
&OS
, const MCAsmInfo
*MAI
) const override
;
73 bool evaluateAsRelocatableImpl(MCValue
&Res
, const MCAssembler
*Asm
,
74 const MCFixup
*Fixup
) const override
;
75 void visitUsedExpr(MCStreamer
&Streamer
) const override
;
76 MCFragment
*findAssociatedFragment() const override
{
77 return getSubExpr()->findAssociatedFragment();
80 // There are no TLS PPCMCExprs at the moment.
81 void fixELFSymbolsInTLSFixups(MCAssembler
&Asm
) const override
{}
83 bool evaluateAsConstant(int64_t &Res
) const;
85 static bool classof(const MCExpr
*E
) {
86 return E
->getKind() == MCExpr::Target
;
89 } // end namespace llvm