blob: 626c2b2232bfca21b808dcd4ce60e925ce270aaf [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- ARMInstrInfo.h - ARM Instruction Information -------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the "Instituto Nokia de Tecnologia" and
6// is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10//
11// This file contains the ARM implementation of the TargetInstrInfo class.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef ARMINSTRUCTIONINFO_H
16#define ARMINSTRUCTIONINFO_H
17
18#include "llvm/Target/TargetInstrInfo.h"
19#include "ARMRegisterInfo.h"
20
21namespace llvm {
22 class ARMSubtarget;
23
24/// ARMII - This namespace holds all of the target specific flags that
25/// instruction info tracks.
26///
27namespace ARMII {
28 enum {
29 //===------------------------------------------------------------------===//
30 // Instruction Flags.
31
32 //===------------------------------------------------------------------===//
33 // This three-bit field describes the addressing mode used. Zero is unused
34 // so that we can tell if we forgot to set a value.
35
36 AddrModeMask = 0xf,
Evan Chenga7b3e7c2007-08-07 01:37:15 +000037 AddrModeNone = 0,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038 AddrMode1 = 1,
39 AddrMode2 = 2,
40 AddrMode3 = 3,
41 AddrMode4 = 4,
42 AddrMode5 = 5,
43 AddrModeT1 = 6,
44 AddrModeT2 = 7,
45 AddrModeT4 = 8,
46 AddrModeTs = 9, // i8 * 4 for pc and sp relative data
47
48 // Size* - Flags to keep track of the size of an instruction.
49 SizeShift = 4,
50 SizeMask = 7 << SizeShift,
51 SizeSpecial = 1, // 0 byte pseudo or special case.
52 Size8Bytes = 2,
53 Size4Bytes = 3,
54 Size2Bytes = 4,
55
56 // IndexMode - Unindex, pre-indexed, or post-indexed. Only valid for load
57 // and store ops
58 IndexModeShift = 7,
59 IndexModeMask = 3 << IndexModeShift,
60 IndexModePre = 1,
61 IndexModePost = 2,
62
63 // Opcode
64 OpcodeShift = 9,
Evan Chenga7b3e7c2007-08-07 01:37:15 +000065 OpcodeMask = 0xf << OpcodeShift,
66
67 // Format
68 FormShift = 13,
69 FormMask = 31 << FormShift,
70
71// Pseudo instructions
72 Pseudo = 1 << FormShift,
73
74// Multiply instructions
75 MulFrm = 2 << FormShift,
76
77// Branch instructions
78 Branch = 3 << FormShift,
79 BranchMisc = 4 << FormShift,
80
81// Data Processing instructions
82 DPRdIm = 5 << FormShift,
83 DPRdReg = 6 << FormShift,
84 DPRdSoReg = 7 << FormShift,
85 DPRdMisc = 8 << FormShift,
86
87 DPRnIm = 9 << FormShift,
88 DPRnReg = 10 << FormShift,
89 DPRnSoReg = 11 << FormShift,
90
91 DPRIm = 12 << FormShift,
92 DPRReg = 13 << FormShift,
93 DPRSoReg = 14 << FormShift,
94
95 DPRImS = 15 << FormShift,
96 DPRRegS = 16 << FormShift,
97 DPRSoRegS = 17 << FormShift,
98
99// Load and Store
100 LdFrm = 18 << FormShift,
101 StFrm = 19 << FormShift,
102
103// Miscellaneous arithmetic instructions
104 ArithMisc = 20 << FormShift,
105
106// Thumb format
107 ThumbFrm = 21 << FormShift,
108
109// VFP format
110 VPFFrm = 22 << FormShift
111
112
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000113 };
114}
115
116class ARMInstrInfo : public TargetInstrInfo {
117 const ARMRegisterInfo RI;
118public:
119 ARMInstrInfo(const ARMSubtarget &STI);
120
121 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
122 /// such, whenever a client has an instance of instruction info, it should
123 /// always be able to get register info as well (through this method).
124 ///
125 virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
126
127 /// getPointerRegClass - Return the register class to use to hold pointers.
128 /// This is used for addressing modes.
129 virtual const TargetRegisterClass *getPointerRegClass() const;
130
131 /// Return true if the instruction is a register to register move and
132 /// leave the source and dest operands in the passed parameters.
133 ///
134 virtual bool isMoveInstr(const MachineInstr &MI,
135 unsigned &SrcReg, unsigned &DstReg) const;
136 virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
137 virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
138
139 virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI,
140 MachineBasicBlock::iterator &MBBI,
141 LiveVariables &LV) const;
142
143 // Branch analysis.
144 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
145 MachineBasicBlock *&FBB,
146 std::vector<MachineOperand> &Cond) const;
147 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
148 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
149 MachineBasicBlock *FBB,
150 const std::vector<MachineOperand> &Cond) const;
151 virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const;
152 virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const;
153
154 // Predication support.
155 virtual bool isPredicated(const MachineInstr *MI) const;
156
157 virtual
158 bool PredicateInstruction(MachineInstr *MI,
159 const std::vector<MachineOperand> &Pred) const;
160
161 virtual
162 bool SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
163 const std::vector<MachineOperand> &Pred1) const;
164
165 virtual bool DefinesPredicate(MachineInstr *MI,
166 std::vector<MachineOperand> &Pred) const;
167};
168
169 // Utility routines
170 namespace ARM {
171 /// GetInstSize - Returns the size of the specified MachineInstr.
172 ///
173 unsigned GetInstSize(MachineInstr *MI);
174
175 /// GetFunctionSize - Returns the size of the specified MachineFunction.
176 ///
177 unsigned GetFunctionSize(MachineFunction &MF);
178 }
179}
180
181#endif