1 //===-- PPCMCExpr.h - PPC specific MC expression classes --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
11 #define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
13 #include "llvm/MC/MCAsmLayout.h"
14 #include "llvm/MC/MCExpr.h"
15 #include "llvm/MC/MCValue.h"
19 class PPCMCExpr
: public MCTargetExpr
{
33 const VariantKind Kind
;
37 int64_t evaluateAsInt64(int64_t Value
) const;
39 explicit PPCMCExpr(VariantKind Kind
, const MCExpr
*Expr
, bool IsDarwin
)
40 : Kind(Kind
), Expr(Expr
), IsDarwin(IsDarwin
) {}
43 /// @name Construction
46 static const PPCMCExpr
*create(VariantKind Kind
, const MCExpr
*Expr
,
47 bool isDarwin
, MCContext
&Ctx
);
49 static const PPCMCExpr
*createLo(const MCExpr
*Expr
,
50 bool isDarwin
, MCContext
&Ctx
) {
51 return create(VK_PPC_LO
, Expr
, isDarwin
, Ctx
);
54 static const PPCMCExpr
*createHi(const MCExpr
*Expr
,
55 bool isDarwin
, MCContext
&Ctx
) {
56 return create(VK_PPC_HI
, Expr
, isDarwin
, Ctx
);
59 static const PPCMCExpr
*createHa(const MCExpr
*Expr
,
60 bool isDarwin
, MCContext
&Ctx
) {
61 return create(VK_PPC_HA
, Expr
, isDarwin
, Ctx
);
68 /// getOpcode - Get the kind of this expression.
69 VariantKind
getKind() const { return Kind
; }
71 /// getSubExpr - Get the child of this expression.
72 const MCExpr
*getSubExpr() const { return Expr
; }
74 /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
75 bool isDarwinSyntax() const { return IsDarwin
; }
80 void printImpl(raw_ostream
&OS
, const MCAsmInfo
*MAI
) const override
;
81 bool evaluateAsRelocatableImpl(MCValue
&Res
,
82 const MCAsmLayout
*Layout
,
83 const MCFixup
*Fixup
) const override
;
84 void visitUsedExpr(MCStreamer
&Streamer
) const override
;
85 MCFragment
*findAssociatedFragment() const override
{
86 return getSubExpr()->findAssociatedFragment();
89 // There are no TLS PPCMCExprs at the moment.
90 void fixELFSymbolsInTLSFixups(MCAssembler
&Asm
) const override
{}
92 bool evaluateAsConstant(int64_t &Res
) const;
94 static bool classof(const MCExpr
*E
) {
95 return E
->getKind() == MCExpr::Target
;
98 } // end namespace llvm