blob: 9de624cc95829f071c1b59f8f74d06c79a29a814 [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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
15#define LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
Chris Lattner158e1f52006-02-05 05:50:24 +000016
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
Eric Christopher8bb838a2015-03-12 05:55:26 +000025class SparcSubtarget;
26
Chris Lattner158e1f52006-02-05 05:50:24 +000027/// SPII - This namespace holds all of the target specific flags that
28/// instruction info tracks.
29///
30namespace SPII {
31 enum {
32 Pseudo = (1<<0),
33 Load = (1<<1),
34 Store = (1<<2),
35 DelaySlot = (1<<3)
36 };
Chris Lattneraa2372562006-05-24 17:04:05 +000037}
Chris Lattner158e1f52006-02-05 05:50:24 +000038
Evan Cheng703a0fb2011-07-01 17:57:27 +000039class SparcInstrInfo : public SparcGenInstrInfo {
Chris Lattner158e1f52006-02-05 05:50:24 +000040 const SparcRegisterInfo RI;
Owen Anderson7a73ae92007-12-31 06:32:00 +000041 const SparcSubtarget& Subtarget;
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000042 virtual void anchor();
Chris Lattner158e1f52006-02-05 05:50:24 +000043public:
Dan Gohmanc60c67f2008-03-25 22:06:05 +000044 explicit SparcInstrInfo(SparcSubtarget &ST);
Chris Lattner158e1f52006-02-05 05:50:24 +000045
46 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
47 /// such, whenever a client has an instance of instruction info, it should
48 /// always be able to get register info as well (through this method).
49 ///
Craig Topperb0c941b2014-04-29 07:57:13 +000050 const SparcRegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattner158e1f52006-02-05 05:50:24 +000051
Chris Lattner158e1f52006-02-05 05:50:24 +000052 /// 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.
Craig Topperb0c941b2014-04-29 07:57:13 +000057 unsigned isLoadFromStackSlot(const MachineInstr *MI,
58 int &FrameIndex) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000059
Chris Lattner158e1f52006-02-05 05:50:24 +000060 /// isStoreToStackSlot - If the specified machine instruction is a direct
61 /// store to a stack slot, return the virtual or physical register number of
62 /// the source reg along with the FrameIndex of the loaded stack slot. If
63 /// not, return 0. This predicate must return 0 if the instruction has
64 /// any side effects other than storing to the stack slot.
Craig Topperb0c941b2014-04-29 07:57:13 +000065 unsigned isStoreToStackSlot(const MachineInstr *MI,
66 int &FrameIndex) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000067
Craig Topperb0c941b2014-04-29 07:57:13 +000068 bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
69 MachineBasicBlock *&FBB,
70 SmallVectorImpl<MachineOperand> &Cond,
71 bool AllowModify = false) const override ;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000072
Craig Topperb0c941b2014-04-29 07:57:13 +000073 unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000074
Craig Topperb0c941b2014-04-29 07:57:13 +000075 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Ahmed Bougachac88bf542015-06-11 19:30:37 +000076 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
Craig Topperb0c941b2014-04-29 07:57:13 +000077 DebugLoc DL) const override;
Owen Anderson7a73ae92007-12-31 06:32:00 +000078
James Y Knight76994942016-01-13 04:44:14 +000079 bool
80 ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
81
Craig Topperb0c941b2014-04-29 07:57:13 +000082 void copyPhysReg(MachineBasicBlock &MBB,
83 MachineBasicBlock::iterator I, DebugLoc DL,
84 unsigned DestReg, unsigned SrcReg,
85 bool KillSrc) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000086
Craig Topperb0c941b2014-04-29 07:57:13 +000087 void storeRegToStackSlot(MachineBasicBlock &MBB,
88 MachineBasicBlock::iterator MBBI,
89 unsigned SrcReg, bool isKill, int FrameIndex,
90 const TargetRegisterClass *RC,
91 const TargetRegisterInfo *TRI) const override;
Owen Andersoneee14602008-01-01 21:11:32 +000092
Craig Topperb0c941b2014-04-29 07:57:13 +000093 void loadRegFromStackSlot(MachineBasicBlock &MBB,
94 MachineBasicBlock::iterator MBBI,
95 unsigned DestReg, int FrameIndex,
96 const TargetRegisterClass *RC,
97 const TargetRegisterInfo *TRI) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000098
Chris Lattner840c7002009-09-15 17:46:24 +000099 unsigned getGlobalBaseReg(MachineFunction *MF) const;
Chris Lattner158e1f52006-02-05 05:50:24 +0000100};
101
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000102}
Chris Lattner158e1f52006-02-05 05:50:24 +0000103
104#endif