LLVM API Documentation

SPUInstrInfo.h

Go to the documentation of this file.
00001 //===- SPUInstrInfo.h - Cell SPU Instruction Information --------*- 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 //
00010 // This file contains the CellSPU implementation of the TargetInstrInfo class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef SPU_INSTRUCTIONINFO_H
00015 #define SPU_INSTRUCTIONINFO_H
00016 
00017 #include "SPU.h"
00018 #include "llvm/Target/TargetInstrInfo.h"
00019 #include "SPURegisterInfo.h"
00020 
00021 namespace llvm {
00022   //! Cell SPU instruction information class
00023   class SPUInstrInfo : public TargetInstrInfoImpl {
00024     SPUTargetMachine &TM;
00025     const SPURegisterInfo RI;
00026   protected:
00027     virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
00028                                             MachineInstr* MI,
00029                                             const SmallVectorImpl<unsigned> &Ops,
00030                                             int FrameIndex) const;
00031 
00032     virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
00033                                                 MachineInstr* MI,
00034                                                 const SmallVectorImpl<unsigned> &Ops,
00035                                                 MachineInstr* LoadMI) const {
00036       return 0;
00037     }
00038 
00039   public:
00040     explicit SPUInstrInfo(SPUTargetMachine &tm);
00041 
00042     /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
00043     /// such, whenever a client has an instance of instruction info, it should
00044     /// always be able to get register info as well (through this method).
00045     ///
00046     virtual const SPURegisterInfo &getRegisterInfo() const { return RI; }
00047 
00048     /// getPointerRegClass - Return the register class to use to hold pointers.
00049     /// This is used for addressing modes.
00050     virtual const TargetRegisterClass *getPointerRegClass() const;
00051 
00052     /// Return true if the instruction is a register to register move and return
00053     /// the source and dest operands and their sub-register indices by reference.
00054     virtual bool isMoveInstr(const MachineInstr &MI,
00055                              unsigned &SrcReg, unsigned &DstReg,
00056                              unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
00057 
00058     unsigned isLoadFromStackSlot(const MachineInstr *MI,
00059                                  int &FrameIndex) const;
00060     unsigned isStoreToStackSlot(const MachineInstr *MI,
00061                                 int &FrameIndex) const;
00062 
00063     virtual bool copyRegToReg(MachineBasicBlock &MBB,
00064                               MachineBasicBlock::iterator MI,
00065                               unsigned DestReg, unsigned SrcReg,
00066                               const TargetRegisterClass *DestRC,
00067                               const TargetRegisterClass *SrcRC) const;
00068 
00069     //! Store a register to a stack slot, based on its register class.
00070     virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
00071                                      MachineBasicBlock::iterator MBBI,
00072                                      unsigned SrcReg, bool isKill, int FrameIndex,
00073                                      const TargetRegisterClass *RC) const;
00074 
00075     //! Store a register to an address, based on its register class
00076     virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
00077                                                   SmallVectorImpl<MachineOperand> &Addr,
00078                                                   const TargetRegisterClass *RC,
00079                                                   SmallVectorImpl<MachineInstr*> &NewMIs) const;
00080 
00081     //! Load a register from a stack slot, based on its register class.
00082     virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
00083                                       MachineBasicBlock::iterator MBBI,
00084                                       unsigned DestReg, int FrameIndex,
00085                                       const TargetRegisterClass *RC) const;
00086 
00087     //! Loqad a register from an address, based on its register class
00088     virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
00089                                                          SmallVectorImpl<MachineOperand> &Addr,
00090                                                          const TargetRegisterClass *RC,
00091                                  SmallVectorImpl<MachineInstr*> &NewMIs) const;
00092 
00093     //! Return true if the specified load or store can be folded
00094     virtual
00095     bool canFoldMemoryOperand(const MachineInstr *MI,
00096                               const SmallVectorImpl<unsigned> &Ops) const;
00097 
00098     //! Return true if the specified block does not fall through
00099     virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
00100 
00101     //! Reverses a branch's condition, returning false on success.
00102     virtual
00103     bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
00104 
00105     virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
00106                                MachineBasicBlock *&FBB,
00107                                SmallVectorImpl<MachineOperand> &Cond,
00108                                bool AllowModify) const;
00109 
00110     virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
00111 
00112     virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
00113                               MachineBasicBlock *FBB,
00114                               const SmallVectorImpl<MachineOperand> &Cond) const;
00115    };
00116 }
00117 
00118 #endif