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 is distributed under the University of Illinois Open Source
00006 // 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 TargetRegisterInfo::FirstVirtualRegister.
00036     VirtualFP = ~0U
00037   };
00038   MachineLocation()
00039   : IsRegister(false)
00040   , Register(0)
00041   , Offset(0)
00042   {}
00043   explicit 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 isReg()           const { return IsRegister; }
00056   unsigned getReg()      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   MachineLocation Destination;          // Move to location.
00083   MachineLocation Source;               // Move from location.
00084   
00085 public:
00086   MachineMove()
00087   : LabelID(0)
00088   , Destination()
00089   , Source()
00090   {}
00091 
00092   MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S)
00093   : LabelID(ID)
00094   , Destination(D)
00095   , Source(S)
00096   {}
00097   
00098   // Accessors
00099   unsigned getLabelID()                   const { return LabelID; }
00100   const MachineLocation &getDestination() const { return Destination; }
00101   const MachineLocation &getSource()      const { return Source; }
00102 };
00103 
00104 } // End llvm namespace
00105 
00106 #endif