Don't attribute in file headers anymore. See llvmdev for the
[oota-llvm.git] / include / llvm / CodeGen / MachineLocation.h
1 //===-- llvm/CodeGen/MachineLocation.h --------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
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.
13 //
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
17 // frames.
18 //===----------------------------------------------------------------------===//
19
20
21 #ifndef LLVM_CODEGEN_MACHINELOCATION_H
22 #define LLVM_CODEGEN_MACHINELOCATION_H
23
24 namespace llvm {
25
26 class MachineLocation {
27 private:
28   bool IsRegister;                      // True if location is a register.
29   unsigned Register;                    // gcc/gdb register number.
30   int Offset;                           // Displacement if not register.
31
32 public:
33   enum {
34     // The target register number for an abstract frame pointer. The value is
35     // an arbitrary value greater than MRegisterInfo::FirstVirtualRegister.
36     VirtualFP = ~0U
37   };
38   MachineLocation()
39   : IsRegister(false)
40   , Register(0)
41   , Offset(0)
42   {}
43   explicit MachineLocation(unsigned R)
44   : IsRegister(true)
45   , Register(R)
46   , Offset(0)
47   {}
48   MachineLocation(unsigned R, int O)
49   : IsRegister(false)
50   , Register(R)
51   , Offset(O)
52   {}
53   
54   // Accessors
55   bool isRegister()      const { return IsRegister; }
56   unsigned getRegister() const { return Register; }
57   int getOffset()        const { return Offset; }
58   void setIsRegister(bool Is)  { IsRegister = Is; }
59   void setRegister(unsigned R) { Register = R; }
60   void setOffset(int O)        { Offset = O; }
61   void set(unsigned R) {
62     IsRegister = true;
63     Register = R;
64     Offset = 0;
65   }
66   void set(unsigned R, int O) {
67     IsRegister = false;
68     Register = R;
69     Offset = O;
70   }
71
72 #ifndef NDEBUG
73   void dump();
74 #endif
75 };
76
77 class MachineMove {
78 private:
79   unsigned LabelID;                     // Label ID number for post-instruction
80                                         // address when result of move takes
81                                         // effect.
82   MachineLocation Destination;          // Move to location.
83   MachineLocation Source;               // Move from location.
84   
85 public:
86   MachineMove()
87   : LabelID(0)
88   , Destination()
89   , Source()
90   {}
91
92   MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S)
93   : LabelID(ID)
94   , Destination(D)
95   , Source(S)
96   {}
97   
98   // Accessors
99   unsigned getLabelID()                   const { return LabelID; }
100   const MachineLocation &getDestination() const { return Destination; }
101   const MachineLocation &getSource()      const { return Source; }
102 };
103
104 } // End llvm namespace
105
106 #endif