Make sure to consider alignment of variable sized objects.
[oota-llvm.git] / include / llvm / CodeGen / MachineLocation.h
1 //===-- llvm/CodeGen/MachineLocation.h --------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by James M. Laskey and is distributed under
6 // the University of Illinois Open Source 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.
12 //===----------------------------------------------------------------------===//
13
14
15 #ifndef LLVM_CODEGEN_MACHINELOCATION_H
16 #define LLVM_CODEGEN_MACHINELOCATION_H
17
18 namespace llvm {
19
20 class MachineLocation {
21 private:
22   bool IsRegister;                      // True if location is a register.
23   unsigned Register;                    // gcc/gdb register number.
24   int Offset;                           // Displacement if not register.
25
26 public:
27   MachineLocation()
28   : IsRegister(false)
29   , Register(0)
30   , Offset(0)
31   {}
32   MachineLocation(unsigned R)
33   : IsRegister(true)
34   , Register(R)
35   , Offset(0)
36   {}
37   MachineLocation(unsigned R, int O)
38   : IsRegister(false)
39   , Register(R)
40   , Offset(0)
41   {}
42   
43   // Accessors
44   bool isRegister()      const { return IsRegister; }
45   unsigned getRegister() const { return Register; }
46   int getOffset()        const { return Offset; }
47   void setIsRegister(bool Is)  { IsRegister = Is; }
48   void setRegister(unsigned R) { Register = R; }
49   void setOffset(int O)        { Offset = O; }
50   void set(unsigned R) {
51     IsRegister = true;
52     Register = R;
53     Offset = 0;
54   }
55   void set(unsigned R, int O) {
56     IsRegister = false;
57     Register = R;
58     Offset = O;
59   }
60 };
61
62 } // End llvm namespace
63
64 #endif