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