Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- ARMMCExpr.h - ARM specific MC expression classes --------*- C++ -*-===// |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H |
| 11 | #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 12 | |
| 13 | #include "llvm/MC/MCExpr.h" |
| 14 | |
| 15 | namespace llvm { |
| 16 | |
| 17 | class ARMMCExpr : public MCTargetExpr { |
| 18 | public: |
| 19 | enum VariantKind { |
| 20 | VK_ARM_None, |
| 21 | VK_ARM_HI16, // The R_ARM_MOVT_ABS relocation (:upper16: in the .s file) |
| 22 | VK_ARM_LO16 // The R_ARM_MOVW_ABS_NC relocation (:lower16: in the .s file) |
| 23 | }; |
| 24 | |
| 25 | private: |
| 26 | const VariantKind Kind; |
| 27 | const MCExpr *Expr; |
| 28 | |
David Blaikie | 9f380a3 | 2015-03-16 18:06:57 +0000 | [diff] [blame] | 29 | explicit ARMMCExpr(VariantKind Kind, const MCExpr *Expr) |
| 30 | : Kind(Kind), Expr(Expr) {} |
Jim Grosbach | e2baa97 | 2012-09-21 00:36:42 +0000 | [diff] [blame] | 31 | |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 32 | public: |
| 33 | /// @name Construction |
| 34 | /// @{ |
| 35 | |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame] | 36 | static const ARMMCExpr *create(VariantKind Kind, const MCExpr *Expr, |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 37 | MCContext &Ctx); |
| 38 | |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame] | 39 | static const ARMMCExpr *createUpper16(const MCExpr *Expr, MCContext &Ctx) { |
| 40 | return create(VK_ARM_HI16, Expr, Ctx); |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame] | 43 | static const ARMMCExpr *createLower16(const MCExpr *Expr, MCContext &Ctx) { |
| 44 | return create(VK_ARM_LO16, Expr, Ctx); |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | /// @} |
| 48 | /// @name Accessors |
| 49 | /// @{ |
| 50 | |
| 51 | /// getOpcode - Get the kind of this expression. |
| 52 | VariantKind getKind() const { return Kind; } |
| 53 | |
| 54 | /// getSubExpr - Get the child of this expression. |
| 55 | const MCExpr *getSubExpr() const { return Expr; } |
| 56 | |
| 57 | /// @} |
| 58 | |
Matt Arsenault | 8b64355 | 2015-06-09 00:31:39 +0000 | [diff] [blame] | 59 | void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override; |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame] | 60 | bool evaluateAsRelocatableImpl(MCValue &Res, |
Joerg Sonnenberger | 752b91b | 2014-08-10 11:35:12 +0000 | [diff] [blame] | 61 | const MCAsmLayout *Layout, |
| 62 | const MCFixup *Fixup) const override { |
| 63 | return false; |
| 64 | } |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 65 | void visitUsedExpr(MCStreamer &Streamer) const override; |
Rafael Espindola | e3a20f5 | 2015-10-05 12:07:05 +0000 | [diff] [blame] | 66 | MCFragment *findAssociatedFragment() const override { |
| 67 | return getSubExpr()->findAssociatedFragment(); |
Daniel Dunbar | dc3e4cc | 2011-04-29 18:00:03 +0000 | [diff] [blame] | 68 | } |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 69 | |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 70 | // There are no TLS ARMMCExprs at the moment. |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 71 | void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {} |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 72 | |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 73 | static bool classof(const MCExpr *E) { |
| 74 | return E->getKind() == MCExpr::Target; |
| 75 | } |
Evan Cheng | 965b3c7 | 2011-01-13 07:58:56 +0000 | [diff] [blame] | 76 | }; |
| 77 | } // end namespace llvm |
| 78 | |
| 79 | #endif |