1 //===-- AVRInstrInfo.h - AVR Instruction Information ------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains the AVR implementation of the TargetInstrInfo class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_AVR_INSTR_INFO_H
14 #define LLVM_AVR_INSTR_INFO_H
16 #include "llvm/CodeGen/TargetInstrInfo.h"
18 #include "AVRRegisterInfo.h"
20 #define GET_INSTRINFO_HEADER
21 #include "AVRGenInstrInfo.inc"
22 #undef GET_INSTRINFO_HEADER
28 /// AVR specific condition codes.
29 /// These correspond to `AVR_*_COND` in `AVRInstrInfo.td`.
30 /// They must be kept in synch.
33 COND_NE
, //!< Not equal
34 COND_GE
, //!< Greater than or equal
35 COND_LT
, //!< Less than
36 COND_SH
, //!< Unsigned same or higher
37 COND_LO
, //!< Unsigned lower
43 } // end of namespace AVRCC
47 /// Specifies a target operand flag.
51 /// On a symbol operand, this represents the lo part.
54 /// On a symbol operand, this represents the hi part.
57 /// On a symbol operand, this represents it has to be negated.
61 } // end of namespace AVRII
63 /// Utilities related to the AVR instruction set.
64 class AVRInstrInfo
: public AVRGenInstrInfo
{
66 explicit AVRInstrInfo();
68 const AVRRegisterInfo
&getRegisterInfo() const { return RI
; }
69 const MCInstrDesc
&getBrCond(AVRCC::CondCodes CC
) const;
70 AVRCC::CondCodes
getCondFromBranchOpc(unsigned Opc
) const;
71 AVRCC::CondCodes
getOppositeCondition(AVRCC::CondCodes CC
) const;
72 unsigned getInstSizeInBytes(const MachineInstr
&MI
) const override
;
74 void copyPhysReg(MachineBasicBlock
&MBB
, MachineBasicBlock::iterator MI
,
75 const DebugLoc
&DL
, unsigned DestReg
, unsigned SrcReg
,
76 bool KillSrc
) const override
;
77 void storeRegToStackSlot(MachineBasicBlock
&MBB
,
78 MachineBasicBlock::iterator MI
, unsigned SrcReg
,
79 bool isKill
, int FrameIndex
,
80 const TargetRegisterClass
*RC
,
81 const TargetRegisterInfo
*TRI
) const override
;
82 void loadRegFromStackSlot(MachineBasicBlock
&MBB
,
83 MachineBasicBlock::iterator MI
, unsigned DestReg
,
84 int FrameIndex
, const TargetRegisterClass
*RC
,
85 const TargetRegisterInfo
*TRI
) const override
;
86 unsigned isLoadFromStackSlot(const MachineInstr
&MI
,
87 int &FrameIndex
) const override
;
88 unsigned isStoreToStackSlot(const MachineInstr
&MI
,
89 int &FrameIndex
) const override
;
92 bool analyzeBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*&TBB
,
93 MachineBasicBlock
*&FBB
,
94 SmallVectorImpl
<MachineOperand
> &Cond
,
95 bool AllowModify
= false) const override
;
96 unsigned insertBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*TBB
,
97 MachineBasicBlock
*FBB
, ArrayRef
<MachineOperand
> Cond
,
99 int *BytesAdded
= nullptr) const override
;
100 unsigned removeBranch(MachineBasicBlock
&MBB
,
101 int *BytesRemoved
= nullptr) const override
;
103 reverseBranchCondition(SmallVectorImpl
<MachineOperand
> &Cond
) const override
;
105 MachineBasicBlock
*getBranchDestBlock(const MachineInstr
&MI
) const override
;
107 bool isBranchOffsetInRange(unsigned BranchOpc
,
108 int64_t BrOffset
) const override
;
110 unsigned insertIndirectBranch(MachineBasicBlock
&MBB
,
111 MachineBasicBlock
&NewDestBB
,
114 RegScavenger
*RS
) const override
;
116 const AVRRegisterInfo RI
;
119 } // end namespace llvm
121 #endif // LLVM_AVR_INSTR_INFO_H