Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/Register.h
Line
Count
Source (jump to first uncovered line)
1
//===-- llvm/CodeGen/Register.h ---------------------------------*- 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_CODEGEN_REGISTER_H
10
#define LLVM_CODEGEN_REGISTER_H
11
12
#include <cassert>
13
14
namespace llvm {
15
16
/// Wrapper class representing virtual and physical registers. Should be passed
17
/// by value.
18
class Register {
19
  unsigned Reg;
20
21
public:
22
3.32G
  Register(unsigned Val = 0): Reg(Val) {}
23
24
  /// Return true if the specified register number is in the virtual register
25
  /// namespace.
26
249
  bool isVirtual() const {
27
249
    return int(Reg) < 0;
28
249
  }
29
30
  /// Return true if the specified register number is in the physical register
31
  /// namespace.
32
0
  bool isPhysical() const {
33
0
    return int(Reg) > 0;
34
0
  }
35
36
  /// Convert a virtual register number to a 0-based index. The first virtual
37
  /// register in a function will get the index 0.
38
0
  unsigned virtRegIndex() const {
39
0
    assert(isVirtual() && "Not a virtual register");
40
0
    return Reg & ~(1u << 31);
41
0
  }
42
43
  /// Convert a 0-based index to a virtual register number.
44
  /// This is the inverse operation of VirtReg2IndexFunctor below.
45
0
  static Register index2VirtReg(unsigned Index) {
46
0
    return Register(Index | (1u << 31));
47
0
  }
48
49
3.51G
  operator unsigned() const {
50
3.51G
    return Reg;
51
3.51G
  }
52
53
0
  bool isValid() const {
54
0
    return Reg != 0;
55
0
  }
56
};
57
58
}
59
60
#endif