Path: blob/main/contrib/llvm-project/llvm/lib/Target/AVR/AVRInstrInfo.h
35269 views
//===-- AVRInstrInfo.h - AVR 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 AVR implementation of the TargetInstrInfo class.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_AVR_INSTR_INFO_H13#define LLVM_AVR_INSTR_INFO_H1415#include "llvm/CodeGen/TargetInstrInfo.h"1617#include "AVRRegisterInfo.h"1819#define GET_INSTRINFO_HEADER20#include "AVRGenInstrInfo.inc"21#undef GET_INSTRINFO_HEADER2223namespace llvm {2425class AVRSubtarget;2627namespace AVRCC {2829/// AVR specific condition codes.30/// These correspond to `AVR_*_COND` in `AVRInstrInfo.td`.31/// They must be kept in synch.32enum CondCodes {33COND_EQ, //!< Equal34COND_NE, //!< Not equal35COND_GE, //!< Greater than or equal36COND_LT, //!< Less than37COND_SH, //!< Unsigned same or higher38COND_LO, //!< Unsigned lower39COND_MI, //!< Minus40COND_PL, //!< Plus41COND_INVALID42};4344} // end of namespace AVRCC4546namespace AVRII {4748/// Specifies a target operand flag.49enum TOF {50MO_NO_FLAG,5152/// On a symbol operand, this represents the lo part.53MO_LO = (1 << 1),5455/// On a symbol operand, this represents the hi part.56MO_HI = (1 << 2),5758/// On a symbol operand, this represents it has to be negated.59MO_NEG = (1 << 3)60};6162} // end of namespace AVRII6364/// Utilities related to the AVR instruction set.65class AVRInstrInfo : public AVRGenInstrInfo {66public:67explicit AVRInstrInfo(AVRSubtarget &STI);6869const AVRRegisterInfo &getRegisterInfo() const { return RI; }70const MCInstrDesc &getBrCond(AVRCC::CondCodes CC) const;71AVRCC::CondCodes getCondFromBranchOpc(unsigned Opc) const;72AVRCC::CondCodes getOppositeCondition(AVRCC::CondCodes CC) const;73unsigned getInstSizeInBytes(const MachineInstr &MI) const override;7475void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,76const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg,77bool KillSrc) const override;78void storeRegToStackSlot(MachineBasicBlock &MBB,79MachineBasicBlock::iterator MI, Register SrcReg,80bool isKill, int FrameIndex,81const TargetRegisterClass *RC,82const TargetRegisterInfo *TRI,83Register VReg) const override;84void loadRegFromStackSlot(MachineBasicBlock &MBB,85MachineBasicBlock::iterator MI, Register DestReg,86int FrameIndex, const TargetRegisterClass *RC,87const TargetRegisterInfo *TRI,88Register VReg) const override;89Register isLoadFromStackSlot(const MachineInstr &MI,90int &FrameIndex) const override;91Register isStoreToStackSlot(const MachineInstr &MI,92int &FrameIndex) const override;9394// Branch analysis.95bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,96MachineBasicBlock *&FBB,97SmallVectorImpl<MachineOperand> &Cond,98bool AllowModify = false) const override;99unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,100MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,101const DebugLoc &DL,102int *BytesAdded = nullptr) const override;103unsigned removeBranch(MachineBasicBlock &MBB,104int *BytesRemoved = nullptr) const override;105bool106reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;107108MachineBasicBlock *getBranchDestBlock(const MachineInstr &MI) const override;109110bool isBranchOffsetInRange(unsigned BranchOpc,111int64_t BrOffset) const override;112113void insertIndirectBranch(MachineBasicBlock &MBB,114MachineBasicBlock &NewDestBB,115MachineBasicBlock &RestoreBB, const DebugLoc &DL,116int64_t BrOffset, RegScavenger *RS) const override;117118private:119const AVRRegisterInfo RI;120121protected:122const AVRSubtarget &STI;123};124125} // end namespace llvm126127#endif // LLVM_AVR_INSTR_INFO_H128129130