Path: blob/main/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
35269 views
//=- LoongArchInstrInfo.h - LoongArch 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 LoongArch implementation of the TargetInstrInfo class.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H13#define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H1415#include "LoongArchRegisterInfo.h"16#include "llvm/CodeGen/TargetInstrInfo.h"1718#define GET_INSTRINFO_HEADER19#include "LoongArchGenInstrInfo.inc"2021namespace llvm {2223class LoongArchSubtarget;2425class LoongArchInstrInfo : public LoongArchGenInstrInfo {26public:27explicit LoongArchInstrInfo(LoongArchSubtarget &STI);2829MCInst getNop() const override;3031void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,32const DebugLoc &DL, MCRegister DstReg, MCRegister SrcReg,33bool KillSrc) const override;3435void storeRegToStackSlot(MachineBasicBlock &MBB,36MachineBasicBlock::iterator MBBI, Register SrcReg,37bool IsKill, int FrameIndex,38const TargetRegisterClass *RC,39const TargetRegisterInfo *TRI,40Register VReg) const override;41void loadRegFromStackSlot(MachineBasicBlock &MBB,42MachineBasicBlock::iterator MBBI, Register DstReg,43int FrameIndex, const TargetRegisterClass *RC,44const TargetRegisterInfo *TRI,45Register VReg) const override;4647// Materializes the given integer Val into DstReg.48void movImm(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,49const DebugLoc &DL, Register DstReg, uint64_t Val,50MachineInstr::MIFlag Flag = MachineInstr::NoFlags) const;5152unsigned getInstSizeInBytes(const MachineInstr &MI) const override;5354bool isAsCheapAsAMove(const MachineInstr &MI) const override;5556MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;5758bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,59MachineBasicBlock *&FBB,60SmallVectorImpl<MachineOperand> &Cond,61bool AllowModify) const override;6263bool isBranchOffsetInRange(unsigned BranchOpc,64int64_t BrOffset) const override;6566unsigned removeBranch(MachineBasicBlock &MBB,67int *BytesRemoved = nullptr) const override;6869unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,70MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,71const DebugLoc &dl,72int *BytesAdded = nullptr) const override;7374void insertIndirectBranch(MachineBasicBlock &MBB,75MachineBasicBlock &NewDestBB,76MachineBasicBlock &RestoreBB, const DebugLoc &DL,77int64_t BrOffset, RegScavenger *RS) const override;7879bool80reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;8182std::pair<unsigned, unsigned>83decomposeMachineOperandsTargetFlags(unsigned TF) const override;8485ArrayRef<std::pair<unsigned, const char *>>86getSerializableDirectMachineOperandTargetFlags() const override;8788protected:89const LoongArchSubtarget &STI;90};9192namespace LoongArch {9394// Returns true if this is the sext.w pattern, addi.w rd, rs, 0.95bool isSEXT_W(const MachineInstr &MI);9697// Mask assignments for floating-point.98static constexpr unsigned FClassMaskSignalingNaN = 0x001;99static constexpr unsigned FClassMaskQuietNaN = 0x002;100static constexpr unsigned FClassMaskNegativeInfinity = 0x004;101static constexpr unsigned FClassMaskNegativeNormal = 0x008;102static constexpr unsigned FClassMaskNegativeSubnormal = 0x010;103static constexpr unsigned FClassMaskNegativeZero = 0x020;104static constexpr unsigned FClassMaskPositiveInfinity = 0x040;105static constexpr unsigned FClassMaskPositiveNormal = 0x080;106static constexpr unsigned FClassMaskPositiveSubnormal = 0x100;107static constexpr unsigned FClassMaskPositiveZero = 0x200;108} // namespace LoongArch109110} // end namespace llvm111#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHINSTRINFO_H112113114