[ARM] MVE integer min and max
[llvm-complete.git] / include / llvm / CodeGen / Register.h
blob907c1a99e56f5ce08f1efdb6eda2aea66985742a
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CODEGEN_REGISTER_H
10 #define LLVM_CODEGEN_REGISTER_H
12 #include <cassert>
14 namespace llvm {
16 /// Wrapper class representing virtual and physical registers. Should be passed
17 /// by value.
18 class Register {
19 unsigned Reg;
21 public:
22 Register(unsigned Val = 0): Reg(Val) {}
24 /// Return true if the specified register number is in the virtual register
25 /// namespace.
26 bool isVirtual() const {
27 return int(Reg) < 0;
30 /// Return true if the specified register number is in the physical register
31 /// namespace.
32 bool isPhysical() const {
33 return int(Reg) > 0;
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 unsigned virtRegIndex() const {
39 assert(isVirtual() && "Not a virtual register");
40 return Reg & ~(1u << 31);
43 /// Convert a 0-based index to a virtual register number.
44 /// This is the inverse operation of VirtReg2IndexFunctor below.
45 static Register index2VirtReg(unsigned Index) {
46 return Register(Index | (1u << 31));
49 operator unsigned() const {
50 return Reg;
53 bool isValid() const {
54 return Reg != 0;
60 #endif