LLVM  7.0.0
Mips16InstrInfo.h
Go to the documentation of this file.
1 //===- Mips16InstrInfo.h - Mips16 Instruction Information -------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the Mips16 implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H
15 #define LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H
16 
17 #include "Mips16RegisterInfo.h"
18 #include "MipsInstrInfo.h"
21 #include <cstdint>
22 
23 namespace llvm {
24 
25 class MCInstrDesc;
26 class MipsSubtarget;
27 
29  const Mips16RegisterInfo RI;
30 
31 public:
32  explicit Mips16InstrInfo(const MipsSubtarget &STI);
33 
34  const MipsRegisterInfo &getRegisterInfo() const override;
35 
36  /// isLoadFromStackSlot - If the specified machine instruction is a direct
37  /// load from a stack slot, return the virtual or physical register number of
38  /// the destination along with the FrameIndex of the loaded stack slot. If
39  /// not, return 0. This predicate must return 0 if the instruction has
40  /// any side effects other than loading from the stack slot.
41  unsigned isLoadFromStackSlot(const MachineInstr &MI,
42  int &FrameIndex) const override;
43 
44  /// isStoreToStackSlot - If the specified machine instruction is a direct
45  /// store to a stack slot, return the virtual or physical register number of
46  /// the source reg along with the FrameIndex of the loaded stack slot. If
47  /// not, return 0. This predicate must return 0 if the instruction has
48  /// any side effects other than storing to the stack slot.
49  unsigned isStoreToStackSlot(const MachineInstr &MI,
50  int &FrameIndex) const override;
51 
53  const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
54  bool KillSrc) const override;
55 
56  bool isCopyInstr(const MachineInstr &MI, const MachineOperand *&Src,
57  const MachineOperand *&Dest) const override;
58 
61  unsigned SrcReg, bool isKill, int FrameIndex,
62  const TargetRegisterClass *RC,
63  const TargetRegisterInfo *TRI,
64  int64_t Offset) const override;
65 
68  unsigned DestReg, int FrameIndex,
69  const TargetRegisterClass *RC,
70  const TargetRegisterInfo *TRI,
71  int64_t Offset) const override;
72 
73  bool expandPostRAPseudo(MachineInstr &MI) const override;
74 
75  unsigned getOppositeBranchOpc(unsigned Opc) const override;
76 
77  // Adjust SP by FrameSize bytes. Save RA, S0, S1
78  void makeFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB,
80 
81  // Adjust SP by FrameSize bytes. Restore RA, S0, S1
82  void restoreFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB,
84 
85  /// Adjust SP by Amount bytes.
86  void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,
87  MachineBasicBlock::iterator I) const override;
88 
89  /// Emit a series of instructions to load an immediate.
90  // This is to adjust some FrameReg. We return the new register to be used
91  // in place of FrameReg and the adjusted immediate field (&NewImm)
92  unsigned loadImmediate(unsigned FrameReg, int64_t Imm, MachineBasicBlock &MBB,
94  unsigned &NewImm) const;
95 
96  static bool validImmediate(unsigned Opcode, unsigned Reg, int64_t Amount);
97 
98  static bool validSpImm8(int offset) {
99  return ((offset & 7) == 0) && isInt<11>(offset);
100  }
101 
102  // build the proper one based on the Imm field
103 
104  const MCInstrDesc& AddiuSpImm(int64_t Imm) const;
105 
106  void BuildAddiuSpImm
107  (MachineBasicBlock &MBB, MachineBasicBlock::iterator I, int64_t Imm) const;
108 private:
109  unsigned getAnalyzableBrOpc(unsigned Opc) const override;
110 
111  void ExpandRetRA16(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
112  unsigned Opc) const;
113 
114  // Adjust SP by Amount bytes where bytes can be up to 32bit number.
115  void adjustStackPtrBig(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,
117  unsigned Reg1, unsigned Reg2) const;
118 
119  // Adjust SP by Amount bytes where bytes can be up to 32bit number.
120  void adjustStackPtrBigUnrestricted(unsigned SP, int64_t Amount,
121  MachineBasicBlock &MBB,
123 };
124 
125 } // end namespace llvm
126 
127 #endif // LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H
const MCInstrDesc & AddiuSpImm(int64_t Imm) const
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:162
unsigned Reg
unsigned const TargetRegisterInfo * TRI
A debug info location.
Definition: DebugLoc.h:34
unsigned loadImmediate(unsigned FrameReg, int64_t Imm, MachineBasicBlock &MBB, MachineBasicBlock::iterator II, const DebugLoc &DL, unsigned &NewImm) const
Emit a series of instructions to load an immediate.
static bool validImmediate(unsigned Opcode, unsigned Reg, int64_t Amount)
void restoreFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlot - If the specified machine instruction is a direct load from a stack slot...
void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
Adjust SP by Amount bytes.
void BuildAddiuSpImm(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, int64_t Imm) const
bool expandPostRAPseudo(MachineInstr &MI) const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static bool validSpImm8(int offset)
const MipsRegisterInfo & getRegisterInfo() const override
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
MachineOperand class - Representation of each machine instruction operand.
void makeFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const
Representation of each machine instruction.
Definition: MachineInstr.h:60
void loadRegFromStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, int64_t Offset) const override
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlot - If the specified machine instruction is a direct store to a stack slot...
Mips16InstrInfo(const MipsSubtarget &STI)
bool isCopyInstr(const MachineInstr &MI, const MachineOperand *&Src, const MachineOperand *&Dest) const override
IRTranslator LLVM IR MI
void storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, int64_t Offset) const override
unsigned getOppositeBranchOpc(unsigned Opc) const override
GetOppositeBranchOpc - Return the inverse of the specified opcode, e.g.