blob: 75dde8008fca0613978e56b601fa829971fcc23a [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- ARMMCExpr.h - ARM specific MC expression classes --------*- C++ -*-===//
Evan Cheng965b3c72011-01-13 07:58:56 +00002//
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 Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H
11#define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H
Evan Cheng965b3c72011-01-13 07:58:56 +000012
13#include "llvm/MC/MCExpr.h"
14
15namespace llvm {
16
17class ARMMCExpr : public MCTargetExpr {
18public:
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
25private:
26 const VariantKind Kind;
27 const MCExpr *Expr;
28
David Blaikie9f380a32015-03-16 18:06:57 +000029 explicit ARMMCExpr(VariantKind Kind, const MCExpr *Expr)
30 : Kind(Kind), Expr(Expr) {}
Jim Grosbache2baa972012-09-21 00:36:42 +000031
Evan Cheng965b3c72011-01-13 07:58:56 +000032public:
33 /// @name Construction
34 /// @{
35
Jim Grosbach13760bd2015-05-30 01:25:56 +000036 static const ARMMCExpr *create(VariantKind Kind, const MCExpr *Expr,
Evan Cheng965b3c72011-01-13 07:58:56 +000037 MCContext &Ctx);
38
Jim Grosbach13760bd2015-05-30 01:25:56 +000039 static const ARMMCExpr *createUpper16(const MCExpr *Expr, MCContext &Ctx) {
40 return create(VK_ARM_HI16, Expr, Ctx);
Evan Cheng965b3c72011-01-13 07:58:56 +000041 }
42
Jim Grosbach13760bd2015-05-30 01:25:56 +000043 static const ARMMCExpr *createLower16(const MCExpr *Expr, MCContext &Ctx) {
44 return create(VK_ARM_LO16, Expr, Ctx);
Evan Cheng965b3c72011-01-13 07:58:56 +000045 }
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 Arsenault8b643552015-06-09 00:31:39 +000059 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
Jim Grosbach13760bd2015-05-30 01:25:56 +000060 bool evaluateAsRelocatableImpl(MCValue &Res,
Joerg Sonnenberger752b91b2014-08-10 11:35:12 +000061 const MCAsmLayout *Layout,
62 const MCFixup *Fixup) const override {
63 return false;
64 }
Rafael Espindola0709a7b2015-05-21 19:20:38 +000065 void visitUsedExpr(MCStreamer &Streamer) const override;
Rafael Espindolae3a20f52015-10-05 12:07:05 +000066 MCFragment *findAssociatedFragment() const override {
67 return getSubExpr()->findAssociatedFragment();
Daniel Dunbardc3e4cc2011-04-29 18:00:03 +000068 }
Evan Cheng965b3c72011-01-13 07:58:56 +000069
Tim Northovere0e3aef2013-01-31 12:12:40 +000070 // There are no TLS ARMMCExprs at the moment.
Craig Topper6bc27bf2014-03-10 02:09:33 +000071 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
Tim Northovere0e3aef2013-01-31 12:12:40 +000072
Evan Cheng965b3c72011-01-13 07:58:56 +000073 static bool classof(const MCExpr *E) {
74 return E->getKind() == MCExpr::Target;
75 }
Evan Cheng965b3c72011-01-13 07:58:56 +000076};
77} // end namespace llvm
78
79#endif