blob: 1b57687996f77a737c7e1377f47e0e1095466a07 [file] [log] [blame]
Ulrich Weigand41789de2013-05-23 22:26:41 +00001//===-- PPCMCExpr.h - PPC 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 PPCMCEXPR_H
11#define PPCMCEXPR_H
12
13#include "llvm/MC/MCExpr.h"
14#include "llvm/MC/MCValue.h"
15#include "llvm/MC/MCAsmLayout.h"
16
17namespace llvm {
18
19class PPCMCExpr : public MCTargetExpr {
20public:
21 enum VariantKind {
22 VK_PPC_None,
23 VK_PPC_HA16,
24 VK_PPC_LO16
25 };
26
27private:
28 const VariantKind Kind;
29 const MCExpr *Expr;
Ulrich Weigand96e65782013-06-20 16:23:52 +000030 const int AssemblerDialect;
Ulrich Weigand41789de2013-05-23 22:26:41 +000031
Ulrich Weigand96e65782013-06-20 16:23:52 +000032 explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr,
33 int _AssemblerDialect)
34 : Kind(_Kind), Expr(_Expr), AssemblerDialect(_AssemblerDialect) {}
Ulrich Weigand41789de2013-05-23 22:26:41 +000035
36public:
37 /// @name Construction
38 /// @{
39
40 static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
41 MCContext &Ctx);
42
43 static const PPCMCExpr *CreateHa16(const MCExpr *Expr, MCContext &Ctx) {
44 return Create(VK_PPC_HA16, Expr, Ctx);
45 }
46
47 static const PPCMCExpr *CreateLo16(const MCExpr *Expr, MCContext &Ctx) {
48 return Create(VK_PPC_LO16, Expr, Ctx);
49 }
50
51 /// @}
52 /// @name Accessors
53 /// @{
54
55 /// getOpcode - Get the kind of this expression.
56 VariantKind getKind() const { return Kind; }
57
58 /// getSubExpr - Get the child of this expression.
59 const MCExpr *getSubExpr() const { return Expr; }
60
Ulrich Weigand96e65782013-06-20 16:23:52 +000061 /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
62 bool isDarwinSyntax() const { return AssemblerDialect == 1; }
63
64
Ulrich Weigand41789de2013-05-23 22:26:41 +000065 /// @}
66
67 void PrintImpl(raw_ostream &OS) const;
68 bool EvaluateAsRelocatableImpl(MCValue &Res,
69 const MCAsmLayout *Layout) const;
70 void AddValueSymbols(MCAssembler *) const;
71 const MCSection *FindAssociatedSection() const {
72 return getSubExpr()->FindAssociatedSection();
73 }
74
75 // There are no TLS PPCMCExprs at the moment.
76 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
77
78 static bool classof(const MCExpr *E) {
79 return E->getKind() == MCExpr::Target;
80 }
81};
82} // end namespace llvm
83
84#endif