blob: 5c41f82400176b996d84081bebfc7ae1a77e118f [file] [log] [blame]
Petar Jovanovica5da5882014-02-04 18:41:57 +00001//===-- MipsMCExpr.h - Mips 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCEXPR_H
11#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCEXPR_H
Petar Jovanovica5da5882014-02-04 18:41:57 +000012
Chandler Carruth442f7842014-03-04 10:07:28 +000013#include "llvm/MC/MCAsmLayout.h"
Petar Jovanovica5da5882014-02-04 18:41:57 +000014#include "llvm/MC/MCExpr.h"
15#include "llvm/MC/MCValue.h"
Petar Jovanovica5da5882014-02-04 18:41:57 +000016
17namespace llvm {
18
19class MipsMCExpr : public MCTargetExpr {
20public:
21 enum VariantKind {
22 VK_Mips_None,
Sasa Stankovic06c47802014-04-03 10:37:45 +000023 VK_Mips_LO,
24 VK_Mips_HI,
25 VK_Mips_HIGHER,
26 VK_Mips_HIGHEST
Petar Jovanovica5da5882014-02-04 18:41:57 +000027 };
28
29private:
30 const VariantKind Kind;
31 const MCExpr *Expr;
32
33 explicit MipsMCExpr(VariantKind Kind, const MCExpr *Expr)
34 : Kind(Kind), Expr(Expr) {}
35
36public:
Sasa Stankovic06c47802014-04-03 10:37:45 +000037 static bool isSupportedBinaryExpr(MCSymbolRefExpr::VariantKind VK,
38 const MCBinaryExpr *BE);
Petar Jovanovica5da5882014-02-04 18:41:57 +000039
Jim Grosbach13760bd2015-05-30 01:25:56 +000040 static const MipsMCExpr *create(MCSymbolRefExpr::VariantKind VK,
Sasa Stankovic06c47802014-04-03 10:37:45 +000041 const MCExpr *Expr, MCContext &Ctx);
Petar Jovanovica5da5882014-02-04 18:41:57 +000042
43 /// getOpcode - Get the kind of this expression.
44 VariantKind getKind() const { return Kind; }
45
46 /// getSubExpr - Get the child of this expression.
47 const MCExpr *getSubExpr() const { return Expr; }
48
Jim Grosbach13760bd2015-05-30 01:25:56 +000049 void printImpl(raw_ostream &OS) const override;
50 bool evaluateAsRelocatableImpl(MCValue &Res,
Joerg Sonnenberger752b91b2014-08-10 11:35:12 +000051 const MCAsmLayout *Layout,
52 const MCFixup *Fixup) const override;
Rafael Espindolae2c66242014-06-25 15:45:33 +000053 void visitUsedExpr(MCStreamer &Streamer) const override;
Jim Grosbach13760bd2015-05-30 01:25:56 +000054 MCSection *findAssociatedSection() const override {
55 return getSubExpr()->findAssociatedSection();
Petar Jovanovica5da5882014-02-04 18:41:57 +000056 }
57
58 // There are no TLS MipsMCExprs at the moment.
Craig Topper56c590a2014-04-29 07:58:02 +000059 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
Petar Jovanovica5da5882014-02-04 18:41:57 +000060
61 static bool classof(const MCExpr *E) {
62 return E->getKind() == MCExpr::Target;
63 }
64};
65} // end namespace llvm
66
67#endif