LLVM API Documentation
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 /// Return true if the instruction is a register to register move and return 00049 /// the source and dest operands and their sub-register indices by reference. 00050 virtual bool isMoveInstr(const MachineInstr &MI, 00051 unsigned &SrcReg, unsigned &DstReg, 00052 unsigned &SrcSubIdx, unsigned &DstSubIdx) const; 00053 00054 unsigned isLoadFromStackSlot(const MachineInstr *MI, 00055 int &FrameIndex) const; 00056 unsigned isStoreToStackSlot(const MachineInstr *MI, 00057 int &FrameIndex) const; 00058 00059 virtual bool copyRegToReg(MachineBasicBlock &MBB, 00060 MachineBasicBlock::iterator MI, 00061 unsigned DestReg, unsigned SrcReg, 00062 const TargetRegisterClass *DestRC, 00063 const TargetRegisterClass *SrcRC) const; 00064 00065 //! Store a register to a stack slot, based on its register class. 00066 virtual void storeRegToStackSlot(MachineBasicBlock &MBB, 00067 MachineBasicBlock::iterator MBBI, 00068 unsigned SrcReg, bool isKill, int FrameIndex, 00069 const TargetRegisterClass *RC) const; 00070 00071 //! Load a register from a stack slot, based on its register class. 00072 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, 00073 MachineBasicBlock::iterator MBBI, 00074 unsigned DestReg, int FrameIndex, 00075 const TargetRegisterClass *RC) const; 00076 00077 //! Return true if the specified load or store can be folded 00078 virtual 00079 bool canFoldMemoryOperand(const MachineInstr *MI, 00080 const SmallVectorImpl<unsigned> &Ops) const; 00081 00082 //! Return true if the specified block does not fall through 00083 virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; 00084 00085 //! Reverses a branch's condition, returning false on success. 00086 virtual 00087 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; 00088 00089 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, 00090 MachineBasicBlock *&FBB, 00091 SmallVectorImpl<MachineOperand> &Cond, 00092 bool AllowModify) const; 00093 00094 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; 00095 00096 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, 00097 MachineBasicBlock *FBB, 00098 const SmallVectorImpl<MachineOperand> &Cond) const; 00099 }; 00100 } 00101 00102 #endif