LLVM 24.0.0git
MipsSEInstrInfo.h
Go to the documentation of this file.
1//===-- MipsSEInstrInfo.h - Mips32/64 Instruction Information ---*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the Mips32/64 implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_MIPS_MIPSSEINSTRINFO_H
14#define LLVM_LIB_TARGET_MIPS_MIPSSEINSTRINFO_H
15
16#include "MipsInstrInfo.h"
17#include "MipsSERegisterInfo.h"
18
19namespace llvm {
20
22 const MipsSERegisterInfo RI;
23
24public:
25 explicit MipsSEInstrInfo(const MipsSubtarget &STI);
26
27 const MipsSERegisterInfo &getRegisterInfo() const { return RI; }
28
29 /// isLoadFromStackSlot - If the specified machine instruction is a direct
30 /// load from a stack slot, return the virtual or physical register number of
31 /// the destination along with the FrameIndex of the loaded stack slot. If
32 /// not, return 0. This predicate must return 0 if the instruction has
33 /// any side effects other than loading from the stack slot.
35 int &FrameIndex) const override;
36
37 /// isStoreToStackSlot - If the specified machine instruction is a direct
38 /// store to a stack slot, return the virtual or physical register number of
39 /// the source reg along with the FrameIndex of the loaded stack slot. If
40 /// not, return 0. This predicate must return 0 if the instruction has
41 /// any side effects other than storing to the stack slot.
43 int &FrameIndex) const override;
44
46 const DebugLoc &DL, Register DestReg, Register SrcReg,
47 bool KillSrc, bool RenamableDest = false,
48 bool RenamableSrc = false) const override;
49
50 void storeRegToStack(
52 bool isKill, int FrameIndex, const TargetRegisterClass *RC,
53 int64_t Offset,
54 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
55
58 int FrameIndex, const TargetRegisterClass *RC, int64_t Offset,
59 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
60
61 bool expandPostRAPseudo(MachineInstr &MI) const override;
62
63 bool isBranchWithImm(unsigned Opc) const override;
64
65 unsigned getOppositeBranchOpc(unsigned Opc) const override;
66
67 /// Adjust SP by Amount bytes.
68 void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,
69 MachineBasicBlock::iterator I) const override;
70
71 /// Emit a series of instructions to load an immediate. If NewImm is a
72 /// non-NULL parameter, the last instruction is not emitted, but instead
73 /// its immediate operand is returned in NewImm.
74 unsigned loadImmediate(int64_t Imm, MachineBasicBlock &MBB,
76 unsigned *NewImm) const;
77
78protected:
79 /// If the specific machine instruction is a instruction that moves/copies
80 /// value from one register to another register return destination and source
81 /// registers as machine operands.
82 std::optional<DestSourcePair>
83 isCopyInstrImpl(const MachineInstr &MI) const override;
84
85private:
86 void storeLoadAFGR64Halves(MachineBasicBlock &MBB,
88 bool IsKill, int FI, int64_t Offset,
89 MachineMemOperand *MMO, bool IsStore) const;
90
91 unsigned getAnalyzableBrOpc(unsigned Opc) const override;
92
93 void expandRetRA(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const;
94
95 void expandERet(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const;
96
97 std::pair<bool, bool> compareOpndSize(unsigned Opc,
98 const MachineFunction &MF) const;
99
100 void expandPseudoMFHiLo(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
101 unsigned NewOpc) const;
102
103 void expandPseudoMTLoHi(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
104 unsigned LoOpc, unsigned HiOpc,
105 bool HasExplicitDef) const;
106
107 /// Expand pseudo Int-to-FP conversion instructions.
108 ///
109 /// For example, the following pseudo instruction
110 /// PseudoCVT_D32_W D2, A5
111 /// gets expanded into these two instructions:
112 /// MTC1 F4, A5
113 /// CVT_D32_W D2, F4
114 ///
115 /// We do this expansion post-RA to avoid inserting a floating point copy
116 /// instruction between MTC1 and CVT_D32_W.
118 unsigned CvtOpc, unsigned MovOpc, bool IsI64) const;
119
120 void expandExtractElementF64(MachineBasicBlock &MBB,
122 bool FP64) const;
123 void expandBuildPairF64(MachineBasicBlock &MBB,
125 bool FP64) const;
126 void expandEhReturn(MachineBasicBlock &MBB,
128};
129
130}
131
132#endif
uint64_t Imm
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
static bool isMicroMips(const MCSubtargetInfo *STI)
uint64_t IntrinsicInst * II
A debug info location.
Definition DebugLoc.h:127
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
A description of a memory reference used in the backend.
MipsInstrInfo(const MipsSubtarget &STI, const MipsRegisterInfo &RI, unsigned UncondBrOpc)
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlot - If the specified machine instruction is a direct load from a stack slot,...
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlot - If the specified machine instruction is a direct store to a stack slot,...
void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
Adjust SP by Amount bytes.
std::optional< DestSourcePair > isCopyInstrImpl(const MachineInstr &MI) const override
If the specific machine instruction is a instruction that moves/copies value from one register to ano...
unsigned loadImmediate(int64_t Imm, MachineBasicBlock &MBB, MachineBasicBlock::iterator II, const DebugLoc &DL, unsigned *NewImm) const
Emit a series of instructions to load an immediate.
bool isBranchWithImm(unsigned Opc) const override
isBranchWithImm - Return true if the branch contains an immediate operand (
MipsSEInstrInfo(const MipsSubtarget &STI)
bool expandPostRAPseudo(MachineInstr &MI) const override
void loadRegFromStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, int64_t Offset, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, int64_t Offset, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
unsigned getOppositeBranchOpc(unsigned Opc) const override
getOppositeBranchOpc - Return the inverse of the specified opcode, e.g.
const MipsSERegisterInfo & getRegisterInfo() const
Wrapper class representing virtual and physical registers.
Definition Register.h:20
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58