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 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_MC_MACHINELOCATION_H
17 #define LLVM_MC_MACHINELOCATION_H
19 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/DataTypes.h"
25 class MachineLocation {
27 bool IsRegister; // True if location is a register.
28 unsigned Register; // gcc/gdb register number.
29 int Offset; // Displacement if not register.
32 // The target register number for an abstract frame pointer. The value is
33 // an arbitrary value that doesn't collide with any real target register.
37 : IsRegister(false), Register(0), Offset(0) {}
38 /// Create a direct register location.
39 explicit MachineLocation(unsigned R)
40 : IsRegister(true), Register(R), Offset(0) {}
41 /// Create a register-indirect location with an offset.
42 MachineLocation(unsigned R, int O)
43 : IsRegister(false), Register(R), Offset(O) {}
45 bool operator==(const MachineLocation &Other) const {
46 return IsRegister == Other.IsRegister && Register == Other.Register &&
47 Offset == Other.Offset;
51 /// \return true iff this is a register-indirect location.
52 bool isIndirect() const { return !IsRegister; }
53 bool isReg() const { return IsRegister; }
54 unsigned getReg() const { return Register; }
55 int getOffset() const { return Offset; }
56 void setIsRegister(bool Is) { IsRegister = Is; }
57 void setRegister(unsigned R) { Register = R; }
58 void setOffset(int O) { Offset = O; }
59 /// Make this location a direct register location.
60 void set(unsigned R) {
65 /// Make this location a register-indirect+offset location.
66 void set(unsigned R, int O) {
77 inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
81 } // End llvm namespace