• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- Nios2MCExpr.h - Nios2 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_NIOS2_MCTARGETDESC_NIOS2MCEXPR_H
11 #define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2MCEXPR_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 Nios2MCExpr : public MCTargetExpr {
20 public:
21   enum Nios2ExprKind {
22     CEK_None,
23     CEK_ABS_HI,
24     CEK_ABS_LO,
25     CEK_Special,
26   };
27 
28 private:
29   const Nios2ExprKind Kind;
30   const MCExpr *Expr;
31 
Nios2MCExpr(Nios2ExprKind Kind,const MCExpr * Expr)32   explicit Nios2MCExpr(Nios2ExprKind Kind, const MCExpr *Expr)
33       : Kind(Kind), Expr(Expr) {}
34 
35 public:
36   static const Nios2MCExpr *create(Nios2ExprKind Kind, const MCExpr *Expr,
37                                    MCContext &Ctx);
38   static const Nios2MCExpr *create(const MCSymbol *Symbol,
39                                    Nios2MCExpr::Nios2ExprKind Kind,
40                                    MCContext &Ctx);
41 
42   /// Get the kind of this expression.
getKind()43   Nios2ExprKind getKind() const { return Kind; }
44 
45   /// Get the child of this expression.
getSubExpr()46   const MCExpr *getSubExpr() const { return Expr; }
47 
48   void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
49   bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
50                                  const MCFixup *Fixup) const override;
51   void visitUsedExpr(MCStreamer &Streamer) const override;
findAssociatedFragment()52   MCFragment *findAssociatedFragment() const override {
53     return getSubExpr()->findAssociatedFragment();
54   }
55 
56   void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
57 };
58 } // end namespace llvm
59 
60 #endif
61