[PowerPC] Do not emit record-form rotates when record-form andi/andis suffices
[llvm-core.git] / lib / Target / RISCV / MCTargetDesc / RISCVMCExpr.h
blobd2e0f6b6cdae2a26562885995ee23f1d959091c0
1 //===-- RISCVMCExpr.h - RISCV specific MC expression classes ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes RISCV-specific MCExprs, used for modifiers like
11 // "%hi" or "%lo" etc.,
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H
16 #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H
18 #include "llvm/MC/MCExpr.h"
20 namespace llvm {
22 class StringRef;
23 class MCOperand;
24 class RISCVMCExpr : public MCTargetExpr {
25 public:
26 enum VariantKind {
27 VK_RISCV_None,
28 VK_RISCV_LO,
29 VK_RISCV_HI,
30 VK_RISCV_PCREL_LO,
31 VK_RISCV_PCREL_HI,
32 VK_RISCV_CALL,
33 VK_RISCV_Invalid
36 private:
37 const MCExpr *Expr;
38 const VariantKind Kind;
40 int64_t evaluateAsInt64(int64_t Value) const;
42 explicit RISCVMCExpr(const MCExpr *Expr, VariantKind Kind)
43 : Expr(Expr), Kind(Kind) {}
45 public:
46 static const RISCVMCExpr *create(const MCExpr *Expr, VariantKind Kind,
47 MCContext &Ctx);
49 VariantKind getKind() const { return Kind; }
51 const MCExpr *getSubExpr() const { return Expr; }
53 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
54 bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
55 const MCFixup *Fixup) const override;
56 void visitUsedExpr(MCStreamer &Streamer) const override;
57 MCFragment *findAssociatedFragment() const override {
58 return getSubExpr()->findAssociatedFragment();
61 // There are no TLS RISCVMCExprs at the moment.
62 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
64 bool evaluateAsConstant(int64_t &Res) const;
66 static bool classof(const MCExpr *E) {
67 return E->getKind() == MCExpr::Target;
70 static bool classof(const RISCVMCExpr *) { return true; }
72 static VariantKind getVariantKindForName(StringRef name);
73 static StringRef getVariantKindName(VariantKind Kind);
76 } // end namespace llvm.
78 #endif