Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/Mips16InstrInfo.h
35269 views
//===- Mips16InstrInfo.h - Mips16 Instruction Information -------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file contains the Mips16 implementation of the TargetInstrInfo class.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H13#define LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H1415#include "Mips16RegisterInfo.h"16#include "MipsInstrInfo.h"17#include "llvm/CodeGen/MachineBasicBlock.h"18#include "llvm/Support/MathExtras.h"19#include <cstdint>2021namespace llvm {2223class MCInstrDesc;24class MipsSubtarget;2526class Mips16InstrInfo : public MipsInstrInfo {27const Mips16RegisterInfo RI;2829public:30explicit Mips16InstrInfo(const MipsSubtarget &STI);3132const MipsRegisterInfo &getRegisterInfo() const override;3334/// isLoadFromStackSlot - If the specified machine instruction is a direct35/// load from a stack slot, return the virtual or physical register number of36/// the destination along with the FrameIndex of the loaded stack slot. If37/// not, return 0. This predicate must return 0 if the instruction has38/// any side effects other than loading from the stack slot.39Register isLoadFromStackSlot(const MachineInstr &MI,40int &FrameIndex) const override;4142/// isStoreToStackSlot - If the specified machine instruction is a direct43/// store to a stack slot, return the virtual or physical register number of44/// the source reg along with the FrameIndex of the loaded stack slot. If45/// not, return 0. This predicate must return 0 if the instruction has46/// any side effects other than storing to the stack slot.47Register isStoreToStackSlot(const MachineInstr &MI,48int &FrameIndex) const override;4950void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,51const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,52bool KillSrc) const override;5354void storeRegToStack(MachineBasicBlock &MBB,55MachineBasicBlock::iterator MBBI,56Register SrcReg, bool isKill, int FrameIndex,57const TargetRegisterClass *RC,58const TargetRegisterInfo *TRI,59int64_t Offset) const override;6061void loadRegFromStack(MachineBasicBlock &MBB,62MachineBasicBlock::iterator MBBI,63Register DestReg, int FrameIndex,64const TargetRegisterClass *RC,65const TargetRegisterInfo *TRI,66int64_t Offset) const override;6768bool expandPostRAPseudo(MachineInstr &MI) const override;6970unsigned getOppositeBranchOpc(unsigned Opc) const override;7172// Adjust SP by FrameSize bytes. Save RA, S0, S173void makeFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB,74MachineBasicBlock::iterator I) const;7576// Adjust SP by FrameSize bytes. Restore RA, S0, S177void restoreFrame(unsigned SP, int64_t FrameSize, MachineBasicBlock &MBB,78MachineBasicBlock::iterator I) const;7980/// Adjust SP by Amount bytes.81void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,82MachineBasicBlock::iterator I) const override;8384/// Emit a series of instructions to load an immediate.85// This is to adjust some FrameReg. We return the new register to be used86// in place of FrameReg and the adjusted immediate field (&NewImm)87unsigned loadImmediate(unsigned FrameReg, int64_t Imm, MachineBasicBlock &MBB,88MachineBasicBlock::iterator II, const DebugLoc &DL,89unsigned &NewImm) const;9091static bool validImmediate(unsigned Opcode, unsigned Reg, int64_t Amount);9293static bool validSpImm8(int offset) {94return ((offset & 7) == 0) && isInt<11>(offset);95}9697// build the proper one based on the Imm field9899const MCInstrDesc& AddiuSpImm(int64_t Imm) const;100101void BuildAddiuSpImm102(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, int64_t Imm) const;103104protected:105/// If the specific machine instruction is a instruction that moves/copies106/// value from one register to another register return destination and source107/// registers as machine operands.108std::optional<DestSourcePair>109isCopyInstrImpl(const MachineInstr &MI) const override;110111private:112unsigned getAnalyzableBrOpc(unsigned Opc) const override;113114void ExpandRetRA16(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,115unsigned Opc) const;116117// Adjust SP by Amount bytes where bytes can be up to 32bit number.118void adjustStackPtrBig(unsigned SP, int64_t Amount, MachineBasicBlock &MBB,119MachineBasicBlock::iterator I,120unsigned Reg1, unsigned Reg2) const;121122// Adjust SP by Amount bytes where bytes can be up to 32bit number.123void adjustStackPtrBigUnrestricted(unsigned SP, int64_t Amount,124MachineBasicBlock &MBB,125MachineBasicBlock::iterator I) const;126};127128} // end namespace llvm129130#endif // LLVM_LIB_TARGET_MIPS_MIPS16INSTRINFO_H131132133