Remove unused variables
[oota-llvm.git] / lib / Target / ARM / ARMExpandPseudoInsts.cpp
1 //===-- ARMExpandPseudoInsts.cpp - Expand pseudo instructions -----*- 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 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.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #define DEBUG_TYPE "arm-pseudo"
18 #include "ARM.h"
19 #include "ARMAddressingModes.h"
20 #include "ARMBaseInstrInfo.h"
21 #include "ARMBaseRegisterInfo.h"
22 #include "ARMMachineFunctionInfo.h"
23 #include "ARMRegisterInfo.h"
24 #include "llvm/CodeGen/MachineFrameInfo.h"
25 #include "llvm/CodeGen/MachineFunctionPass.h"
26 #include "llvm/CodeGen/MachineInstrBuilder.h"
27 #include "llvm/Target/TargetFrameInfo.h"
28 #include "llvm/Target/TargetRegisterInfo.h"
29 #include "llvm/Support/raw_ostream.h" // FIXME: for debug only. remove!
30 using namespace llvm;
31
32 namespace {
33   class ARMExpandPseudo : public MachineFunctionPass {
34   public:
35     static char ID;
36     ARMExpandPseudo() : MachineFunctionPass(ID) {}
37
38     const ARMBaseInstrInfo *TII;
39     const TargetRegisterInfo *TRI;
40     const ARMSubtarget *STI;
41
42     virtual bool runOnMachineFunction(MachineFunction &Fn);
43
44     virtual const char *getPassName() const {
45       return "ARM pseudo instruction expansion pass";
46     }
47
48   private:
49     void TransferImpOps(MachineInstr &OldMI,
50                         MachineInstrBuilder &UseMI, MachineInstrBuilder &DefMI);
51     bool ExpandMBB(MachineBasicBlock &MBB);
52     void ExpandVLD(MachineBasicBlock::iterator &MBBI);
53     void ExpandVST(MachineBasicBlock::iterator &MBBI);
54     void ExpandLaneOp(MachineBasicBlock::iterator &MBBI);
55     void ExpandVTBL(MachineBasicBlock::iterator &MBBI,
56                     unsigned Opc, bool IsExt, unsigned NumRegs);
57   };
58   char ARMExpandPseudo::ID = 0;
59 }
60
61 /// TransferImpOps - Transfer implicit operands on the pseudo instruction to
62 /// the instructions created from the expansion.
63 void ARMExpandPseudo::TransferImpOps(MachineInstr &OldMI,
64                                      MachineInstrBuilder &UseMI,
65                                      MachineInstrBuilder &DefMI) {
66   const TargetInstrDesc &Desc = OldMI.getDesc();
67   for (unsigned i = Desc.getNumOperands(), e = OldMI.getNumOperands();
68        i != e; ++i) {
69     const MachineOperand &MO = OldMI.getOperand(i);
70     assert(MO.isReg() && MO.getReg());
71     if (MO.isUse())
72       UseMI.addOperand(MO);
73     else
74       DefMI.addOperand(MO);
75   }
76 }
77
78 namespace {
79   // Constants for register spacing in NEON load/store instructions.
80   // For quad-register load-lane and store-lane pseudo instructors, the
81   // spacing is initially assumed to be EvenDblSpc, and that is changed to
82   // OddDblSpc depending on the lane number operand.
83   enum NEONRegSpacing {
84     SingleSpc,
85     EvenDblSpc,
86     OddDblSpc
87   };
88
89   // Entries for NEON load/store information table.  The table is sorted by
90   // PseudoOpc for fast binary-search lookups.
91   struct NEONLdStTableEntry {
92     unsigned PseudoOpc;
93     unsigned RealOpc;
94     bool IsLoad;
95     bool HasWriteBack;
96     NEONRegSpacing RegSpacing;
97     unsigned char NumRegs; // D registers loaded or stored
98     unsigned char RegElts; // elements per D register; used for lane ops
99
100     // Comparison methods for binary search of the table.
101     bool operator<(const NEONLdStTableEntry &TE) const {
102       return PseudoOpc < TE.PseudoOpc;
103     }
104     friend bool operator<(const NEONLdStTableEntry &TE, unsigned PseudoOpc) {
105       return TE.PseudoOpc < PseudoOpc;
106     }
107     friend bool LLVM_ATTRIBUTE_UNUSED operator<(unsigned PseudoOpc,
108                                                 const NEONLdStTableEntry &TE) {
109       return PseudoOpc < TE.PseudoOpc;
110     }
111   };
112 }
113
114 static const NEONLdStTableEntry NEONLdStTable[] = {
115 { ARM::VLD1DUPq16Pseudo,     ARM::VLD1DUPq16,     true, false, SingleSpc, 2, 4},
116 { ARM::VLD1DUPq16Pseudo_UPD, ARM::VLD1DUPq16_UPD, true, true,  SingleSpc, 2, 4},
117 { ARM::VLD1DUPq32Pseudo,     ARM::VLD1DUPq32,     true, false, SingleSpc, 2, 2},
118 { ARM::VLD1DUPq32Pseudo_UPD, ARM::VLD1DUPq32_UPD, true, true,  SingleSpc, 2, 2},
119 { ARM::VLD1DUPq8Pseudo,      ARM::VLD1DUPq8,      true, false, SingleSpc, 2, 8},
120 { ARM::VLD1DUPq8Pseudo_UPD,  ARM::VLD1DUPq8_UPD,  true, true,  SingleSpc, 2, 8},
121
122 { ARM::VLD1LNq16Pseudo,     ARM::VLD1LNd16,     true, false, EvenDblSpc, 1, 4 },
123 { ARM::VLD1LNq16Pseudo_UPD, ARM::VLD1LNd16_UPD, true, true,  EvenDblSpc, 1, 4 },
124 { ARM::VLD1LNq32Pseudo,     ARM::VLD1LNd32,     true, false, EvenDblSpc, 1, 2 },
125 { ARM::VLD1LNq32Pseudo_UPD, ARM::VLD1LNd32_UPD, true, true,  EvenDblSpc, 1, 2 },
126 { ARM::VLD1LNq8Pseudo,      ARM::VLD1LNd8,      true, false, EvenDblSpc, 1, 8 },
127 { ARM::VLD1LNq8Pseudo_UPD,  ARM::VLD1LNd8_UPD,  true, true,  EvenDblSpc, 1, 8 },
128
129 { ARM::VLD1d64QPseudo,      ARM::VLD1d64Q,     true,  false, SingleSpc,  4, 1 },
130 { ARM::VLD1d64QPseudo_UPD,  ARM::VLD1d64Q_UPD, true,  true,  SingleSpc,  4, 1 },
131 { ARM::VLD1d64TPseudo,      ARM::VLD1d64T,     true,  false, SingleSpc,  3, 1 },
132 { ARM::VLD1d64TPseudo_UPD,  ARM::VLD1d64T_UPD, true,  true,  SingleSpc,  3, 1 },
133
134 { ARM::VLD1q16Pseudo,       ARM::VLD1q16,      true,  false, SingleSpc,  2, 4 },
135 { ARM::VLD1q16Pseudo_UPD,   ARM::VLD1q16_UPD,  true,  true,  SingleSpc,  2, 4 },
136 { ARM::VLD1q32Pseudo,       ARM::VLD1q32,      true,  false, SingleSpc,  2, 2 },
137 { ARM::VLD1q32Pseudo_UPD,   ARM::VLD1q32_UPD,  true,  true,  SingleSpc,  2, 2 },
138 { ARM::VLD1q64Pseudo,       ARM::VLD1q64,      true,  false, SingleSpc,  2, 1 },
139 { ARM::VLD1q64Pseudo_UPD,   ARM::VLD1q64_UPD,  true,  true,  SingleSpc,  2, 1 },
140 { ARM::VLD1q8Pseudo,        ARM::VLD1q8,       true,  false, SingleSpc,  2, 8 },
141 { ARM::VLD1q8Pseudo_UPD,    ARM::VLD1q8_UPD,   true,  true,  SingleSpc,  2, 8 },
142
143 { ARM::VLD2DUPd16Pseudo,     ARM::VLD2DUPd16,     true, false, SingleSpc, 2, 4},
144 { ARM::VLD2DUPd16Pseudo_UPD, ARM::VLD2DUPd16_UPD, true, true,  SingleSpc, 2, 4},
145 { ARM::VLD2DUPd32Pseudo,     ARM::VLD2DUPd32,     true, false, SingleSpc, 2, 2},
146 { ARM::VLD2DUPd32Pseudo_UPD, ARM::VLD2DUPd32_UPD, true, true,  SingleSpc, 2, 2},
147 { ARM::VLD2DUPd8Pseudo,      ARM::VLD2DUPd8,      true, false, SingleSpc, 2, 8},
148 { ARM::VLD2DUPd8Pseudo_UPD,  ARM::VLD2DUPd8_UPD,  true, true,  SingleSpc, 2, 8},
149
150 { ARM::VLD2LNd16Pseudo,     ARM::VLD2LNd16,     true, false, SingleSpc,  2, 4 },
151 { ARM::VLD2LNd16Pseudo_UPD, ARM::VLD2LNd16_UPD, true, true,  SingleSpc,  2, 4 },
152 { ARM::VLD2LNd32Pseudo,     ARM::VLD2LNd32,     true, false, SingleSpc,  2, 2 },
153 { ARM::VLD2LNd32Pseudo_UPD, ARM::VLD2LNd32_UPD, true, true,  SingleSpc,  2, 2 },
154 { ARM::VLD2LNd8Pseudo,      ARM::VLD2LNd8,      true, false, SingleSpc,  2, 8 },
155 { ARM::VLD2LNd8Pseudo_UPD,  ARM::VLD2LNd8_UPD,  true, true,  SingleSpc,  2, 8 },
156 { ARM::VLD2LNq16Pseudo,     ARM::VLD2LNq16,     true, false, EvenDblSpc, 2, 4 },
157 { ARM::VLD2LNq16Pseudo_UPD, ARM::VLD2LNq16_UPD, true, true,  EvenDblSpc, 2, 4 },
158 { ARM::VLD2LNq32Pseudo,     ARM::VLD2LNq32,     true, false, EvenDblSpc, 2, 2 },
159 { ARM::VLD2LNq32Pseudo_UPD, ARM::VLD2LNq32_UPD, true, true,  EvenDblSpc, 2, 2 },
160
161 { ARM::VLD2d16Pseudo,       ARM::VLD2d16,      true,  false, SingleSpc,  2, 4 },
162 { ARM::VLD2d16Pseudo_UPD,   ARM::VLD2d16_UPD,  true,  true,  SingleSpc,  2, 4 },
163 { ARM::VLD2d32Pseudo,       ARM::VLD2d32,      true,  false, SingleSpc,  2, 2 },
164 { ARM::VLD2d32Pseudo_UPD,   ARM::VLD2d32_UPD,  true,  true,  SingleSpc,  2, 2 },
165 { ARM::VLD2d8Pseudo,        ARM::VLD2d8,       true,  false, SingleSpc,  2, 8 },
166 { ARM::VLD2d8Pseudo_UPD,    ARM::VLD2d8_UPD,   true,  true,  SingleSpc,  2, 8 },
167
168 { ARM::VLD2q16Pseudo,       ARM::VLD2q16,      true,  false, SingleSpc,  4, 4 },
169 { ARM::VLD2q16Pseudo_UPD,   ARM::VLD2q16_UPD,  true,  true,  SingleSpc,  4, 4 },
170 { ARM::VLD2q32Pseudo,       ARM::VLD2q32,      true,  false, SingleSpc,  4, 2 },
171 { ARM::VLD2q32Pseudo_UPD,   ARM::VLD2q32_UPD,  true,  true,  SingleSpc,  4, 2 },
172 { ARM::VLD2q8Pseudo,        ARM::VLD2q8,       true,  false, SingleSpc,  4, 8 },
173 { ARM::VLD2q8Pseudo_UPD,    ARM::VLD2q8_UPD,   true,  true,  SingleSpc,  4, 8 },
174
175 { ARM::VLD3DUPd16Pseudo,     ARM::VLD3DUPd16,     true, false, SingleSpc, 3, 4},
176 { ARM::VLD3DUPd16Pseudo_UPD, ARM::VLD3DUPd16_UPD, true, true,  SingleSpc, 3, 4},
177 { ARM::VLD3DUPd32Pseudo,     ARM::VLD3DUPd32,     true, false, SingleSpc, 3, 2},
178 { ARM::VLD3DUPd32Pseudo_UPD, ARM::VLD3DUPd32_UPD, true, true,  SingleSpc, 3, 2},
179 { ARM::VLD3DUPd8Pseudo,      ARM::VLD3DUPd8,      true, false, SingleSpc, 3, 8},
180 { ARM::VLD3DUPd8Pseudo_UPD,  ARM::VLD3DUPd8_UPD,  true, true,  SingleSpc, 3, 8},
181
182 { ARM::VLD3LNd16Pseudo,     ARM::VLD3LNd16,     true, false, SingleSpc,  3, 4 },
183 { ARM::VLD3LNd16Pseudo_UPD, ARM::VLD3LNd16_UPD, true, true,  SingleSpc,  3, 4 },
184 { ARM::VLD3LNd32Pseudo,     ARM::VLD3LNd32,     true, false, SingleSpc,  3, 2 },
185 { ARM::VLD3LNd32Pseudo_UPD, ARM::VLD3LNd32_UPD, true, true,  SingleSpc,  3, 2 },
186 { ARM::VLD3LNd8Pseudo,      ARM::VLD3LNd8,      true, false, SingleSpc,  3, 8 },
187 { ARM::VLD3LNd8Pseudo_UPD,  ARM::VLD3LNd8_UPD,  true, true,  SingleSpc,  3, 8 },
188 { ARM::VLD3LNq16Pseudo,     ARM::VLD3LNq16,     true, false, EvenDblSpc, 3, 4 },
189 { ARM::VLD3LNq16Pseudo_UPD, ARM::VLD3LNq16_UPD, true, true,  EvenDblSpc, 3, 4 },
190 { ARM::VLD3LNq32Pseudo,     ARM::VLD3LNq32,     true, false, EvenDblSpc, 3, 2 },
191 { ARM::VLD3LNq32Pseudo_UPD, ARM::VLD3LNq32_UPD, true, true,  EvenDblSpc, 3, 2 },
192
193 { ARM::VLD3d16Pseudo,       ARM::VLD3d16,      true,  false, SingleSpc,  3, 4 },
194 { ARM::VLD3d16Pseudo_UPD,   ARM::VLD3d16_UPD,  true,  true,  SingleSpc,  3, 4 },
195 { ARM::VLD3d32Pseudo,       ARM::VLD3d32,      true,  false, SingleSpc,  3, 2 },
196 { ARM::VLD3d32Pseudo_UPD,   ARM::VLD3d32_UPD,  true,  true,  SingleSpc,  3, 2 },
197 { ARM::VLD3d8Pseudo,        ARM::VLD3d8,       true,  false, SingleSpc,  3, 8 },
198 { ARM::VLD3d8Pseudo_UPD,    ARM::VLD3d8_UPD,   true,  true,  SingleSpc,  3, 8 },
199
200 { ARM::VLD3q16Pseudo_UPD,    ARM::VLD3q16_UPD, true,  true,  EvenDblSpc, 3, 4 },
201 { ARM::VLD3q16oddPseudo_UPD, ARM::VLD3q16_UPD, true,  true,  OddDblSpc,  3, 4 },
202 { ARM::VLD3q32Pseudo_UPD,    ARM::VLD3q32_UPD, true,  true,  EvenDblSpc, 3, 2 },
203 { ARM::VLD3q32oddPseudo_UPD, ARM::VLD3q32_UPD, true,  true,  OddDblSpc,  3, 2 },
204 { ARM::VLD3q8Pseudo_UPD,     ARM::VLD3q8_UPD,  true,  true,  EvenDblSpc, 3, 8 },
205 { ARM::VLD3q8oddPseudo_UPD,  ARM::VLD3q8_UPD,  true,  true,  OddDblSpc,  3, 8 },
206
207 { ARM::VLD4DUPd16Pseudo,     ARM::VLD4DUPd16,     true, false, SingleSpc, 4, 4},
208 { ARM::VLD4DUPd16Pseudo_UPD, ARM::VLD4DUPd16_UPD, true, true,  SingleSpc, 4, 4},
209 { ARM::VLD4DUPd32Pseudo,     ARM::VLD4DUPd32,     true, false, SingleSpc, 4, 2},
210 { ARM::VLD4DUPd32Pseudo_UPD, ARM::VLD4DUPd32_UPD, true, true,  SingleSpc, 4, 2},
211 { ARM::VLD4DUPd8Pseudo,      ARM::VLD4DUPd8,      true, false, SingleSpc, 4, 8},
212 { ARM::VLD4DUPd8Pseudo_UPD,  ARM::VLD4DUPd8_UPD,  true, true,  SingleSpc, 4, 8},
213
214 { ARM::VLD4LNd16Pseudo,     ARM::VLD4LNd16,     true, false, SingleSpc,  4, 4 },
215 { ARM::VLD4LNd16Pseudo_UPD, ARM::VLD4LNd16_UPD, true, true,  SingleSpc,  4, 4 },
216 { ARM::VLD4LNd32Pseudo,     ARM::VLD4LNd32,     true, false, SingleSpc,  4, 2 },
217 { ARM::VLD4LNd32Pseudo_UPD, ARM::VLD4LNd32_UPD, true, true,  SingleSpc,  4, 2 },
218 { ARM::VLD4LNd8Pseudo,      ARM::VLD4LNd8,      true, false, SingleSpc,  4, 8 },
219 { ARM::VLD4LNd8Pseudo_UPD,  ARM::VLD4LNd8_UPD,  true, true,  SingleSpc,  4, 8 },
220 { ARM::VLD4LNq16Pseudo,     ARM::VLD4LNq16,     true, false, EvenDblSpc, 4, 4 },
221 { ARM::VLD4LNq16Pseudo_UPD, ARM::VLD4LNq16_UPD, true, true,  EvenDblSpc, 4, 4 },
222 { ARM::VLD4LNq32Pseudo,     ARM::VLD4LNq32,     true, false, EvenDblSpc, 4, 2 },
223 { ARM::VLD4LNq32Pseudo_UPD, ARM::VLD4LNq32_UPD, true, true,  EvenDblSpc, 4, 2 },
224
225 { ARM::VLD4d16Pseudo,       ARM::VLD4d16,      true,  false, SingleSpc,  4, 4 },
226 { ARM::VLD4d16Pseudo_UPD,   ARM::VLD4d16_UPD,  true,  true,  SingleSpc,  4, 4 },
227 { ARM::VLD4d32Pseudo,       ARM::VLD4d32,      true,  false, SingleSpc,  4, 2 },
228 { ARM::VLD4d32Pseudo_UPD,   ARM::VLD4d32_UPD,  true,  true,  SingleSpc,  4, 2 },
229 { ARM::VLD4d8Pseudo,        ARM::VLD4d8,       true,  false, SingleSpc,  4, 8 },
230 { ARM::VLD4d8Pseudo_UPD,    ARM::VLD4d8_UPD,   true,  true,  SingleSpc,  4, 8 },
231
232 { ARM::VLD4q16Pseudo_UPD,    ARM::VLD4q16_UPD, true,  true,  EvenDblSpc, 4, 4 },
233 { ARM::VLD4q16oddPseudo_UPD, ARM::VLD4q16_UPD, true,  true,  OddDblSpc,  4, 4 },
234 { ARM::VLD4q32Pseudo_UPD,    ARM::VLD4q32_UPD, true,  true,  EvenDblSpc, 4, 2 },
235 { ARM::VLD4q32oddPseudo_UPD, ARM::VLD4q32_UPD, true,  true,  OddDblSpc,  4, 2 },
236 { ARM::VLD4q8Pseudo_UPD,     ARM::VLD4q8_UPD,  true,  true,  EvenDblSpc, 4, 8 },
237 { ARM::VLD4q8oddPseudo_UPD,  ARM::VLD4q8_UPD,  true,  true,  OddDblSpc,  4, 8 },
238
239 { ARM::VST1LNq16Pseudo,     ARM::VST1LNd16,    false, false, EvenDblSpc, 1, 4 },
240 { ARM::VST1LNq16Pseudo_UPD, ARM::VST1LNd16_UPD,false, true,  EvenDblSpc, 1, 4 },
241 { ARM::VST1LNq32Pseudo,     ARM::VST1LNd32,    false, false, EvenDblSpc, 1, 2 },
242 { ARM::VST1LNq32Pseudo_UPD, ARM::VST1LNd32_UPD,false, true,  EvenDblSpc, 1, 2 },
243 { ARM::VST1LNq8Pseudo,      ARM::VST1LNd8,     false, false, EvenDblSpc, 1, 8 },
244 { ARM::VST1LNq8Pseudo_UPD,  ARM::VST1LNd8_UPD, false, true,  EvenDblSpc, 1, 8 },
245
246 { ARM::VST1d64QPseudo,      ARM::VST1d64Q,     false, false, SingleSpc,  4, 1 },
247 { ARM::VST1d64QPseudo_UPD,  ARM::VST1d64Q_UPD, false, true,  SingleSpc,  4, 1 },
248 { ARM::VST1d64TPseudo,      ARM::VST1d64T,     false, false, SingleSpc,  3, 1 },
249 { ARM::VST1d64TPseudo_UPD,  ARM::VST1d64T_UPD, false, true,  SingleSpc,  3, 1 },
250
251 { ARM::VST1q16Pseudo,       ARM::VST1q16,      false, false, SingleSpc,  2, 4 },
252 { ARM::VST1q16Pseudo_UPD,   ARM::VST1q16_UPD,  false, true,  SingleSpc,  2, 4 },
253 { ARM::VST1q32Pseudo,       ARM::VST1q32,      false, false, SingleSpc,  2, 2 },
254 { ARM::VST1q32Pseudo_UPD,   ARM::VST1q32_UPD,  false, true,  SingleSpc,  2, 2 },
255 { ARM::VST1q64Pseudo,       ARM::VST1q64,      false, false, SingleSpc,  2, 1 },
256 { ARM::VST1q64Pseudo_UPD,   ARM::VST1q64_UPD,  false, true,  SingleSpc,  2, 1 },
257 { ARM::VST1q8Pseudo,        ARM::VST1q8,       false, false, SingleSpc,  2, 8 },
258 { ARM::VST1q8Pseudo_UPD,    ARM::VST1q8_UPD,   false, true,  SingleSpc,  2, 8 },
259
260 { ARM::VST2LNd16Pseudo,     ARM::VST2LNd16,     false, false, SingleSpc, 2, 4 },
261 { ARM::VST2LNd16Pseudo_UPD, ARM::VST2LNd16_UPD, false, true,  SingleSpc, 2, 4 },
262 { ARM::VST2LNd32Pseudo,     ARM::VST2LNd32,     false, false, SingleSpc, 2, 2 },
263 { ARM::VST2LNd32Pseudo_UPD, ARM::VST2LNd32_UPD, false, true,  SingleSpc, 2, 2 },
264 { ARM::VST2LNd8Pseudo,      ARM::VST2LNd8,      false, false, SingleSpc, 2, 8 },
265 { ARM::VST2LNd8Pseudo_UPD,  ARM::VST2LNd8_UPD,  false, true,  SingleSpc, 2, 8 },
266 { ARM::VST2LNq16Pseudo,     ARM::VST2LNq16,     false, false, EvenDblSpc, 2, 4},
267 { ARM::VST2LNq16Pseudo_UPD, ARM::VST2LNq16_UPD, false, true,  EvenDblSpc, 2, 4},
268 { ARM::VST2LNq32Pseudo,     ARM::VST2LNq32,     false, false, EvenDblSpc, 2, 2},
269 { ARM::VST2LNq32Pseudo_UPD, ARM::VST2LNq32_UPD, false, true,  EvenDblSpc, 2, 2},
270
271 { ARM::VST2d16Pseudo,       ARM::VST2d16,      false, false, SingleSpc,  2, 4 },
272 { ARM::VST2d16Pseudo_UPD,   ARM::VST2d16_UPD,  false, true,  SingleSpc,  2, 4 },
273 { ARM::VST2d32Pseudo,       ARM::VST2d32,      false, false, SingleSpc,  2, 2 },
274 { ARM::VST2d32Pseudo_UPD,   ARM::VST2d32_UPD,  false, true,  SingleSpc,  2, 2 },
275 { ARM::VST2d8Pseudo,        ARM::VST2d8,       false, false, SingleSpc,  2, 8 },
276 { ARM::VST2d8Pseudo_UPD,    ARM::VST2d8_UPD,   false, true,  SingleSpc,  2, 8 },
277
278 { ARM::VST2q16Pseudo,       ARM::VST2q16,      false, false, SingleSpc,  4, 4 },
279 { ARM::VST2q16Pseudo_UPD,   ARM::VST2q16_UPD,  false, true,  SingleSpc,  4, 4 },
280 { ARM::VST2q32Pseudo,       ARM::VST2q32,      false, false, SingleSpc,  4, 2 },
281 { ARM::VST2q32Pseudo_UPD,   ARM::VST2q32_UPD,  false, true,  SingleSpc,  4, 2 },
282 { ARM::VST2q8Pseudo,        ARM::VST2q8,       false, false, SingleSpc,  4, 8 },
283 { ARM::VST2q8Pseudo_UPD,    ARM::VST2q8_UPD,   false, true,  SingleSpc,  4, 8 },
284
285 { ARM::VST3LNd16Pseudo,     ARM::VST3LNd16,     false, false, SingleSpc, 3, 4 },
286 { ARM::VST3LNd16Pseudo_UPD, ARM::VST3LNd16_UPD, false, true,  SingleSpc, 3, 4 },
287 { ARM::VST3LNd32Pseudo,     ARM::VST3LNd32,     false, false, SingleSpc, 3, 2 },
288 { ARM::VST3LNd32Pseudo_UPD, ARM::VST3LNd32_UPD, false, true,  SingleSpc, 3, 2 },
289 { ARM::VST3LNd8Pseudo,      ARM::VST3LNd8,      false, false, SingleSpc, 3, 8 },
290 { ARM::VST3LNd8Pseudo_UPD,  ARM::VST3LNd8_UPD,  false, true,  SingleSpc, 3, 8 },
291 { ARM::VST3LNq16Pseudo,     ARM::VST3LNq16,     false, false, EvenDblSpc, 3, 4},
292 { ARM::VST3LNq16Pseudo_UPD, ARM::VST3LNq16_UPD, false, true,  EvenDblSpc, 3, 4},
293 { ARM::VST3LNq32Pseudo,     ARM::VST3LNq32,     false, false, EvenDblSpc, 3, 2},
294 { ARM::VST3LNq32Pseudo_UPD, ARM::VST3LNq32_UPD, false, true,  EvenDblSpc, 3, 2},
295
296 { ARM::VST3d16Pseudo,       ARM::VST3d16,      false, false, SingleSpc,  3, 4 },
297 { ARM::VST3d16Pseudo_UPD,   ARM::VST3d16_UPD,  false, true,  SingleSpc,  3, 4 },
298 { ARM::VST3d32Pseudo,       ARM::VST3d32,      false, false, SingleSpc,  3, 2 },
299 { ARM::VST3d32Pseudo_UPD,   ARM::VST3d32_UPD,  false, true,  SingleSpc,  3, 2 },
300 { ARM::VST3d8Pseudo,        ARM::VST3d8,       false, false, SingleSpc,  3, 8 },
301 { ARM::VST3d8Pseudo_UPD,    ARM::VST3d8_UPD,   false, true,  SingleSpc,  3, 8 },
302
303 { ARM::VST3q16Pseudo_UPD,    ARM::VST3q16_UPD, false, true,  EvenDblSpc, 3, 4 },
304 { ARM::VST3q16oddPseudo_UPD, ARM::VST3q16_UPD, false, true,  OddDblSpc,  3, 4 },
305 { ARM::VST3q32Pseudo_UPD,    ARM::VST3q32_UPD, false, true,  EvenDblSpc, 3, 2 },
306 { ARM::VST3q32oddPseudo_UPD, ARM::VST3q32_UPD, false, true,  OddDblSpc,  3, 2 },
307 { ARM::VST3q8Pseudo_UPD,     ARM::VST3q8_UPD,  false, true,  EvenDblSpc, 3, 8 },
308 { ARM::VST3q8oddPseudo_UPD,  ARM::VST3q8_UPD,  false, true,  OddDblSpc,  3, 8 },
309
310 { ARM::VST4LNd16Pseudo,     ARM::VST4LNd16,     false, false, SingleSpc, 4, 4 },
311 { ARM::VST4LNd16Pseudo_UPD, ARM::VST4LNd16_UPD, false, true,  SingleSpc, 4, 4 },
312 { ARM::VST4LNd32Pseudo,     ARM::VST4LNd32,     false, false, SingleSpc, 4, 2 },
313 { ARM::VST4LNd32Pseudo_UPD, ARM::VST4LNd32_UPD, false, true,  SingleSpc, 4, 2 },
314 { ARM::VST4LNd8Pseudo,      ARM::VST4LNd8,      false, false, SingleSpc, 4, 8 },
315 { ARM::VST4LNd8Pseudo_UPD,  ARM::VST4LNd8_UPD,  false, true,  SingleSpc, 4, 8 },
316 { ARM::VST4LNq16Pseudo,     ARM::VST4LNq16,     false, false, EvenDblSpc, 4, 4},
317 { ARM::VST4LNq16Pseudo_UPD, ARM::VST4LNq16_UPD, false, true,  EvenDblSpc, 4, 4},
318 { ARM::VST4LNq32Pseudo,     ARM::VST4LNq32,     false, false, EvenDblSpc, 4, 2},
319 { ARM::VST4LNq32Pseudo_UPD, ARM::VST4LNq32_UPD, false, true,  EvenDblSpc, 4, 2},
320
321 { ARM::VST4d16Pseudo,       ARM::VST4d16,      false, false, SingleSpc,  4, 4 },
322 { ARM::VST4d16Pseudo_UPD,   ARM::VST4d16_UPD,  false, true,  SingleSpc,  4, 4 },
323 { ARM::VST4d32Pseudo,       ARM::VST4d32,      false, false, SingleSpc,  4, 2 },
324 { ARM::VST4d32Pseudo_UPD,   ARM::VST4d32_UPD,  false, true,  SingleSpc,  4, 2 },
325 { ARM::VST4d8Pseudo,        ARM::VST4d8,       false, false, SingleSpc,  4, 8 },
326 { ARM::VST4d8Pseudo_UPD,    ARM::VST4d8_UPD,   false, true,  SingleSpc,  4, 8 },
327
328 { ARM::VST4q16Pseudo_UPD,    ARM::VST4q16_UPD, false, true,  EvenDblSpc, 4, 4 },
329 { ARM::VST4q16oddPseudo_UPD, ARM::VST4q16_UPD, false, true,  OddDblSpc,  4, 4 },
330 { ARM::VST4q32Pseudo_UPD,    ARM::VST4q32_UPD, false, true,  EvenDblSpc, 4, 2 },
331 { ARM::VST4q32oddPseudo_UPD, ARM::VST4q32_UPD, false, true,  OddDblSpc,  4, 2 },
332 { ARM::VST4q8Pseudo_UPD,     ARM::VST4q8_UPD,  false, true,  EvenDblSpc, 4, 8 },
333 { ARM::VST4q8oddPseudo_UPD , ARM::VST4q8_UPD,  false, true,  OddDblSpc,  4, 8 }
334 };
335
336 /// LookupNEONLdSt - Search the NEONLdStTable for information about a NEON
337 /// load or store pseudo instruction.
338 static const NEONLdStTableEntry *LookupNEONLdSt(unsigned Opcode) {
339   unsigned NumEntries = array_lengthof(NEONLdStTable);
340
341 #ifndef NDEBUG
342   // Make sure the table is sorted.
343   static bool TableChecked = false;
344   if (!TableChecked) {
345     for (unsigned i = 0; i != NumEntries-1; ++i)
346       assert(NEONLdStTable[i] < NEONLdStTable[i+1] &&
347              "NEONLdStTable is not sorted!");
348     TableChecked = true;
349   }
350 #endif
351
352   const NEONLdStTableEntry *I =
353     std::lower_bound(NEONLdStTable, NEONLdStTable + NumEntries, Opcode);
354   if (I != NEONLdStTable + NumEntries && I->PseudoOpc == Opcode)
355     return I;
356   return NULL;
357 }
358
359 /// GetDSubRegs - Get 4 D subregisters of a Q, QQ, or QQQQ register,
360 /// corresponding to the specified register spacing.  Not all of the results
361 /// are necessarily valid, e.g., a Q register only has 2 D subregisters.
362 static void GetDSubRegs(unsigned Reg, NEONRegSpacing RegSpc,
363                         const TargetRegisterInfo *TRI, unsigned &D0,
364                         unsigned &D1, unsigned &D2, unsigned &D3) {
365   if (RegSpc == SingleSpc) {
366     D0 = TRI->getSubReg(Reg, ARM::dsub_0);
367     D1 = TRI->getSubReg(Reg, ARM::dsub_1);
368     D2 = TRI->getSubReg(Reg, ARM::dsub_2);
369     D3 = TRI->getSubReg(Reg, ARM::dsub_3);
370   } else if (RegSpc == EvenDblSpc) {
371     D0 = TRI->getSubReg(Reg, ARM::dsub_0);
372     D1 = TRI->getSubReg(Reg, ARM::dsub_2);
373     D2 = TRI->getSubReg(Reg, ARM::dsub_4);
374     D3 = TRI->getSubReg(Reg, ARM::dsub_6);
375   } else {
376     assert(RegSpc == OddDblSpc && "unknown register spacing");
377     D0 = TRI->getSubReg(Reg, ARM::dsub_1);
378     D1 = TRI->getSubReg(Reg, ARM::dsub_3);
379     D2 = TRI->getSubReg(Reg, ARM::dsub_5);
380     D3 = TRI->getSubReg(Reg, ARM::dsub_7);
381   }
382 }
383
384 /// ExpandVLD - Translate VLD pseudo instructions with Q, QQ or QQQQ register
385 /// operands to real VLD instructions with D register operands.
386 void ARMExpandPseudo::ExpandVLD(MachineBasicBlock::iterator &MBBI) {
387   MachineInstr &MI = *MBBI;
388   MachineBasicBlock &MBB = *MI.getParent();
389
390   const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode());
391   assert(TableEntry && TableEntry->IsLoad && "NEONLdStTable lookup failed");
392   NEONRegSpacing RegSpc = TableEntry->RegSpacing;
393   unsigned NumRegs = TableEntry->NumRegs;
394
395   MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
396                                     TII->get(TableEntry->RealOpc));
397   unsigned OpIdx = 0;
398
399   bool DstIsDead = MI.getOperand(OpIdx).isDead();
400   unsigned DstReg = MI.getOperand(OpIdx++).getReg();
401   unsigned D0, D1, D2, D3;
402   GetDSubRegs(DstReg, RegSpc, TRI, D0, D1, D2, D3);
403   MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead))
404     .addReg(D1, RegState::Define | getDeadRegState(DstIsDead));
405   if (NumRegs > 2)
406     MIB.addReg(D2, RegState::Define | getDeadRegState(DstIsDead));
407   if (NumRegs > 3)
408     MIB.addReg(D3, RegState::Define | getDeadRegState(DstIsDead));
409
410   if (TableEntry->HasWriteBack)
411     MIB.addOperand(MI.getOperand(OpIdx++));
412
413   // Copy the addrmode6 operands.
414   MIB.addOperand(MI.getOperand(OpIdx++));
415   MIB.addOperand(MI.getOperand(OpIdx++));
416   // Copy the am6offset operand.
417   if (TableEntry->HasWriteBack)
418     MIB.addOperand(MI.getOperand(OpIdx++));
419
420   // For an instruction writing double-spaced subregs, the pseudo instruction
421   // has an extra operand that is a use of the super-register.  Record the
422   // operand index and skip over it.
423   unsigned SrcOpIdx = 0;
424   if (RegSpc == EvenDblSpc || RegSpc == OddDblSpc)
425     SrcOpIdx = OpIdx++;
426
427   // Copy the predicate operands.
428   MIB.addOperand(MI.getOperand(OpIdx++));
429   MIB.addOperand(MI.getOperand(OpIdx++));
430
431   // Copy the super-register source operand used for double-spaced subregs over
432   // to the new instruction as an implicit operand.
433   if (SrcOpIdx != 0) {
434     MachineOperand MO = MI.getOperand(SrcOpIdx);
435     MO.setImplicit(true);
436     MIB.addOperand(MO);
437   }
438   // Add an implicit def for the super-register.
439   MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead));
440   TransferImpOps(MI, MIB, MIB);
441   MI.eraseFromParent();
442 }
443
444 /// ExpandVST - Translate VST pseudo instructions with Q, QQ or QQQQ register
445 /// operands to real VST instructions with D register operands.
446 void ARMExpandPseudo::ExpandVST(MachineBasicBlock::iterator &MBBI) {
447   MachineInstr &MI = *MBBI;
448   MachineBasicBlock &MBB = *MI.getParent();
449
450   const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode());
451   assert(TableEntry && !TableEntry->IsLoad && "NEONLdStTable lookup failed");
452   NEONRegSpacing RegSpc = TableEntry->RegSpacing;
453   unsigned NumRegs = TableEntry->NumRegs;
454
455   MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
456                                     TII->get(TableEntry->RealOpc));
457   unsigned OpIdx = 0;
458   if (TableEntry->HasWriteBack)
459     MIB.addOperand(MI.getOperand(OpIdx++));
460
461   // Copy the addrmode6 operands.
462   MIB.addOperand(MI.getOperand(OpIdx++));
463   MIB.addOperand(MI.getOperand(OpIdx++));
464   // Copy the am6offset operand.
465   if (TableEntry->HasWriteBack)
466     MIB.addOperand(MI.getOperand(OpIdx++));
467
468   bool SrcIsKill = MI.getOperand(OpIdx).isKill();
469   unsigned SrcReg = MI.getOperand(OpIdx++).getReg();
470   unsigned D0, D1, D2, D3;
471   GetDSubRegs(SrcReg, RegSpc, TRI, D0, D1, D2, D3);
472   MIB.addReg(D0).addReg(D1);
473   if (NumRegs > 2)
474     MIB.addReg(D2);
475   if (NumRegs > 3)
476     MIB.addReg(D3);
477
478   // Copy the predicate operands.
479   MIB.addOperand(MI.getOperand(OpIdx++));
480   MIB.addOperand(MI.getOperand(OpIdx++));
481
482   if (SrcIsKill)
483     // Add an implicit kill for the super-reg.
484     (*MIB).addRegisterKilled(SrcReg, TRI, true);
485   TransferImpOps(MI, MIB, MIB);
486   MI.eraseFromParent();
487 }
488
489 /// ExpandLaneOp - Translate VLD*LN and VST*LN instructions with Q, QQ or QQQQ
490 /// register operands to real instructions with D register operands.
491 void ARMExpandPseudo::ExpandLaneOp(MachineBasicBlock::iterator &MBBI) {
492   MachineInstr &MI = *MBBI;
493   MachineBasicBlock &MBB = *MI.getParent();
494
495   const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode());
496   assert(TableEntry && "NEONLdStTable lookup failed");
497   NEONRegSpacing RegSpc = TableEntry->RegSpacing;
498   unsigned NumRegs = TableEntry->NumRegs;
499   unsigned RegElts = TableEntry->RegElts;
500
501   MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
502                                     TII->get(TableEntry->RealOpc));
503   unsigned OpIdx = 0;
504   // The lane operand is always the 3rd from last operand, before the 2
505   // predicate operands.
506   unsigned Lane = MI.getOperand(MI.getDesc().getNumOperands() - 3).getImm();
507
508   // Adjust the lane and spacing as needed for Q registers.
509   assert(RegSpc != OddDblSpc && "unexpected register spacing for VLD/VST-lane");
510   if (RegSpc == EvenDblSpc && Lane >= RegElts) {
511     RegSpc = OddDblSpc;
512     Lane -= RegElts;
513   }
514   assert(Lane < RegElts && "out of range lane for VLD/VST-lane");
515
516   unsigned D0, D1, D2, D3;
517   unsigned DstReg = 0;
518   bool DstIsDead = false;
519   if (TableEntry->IsLoad) {
520     DstIsDead = MI.getOperand(OpIdx).isDead();
521     DstReg = MI.getOperand(OpIdx++).getReg();
522     GetDSubRegs(DstReg, RegSpc, TRI, D0, D1, D2, D3);
523     MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead));
524     if (NumRegs > 1)
525       MIB.addReg(D1, RegState::Define | getDeadRegState(DstIsDead));
526     if (NumRegs > 2)
527       MIB.addReg(D2, RegState::Define | getDeadRegState(DstIsDead));
528     if (NumRegs > 3)
529       MIB.addReg(D3, RegState::Define | getDeadRegState(DstIsDead));
530   }
531
532   if (TableEntry->HasWriteBack)
533     MIB.addOperand(MI.getOperand(OpIdx++));
534
535   // Copy the addrmode6 operands.
536   MIB.addOperand(MI.getOperand(OpIdx++));
537   MIB.addOperand(MI.getOperand(OpIdx++));
538   // Copy the am6offset operand.
539   if (TableEntry->HasWriteBack)
540     MIB.addOperand(MI.getOperand(OpIdx++));
541
542   // Grab the super-register source.
543   MachineOperand MO = MI.getOperand(OpIdx++);
544   if (!TableEntry->IsLoad)
545     GetDSubRegs(MO.getReg(), RegSpc, TRI, D0, D1, D2, D3);
546
547   // Add the subregs as sources of the new instruction.
548   unsigned SrcFlags = (getUndefRegState(MO.isUndef()) |
549                        getKillRegState(MO.isKill()));
550   MIB.addReg(D0, SrcFlags);
551   if (NumRegs > 1)
552     MIB.addReg(D1, SrcFlags);
553   if (NumRegs > 2)
554     MIB.addReg(D2, SrcFlags);
555   if (NumRegs > 3)
556     MIB.addReg(D3, SrcFlags);
557
558   // Add the lane number operand.
559   MIB.addImm(Lane);
560   OpIdx += 1;
561
562   // Copy the predicate operands.
563   MIB.addOperand(MI.getOperand(OpIdx++));
564   MIB.addOperand(MI.getOperand(OpIdx++));
565
566   // Copy the super-register source to be an implicit source.
567   MO.setImplicit(true);
568   MIB.addOperand(MO);
569   if (TableEntry->IsLoad)
570     // Add an implicit def for the super-register.
571     MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead));
572   TransferImpOps(MI, MIB, MIB);
573   MI.eraseFromParent();
574 }
575
576 /// ExpandVTBL - Translate VTBL and VTBX pseudo instructions with Q or QQ
577 /// register operands to real instructions with D register operands.
578 void ARMExpandPseudo::ExpandVTBL(MachineBasicBlock::iterator &MBBI,
579                                  unsigned Opc, bool IsExt, unsigned NumRegs) {
580   MachineInstr &MI = *MBBI;
581   MachineBasicBlock &MBB = *MI.getParent();
582
583   MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(Opc));
584   unsigned OpIdx = 0;
585
586   // Transfer the destination register operand.
587   MIB.addOperand(MI.getOperand(OpIdx++));
588   if (IsExt)
589     MIB.addOperand(MI.getOperand(OpIdx++));
590
591   bool SrcIsKill = MI.getOperand(OpIdx).isKill();
592   unsigned SrcReg = MI.getOperand(OpIdx++).getReg();
593   unsigned D0, D1, D2, D3;
594   GetDSubRegs(SrcReg, SingleSpc, TRI, D0, D1, D2, D3);
595   MIB.addReg(D0).addReg(D1);
596   if (NumRegs > 2)
597     MIB.addReg(D2);
598   if (NumRegs > 3)
599     MIB.addReg(D3);
600
601   // Copy the other source register operand.
602   MIB.addOperand(MI.getOperand(OpIdx++));
603
604   // Copy the predicate operands.
605   MIB.addOperand(MI.getOperand(OpIdx++));
606   MIB.addOperand(MI.getOperand(OpIdx++));
607
608   if (SrcIsKill)
609     // Add an implicit kill for the super-reg.
610     (*MIB).addRegisterKilled(SrcReg, TRI, true);
611   TransferImpOps(MI, MIB, MIB);
612   MI.eraseFromParent();
613 }
614
615 bool ARMExpandPseudo::ExpandMBB(MachineBasicBlock &MBB) {
616   bool Modified = false;
617
618   MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end();
619   while (MBBI != E) {
620     MachineInstr &MI = *MBBI;
621     MachineBasicBlock::iterator NMBBI = llvm::next(MBBI);
622
623     bool ModifiedOp = true;
624     unsigned Opcode = MI.getOpcode();
625     switch (Opcode) {
626     default:
627       ModifiedOp = false;
628       break;
629
630     case ARM::Int_eh_sjlj_dispatchsetup: {
631       MachineFunction &MF = *MI.getParent()->getParent();
632       const ARMBaseInstrInfo *AII =
633         static_cast<const ARMBaseInstrInfo*>(TII);
634       const ARMBaseRegisterInfo &RI = AII->getRegisterInfo();
635       // For functions using a base pointer, we rematerialize it (via the frame
636       // pointer) here since eh.sjlj.setjmp and eh.sjlj.longjmp don't do it
637       // for us. Otherwise, expand to nothing.
638       if (RI.hasBasePointer(MF)) {
639         ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
640         int32_t NumBytes = AFI->getFramePtrSpillOffset();
641         unsigned FramePtr = RI.getFrameRegister(MF);
642         assert(MF.getTarget().getFrameInfo()->hasFP(MF) &&
643                "base pointer without frame pointer?");
644
645         if (AFI->isThumb2Function()) {
646           llvm::emitT2RegPlusImmediate(MBB, MBBI, MI.getDebugLoc(), ARM::R6,
647                                        FramePtr, -NumBytes, ARMCC::AL, 0, *TII);
648         } else if (AFI->isThumbFunction()) {
649           llvm::emitThumbRegPlusImmediate(MBB, MBBI, ARM::R6,
650                                           FramePtr, -NumBytes,
651                                           *TII, RI, MI.getDebugLoc());
652         } else {
653           llvm::emitARMRegPlusImmediate(MBB, MBBI, MI.getDebugLoc(), ARM::R6,
654                                         FramePtr, -NumBytes, ARMCC::AL, 0,
655                                         *TII);
656         }
657         // If there's dynamic realignment, adjust for it.
658         if (RI.needsStackRealignment(MF)) {
659           MachineFrameInfo  *MFI = MF.getFrameInfo();
660           unsigned MaxAlign = MFI->getMaxAlignment();
661           assert (!AFI->isThumb1OnlyFunction());
662           // Emit bic r6, r6, MaxAlign
663           unsigned bicOpc = AFI->isThumbFunction() ?
664             ARM::t2BICri : ARM::BICri;
665           AddDefaultCC(AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(),
666                                               TII->get(bicOpc), ARM::R6)
667                                       .addReg(ARM::R6, RegState::Kill)
668                                       .addImm(MaxAlign-1)));
669         }
670
671       }
672       MI.eraseFromParent();
673       break;
674     }
675
676     case ARM::MOVsrl_flag:
677     case ARM::MOVsra_flag: {
678       // These are just fancy MOVs insructions.
679       AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVs),
680                              MI.getOperand(0).getReg())
681       .addOperand(MI.getOperand(1))
682       .addReg(0)
683       .addImm(ARM_AM::getSORegOpc((Opcode == ARM::MOVsrl_flag ? ARM_AM::lsr
684                                    : ARM_AM::asr), 1)))
685       .addReg(ARM::CPSR, RegState::Define);
686       MI.eraseFromParent();
687       break;
688     }
689     case ARM::RRX: {
690       // This encodes as "MOVs Rd, Rm, rrx
691       MachineInstrBuilder MIB =
692         AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVs),
693                                MI.getOperand(0).getReg())
694         .addOperand(MI.getOperand(1))
695         .addOperand(MI.getOperand(1))
696         .addImm(ARM_AM::getSORegOpc(ARM_AM::rrx, 0)))
697         .addReg(0);
698       TransferImpOps(MI, MIB, MIB);
699       MI.eraseFromParent();
700       break;
701     }
702     case ARM::TPsoft: {
703       MachineInstrBuilder MIB = 
704         BuildMI(MBB, MBBI, MI.getDebugLoc(),
705                 TII->get(ARM::BL))
706         .addExternalSymbol("__aeabi_read_tp", 0);
707
708       (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
709       TransferImpOps(MI, MIB, MIB);
710       MI.eraseFromParent();
711       break;
712     }
713     case ARM::t2LDRHpci:
714     case ARM::t2LDRBpci:
715     case ARM::t2LDRSHpci:
716     case ARM::t2LDRSBpci:
717     case ARM::t2LDRpci: {
718       unsigned NewLdOpc;
719       if (Opcode == ARM::t2LDRpci)
720         NewLdOpc = ARM::t2LDRi12;
721       else if (Opcode == ARM::t2LDRHpci)
722         NewLdOpc = ARM::t2LDRHi12;
723       else if (Opcode == ARM::t2LDRBpci)
724         NewLdOpc = ARM::t2LDRBi12;
725       else if (Opcode == ARM::t2LDRSHpci)
726         NewLdOpc = ARM::t2LDRSHi12;
727       else if (Opcode == ARM::t2LDRSBpci)
728         NewLdOpc = ARM::t2LDRSBi12;
729       else
730         llvm_unreachable("Not a known opcode?");
731
732       unsigned DstReg = MI.getOperand(0).getReg();
733       MachineInstrBuilder MIB =
734         AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(),
735                                TII->get(NewLdOpc), DstReg)
736                 .addReg(ARM::PC)
737                 .addOperand(MI.getOperand(1)));
738       (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
739       TransferImpOps(MI, MIB, MIB);
740       MI.eraseFromParent();
741       break;
742     }
743     case ARM::tLDRpci_pic:
744     case ARM::t2LDRpci_pic: {
745       unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic)
746         ? ARM::tLDRpci : ARM::t2LDRi12;
747       unsigned DstReg = MI.getOperand(0).getReg();
748       bool DstIsDead = MI.getOperand(0).isDead();
749       MachineInstrBuilder MIB1 =
750         BuildMI(MBB, MBBI, MI.getDebugLoc(),
751         TII->get(NewLdOpc), DstReg);
752       if (Opcode == ARM::t2LDRpci_pic) MIB1.addReg(ARM::PC);
753       MIB1.addOperand(MI.getOperand(1));
754       AddDefaultPred(MIB1);
755       (*MIB1).setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
756       MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
757                                          TII->get(ARM::tPICADD))
758         .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
759         .addReg(DstReg)
760         .addOperand(MI.getOperand(2));
761       TransferImpOps(MI, MIB1, MIB2);
762       MI.eraseFromParent();
763       break;
764     }
765
766     case ARM::MOVi32imm:
767     case ARM::MOVCCi32imm:
768     case ARM::t2MOVi32imm:
769     case ARM::t2MOVCCi32imm: {
770       unsigned PredReg = 0;
771       ARMCC::CondCodes Pred = llvm::getInstrPredicate(&MI, PredReg);
772       unsigned DstReg = MI.getOperand(0).getReg();
773       bool DstIsDead = MI.getOperand(0).isDead();
774       bool isCC = Opcode == ARM::MOVCCi32imm || Opcode == ARM::t2MOVCCi32imm;
775       const MachineOperand &MO = MI.getOperand(isCC ? 2 : 1);
776       MachineInstrBuilder LO16, HI16;
777
778       if (!STI->hasV6T2Ops() &&
779           (Opcode == ARM::MOVi32imm || Opcode == ARM::MOVCCi32imm)) {
780         // Expand into a movi + orr.
781         LO16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::MOVi), DstReg);
782         HI16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::ORRri))
783           .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
784           .addReg(DstReg);
785
786         assert (MO.isImm() && "MOVi32imm w/ non-immediate source operand!");
787         unsigned ImmVal = (unsigned)MO.getImm();
788         unsigned SOImmValV1 = ARM_AM::getSOImmTwoPartFirst(ImmVal);
789         unsigned SOImmValV2 = ARM_AM::getSOImmTwoPartSecond(ImmVal);
790         LO16 = LO16.addImm(SOImmValV1);
791         HI16 = HI16.addImm(SOImmValV2);
792         (*LO16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
793         (*HI16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
794         LO16.addImm(Pred).addReg(PredReg).addReg(0);
795         HI16.addImm(Pred).addReg(PredReg).addReg(0);
796         TransferImpOps(MI, LO16, HI16);
797         MI.eraseFromParent();
798         break;
799       }
800
801       bool isThumb =
802         (Opcode == ARM::t2MOVi32imm || Opcode == ARM::t2MOVCCi32imm);
803
804       LO16 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
805                      TII->get(isThumb ? ARM::t2MOVi16 : ARM::MOVi16),
806                      DstReg);
807       HI16 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
808                      TII->get(isThumb ? ARM::t2MOVTi16 : ARM::MOVTi16))
809         .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead))
810         .addReg(DstReg);
811
812       if (MO.isImm()) {
813         unsigned Imm = MO.getImm();
814         unsigned Lo16 = Imm & 0xffff;
815         unsigned Hi16 = (Imm >> 16) & 0xffff;
816         LO16 = LO16.addImm(Lo16);
817         HI16 = HI16.addImm(Hi16);
818       } else {
819         const GlobalValue *GV = MO.getGlobal();
820         unsigned TF = MO.getTargetFlags();
821         LO16 = LO16.addGlobalAddress(GV, MO.getOffset(), TF | ARMII::MO_LO16);
822         HI16 = HI16.addGlobalAddress(GV, MO.getOffset(), TF | ARMII::MO_HI16);
823       }
824       (*LO16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
825       (*HI16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
826       LO16.addImm(Pred).addReg(PredReg);
827       HI16.addImm(Pred).addReg(PredReg);
828       TransferImpOps(MI, LO16, HI16);
829       MI.eraseFromParent();
830       break;
831     }
832
833     case ARM::VMOVQQ: {
834       unsigned DstReg = MI.getOperand(0).getReg();
835       bool DstIsDead = MI.getOperand(0).isDead();
836       unsigned EvenDst = TRI->getSubReg(DstReg, ARM::qsub_0);
837       unsigned OddDst  = TRI->getSubReg(DstReg, ARM::qsub_1);
838       unsigned SrcReg = MI.getOperand(1).getReg();
839       bool SrcIsKill = MI.getOperand(1).isKill();
840       unsigned EvenSrc = TRI->getSubReg(SrcReg, ARM::qsub_0);
841       unsigned OddSrc  = TRI->getSubReg(SrcReg, ARM::qsub_1);
842       MachineInstrBuilder Even =
843         AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(),
844                                TII->get(ARM::VMOVQ))
845                      .addReg(EvenDst,
846                              RegState::Define | getDeadRegState(DstIsDead))
847                      .addReg(EvenSrc, getKillRegState(SrcIsKill)));
848       MachineInstrBuilder Odd =
849         AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(),
850                                TII->get(ARM::VMOVQ))
851                      .addReg(OddDst,
852                              RegState::Define | getDeadRegState(DstIsDead))
853                      .addReg(OddSrc, getKillRegState(SrcIsKill)));
854       TransferImpOps(MI, Even, Odd);
855       MI.eraseFromParent();
856       break;
857     }
858
859     case ARM::VLDMQIA:
860     case ARM::VLDMQDB: {
861       unsigned NewOpc = (Opcode == ARM::VLDMQIA) ? ARM::VLDMDIA : ARM::VLDMDDB;
862       MachineInstrBuilder MIB =
863         BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewOpc));
864       unsigned OpIdx = 0;
865
866       // Grab the Q register destination.
867       bool DstIsDead = MI.getOperand(OpIdx).isDead();
868       unsigned DstReg = MI.getOperand(OpIdx++).getReg();
869
870       // Copy the source register.
871       MIB.addOperand(MI.getOperand(OpIdx++));
872
873       // Copy the predicate operands.
874       MIB.addOperand(MI.getOperand(OpIdx++));
875       MIB.addOperand(MI.getOperand(OpIdx++));
876
877       // Add the destination operands (D subregs).
878       unsigned D0 = TRI->getSubReg(DstReg, ARM::dsub_0);
879       unsigned D1 = TRI->getSubReg(DstReg, ARM::dsub_1);
880       MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead))
881         .addReg(D1, RegState::Define | getDeadRegState(DstIsDead));
882
883       // Add an implicit def for the super-register.
884       MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead));
885       TransferImpOps(MI, MIB, MIB);
886       MI.eraseFromParent();
887       break;
888     }
889
890     case ARM::VSTMQIA:
891     case ARM::VSTMQDB: {
892       unsigned NewOpc = (Opcode == ARM::VSTMQIA) ? ARM::VSTMDIA : ARM::VSTMDDB;
893       MachineInstrBuilder MIB =
894         BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewOpc));
895       unsigned OpIdx = 0;
896
897       // Grab the Q register source.
898       bool SrcIsKill = MI.getOperand(OpIdx).isKill();
899       unsigned SrcReg = MI.getOperand(OpIdx++).getReg();
900
901       // Copy the destination register.
902       MIB.addOperand(MI.getOperand(OpIdx++));
903
904       // Copy the predicate operands.
905       MIB.addOperand(MI.getOperand(OpIdx++));
906       MIB.addOperand(MI.getOperand(OpIdx++));
907
908       // Add the source operands (D subregs).
909       unsigned D0 = TRI->getSubReg(SrcReg, ARM::dsub_0);
910       unsigned D1 = TRI->getSubReg(SrcReg, ARM::dsub_1);
911       MIB.addReg(D0).addReg(D1);
912
913       if (SrcIsKill)
914         // Add an implicit kill for the Q register.
915         (*MIB).addRegisterKilled(SrcReg, TRI, true);
916
917       TransferImpOps(MI, MIB, MIB);
918       MI.eraseFromParent();
919       break;
920     }
921     case ARM::VDUPfqf:
922     case ARM::VDUPfdf:{
923       unsigned NewOpc = Opcode == ARM::VDUPfqf ? ARM::VDUPLNfq : ARM::VDUPLNfd;
924       MachineInstrBuilder MIB =
925         BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewOpc));
926       unsigned OpIdx = 0;
927       unsigned SrcReg = MI.getOperand(1).getReg();
928       unsigned Lane = getARMRegisterNumbering(SrcReg) & 1;
929       unsigned DReg = TRI->getMatchingSuperReg(SrcReg,
930           Lane & 1 ? ARM::ssub_1 : ARM::ssub_0, &ARM::DPR_VFP2RegClass);
931       // The lane is [0,1] for the containing DReg superregister.
932       // Copy the dst/src register operands.
933       MIB.addOperand(MI.getOperand(OpIdx++));
934       MIB.addReg(DReg);
935       ++OpIdx;
936       // Add the lane select operand.
937       MIB.addImm(Lane);
938       // Add the predicate operands.
939       MIB.addOperand(MI.getOperand(OpIdx++));
940       MIB.addOperand(MI.getOperand(OpIdx++));
941
942       TransferImpOps(MI, MIB, MIB);
943       MI.eraseFromParent();
944       break;
945     }
946
947     case ARM::VLD1q8Pseudo:
948     case ARM::VLD1q16Pseudo:
949     case ARM::VLD1q32Pseudo:
950     case ARM::VLD1q64Pseudo:
951     case ARM::VLD1q8Pseudo_UPD:
952     case ARM::VLD1q16Pseudo_UPD:
953     case ARM::VLD1q32Pseudo_UPD:
954     case ARM::VLD1q64Pseudo_UPD:
955     case ARM::VLD2d8Pseudo:
956     case ARM::VLD2d16Pseudo:
957     case ARM::VLD2d32Pseudo:
958     case ARM::VLD2q8Pseudo:
959     case ARM::VLD2q16Pseudo:
960     case ARM::VLD2q32Pseudo:
961     case ARM::VLD2d8Pseudo_UPD:
962     case ARM::VLD2d16Pseudo_UPD:
963     case ARM::VLD2d32Pseudo_UPD:
964     case ARM::VLD2q8Pseudo_UPD:
965     case ARM::VLD2q16Pseudo_UPD:
966     case ARM::VLD2q32Pseudo_UPD:
967     case ARM::VLD3d8Pseudo:
968     case ARM::VLD3d16Pseudo:
969     case ARM::VLD3d32Pseudo:
970     case ARM::VLD1d64TPseudo:
971     case ARM::VLD3d8Pseudo_UPD:
972     case ARM::VLD3d16Pseudo_UPD:
973     case ARM::VLD3d32Pseudo_UPD:
974     case ARM::VLD1d64TPseudo_UPD:
975     case ARM::VLD3q8Pseudo_UPD:
976     case ARM::VLD3q16Pseudo_UPD:
977     case ARM::VLD3q32Pseudo_UPD:
978     case ARM::VLD3q8oddPseudo_UPD:
979     case ARM::VLD3q16oddPseudo_UPD:
980     case ARM::VLD3q32oddPseudo_UPD:
981     case ARM::VLD4d8Pseudo:
982     case ARM::VLD4d16Pseudo:
983     case ARM::VLD4d32Pseudo:
984     case ARM::VLD1d64QPseudo:
985     case ARM::VLD4d8Pseudo_UPD:
986     case ARM::VLD4d16Pseudo_UPD:
987     case ARM::VLD4d32Pseudo_UPD:
988     case ARM::VLD1d64QPseudo_UPD:
989     case ARM::VLD4q8Pseudo_UPD:
990     case ARM::VLD4q16Pseudo_UPD:
991     case ARM::VLD4q32Pseudo_UPD:
992     case ARM::VLD4q8oddPseudo_UPD:
993     case ARM::VLD4q16oddPseudo_UPD:
994     case ARM::VLD4q32oddPseudo_UPD:
995     case ARM::VLD1DUPq8Pseudo:
996     case ARM::VLD1DUPq16Pseudo:
997     case ARM::VLD1DUPq32Pseudo:
998     case ARM::VLD1DUPq8Pseudo_UPD:
999     case ARM::VLD1DUPq16Pseudo_UPD:
1000     case ARM::VLD1DUPq32Pseudo_UPD:
1001     case ARM::VLD2DUPd8Pseudo:
1002     case ARM::VLD2DUPd16Pseudo:
1003     case ARM::VLD2DUPd32Pseudo:
1004     case ARM::VLD2DUPd8Pseudo_UPD:
1005     case ARM::VLD2DUPd16Pseudo_UPD:
1006     case ARM::VLD2DUPd32Pseudo_UPD:
1007     case ARM::VLD3DUPd8Pseudo:
1008     case ARM::VLD3DUPd16Pseudo:
1009     case ARM::VLD3DUPd32Pseudo:
1010     case ARM::VLD3DUPd8Pseudo_UPD:
1011     case ARM::VLD3DUPd16Pseudo_UPD:
1012     case ARM::VLD3DUPd32Pseudo_UPD:
1013     case ARM::VLD4DUPd8Pseudo:
1014     case ARM::VLD4DUPd16Pseudo:
1015     case ARM::VLD4DUPd32Pseudo:
1016     case ARM::VLD4DUPd8Pseudo_UPD:
1017     case ARM::VLD4DUPd16Pseudo_UPD:
1018     case ARM::VLD4DUPd32Pseudo_UPD:
1019       ExpandVLD(MBBI);
1020       break;
1021
1022     case ARM::VST1q8Pseudo:
1023     case ARM::VST1q16Pseudo:
1024     case ARM::VST1q32Pseudo:
1025     case ARM::VST1q64Pseudo:
1026     case ARM::VST1q8Pseudo_UPD:
1027     case ARM::VST1q16Pseudo_UPD:
1028     case ARM::VST1q32Pseudo_UPD:
1029     case ARM::VST1q64Pseudo_UPD:
1030     case ARM::VST2d8Pseudo:
1031     case ARM::VST2d16Pseudo:
1032     case ARM::VST2d32Pseudo:
1033     case ARM::VST2q8Pseudo:
1034     case ARM::VST2q16Pseudo:
1035     case ARM::VST2q32Pseudo:
1036     case ARM::VST2d8Pseudo_UPD:
1037     case ARM::VST2d16Pseudo_UPD:
1038     case ARM::VST2d32Pseudo_UPD:
1039     case ARM::VST2q8Pseudo_UPD:
1040     case ARM::VST2q16Pseudo_UPD:
1041     case ARM::VST2q32Pseudo_UPD:
1042     case ARM::VST3d8Pseudo:
1043     case ARM::VST3d16Pseudo:
1044     case ARM::VST3d32Pseudo:
1045     case ARM::VST1d64TPseudo:
1046     case ARM::VST3d8Pseudo_UPD:
1047     case ARM::VST3d16Pseudo_UPD:
1048     case ARM::VST3d32Pseudo_UPD:
1049     case ARM::VST1d64TPseudo_UPD:
1050     case ARM::VST3q8Pseudo_UPD:
1051     case ARM::VST3q16Pseudo_UPD:
1052     case ARM::VST3q32Pseudo_UPD:
1053     case ARM::VST3q8oddPseudo_UPD:
1054     case ARM::VST3q16oddPseudo_UPD:
1055     case ARM::VST3q32oddPseudo_UPD:
1056     case ARM::VST4d8Pseudo:
1057     case ARM::VST4d16Pseudo:
1058     case ARM::VST4d32Pseudo:
1059     case ARM::VST1d64QPseudo:
1060     case ARM::VST4d8Pseudo_UPD:
1061     case ARM::VST4d16Pseudo_UPD:
1062     case ARM::VST4d32Pseudo_UPD:
1063     case ARM::VST1d64QPseudo_UPD:
1064     case ARM::VST4q8Pseudo_UPD:
1065     case ARM::VST4q16Pseudo_UPD:
1066     case ARM::VST4q32Pseudo_UPD:
1067     case ARM::VST4q8oddPseudo_UPD:
1068     case ARM::VST4q16oddPseudo_UPD:
1069     case ARM::VST4q32oddPseudo_UPD:
1070       ExpandVST(MBBI);
1071       break;
1072
1073     case ARM::VLD1LNq8Pseudo:
1074     case ARM::VLD1LNq16Pseudo:
1075     case ARM::VLD1LNq32Pseudo:
1076     case ARM::VLD1LNq8Pseudo_UPD:
1077     case ARM::VLD1LNq16Pseudo_UPD:
1078     case ARM::VLD1LNq32Pseudo_UPD:
1079     case ARM::VLD2LNd8Pseudo:
1080     case ARM::VLD2LNd16Pseudo:
1081     case ARM::VLD2LNd32Pseudo:
1082     case ARM::VLD2LNq16Pseudo:
1083     case ARM::VLD2LNq32Pseudo:
1084     case ARM::VLD2LNd8Pseudo_UPD:
1085     case ARM::VLD2LNd16Pseudo_UPD:
1086     case ARM::VLD2LNd32Pseudo_UPD:
1087     case ARM::VLD2LNq16Pseudo_UPD:
1088     case ARM::VLD2LNq32Pseudo_UPD:
1089     case ARM::VLD3LNd8Pseudo:
1090     case ARM::VLD3LNd16Pseudo:
1091     case ARM::VLD3LNd32Pseudo:
1092     case ARM::VLD3LNq16Pseudo:
1093     case ARM::VLD3LNq32Pseudo:
1094     case ARM::VLD3LNd8Pseudo_UPD:
1095     case ARM::VLD3LNd16Pseudo_UPD:
1096     case ARM::VLD3LNd32Pseudo_UPD:
1097     case ARM::VLD3LNq16Pseudo_UPD:
1098     case ARM::VLD3LNq32Pseudo_UPD:
1099     case ARM::VLD4LNd8Pseudo:
1100     case ARM::VLD4LNd16Pseudo:
1101     case ARM::VLD4LNd32Pseudo:
1102     case ARM::VLD4LNq16Pseudo:
1103     case ARM::VLD4LNq32Pseudo:
1104     case ARM::VLD4LNd8Pseudo_UPD:
1105     case ARM::VLD4LNd16Pseudo_UPD:
1106     case ARM::VLD4LNd32Pseudo_UPD:
1107     case ARM::VLD4LNq16Pseudo_UPD:
1108     case ARM::VLD4LNq32Pseudo_UPD:
1109     case ARM::VST1LNq8Pseudo:
1110     case ARM::VST1LNq16Pseudo:
1111     case ARM::VST1LNq32Pseudo:
1112     case ARM::VST1LNq8Pseudo_UPD:
1113     case ARM::VST1LNq16Pseudo_UPD:
1114     case ARM::VST1LNq32Pseudo_UPD:
1115     case ARM::VST2LNd8Pseudo:
1116     case ARM::VST2LNd16Pseudo:
1117     case ARM::VST2LNd32Pseudo:
1118     case ARM::VST2LNq16Pseudo:
1119     case ARM::VST2LNq32Pseudo:
1120     case ARM::VST2LNd8Pseudo_UPD:
1121     case ARM::VST2LNd16Pseudo_UPD:
1122     case ARM::VST2LNd32Pseudo_UPD:
1123     case ARM::VST2LNq16Pseudo_UPD:
1124     case ARM::VST2LNq32Pseudo_UPD:
1125     case ARM::VST3LNd8Pseudo:
1126     case ARM::VST3LNd16Pseudo:
1127     case ARM::VST3LNd32Pseudo:
1128     case ARM::VST3LNq16Pseudo:
1129     case ARM::VST3LNq32Pseudo:
1130     case ARM::VST3LNd8Pseudo_UPD:
1131     case ARM::VST3LNd16Pseudo_UPD:
1132     case ARM::VST3LNd32Pseudo_UPD:
1133     case ARM::VST3LNq16Pseudo_UPD:
1134     case ARM::VST3LNq32Pseudo_UPD:
1135     case ARM::VST4LNd8Pseudo:
1136     case ARM::VST4LNd16Pseudo:
1137     case ARM::VST4LNd32Pseudo:
1138     case ARM::VST4LNq16Pseudo:
1139     case ARM::VST4LNq32Pseudo:
1140     case ARM::VST4LNd8Pseudo_UPD:
1141     case ARM::VST4LNd16Pseudo_UPD:
1142     case ARM::VST4LNd32Pseudo_UPD:
1143     case ARM::VST4LNq16Pseudo_UPD:
1144     case ARM::VST4LNq32Pseudo_UPD:
1145       ExpandLaneOp(MBBI);
1146       break;
1147
1148     case ARM::VTBL2Pseudo:
1149       ExpandVTBL(MBBI, ARM::VTBL2, false, 2); break;
1150     case ARM::VTBL3Pseudo:
1151       ExpandVTBL(MBBI, ARM::VTBL3, false, 3); break;
1152     case ARM::VTBL4Pseudo:
1153       ExpandVTBL(MBBI, ARM::VTBL4, false, 4); break;
1154     case ARM::VTBX2Pseudo:
1155       ExpandVTBL(MBBI, ARM::VTBX2, true, 2); break;
1156     case ARM::VTBX3Pseudo:
1157       ExpandVTBL(MBBI, ARM::VTBX3, true, 3); break;
1158     case ARM::VTBX4Pseudo:
1159       ExpandVTBL(MBBI, ARM::VTBX4, true, 4); break;
1160     }
1161
1162     if (ModifiedOp)
1163       Modified = true;
1164     MBBI = NMBBI;
1165   }
1166
1167   return Modified;
1168 }
1169
1170 bool ARMExpandPseudo::runOnMachineFunction(MachineFunction &MF) {
1171   TII = static_cast<const ARMBaseInstrInfo*>(MF.getTarget().getInstrInfo());
1172   TRI = MF.getTarget().getRegisterInfo();
1173   STI = &MF.getTarget().getSubtarget<ARMSubtarget>();
1174
1175   bool Modified = false;
1176   for (MachineFunction::iterator MFI = MF.begin(), E = MF.end(); MFI != E;
1177        ++MFI)
1178     Modified |= ExpandMBB(*MFI);
1179   return Modified;
1180 }
1181
1182 /// createARMExpandPseudoPass - returns an instance of the pseudo instruction
1183 /// expansion pass.
1184 FunctionPass *llvm::createARMExpandPseudoPass() {
1185   return new ARMExpandPseudo();
1186 }