LLVM API Documentation
00001 //===-- Mips16InstrInfo.h - Mips16 Instruction Information ------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the Mips16 implementation of the TargetInstrInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H 00015 #define LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H 00016 00017 #include "Mips16RegisterInfo.h" 00018 #include "MipsInstrInfo.h" 00019 00020 namespace llvm { 00021 00022 class Mips16InstrInfo : public MipsInstrInfo { 00023 const Mips16RegisterInfo RI; 00024 00025 public: 00026 explicit Mips16InstrInfo(const MipsSubtarget &STI); 00027 00028 const MipsRegisterInfo &getRegisterInfo() const override; 00029 00030 /// isLoadFromStackSlot - If the specified machine instruction is a direct 00031 /// load from a stack slot, return the virtual or physical register number of 00032 /// the destination along with the FrameIndex of the loaded stack slot. If 00033 /// not, return 0. This predicate must return 0 if the instruction has 00034 /// any side effects other than loading from the stack slot. 00035 unsigned isLoadFromStackSlot(const MachineInstr *MI, 00036 int &FrameIndex) const override; 00037 00038 /// isStoreToStackSlot - If the specified machine instruction is a direct 00039 /// store to a stack slot, return the virtual or physical register number of 00040 /// the source reg along with the FrameIndex of the loaded stack slot. If 00041 /// not, return 0. This predicate must return 0 if the instruction has 00042 /// any side effects other than storing to the stack slot. 00043 unsigned isStoreToStackSlot(const MachineInstr *MI, 00044 int &FrameIndex) const override; 00045 00046 void copyPhysReg(MachineBasicBlock &MBB, 00047 MachineBasicBlock::iterator MI, DebugLoc DL, 00048 unsigned DestReg, unsigned SrcReg, 00049 bool KillSrc) const override; 00050 00051 void storeRegToStack(MachineBasicBlock &MBB, 00052 MachineBasicBlock::iterator MBBI, 00053 unsigned SrcReg, bool isKill, int FrameIndex, 00054 const TargetRegisterClass *RC, 00055 const TargetRegisterInfo *TRI, 00056 int64_t Offset) const override; 00057 00058 void loadRegFromStack(MachineBasicBlock &MBB, 00059 MachineBasicBlock::iterator MBBI, 00060 unsigned DestReg, int FrameIndex, 00061 const TargetRegisterClass *RC, 00062 const TargetRegisterInfo *TRI, 00063 int64_t Offset) const override; 00064 00065 bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override; 00066 00067 unsigned getOppositeBranchOpc(unsigned Opc) const override; 00068 00069 // Adjust SP by FrameSize bytes. Save RA, S0, S1 00070 void makeFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB, 00071 MachineBasicBlock::iterator I) const; 00072 00073 // Adjust SP by FrameSize bytes. Restore RA, S0, S1 00074 void restoreFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB, 00075 MachineBasicBlock::iterator I) const; 00076 00077 00078 /// Adjust SP by Amount bytes. 00079 void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, 00080 MachineBasicBlock::iterator I) const; 00081 00082 /// Emit a series of instructions to load an immediate. 00083 // This is to adjust some FrameReg. We return the new register to be used 00084 // in place of FrameReg and the adjusted immediate field (&NewImm) 00085 // 00086 unsigned loadImmediate(unsigned FrameReg, 00087 int64_t Imm, MachineBasicBlock &MBB, 00088 MachineBasicBlock::iterator II, DebugLoc DL, 00089 unsigned &NewImm) const; 00090 00091 static bool validImmediate(unsigned Opcode, unsigned Reg, int64_t Amount); 00092 00093 static bool validSpImm8(int offset) { 00094 return ((offset & 7) == 0) && isInt<11>(offset); 00095 } 00096 00097 // 00098 // build the proper one based on the Imm field 00099 // 00100 00101 const MCInstrDesc& AddiuSpImm(int64_t Imm) const; 00102 00103 void BuildAddiuSpImm 00104 (MachineBasicBlock &MBB, MachineBasicBlock::iterator I, int64_t Imm) const; 00105 00106 unsigned getInlineAsmLength(const char *Str, 00107 const MCAsmInfo &MAI) const override; 00108 private: 00109 unsigned getAnalyzableBrOpc(unsigned Opc) const override; 00110 00111 void ExpandRetRA16(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, 00112 unsigned Opc) const; 00113 00114 // Adjust SP by Amount bytes where bytes can be up to 32bit number. 00115 void adjustStackPtrBig(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, 00116 MachineBasicBlock::iterator I, 00117 unsigned Reg1, unsigned Reg2) const; 00118 00119 // Adjust SP by Amount bytes where bytes can be up to 32bit number. 00120 void adjustStackPtrBigUnrestricted(unsigned SP, int64_t Amount, 00121 MachineBasicBlock &MBB, 00122 MachineBasicBlock::iterator I) const; 00123 00124 }; 00125 00126 } 00127 00128 #endif