Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
Line
Count
Source (jump to first uncovered line)
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 LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
11
#define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
12
13
#include "llvm/MC/MCAsmLayout.h"
14
#include "llvm/MC/MCExpr.h"
15
#include "llvm/MC/MCValue.h"
16
17
namespace llvm {
18
19
class PPCMCExpr : public MCTargetExpr {
20
public:
21
  enum VariantKind {
22
    VK_PPC_None,
23
    VK_PPC_LO,
24
    VK_PPC_HI,
25
    VK_PPC_HA,
26
    VK_PPC_HIGHER,
27
    VK_PPC_HIGHERA,
28
    VK_PPC_HIGHEST,
29
    VK_PPC_HIGHESTA
30
  };
31
32
private:
33
  const VariantKind Kind;
34
  const MCExpr *Expr;
35
  bool IsDarwin;
36
37
  int64_t evaluateAsInt64(int64_t Value) const;
38
39
  explicit PPCMCExpr(VariantKind Kind, const MCExpr *Expr, bool IsDarwin)
40
1.86k
      : Kind(Kind), Expr(Expr), IsDarwin(IsDarwin) {}
41
42
public:
43
  /// @name Construction
44
  /// @{
45
46
  static const PPCMCExpr *create(VariantKind Kind, const MCExpr *Expr,
47
                                 bool isDarwin, MCContext &Ctx);
48
49
  static const PPCMCExpr *createLo(const MCExpr *Expr,
50
878
                                   bool isDarwin, MCContext &Ctx) {
51
878
    return create(VK_PPC_LO, Expr, isDarwin, Ctx);
52
878
  }
53
54
  static const PPCMCExpr *createHi(const MCExpr *Expr,
55
0
                                   bool isDarwin, MCContext &Ctx) {
56
0
    return create(VK_PPC_HI, Expr, isDarwin, Ctx);
57
0
  }
58
59
  static const PPCMCExpr *createHa(const MCExpr *Expr,
60
834
                                   bool isDarwin, MCContext &Ctx) {
61
834
    return create(VK_PPC_HA, Expr, isDarwin, Ctx);
62
834
  }
63
64
  /// @}
65
  /// @name Accessors
66
  /// @{
67
68
  /// getOpcode - Get the kind of this expression.
69
58
  VariantKind getKind() const { return Kind; }
70
71
  /// getSubExpr - Get the child of this expression.
72
2.14k
  const MCExpr *getSubExpr() const { return Expr; }
73
74
  /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
75
1.78k
  bool isDarwinSyntax() const { return IsDarwin; }
76
77
78
  /// @}
79
80
  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
81
  bool evaluateAsRelocatableImpl(MCValue &Res,
82
                                 const MCAsmLayout *Layout,
83
                                 const MCFixup *Fixup) const override;
84
  void visitUsedExpr(MCStreamer &Streamer) const override;
85
0
  MCFragment *findAssociatedFragment() const override {
86
0
    return getSubExpr()->findAssociatedFragment();
87
0
  }
88
89
  // There are no TLS PPCMCExprs at the moment.
90
90
  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
91
92
  bool evaluateAsConstant(int64_t &Res) const;
93
94
1.31k
  static bool classof(const MCExpr *E) {
95
1.31k
    return E->getKind() == MCExpr::Target;
96
1.31k
  }
97
};
98
} // end namespace llvm
99
100
#endif