blob: 0ec17554c0bc1921a2601d0557fabb123737ac6e [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,
23 VK_Mips_ABS_LO,
24 VK_Mips_ABS_HI
25 };
26
27private:
28 const VariantKind Kind;
29 const MCExpr *Expr;
30
31 explicit MipsMCExpr(VariantKind Kind, const MCExpr *Expr)
32 : Kind(Kind), Expr(Expr) {}
33
34public:
35 static const MipsMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
36 MCContext &Ctx);
37
38 static const MipsMCExpr *CreateLo(const MCExpr *Expr, MCContext &Ctx) {
39 return Create(VK_Mips_ABS_LO, Expr, Ctx);
40 }
41
42 static const MipsMCExpr *CreateHi(const MCExpr *Expr, MCContext &Ctx) {
43 return Create(VK_Mips_ABS_HI, Expr, Ctx);
44 }
45
46 /// getOpcode - Get the kind of this expression.
47 VariantKind getKind() const { return Kind; }
48
49 /// getSubExpr - Get the child of this expression.
50 const MCExpr *getSubExpr() const { return Expr; }
51
52 void PrintImpl(raw_ostream &OS) const;
53 bool EvaluateAsRelocatableImpl(MCValue &Res,
54 const MCAsmLayout *Layout) const;
55 void AddValueSymbols(MCAssembler *) const;
56 const MCSection *FindAssociatedSection() const {
57 return getSubExpr()->FindAssociatedSection();
58 }
59
60 // There are no TLS MipsMCExprs at the moment.
61 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
62
63 static bool classof(const MCExpr *E) {
64 return E->getKind() == MCExpr::Target;
65 }
66};
67} // end namespace llvm
68
69#endif