blob: 3a1472ee9b15c9c9af36891560b81d39135b5b02 [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
Chris Lattner158e1f52006-02-05 05:50:24 +000017#include "SparcRegisterInfo.h"
Craig Topperb25fda92012-03-17 18:46:09 +000018#include "llvm/Target/TargetInstrInfo.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000019
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;
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000040 virtual void anchor();
Chris Lattner158e1f52006-02-05 05:50:24 +000041public:
Dan Gohmanc60c67f2008-03-25 22:06:05 +000042 explicit SparcInstrInfo(SparcSubtarget &ST);
Chris Lattner158e1f52006-02-05 05:50:24 +000043
44 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
45 /// such, whenever a client has an instance of instruction info, it should
46 /// always be able to get register info as well (through this method).
47 ///
Craig Topperb0c941b2014-04-29 07:57:13 +000048 const SparcRegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattner158e1f52006-02-05 05:50:24 +000049
Chris Lattner158e1f52006-02-05 05:50:24 +000050 /// isLoadFromStackSlot - If the specified machine instruction is a direct
51 /// load from a stack slot, return the virtual or physical register number of
52 /// the destination along with the FrameIndex of the loaded stack slot. If
53 /// not, return 0. This predicate must return 0 if the instruction has
54 /// any side effects other than loading from the stack slot.
Craig Topperb0c941b2014-04-29 07:57:13 +000055 unsigned isLoadFromStackSlot(const MachineInstr *MI,
56 int &FrameIndex) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000057
Chris Lattner158e1f52006-02-05 05:50:24 +000058 /// isStoreToStackSlot - If the specified machine instruction is a direct
59 /// store to a stack slot, return the virtual or physical register number of
60 /// the source reg along with the FrameIndex of the loaded stack slot. If
61 /// not, return 0. This predicate must return 0 if the instruction has
62 /// any side effects other than storing to the stack slot.
Craig Topperb0c941b2014-04-29 07:57:13 +000063 unsigned isStoreToStackSlot(const MachineInstr *MI,
64 int &FrameIndex) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000065
Craig Topperb0c941b2014-04-29 07:57:13 +000066 bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
67 MachineBasicBlock *&FBB,
68 SmallVectorImpl<MachineOperand> &Cond,
69 bool AllowModify = false) const override ;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000070
Craig Topperb0c941b2014-04-29 07:57:13 +000071 unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000072
Craig Topperb0c941b2014-04-29 07:57:13 +000073 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
74 MachineBasicBlock *FBB,
75 const SmallVectorImpl<MachineOperand> &Cond,
76 DebugLoc DL) const override;
Owen Anderson7a73ae92007-12-31 06:32:00 +000077
Craig Topperb0c941b2014-04-29 07:57:13 +000078 void copyPhysReg(MachineBasicBlock &MBB,
79 MachineBasicBlock::iterator I, DebugLoc DL,
80 unsigned DestReg, unsigned SrcReg,
81 bool KillSrc) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000082
Craig Topperb0c941b2014-04-29 07:57:13 +000083 void storeRegToStackSlot(MachineBasicBlock &MBB,
84 MachineBasicBlock::iterator MBBI,
85 unsigned SrcReg, bool isKill, int FrameIndex,
86 const TargetRegisterClass *RC,
87 const TargetRegisterInfo *TRI) const override;
Owen Andersoneee14602008-01-01 21:11:32 +000088
Craig Topperb0c941b2014-04-29 07:57:13 +000089 void loadRegFromStackSlot(MachineBasicBlock &MBB,
90 MachineBasicBlock::iterator MBBI,
91 unsigned DestReg, int FrameIndex,
92 const TargetRegisterClass *RC,
93 const TargetRegisterInfo *TRI) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000094
Chris Lattner840c7002009-09-15 17:46:24 +000095 unsigned getGlobalBaseReg(MachineFunction *MF) const;
Chris Lattner158e1f52006-02-05 05:50:24 +000096};
97
98}
99
100#endif