blob: 27766ba43272488c58815da2287ac4da45548e16 [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;
26 public:
Dan Gohman950a4c42008-03-25 22:06:05 +000027 explicit SPUInstrInfo(SPUTargetMachine &tm);
Scott Michel66377522007-12-04 22:35:58 +000028
29 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
30 /// such, whenever a client has an instance of instruction info, it should
31 /// always be able to get register info as well (through this method).
32 ///
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000033 virtual const SPURegisterInfo &getRegisterInfo() const { return RI; }
Scott Michel66377522007-12-04 22:35:58 +000034
35 /// getPointerRegClass - Return the register class to use to hold pointers.
36 /// This is used for addressing modes.
37 virtual const TargetRegisterClass *getPointerRegClass() const;
38
39 // Return true if the instruction is a register to register move and
40 // leave the source and dest operands in the passed parameters.
41 //
42 virtual bool isMoveInstr(const MachineInstr& MI,
Scott Michel7f9ba9b2008-01-30 02:55:46 +000043 unsigned& sourceReg,
44 unsigned& destReg) const;
Scott Michel66377522007-12-04 22:35:58 +000045
Dan Gohmancbad42c2008-11-18 19:49:32 +000046 unsigned isLoadFromStackSlot(const MachineInstr *MI,
47 int &FrameIndex) const;
48 unsigned isStoreToStackSlot(const MachineInstr *MI,
49 int &FrameIndex) const;
Owen Andersond10fd972007-12-31 06:32:00 +000050
Owen Anderson940f83e2008-08-26 18:03:31 +000051 virtual bool copyRegToReg(MachineBasicBlock &MBB,
Owen Andersond10fd972007-12-31 06:32:00 +000052 MachineBasicBlock::iterator MI,
53 unsigned DestReg, unsigned SrcReg,
54 const TargetRegisterClass *DestRC,
55 const TargetRegisterClass *SrcRC) const;
Owen Andersonf6372aa2008-01-01 21:11:32 +000056
57 //! Store a register to a stack slot, based on its register class.
58 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
59 MachineBasicBlock::iterator MBBI,
60 unsigned SrcReg, bool isKill, int FrameIndex,
61 const TargetRegisterClass *RC) const;
62
63 //! Store a register to an address, based on its register class
64 virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
Scott Michel7f9ba9b2008-01-30 02:55:46 +000065 SmallVectorImpl<MachineOperand> &Addr,
66 const TargetRegisterClass *RC,
67 SmallVectorImpl<MachineInstr*> &NewMIs) const;
Owen Andersonf6372aa2008-01-01 21:11:32 +000068
69 //! Load a register from a stack slot, based on its register class.
70 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
71 MachineBasicBlock::iterator MBBI,
72 unsigned DestReg, int FrameIndex,
73 const TargetRegisterClass *RC) const;
74
75 //! Loqad a register from an address, based on its register class
76 virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
Scott Michel7f9ba9b2008-01-30 02:55:46 +000077 SmallVectorImpl<MachineOperand> &Addr,
78 const TargetRegisterClass *RC,
Owen Anderson43dbe052008-01-07 01:35:02 +000079 SmallVectorImpl<MachineInstr*> &NewMIs) const;
80
81 //! Fold spills into load/store instructions
Dan Gohmanc54baa22008-12-03 18:43:12 +000082 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
83 MachineInstr* MI,
84 const SmallVectorImpl<unsigned> &Ops,
85 int FrameIndex) const;
Owen Anderson43dbe052008-01-07 01:35:02 +000086
87 //! Fold any load/store to an operand
Dan Gohmanc54baa22008-12-03 18:43:12 +000088 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
89 MachineInstr* MI,
90 const SmallVectorImpl<unsigned> &Ops,
91 MachineInstr* LoadMI) const {
Owen Anderson43dbe052008-01-07 01:35:02 +000092 return 0;
93 }
Scott Michelaedc6372008-12-10 00:15:19 +000094
95 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
96 MachineBasicBlock *&FBB,
97 SmallVectorImpl<MachineOperand> &Cond) const;
98
99 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
100
101 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
102 MachineBasicBlock *FBB,
103 const SmallVectorImpl<MachineOperand> &Cond) const;
104 };
Scott Michel66377522007-12-04 22:35:58 +0000105}
106
107#endif