1 //===- llvm/MC/MachineLocation.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
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 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_MC_MACHINELOCATION_H
16 #define LLVM_MC_MACHINELOCATION_H
23 class MachineLocation {
25 bool IsRegister = false; ///< True if location is a register.
26 unsigned Register = 0; ///< gcc/gdb register number.
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.
35 MachineLocation() = default;
36 /// Create a direct register location.
37 explicit MachineLocation(unsigned R, bool Indirect = false)
38 : IsRegister(!Indirect), Register(R) {}
40 bool operator==(const MachineLocation &Other) const {
41 return IsRegister == Other.IsRegister && Register == Other.Register;
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; }
53 inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
57 } // end namespace llvm
59 #endif // LLVM_MC_MACHINELOCATION_H