LLVM API Documentation

MachineLocation.h

Go to the documentation of this file.
00001 //===-- llvm/CodeGen/MachineLocation.h --------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by James M. Laskey and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 // The MachineLocation class is used to represent a simple location in a machine
00010 // frame.  Locations will be one of two forms; a register or an address formed
00011 // from a base address plus an offset.  Register indirection can be specified by
00012 // using an offset of zero.
00013 //
00014 // The MachineMove class is used to represent abstract move operations in the 
00015 // prolog/epilog of a compiled function.  A collection of these objects can be
00016 // used by a debug consumer to track the location of values when unwinding stack
00017 // frames.
00018 //===----------------------------------------------------------------------===//
00019 
00020 
00021 #ifndef LLVM_CODEGEN_MACHINELOCATION_H
00022 #define LLVM_CODEGEN_MACHINELOCATION_H
00023 
00024 namespace llvm {
00025 
00026 class MachineLocation {
00027 private:
00028   bool IsRegister;                      // True if location is a register.
00029   unsigned Register;                    // gcc/gdb register number.
00030   int Offset;                           // Displacement if not register.
00031 
00032 public:
00033   enum {
00034     // The target register number for an abstract frame pointer. The value is
00035     // an arbitrary value greater than MRegisterInfo::FirstVirtualRegister.
00036     VirtualFP = ~0U
00037   };
00038   MachineLocation()
00039   : IsRegister(false)
00040   , Register(0)
00041   , Offset(0)
00042   {}
00043   MachineLocation(unsigned R)
00044   : IsRegister(true)
00045   , Register(R)
00046   , Offset(0)
00047   {}
00048   MachineLocation(unsigned R, int O)
00049   : IsRegister(false)
00050   , Register(R)
00051   , Offset(O)
00052   {}
00053   
00054   // Accessors
00055   bool isRegister()      const { return IsRegister; }
00056   unsigned getRegister() const { return Register; }
00057   int getOffset()        const { return Offset; }
00058   void setIsRegister(bool Is)  { IsRegister = Is; }
00059   void setRegister(unsigned R) { Register = R; }
00060   void setOffset(int O)        { Offset = O; }
00061   void set(unsigned R) {
00062     IsRegister = true;
00063     Register = R;
00064     Offset = 0;
00065   }
00066   void set(unsigned R, int O) {
00067     IsRegister = false;
00068     Register = R;
00069     Offset = O;
00070   }
00071 
00072 #ifndef NDEBUG
00073   void dump();
00074 #endif
00075 };
00076 
00077 class MachineMove {
00078 private:
00079   unsigned LabelID;                     // Label ID number for post-instruction
00080                                         // address when result of move takes
00081                                         // effect.
00082   const MachineLocation Destination;    // Move to location.
00083   const MachineLocation Source;         // Move from location.
00084   
00085 public:
00086   MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S)
00087   : LabelID(ID)
00088   , Destination(D)
00089   , Source(S)
00090   {}
00091   
00092   // Accessors
00093   unsigned getLabelID()                   const { return LabelID; }
00094   const MachineLocation &getDestination() const { return Destination; }
00095   const MachineLocation &getSource()      const { return Source; }
00096 };
00097 
00098 } // End llvm namespace
00099 
00100 #endif