blob: 0a914865afa13dbd01b1c503e661ae0790a1e471 [file] [log] [blame]
Scott Micheldfe09ed2007-12-04 22:35:58 +00001//===- SPUInstrInfo.h - Cell SPU Instruction Information --------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Micheldfe09ed2007-12-04 22:35:58 +00007//
8//===----------------------------------------------------------------------===//
9//
Scott Micheld1b5b9f2007-12-05 01:40:25 +000010// This file contains the CellSPU implementation of the TargetInstrInfo class.
Scott Micheldfe09ed2007-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 Lattner25568e42008-01-01 01:03:04 +000023 class SPUInstrInfo : public TargetInstrInfoImpl {
Scott Micheldfe09ed2007-12-04 22:35:58 +000024 SPUTargetMachine &TM;
25 const SPURegisterInfo RI;
Scott Michel6a1f6272009-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 Micheldfe09ed2007-12-04 22:35:58 +000039 public:
Dan Gohmanc60c67f2008-03-25 22:06:05 +000040 explicit SPUInstrInfo(SPUTargetMachine &tm);
Scott Micheldfe09ed2007-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 Gohmaneabd6472008-05-14 01:58:56 +000046 virtual const SPURegisterInfo &getRegisterInfo() const { return RI; }
Scott Micheldfe09ed2007-12-04 22:35:58 +000047
Evan Chengc544cb02009-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 Micheldfe09ed2007-12-04 22:35:58 +000053
Dan Gohman0b273252008-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 Michel6a1f6272009-01-03 00:27:53 +000058
Owen Anderson27fb3dc2008-08-26 18:03:31 +000059 virtual bool copyRegToReg(MachineBasicBlock &MBB,
Owen Anderson7a73ae92007-12-31 06:32:00 +000060 MachineBasicBlock::iterator MI,
61 unsigned DestReg, unsigned SrcReg,
62 const TargetRegisterClass *DestRC,
Dan Gohman779c69b2010-05-06 20:33:48 +000063 const TargetRegisterClass *SrcRC,
64 DebugLoc DL) const;
Scott Michel6a1f6272009-01-03 00:27:53 +000065
Owen Andersoneee14602008-01-01 21:11:32 +000066 //! Store a register to a stack slot, based on its register class.
67 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
68 MachineBasicBlock::iterator MBBI,
69 unsigned SrcReg, bool isKill, int FrameIndex,
Evan Chengefb126a2010-05-06 19:06:44 +000070 const TargetRegisterClass *RC,
71 const TargetRegisterInfo *TRI) const;
Owen Andersoneee14602008-01-01 21:11:32 +000072
Owen Andersoneee14602008-01-01 21:11:32 +000073 //! Load a register from a stack slot, based on its register class.
74 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
75 MachineBasicBlock::iterator MBBI,
76 unsigned DestReg, int FrameIndex,
Evan Chengefb126a2010-05-06 19:06:44 +000077 const TargetRegisterClass *RC,
78 const TargetRegisterInfo *TRI) const;
Owen Andersoneee14602008-01-01 21:11:32 +000079
Scott Michel6a1f6272009-01-03 00:27:53 +000080 //! Return true if the specified load or store can be folded
81 virtual
82 bool canFoldMemoryOperand(const MachineInstr *MI,
83 const SmallVectorImpl<unsigned> &Ops) const;
84
Scott Michel6a1f6272009-01-03 00:27:53 +000085 //! Reverses a branch's condition, returning false on success.
86 virtual
87 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
Scott Michela2495502008-12-10 00:15:19 +000088
89 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
Scott Michel95b2a202009-01-26 03:37:41 +000090 MachineBasicBlock *&FBB,
Evan Cheng64dfcac2009-02-09 07:14:22 +000091 SmallVectorImpl<MachineOperand> &Cond,
92 bool AllowModify) const;
Scott Michel6a1f6272009-01-03 00:27:53 +000093
Scott Michela2495502008-12-10 00:15:19 +000094 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
Scott Michel6a1f6272009-01-03 00:27:53 +000095
Scott Michela2495502008-12-10 00:15:19 +000096 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Stuart Hastings0125b642010-06-17 22:43:56 +000097 MachineBasicBlock *FBB,
98 const SmallVectorImpl<MachineOperand> &Cond,
99 DebugLoc DL) const;
Scott Michela2495502008-12-10 00:15:19 +0000100 };
Scott Micheldfe09ed2007-12-04 22:35:58 +0000101}
102
103#endif