Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 1 | //===- SPUInstrInfo.h - Cell SPU Instruction Information --------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Scott Michel | 2466c37 | 2007-12-05 01:40:25 +0000 | [diff] [blame] | 10 | // This file contains the CellSPU implementation of the TargetInstrInfo class. |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef SPU_INSTRUCTIONINFO_H |
| 15 | #define SPU_INSTRUCTIONINFO_H |
| 16 | |
| 17 | #include "SPU.h" |
| 18 | #include "llvm/Target/TargetInstrInfo.h" |
| 19 | #include "SPURegisterInfo.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | //! Cell SPU instruction information class |
Chris Lattner | 6410552 | 2008-01-01 01:03:04 +0000 | [diff] [blame] | 23 | class SPUInstrInfo : public TargetInstrInfoImpl { |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 24 | SPUTargetMachine &TM; |
| 25 | const SPURegisterInfo RI; |
Scott Michel | 52d0001 | 2009-01-03 00:27:53 +0000 | [diff] [blame] | 26 | protected: |
| 27 | virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, |
| 28 | MachineInstr* MI, |
| 29 | const SmallVectorImpl<unsigned> &Ops, |
| 30 | int FrameIndex) const; |
| 31 | |
| 32 | virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, |
| 33 | MachineInstr* MI, |
| 34 | const SmallVectorImpl<unsigned> &Ops, |
| 35 | MachineInstr* LoadMI) const { |
| 36 | return 0; |
| 37 | } |
| 38 | |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 39 | public: |
Dan Gohman | 950a4c4 | 2008-03-25 22:06:05 +0000 | [diff] [blame] | 40 | explicit SPUInstrInfo(SPUTargetMachine &tm); |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 41 | |
| 42 | /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As |
| 43 | /// such, whenever a client has an instance of instruction info, it should |
| 44 | /// always be able to get register info as well (through this method). |
| 45 | /// |
Dan Gohman | c9f5f3f | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 46 | virtual const SPURegisterInfo &getRegisterInfo() const { return RI; } |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 47 | |
Evan Cheng | 04ee5a1 | 2009-01-20 19:12:24 +0000 | [diff] [blame] | 48 | /// Return true if the instruction is a register to register move and return |
| 49 | /// the source and dest operands and their sub-register indices by reference. |
| 50 | virtual bool isMoveInstr(const MachineInstr &MI, |
| 51 | unsigned &SrcReg, unsigned &DstReg, |
| 52 | unsigned &SrcSubIdx, unsigned &DstSubIdx) const; |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 53 | |
Dan Gohman | cbad42c | 2008-11-18 19:49:32 +0000 | [diff] [blame] | 54 | unsigned isLoadFromStackSlot(const MachineInstr *MI, |
| 55 | int &FrameIndex) const; |
| 56 | unsigned isStoreToStackSlot(const MachineInstr *MI, |
| 57 | int &FrameIndex) const; |
Scott Michel | 52d0001 | 2009-01-03 00:27:53 +0000 | [diff] [blame] | 58 | |
Owen Anderson | 940f83e | 2008-08-26 18:03:31 +0000 | [diff] [blame] | 59 | virtual bool copyRegToReg(MachineBasicBlock &MBB, |
Owen Anderson | d10fd97 | 2007-12-31 06:32:00 +0000 | [diff] [blame] | 60 | MachineBasicBlock::iterator MI, |
| 61 | unsigned DestReg, unsigned SrcReg, |
| 62 | const TargetRegisterClass *DestRC, |
| 63 | const TargetRegisterClass *SrcRC) const; |
Scott Michel | 52d0001 | 2009-01-03 00:27:53 +0000 | [diff] [blame] | 64 | |
Owen Anderson | f6372aa | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 65 | //! Store a register to a stack slot, based on its register class. |
| 66 | virtual void storeRegToStackSlot(MachineBasicBlock &MBB, |
| 67 | MachineBasicBlock::iterator MBBI, |
| 68 | unsigned SrcReg, bool isKill, int FrameIndex, |
| 69 | const TargetRegisterClass *RC) const; |
| 70 | |
Owen Anderson | f6372aa | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 71 | //! Load a register from a stack slot, based on its register class. |
| 72 | virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, |
| 73 | MachineBasicBlock::iterator MBBI, |
| 74 | unsigned DestReg, int FrameIndex, |
| 75 | const TargetRegisterClass *RC) const; |
| 76 | |
Scott Michel | 52d0001 | 2009-01-03 00:27:53 +0000 | [diff] [blame] | 77 | //! Return true if the specified load or store can be folded |
| 78 | virtual |
| 79 | bool canFoldMemoryOperand(const MachineInstr *MI, |
| 80 | const SmallVectorImpl<unsigned> &Ops) const; |
| 81 | |
Scott Michel | 52d0001 | 2009-01-03 00:27:53 +0000 | [diff] [blame] | 82 | //! Reverses a branch's condition, returning false on success. |
| 83 | virtual |
| 84 | bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; |
Scott Michel | aedc637 | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 85 | |
| 86 | virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, |
Scott Michel | 19c10e6 | 2009-01-26 03:37:41 +0000 | [diff] [blame] | 87 | MachineBasicBlock *&FBB, |
Evan Cheng | dc54d31 | 2009-02-09 07:14:22 +0000 | [diff] [blame] | 88 | SmallVectorImpl<MachineOperand> &Cond, |
| 89 | bool AllowModify) const; |
Scott Michel | 52d0001 | 2009-01-03 00:27:53 +0000 | [diff] [blame] | 90 | |
Scott Michel | aedc637 | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 91 | virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; |
Scott Michel | 52d0001 | 2009-01-03 00:27:53 +0000 | [diff] [blame] | 92 | |
Scott Michel | aedc637 | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 93 | virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
Scott Michel | 19c10e6 | 2009-01-26 03:37:41 +0000 | [diff] [blame] | 94 | MachineBasicBlock *FBB, |
| 95 | const SmallVectorImpl<MachineOperand> &Cond) const; |
Scott Michel | aedc637 | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 96 | }; |
Scott Michel | 6637752 | 2007-12-04 22:35:58 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | #endif |