blob: f0b3dde6dec3ebe4649a9a03a730ed65e0e0cd73 [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//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattner158e1f52006-02-05 05:50:24 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the Sparc implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
14#define LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
Chris Lattner158e1f52006-02-05 05:50:24 +000015
Chris Lattner158e1f52006-02-05 05:50:24 +000016#include "SparcRegisterInfo.h"
David Blaikie3f833ed2017-11-08 01:01:31 +000017#include "llvm/CodeGen/TargetInstrInfo.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000018
Evan Cheng703a0fb2011-07-01 17:57:27 +000019#define GET_INSTRINFO_HEADER
20#include "SparcGenInstrInfo.inc"
21
Chris Lattner158e1f52006-02-05 05:50:24 +000022namespace llvm {
23
Eric Christopher8bb838a2015-03-12 05:55:26 +000024class SparcSubtarget;
25
Chris Lattner158e1f52006-02-05 05:50:24 +000026/// SPII - This namespace holds all of the target specific flags that
27/// instruction info tracks.
28///
29namespace SPII {
30 enum {
31 Pseudo = (1<<0),
32 Load = (1<<1),
33 Store = (1<<2),
34 DelaySlot = (1<<3)
35 };
Chris Lattneraa2372562006-05-24 17:04:05 +000036}
Chris Lattner158e1f52006-02-05 05:50:24 +000037
Evan Cheng703a0fb2011-07-01 17:57:27 +000038class SparcInstrInfo : public SparcGenInstrInfo {
Chris Lattner158e1f52006-02-05 05:50:24 +000039 const SparcRegisterInfo RI;
Owen Anderson7a73ae92007-12-31 06:32:00 +000040 const SparcSubtarget& Subtarget;
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000041 virtual void anchor();
Chris Lattner158e1f52006-02-05 05:50:24 +000042public:
Dan Gohmanc60c67f2008-03-25 22:06:05 +000043 explicit SparcInstrInfo(SparcSubtarget &ST);
Chris Lattner158e1f52006-02-05 05:50:24 +000044
45 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
46 /// such, whenever a client has an instance of instruction info, it should
47 /// always be able to get register info as well (through this method).
48 ///
Craig Topperb0c941b2014-04-29 07:57:13 +000049 const SparcRegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattner158e1f52006-02-05 05:50:24 +000050
Chris Lattner158e1f52006-02-05 05:50:24 +000051 /// isLoadFromStackSlot - If the specified machine instruction is a direct
52 /// load from a stack slot, return the virtual or physical register number of
53 /// the destination along with the FrameIndex of the loaded stack slot. If
54 /// not, return 0. This predicate must return 0 if the instruction has
55 /// any side effects other than loading from the stack slot.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000056 unsigned isLoadFromStackSlot(const MachineInstr &MI,
Craig Topperb0c941b2014-04-29 07:57:13 +000057 int &FrameIndex) const override;
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000058
Chris Lattner158e1f52006-02-05 05:50:24 +000059 /// 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.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000064 unsigned isStoreToStackSlot(const MachineInstr &MI,
Craig Topperb0c941b2014-04-29 07:57:13 +000065 int &FrameIndex) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000066
Jacques Pienaar71c30a12016-07-15 14:41:04 +000067 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
Craig Topperb0c941b2014-04-29 07:57:13 +000068 MachineBasicBlock *&FBB,
69 SmallVectorImpl<MachineOperand> &Cond,
Jacques Pienaar71c30a12016-07-15 14:41:04 +000070 bool AllowModify = false) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000071
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +000072 unsigned removeBranch(MachineBasicBlock &MBB,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +000073 int *BytesRemoved = nullptr) const override;
Venkatraman Govindaraju1b0e2cb2011-01-16 03:15:11 +000074
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +000075 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Ahmed Bougachac88bf542015-06-11 19:30:37 +000076 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +000077 const DebugLoc &DL,
78 int *BytesAdded = nullptr) const override;
Owen Anderson7a73ae92007-12-31 06:32:00 +000079
James Y Knight76994942016-01-13 04:44:14 +000080 bool
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +000081 reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
James Y Knight76994942016-01-13 04:44:14 +000082
Benjamin Kramerbdc49562016-06-12 15:39:02 +000083 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
Matt Arsenaulte6c9a9a2019-11-11 13:54:21 +053084 const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,
Craig Topperb0c941b2014-04-29 07:57:13 +000085 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;
Marcin Koscielnicki33571e22016-04-26 10:37:14 +0000100
101 // Lower pseudo instructions after register allocation.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000102 bool expandPostRAPseudo(MachineInstr &MI) const override;
Chris Lattner158e1f52006-02-05 05:50:24 +0000103};
104
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000105}
Chris Lattner158e1f52006-02-05 05:50:24 +0000106
107#endif