2007-12-04 22:35:58 +00:00
|
|
|
//===- SPUInstrInfo.h - Cell SPU Instruction Information --------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-12-04 22:35:58 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2007-12-05 01:40:25 +00:00
|
|
|
// This file contains the CellSPU implementation of the TargetInstrInfo class.
|
2007-12-04 22:35:58 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef SPU_INSTRUCTIONINFO_H
|
|
|
|
#define SPU_INSTRUCTIONINFO_H
|
|
|
|
|
|
|
|
#include "SPU.h"
|
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
|
|
|
#include "SPURegisterInfo.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
//! Cell SPU instruction information class
|
2008-01-01 01:03:04 +00:00
|
|
|
class SPUInstrInfo : public TargetInstrInfoImpl {
|
2007-12-04 22:35:58 +00:00
|
|
|
SPUTargetMachine &TM;
|
|
|
|
const SPURegisterInfo RI;
|
2009-01-03 00:27:53 +00:00
|
|
|
protected:
|
|
|
|
virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
int FrameIndex) const;
|
|
|
|
|
|
|
|
virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
MachineInstr* LoadMI) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-04 22:35:58 +00:00
|
|
|
public:
|
2008-03-25 22:06:05 +00:00
|
|
|
explicit SPUInstrInfo(SPUTargetMachine &tm);
|
2007-12-04 22:35:58 +00:00
|
|
|
|
|
|
|
/// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
|
|
|
|
/// such, whenever a client has an instance of instruction info, it should
|
|
|
|
/// always be able to get register info as well (through this method).
|
|
|
|
///
|
2008-05-14 01:58:56 +00:00
|
|
|
virtual const SPURegisterInfo &getRegisterInfo() const { return RI; }
|
2007-12-04 22:35:58 +00:00
|
|
|
|
2009-01-20 19:12:24 +00:00
|
|
|
/// Return true if the instruction is a register to register move and return
|
|
|
|
/// the source and dest operands and their sub-register indices by reference.
|
|
|
|
virtual bool isMoveInstr(const MachineInstr &MI,
|
|
|
|
unsigned &SrcReg, unsigned &DstReg,
|
|
|
|
unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
|
2007-12-04 22:35:58 +00:00
|
|
|
|
2008-11-18 19:49:32 +00:00
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
|
|
|
unsigned isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
2009-01-03 00:27:53 +00:00
|
|
|
|
2008-08-26 18:03:31 +00:00
|
|
|
virtual bool copyRegToReg(MachineBasicBlock &MBB,
|
2007-12-31 06:32:00 +00:00
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
const TargetRegisterClass *DestRC,
|
|
|
|
const TargetRegisterClass *SrcRC) const;
|
2009-01-03 00:27:53 +00:00
|
|
|
|
2008-01-01 21:11:32 +00:00
|
|
|
//! Store a register to a stack slot, based on its register class.
|
|
|
|
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC) const;
|
|
|
|
|
|
|
|
//! Store a register to an address, based on its register class
|
|
|
|
virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
|
2008-01-30 02:55:46 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const;
|
2008-01-01 21:11:32 +00:00
|
|
|
|
|
|
|
//! Load a register from a stack slot, based on its register class.
|
|
|
|
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC) const;
|
|
|
|
|
|
|
|
//! Loqad a register from an address, based on its register class
|
|
|
|
virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
|
2008-01-30 02:55:46 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
2008-01-07 01:35:02 +00:00
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const;
|
|
|
|
|
2009-01-03 00:27:53 +00:00
|
|
|
//! Return true if the specified load or store can be folded
|
|
|
|
virtual
|
|
|
|
bool canFoldMemoryOperand(const MachineInstr *MI,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops) const;
|
|
|
|
|
|
|
|
//! Return true if the specified block does not fall through
|
|
|
|
virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
|
|
|
|
|
|
|
|
//! Reverses a branch's condition, returning false on success.
|
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
|
2008-12-10 00:15:19 +00:00
|
|
|
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
2009-01-26 03:37:41 +00:00
|
|
|
MachineBasicBlock *&FBB,
|
2009-02-09 07:14:22 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const;
|
2009-01-03 00:27:53 +00:00
|
|
|
|
2008-12-10 00:15:19 +00:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
2009-01-03 00:27:53 +00:00
|
|
|
|
2008-12-10 00:15:19 +00:00
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2009-01-26 03:37:41 +00:00
|
|
|
MachineBasicBlock *FBB,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond) const;
|
2008-12-10 00:15:19 +00:00
|
|
|
};
|
2007-12-04 22:35:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|