xref: /aosp_15_r20/external/llvm/lib/Target/AVR/AVRInstrInfo.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- AVRInstrInfo.h - AVR Instruction Information ------------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file contains the AVR implementation of the TargetInstrInfo class.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_AVR_INSTR_INFO_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_AVR_INSTR_INFO_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetInstrInfo.h"
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker #include "AVRRegisterInfo.h"
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker #define GET_INSTRINFO_HEADER
22*9880d681SAndroid Build Coastguard Worker #include "AVRGenInstrInfo.inc"
23*9880d681SAndroid Build Coastguard Worker #undef GET_INSTRINFO_HEADER
24*9880d681SAndroid Build Coastguard Worker 
25*9880d681SAndroid Build Coastguard Worker namespace llvm {
26*9880d681SAndroid Build Coastguard Worker 
27*9880d681SAndroid Build Coastguard Worker namespace AVRCC {
28*9880d681SAndroid Build Coastguard Worker 
29*9880d681SAndroid Build Coastguard Worker /// AVR specific condition codes.
30*9880d681SAndroid Build Coastguard Worker /// These correspond to `AVR_*_COND` in `AVRInstrInfo.td`.
31*9880d681SAndroid Build Coastguard Worker /// They must be kept in synch.
32*9880d681SAndroid Build Coastguard Worker enum CondCodes {
33*9880d681SAndroid Build Coastguard Worker   COND_EQ, //!< Equal
34*9880d681SAndroid Build Coastguard Worker   COND_NE, //!< Not equal
35*9880d681SAndroid Build Coastguard Worker   COND_GE, //!< Greater than or equal
36*9880d681SAndroid Build Coastguard Worker   COND_LT, //!< Less than
37*9880d681SAndroid Build Coastguard Worker   COND_SH, //!< Unsigned same or higher
38*9880d681SAndroid Build Coastguard Worker   COND_LO, //!< Unsigned lower
39*9880d681SAndroid Build Coastguard Worker   COND_MI, //!< Minus
40*9880d681SAndroid Build Coastguard Worker   COND_PL, //!< Plus
41*9880d681SAndroid Build Coastguard Worker   COND_INVALID
42*9880d681SAndroid Build Coastguard Worker };
43*9880d681SAndroid Build Coastguard Worker 
44*9880d681SAndroid Build Coastguard Worker } // end of namespace AVRCC
45*9880d681SAndroid Build Coastguard Worker 
46*9880d681SAndroid Build Coastguard Worker namespace AVRII {
47*9880d681SAndroid Build Coastguard Worker 
48*9880d681SAndroid Build Coastguard Worker /// Specifies a target operand flag.
49*9880d681SAndroid Build Coastguard Worker enum TOF {
50*9880d681SAndroid Build Coastguard Worker   MO_NO_FLAG,
51*9880d681SAndroid Build Coastguard Worker 
52*9880d681SAndroid Build Coastguard Worker   /// On a symbol operand, this represents the lo part.
53*9880d681SAndroid Build Coastguard Worker   MO_LO = (1 << 1),
54*9880d681SAndroid Build Coastguard Worker 
55*9880d681SAndroid Build Coastguard Worker   /// On a symbol operand, this represents the hi part.
56*9880d681SAndroid Build Coastguard Worker   MO_HI = (1 << 2),
57*9880d681SAndroid Build Coastguard Worker 
58*9880d681SAndroid Build Coastguard Worker   /// On a symbol operand, this represents it has to be negated.
59*9880d681SAndroid Build Coastguard Worker   MO_NEG = (1 << 3)
60*9880d681SAndroid Build Coastguard Worker };
61*9880d681SAndroid Build Coastguard Worker 
62*9880d681SAndroid Build Coastguard Worker } // end of namespace AVRII
63*9880d681SAndroid Build Coastguard Worker 
64*9880d681SAndroid Build Coastguard Worker /// Utilities related to the AVR instruction set.
65*9880d681SAndroid Build Coastguard Worker class AVRInstrInfo : public AVRGenInstrInfo {
66*9880d681SAndroid Build Coastguard Worker public:
67*9880d681SAndroid Build Coastguard Worker   explicit AVRInstrInfo();
68*9880d681SAndroid Build Coastguard Worker 
getRegisterInfo()69*9880d681SAndroid Build Coastguard Worker   const AVRRegisterInfo &getRegisterInfo() const { return RI; }
70*9880d681SAndroid Build Coastguard Worker   const MCInstrDesc &getBrCond(AVRCC::CondCodes CC) const;
71*9880d681SAndroid Build Coastguard Worker   AVRCC::CondCodes getCondFromBranchOpc(unsigned Opc) const;
72*9880d681SAndroid Build Coastguard Worker   AVRCC::CondCodes getOppositeCondition(AVRCC::CondCodes CC) const;
73*9880d681SAndroid Build Coastguard Worker   unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
74*9880d681SAndroid Build Coastguard Worker 
75*9880d681SAndroid Build Coastguard Worker   void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
76*9880d681SAndroid Build Coastguard Worker                    const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
77*9880d681SAndroid Build Coastguard Worker                    bool KillSrc) const override;
78*9880d681SAndroid Build Coastguard Worker   void storeRegToStackSlot(MachineBasicBlock &MBB,
79*9880d681SAndroid Build Coastguard Worker                            MachineBasicBlock::iterator MI, unsigned SrcReg,
80*9880d681SAndroid Build Coastguard Worker                            bool isKill, int FrameIndex,
81*9880d681SAndroid Build Coastguard Worker                            const TargetRegisterClass *RC,
82*9880d681SAndroid Build Coastguard Worker                            const TargetRegisterInfo *TRI) const override;
83*9880d681SAndroid Build Coastguard Worker   void loadRegFromStackSlot(MachineBasicBlock &MBB,
84*9880d681SAndroid Build Coastguard Worker                             MachineBasicBlock::iterator MI, unsigned DestReg,
85*9880d681SAndroid Build Coastguard Worker                             int FrameIndex, const TargetRegisterClass *RC,
86*9880d681SAndroid Build Coastguard Worker                             const TargetRegisterInfo *TRI) const override;
87*9880d681SAndroid Build Coastguard Worker   unsigned isLoadFromStackSlot(const MachineInstr &MI,
88*9880d681SAndroid Build Coastguard Worker                                int &FrameIndex) const override;
89*9880d681SAndroid Build Coastguard Worker   unsigned isStoreToStackSlot(const MachineInstr &MI,
90*9880d681SAndroid Build Coastguard Worker                               int &FrameIndex) const override;
91*9880d681SAndroid Build Coastguard Worker 
92*9880d681SAndroid Build Coastguard Worker   // Branch analysis.
93*9880d681SAndroid Build Coastguard Worker   bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
94*9880d681SAndroid Build Coastguard Worker                      MachineBasicBlock *&FBB,
95*9880d681SAndroid Build Coastguard Worker                      SmallVectorImpl<MachineOperand> &Cond,
96*9880d681SAndroid Build Coastguard Worker                      bool AllowModify = false) const override;
97*9880d681SAndroid Build Coastguard Worker   unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
98*9880d681SAndroid Build Coastguard Worker                         MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
99*9880d681SAndroid Build Coastguard Worker                         const DebugLoc &DL) const override;
100*9880d681SAndroid Build Coastguard Worker   unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
101*9880d681SAndroid Build Coastguard Worker   bool
102*9880d681SAndroid Build Coastguard Worker   ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
103*9880d681SAndroid Build Coastguard Worker 
104*9880d681SAndroid Build Coastguard Worker private:
105*9880d681SAndroid Build Coastguard Worker   const AVRRegisterInfo RI;
106*9880d681SAndroid Build Coastguard Worker };
107*9880d681SAndroid Build Coastguard Worker 
108*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
109*9880d681SAndroid Build Coastguard Worker 
110*9880d681SAndroid Build Coastguard Worker #endif // LLVM_AVR_INSTR_INFO_H
111