blob: 8ae28cb936857ea36a86096d5eac0fc24ed2e653 [file] [log] [blame]
Jacques Pienaarfcef3e42016-03-28 13:09:54 +00001//===- LanaiInstrInfo.h - Lanai 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 Lanai implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H
15#define LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H
16
17#include "LanaiRegisterInfo.h"
18#include "llvm/Target/TargetInstrInfo.h"
19
20#define GET_INSTRINFO_HEADER
21#include "LanaiGenInstrInfo.inc"
22
23namespace llvm {
24
25class LanaiInstrInfo : public LanaiGenInstrInfo {
26 const LanaiRegisterInfo RegisterInfo;
27
28public:
29 LanaiInstrInfo();
30
31 // getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
32 // such, whenever a client has an instance of instruction info, it should
33 // always be able to get register info as well (through this method).
34 virtual const LanaiRegisterInfo &getRegisterInfo() const {
35 return RegisterInfo;
36 }
37
38 unsigned isLoadFromStackSlot(const MachineInstr *MI,
39 int &FrameIndex) const override;
40
41 unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI,
42 int &FrameIndex) const override;
43
44 unsigned isStoreToStackSlot(const MachineInstr *MI,
45 int &FrameIndex) const override;
46
47 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position,
48 DebugLoc DL, unsigned DestinationRegister,
49 unsigned SourceRegister, bool KillSource) const override;
50
51 void
52 storeRegToStackSlot(MachineBasicBlock &MBB,
53 MachineBasicBlock::iterator Position,
54 unsigned SourceRegister, bool IsKill, int FrameIndex,
55 const TargetRegisterClass *RegisterClass,
56 const TargetRegisterInfo *RegisterInfo) const override;
57
58 void
59 loadRegFromStackSlot(MachineBasicBlock &MBB,
60 MachineBasicBlock::iterator Position,
61 unsigned DestinationRegister, int FrameIndex,
62 const TargetRegisterClass *RegisterClass,
63 const TargetRegisterInfo *RegisterInfo) const override;
64
65 bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override;
66
67 bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TrueBlock,
68 MachineBasicBlock *&FalseBlock,
69 SmallVectorImpl<MachineOperand> &Condition,
70 bool AllowModify) const override;
71
72 unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
73
74 bool ReverseBranchCondition(
75 SmallVectorImpl<MachineOperand> &Condition) const override;
76
77 unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TrueBlock,
78 MachineBasicBlock *FalseBlock,
79 ArrayRef<MachineOperand> Condition,
80 DebugLoc DL) const override;
81};
82
83static inline bool isSPLSOpcode(unsigned Opcode) {
84 switch (Opcode) {
85 case Lanai::LDBs_RI:
86 case Lanai::LDBz_RI:
87 case Lanai::LDHs_RI:
88 case Lanai::LDHz_RI:
89 case Lanai::STB_RI:
90 case Lanai::STH_RI:
91 return true;
92 default:
93 return false;
94 }
95}
96
97static inline bool isRMOpcode(unsigned Opcode) {
98 switch (Opcode) {
99 case Lanai::LDW_RI:
100 case Lanai::SW_RI:
101 return true;
102 default:
103 return false;
104 }
105}
106
107static inline bool isRRMOpcode(unsigned Opcode) {
108 switch (Opcode) {
109 case Lanai::LDBs_RR:
110 case Lanai::LDBz_RR:
111 case Lanai::LDHs_RR:
112 case Lanai::LDHz_RR:
113 case Lanai::LDWz_RR:
114 case Lanai::LDW_RR:
115 case Lanai::STB_RR:
116 case Lanai::STH_RR:
117 case Lanai::SW_RR:
118 return true;
119 default:
120 return false;
121 }
122}
123
124} // namespace llvm
125
126#endif // LLVM_LIB_TARGET_LANAI_LANAIINSTRINFO_H