2017-02-10 01:33:54 +00:00
|
|
|
//===- llvm/MC/MachineLocation.h --------------------------------*- C++ -*-===//
|
2006-03-23 18:01:12 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-03-23 18:01:12 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// The MachineLocation class is used to represent a simple location in a machine
|
|
|
|
// frame. Locations will be one of two forms; a register or an address formed
|
2006-04-07 16:34:46 +00:00
|
|
|
// from a base address plus an offset. Register indirection can be specified by
|
2013-04-26 21:57:17 +00:00
|
|
|
// explicitly passing an offset to the constructor.
|
2006-03-23 18:01:12 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-07-18 22:29:13 +00:00
|
|
|
#ifndef LLVM_MC_MACHINELOCATION_H
|
|
|
|
#define LLVM_MC_MACHINELOCATION_H
|
2006-03-23 18:01:12 +00:00
|
|
|
|
2017-02-10 01:33:54 +00:00
|
|
|
#include <cstdint>
|
2017-08-01 22:57:05 +00:00
|
|
|
#include <cassert>
|
2013-09-23 23:26:57 +00:00
|
|
|
|
2006-03-23 18:01:12 +00:00
|
|
|
namespace llvm {
|
2012-05-11 01:39:13 +00:00
|
|
|
|
2006-03-23 18:01:12 +00:00
|
|
|
class MachineLocation {
|
|
|
|
private:
|
2017-08-02 17:07:38 +00:00
|
|
|
bool IsRegister = false; ///< True if location is a register.
|
|
|
|
unsigned Register = 0; ///< gcc/gdb register number.
|
2017-02-10 01:33:54 +00:00
|
|
|
|
2006-03-23 18:01:12 +00:00
|
|
|
public:
|
2014-03-02 03:20:38 +00:00
|
|
|
enum : uint32_t {
|
2006-04-07 16:34:46 +00:00
|
|
|
// The target register number for an abstract frame pointer. The value is
|
2011-01-08 23:10:53 +00:00
|
|
|
// an arbitrary value that doesn't collide with any real target register.
|
2006-04-07 16:34:46 +00:00
|
|
|
VirtualFP = ~0U
|
|
|
|
};
|
2017-02-10 01:33:54 +00:00
|
|
|
|
|
|
|
MachineLocation() = default;
|
2013-04-26 21:57:17 +00:00
|
|
|
/// Create a direct register location.
|
2017-08-02 17:07:38 +00:00
|
|
|
explicit MachineLocation(unsigned R, bool Indirect = false)
|
|
|
|
: IsRegister(!Indirect), Register(R) {}
|
2011-02-04 22:57:18 +00:00
|
|
|
|
|
|
|
bool operator==(const MachineLocation &Other) const {
|
2017-08-02 17:07:38 +00:00
|
|
|
return IsRegister == Other.IsRegister && Register == Other.Register;
|
2011-02-04 22:57:18 +00:00
|
|
|
}
|
2012-05-11 01:39:13 +00:00
|
|
|
|
2013-09-18 22:08:59 +00:00
|
|
|
// Accessors.
|
|
|
|
/// \return true iff this is a register-indirect location.
|
2013-04-26 21:57:17 +00:00
|
|
|
bool isIndirect() const { return !IsRegister; }
|
2008-10-03 15:45:36 +00:00
|
|
|
bool isReg() const { return IsRegister; }
|
|
|
|
unsigned getReg() const { return Register; }
|
2006-03-23 18:01:12 +00:00
|
|
|
void setIsRegister(bool Is) { IsRegister = Is; }
|
|
|
|
void setRegister(unsigned R) { Register = R; }
|
2006-04-07 16:34:46 +00:00
|
|
|
};
|
2014-04-01 21:54:52 +00:00
|
|
|
|
|
|
|
inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
|
|
|
|
return !(LHS == RHS);
|
|
|
|
}
|
|
|
|
|
2017-02-10 01:33:54 +00:00
|
|
|
} // end namespace llvm
|
2006-03-23 18:01:12 +00:00
|
|
|
|
2017-02-10 01:33:54 +00:00
|
|
|
#endif // LLVM_MC_MACHINELOCATION_H
|