[VPlan] Check VPWidenIntrinsicSC in VPRecipeWithIRFlags::classof.
[llvm-project.git] / llvm / lib / Target / PowerPC / MCTargetDesc / PPCMCExpr.h
blob59ca51459a40c7b7517c8d2133a1948c57ad53fe
1 //===-- PPCMCExpr.h - PPC specific MC expression classes --------*- C++ -*-===//
2 //
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
6 //
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"
15 namespace llvm {
17 class PPCMCExpr : public MCTargetExpr {
18 public:
19 enum VariantKind {
20 VK_PPC_None,
21 VK_PPC_LO,
22 VK_PPC_HI,
23 VK_PPC_HA,
24 VK_PPC_HIGH,
25 VK_PPC_HIGHA,
26 VK_PPC_HIGHER,
27 VK_PPC_HIGHERA,
28 VK_PPC_HIGHEST,
29 VK_PPC_HIGHESTA
32 private:
33 const VariantKind Kind;
34 const MCExpr *Expr;
36 int64_t evaluateAsInt64(int64_t Value) const;
38 explicit PPCMCExpr(VariantKind Kind, const MCExpr *Expr)
39 : Kind(Kind), Expr(Expr) {}
41 public:
42 /// @name Construction
43 /// @{
45 static const PPCMCExpr *create(VariantKind Kind, const MCExpr *Expr,
46 MCContext &Ctx);
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);
60 /// @}
61 /// @name Accessors
62 /// @{
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; }
70 /// @}
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
91 #endif