LLVM  8.0.1
MachineLocation.h
Go to the documentation of this file.
1 //===- llvm/MC/MachineLocation.h --------------------------------*- 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 // The MachineLocation class is used to represent a simple location in a machine
10 // frame. Locations will be one of two forms; a register or an address formed
11 // from a base address plus an offset. Register indirection can be specified by
12 // explicitly passing an offset to the constructor.
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_MC_MACHINELOCATION_H
16 #define LLVM_MC_MACHINELOCATION_H
17 
18 #include <cstdint>
19 #include <cassert>
20 
21 namespace llvm {
22 
24 private:
25  bool IsRegister = false; ///< True if location is a register.
26  unsigned Register = 0; ///< gcc/gdb register number.
27 
28 public:
29  enum : uint32_t {
30  // The target register number for an abstract frame pointer. The value is
31  // an arbitrary value that doesn't collide with any real target register.
32  VirtualFP = ~0U
33  };
34 
35  MachineLocation() = default;
36  /// Create a direct register location.
37  explicit MachineLocation(unsigned R, bool Indirect = false)
38  : IsRegister(!Indirect), Register(R) {}
39 
40  bool operator==(const MachineLocation &Other) const {
41  return IsRegister == Other.IsRegister && Register == Other.Register;
42  }
43 
44  // Accessors.
45  /// \return true iff this is a register-indirect location.
46  bool isIndirect() const { return !IsRegister; }
47  bool isReg() const { return IsRegister; }
48  unsigned getReg() const { return Register; }
49  void setIsRegister(bool Is) { IsRegister = Is; }
50  void setRegister(unsigned R) { Register = R; }
51 };
52 
53 inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
54  return !(LHS == RHS);
55 }
56 
57 } // end namespace llvm
58 
59 #endif // LLVM_MC_MACHINELOCATION_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned getReg() const
bool operator==(const MachineLocation &Other) const
void setIsRegister(bool Is)
void setRegister(unsigned R)
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1969
MachineLocation(unsigned R, bool Indirect=false)
Create a direct register location.