]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Mips / MCTargetDesc / MipsMCExpr.h
1 //===- MipsMCExpr.h - Mips 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 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCEXPR_H
11 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCEXPR_H
12
13 #include "llvm/MC/MCAsmLayout.h"
14 #include "llvm/MC/MCExpr.h"
15 #include "llvm/MC/MCValue.h"
16
17 namespace llvm {
18
19 class MipsMCExpr : public MCTargetExpr {
20 public:
21   enum MipsExprKind {
22     MEK_None,
23     MEK_CALL_HI16,
24     MEK_CALL_LO16,
25     MEK_DTPREL,
26     MEK_DTPREL_HI,
27     MEK_DTPREL_LO,
28     MEK_GOT,
29     MEK_GOTTPREL,
30     MEK_GOT_CALL,
31     MEK_GOT_DISP,
32     MEK_GOT_HI16,
33     MEK_GOT_LO16,
34     MEK_GOT_OFST,
35     MEK_GOT_PAGE,
36     MEK_GPREL,
37     MEK_HI,
38     MEK_HIGHER,
39     MEK_HIGHEST,
40     MEK_LO,
41     MEK_NEG,
42     MEK_PCREL_HI16,
43     MEK_PCREL_LO16,
44     MEK_TLSGD,
45     MEK_TLSLDM,
46     MEK_TPREL_HI,
47     MEK_TPREL_LO,
48     MEK_Special,
49   };
50
51 private:
52   const MipsExprKind Kind;
53   const MCExpr *Expr;
54
55   explicit MipsMCExpr(MipsExprKind Kind, const MCExpr *Expr)
56       : Kind(Kind), Expr(Expr) {}
57
58 public:
59   static const MipsMCExpr *create(MipsExprKind Kind, const MCExpr *Expr,
60                                   MCContext &Ctx);
61   static const MipsMCExpr *createGpOff(MipsExprKind Kind, const MCExpr *Expr,
62                                        MCContext &Ctx);
63
64   /// Get the kind of this expression.
65   MipsExprKind getKind() const { return Kind; }
66
67   /// Get the child of this expression.
68   const MCExpr *getSubExpr() const { return Expr; }
69
70   void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
71   bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
72                                  const MCFixup *Fixup) const override;
73   void visitUsedExpr(MCStreamer &Streamer) const override;
74
75   MCFragment *findAssociatedFragment() const override {
76     return getSubExpr()->findAssociatedFragment();
77   }
78
79   void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
80
81   static bool classof(const MCExpr *E) {
82     return E->getKind() == MCExpr::Target;
83   }
84
85   bool isGpOff(MipsExprKind &Kind) const;
86   bool isGpOff() const {
87     MipsExprKind Kind;
88     return isGpOff(Kind);
89   }
90 };
91
92 } // end namespace llvm
93
94 #endif // LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCEXPR_H