blob: 722bba71e9b5869f1133d794ab4774ea90b20ade [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
10#ifndef MIPSMCEXPR_H
11#define MIPSMCEXPR_H
12
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
Sasa Stankovic06c47802014-04-03 10:37:45 +000040 static const MipsMCExpr *Create(MCSymbolRefExpr::VariantKind VK,
41 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
49 void PrintImpl(raw_ostream &OS) const;
50 bool EvaluateAsRelocatableImpl(MCValue &Res,
51 const MCAsmLayout *Layout) const;
52 void AddValueSymbols(MCAssembler *) const;
53 const MCSection *FindAssociatedSection() const {
54 return getSubExpr()->FindAssociatedSection();
55 }
56
57 // There are no TLS MipsMCExprs at the moment.
58 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
59
60 static bool classof(const MCExpr *E) {
61 return E->getKind() == MCExpr::Target;
62 }
63};
64} // end namespace llvm
65
66#endif