blob: 91d86cb6453dff81ba960133c91123b56e37f011 [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.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000057 unsigned isLoadFromStackSlot(const MachineInstr &MI,
Craig Topperb0c941b2014-04-29 07:57:13 +000058 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.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000065 unsigned isStoreToStackSlot(const MachineInstr &MI,
Craig Topperb0c941b2014-04-29 07:57:13 +000066 int &FrameIndex) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000067
Jacques Pienaar71c30a12016-07-15 14:41:04 +000068 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
Craig Topperb0c941b2014-04-29 07:57:13 +000069 MachineBasicBlock *&FBB,
70 SmallVectorImpl<MachineOperand> &Cond,
Jacques Pienaar71c30a12016-07-15 14:41:04 +000071 bool AllowModify = false) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000072
Matt Arsenaulta2b036e2016-09-14 17:23:48 +000073 unsigned RemoveBranch(MachineBasicBlock &MBB,
74 int *BytesRemoved = nullptr) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000075
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +000076 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Ahmed Bougachac88bf542015-06-11 19:30:37 +000077 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +000078 const DebugLoc &DL,
79 int *BytesAdded = nullptr) const override;
Owen Anderson7a73ae92007-12-31 06:32:00 +000080
James Y Knight76994942016-01-13 04:44:14 +000081 bool
82 ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
83
Benjamin Kramerbdc49562016-06-12 15:39:02 +000084 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
85 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
Craig Topperb0c941b2014-04-29 07:57:13 +000086 bool KillSrc) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000087
Craig Topperb0c941b2014-04-29 07:57:13 +000088 void storeRegToStackSlot(MachineBasicBlock &MBB,
89 MachineBasicBlock::iterator MBBI,
90 unsigned SrcReg, bool isKill, int FrameIndex,
91 const TargetRegisterClass *RC,
92 const TargetRegisterInfo *TRI) const override;
Owen Andersoneee14602008-01-01 21:11:32 +000093
Craig Topperb0c941b2014-04-29 07:57:13 +000094 void loadRegFromStackSlot(MachineBasicBlock &MBB,
95 MachineBasicBlock::iterator MBBI,
96 unsigned DestReg, int FrameIndex,
97 const TargetRegisterClass *RC,
98 const TargetRegisterInfo *TRI) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000099
Chris Lattner840c7002009-09-15 17:46:24 +0000100 unsigned getGlobalBaseReg(MachineFunction *MF) const;
Marcin Koscielnicki33571e22016-04-26 10:37:14 +0000101
102 // Lower pseudo instructions after register allocation.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000103 bool expandPostRAPseudo(MachineInstr &MI) const override;
Chris Lattner158e1f52006-02-05 05:50:24 +0000104};
105
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000106}
Chris Lattner158e1f52006-02-05 05:50:24 +0000107
108#endif