blob: 3cbb493bc6b02168a7f3113d08d1f3510d9325f3 [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,
Ulrich Weigandd51c09f2013-06-21 14:42:20 +000023 VK_PPC_LO,
Ulrich Weigande67c5652013-06-21 14:42:49 +000024 VK_PPC_HI,
Ulrich Weigande9126f52013-06-21 14:43:42 +000025 VK_PPC_HA,
26 VK_PPC_HIGHER,
27 VK_PPC_HIGHERA,
28 VK_PPC_HIGHEST,
29 VK_PPC_HIGHESTA
Ulrich Weigand41789de2013-05-23 22:26:41 +000030 };
31
32private:
33 const VariantKind Kind;
34 const MCExpr *Expr;
Ulrich Weigand96e65782013-06-20 16:23:52 +000035 const int AssemblerDialect;
Ulrich Weigand41789de2013-05-23 22:26:41 +000036
Ulrich Weigand96e65782013-06-20 16:23:52 +000037 explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr,
38 int _AssemblerDialect)
39 : Kind(_Kind), Expr(_Expr), AssemblerDialect(_AssemblerDialect) {}
Ulrich Weigand41789de2013-05-23 22:26:41 +000040
41public:
42 /// @name Construction
43 /// @{
44
45 static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
46 MCContext &Ctx);
47
Ulrich Weigandd51c09f2013-06-21 14:42:20 +000048 static const PPCMCExpr *CreateLo(const MCExpr *Expr, MCContext &Ctx) {
49 return Create(VK_PPC_LO, Expr, Ctx);
Ulrich Weigand41789de2013-05-23 22:26:41 +000050 }
51
Ulrich Weigande67c5652013-06-21 14:42:49 +000052 static const PPCMCExpr *CreateHi(const MCExpr *Expr, MCContext &Ctx) {
53 return Create(VK_PPC_HI, Expr, Ctx);
54 }
55
Ulrich Weigandd51c09f2013-06-21 14:42:20 +000056 static const PPCMCExpr *CreateHa(const MCExpr *Expr, MCContext &Ctx) {
57 return Create(VK_PPC_HA, Expr, Ctx);
Ulrich Weigand41789de2013-05-23 22:26:41 +000058 }
59
60 /// @}
61 /// @name Accessors
62 /// @{
63
64 /// getOpcode - Get the kind of this expression.
65 VariantKind getKind() const { return Kind; }
66
67 /// getSubExpr - Get the child of this expression.
68 const MCExpr *getSubExpr() const { return Expr; }
69
Ulrich Weigand96e65782013-06-20 16:23:52 +000070 /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
71 bool isDarwinSyntax() const { return AssemblerDialect == 1; }
72
73
Ulrich Weigand41789de2013-05-23 22:26:41 +000074 /// @}
75
76 void PrintImpl(raw_ostream &OS) const;
77 bool EvaluateAsRelocatableImpl(MCValue &Res,
78 const MCAsmLayout *Layout) const;
79 void AddValueSymbols(MCAssembler *) const;
80 const MCSection *FindAssociatedSection() const {
81 return getSubExpr()->FindAssociatedSection();
82 }
83
84 // There are no TLS PPCMCExprs at the moment.
85 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
86
87 static bool classof(const MCExpr *E) {
88 return E->getKind() == MCExpr::Target;
89 }
90};
91} // end namespace llvm
92
93#endif