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
22 class MachineLocation {
24 bool IsRegister; // True if location is a register.
25 unsigned Register; // gcc/gdb register number.
26 int Offset; // Displacement if not register.
29 // The target register number for an abstract frame pointer. The value is
30 // an arbitrary value that doesn't collide with any real target register.
34 : IsRegister(false), Register(0), Offset(0) {}
35 /// Create a direct register location.
36 explicit MachineLocation(unsigned R)
37 : IsRegister(true), Register(R), Offset(0) {}
38 /// Create a register-indirect location with an offset.
39 MachineLocation(unsigned R, int O)
40 : IsRegister(false), Register(R), Offset(O) {}
42 bool operator==(const MachineLocation &Other) const {
43 return IsRegister == Other.IsRegister && Register == Other.Register &&
44 Offset == Other.Offset;
48 bool isIndirect() const { return !IsRegister; }
49 bool isReg() const { return IsRegister; }
50 unsigned getReg() const { return Register; }
51 int getOffset() const { return Offset; }
52 void setIsRegister(bool Is) { IsRegister = Is; }
53 void setRegister(unsigned R) { Register = R; }
54 void setOffset(int O) { Offset = O; }
55 /// Make this location a direct register location.
56 void set(unsigned R) {
61 /// Make this location a register-indirect+offset location.
62 void set(unsigned R, int O) {
72 } // End llvm namespace