1 //===-- SparcInstrInfo.h - Sparc Instruction Information --------*- C++ -*-===//
3 // 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
7 //===----------------------------------------------------------------------===//
9 // This file contains the Sparc implementation of the TargetInstrInfo class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
14 #define LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
16 #include "SparcRegisterInfo.h"
17 #include "llvm/CodeGen/TargetInstrInfo.h"
19 #define GET_INSTRINFO_HEADER
20 #include "SparcGenInstrInfo.inc"
26 /// SPII - This namespace holds all of the target specific flags that
27 /// instruction info tracks.
38 class SparcInstrInfo
: public SparcGenInstrInfo
{
39 const SparcRegisterInfo RI
;
40 const SparcSubtarget
& Subtarget
;
41 virtual void anchor();
43 explicit SparcInstrInfo(SparcSubtarget
&ST
);
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).
49 const SparcRegisterInfo
&getRegisterInfo() const { return RI
; }
51 /// 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.
56 Register
isLoadFromStackSlot(const MachineInstr
&MI
,
57 int &FrameIndex
) const override
;
59 /// 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.
64 Register
isStoreToStackSlot(const MachineInstr
&MI
,
65 int &FrameIndex
) const override
;
67 MachineBasicBlock
*getBranchDestBlock(const MachineInstr
&MI
) const override
;
69 bool analyzeBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*&TBB
,
70 MachineBasicBlock
*&FBB
,
71 SmallVectorImpl
<MachineOperand
> &Cond
,
72 bool AllowModify
= false) const override
;
74 unsigned removeBranch(MachineBasicBlock
&MBB
,
75 int *BytesRemoved
= nullptr) const override
;
77 unsigned insertBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*TBB
,
78 MachineBasicBlock
*FBB
, ArrayRef
<MachineOperand
> Cond
,
80 int *BytesAdded
= nullptr) const override
;
83 reverseBranchCondition(SmallVectorImpl
<MachineOperand
> &Cond
) const override
;
85 /// Determine if the branch target is in range.
86 bool isBranchOffsetInRange(unsigned BranchOpc
, int64_t Offset
) const override
;
88 void copyPhysReg(MachineBasicBlock
&MBB
, MachineBasicBlock::iterator I
,
89 const DebugLoc
&DL
, MCRegister DestReg
, MCRegister SrcReg
,
90 bool KillSrc
, bool RenamableDest
= false,
91 bool RenamableSrc
= false) const override
;
93 void storeRegToStackSlot(MachineBasicBlock
&MBB
,
94 MachineBasicBlock::iterator MBBI
, Register SrcReg
,
95 bool isKill
, int FrameIndex
,
96 const TargetRegisterClass
*RC
,
97 const TargetRegisterInfo
*TRI
,
98 Register VReg
) const override
;
100 void loadRegFromStackSlot(MachineBasicBlock
&MBB
,
101 MachineBasicBlock::iterator MBBI
, Register DestReg
,
102 int FrameIndex
, const TargetRegisterClass
*RC
,
103 const TargetRegisterInfo
*TRI
,
104 Register VReg
) const override
;
106 Register
getGlobalBaseReg(MachineFunction
*MF
) const;
108 /// GetInstSize - Return the number of bytes of code the specified
109 /// instruction may be. This returns the maximum number of bytes.
110 unsigned getInstSizeInBytes(const MachineInstr
&MI
) const override
;
112 // Lower pseudo instructions after register allocation.
113 bool expandPostRAPseudo(MachineInstr
&MI
) const override
;