[PowerPC] Clean up generation of ha16() / lo16() markers
[oota-llvm.git] / lib / Target / PowerPC / MCTargetDesc / PPCMCExpr.h
1 //===-- 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
17 namespace llvm {
18
19 class PPCMCExpr : public MCTargetExpr {
20 public:
21   enum VariantKind {
22     VK_PPC_None,
23     VK_PPC_HA16,
24     VK_PPC_LO16
25   };
26
27 private:
28   const VariantKind Kind;
29   const MCExpr *Expr;
30
31   explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr)
32     : Kind(_Kind), Expr(_Expr) {}
33
34 public:
35   /// @name Construction
36   /// @{
37
38   static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
39                                       MCContext &Ctx);
40
41   static const PPCMCExpr *CreateHa16(const MCExpr *Expr, MCContext &Ctx) {
42     return Create(VK_PPC_HA16, Expr, Ctx);
43   }
44
45   static const PPCMCExpr *CreateLo16(const MCExpr *Expr, MCContext &Ctx) {
46     return Create(VK_PPC_LO16, Expr, Ctx);
47   }
48
49   /// @}
50   /// @name Accessors
51   /// @{
52
53   /// getOpcode - Get the kind of this expression.
54   VariantKind getKind() const { return Kind; }
55
56   /// getSubExpr - Get the child of this expression.
57   const MCExpr *getSubExpr() const { return Expr; }
58
59   /// @}
60
61   void PrintImpl(raw_ostream &OS) const;
62   bool EvaluateAsRelocatableImpl(MCValue &Res,
63                                  const MCAsmLayout *Layout) const;
64   void AddValueSymbols(MCAssembler *) const;
65   const MCSection *FindAssociatedSection() const {
66     return getSubExpr()->FindAssociatedSection();
67   }
68
69   // There are no TLS PPCMCExprs at the moment.
70   void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
71
72   static bool classof(const MCExpr *E) {
73     return E->getKind() == MCExpr::Target;
74   }
75 };
76 } // end namespace llvm
77
78 #endif