1 //===- SPUInstrInfo.h - Cell SPU Instruction Information --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the CellSPU implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef SPU_INSTRUCTIONINFO_H
15 #define SPU_INSTRUCTIONINFO_H
18 #include "llvm/Target/TargetInstrInfo.h"
19 #include "SPURegisterInfo.h"
22 //! Cell SPU instruction information class
23 class SPUInstrInfo
: public TargetInstrInfoImpl
{
25 const SPURegisterInfo RI
;
27 virtual MachineInstr
* foldMemoryOperandImpl(MachineFunction
&MF
,
29 const SmallVectorImpl
<unsigned> &Ops
,
30 int FrameIndex
) const;
32 virtual MachineInstr
* foldMemoryOperandImpl(MachineFunction
&MF
,
34 const SmallVectorImpl
<unsigned> &Ops
,
35 MachineInstr
* LoadMI
) const {
40 explicit SPUInstrInfo(SPUTargetMachine
&tm
);
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).
46 virtual const SPURegisterInfo
&getRegisterInfo() const { return RI
; }
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;
54 unsigned isLoadFromStackSlot(const MachineInstr
*MI
,
55 int &FrameIndex
) const;
56 unsigned isStoreToStackSlot(const MachineInstr
*MI
,
57 int &FrameIndex
) const;
59 virtual bool copyRegToReg(MachineBasicBlock
&MBB
,
60 MachineBasicBlock::iterator MI
,
61 unsigned DestReg
, unsigned SrcReg
,
62 const TargetRegisterClass
*DestRC
,
63 const TargetRegisterClass
*SrcRC
) const;
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;
71 //! Store a register to an address, based on its register class
72 virtual void storeRegToAddr(MachineFunction
&MF
, unsigned SrcReg
, bool isKill
,
73 SmallVectorImpl
<MachineOperand
> &Addr
,
74 const TargetRegisterClass
*RC
,
75 SmallVectorImpl
<MachineInstr
*> &NewMIs
) const;
77 //! Load a register from a stack slot, based on its register class.
78 virtual void loadRegFromStackSlot(MachineBasicBlock
&MBB
,
79 MachineBasicBlock::iterator MBBI
,
80 unsigned DestReg
, int FrameIndex
,
81 const TargetRegisterClass
*RC
) const;
83 //! Loqad a register from an address, based on its register class
84 virtual void loadRegFromAddr(MachineFunction
&MF
, unsigned DestReg
,
85 SmallVectorImpl
<MachineOperand
> &Addr
,
86 const TargetRegisterClass
*RC
,
87 SmallVectorImpl
<MachineInstr
*> &NewMIs
) const;
89 //! Return true if the specified load or store can be folded
91 bool canFoldMemoryOperand(const MachineInstr
*MI
,
92 const SmallVectorImpl
<unsigned> &Ops
) const;
94 //! Return true if the specified block does not fall through
95 virtual bool BlockHasNoFallThrough(const MachineBasicBlock
&MBB
) const;
97 //! Reverses a branch's condition, returning false on success.
99 bool ReverseBranchCondition(SmallVectorImpl
<MachineOperand
> &Cond
) const;
101 virtual bool AnalyzeBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*&TBB
,
102 MachineBasicBlock
*&FBB
,
103 SmallVectorImpl
<MachineOperand
> &Cond
,
104 bool AllowModify
) const;
106 virtual unsigned RemoveBranch(MachineBasicBlock
&MBB
) const;
108 virtual unsigned InsertBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*TBB
,
109 MachineBasicBlock
*FBB
,
110 const SmallVectorImpl
<MachineOperand
> &Cond
) const;