blob: e9ce790a2a004e4ceb84c684d724f51c269e5ef6 [file] [log] [blame]
Chris Lattner158e1f52006-02-05 05:50:24 +00001//===- SparcInstrInfo.h - Sparc 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.
Chris Lattner158e1f52006-02-05 05:50:24 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the Sparc implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef SPARCINSTRUCTIONINFO_H
15#define SPARCINSTRUCTIONINFO_H
16
17#include "llvm/Target/TargetInstrInfo.h"
18#include "SparcRegisterInfo.h"
19
20namespace llvm {
21
22/// SPII - This namespace holds all of the target specific flags that
23/// instruction info tracks.
24///
25namespace SPII {
26 enum {
27 Pseudo = (1<<0),
28 Load = (1<<1),
29 Store = (1<<2),
30 DelaySlot = (1<<3)
31 };
Chris Lattneraa2372562006-05-24 17:04:05 +000032}
Chris Lattner158e1f52006-02-05 05:50:24 +000033
Chris Lattner25568e42008-01-01 01:03:04 +000034class SparcInstrInfo : public TargetInstrInfoImpl {
Chris Lattner158e1f52006-02-05 05:50:24 +000035 const SparcRegisterInfo RI;
Owen Anderson7a73ae92007-12-31 06:32:00 +000036 const SparcSubtarget& Subtarget;
Chris Lattner158e1f52006-02-05 05:50:24 +000037public:
Dan Gohmanc60c67f2008-03-25 22:06:05 +000038 explicit SparcInstrInfo(SparcSubtarget &ST);
Chris Lattner158e1f52006-02-05 05:50:24 +000039
40 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
41 /// such, whenever a client has an instance of instruction info, it should
42 /// always be able to get register info as well (through this method).
43 ///
Dan Gohman3a4be0f2008-02-10 18:45:23 +000044 virtual const TargetRegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattner158e1f52006-02-05 05:50:24 +000045
46 /// Return true if the instruction is a register to register move and
47 /// leave the source and dest operands in the passed parameters.
48 ///
49 virtual bool isMoveInstr(const MachineInstr &MI,
50 unsigned &SrcReg, unsigned &DstReg) const;
51
52 /// isLoadFromStackSlot - If the specified machine instruction is a direct
53 /// load from a stack slot, return the virtual or physical register number of
54 /// the destination along with the FrameIndex of the loaded stack slot. If
55 /// not, return 0. This predicate must return 0 if the instruction has
56 /// any side effects other than loading from the stack slot.
57 virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
58
59 /// isStoreToStackSlot - If the specified machine instruction is a direct
60 /// store to a stack slot, return the virtual or physical register number of
61 /// the source reg along with the FrameIndex of the loaded stack slot. If
62 /// not, return 0. This predicate must return 0 if the instruction has
63 /// any side effects other than storing to the stack slot.
64 virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
Chris Lattnerb7267bd2006-10-24 16:39:19 +000065
66
Evan Chenge20dd922007-05-18 00:18:17 +000067 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
68 MachineBasicBlock *FBB,
69 const std::vector<MachineOperand> &Cond) const;
Owen Anderson7a73ae92007-12-31 06:32:00 +000070
71 virtual void copyRegToReg(MachineBasicBlock &MBB,
72 MachineBasicBlock::iterator I,
73 unsigned DestReg, unsigned SrcReg,
74 const TargetRegisterClass *DestRC,
75 const TargetRegisterClass *SrcRC) const;
Owen Andersoneee14602008-01-01 21:11:32 +000076
77 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
78 MachineBasicBlock::iterator MBBI,
79 unsigned SrcReg, bool isKill, int FrameIndex,
80 const TargetRegisterClass *RC) const;
81
82 virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
83 SmallVectorImpl<MachineOperand> &Addr,
84 const TargetRegisterClass *RC,
85 SmallVectorImpl<MachineInstr*> &NewMIs) const;
86
87 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
88 MachineBasicBlock::iterator MBBI,
89 unsigned DestReg, int FrameIndex,
90 const TargetRegisterClass *RC) const;
91
92 virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
93 SmallVectorImpl<MachineOperand> &Addr,
94 const TargetRegisterClass *RC,
95 SmallVectorImpl<MachineInstr*> &NewMIs) const;
Owen Anderson2a3be7b2008-01-07 01:35:02 +000096
Evan Cheng3b3286d2008-02-08 21:20:40 +000097 virtual MachineInstr* foldMemoryOperand(MachineFunction &MF,
98 MachineInstr* MI,
Owen Anderson2a3be7b2008-01-07 01:35:02 +000099 SmallVectorImpl<unsigned> &Ops,
100 int FrameIndex) const;
101
Evan Cheng3b3286d2008-02-08 21:20:40 +0000102 virtual MachineInstr* foldMemoryOperand(MachineFunction &MF,
103 MachineInstr* MI,
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000104 SmallVectorImpl<unsigned> &Ops,
105 MachineInstr* LoadMI) const {
106 return 0;
107 }
Chris Lattner158e1f52006-02-05 05:50:24 +0000108};
109
110}
111
112#endif