Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/MC/MCValue.h
Line
Count
Source
1
//===-- llvm/MC/MCValue.h - MCValue class -----------------------*- 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
// This file contains the declaration of the MCValue class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_MC_MCVALUE_H
15
#define LLVM_MC_MCVALUE_H
16
17
#include "llvm/MC/MCExpr.h"
18
#include "llvm/MC/MCSymbol.h"
19
#include "llvm/Support/DataTypes.h"
20
#include <cassert>
21
22
namespace llvm {
23
class MCAsmInfo;
24
class raw_ostream;
25
26
/// \brief This represents an "assembler immediate".
27
///
28
///  In its most general form, this can hold ":Kind:(SymbolA - SymbolB +
29
///  imm64)".  Not all targets supports relocations of this general form, but we
30
///  need to represent this anyway.
31
///
32
/// In general both SymbolA and SymbolB will also have a modifier
33
/// analogous to the top-level Kind. Current targets are not expected
34
/// to make use of both though. The choice comes down to whether
35
/// relocation modifiers apply to the closest symbol or the whole
36
/// expression.
37
///
38
/// Note that this class must remain a simple POD value class, because we need
39
/// it to live in unions etc.
40
class MCValue {
41
  const MCSymbolRefExpr *SymA, *SymB;
42
  int64_t Cst;
43
  uint32_t RefKind;
44
public:
45
32.6M
  MCValue() : SymA(nullptr), SymB(nullptr), Cst(0), RefKind(0) {}
46
16.9M
  int64_t getConstant() const { return Cst; }
47
33.9M
  const MCSymbolRefExpr *getSymA() const { return SymA; }
48
30.0M
  const MCSymbolRefExpr *getSymB() const { return SymB; }
49
13.5k
  uint32_t getRefKind() const { return RefKind; }
50
51
  /// \brief Is this an absolute (as opposed to relocatable) value.
52
9.51M
  bool isAbsolute() const 
{ return !SymA && 9.51M
!SymB771k
; }
53
54
  /// \brief Print the value to the stream \p OS.
55
  void print(raw_ostream &OS) const;
56
57
  /// \brief Print the value to stderr.
58
  void dump() const;
59
60
  MCSymbolRefExpr::VariantKind getAccessVariant() const;
61
62
  static MCValue get(const MCSymbolRefExpr *SymA,
63
                     const MCSymbolRefExpr *SymB = nullptr,
64
11.6M
                     int64_t Val = 0, uint32_t RefKind = 0) {
65
11.6M
    MCValue R;
66
11.6M
    R.Cst = Val;
67
11.6M
    R.SymA = SymA;
68
11.6M
    R.SymB = SymB;
69
11.6M
    R.RefKind = RefKind;
70
11.6M
    return R;
71
11.6M
  }
72
73
587k
  static MCValue get(int64_t Val) {
74
587k
    MCValue R;
75
587k
    R.Cst = Val;
76
587k
    R.SymA = nullptr;
77
587k
    R.SymB = nullptr;
78
587k
    R.RefKind = 0;
79
587k
    return R;
80
587k
  }
81
82
};
83
84
} // end namespace llvm
85
86
#endif