blob: 4932531f06ae6fb387bb3ee4f780857d5f5f0080 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- SparcInstrInfo.h - Sparc Instruction Information --------*- C++ -*-===//
Chris Lattner158e1f52006-02-05 05:50:24 +00002//
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
Evan Cheng703a0fb2011-07-01 17:57:27 +000020#define GET_INSTRINFO_HEADER
21#include "SparcGenInstrInfo.inc"
22
Chris Lattner158e1f52006-02-05 05:50:24 +000023namespace llvm {
24
25/// SPII - This namespace holds all of the target specific flags that
26/// instruction info tracks.
27///
28namespace SPII {
29 enum {
30 Pseudo = (1<<0),
31 Load = (1<<1),
32 Store = (1<<2),
33 DelaySlot = (1<<3)
34 };
Chris Lattneraa2372562006-05-24 17:04:05 +000035}
Chris Lattner158e1f52006-02-05 05:50:24 +000036
Evan Cheng703a0fb2011-07-01 17:57:27 +000037class SparcInstrInfo : public SparcGenInstrInfo {
Chris Lattner158e1f52006-02-05 05:50:24 +000038 const SparcRegisterInfo RI;
Owen Anderson7a73ae92007-12-31 06:32:00 +000039 const SparcSubtarget& Subtarget;
Chris Lattner158e1f52006-02-05 05:50:24 +000040public:
Dan Gohmanc60c67f2008-03-25 22:06:05 +000041 explicit SparcInstrInfo(SparcSubtarget &ST);
Chris Lattner158e1f52006-02-05 05:50:24 +000042
43 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
44 /// such, whenever a client has an instance of instruction info, it should
45 /// always be able to get register info as well (through this method).
46 ///
Dan Gohmaneabd6472008-05-14 01:58:56 +000047 virtual const SparcRegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattner158e1f52006-02-05 05:50:24 +000048
Chris Lattner158e1f52006-02-05 05:50:24 +000049 /// isLoadFromStackSlot - If the specified machine instruction is a direct
50 /// load from a stack slot, return the virtual or physical register number of
51 /// the destination along with the FrameIndex of the loaded stack slot. If
52 /// not, return 0. This predicate must return 0 if the instruction has
53 /// any side effects other than loading from the stack slot.
Dan Gohman0b273252008-11-18 19:49:32 +000054 virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
55 int &FrameIndex) const;
Chris Lattner158e1f52006-02-05 05:50:24 +000056
57 /// isStoreToStackSlot - If the specified machine instruction is a direct
58 /// store to a stack slot, return the virtual or physical register number of
59 /// the source reg along with the FrameIndex of the loaded stack slot. If
60 /// not, return 0. This predicate must return 0 if the instruction has
61 /// any side effects other than storing to the stack slot.
Dan Gohman0b273252008-11-18 19:49:32 +000062 virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
63 int &FrameIndex) const;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000064
Venkatraman Govindaraju1fc82632011-12-25 18:50:24 +000065 /// emitFrameIndexDebugValue - Emit a target-dependent form of
66 /// DBG_VALUE encoding the address of a frame index.
67 virtual MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF,
68 int FrameIx,
69 uint64_t Offset,
70 const MDNode *MDPtr,
71 DebugLoc dl) const;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000072
73 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
74 MachineBasicBlock *&FBB,
75 SmallVectorImpl<MachineOperand> &Cond,
76 bool AllowModify = false) const ;
77
78 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
79
Evan Chenge20dd922007-05-18 00:18:17 +000080 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
81 MachineBasicBlock *FBB,
Stuart Hastings0125b642010-06-17 22:43:56 +000082 const SmallVectorImpl<MachineOperand> &Cond,
83 DebugLoc DL) const;
Owen Anderson7a73ae92007-12-31 06:32:00 +000084
Jakob Stoklund Olesen976b7b62010-07-11 07:56:09 +000085 virtual void copyPhysReg(MachineBasicBlock &MBB,
86 MachineBasicBlock::iterator I, DebugLoc DL,
87 unsigned DestReg, unsigned SrcReg,
88 bool KillSrc) const;
Owen Andersoneee14602008-01-01 21:11:32 +000089
90 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
91 MachineBasicBlock::iterator MBBI,
92 unsigned SrcReg, bool isKill, int FrameIndex,
Evan Chengefb126a2010-05-06 19:06:44 +000093 const TargetRegisterClass *RC,
94 const TargetRegisterInfo *TRI) const;
Owen Andersoneee14602008-01-01 21:11:32 +000095
Owen Andersoneee14602008-01-01 21:11:32 +000096 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
97 MachineBasicBlock::iterator MBBI,
98 unsigned DestReg, int FrameIndex,
Evan Chengefb126a2010-05-06 19:06:44 +000099 const TargetRegisterClass *RC,
100 const TargetRegisterInfo *TRI) const;
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000101
Chris Lattner840c7002009-09-15 17:46:24 +0000102 unsigned getGlobalBaseReg(MachineFunction *MF) const;
Chris Lattner158e1f52006-02-05 05:50:24 +0000103};
104
105}
106
107#endif