Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
10
#define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
11
12
#include "llvm/MC/MCAsmLayout.h"
13
#include "llvm/MC/MCExpr.h"
14
#include "llvm/MC/MCValue.h"
15
16
namespace llvm {
17
18
class PPCMCExpr : public MCTargetExpr {
19
public:
20
  enum VariantKind {
21
    VK_PPC_None,
22
    VK_PPC_LO,
23
    VK_PPC_HI,
24
    VK_PPC_HA,
25
    VK_PPC_HIGH,
26
    VK_PPC_HIGHA,
27
    VK_PPC_HIGHER,
28
    VK_PPC_HIGHERA,
29
    VK_PPC_HIGHEST,
30
    VK_PPC_HIGHESTA
31
  };
32
33
private:
34
  const VariantKind Kind;
35
  const MCExpr *Expr;
36
  bool IsDarwin;
37
38
  int64_t evaluateAsInt64(int64_t Value) const;
39
40
  explicit PPCMCExpr(VariantKind Kind, const MCExpr *Expr, bool IsDarwin)
41
4.00k
      : Kind(Kind), Expr(Expr), IsDarwin(IsDarwin) {}
42
43
public:
44
  /// @name Construction
45
  /// @{
46
47
  static const PPCMCExpr *create(VariantKind Kind, const MCExpr *Expr,
48
                                 bool isDarwin, MCContext &Ctx);
49
50
  static const PPCMCExpr *createLo(const MCExpr *Expr,
51
1.80k
                                   bool isDarwin, MCContext &Ctx) {
52
1.80k
    return create(VK_PPC_LO, Expr, isDarwin, Ctx);
53
1.80k
  }
54
55
  static const PPCMCExpr *createHi(const MCExpr *Expr,
56
0
                                   bool isDarwin, MCContext &Ctx) {
57
0
    return create(VK_PPC_HI, Expr, isDarwin, Ctx);
58
0
  }
59
60
  static const PPCMCExpr *createHa(const MCExpr *Expr,
61
1.79k
                                   bool isDarwin, MCContext &Ctx) {
62
1.79k
    return create(VK_PPC_HA, Expr, isDarwin, Ctx);
63
1.79k
  }
64
65
  /// @}
66
  /// @name Accessors
67
  /// @{
68
69
  /// getOpcode - Get the kind of this expression.
70
292
  VariantKind getKind() const { return Kind; }
71
72
  /// getSubExpr - Get the child of this expression.
73
4.76k
  const MCExpr *getSubExpr() const { return Expr; }
74
75
  /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
76
3.67k
  bool isDarwinSyntax() const { return IsDarwin; }
77
78
79
  /// @}
80
81
  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
82
  bool evaluateAsRelocatableImpl(MCValue &Res,
83
                                 const MCAsmLayout *Layout,
84
                                 const MCFixup *Fixup) const override;
85
  void visitUsedExpr(MCStreamer &Streamer) const override;
86
0
  MCFragment *findAssociatedFragment() const override {
87
0
    return getSubExpr()->findAssociatedFragment();
88
0
  }
89
90
  // There are no TLS PPCMCExprs at the moment.
91
328
  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
92
93
  bool evaluateAsConstant(int64_t &Res) const;
94
95
2.16k
  static bool classof(const MCExpr *E) {
96
2.16k
    return E->getKind() == MCExpr::Target;
97
2.16k
  }
98
};
99
} // end namespace llvm
100
101
#endif