LLVM API Documentation

XCoreInstrInfo.h

Go to the documentation of this file.
00001 //===- XCoreInstrInfo.h - XCore 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 XCore implementation of the TargetInstrInfo class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef XCOREINSTRUCTIONINFO_H
00015 #define XCOREINSTRUCTIONINFO_H
00016 
00017 #include "llvm/Target/TargetInstrInfo.h"
00018 #include "XCoreRegisterInfo.h"
00019 
00020 namespace llvm {
00021 
00022 class XCoreInstrInfo : public TargetInstrInfoImpl {
00023   const XCoreRegisterInfo RI;
00024 public:
00025   XCoreInstrInfo(void);
00026 
00027   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
00028   /// such, whenever a client has an instance of instruction info, it should
00029   /// always be able to get register info as well (through this method).
00030   ///
00031   virtual const TargetRegisterInfo &getRegisterInfo() const { return RI; }
00032 
00033   /// Return true if the instruction is a register to register move and return
00034   /// the source and dest operands and their sub-register indices by reference.
00035   virtual bool isMoveInstr(const MachineInstr &MI,
00036                            unsigned &SrcReg, unsigned &DstReg,
00037                            unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
00038   
00039   /// isLoadFromStackSlot - If the specified machine instruction is a direct
00040   /// load from a stack slot, return the virtual or physical register number of
00041   /// the destination along with the FrameIndex of the loaded stack slot.  If
00042   /// not, return 0.  This predicate must return 0 if the instruction has
00043   /// any side effects other than loading from the stack slot.
00044   virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
00045                                        int &FrameIndex) const;
00046   
00047   /// isStoreToStackSlot - If the specified machine instruction is a direct
00048   /// store to a stack slot, return the virtual or physical register number of
00049   /// the source reg along with the FrameIndex of the loaded stack slot.  If
00050   /// not, return 0.  This predicate must return 0 if the instruction has
00051   /// any side effects other than storing to the stack slot.
00052   virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
00053                                       int &FrameIndex) const;
00054   
00055   virtual bool isInvariantLoad(const MachineInstr *MI) const;
00056   
00057   virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
00058                              MachineBasicBlock *&FBB,
00059                              SmallVectorImpl<MachineOperand> &Cond,
00060                              bool AllowModify) const;
00061   
00062   virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
00063                              MachineBasicBlock *FBB,
00064                              const SmallVectorImpl<MachineOperand> &Cond) const;
00065   
00066   virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
00067 
00068   virtual bool copyRegToReg(MachineBasicBlock &MBB,
00069                             MachineBasicBlock::iterator I,
00070                             unsigned DestReg, unsigned SrcReg,
00071                             const TargetRegisterClass *DestRC,
00072                             const TargetRegisterClass *SrcRC) const;
00073 
00074   virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
00075                                    MachineBasicBlock::iterator MI,
00076                                    unsigned SrcReg, bool isKill, int FrameIndex,
00077                                    const TargetRegisterClass *RC) const;
00078 
00079   virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
00080                               SmallVectorImpl<MachineOperand> &Addr,
00081                               const TargetRegisterClass *RC,
00082                               SmallVectorImpl<MachineInstr*> &NewMIs) const;
00083 
00084   virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
00085                                     MachineBasicBlock::iterator MI,
00086                                     unsigned DestReg, int FrameIndex,
00087                                     const TargetRegisterClass *RC) const;
00088 
00089   virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
00090                                SmallVectorImpl<MachineOperand> &Addr,
00091                                const TargetRegisterClass *RC,
00092                                SmallVectorImpl<MachineInstr*> &NewMIs) const;
00093              
00094   virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
00095                                         MachineBasicBlock::iterator MI,
00096                                 const std::vector<CalleeSavedInfo> &CSI) const;
00097   
00098   virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
00099                                          MachineBasicBlock::iterator MI,
00100                                const std::vector<CalleeSavedInfo> &CSI) const;
00101 
00102   virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
00103 
00104   virtual bool ReverseBranchCondition(
00105                             SmallVectorImpl<MachineOperand> &Cond) const;
00106 };
00107 
00108 }
00109 
00110 #endif