1 //===-- ARMExpandPseudoInsts.cpp - Expand pseudo instructions -----*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains a pass that expands pseudo instructions into target
11 // instructions to allow proper scheduling, if-conversion, and other late
12 // optimizations. This pass should be run after register allocation but before
13 // the post-regalloc scheduling pass.
15 //===----------------------------------------------------------------------===//
17 #define DEBUG_TYPE "arm-pseudo"
19 #include "ARMBaseInstrInfo.h"
20 #include "ARMBaseRegisterInfo.h"
21 #include "ARMMachineFunctionInfo.h"
22 #include "ARMRegisterInfo.h"
23 #include "MCTargetDesc/ARMAddressingModes.h"
24 #include "llvm/CodeGen/MachineFrameInfo.h"
25 #include "llvm/CodeGen/MachineFunctionPass.h"
26 #include "llvm/CodeGen/MachineInstrBuilder.h"
27 #include "llvm/Target/TargetFrameLowering.h"
28 #include "llvm/Target/TargetRegisterInfo.h"
29 #include "llvm/Support/CommandLine.h"
30 #include "llvm/Support/raw_ostream.h" // FIXME: for debug only. remove!
34 VerifyARMPseudo("verify-arm-pseudo-expand", cl::Hidden,
35 cl::desc("Verify machine code after expanding ARM pseudos"));
38 class ARMExpandPseudo : public MachineFunctionPass {
41 ARMExpandPseudo() : MachineFunctionPass(ID) {}
43 const ARMBaseInstrInfo *TII;
44 const TargetRegisterInfo *TRI;
45 const ARMSubtarget *STI;
48 virtual bool runOnMachineFunction(MachineFunction &Fn);
50 virtual const char *getPassName() const {
51 return "ARM pseudo instruction expansion pass";
55 void TransferImpOps(MachineInstr &OldMI,
56 MachineInstrBuilder &UseMI, MachineInstrBuilder &DefMI);
57 bool ExpandMI(MachineBasicBlock &MBB,
58 MachineBasicBlock::iterator MBBI);
59 bool ExpandMBB(MachineBasicBlock &MBB);
60 void ExpandVLD(MachineBasicBlock::iterator &MBBI);
61 void ExpandVST(MachineBasicBlock::iterator &MBBI);
62 void ExpandLaneOp(MachineBasicBlock::iterator &MBBI);
63 void ExpandVTBL(MachineBasicBlock::iterator &MBBI,
64 unsigned Opc, bool IsExt, unsigned NumRegs);
65 void ExpandMOV32BitImm(MachineBasicBlock &MBB,
66 MachineBasicBlock::iterator &MBBI);
68 char ARMExpandPseudo::ID = 0;
71 /// TransferImpOps - Transfer implicit operands on the pseudo instruction to
72 /// the instructions created from the expansion.
73 void ARMExpandPseudo::TransferImpOps(MachineInstr &OldMI,
74 MachineInstrBuilder &UseMI,
75 MachineInstrBuilder &DefMI) {
76 const MCInstrDesc &Desc = OldMI.getDesc();
77 for (unsigned i = Desc.getNumOperands(), e = OldMI.getNumOperands();
79 const MachineOperand &MO = OldMI.getOperand(i);
80 assert(MO.isReg() && MO.getReg());
89 // Constants for register spacing in NEON load/store instructions.
90 // For quad-register load-lane and store-lane pseudo instructors, the
91 // spacing is initially assumed to be EvenDblSpc, and that is changed to
92 // OddDblSpc depending on the lane number operand.
99 // Entries for NEON load/store information table. The table is sorted by
100 // PseudoOpc for fast binary-search lookups.
101 struct NEONLdStTableEntry {
106 bool hasWritebackOperand;
107 NEONRegSpacing RegSpacing;
108 unsigned char NumRegs; // D registers loaded or stored
109 unsigned char RegElts; // elements per D register; used for lane ops
110 // FIXME: Temporary flag to denote whether the real instruction takes
111 // a single register (like the encoding) or all of the registers in
112 // the list (like the asm syntax and the isel DAG). When all definitions
113 // are converted to take only the single encoded register, this will
115 bool copyAllListRegs;
117 // Comparison methods for binary search of the table.
118 bool operator<(const NEONLdStTableEntry &TE) const {
119 return PseudoOpc < TE.PseudoOpc;
121 friend bool operator<(const NEONLdStTableEntry &TE, unsigned PseudoOpc) {
122 return TE.PseudoOpc < PseudoOpc;
124 friend bool LLVM_ATTRIBUTE_UNUSED operator<(unsigned PseudoOpc,
125 const NEONLdStTableEntry &TE) {
126 return PseudoOpc < TE.PseudoOpc;
131 static const NEONLdStTableEntry NEONLdStTable[] = {
132 { ARM::VLD1DUPq16Pseudo, ARM::VLD1DUPq16, true, false, false, SingleSpc, 2, 4,false},
133 { ARM::VLD1DUPq16Pseudo_UPD, ARM::VLD1DUPq16_UPD, true, true, true, SingleSpc, 2, 4,true},
134 { ARM::VLD1DUPq32Pseudo, ARM::VLD1DUPq32, true, false, false, SingleSpc, 2, 2,false},
135 { ARM::VLD1DUPq32Pseudo_UPD, ARM::VLD1DUPq32_UPD, true, true, true, SingleSpc, 2, 2,true},
136 { ARM::VLD1DUPq8Pseudo, ARM::VLD1DUPq8, true, false, false, SingleSpc, 2, 8,false},
137 { ARM::VLD1DUPq8Pseudo_UPD, ARM::VLD1DUPq8_UPD, true, true, true, SingleSpc, 2, 8,true},
139 { ARM::VLD1LNq16Pseudo, ARM::VLD1LNd16, true, false, false, EvenDblSpc, 1, 4 ,true},
140 { ARM::VLD1LNq16Pseudo_UPD, ARM::VLD1LNd16_UPD, true, true, true, EvenDblSpc, 1, 4 ,true},
141 { ARM::VLD1LNq32Pseudo, ARM::VLD1LNd32, true, false, false, EvenDblSpc, 1, 2 ,true},
142 { ARM::VLD1LNq32Pseudo_UPD, ARM::VLD1LNd32_UPD, true, true, true, EvenDblSpc, 1, 2 ,true},
143 { ARM::VLD1LNq8Pseudo, ARM::VLD1LNd8, true, false, false, EvenDblSpc, 1, 8 ,true},
144 { ARM::VLD1LNq8Pseudo_UPD, ARM::VLD1LNd8_UPD, true, true, true, EvenDblSpc, 1, 8 ,true},
146 { ARM::VLD1d64QPseudo, ARM::VLD1d64Q, true, false, false, SingleSpc, 4, 1 ,false},
147 { ARM::VLD1d64TPseudo, ARM::VLD1d64T, true, false, false, SingleSpc, 3, 1 ,false},
148 { ARM::VLD1q16Pseudo, ARM::VLD1q16, true, false, false, SingleSpc, 2, 4 ,false},
149 { ARM::VLD1q16PseudoWB_fixed, ARM::VLD1q16wb_fixed,true,false,false,SingleSpc, 2, 4 ,false},
150 { ARM::VLD1q16PseudoWB_register, ARM::VLD1q16wb_register, true, true, true, SingleSpc, 2, 4 ,false},
151 { ARM::VLD1q32Pseudo, ARM::VLD1q32, true, false, false, SingleSpc, 2, 2 ,false},
152 { ARM::VLD1q32PseudoWB_fixed, ARM::VLD1q32wb_fixed,true,false, false,SingleSpc, 2, 2 ,false},
153 { ARM::VLD1q32PseudoWB_register, ARM::VLD1q32wb_register, true, true, true, SingleSpc, 2, 2 ,false},
154 { ARM::VLD1q64Pseudo, ARM::VLD1q64, true, false, false, SingleSpc, 2, 1 ,false},
155 { ARM::VLD1q64PseudoWB_fixed, ARM::VLD1q64wb_fixed,true,false, false,SingleSpc, 2, 2 ,false},
156 { ARM::VLD1q64PseudoWB_register, ARM::VLD1q64wb_register, true, true, true, SingleSpc, 2, 1 ,false},
157 { ARM::VLD1q8Pseudo, ARM::VLD1q8, true, false, false, SingleSpc, 2, 8 ,false},
158 { ARM::VLD1q8PseudoWB_fixed, ARM::VLD1q8wb_fixed,true,false, false, SingleSpc, 2, 8 ,false},
159 { ARM::VLD1q8PseudoWB_register, ARM::VLD1q8wb_register,true,true, true,SingleSpc,2,8,false},
161 { ARM::VLD2DUPd16Pseudo, ARM::VLD2DUPd16, true, false, false, SingleSpc, 2, 4,true},
162 { ARM::VLD2DUPd16Pseudo_UPD, ARM::VLD2DUPd16_UPD, true, true, true, SingleSpc, 2, 4,true},
163 { ARM::VLD2DUPd32Pseudo, ARM::VLD2DUPd32, true, false, false, SingleSpc, 2, 2,true},
164 { ARM::VLD2DUPd32Pseudo_UPD, ARM::VLD2DUPd32_UPD, true, true, true, SingleSpc, 2, 2,true},
165 { ARM::VLD2DUPd8Pseudo, ARM::VLD2DUPd8, true, false, false, SingleSpc, 2, 8,true},
166 { ARM::VLD2DUPd8Pseudo_UPD, ARM::VLD2DUPd8_UPD, true, true, true, SingleSpc, 2, 8,true},
168 { ARM::VLD2LNd16Pseudo, ARM::VLD2LNd16, true, false, false, SingleSpc, 2, 4 ,true},
169 { ARM::VLD2LNd16Pseudo_UPD, ARM::VLD2LNd16_UPD, true, true, true, SingleSpc, 2, 4 ,true},
170 { ARM::VLD2LNd32Pseudo, ARM::VLD2LNd32, true, false, false, SingleSpc, 2, 2 ,true},
171 { ARM::VLD2LNd32Pseudo_UPD, ARM::VLD2LNd32_UPD, true, true, true, SingleSpc, 2, 2 ,true},
172 { ARM::VLD2LNd8Pseudo, ARM::VLD2LNd8, true, false, false, SingleSpc, 2, 8 ,true},
173 { ARM::VLD2LNd8Pseudo_UPD, ARM::VLD2LNd8_UPD, true, true, true, SingleSpc, 2, 8 ,true},
174 { ARM::VLD2LNq16Pseudo, ARM::VLD2LNq16, true, false, false, EvenDblSpc, 2, 4 ,true},
175 { ARM::VLD2LNq16Pseudo_UPD, ARM::VLD2LNq16_UPD, true, true, true, EvenDblSpc, 2, 4 ,true},
176 { ARM::VLD2LNq32Pseudo, ARM::VLD2LNq32, true, false, false, EvenDblSpc, 2, 2 ,true},
177 { ARM::VLD2LNq32Pseudo_UPD, ARM::VLD2LNq32_UPD, true, true, true, EvenDblSpc, 2, 2 ,true},
179 { ARM::VLD2d16Pseudo, ARM::VLD2d16, true, false, false, SingleSpc, 2, 4 ,false},
180 { ARM::VLD2d16Pseudo_UPD, ARM::VLD2d16_UPD, true, true, true, SingleSpc, 2, 4 ,false},
181 { ARM::VLD2d32Pseudo, ARM::VLD2d32, true, false, false, SingleSpc, 2, 2 ,false},
182 { ARM::VLD2d32Pseudo_UPD, ARM::VLD2d32_UPD, true, true, true, SingleSpc, 2, 2 ,false},
183 { ARM::VLD2d8Pseudo, ARM::VLD2d8, true, false, false, SingleSpc, 2, 8 ,false},
184 { ARM::VLD2d8Pseudo_UPD, ARM::VLD2d8_UPD, true, true, true, SingleSpc, 2, 8 ,false},
186 { ARM::VLD2q16Pseudo, ARM::VLD2q16, true, false, false, SingleSpc, 4, 4 ,false},
187 { ARM::VLD2q16Pseudo_UPD, ARM::VLD2q16_UPD, true, true, true, SingleSpc, 4, 4 ,false},
188 { ARM::VLD2q32Pseudo, ARM::VLD2q32, true, false, false, SingleSpc, 4, 2 ,false},
189 { ARM::VLD2q32Pseudo_UPD, ARM::VLD2q32_UPD, true, true, true, SingleSpc, 4, 2 ,false},
190 { ARM::VLD2q8Pseudo, ARM::VLD2q8, true, false, false, SingleSpc, 4, 8 ,false},
191 { ARM::VLD2q8Pseudo_UPD, ARM::VLD2q8_UPD, true, true, true, SingleSpc, 4, 8 ,false},
193 { ARM::VLD3DUPd16Pseudo, ARM::VLD3DUPd16, true, false, false, SingleSpc, 3, 4,true},
194 { ARM::VLD3DUPd16Pseudo_UPD, ARM::VLD3DUPd16_UPD, true, true, true, SingleSpc, 3, 4,true},
195 { ARM::VLD3DUPd32Pseudo, ARM::VLD3DUPd32, true, false, false, SingleSpc, 3, 2,true},
196 { ARM::VLD3DUPd32Pseudo_UPD, ARM::VLD3DUPd32_UPD, true, true, true, SingleSpc, 3, 2,true},
197 { ARM::VLD3DUPd8Pseudo, ARM::VLD3DUPd8, true, false, false, SingleSpc, 3, 8,true},
198 { ARM::VLD3DUPd8Pseudo_UPD, ARM::VLD3DUPd8_UPD, true, true, true, SingleSpc, 3, 8,true},
200 { ARM::VLD3LNd16Pseudo, ARM::VLD3LNd16, true, false, false, SingleSpc, 3, 4 ,true},
201 { ARM::VLD3LNd16Pseudo_UPD, ARM::VLD3LNd16_UPD, true, true, true, SingleSpc, 3, 4 ,true},
202 { ARM::VLD3LNd32Pseudo, ARM::VLD3LNd32, true, false, false, SingleSpc, 3, 2 ,true},
203 { ARM::VLD3LNd32Pseudo_UPD, ARM::VLD3LNd32_UPD, true, true, true, SingleSpc, 3, 2 ,true},
204 { ARM::VLD3LNd8Pseudo, ARM::VLD3LNd8, true, false, false, SingleSpc, 3, 8 ,true},
205 { ARM::VLD3LNd8Pseudo_UPD, ARM::VLD3LNd8_UPD, true, true, true, SingleSpc, 3, 8 ,true},
206 { ARM::VLD3LNq16Pseudo, ARM::VLD3LNq16, true, false, false, EvenDblSpc, 3, 4 ,true},
207 { ARM::VLD3LNq16Pseudo_UPD, ARM::VLD3LNq16_UPD, true, true, true, EvenDblSpc, 3, 4 ,true},
208 { ARM::VLD3LNq32Pseudo, ARM::VLD3LNq32, true, false, false, EvenDblSpc, 3, 2 ,true},
209 { ARM::VLD3LNq32Pseudo_UPD, ARM::VLD3LNq32_UPD, true, true, true, EvenDblSpc, 3, 2 ,true},
211 { ARM::VLD3d16Pseudo, ARM::VLD3d16, true, false, false, SingleSpc, 3, 4 ,true},
212 { ARM::VLD3d16Pseudo_UPD, ARM::VLD3d16_UPD, true, true, true, SingleSpc, 3, 4 ,true},
213 { ARM::VLD3d32Pseudo, ARM::VLD3d32, true, false, false, SingleSpc, 3, 2 ,true},
214 { ARM::VLD3d32Pseudo_UPD, ARM::VLD3d32_UPD, true, true, true, SingleSpc, 3, 2 ,true},
215 { ARM::VLD3d8Pseudo, ARM::VLD3d8, true, false, false, SingleSpc, 3, 8 ,true},
216 { ARM::VLD3d8Pseudo_UPD, ARM::VLD3d8_UPD, true, true, true, SingleSpc, 3, 8 ,true},
218 { ARM::VLD3q16Pseudo_UPD, ARM::VLD3q16_UPD, true, true, true, EvenDblSpc, 3, 4 ,true},
219 { ARM::VLD3q16oddPseudo, ARM::VLD3q16, true, false, false, OddDblSpc, 3, 4 ,true},
220 { ARM::VLD3q16oddPseudo_UPD, ARM::VLD3q16_UPD, true, true, true, OddDblSpc, 3, 4 ,true},
221 { ARM::VLD3q32Pseudo_UPD, ARM::VLD3q32_UPD, true, true, true, EvenDblSpc, 3, 2 ,true},
222 { ARM::VLD3q32oddPseudo, ARM::VLD3q32, true, false, false, OddDblSpc, 3, 2 ,true},
223 { ARM::VLD3q32oddPseudo_UPD, ARM::VLD3q32_UPD, true, true, true, OddDblSpc, 3, 2 ,true},
224 { ARM::VLD3q8Pseudo_UPD, ARM::VLD3q8_UPD, true, true, true, EvenDblSpc, 3, 8 ,true},
225 { ARM::VLD3q8oddPseudo, ARM::VLD3q8, true, false, false, OddDblSpc, 3, 8 ,true},
226 { ARM::VLD3q8oddPseudo_UPD, ARM::VLD3q8_UPD, true, true, true, OddDblSpc, 3, 8 ,true},
228 { ARM::VLD4DUPd16Pseudo, ARM::VLD4DUPd16, true, false, false, SingleSpc, 4, 4,true},
229 { ARM::VLD4DUPd16Pseudo_UPD, ARM::VLD4DUPd16_UPD, true, true, true, SingleSpc, 4, 4,true},
230 { ARM::VLD4DUPd32Pseudo, ARM::VLD4DUPd32, true, false, false, SingleSpc, 4, 2,true},
231 { ARM::VLD4DUPd32Pseudo_UPD, ARM::VLD4DUPd32_UPD, true, true, true, SingleSpc, 4, 2,true},
232 { ARM::VLD4DUPd8Pseudo, ARM::VLD4DUPd8, true, false, false, SingleSpc, 4, 8,true},
233 { ARM::VLD4DUPd8Pseudo_UPD, ARM::VLD4DUPd8_UPD, true, true, true, SingleSpc, 4, 8,true},
235 { ARM::VLD4LNd16Pseudo, ARM::VLD4LNd16, true, false, false, SingleSpc, 4, 4 ,true},
236 { ARM::VLD4LNd16Pseudo_UPD, ARM::VLD4LNd16_UPD, true, true, true, SingleSpc, 4, 4 ,true},
237 { ARM::VLD4LNd32Pseudo, ARM::VLD4LNd32, true, false, false, SingleSpc, 4, 2 ,true},
238 { ARM::VLD4LNd32Pseudo_UPD, ARM::VLD4LNd32_UPD, true, true, true, SingleSpc, 4, 2 ,true},
239 { ARM::VLD4LNd8Pseudo, ARM::VLD4LNd8, true, false, false, SingleSpc, 4, 8 ,true},
240 { ARM::VLD4LNd8Pseudo_UPD, ARM::VLD4LNd8_UPD, true, true, true, SingleSpc, 4, 8 ,true},
241 { ARM::VLD4LNq16Pseudo, ARM::VLD4LNq16, true, false, false, EvenDblSpc, 4, 4 ,true},
242 { ARM::VLD4LNq16Pseudo_UPD, ARM::VLD4LNq16_UPD, true, true, true, EvenDblSpc, 4, 4 ,true},
243 { ARM::VLD4LNq32Pseudo, ARM::VLD4LNq32, true, false, false, EvenDblSpc, 4, 2 ,true},
244 { ARM::VLD4LNq32Pseudo_UPD, ARM::VLD4LNq32_UPD, true, true, true, EvenDblSpc, 4, 2 ,true},
246 { ARM::VLD4d16Pseudo, ARM::VLD4d16, true, false, false, SingleSpc, 4, 4 ,true},
247 { ARM::VLD4d16Pseudo_UPD, ARM::VLD4d16_UPD, true, true, true, SingleSpc, 4, 4 ,true},
248 { ARM::VLD4d32Pseudo, ARM::VLD4d32, true, false, false, SingleSpc, 4, 2 ,true},
249 { ARM::VLD4d32Pseudo_UPD, ARM::VLD4d32_UPD, true, true, true, SingleSpc, 4, 2 ,true},
250 { ARM::VLD4d8Pseudo, ARM::VLD4d8, true, false, false, SingleSpc, 4, 8 ,true},
251 { ARM::VLD4d8Pseudo_UPD, ARM::VLD4d8_UPD, true, true, true, SingleSpc, 4, 8 ,true},
253 { ARM::VLD4q16Pseudo_UPD, ARM::VLD4q16_UPD, true, true, true, EvenDblSpc, 4, 4 ,true},
254 { ARM::VLD4q16oddPseudo, ARM::VLD4q16, true, false, false, OddDblSpc, 4, 4 ,true},
255 { ARM::VLD4q16oddPseudo_UPD, ARM::VLD4q16_UPD, true, true, true, OddDblSpc, 4, 4 ,true},
256 { ARM::VLD4q32Pseudo_UPD, ARM::VLD4q32_UPD, true, true, true, EvenDblSpc, 4, 2 ,true},
257 { ARM::VLD4q32oddPseudo, ARM::VLD4q32, true, false, false, OddDblSpc, 4, 2 ,true},
258 { ARM::VLD4q32oddPseudo_UPD, ARM::VLD4q32_UPD, true, true, true, OddDblSpc, 4, 2 ,true},
259 { ARM::VLD4q8Pseudo_UPD, ARM::VLD4q8_UPD, true, true, true, EvenDblSpc, 4, 8 ,true},
260 { ARM::VLD4q8oddPseudo, ARM::VLD4q8, true, false, false, OddDblSpc, 4, 8 ,true},
261 { ARM::VLD4q8oddPseudo_UPD, ARM::VLD4q8_UPD, true, true, true, OddDblSpc, 4, 8 ,true},
263 { ARM::VST1LNq16Pseudo, ARM::VST1LNd16, false, false, false, EvenDblSpc, 1, 4 ,true},
264 { ARM::VST1LNq16Pseudo_UPD, ARM::VST1LNd16_UPD, false, true, true, EvenDblSpc, 1, 4 ,true},
265 { ARM::VST1LNq32Pseudo, ARM::VST1LNd32, false, false, false, EvenDblSpc, 1, 2 ,true},
266 { ARM::VST1LNq32Pseudo_UPD, ARM::VST1LNd32_UPD, false, true, true, EvenDblSpc, 1, 2 ,true},
267 { ARM::VST1LNq8Pseudo, ARM::VST1LNd8, false, false, false, EvenDblSpc, 1, 8 ,true},
268 { ARM::VST1LNq8Pseudo_UPD, ARM::VST1LNd8_UPD, false, true, true, EvenDblSpc, 1, 8 ,true},
270 { ARM::VST1d64QPseudo, ARM::VST1d64Q, false, false, false, SingleSpc, 4, 1 ,false},
271 { ARM::VST1d64QPseudoWB_fixed, ARM::VST1d64Qwb_fixed, false, true, false, SingleSpc, 4, 1 ,false},
272 { ARM::VST1d64QPseudoWB_register, ARM::VST1d64Qwb_register, false, true, true, SingleSpc, 4, 1 ,false},
273 { ARM::VST1d64TPseudo, ARM::VST1d64T, false, false, false, SingleSpc, 3, 1 ,false},
274 { ARM::VST1d64TPseudoWB_fixed, ARM::VST1d64Twb_fixed, false, true, false, SingleSpc, 3, 1 ,false},
275 { ARM::VST1d64TPseudoWB_register, ARM::VST1d64Twb_register, false, true, true, SingleSpc, 3, 1 ,false},
277 { ARM::VST1q16Pseudo, ARM::VST1q16, false, false, false, SingleSpc, 2, 4 ,false},
278 { ARM::VST1q16PseudoWB_fixed, ARM::VST1q16wb_fixed, false, true, false, SingleSpc, 2, 4 ,false},
279 { ARM::VST1q16PseudoWB_register, ARM::VST1q16wb_register, false, true, true, SingleSpc, 2, 4 ,false},
280 { ARM::VST1q32Pseudo, ARM::VST1q32, false, false, false, SingleSpc, 2, 2 ,false},
281 { ARM::VST1q32PseudoWB_fixed, ARM::VST1q32wb_fixed, false, true, false, SingleSpc, 2, 2 ,false},
282 { ARM::VST1q32PseudoWB_register, ARM::VST1q32wb_register, false, true, true, SingleSpc, 2, 2 ,false},
283 { ARM::VST1q64Pseudo, ARM::VST1q64, false, false, false, SingleSpc, 2, 1 ,false},
284 { ARM::VST1q64PseudoWB_fixed, ARM::VST1q64wb_fixed, false, true, false, SingleSpc, 2, 1 ,false},
285 { ARM::VST1q64PseudoWB_register, ARM::VST1q64wb_register, false, true, true, SingleSpc, 2, 1 ,false},
286 { ARM::VST1q8Pseudo, ARM::VST1q8, false, false, false, SingleSpc, 2, 8 ,false},
287 { ARM::VST1q8PseudoWB_fixed, ARM::VST1q8wb_fixed, false, true, false, SingleSpc, 2, 8 ,false},
288 { ARM::VST1q8PseudoWB_register, ARM::VST1q8wb_register, false, true, true, SingleSpc, 2, 8 ,false},
290 { ARM::VST2LNd16Pseudo, ARM::VST2LNd16, false, false, false, SingleSpc, 2, 4 ,true},
291 { ARM::VST2LNd16Pseudo_UPD, ARM::VST2LNd16_UPD, false, true, true, SingleSpc, 2, 4 ,true},
292 { ARM::VST2LNd32Pseudo, ARM::VST2LNd32, false, false, false, SingleSpc, 2, 2 ,true},
293 { ARM::VST2LNd32Pseudo_UPD, ARM::VST2LNd32_UPD, false, true, true, SingleSpc, 2, 2 ,true},
294 { ARM::VST2LNd8Pseudo, ARM::VST2LNd8, false, false, false, SingleSpc, 2, 8 ,true},
295 { ARM::VST2LNd8Pseudo_UPD, ARM::VST2LNd8_UPD, false, true, true, SingleSpc, 2, 8 ,true},
296 { ARM::VST2LNq16Pseudo, ARM::VST2LNq16, false, false, false, EvenDblSpc, 2, 4,true},
297 { ARM::VST2LNq16Pseudo_UPD, ARM::VST2LNq16_UPD, false, true, true, EvenDblSpc, 2, 4,true},
298 { ARM::VST2LNq32Pseudo, ARM::VST2LNq32, false, false, false, EvenDblSpc, 2, 2,true},
299 { ARM::VST2LNq32Pseudo_UPD, ARM::VST2LNq32_UPD, false, true, true, EvenDblSpc, 2, 2,true},
301 { ARM::VST2d16Pseudo, ARM::VST2d16, false, false, false, SingleSpc, 2, 4 ,true},
302 { ARM::VST2d16Pseudo_UPD, ARM::VST2d16_UPD, false, true, true, SingleSpc, 2, 4 ,true},
303 { ARM::VST2d32Pseudo, ARM::VST2d32, false, false, false, SingleSpc, 2, 2 ,true},
304 { ARM::VST2d32Pseudo_UPD, ARM::VST2d32_UPD, false, true, true, SingleSpc, 2, 2 ,true},
305 { ARM::VST2d8Pseudo, ARM::VST2d8, false, false, false, SingleSpc, 2, 8 ,true},
306 { ARM::VST2d8Pseudo_UPD, ARM::VST2d8_UPD, false, true, true, SingleSpc, 2, 8 ,true},
308 { ARM::VST2q16Pseudo, ARM::VST2q16, false, false, false, SingleSpc, 4, 4 ,true},
309 { ARM::VST2q16Pseudo_UPD, ARM::VST2q16_UPD, false, true, true, SingleSpc, 4, 4 ,true},
310 { ARM::VST2q32Pseudo, ARM::VST2q32, false, false, false, SingleSpc, 4, 2 ,true},
311 { ARM::VST2q32Pseudo_UPD, ARM::VST2q32_UPD, false, true, true, SingleSpc, 4, 2 ,true},
312 { ARM::VST2q8Pseudo, ARM::VST2q8, false, false, false, SingleSpc, 4, 8 ,true},
313 { ARM::VST2q8Pseudo_UPD, ARM::VST2q8_UPD, false, true, true, SingleSpc, 4, 8 ,true},
315 { ARM::VST3LNd16Pseudo, ARM::VST3LNd16, false, false, false, SingleSpc, 3, 4 ,true},
316 { ARM::VST3LNd16Pseudo_UPD, ARM::VST3LNd16_UPD, false, true, true, SingleSpc, 3, 4 ,true},
317 { ARM::VST3LNd32Pseudo, ARM::VST3LNd32, false, false, false, SingleSpc, 3, 2 ,true},
318 { ARM::VST3LNd32Pseudo_UPD, ARM::VST3LNd32_UPD, false, true, true, SingleSpc, 3, 2 ,true},
319 { ARM::VST3LNd8Pseudo, ARM::VST3LNd8, false, false, false, SingleSpc, 3, 8 ,true},
320 { ARM::VST3LNd8Pseudo_UPD, ARM::VST3LNd8_UPD, false, true, true, SingleSpc, 3, 8 ,true},
321 { ARM::VST3LNq16Pseudo, ARM::VST3LNq16, false, false, false, EvenDblSpc, 3, 4,true},
322 { ARM::VST3LNq16Pseudo_UPD, ARM::VST3LNq16_UPD, false, true, true, EvenDblSpc, 3, 4,true},
323 { ARM::VST3LNq32Pseudo, ARM::VST3LNq32, false, false, false, EvenDblSpc, 3, 2,true},
324 { ARM::VST3LNq32Pseudo_UPD, ARM::VST3LNq32_UPD, false, true, true, EvenDblSpc, 3, 2,true},
326 { ARM::VST3d16Pseudo, ARM::VST3d16, false, false, false, SingleSpc, 3, 4 ,true},
327 { ARM::VST3d16Pseudo_UPD, ARM::VST3d16_UPD, false, true, true, SingleSpc, 3, 4 ,true},
328 { ARM::VST3d32Pseudo, ARM::VST3d32, false, false, false, SingleSpc, 3, 2 ,true},
329 { ARM::VST3d32Pseudo_UPD, ARM::VST3d32_UPD, false, true, true, SingleSpc, 3, 2 ,true},
330 { ARM::VST3d8Pseudo, ARM::VST3d8, false, false, false, SingleSpc, 3, 8 ,true},
331 { ARM::VST3d8Pseudo_UPD, ARM::VST3d8_UPD, false, true, true, SingleSpc, 3, 8 ,true},
333 { ARM::VST3q16Pseudo_UPD, ARM::VST3q16_UPD, false, true, true, EvenDblSpc, 3, 4 ,true},
334 { ARM::VST3q16oddPseudo, ARM::VST3q16, false, false, false, OddDblSpc, 3, 4 ,true},
335 { ARM::VST3q16oddPseudo_UPD, ARM::VST3q16_UPD, false, true, true, OddDblSpc, 3, 4 ,true},
336 { ARM::VST3q32Pseudo_UPD, ARM::VST3q32_UPD, false, true, true, EvenDblSpc, 3, 2 ,true},
337 { ARM::VST3q32oddPseudo, ARM::VST3q32, false, false, false, OddDblSpc, 3, 2 ,true},
338 { ARM::VST3q32oddPseudo_UPD, ARM::VST3q32_UPD, false, true, true, OddDblSpc, 3, 2 ,true},
339 { ARM::VST3q8Pseudo_UPD, ARM::VST3q8_UPD, false, true, true, EvenDblSpc, 3, 8 ,true},
340 { ARM::VST3q8oddPseudo, ARM::VST3q8, false, false, false, OddDblSpc, 3, 8 ,true},
341 { ARM::VST3q8oddPseudo_UPD, ARM::VST3q8_UPD, false, true, true, OddDblSpc, 3, 8 ,true},
343 { ARM::VST4LNd16Pseudo, ARM::VST4LNd16, false, false, false, SingleSpc, 4, 4 ,true},
344 { ARM::VST4LNd16Pseudo_UPD, ARM::VST4LNd16_UPD, false, true, true, SingleSpc, 4, 4 ,true},
345 { ARM::VST4LNd32Pseudo, ARM::VST4LNd32, false, false, false, SingleSpc, 4, 2 ,true},
346 { ARM::VST4LNd32Pseudo_UPD, ARM::VST4LNd32_UPD, false, true, true, SingleSpc, 4, 2 ,true},
347 { ARM::VST4LNd8Pseudo, ARM::VST4LNd8, false, false, false, SingleSpc, 4, 8 ,true},
348 { ARM::VST4LNd8Pseudo_UPD, ARM::VST4LNd8_UPD, false, true, true, SingleSpc, 4, 8 ,true},
349 { ARM::VST4LNq16Pseudo, ARM::VST4LNq16, false, false, false, EvenDblSpc, 4, 4,true},
350 { ARM::VST4LNq16Pseudo_UPD, ARM::VST4LNq16_UPD, false, true, true, EvenDblSpc, 4, 4,true},
351 { ARM::VST4LNq32Pseudo, ARM::VST4LNq32, false, false, false, EvenDblSpc, 4, 2,true},
352 { ARM::VST4LNq32Pseudo_UPD, ARM::VST4LNq32_UPD, false, true, true, EvenDblSpc, 4, 2,true},
354 { ARM::VST4d16Pseudo, ARM::VST4d16, false, false, false, SingleSpc, 4, 4 ,true},
355 { ARM::VST4d16Pseudo_UPD, ARM::VST4d16_UPD, false, true, true, SingleSpc, 4, 4 ,true},
356 { ARM::VST4d32Pseudo, ARM::VST4d32, false, false, false, SingleSpc, 4, 2 ,true},
357 { ARM::VST4d32Pseudo_UPD, ARM::VST4d32_UPD, false, true, true, SingleSpc, 4, 2 ,true},
358 { ARM::VST4d8Pseudo, ARM::VST4d8, false, false, false, SingleSpc, 4, 8 ,true},
359 { ARM::VST4d8Pseudo_UPD, ARM::VST4d8_UPD, false, true, true, SingleSpc, 4, 8 ,true},
361 { ARM::VST4q16Pseudo_UPD, ARM::VST4q16_UPD, false, true, true, EvenDblSpc, 4, 4 ,true},
362 { ARM::VST4q16oddPseudo, ARM::VST4q16, false, false, false, OddDblSpc, 4, 4 ,true},
363 { ARM::VST4q16oddPseudo_UPD, ARM::VST4q16_UPD, false, true, true, OddDblSpc, 4, 4 ,true},
364 { ARM::VST4q32Pseudo_UPD, ARM::VST4q32_UPD, false, true, true, EvenDblSpc, 4, 2 ,true},
365 { ARM::VST4q32oddPseudo, ARM::VST4q32, false, false, false, OddDblSpc, 4, 2 ,true},
366 { ARM::VST4q32oddPseudo_UPD, ARM::VST4q32_UPD, false, true, true, OddDblSpc, 4, 2 ,true},
367 { ARM::VST4q8Pseudo_UPD, ARM::VST4q8_UPD, false, true, true, EvenDblSpc, 4, 8 ,true},
368 { ARM::VST4q8oddPseudo, ARM::VST4q8, false, false, false, OddDblSpc, 4, 8 ,true},
369 { ARM::VST4q8oddPseudo_UPD, ARM::VST4q8_UPD, false, true, true, OddDblSpc, 4, 8 ,true}
372 /// LookupNEONLdSt - Search the NEONLdStTable for information about a NEON
373 /// load or store pseudo instruction.
374 static const NEONLdStTableEntry *LookupNEONLdSt(unsigned Opcode) {
375 unsigned NumEntries = array_lengthof(NEONLdStTable);
378 // Make sure the table is sorted.
379 static bool TableChecked = false;
381 for (unsigned i = 0; i != NumEntries-1; ++i)
382 assert(NEONLdStTable[i] < NEONLdStTable[i+1] &&
383 "NEONLdStTable is not sorted!");
388 const NEONLdStTableEntry *I =
389 std::lower_bound(NEONLdStTable, NEONLdStTable + NumEntries, Opcode);
390 if (I != NEONLdStTable + NumEntries && I->PseudoOpc == Opcode)
395 /// GetDSubRegs - Get 4 D subregisters of a Q, QQ, or QQQQ register,
396 /// corresponding to the specified register spacing. Not all of the results
397 /// are necessarily valid, e.g., a Q register only has 2 D subregisters.
398 static void GetDSubRegs(unsigned Reg, NEONRegSpacing RegSpc,
399 const TargetRegisterInfo *TRI, unsigned &D0,
400 unsigned &D1, unsigned &D2, unsigned &D3) {
401 if (RegSpc == SingleSpc) {
402 D0 = TRI->getSubReg(Reg, ARM::dsub_0);
403 D1 = TRI->getSubReg(Reg, ARM::dsub_1);
404 D2 = TRI->getSubReg(Reg, ARM::dsub_2);
405 D3 = TRI->getSubReg(Reg, ARM::dsub_3);
406 } else if (RegSpc == EvenDblSpc) {
407 D0 = TRI->getSubReg(Reg, ARM::dsub_0);
408 D1 = TRI->getSubReg(Reg, ARM::dsub_2);
409 D2 = TRI->getSubReg(Reg, ARM::dsub_4);
410 D3 = TRI->getSubReg(Reg, ARM::dsub_6);
412 assert(RegSpc == OddDblSpc && "unknown register spacing");
413 D0 = TRI->getSubReg(Reg, ARM::dsub_1);
414 D1 = TRI->getSubReg(Reg, ARM::dsub_3);
415 D2 = TRI->getSubReg(Reg, ARM::dsub_5);
416 D3 = TRI->getSubReg(Reg, ARM::dsub_7);
420 /// ExpandVLD - Translate VLD pseudo instructions with Q, QQ or QQQQ register
421 /// operands to real VLD instructions with D register operands.
422 void ARMExpandPseudo::ExpandVLD(MachineBasicBlock::iterator &MBBI) {
423 MachineInstr &MI = *MBBI;
424 MachineBasicBlock &MBB = *MI.getParent();
426 const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode());
427 assert(TableEntry && TableEntry->IsLoad && "NEONLdStTable lookup failed");
428 NEONRegSpacing RegSpc = TableEntry->RegSpacing;
429 unsigned NumRegs = TableEntry->NumRegs;
431 MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
432 TII->get(TableEntry->RealOpc));
435 bool DstIsDead = MI.getOperand(OpIdx).isDead();
436 unsigned DstReg = MI.getOperand(OpIdx++).getReg();
437 unsigned D0, D1, D2, D3;
438 GetDSubRegs(DstReg, RegSpc, TRI, D0, D1, D2, D3);
439 MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead));
440 if (NumRegs > 1 && TableEntry->copyAllListRegs)
441 MIB.addReg(D1, RegState::Define | getDeadRegState(DstIsDead));
442 if (NumRegs > 2 && TableEntry->copyAllListRegs)
443 MIB.addReg(D2, RegState::Define | getDeadRegState(DstIsDead));
444 if (NumRegs > 3 && TableEntry->copyAllListRegs)
445 MIB.addReg(D3, RegState::Define | getDeadRegState(DstIsDead));
447 if (TableEntry->isUpdating)
448 MIB.addOperand(MI.getOperand(OpIdx++));
450 // Copy the addrmode6 operands.
451 MIB.addOperand(MI.getOperand(OpIdx++));
452 MIB.addOperand(MI.getOperand(OpIdx++));
453 // Copy the am6offset operand.
454 if (TableEntry->hasWritebackOperand)
455 MIB.addOperand(MI.getOperand(OpIdx++));
457 // For an instruction writing double-spaced subregs, the pseudo instruction
458 // has an extra operand that is a use of the super-register. Record the
459 // operand index and skip over it.
460 unsigned SrcOpIdx = 0;
461 if (RegSpc == EvenDblSpc || RegSpc == OddDblSpc)
464 // Copy the predicate operands.
465 MIB.addOperand(MI.getOperand(OpIdx++));
466 MIB.addOperand(MI.getOperand(OpIdx++));
468 // Copy the super-register source operand used for double-spaced subregs over
469 // to the new instruction as an implicit operand.
471 MachineOperand MO = MI.getOperand(SrcOpIdx);
472 MO.setImplicit(true);
475 // Add an implicit def for the super-register.
476 MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead));
477 TransferImpOps(MI, MIB, MIB);
479 // Transfer memoperands.
480 MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
482 MI.eraseFromParent();
485 /// ExpandVST - Translate VST pseudo instructions with Q, QQ or QQQQ register
486 /// operands to real VST instructions with D register operands.
487 void ARMExpandPseudo::ExpandVST(MachineBasicBlock::iterator &MBBI) {
488 MachineInstr &MI = *MBBI;
489 MachineBasicBlock &MBB = *MI.getParent();
491 const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode());
492 assert(TableEntry && !TableEntry->IsLoad && "NEONLdStTable lookup failed");
493 NEONRegSpacing RegSpc = TableEntry->RegSpacing;
494 unsigned NumRegs = TableEntry->NumRegs;
496 MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
497 TII->get(TableEntry->RealOpc));
499 if (TableEntry->isUpdating)
500 MIB.addOperand(MI.getOperand(OpIdx++));
502 // Copy the addrmode6 operands.
503 MIB.addOperand(MI.getOperand(OpIdx++));
504 MIB.addOperand(MI.getOperand(OpIdx++));
505 // Copy the am6offset operand.
506 if (TableEntry->hasWritebackOperand)
507 MIB.addOperand(MI.getOperand(OpIdx++));
509 bool SrcIsKill = MI.getOperand(OpIdx).isKill();
510 unsigned SrcReg = MI.getOperand(OpIdx++).getReg();
511 unsigned D0, D1, D2, D3;
512 GetDSubRegs(SrcReg, RegSpc, TRI, D0, D1, D2, D3);
514 if (NumRegs > 1 && TableEntry->copyAllListRegs)
516 if (NumRegs > 2 && TableEntry->copyAllListRegs)
518 if (NumRegs > 3 && TableEntry->copyAllListRegs)
521 // Copy the predicate operands.
522 MIB.addOperand(MI.getOperand(OpIdx++));
523 MIB.addOperand(MI.getOperand(OpIdx++));
525 if (SrcIsKill) // Add an implicit kill for the super-reg.
526 MIB->addRegisterKilled(SrcReg, TRI, true);
527 TransferImpOps(MI, MIB, MIB);
529 // Transfer memoperands.
530 MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
532 MI.eraseFromParent();
535 /// ExpandLaneOp - Translate VLD*LN and VST*LN instructions with Q, QQ or QQQQ
536 /// register operands to real instructions with D register operands.
537 void ARMExpandPseudo::ExpandLaneOp(MachineBasicBlock::iterator &MBBI) {
538 MachineInstr &MI = *MBBI;
539 MachineBasicBlock &MBB = *MI.getParent();
541 const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode());
542 assert(TableEntry && "NEONLdStTable lookup failed");
543 NEONRegSpacing RegSpc = TableEntry->RegSpacing;
544 unsigned NumRegs = TableEntry->NumRegs;
545 unsigned RegElts = TableEntry->RegElts;
547 MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
548 TII->get(TableEntry->RealOpc));
550 // The lane operand is always the 3rd from last operand, before the 2
551 // predicate operands.
552 unsigned Lane = MI.getOperand(MI.getDesc().getNumOperands() - 3).getImm();
554 // Adjust the lane and spacing as needed for Q registers.
555 assert(RegSpc != OddDblSpc && "unexpected register spacing for VLD/VST-lane");
556 if (RegSpc == EvenDblSpc && Lane >= RegElts) {
560 assert(Lane < RegElts && "out of range lane for VLD/VST-lane");
562 unsigned D0 = 0, D1 = 0, D2 = 0, D3 = 0;
564 bool DstIsDead = false;
565 if (TableEntry->IsLoad) {
566 DstIsDead = MI.getOperand(OpIdx).isDead();
567 DstReg = MI.getOperand(OpIdx++).getReg();
568 GetDSubRegs(DstReg, RegSpc, TRI, D0, D1, D2, D3);
569 MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead));
571 MIB.addReg(D1, RegState::Define | getDeadRegState(DstIsDead));
573 MIB.addReg(D2, RegState::Define | getDeadRegState(DstIsDead));
575 MIB.addReg(D3, RegState::Define | getDeadRegState(DstIsDead));
578 if (TableEntry->isUpdating)
579 MIB.addOperand(MI.getOperand(OpIdx++));
581 // Copy the addrmode6 operands.
582 MIB.addOperand(MI.getOperand(OpIdx++));
583 MIB.addOperand(MI.getOperand(OpIdx++));
584 // Copy the am6offset operand.
585 if (TableEntry->hasWritebackOperand)
586 MIB.addOperand(MI.getOperand(OpIdx++));
588 // Grab the super-register source.
589 MachineOperand MO = MI.getOperand(OpIdx++);
590 if (!TableEntry->IsLoad)
591 GetDSubRegs(MO.getReg(), RegSpc, TRI, D0, D1, D2, D3);
593 // Add the subregs as sources of the new instruction.
594 unsigned SrcFlags = (getUndefRegState(MO.isUndef()) |
595 getKillRegState(MO.isKill()));
596 MIB.addReg(D0, SrcFlags);
598 MIB.addReg(D1, SrcFlags);
600 MIB.addReg(D2, SrcFlags);
602 MIB.addReg(D3, SrcFlags);
604 // Add the lane number operand.
608 // Copy the predicate operands.
609 MIB.addOperand(MI.getOperand(OpIdx++));
610 MIB.addOperand(MI.getOperand(OpIdx++));
612 // Copy the super-register source to be an implicit source.
613 MO.setImplicit(true);
615 if (TableEntry->IsLoad)
616 // Add an implicit def for the super-register.
617 MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead));
618 TransferImpOps(MI, MIB, MIB);
619 MI.eraseFromParent();
622 /// ExpandVTBL - Translate VTBL and VTBX pseudo instructions with Q or QQ
623 /// register operands to real instructions with D register operands.
624 void ARMExpandPseudo::ExpandVTBL(MachineBasicBlock::iterator &MBBI,
625 unsigned Opc, bool IsExt, unsigned NumRegs) {
626 MachineInstr &MI = *MBBI;
627 MachineBasicBlock &MBB = *MI.getParent();
629 MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(Opc));
632 // Transfer the destination register operand.
633 MIB.addOperand(MI.getOperand(OpIdx++));
635 MIB.addOperand(MI.getOperand(OpIdx++));
637 bool SrcIsKill = MI.getOperand(OpIdx).isKill();
638 unsigned SrcReg = MI.getOperand(OpIdx++).getReg();
639 unsigned D0, D1, D2, D3;
640 GetDSubRegs(SrcReg, SingleSpc, TRI, D0, D1, D2, D3);
641 MIB.addReg(D0).addReg(D1);
647 // Copy the other source register operand.
648 MIB.addOperand(MI.getOperand(OpIdx++));
650 // Copy the predicate operands.
651 MIB.addOperand(MI.getOperand(OpIdx++));
652 MIB.addOperand(MI.getOperand(OpIdx++));
654 if (SrcIsKill) // Add an implicit kill for the super-reg.
655 MIB->addRegisterKilled(SrcReg, TRI, true);
656 TransferImpOps(MI, MIB, MIB);
657 MI.eraseFromParent();
660 void ARMExpandPseudo::ExpandMOV32BitImm(MachineBasicBlock &MBB,
661 MachineBasicBlock::iterator &MBBI) {
662 MachineInstr &MI = *MBBI;
663 unsigned Opcode = MI.getOpcode();
664 unsigned PredReg = 0;
665 ARMCC::CondCodes Pred = llvm::getInstrPredicate(&MI, PredReg);
666 unsigned DstReg = MI.getOperand(0).getReg();
667 bool DstIsDead = MI.getOperand(0).isDead();
668 bool isCC = Opcode == ARM::MOVCCi32imm || Opcode == ARM::t2MOVCCi32imm;
669 const MachineOperand &MO = MI.getOperand(isCC ? 2 : 1);
670 MachineInstrBuilder LO16, HI16;
672 if (!STI->hasV6T2Ops() &&
673 (Opcode == ARM::MOVi32imm || Opcode == ARM::MOVCCi32imm)) {
674 // Expand into a movi + orr.
675 LO16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVi), DstReg);
676 HI16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::ORRri))
677 .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
680 assert (MO.isImm() && "MOVi32imm w/ non-immediate source operand!");
681 unsigned ImmVal = (unsigned)MO.getImm();
682 unsigned SOImmValV1 = ARM_AM::getSOImmTwoPartFirst(ImmVal);
683 unsigned SOImmValV2 = ARM_AM::getSOImmTwoPartSecond(ImmVal);
684 LO16 = LO16.addImm(SOImmValV1);
685 HI16 = HI16.addImm(SOImmValV2);
686 LO16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
687 HI16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
688 LO16.addImm(Pred).addReg(PredReg).addReg(0);
689 HI16.addImm(Pred).addReg(PredReg).addReg(0);
690 TransferImpOps(MI, LO16, HI16);
691 MI.eraseFromParent();
695 unsigned LO16Opc = 0;
696 unsigned HI16Opc = 0;
697 if (Opcode == ARM::t2MOVi32imm || Opcode == ARM::t2MOVCCi32imm) {
698 LO16Opc = ARM::t2MOVi16;
699 HI16Opc = ARM::t2MOVTi16;
701 LO16Opc = ARM::MOVi16;
702 HI16Opc = ARM::MOVTi16;
705 LO16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(LO16Opc), DstReg);
706 HI16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(HI16Opc))
707 .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
711 unsigned Imm = MO.getImm();
712 unsigned Lo16 = Imm & 0xffff;
713 unsigned Hi16 = (Imm >> 16) & 0xffff;
714 LO16 = LO16.addImm(Lo16);
715 HI16 = HI16.addImm(Hi16);
717 const GlobalValue *GV = MO.getGlobal();
718 unsigned TF = MO.getTargetFlags();
719 LO16 = LO16.addGlobalAddress(GV, MO.getOffset(), TF | ARMII::MO_LO16);
720 HI16 = HI16.addGlobalAddress(GV, MO.getOffset(), TF | ARMII::MO_HI16);
723 LO16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
724 HI16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
725 LO16.addImm(Pred).addReg(PredReg);
726 HI16.addImm(Pred).addReg(PredReg);
728 TransferImpOps(MI, LO16, HI16);
729 MI.eraseFromParent();
732 bool ARMExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
733 MachineBasicBlock::iterator MBBI) {
734 MachineInstr &MI = *MBBI;
735 unsigned Opcode = MI.getOpcode();
741 unsigned newOpc = Opcode == ARM::VMOVScc ? ARM::VMOVS : ARM::VMOVD;
742 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(newOpc),
743 MI.getOperand(1).getReg())
744 .addReg(MI.getOperand(2).getReg(),
745 getKillRegState(MI.getOperand(2).isKill()))
746 .addImm(MI.getOperand(3).getImm()) // 'pred'
747 .addReg(MI.getOperand(4).getReg());
749 MI.eraseFromParent();
754 unsigned Opc = AFI->isThumbFunction() ? ARM::t2MOVr : ARM::MOVr;
755 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(Opc),
756 MI.getOperand(1).getReg())
757 .addReg(MI.getOperand(2).getReg(),
758 getKillRegState(MI.getOperand(2).isKill()))
759 .addImm(MI.getOperand(3).getImm()) // 'pred'
760 .addReg(MI.getOperand(4).getReg())
761 .addReg(0); // 's' bit
763 MI.eraseFromParent();
767 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVsi),
768 (MI.getOperand(1).getReg()))
769 .addReg(MI.getOperand(2).getReg(),
770 getKillRegState(MI.getOperand(2).isKill()))
771 .addImm(MI.getOperand(3).getImm())
772 .addImm(MI.getOperand(4).getImm()) // 'pred'
773 .addReg(MI.getOperand(5).getReg())
774 .addReg(0); // 's' bit
776 MI.eraseFromParent();
781 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVsr),
782 (MI.getOperand(1).getReg()))
783 .addReg(MI.getOperand(2).getReg(),
784 getKillRegState(MI.getOperand(2).isKill()))
785 .addReg(MI.getOperand(3).getReg(),
786 getKillRegState(MI.getOperand(3).isKill()))
787 .addImm(MI.getOperand(4).getImm())
788 .addImm(MI.getOperand(5).getImm()) // 'pred'
789 .addReg(MI.getOperand(6).getReg())
790 .addReg(0); // 's' bit
792 MI.eraseFromParent();
795 case ARM::MOVCCi16: {
796 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVi16),
797 MI.getOperand(1).getReg())
798 .addImm(MI.getOperand(2).getImm())
799 .addImm(MI.getOperand(3).getImm()) // 'pred'
800 .addReg(MI.getOperand(4).getReg());
802 MI.eraseFromParent();
807 unsigned Opc = AFI->isThumbFunction() ? ARM::t2MOVi : ARM::MOVi;
808 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(Opc),
809 MI.getOperand(1).getReg())
810 .addImm(MI.getOperand(2).getImm())
811 .addImm(MI.getOperand(3).getImm()) // 'pred'
812 .addReg(MI.getOperand(4).getReg())
813 .addReg(0); // 's' bit
815 MI.eraseFromParent();
819 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MVNi),
820 MI.getOperand(1).getReg())
821 .addImm(MI.getOperand(2).getImm())
822 .addImm(MI.getOperand(3).getImm()) // 'pred'
823 .addReg(MI.getOperand(4).getReg())
824 .addReg(0); // 's' bit
826 MI.eraseFromParent();
829 case ARM::eh_sjlj_dispatchsetup: {
830 MachineFunction &MF = *MI.getParent()->getParent();
831 const ARMBaseInstrInfo *AII =
832 static_cast<const ARMBaseInstrInfo*>(TII);
833 const ARMBaseRegisterInfo &RI = AII->getRegisterInfo();
834 // For functions using a base pointer, we rematerialize it (via the frame
835 // pointer) here since eh.sjlj.setjmp and eh.sjlj.longjmp don't do it
836 // for us. Otherwise, expand to nothing.
837 if (RI.hasBasePointer(MF)) {
838 int32_t NumBytes = AFI->getFramePtrSpillOffset();
839 unsigned FramePtr = RI.getFrameRegister(MF);
840 assert(MF.getTarget().getFrameLowering()->hasFP(MF) &&
841 "base pointer without frame pointer?");
843 if (AFI->isThumb2Function()) {
844 llvm::emitT2RegPlusImmediate(MBB, MBBI, MI.getDebugLoc(), ARM::R6,
845 FramePtr, -NumBytes, ARMCC::AL, 0, *TII);
846 } else if (AFI->isThumbFunction()) {
847 llvm::emitThumbRegPlusImmediate(MBB, MBBI, MI.getDebugLoc(), ARM::R6,
848 FramePtr, -NumBytes, *TII, RI);
850 llvm::emitARMRegPlusImmediate(MBB, MBBI, MI.getDebugLoc(), ARM::R6,
851 FramePtr, -NumBytes, ARMCC::AL, 0,
854 // If there's dynamic realignment, adjust for it.
855 if (RI.needsStackRealignment(MF)) {
856 MachineFrameInfo *MFI = MF.getFrameInfo();
857 unsigned MaxAlign = MFI->getMaxAlignment();
858 assert (!AFI->isThumb1OnlyFunction());
859 // Emit bic r6, r6, MaxAlign
860 unsigned bicOpc = AFI->isThumbFunction() ?
861 ARM::t2BICri : ARM::BICri;
862 AddDefaultCC(AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(),
863 TII->get(bicOpc), ARM::R6)
864 .addReg(ARM::R6, RegState::Kill)
865 .addImm(MaxAlign-1)));
869 MI.eraseFromParent();
873 case ARM::MOVsrl_flag:
874 case ARM::MOVsra_flag: {
875 // These are just fancy MOVs insructions.
876 AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVsi),
877 MI.getOperand(0).getReg())
878 .addOperand(MI.getOperand(1))
879 .addImm(ARM_AM::getSORegOpc((Opcode == ARM::MOVsrl_flag ?
880 ARM_AM::lsr : ARM_AM::asr),
882 .addReg(ARM::CPSR, RegState::Define);
883 MI.eraseFromParent();
887 // This encodes as "MOVs Rd, Rm, rrx
888 MachineInstrBuilder MIB =
889 AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(),TII->get(ARM::MOVsi),
890 MI.getOperand(0).getReg())
891 .addOperand(MI.getOperand(1))
892 .addImm(ARM_AM::getSORegOpc(ARM_AM::rrx, 0)))
894 TransferImpOps(MI, MIB, MIB);
895 MI.eraseFromParent();
900 MachineInstrBuilder MIB =
901 BuildMI(MBB, MBBI, MI.getDebugLoc(),
902 TII->get(Opcode == ARM::tTPsoft ? ARM::tBL : ARM::BL))
903 .addExternalSymbol("__aeabi_read_tp", 0);
905 MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
906 TransferImpOps(MI, MIB, MIB);
907 MI.eraseFromParent();
910 case ARM::tLDRpci_pic:
911 case ARM::t2LDRpci_pic: {
912 unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic)
913 ? ARM::tLDRpci : ARM::t2LDRpci;
914 unsigned DstReg = MI.getOperand(0).getReg();
915 bool DstIsDead = MI.getOperand(0).isDead();
916 MachineInstrBuilder MIB1 =
917 AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(),
918 TII->get(NewLdOpc), DstReg)
919 .addOperand(MI.getOperand(1)));
920 MIB1->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
921 MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
922 TII->get(ARM::tPICADD))
923 .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
925 .addOperand(MI.getOperand(2));
926 TransferImpOps(MI, MIB1, MIB2);
927 MI.eraseFromParent();
931 case ARM::MOV_ga_dyn:
932 case ARM::MOV_ga_pcrel:
933 case ARM::MOV_ga_pcrel_ldr:
934 case ARM::t2MOV_ga_dyn:
935 case ARM::t2MOV_ga_pcrel: {
936 // Expand into movw + movw. Also "add pc" / ldr [pc] in PIC mode.
937 unsigned LabelId = AFI->createPICLabelUId();
938 unsigned DstReg = MI.getOperand(0).getReg();
939 bool DstIsDead = MI.getOperand(0).isDead();
940 const MachineOperand &MO1 = MI.getOperand(1);
941 const GlobalValue *GV = MO1.getGlobal();
942 unsigned TF = MO1.getTargetFlags();
943 bool isARM = (Opcode != ARM::t2MOV_ga_pcrel && Opcode!=ARM::t2MOV_ga_dyn);
944 bool isPIC = (Opcode != ARM::MOV_ga_dyn && Opcode != ARM::t2MOV_ga_dyn);
945 unsigned LO16Opc = isARM ? ARM::MOVi16_ga_pcrel : ARM::t2MOVi16_ga_pcrel;
946 unsigned HI16Opc = isARM ? ARM::MOVTi16_ga_pcrel :ARM::t2MOVTi16_ga_pcrel;
947 unsigned LO16TF = isPIC
948 ? ARMII::MO_LO16_NONLAZY_PIC : ARMII::MO_LO16_NONLAZY;
949 unsigned HI16TF = isPIC
950 ? ARMII::MO_HI16_NONLAZY_PIC : ARMII::MO_HI16_NONLAZY;
951 unsigned PICAddOpc = isARM
952 ? (Opcode == ARM::MOV_ga_pcrel_ldr ? ARM::PICLDR : ARM::PICADD)
954 MachineInstrBuilder MIB1 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
955 TII->get(LO16Opc), DstReg)
956 .addGlobalAddress(GV, MO1.getOffset(), TF | LO16TF)
958 MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
959 TII->get(HI16Opc), DstReg)
961 .addGlobalAddress(GV, MO1.getOffset(), TF | HI16TF)
964 TransferImpOps(MI, MIB1, MIB2);
965 MI.eraseFromParent();
969 MachineInstrBuilder MIB3 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
971 .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
972 .addReg(DstReg).addImm(LabelId);
974 AddDefaultPred(MIB3);
975 if (Opcode == ARM::MOV_ga_pcrel_ldr)
976 MIB2->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
978 TransferImpOps(MI, MIB1, MIB3);
979 MI.eraseFromParent();
984 case ARM::MOVCCi32imm:
985 case ARM::t2MOVi32imm:
986 case ARM::t2MOVCCi32imm:
987 ExpandMOV32BitImm(MBB, MBBI);
991 unsigned NewOpc = ARM::VLDMDIA;
992 MachineInstrBuilder MIB =
993 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewOpc));
996 // Grab the Q register destination.
997 bool DstIsDead = MI.getOperand(OpIdx).isDead();
998 unsigned DstReg = MI.getOperand(OpIdx++).getReg();
1000 // Copy the source register.
1001 MIB.addOperand(MI.getOperand(OpIdx++));
1003 // Copy the predicate operands.
1004 MIB.addOperand(MI.getOperand(OpIdx++));
1005 MIB.addOperand(MI.getOperand(OpIdx++));
1007 // Add the destination operands (D subregs).
1008 unsigned D0 = TRI->getSubReg(DstReg, ARM::dsub_0);
1009 unsigned D1 = TRI->getSubReg(DstReg, ARM::dsub_1);
1010 MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead))
1011 .addReg(D1, RegState::Define | getDeadRegState(DstIsDead));
1013 // Add an implicit def for the super-register.
1014 MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead));
1015 TransferImpOps(MI, MIB, MIB);
1016 MI.eraseFromParent();
1020 case ARM::VSTMQIA: {
1021 unsigned NewOpc = ARM::VSTMDIA;
1022 MachineInstrBuilder MIB =
1023 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewOpc));
1026 // Grab the Q register source.
1027 bool SrcIsKill = MI.getOperand(OpIdx).isKill();
1028 unsigned SrcReg = MI.getOperand(OpIdx++).getReg();
1030 // Copy the destination register.
1031 MIB.addOperand(MI.getOperand(OpIdx++));
1033 // Copy the predicate operands.
1034 MIB.addOperand(MI.getOperand(OpIdx++));
1035 MIB.addOperand(MI.getOperand(OpIdx++));
1037 // Add the source operands (D subregs).
1038 unsigned D0 = TRI->getSubReg(SrcReg, ARM::dsub_0);
1039 unsigned D1 = TRI->getSubReg(SrcReg, ARM::dsub_1);
1040 MIB.addReg(D0).addReg(D1);
1042 if (SrcIsKill) // Add an implicit kill for the Q register.
1043 MIB->addRegisterKilled(SrcReg, TRI, true);
1045 TransferImpOps(MI, MIB, MIB);
1046 MI.eraseFromParent();
1051 unsigned NewOpc = Opcode == ARM::VDUPfqf ? ARM::VDUPLN32q :
1053 MachineInstrBuilder MIB =
1054 BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewOpc));
1056 unsigned SrcReg = MI.getOperand(1).getReg();
1057 unsigned Lane = getARMRegisterNumbering(SrcReg) & 1;
1058 unsigned DReg = TRI->getMatchingSuperReg(SrcReg,
1059 Lane & 1 ? ARM::ssub_1 : ARM::ssub_0,
1060 &ARM::DPR_VFP2RegClass);
1061 // The lane is [0,1] for the containing DReg superregister.
1062 // Copy the dst/src register operands.
1063 MIB.addOperand(MI.getOperand(OpIdx++));
1066 // Add the lane select operand.
1068 // Add the predicate operands.
1069 MIB.addOperand(MI.getOperand(OpIdx++));
1070 MIB.addOperand(MI.getOperand(OpIdx++));
1072 TransferImpOps(MI, MIB, MIB);
1073 MI.eraseFromParent();
1077 case ARM::VLD1q8Pseudo:
1078 case ARM::VLD1q16Pseudo:
1079 case ARM::VLD1q32Pseudo:
1080 case ARM::VLD1q64Pseudo:
1081 case ARM::VLD1q8PseudoWB_register:
1082 case ARM::VLD1q16PseudoWB_register:
1083 case ARM::VLD1q32PseudoWB_register:
1084 case ARM::VLD1q64PseudoWB_register:
1085 case ARM::VLD1q8PseudoWB_fixed:
1086 case ARM::VLD1q16PseudoWB_fixed:
1087 case ARM::VLD1q32PseudoWB_fixed:
1088 case ARM::VLD1q64PseudoWB_fixed:
1089 case ARM::VLD2d8Pseudo:
1090 case ARM::VLD2d16Pseudo:
1091 case ARM::VLD2d32Pseudo:
1092 case ARM::VLD2q8Pseudo:
1093 case ARM::VLD2q16Pseudo:
1094 case ARM::VLD2q32Pseudo:
1095 case ARM::VLD2d8Pseudo_UPD:
1096 case ARM::VLD2d16Pseudo_UPD:
1097 case ARM::VLD2d32Pseudo_UPD:
1098 case ARM::VLD2q8Pseudo_UPD:
1099 case ARM::VLD2q16Pseudo_UPD:
1100 case ARM::VLD2q32Pseudo_UPD:
1101 case ARM::VLD3d8Pseudo:
1102 case ARM::VLD3d16Pseudo:
1103 case ARM::VLD3d32Pseudo:
1104 case ARM::VLD1d64TPseudo:
1105 case ARM::VLD3d8Pseudo_UPD:
1106 case ARM::VLD3d16Pseudo_UPD:
1107 case ARM::VLD3d32Pseudo_UPD:
1108 case ARM::VLD3q8Pseudo_UPD:
1109 case ARM::VLD3q16Pseudo_UPD:
1110 case ARM::VLD3q32Pseudo_UPD:
1111 case ARM::VLD3q8oddPseudo:
1112 case ARM::VLD3q16oddPseudo:
1113 case ARM::VLD3q32oddPseudo:
1114 case ARM::VLD3q8oddPseudo_UPD:
1115 case ARM::VLD3q16oddPseudo_UPD:
1116 case ARM::VLD3q32oddPseudo_UPD:
1117 case ARM::VLD4d8Pseudo:
1118 case ARM::VLD4d16Pseudo:
1119 case ARM::VLD4d32Pseudo:
1120 case ARM::VLD1d64QPseudo:
1121 case ARM::VLD4d8Pseudo_UPD:
1122 case ARM::VLD4d16Pseudo_UPD:
1123 case ARM::VLD4d32Pseudo_UPD:
1124 case ARM::VLD4q8Pseudo_UPD:
1125 case ARM::VLD4q16Pseudo_UPD:
1126 case ARM::VLD4q32Pseudo_UPD:
1127 case ARM::VLD4q8oddPseudo:
1128 case ARM::VLD4q16oddPseudo:
1129 case ARM::VLD4q32oddPseudo:
1130 case ARM::VLD4q8oddPseudo_UPD:
1131 case ARM::VLD4q16oddPseudo_UPD:
1132 case ARM::VLD4q32oddPseudo_UPD:
1133 case ARM::VLD1DUPq8Pseudo:
1134 case ARM::VLD1DUPq16Pseudo:
1135 case ARM::VLD1DUPq32Pseudo:
1136 case ARM::VLD1DUPq8Pseudo_UPD:
1137 case ARM::VLD1DUPq16Pseudo_UPD:
1138 case ARM::VLD1DUPq32Pseudo_UPD:
1139 case ARM::VLD2DUPd8Pseudo:
1140 case ARM::VLD2DUPd16Pseudo:
1141 case ARM::VLD2DUPd32Pseudo:
1142 case ARM::VLD2DUPd8Pseudo_UPD:
1143 case ARM::VLD2DUPd16Pseudo_UPD:
1144 case ARM::VLD2DUPd32Pseudo_UPD:
1145 case ARM::VLD3DUPd8Pseudo:
1146 case ARM::VLD3DUPd16Pseudo:
1147 case ARM::VLD3DUPd32Pseudo:
1148 case ARM::VLD3DUPd8Pseudo_UPD:
1149 case ARM::VLD3DUPd16Pseudo_UPD:
1150 case ARM::VLD3DUPd32Pseudo_UPD:
1151 case ARM::VLD4DUPd8Pseudo:
1152 case ARM::VLD4DUPd16Pseudo:
1153 case ARM::VLD4DUPd32Pseudo:
1154 case ARM::VLD4DUPd8Pseudo_UPD:
1155 case ARM::VLD4DUPd16Pseudo_UPD:
1156 case ARM::VLD4DUPd32Pseudo_UPD:
1160 case ARM::VST1q8Pseudo:
1161 case ARM::VST1q16Pseudo:
1162 case ARM::VST1q32Pseudo:
1163 case ARM::VST1q64Pseudo:
1164 case ARM::VST1q8PseudoWB_fixed:
1165 case ARM::VST1q16PseudoWB_fixed:
1166 case ARM::VST1q32PseudoWB_fixed:
1167 case ARM::VST1q64PseudoWB_fixed:
1168 case ARM::VST1q8PseudoWB_register:
1169 case ARM::VST1q16PseudoWB_register:
1170 case ARM::VST1q32PseudoWB_register:
1171 case ARM::VST1q64PseudoWB_register:
1172 case ARM::VST2d8Pseudo:
1173 case ARM::VST2d16Pseudo:
1174 case ARM::VST2d32Pseudo:
1175 case ARM::VST2q8Pseudo:
1176 case ARM::VST2q16Pseudo:
1177 case ARM::VST2q32Pseudo:
1178 case ARM::VST2d8Pseudo_UPD:
1179 case ARM::VST2d16Pseudo_UPD:
1180 case ARM::VST2d32Pseudo_UPD:
1181 case ARM::VST2q8Pseudo_UPD:
1182 case ARM::VST2q16Pseudo_UPD:
1183 case ARM::VST2q32Pseudo_UPD:
1184 case ARM::VST3d8Pseudo:
1185 case ARM::VST3d16Pseudo:
1186 case ARM::VST3d32Pseudo:
1187 case ARM::VST1d64TPseudo:
1188 case ARM::VST3d8Pseudo_UPD:
1189 case ARM::VST3d16Pseudo_UPD:
1190 case ARM::VST3d32Pseudo_UPD:
1191 case ARM::VST1d64TPseudoWB_fixed:
1192 case ARM::VST1d64TPseudoWB_register:
1193 case ARM::VST3q8Pseudo_UPD:
1194 case ARM::VST3q16Pseudo_UPD:
1195 case ARM::VST3q32Pseudo_UPD:
1196 case ARM::VST3q8oddPseudo:
1197 case ARM::VST3q16oddPseudo:
1198 case ARM::VST3q32oddPseudo:
1199 case ARM::VST3q8oddPseudo_UPD:
1200 case ARM::VST3q16oddPseudo_UPD:
1201 case ARM::VST3q32oddPseudo_UPD:
1202 case ARM::VST4d8Pseudo:
1203 case ARM::VST4d16Pseudo:
1204 case ARM::VST4d32Pseudo:
1205 case ARM::VST1d64QPseudo:
1206 case ARM::VST4d8Pseudo_UPD:
1207 case ARM::VST4d16Pseudo_UPD:
1208 case ARM::VST4d32Pseudo_UPD:
1209 case ARM::VST1d64QPseudoWB_fixed:
1210 case ARM::VST1d64QPseudoWB_register:
1211 case ARM::VST4q8Pseudo_UPD:
1212 case ARM::VST4q16Pseudo_UPD:
1213 case ARM::VST4q32Pseudo_UPD:
1214 case ARM::VST4q8oddPseudo:
1215 case ARM::VST4q16oddPseudo:
1216 case ARM::VST4q32oddPseudo:
1217 case ARM::VST4q8oddPseudo_UPD:
1218 case ARM::VST4q16oddPseudo_UPD:
1219 case ARM::VST4q32oddPseudo_UPD:
1223 case ARM::VLD1LNq8Pseudo:
1224 case ARM::VLD1LNq16Pseudo:
1225 case ARM::VLD1LNq32Pseudo:
1226 case ARM::VLD1LNq8Pseudo_UPD:
1227 case ARM::VLD1LNq16Pseudo_UPD:
1228 case ARM::VLD1LNq32Pseudo_UPD:
1229 case ARM::VLD2LNd8Pseudo:
1230 case ARM::VLD2LNd16Pseudo:
1231 case ARM::VLD2LNd32Pseudo:
1232 case ARM::VLD2LNq16Pseudo:
1233 case ARM::VLD2LNq32Pseudo:
1234 case ARM::VLD2LNd8Pseudo_UPD:
1235 case ARM::VLD2LNd16Pseudo_UPD:
1236 case ARM::VLD2LNd32Pseudo_UPD:
1237 case ARM::VLD2LNq16Pseudo_UPD:
1238 case ARM::VLD2LNq32Pseudo_UPD:
1239 case ARM::VLD3LNd8Pseudo:
1240 case ARM::VLD3LNd16Pseudo:
1241 case ARM::VLD3LNd32Pseudo:
1242 case ARM::VLD3LNq16Pseudo:
1243 case ARM::VLD3LNq32Pseudo:
1244 case ARM::VLD3LNd8Pseudo_UPD:
1245 case ARM::VLD3LNd16Pseudo_UPD:
1246 case ARM::VLD3LNd32Pseudo_UPD:
1247 case ARM::VLD3LNq16Pseudo_UPD:
1248 case ARM::VLD3LNq32Pseudo_UPD:
1249 case ARM::VLD4LNd8Pseudo:
1250 case ARM::VLD4LNd16Pseudo:
1251 case ARM::VLD4LNd32Pseudo:
1252 case ARM::VLD4LNq16Pseudo:
1253 case ARM::VLD4LNq32Pseudo:
1254 case ARM::VLD4LNd8Pseudo_UPD:
1255 case ARM::VLD4LNd16Pseudo_UPD:
1256 case ARM::VLD4LNd32Pseudo_UPD:
1257 case ARM::VLD4LNq16Pseudo_UPD:
1258 case ARM::VLD4LNq32Pseudo_UPD:
1259 case ARM::VST1LNq8Pseudo:
1260 case ARM::VST1LNq16Pseudo:
1261 case ARM::VST1LNq32Pseudo:
1262 case ARM::VST1LNq8Pseudo_UPD:
1263 case ARM::VST1LNq16Pseudo_UPD:
1264 case ARM::VST1LNq32Pseudo_UPD:
1265 case ARM::VST2LNd8Pseudo:
1266 case ARM::VST2LNd16Pseudo:
1267 case ARM::VST2LNd32Pseudo:
1268 case ARM::VST2LNq16Pseudo:
1269 case ARM::VST2LNq32Pseudo:
1270 case ARM::VST2LNd8Pseudo_UPD:
1271 case ARM::VST2LNd16Pseudo_UPD:
1272 case ARM::VST2LNd32Pseudo_UPD:
1273 case ARM::VST2LNq16Pseudo_UPD:
1274 case ARM::VST2LNq32Pseudo_UPD:
1275 case ARM::VST3LNd8Pseudo:
1276 case ARM::VST3LNd16Pseudo:
1277 case ARM::VST3LNd32Pseudo:
1278 case ARM::VST3LNq16Pseudo:
1279 case ARM::VST3LNq32Pseudo:
1280 case ARM::VST3LNd8Pseudo_UPD:
1281 case ARM::VST3LNd16Pseudo_UPD:
1282 case ARM::VST3LNd32Pseudo_UPD:
1283 case ARM::VST3LNq16Pseudo_UPD:
1284 case ARM::VST3LNq32Pseudo_UPD:
1285 case ARM::VST4LNd8Pseudo:
1286 case ARM::VST4LNd16Pseudo:
1287 case ARM::VST4LNd32Pseudo:
1288 case ARM::VST4LNq16Pseudo:
1289 case ARM::VST4LNq32Pseudo:
1290 case ARM::VST4LNd8Pseudo_UPD:
1291 case ARM::VST4LNd16Pseudo_UPD:
1292 case ARM::VST4LNd32Pseudo_UPD:
1293 case ARM::VST4LNq16Pseudo_UPD:
1294 case ARM::VST4LNq32Pseudo_UPD:
1298 case ARM::VTBL2Pseudo: ExpandVTBL(MBBI, ARM::VTBL2, false, 2); return true;
1299 case ARM::VTBL3Pseudo: ExpandVTBL(MBBI, ARM::VTBL3, false, 3); return true;
1300 case ARM::VTBL4Pseudo: ExpandVTBL(MBBI, ARM::VTBL4, false, 4); return true;
1301 case ARM::VTBX2Pseudo: ExpandVTBL(MBBI, ARM::VTBX2, true, 2); return true;
1302 case ARM::VTBX3Pseudo: ExpandVTBL(MBBI, ARM::VTBX3, true, 3); return true;
1303 case ARM::VTBX4Pseudo: ExpandVTBL(MBBI, ARM::VTBX4, true, 4); return true;
1309 bool ARMExpandPseudo::ExpandMBB(MachineBasicBlock &MBB) {
1310 bool Modified = false;
1312 MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end();
1314 MachineBasicBlock::iterator NMBBI = llvm::next(MBBI);
1315 Modified |= ExpandMI(MBB, MBBI);
1322 bool ARMExpandPseudo::runOnMachineFunction(MachineFunction &MF) {
1323 const TargetMachine &TM = MF.getTarget();
1324 TII = static_cast<const ARMBaseInstrInfo*>(TM.getInstrInfo());
1325 TRI = TM.getRegisterInfo();
1326 STI = &TM.getSubtarget<ARMSubtarget>();
1327 AFI = MF.getInfo<ARMFunctionInfo>();
1329 bool Modified = false;
1330 for (MachineFunction::iterator MFI = MF.begin(), E = MF.end(); MFI != E;
1332 Modified |= ExpandMBB(*MFI);
1333 if (VerifyARMPseudo)
1334 MF.verify(this, "After expanding ARM pseudo instructions.");
1338 /// createARMExpandPseudoPass - returns an instance of the pseudo instruction
1340 FunctionPass *llvm::createARMExpandPseudoPass() {
1341 return new ARMExpandPseudo();