Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 1 | //===-- PPCMCExpr.h - PPC 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 PPCMCEXPR_H |
| 11 | #define PPCMCEXPR_H |
| 12 | |
| 13 | #include "llvm/MC/MCExpr.h" |
| 14 | #include "llvm/MC/MCValue.h" |
| 15 | #include "llvm/MC/MCAsmLayout.h" |
| 16 | |
| 17 | namespace llvm { |
| 18 | |
| 19 | class PPCMCExpr : public MCTargetExpr { |
| 20 | public: |
| 21 | enum VariantKind { |
| 22 | VK_PPC_None, |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 23 | VK_PPC_LO, |
Ulrich Weigand | e67c565 | 2013-06-21 14:42:49 +0000 | [diff] [blame] | 24 | VK_PPC_HI, |
Ulrich Weigand | e9126f5 | 2013-06-21 14:43:42 +0000 | [diff] [blame] | 25 | VK_PPC_HA, |
| 26 | VK_PPC_HIGHER, |
| 27 | VK_PPC_HIGHERA, |
| 28 | VK_PPC_HIGHEST, |
| 29 | VK_PPC_HIGHESTA |
Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | private: |
| 33 | const VariantKind Kind; |
| 34 | const MCExpr *Expr; |
Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame^] | 35 | bool IsDarwin; |
Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 36 | |
Ulrich Weigand | 96e6578 | 2013-06-20 16:23:52 +0000 | [diff] [blame] | 37 | explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr, |
Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame^] | 38 | bool _IsDarwin) |
| 39 | : Kind(_Kind), Expr(_Expr), IsDarwin(_IsDarwin) {} |
Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 40 | |
| 41 | public: |
| 42 | /// @name Construction |
| 43 | /// @{ |
| 44 | |
| 45 | static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr, |
Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame^] | 46 | bool isDarwin, MCContext &Ctx); |
Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 47 | |
Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame^] | 48 | static const PPCMCExpr *CreateLo(const MCExpr *Expr, |
| 49 | bool isDarwin, MCContext &Ctx) { |
| 50 | return Create(VK_PPC_LO, Expr, isDarwin, Ctx); |
Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame^] | 53 | static const PPCMCExpr *CreateHi(const MCExpr *Expr, |
| 54 | bool isDarwin, MCContext &Ctx) { |
| 55 | return Create(VK_PPC_HI, Expr, isDarwin, Ctx); |
Ulrich Weigand | e67c565 | 2013-06-21 14:42:49 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame^] | 58 | static const PPCMCExpr *CreateHa(const MCExpr *Expr, |
| 59 | bool isDarwin, MCContext &Ctx) { |
| 60 | return Create(VK_PPC_HA, Expr, isDarwin, Ctx); |
Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /// @} |
| 64 | /// @name Accessors |
| 65 | /// @{ |
| 66 | |
| 67 | /// getOpcode - Get the kind of this expression. |
| 68 | VariantKind getKind() const { return Kind; } |
| 69 | |
| 70 | /// getSubExpr - Get the child of this expression. |
| 71 | const MCExpr *getSubExpr() const { return Expr; } |
| 72 | |
Ulrich Weigand | 96e6578 | 2013-06-20 16:23:52 +0000 | [diff] [blame] | 73 | /// isDarwinSyntax - True if expression is to be printed using Darwin syntax. |
Ulrich Weigand | 266db7f | 2013-07-08 20:20:51 +0000 | [diff] [blame^] | 74 | bool isDarwinSyntax() const { return IsDarwin; } |
Ulrich Weigand | 96e6578 | 2013-06-20 16:23:52 +0000 | [diff] [blame] | 75 | |
| 76 | |
Ulrich Weigand | 41789de | 2013-05-23 22:26:41 +0000 | [diff] [blame] | 77 | /// @} |
| 78 | |
| 79 | void PrintImpl(raw_ostream &OS) const; |
| 80 | bool EvaluateAsRelocatableImpl(MCValue &Res, |
| 81 | const MCAsmLayout *Layout) const; |
| 82 | void AddValueSymbols(MCAssembler *) const; |
| 83 | const MCSection *FindAssociatedSection() const { |
| 84 | return getSubExpr()->FindAssociatedSection(); |
| 85 | } |
| 86 | |
| 87 | // There are no TLS PPCMCExprs at the moment. |
| 88 | void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {} |
| 89 | |
| 90 | static bool classof(const MCExpr *E) { |
| 91 | return E->getKind() == MCExpr::Target; |
| 92 | } |
| 93 | }; |
| 94 | } // end namespace llvm |
| 95 | |
| 96 | #endif |