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 // using an offset of zero.
14 // The MachineMove class is used to represent abstract move operations in the
15 // prolog/epilog of a compiled function. A collection of these objects can be
16 // used by a debug consumer to track the location of values when unwinding stack
18 //===----------------------------------------------------------------------===//
21 #ifndef LLVM_MC_MACHINELOCATION_H
22 #define LLVM_MC_MACHINELOCATION_H
27 class MachineLocation {
29 bool IsRegister; // True if location is a register.
30 unsigned Register; // gcc/gdb register number.
31 int Offset; // Displacement if not register.
34 // The target register number for an abstract frame pointer. The value is
35 // an arbitrary value that doesn't collide with any real target register.
39 : IsRegister(false), Register(0), Offset(0) {}
40 explicit MachineLocation(unsigned R)
41 : IsRegister(true), Register(R), Offset(0) {}
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 bool isReg() const { return IsRegister; }
52 unsigned getReg() const { return Register; }
53 int getOffset() const { return Offset; }
54 void setIsRegister(bool Is) { IsRegister = Is; }
55 void setRegister(unsigned R) { Register = R; }
56 void setOffset(int O) { Offset = O; }
57 void set(unsigned R) {
62 void set(unsigned R, int O) {
73 /// MachineMove - This class represents the save or restore of a callee saved
74 /// register that exception or debug info needs to know about.
77 /// Label - Symbol for post-instruction address when result of move takes
81 // Move to & from location.
82 MachineLocation Destination, Source;
84 MachineMove() : Label(0) {}
86 MachineMove(MCSymbol *label, const MachineLocation &D,
87 const MachineLocation &S)
88 : Label(label), Destination(D), Source(S) {}
91 MCSymbol *getLabel() const { return Label; }
92 const MachineLocation &getDestination() const { return Destination; }
93 const MachineLocation &getSource() const { return Source; }
96 } // End llvm namespace