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