blob: ffb40875ff10316a143fc55a59ad1eab905ebfb6 [file] [log] [blame]
Scott Michel66377522007-12-04 22:35:58 +00001//===- SPUInstrInfo.h - Cell SPU Instruction Information --------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Scott Michel66377522007-12-04 22:35:58 +00007//
8//===----------------------------------------------------------------------===//
9//
Scott Michel2466c372007-12-05 01:40:25 +000010// This file contains the CellSPU implementation of the TargetInstrInfo class.
Scott Michel66377522007-12-04 22:35:58 +000011//
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
21namespace llvm {
22 //! Cell SPU instruction information class
Chris Lattner64105522008-01-01 01:03:04 +000023 class SPUInstrInfo : public TargetInstrInfoImpl {
Scott Michel66377522007-12-04 22:35:58 +000024 SPUTargetMachine &TM;
25 const SPURegisterInfo RI;
Scott Michel52d00012009-01-03 00:27:53 +000026 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 Michel66377522007-12-04 22:35:58 +000039 public:
Dan Gohman950a4c42008-03-25 22:06:05 +000040 explicit SPUInstrInfo(SPUTargetMachine &tm);
Scott Michel66377522007-12-04 22:35:58 +000041
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 Gohmanc9f5f3f2008-05-14 01:58:56 +000046 virtual const SPURegisterInfo &getRegisterInfo() const { return RI; }
Scott Michel66377522007-12-04 22:35:58 +000047
Evan Cheng04ee5a12009-01-20 19:12:24 +000048 /// 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 Michel66377522007-12-04 22:35:58 +000053
Dan Gohmancbad42c2008-11-18 19:49:32 +000054 unsigned isLoadFromStackSlot(const MachineInstr *MI,
55 int &FrameIndex) const;
56 unsigned isStoreToStackSlot(const MachineInstr *MI,
57 int &FrameIndex) const;
Scott Michel52d00012009-01-03 00:27:53 +000058
Owen Anderson940f83e2008-08-26 18:03:31 +000059 virtual bool copyRegToReg(MachineBasicBlock &MBB,
Owen Andersond10fd972007-12-31 06:32:00 +000060 MachineBasicBlock::iterator MI,
61 unsigned DestReg, unsigned SrcReg,
62 const TargetRegisterClass *DestRC,
63 const TargetRegisterClass *SrcRC) const;
Scott Michel52d00012009-01-03 00:27:53 +000064
Owen Andersonf6372aa2008-01-01 21:11:32 +000065 //! 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
71 //! Store a register to an address, based on its register class
72 virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
Scott Michel7f9ba9b2008-01-30 02:55:46 +000073 SmallVectorImpl<MachineOperand> &Addr,
74 const TargetRegisterClass *RC,
75 SmallVectorImpl<MachineInstr*> &NewMIs) const;
Owen Andersonf6372aa2008-01-01 21:11:32 +000076
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;
82
83 //! Loqad a register from an address, based on its register class
84 virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
Scott Michel7f9ba9b2008-01-30 02:55:46 +000085 SmallVectorImpl<MachineOperand> &Addr,
86 const TargetRegisterClass *RC,
Owen Anderson43dbe052008-01-07 01:35:02 +000087 SmallVectorImpl<MachineInstr*> &NewMIs) const;
Owen Anderson43dbe052008-01-07 01:35:02 +000088
Scott Michel52d00012009-01-03 00:27:53 +000089 //! Return true if the specified load or store can be folded
90 virtual
91 bool canFoldMemoryOperand(const MachineInstr *MI,
92 const SmallVectorImpl<unsigned> &Ops) const;
93
94 //! Return true if the specified block does not fall through
95 virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
96
97 //! Reverses a branch's condition, returning false on success.
98 virtual
99 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
Scott Michelaedc6372008-12-10 00:15:19 +0000100
101 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
Scott Michel19c10e62009-01-26 03:37:41 +0000102 MachineBasicBlock *&FBB,
Evan Chengdc54d312009-02-09 07:14:22 +0000103 SmallVectorImpl<MachineOperand> &Cond,
104 bool AllowModify) const;
Scott Michel52d00012009-01-03 00:27:53 +0000105
Scott Michelaedc6372008-12-10 00:15:19 +0000106 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
Scott Michel52d00012009-01-03 00:27:53 +0000107
Scott Michelaedc6372008-12-10 00:15:19 +0000108 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Scott Michel19c10e62009-01-26 03:37:41 +0000109 MachineBasicBlock *FBB,
110 const SmallVectorImpl<MachineOperand> &Cond) const;
Scott Michelaedc6372008-12-10 00:15:19 +0000111 };
Scott Michel66377522007-12-04 22:35:58 +0000112}
113
114#endif