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,
41 : Kind(_Kind), Expr(_Expr), IsDarwin(_IsDarwin) {}
44 /// @name Construction
47 static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
48 bool isDarwin, MCContext &Ctx);
50 static const PPCMCExpr *CreateLo(const MCExpr *Expr,
51 bool isDarwin, MCContext &Ctx) {
52 return Create(VK_PPC_LO, Expr, isDarwin, Ctx);
55 static const PPCMCExpr *CreateHi(const MCExpr *Expr,
56 bool isDarwin, MCContext &Ctx) {
57 return Create(VK_PPC_HI, Expr, isDarwin, Ctx);
60 static const PPCMCExpr *CreateHa(const MCExpr *Expr,
61 bool isDarwin, MCContext &Ctx) {
62 return Create(VK_PPC_HA, Expr, isDarwin, Ctx);
69 /// getOpcode - Get the kind of this expression.
70 VariantKind getKind() const { return Kind; }
72 /// getSubExpr - Get the child of this expression.
73 const MCExpr *getSubExpr() const { return Expr; }
75 /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
76 bool isDarwinSyntax() const { return IsDarwin; }
81 void PrintImpl(raw_ostream &OS) const override;
82 bool EvaluateAsRelocatableImpl(MCValue &Res,
83 const MCAsmLayout *Layout,
84 const MCFixup *Fixup) const override;
85 void visitUsedExpr(MCStreamer &Streamer) const override;
86 const MCSection *FindAssociatedSection() const override {
87 return getSubExpr()->FindAssociatedSection();
90 // There are no TLS PPCMCExprs at the moment.
91 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
93 bool EvaluateAsConstant(int64_t &Res) const;
95 static bool classof(const MCExpr *E) {
96 return E->getKind() == MCExpr::Target;
99 } // end namespace llvm