blob: 6f9bac9f13242cf0f998a81379df134045d51dbf [file] [log] [blame]
Anton Korobeynikovd4022c32009-05-29 23:41:08 +00001//===- ARMInstrThumb2.td - Thumb2 support for ARM -------------------------===//
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 describes the Thumb2 instruction set.
11//
12//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +000013
Evan Cheng06e16582009-07-10 01:54:42 +000014// IT block predicate field
15def it_pred : Operand<i32> {
Johnny Chen9d3acaa2010-03-02 17:57:15 +000016 let PrintMethod = "printMandatoryPredicateOperand";
Evan Cheng06e16582009-07-10 01:54:42 +000017}
18
19// IT block condition mask
20def it_mask : Operand<i32> {
21 let PrintMethod = "printThumbITMask";
22}
23
Evan Cheng5657c012009-07-29 02:18:14 +000024// Table branch address
25def tb_addrmode : Operand<i32> {
26 let PrintMethod = "printTBAddrMode";
27}
28
Anton Korobeynikov52237112009-06-17 18:13:58 +000029// Shifted operands. No register controlled shifts for Thumb2.
30// Note: We do not support rrx shifted operands yet.
31def t2_so_reg : Operand<i32>, // reg imm
Evan Cheng9cb9e672009-06-27 02:26:13 +000032 ComplexPattern<i32, 2, "SelectT2ShifterOperandReg",
Anton Korobeynikov52237112009-06-17 18:13:58 +000033 [shl,srl,sra,rotr]> {
Chris Lattner2ac19022010-11-15 05:19:05 +000034 let EncoderMethod = "getT2SORegOpValue";
Evan Cheng9cb9e672009-06-27 02:26:13 +000035 let PrintMethod = "printT2SOOperand";
Jim Grosbach6ccfc502010-07-30 02:41:01 +000036 let MIOperandInfo = (ops rGPR, i32imm);
Anton Korobeynikov52237112009-06-17 18:13:58 +000037}
38
Evan Chengf49810c2009-06-23 17:48:47 +000039// t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
40def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{
Owen Anderson825b72b2009-08-11 20:47:22 +000041 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
Anton Korobeynikov52237112009-06-17 18:13:58 +000042}]>;
43
Evan Chengf49810c2009-06-23 17:48:47 +000044// t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
45def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
Owen Anderson825b72b2009-08-11 20:47:22 +000046 return CurDAG->getTargetConstant(-((int)N->getZExtValue()), MVT::i32);
Evan Chengf49810c2009-06-23 17:48:47 +000047}]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +000048
Evan Chengf49810c2009-06-23 17:48:47 +000049// t2_so_imm - Match a 32-bit immediate operand, which is an
50// 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
51// immediate splatted into multiple bytes of the word. t2_so_imm values are
52// represented in the imm field in the same 12-bit form that they are encoded
Jim Grosbach6935efc2009-11-24 00:20:27 +000053// into t2_so_imm instructions: the 8-bit immediate is the least significant
54// bits [bits 0-7], the 4-bit shift/splat amount is the next 4 bits [bits 8-11].
Owen Anderson5de6d842010-11-12 21:12:40 +000055def t2_so_imm : Operand<i32>, PatLeaf<(imm), [{ return Pred_t2_so_imm(N); }]> {
Chris Lattner2ac19022010-11-15 05:19:05 +000056 let EncoderMethod = "getT2SOImmOpValue";
Owen Anderson5de6d842010-11-12 21:12:40 +000057}
Anton Korobeynikov52237112009-06-17 18:13:58 +000058
Jim Grosbach64171712010-02-16 21:07:46 +000059// t2_so_imm_not - Match an immediate that is a complement
Evan Chengf49810c2009-06-23 17:48:47 +000060// of a t2_so_imm.
61def t2_so_imm_not : Operand<i32>,
62 PatLeaf<(imm), [{
Evan Chenge7cbe412009-07-08 21:03:57 +000063 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
64}], t2_so_imm_not_XFORM>;
Evan Chengf49810c2009-06-23 17:48:47 +000065
66// t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
67def t2_so_imm_neg : Operand<i32>,
68 PatLeaf<(imm), [{
Evan Cheng875a6ac2010-11-12 22:42:47 +000069 return ARM_AM::getT2SOImmVal(-((uint32_t)N->getZExtValue())) != -1;
Evan Chenge7cbe412009-07-08 21:03:57 +000070}], t2_so_imm_neg_XFORM>;
Evan Chengf49810c2009-06-23 17:48:47 +000071
Jim Grosbach65b7f3a2009-10-21 20:44:34 +000072// Break t2_so_imm's up into two pieces. This handles immediates with up to 16
73// bits set in them. This uses t2_so_imm2part to match and t2_so_imm2part_[12]
74// to get the first/second pieces.
75def t2_so_imm2part : Operand<i32>,
76 PatLeaf<(imm), [{
77 return ARM_AM::isT2SOImmTwoPartVal((unsigned)N->getZExtValue());
78 }]> {
79}
80
81def t2_so_imm2part_1 : SDNodeXForm<imm, [{
82 unsigned V = ARM_AM::getT2SOImmTwoPartFirst((unsigned)N->getZExtValue());
83 return CurDAG->getTargetConstant(V, MVT::i32);
84}]>;
85
86def t2_so_imm2part_2 : SDNodeXForm<imm, [{
87 unsigned V = ARM_AM::getT2SOImmTwoPartSecond((unsigned)N->getZExtValue());
88 return CurDAG->getTargetConstant(V, MVT::i32);
89}]>;
90
Jim Grosbach15e6ef82009-11-23 20:35:53 +000091def t2_so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
92 return ARM_AM::isT2SOImmTwoPartVal(-(int)N->getZExtValue());
93 }]> {
94}
95
96def t2_so_neg_imm2part_1 : SDNodeXForm<imm, [{
97 unsigned V = ARM_AM::getT2SOImmTwoPartFirst(-(int)N->getZExtValue());
98 return CurDAG->getTargetConstant(V, MVT::i32);
99}]>;
100
101def t2_so_neg_imm2part_2 : SDNodeXForm<imm, [{
102 unsigned V = ARM_AM::getT2SOImmTwoPartSecond(-(int)N->getZExtValue());
103 return CurDAG->getTargetConstant(V, MVT::i32);
104}]>;
105
Evan Chenga67efd12009-06-23 19:39:13 +0000106/// imm1_31 predicate - True if the 32-bit immediate is in the range [1,31].
107def imm1_31 : PatLeaf<(i32 imm), [{
108 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 32;
109}]>;
110
Evan Chengf49810c2009-06-23 17:48:47 +0000111/// imm0_4095 predicate - True if the 32-bit immediate is in the range [0.4095].
Evan Cheng86198642009-08-07 00:34:42 +0000112def imm0_4095 : Operand<i32>,
113 PatLeaf<(i32 imm), [{
Evan Chengf49810c2009-06-23 17:48:47 +0000114 return (uint32_t)N->getZExtValue() < 4096;
115}]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000116
Jim Grosbach64171712010-02-16 21:07:46 +0000117def imm0_4095_neg : PatLeaf<(i32 imm), [{
118 return (uint32_t)(-N->getZExtValue()) < 4096;
119}], imm_neg_XFORM>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000120
Evan Chengfa2ea1a2009-08-04 01:41:15 +0000121def imm0_255_neg : PatLeaf<(i32 imm), [{
122 return (uint32_t)(-N->getZExtValue()) < 255;
Jim Grosbach64171712010-02-16 21:07:46 +0000123}], imm_neg_XFORM>;
Evan Chengfa2ea1a2009-08-04 01:41:15 +0000124
Jim Grosbach502e0aa2010-07-14 17:45:16 +0000125def imm0_255_not : PatLeaf<(i32 imm), [{
126 return (uint32_t)(~N->getZExtValue()) < 255;
127}], imm_comp_XFORM>;
128
Evan Cheng055b0312009-06-29 07:51:04 +0000129// Define Thumb2 specific addressing modes.
130
131// t2addrmode_imm12 := reg + imm12
132def t2addrmode_imm12 : Operand<i32>,
133 ComplexPattern<i32, 2, "SelectT2AddrModeImm12", []> {
Jim Grosbach458f2dc2010-10-25 20:00:01 +0000134 let PrintMethod = "printAddrModeImm12Operand";
Evan Cheng055b0312009-06-29 07:51:04 +0000135 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
136}
137
Johnny Chen0635fc52010-03-04 17:40:44 +0000138// t2addrmode_imm8 := reg +/- imm8
Evan Cheng055b0312009-06-29 07:51:04 +0000139def t2addrmode_imm8 : Operand<i32>,
140 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
141 let PrintMethod = "printT2AddrModeImm8Operand";
142 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
143}
144
Evan Cheng6d94f112009-07-03 00:06:39 +0000145def t2am_imm8_offset : Operand<i32>,
Chris Lattner52a261b2010-09-21 20:31:19 +0000146 ComplexPattern<i32, 1, "SelectT2AddrModeImm8Offset",
147 [], [SDNPWantRoot]> {
Evan Chenge88d5ce2009-07-02 07:28:31 +0000148 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
149}
150
Evan Cheng5c874172009-07-09 22:21:59 +0000151// t2addrmode_imm8s4 := reg +/- (imm8 << 2)
Chris Lattner979b0612010-09-05 22:51:11 +0000152def t2addrmode_imm8s4 : Operand<i32> {
Evan Cheng5c874172009-07-09 22:21:59 +0000153 let PrintMethod = "printT2AddrModeImm8s4Operand";
David Goodwin6647cea2009-06-30 22:50:01 +0000154 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
155}
156
Johnny Chenae1757b2010-03-11 01:13:36 +0000157def t2am_imm8s4_offset : Operand<i32> {
158 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand";
159}
160
Evan Chengcba962d2009-07-09 20:40:44 +0000161// t2addrmode_so_reg := reg + (reg << imm2)
Evan Cheng055b0312009-06-29 07:51:04 +0000162def t2addrmode_so_reg : Operand<i32>,
163 ComplexPattern<i32, 3, "SelectT2AddrModeSoReg", []> {
164 let PrintMethod = "printT2AddrModeSoRegOperand";
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000165 let MIOperandInfo = (ops GPR:$base, rGPR:$offsreg, i32imm:$offsimm);
Evan Cheng055b0312009-06-29 07:51:04 +0000166}
167
168
Anton Korobeynikov52237112009-06-17 18:13:58 +0000169//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000170// Multiclass helpers...
Anton Korobeynikov52237112009-06-17 18:13:58 +0000171//
172
Owen Andersona99e7782010-11-15 18:45:17 +0000173
174class T2OneRegImm<dag oops, dag iops, InstrItinClass itin,
Owen Anderson83da6cd2010-11-14 05:37:38 +0000175 string opc, string asm, list<dag> pattern>
176 : T2I<oops, iops, itin, opc, asm, pattern> {
177 bits<4> Rd;
Owen Andersona99e7782010-11-15 18:45:17 +0000178 bits<12> imm;
179
180 let Inst{11-8} = Rd{3-0};
181 let Inst{26} = imm{11};
182 let Inst{14-12} = imm{10-8};
183 let Inst{7-0} = imm{7-0};
184}
185
Owen Andersonbb6315d2010-11-15 19:58:36 +0000186
Owen Andersona99e7782010-11-15 18:45:17 +0000187class T2sOneRegImm<dag oops, dag iops, InstrItinClass itin,
188 string opc, string asm, list<dag> pattern>
189 : T2sI<oops, iops, itin, opc, asm, pattern> {
190 bits<4> Rd;
Owen Anderson83da6cd2010-11-14 05:37:38 +0000191 bits<4> Rn;
192 bits<12> imm;
193
194 let Inst{11-8} = Rd{3-0};
Owen Anderson83da6cd2010-11-14 05:37:38 +0000195 let Inst{26} = imm{11};
196 let Inst{14-12} = imm{10-8};
197 let Inst{7-0} = imm{7-0};
198}
199
Owen Andersonbb6315d2010-11-15 19:58:36 +0000200class T2OneRegCmpImm<dag oops, dag iops, InstrItinClass itin,
201 string opc, string asm, list<dag> pattern>
202 : T2I<oops, iops, itin, opc, asm, pattern> {
203 bits<4> Rn;
204 bits<12> imm;
205
206 let Inst{19-16} = Rn{3-0};
207 let Inst{26} = imm{11};
208 let Inst{14-12} = imm{10-8};
209 let Inst{7-0} = imm{7-0};
210}
211
212
Owen Andersona99e7782010-11-15 18:45:17 +0000213class T2OneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
214 string opc, string asm, list<dag> pattern>
215 : T2I<oops, iops, itin, opc, asm, pattern> {
216 bits<4> Rd;
217 bits<12> ShiftedRm;
218
219 let Inst{11-8} = Rd{3-0};
220 let Inst{3-0} = ShiftedRm{3-0};
221 let Inst{5-4} = ShiftedRm{6-5};
222 let Inst{14-12} = ShiftedRm{11-9};
223 let Inst{7-6} = ShiftedRm{8-7};
224}
225
226class T2sOneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
227 string opc, string asm, list<dag> pattern>
228 : T2I<oops, iops, itin, opc, asm, pattern> {
229 bits<4> Rd;
230 bits<12> ShiftedRm;
231
232 let Inst{11-8} = Rd{3-0};
233 let Inst{3-0} = ShiftedRm{3-0};
234 let Inst{5-4} = ShiftedRm{6-5};
235 let Inst{14-12} = ShiftedRm{11-9};
236 let Inst{7-6} = ShiftedRm{8-7};
237}
238
Owen Andersonbb6315d2010-11-15 19:58:36 +0000239class T2OneRegCmpShiftedReg<dag oops, dag iops, InstrItinClass itin,
240 string opc, string asm, list<dag> pattern>
241 : T2I<oops, iops, itin, opc, asm, pattern> {
242 bits<4> Rn;
243 bits<12> ShiftedRm;
244
245 let Inst{19-16} = Rn{3-0};
246 let Inst{3-0} = ShiftedRm{3-0};
247 let Inst{5-4} = ShiftedRm{6-5};
248 let Inst{14-12} = ShiftedRm{11-9};
249 let Inst{7-6} = ShiftedRm{8-7};
250}
251
Owen Andersona99e7782010-11-15 18:45:17 +0000252class T2TwoReg<dag oops, dag iops, InstrItinClass itin,
253 string opc, string asm, list<dag> pattern>
254 : T2I<oops, iops, itin, opc, asm, pattern> {
255 bits<4> Rd;
256 bits<4> Rm;
257
258 let Inst{11-8} = Rd{3-0};
259 let Inst{3-0} = Rm{3-0};
260}
261
262class T2sTwoReg<dag oops, dag iops, InstrItinClass itin,
263 string opc, string asm, list<dag> pattern>
264 : T2sI<oops, iops, itin, opc, asm, pattern> {
265 bits<4> Rd;
266 bits<4> Rm;
267
268 let Inst{11-8} = Rd{3-0};
269 let Inst{3-0} = Rm{3-0};
270}
271
Owen Andersonbb6315d2010-11-15 19:58:36 +0000272class T2TwoRegCmp<dag oops, dag iops, InstrItinClass itin,
273 string opc, string asm, list<dag> pattern>
274 : T2I<oops, iops, itin, opc, asm, pattern> {
275 bits<4> Rn;
276 bits<4> Rm;
277
278 let Inst{19-16} = Rn{3-0};
279 let Inst{3-0} = Rm{3-0};
280}
281
Owen Andersona99e7782010-11-15 18:45:17 +0000282
283class T2TwoRegImm<dag oops, dag iops, InstrItinClass itin,
284 string opc, string asm, list<dag> pattern>
285 : T2I<oops, iops, itin, opc, asm, pattern> {
286 bits<4> Rd;
287 bits<4> Rm;
288
289 let Inst{11-8} = Rd{3-0};
290 let Inst{3-0} = Rm{3-0};
291}
292
Owen Anderson83da6cd2010-11-14 05:37:38 +0000293class T2sTwoRegImm<dag oops, dag iops, InstrItinClass itin,
Owen Anderson5de6d842010-11-12 21:12:40 +0000294 string opc, string asm, list<dag> pattern>
295 : T2sI<oops, iops, itin, opc, asm, pattern> {
296 bits<4> Rd;
297 bits<4> Rn;
298 bits<12> imm;
299
300 let Inst{11-8} = Rd{3-0};
301 let Inst{19-16} = Rn{3-0};
302 let Inst{26} = imm{11};
303 let Inst{14-12} = imm{10-8};
304 let Inst{7-0} = imm{7-0};
305}
306
Owen Andersonbb6315d2010-11-15 19:58:36 +0000307class T2TwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
308 string opc, string asm, list<dag> pattern>
309 : T2I<oops, iops, itin, opc, asm, pattern> {
310 bits<4> Rd;
311 bits<4> Rm;
312 bits<5> imm;
313
314 let Inst{11-8} = Rd{3-0};
315 let Inst{3-0} = Rm{3-0};
316 let Inst{14-12} = imm{4-2};
317 let Inst{7-6} = imm{1-0};
318}
319
320class T2sTwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
321 string opc, string asm, list<dag> pattern>
322 : T2sI<oops, iops, itin, opc, asm, pattern> {
323 bits<4> Rd;
324 bits<4> Rm;
325 bits<5> imm;
326
327 let Inst{11-8} = Rd{3-0};
328 let Inst{3-0} = Rm{3-0};
329 let Inst{14-12} = imm{4-2};
330 let Inst{7-6} = imm{1-0};
331}
332
Owen Anderson5de6d842010-11-12 21:12:40 +0000333class T2ThreeReg<dag oops, dag iops, InstrItinClass itin,
334 string opc, string asm, list<dag> pattern>
Owen Anderson83da6cd2010-11-14 05:37:38 +0000335 : T2I<oops, iops, itin, opc, asm, pattern> {
336 bits<4> Rd;
337 bits<4> Rn;
338 bits<4> Rm;
339
340 let Inst{11-8} = Rd{3-0};
341 let Inst{19-16} = Rn{3-0};
342 let Inst{3-0} = Rm{3-0};
343}
344
345class T2sThreeReg<dag oops, dag iops, InstrItinClass itin,
346 string opc, string asm, list<dag> pattern>
Owen Anderson5de6d842010-11-12 21:12:40 +0000347 : T2sI<oops, iops, itin, opc, asm, pattern> {
348 bits<4> Rd;
349 bits<4> Rn;
350 bits<4> Rm;
351
352 let Inst{11-8} = Rd{3-0};
353 let Inst{19-16} = Rn{3-0};
354 let Inst{3-0} = Rm{3-0};
355}
356
357class T2TwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
358 string opc, string asm, list<dag> pattern>
Owen Anderson83da6cd2010-11-14 05:37:38 +0000359 : T2I<oops, iops, itin, opc, asm, pattern> {
360 bits<4> Rd;
361 bits<4> Rn;
362 bits<12> ShiftedRm;
363
364 let Inst{11-8} = Rd{3-0};
365 let Inst{19-16} = Rn{3-0};
366 let Inst{3-0} = ShiftedRm{3-0};
367 let Inst{5-4} = ShiftedRm{6-5};
368 let Inst{14-12} = ShiftedRm{11-9};
369 let Inst{7-6} = ShiftedRm{8-7};
370}
371
372class T2sTwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
373 string opc, string asm, list<dag> pattern>
Owen Anderson5de6d842010-11-12 21:12:40 +0000374 : T2sI<oops, iops, itin, opc, asm, pattern> {
375 bits<4> Rd;
376 bits<4> Rn;
377 bits<12> ShiftedRm;
378
379 let Inst{11-8} = Rd{3-0};
380 let Inst{19-16} = Rn{3-0};
381 let Inst{3-0} = ShiftedRm{3-0};
382 let Inst{5-4} = ShiftedRm{6-5};
383 let Inst{14-12} = ShiftedRm{11-9};
384 let Inst{7-6} = ShiftedRm{8-7};
385}
386
Evan Chenga67efd12009-06-23 19:39:13 +0000387/// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000388/// unary operation that produces a value. These are predicable and can be
389/// changed to modify CPSR.
Evan Cheng5d42c562010-09-29 00:49:25 +0000390multiclass T2I_un_irs<bits<4> opcod, string opc,
391 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
392 PatFrag opnode, bit Cheap = 0, bit ReMat = 0> {
Evan Chenga67efd12009-06-23 19:39:13 +0000393 // shifted imm
Owen Andersona99e7782010-11-15 18:45:17 +0000394 def i : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), iii,
395 opc, "\t$Rd, $imm",
396 [(set rGPR:$Rd, (opnode t2_so_imm:$imm))]> {
Evan Chenga67efd12009-06-23 19:39:13 +0000397 let isAsCheapAsAMove = Cheap;
398 let isReMaterializable = ReMat;
Johnny Chend68e1192009-12-15 17:24:14 +0000399 let Inst{31-27} = 0b11110;
400 let Inst{25} = 0;
401 let Inst{24-21} = opcod;
402 let Inst{20} = ?; // The S bit.
403 let Inst{19-16} = 0b1111; // Rn
404 let Inst{15} = 0;
Evan Chenga67efd12009-06-23 19:39:13 +0000405 }
406 // register
Owen Andersona99e7782010-11-15 18:45:17 +0000407 def r : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), iir,
408 opc, ".w\t$Rd, $Rm",
409 [(set rGPR:$Rd, (opnode rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000410 let Inst{31-27} = 0b11101;
411 let Inst{26-25} = 0b01;
412 let Inst{24-21} = opcod;
413 let Inst{20} = ?; // The S bit.
414 let Inst{19-16} = 0b1111; // Rn
415 let Inst{14-12} = 0b000; // imm3
416 let Inst{7-6} = 0b00; // imm2
417 let Inst{5-4} = 0b00; // type
418 }
Evan Chenga67efd12009-06-23 19:39:13 +0000419 // shifted register
Owen Andersona99e7782010-11-15 18:45:17 +0000420 def s : T2sOneRegShiftedReg<(outs rGPR:$Rd), (ins t2_so_reg:$ShiftedRm), iis,
421 opc, ".w\t$Rd, $ShiftedRm",
422 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000423 let Inst{31-27} = 0b11101;
424 let Inst{26-25} = 0b01;
425 let Inst{24-21} = opcod;
426 let Inst{20} = ?; // The S bit.
427 let Inst{19-16} = 0b1111; // Rn
428 }
Evan Chenga67efd12009-06-23 19:39:13 +0000429}
430
431/// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
Bob Wilson4876bdb2010-05-25 04:43:08 +0000432/// binary operation that produces a value. These are predicable and can be
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000433/// changed to modify CPSR.
Evan Cheng7e1bf302010-09-29 00:27:46 +0000434multiclass T2I_bin_irs<bits<4> opcod, string opc,
435 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
436 PatFrag opnode, bit Commutable = 0, string wide = ""> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000437 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000438 def ri : T2sTwoRegImm<
439 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii,
440 opc, "\t$Rd, $Rn, $imm",
441 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000442 let Inst{31-27} = 0b11110;
443 let Inst{25} = 0;
444 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000445 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000446 let Inst{15} = 0;
447 }
Evan Chenga67efd12009-06-23 19:39:13 +0000448 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000449 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir,
450 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"),
451 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000452 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000453 let Inst{31-27} = 0b11101;
454 let Inst{26-25} = 0b01;
455 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000456 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000457 let Inst{14-12} = 0b000; // imm3
458 let Inst{7-6} = 0b00; // imm2
459 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000460 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000461 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000462 def rs : T2sTwoRegShiftedReg<
463 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
464 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"),
465 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000466 let Inst{31-27} = 0b11101;
467 let Inst{26-25} = 0b01;
468 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000469 let Inst{20} = ?; // The S bit.
470 }
471}
472
David Goodwin1f096272009-07-27 23:34:12 +0000473/// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
474// the ".w" prefix to indicate that they are wide.
Evan Cheng7e1bf302010-09-29 00:27:46 +0000475multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
476 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
477 PatFrag opnode, bit Commutable = 0> :
478 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w">;
Bill Wendling1f7bf0e2010-08-29 03:55:31 +0000479
Evan Cheng1e249e32009-06-25 20:59:23 +0000480/// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000481/// reversed. The 'rr' form is only defined for the disassembler; for codegen
482/// it is equivalent to the T2I_bin_irs counterpart.
483multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000484 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000485 def ri : T2sTwoRegImm<
486 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
487 opc, ".w\t$Rd, $Rn, $imm",
488 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000489 let Inst{31-27} = 0b11110;
490 let Inst{25} = 0;
491 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000492 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000493 let Inst{15} = 0;
494 }
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000495 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000496 def rr : T2sThreeReg<
497 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
498 opc, "\t$Rd, $Rn, $Rm",
Bob Wilson136e4912010-08-14 03:18:29 +0000499 [/* For disassembly only; pattern left blank */]> {
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000500 let Inst{31-27} = 0b11101;
501 let Inst{26-25} = 0b01;
502 let Inst{24-21} = opcod;
503 let Inst{20} = ?; // The S bit.
504 let Inst{14-12} = 0b000; // imm3
505 let Inst{7-6} = 0b00; // imm2
506 let Inst{5-4} = 0b00; // type
507 }
Evan Chengf49810c2009-06-23 17:48:47 +0000508 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000509 def rs : T2sTwoRegShiftedReg<
510 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
511 IIC_iALUsir, opc, "\t$Rd, $Rn, $ShiftedRm",
512 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000513 let Inst{31-27} = 0b11101;
514 let Inst{26-25} = 0b01;
515 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000516 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000517 }
Evan Chengf49810c2009-06-23 17:48:47 +0000518}
519
Evan Chenga67efd12009-06-23 19:39:13 +0000520/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
Anton Korobeynikov52237112009-06-17 18:13:58 +0000521/// instruction modifies the CPSR register.
522let Defs = [CPSR] in {
Evan Cheng7e1bf302010-09-29 00:27:46 +0000523multiclass T2I_bin_s_irs<bits<4> opcod, string opc,
524 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
525 PatFrag opnode, bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000526 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000527 def ri : T2TwoRegImm<
528 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_imm:$imm), iii,
529 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $imm",
530 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000531 let Inst{31-27} = 0b11110;
532 let Inst{25} = 0;
533 let Inst{24-21} = opcod;
534 let Inst{20} = 1; // The S bit.
535 let Inst{15} = 0;
536 }
Evan Chenga67efd12009-06-23 19:39:13 +0000537 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000538 def rr : T2ThreeReg<
539 (outs rGPR:$Rd), (ins GPR:$Rn, rGPR:$Rm), iir,
540 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $Rm",
541 [(set rGPR:$Rd, (opnode GPR:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000542 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000543 let Inst{31-27} = 0b11101;
544 let Inst{26-25} = 0b01;
545 let Inst{24-21} = opcod;
546 let Inst{20} = 1; // The S bit.
547 let Inst{14-12} = 0b000; // imm3
548 let Inst{7-6} = 0b00; // imm2
549 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000550 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000551 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000552 def rs : T2TwoRegShiftedReg<
553 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_reg:$ShiftedRm), iis,
554 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $ShiftedRm",
555 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000556 let Inst{31-27} = 0b11101;
557 let Inst{26-25} = 0b01;
558 let Inst{24-21} = opcod;
559 let Inst{20} = 1; // The S bit.
560 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000561}
562}
563
Evan Chenga67efd12009-06-23 19:39:13 +0000564/// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
565/// patterns for a binary operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000566multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
567 bit Commutable = 0> {
Evan Chengf49810c2009-06-23 17:48:47 +0000568 // shifted imm
Jim Grosbach663e3392010-08-30 19:49:58 +0000569 // The register-immediate version is re-materializable. This is useful
570 // in particular for taking the address of a local.
571 let isReMaterializable = 1 in {
Owen Anderson83da6cd2010-11-14 05:37:38 +0000572 def ri : T2sTwoRegImm<
573 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
574 opc, ".w\t$Rd, $Rn, $imm",
575 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000576 let Inst{31-27} = 0b11110;
577 let Inst{25} = 0;
578 let Inst{24} = 1;
579 let Inst{23-21} = op23_21;
580 let Inst{20} = 0; // The S bit.
581 let Inst{15} = 0;
582 }
Jim Grosbach663e3392010-08-30 19:49:58 +0000583 }
Evan Chengf49810c2009-06-23 17:48:47 +0000584 // 12-bit imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000585 def ri12 : T2TwoRegImm<
586 (outs rGPR:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi,
587 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
588 [(set rGPR:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000589 let Inst{31-27} = 0b11110;
590 let Inst{25} = 1;
591 let Inst{24} = 0;
592 let Inst{23-21} = op23_21;
593 let Inst{20} = 0; // The S bit.
594 let Inst{15} = 0;
595 }
Evan Chenga67efd12009-06-23 19:39:13 +0000596 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000597 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins GPR:$Rn, rGPR:$Rm), IIC_iALUr,
598 opc, ".w\t$Rd, $Rn, $Rm",
599 [(set rGPR:$Rd, (opnode GPR:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000600 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000601 let Inst{31-27} = 0b11101;
602 let Inst{26-25} = 0b01;
603 let Inst{24} = 1;
604 let Inst{23-21} = op23_21;
605 let Inst{20} = 0; // The S bit.
606 let Inst{14-12} = 0b000; // imm3
607 let Inst{7-6} = 0b00; // imm2
608 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000609 }
Evan Chengf49810c2009-06-23 17:48:47 +0000610 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000611 def rs : T2sTwoRegShiftedReg<
612 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_reg:$ShiftedRm),
613 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
614 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000615 let Inst{31-27} = 0b11101;
Johnny Chend68e1192009-12-15 17:24:14 +0000616 let Inst{26-25} = 0b01;
Johnny Chend248ffb2010-01-08 17:41:33 +0000617 let Inst{24} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000618 let Inst{23-21} = op23_21;
619 let Inst{20} = 0; // The S bit.
620 }
Evan Chengf49810c2009-06-23 17:48:47 +0000621}
622
Jim Grosbach6935efc2009-11-24 00:20:27 +0000623/// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000624/// for a binary operation that produces a value and use the carry
Jim Grosbach6935efc2009-11-24 00:20:27 +0000625/// bit. It's not predicable.
Evan Cheng62674222009-06-25 23:34:10 +0000626let Uses = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000627multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
628 bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000629 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000630 def ri : T2sTwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
Owen Anderson5de6d842010-11-12 21:12:40 +0000631 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
632 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000633 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000634 let Inst{31-27} = 0b11110;
635 let Inst{25} = 0;
636 let Inst{24-21} = opcod;
637 let Inst{20} = 0; // The S bit.
638 let Inst{15} = 0;
639 }
Evan Chenga67efd12009-06-23 19:39:13 +0000640 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000641 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
Owen Anderson5de6d842010-11-12 21:12:40 +0000642 opc, ".w\t$Rd, $Rn, $Rm",
643 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000644 Requires<[IsThumb2]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000645 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000646 let Inst{31-27} = 0b11101;
647 let Inst{26-25} = 0b01;
648 let Inst{24-21} = opcod;
649 let Inst{20} = 0; // The S bit.
650 let Inst{14-12} = 0b000; // imm3
651 let Inst{7-6} = 0b00; // imm2
652 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000653 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000654 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000655 def rs : T2sTwoRegShiftedReg<
Owen Anderson5de6d842010-11-12 21:12:40 +0000656 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
657 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
658 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000659 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000660 let Inst{31-27} = 0b11101;
661 let Inst{26-25} = 0b01;
662 let Inst{24-21} = opcod;
663 let Inst{20} = 0; // The S bit.
664 }
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000665}
666
667// Carry setting variants
668let Defs = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000669multiclass T2I_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
670 bit Commutable = 0> {
Evan Cheng62674222009-06-25 23:34:10 +0000671 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000672 def ri : T2sTwoRegImm<
Owen Anderson5de6d842010-11-12 21:12:40 +0000673 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
674 opc, "\t$Rd, $Rn, $imm",
675 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000676 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000677 let Inst{31-27} = 0b11110;
678 let Inst{25} = 0;
679 let Inst{24-21} = opcod;
680 let Inst{20} = 1; // The S bit.
681 let Inst{15} = 0;
682 }
Evan Cheng62674222009-06-25 23:34:10 +0000683 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000684 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
Owen Anderson5de6d842010-11-12 21:12:40 +0000685 opc, ".w\t$Rd, $Rn, $Rm",
686 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000687 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000688 let isCommutable = Commutable;
689 let Inst{31-27} = 0b11101;
690 let Inst{26-25} = 0b01;
691 let Inst{24-21} = opcod;
692 let Inst{20} = 1; // The S bit.
693 let Inst{14-12} = 0b000; // imm3
694 let Inst{7-6} = 0b00; // imm2
695 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000696 }
Evan Cheng62674222009-06-25 23:34:10 +0000697 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000698 def rs : T2sTwoRegShiftedReg<
Owen Anderson5de6d842010-11-12 21:12:40 +0000699 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
700 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
701 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000702 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000703 let Inst{31-27} = 0b11101;
704 let Inst{26-25} = 0b01;
705 let Inst{24-21} = opcod;
706 let Inst{20} = 1; // The S bit.
Evan Cheng8de898a2009-06-26 00:19:44 +0000707 }
Evan Chengf49810c2009-06-23 17:48:47 +0000708}
709}
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000710}
Evan Chengf49810c2009-06-23 17:48:47 +0000711
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000712/// T2I_rbin_s_is - Same as T2I_rbin_irs except sets 's' bit and the register
713/// version is not needed since this is only for codegen.
Evan Cheng1e249e32009-06-25 20:59:23 +0000714let Defs = [CPSR] in {
Johnny Chend68e1192009-12-15 17:24:14 +0000715multiclass T2I_rbin_s_is<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000716 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000717 def ri : T2TwoRegImm<
718 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
719 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $imm",
720 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000721 let Inst{31-27} = 0b11110;
722 let Inst{25} = 0;
723 let Inst{24-21} = opcod;
724 let Inst{20} = 1; // The S bit.
725 let Inst{15} = 0;
726 }
Evan Chengf49810c2009-06-23 17:48:47 +0000727 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000728 def rs : T2TwoRegShiftedReg<
729 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
730 IIC_iALUsi, !strconcat(opc, "s"), "\t$Rd, $Rn, $ShiftedRm",
731 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000732 let Inst{31-27} = 0b11101;
733 let Inst{26-25} = 0b01;
734 let Inst{24-21} = opcod;
735 let Inst{20} = 1; // The S bit.
736 }
Evan Chengf49810c2009-06-23 17:48:47 +0000737}
738}
739
Evan Chenga67efd12009-06-23 19:39:13 +0000740/// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
741// rotate operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000742multiclass T2I_sh_ir<bits<2> opcod, string opc, PatFrag opnode> {
Evan Chenga67efd12009-06-23 19:39:13 +0000743 // 5-bit imm
Owen Andersonbb6315d2010-11-15 19:58:36 +0000744 def ri : T2sTwoRegShiftImm<
745 (outs rGPR:$Rd), (ins rGPR:$Rm, i32imm:$imm), IIC_iMOVsi,
746 opc, ".w\t$Rd, $Rm, $imm",
747 [(set rGPR:$Rd, (opnode rGPR:$Rm, imm1_31:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000748 let Inst{31-27} = 0b11101;
749 let Inst{26-21} = 0b010010;
750 let Inst{19-16} = 0b1111; // Rn
751 let Inst{5-4} = opcod;
752 }
Evan Chenga67efd12009-06-23 19:39:13 +0000753 // register
Owen Andersonbb6315d2010-11-15 19:58:36 +0000754 def rr : T2sThreeReg<
755 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMOVsr,
756 opc, ".w\t$Rd, $Rn, $Rm",
757 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000758 let Inst{31-27} = 0b11111;
759 let Inst{26-23} = 0b0100;
760 let Inst{22-21} = opcod;
761 let Inst{15-12} = 0b1111;
762 let Inst{7-4} = 0b0000;
763 }
Evan Chenga67efd12009-06-23 19:39:13 +0000764}
Evan Chengf49810c2009-06-23 17:48:47 +0000765
Johnny Chend68e1192009-12-15 17:24:14 +0000766/// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
Evan Chenga67efd12009-06-23 19:39:13 +0000767/// patterns. Similar to T2I_bin_irs except the instruction does not produce
Evan Chengf49810c2009-06-23 17:48:47 +0000768/// a explicit result, only implicitly set CPSR.
Bill Wendlingf0e132c2010-08-19 00:05:48 +0000769let isCompare = 1, Defs = [CPSR] in {
Evan Cheng5d42c562010-09-29 00:49:25 +0000770multiclass T2I_cmp_irs<bits<4> opcod, string opc,
771 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
772 PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000773 // shifted imm
Owen Andersonbb6315d2010-11-15 19:58:36 +0000774 def ri : T2OneRegCmpImm<
775 (outs), (ins GPR:$Rn, t2_so_imm:$imm), iii,
776 opc, ".w\t$Rn, $imm",
777 [(opnode GPR:$Rn, t2_so_imm:$imm)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000778 let Inst{31-27} = 0b11110;
779 let Inst{25} = 0;
780 let Inst{24-21} = opcod;
781 let Inst{20} = 1; // The S bit.
782 let Inst{15} = 0;
783 let Inst{11-8} = 0b1111; // Rd
784 }
Evan Chenga67efd12009-06-23 19:39:13 +0000785 // register
Owen Andersonbb6315d2010-11-15 19:58:36 +0000786 def rr : T2TwoRegCmp<
787 (outs), (ins GPR:$lhs, rGPR:$rhs), iir,
Evan Cheng699beba2009-10-27 00:08:59 +0000788 opc, ".w\t$lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000789 [(opnode GPR:$lhs, rGPR:$rhs)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000790 let Inst{31-27} = 0b11101;
791 let Inst{26-25} = 0b01;
792 let Inst{24-21} = opcod;
793 let Inst{20} = 1; // The S bit.
794 let Inst{14-12} = 0b000; // imm3
795 let Inst{11-8} = 0b1111; // Rd
796 let Inst{7-6} = 0b00; // imm2
797 let Inst{5-4} = 0b00; // type
798 }
Evan Chengf49810c2009-06-23 17:48:47 +0000799 // shifted register
Owen Andersonbb6315d2010-11-15 19:58:36 +0000800 def rs : T2OneRegCmpShiftedReg<
801 (outs), (ins GPR:$Rn, t2_so_reg:$ShiftedRm), iis,
802 opc, ".w\t$Rn, $ShiftedRm",
803 [(opnode GPR:$Rn, t2_so_reg:$ShiftedRm)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000804 let Inst{31-27} = 0b11101;
805 let Inst{26-25} = 0b01;
806 let Inst{24-21} = opcod;
807 let Inst{20} = 1; // The S bit.
808 let Inst{11-8} = 0b1111; // Rd
809 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000810}
811}
812
Evan Chengf3c21b82009-06-30 02:15:48 +0000813/// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000814multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
Evan Cheng7e2fe912010-10-28 06:47:08 +0000815 InstrItinClass iii, InstrItinClass iis, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +0000816 def i12 : T2Ii12<(outs GPR:$dst), (ins t2addrmode_imm12:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000817 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000818 [(set GPR:$dst, (opnode t2addrmode_imm12:$addr))]> {
819 let Inst{31-27} = 0b11111;
820 let Inst{26-25} = 0b00;
821 let Inst{24} = signed;
822 let Inst{23} = 1;
823 let Inst{22-21} = opcod;
824 let Inst{20} = 1; // load
825 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000826 def i8 : T2Ii8 <(outs GPR:$dst), (ins t2addrmode_imm8:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000827 opc, "\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000828 [(set GPR:$dst, (opnode t2addrmode_imm8:$addr))]> {
829 let Inst{31-27} = 0b11111;
830 let Inst{26-25} = 0b00;
831 let Inst{24} = signed;
832 let Inst{23} = 0;
833 let Inst{22-21} = opcod;
834 let Inst{20} = 1; // load
835 let Inst{11} = 1;
836 // Offset: index==TRUE, wback==FALSE
837 let Inst{10} = 1; // The P bit.
838 let Inst{8} = 0; // The W bit.
839 }
Evan Cheng7e2fe912010-10-28 06:47:08 +0000840 def s : T2Iso <(outs GPR:$dst), (ins t2addrmode_so_reg:$addr), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000841 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000842 [(set GPR:$dst, (opnode t2addrmode_so_reg:$addr))]> {
843 let Inst{31-27} = 0b11111;
844 let Inst{26-25} = 0b00;
845 let Inst{24} = signed;
846 let Inst{23} = 0;
847 let Inst{22-21} = opcod;
848 let Inst{20} = 1; // load
849 let Inst{11-6} = 0b000000;
850 }
Evan Chengbc7deb02010-11-03 05:14:24 +0000851
852 // FIXME: Is the pci variant actually needed?
Evan Cheng0e55fd62010-09-30 01:08:25 +0000853 def pci : T2Ipc <(outs GPR:$dst), (ins i32imm:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000854 opc, ".w\t$dst, $addr",
Evan Cheng9eda6892009-10-31 03:39:36 +0000855 [(set GPR:$dst, (opnode (ARMWrapper tconstpool:$addr)))]> {
856 let isReMaterializable = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000857 let Inst{31-27} = 0b11111;
858 let Inst{26-25} = 0b00;
859 let Inst{24} = signed;
860 let Inst{23} = ?; // add = (U == '1')
861 let Inst{22-21} = opcod;
862 let Inst{20} = 1; // load
863 let Inst{19-16} = 0b1111; // Rn
Evan Cheng9eda6892009-10-31 03:39:36 +0000864 }
Evan Chengf3c21b82009-06-30 02:15:48 +0000865}
866
David Goodwin73b8f162009-06-30 22:11:34 +0000867/// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000868multiclass T2I_st<bits<2> opcod, string opc,
Evan Cheng7e2fe912010-10-28 06:47:08 +0000869 InstrItinClass iii, InstrItinClass iis, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +0000870 def i12 : T2Ii12<(outs), (ins GPR:$src, t2addrmode_imm12:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000871 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000872 [(opnode GPR:$src, t2addrmode_imm12:$addr)]> {
873 let Inst{31-27} = 0b11111;
874 let Inst{26-23} = 0b0001;
875 let Inst{22-21} = opcod;
876 let Inst{20} = 0; // !load
877 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000878 def i8 : T2Ii8 <(outs), (ins GPR:$src, t2addrmode_imm8:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000879 opc, "\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000880 [(opnode GPR:$src, t2addrmode_imm8:$addr)]> {
881 let Inst{31-27} = 0b11111;
882 let Inst{26-23} = 0b0000;
883 let Inst{22-21} = opcod;
884 let Inst{20} = 0; // !load
885 let Inst{11} = 1;
886 // Offset: index==TRUE, wback==FALSE
887 let Inst{10} = 1; // The P bit.
888 let Inst{8} = 0; // The W bit.
889 }
Evan Cheng7e2fe912010-10-28 06:47:08 +0000890 def s : T2Iso <(outs), (ins GPR:$src, t2addrmode_so_reg:$addr), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000891 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000892 [(opnode GPR:$src, t2addrmode_so_reg:$addr)]> {
893 let Inst{31-27} = 0b11111;
894 let Inst{26-23} = 0b0000;
895 let Inst{22-21} = opcod;
896 let Inst{20} = 0; // !load
897 let Inst{11-6} = 0b000000;
898 }
David Goodwin73b8f162009-06-30 22:11:34 +0000899}
900
Evan Cheng0e55fd62010-09-30 01:08:25 +0000901/// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +0000902/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000903multiclass T2I_ext_rrot<bits<3> opcod, string opc, PatFrag opnode> {
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000904 def r : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iEXTr,
905 opc, ".w\t$Rd, $Rm",
906 [(set rGPR:$Rd, (opnode rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000907 let Inst{31-27} = 0b11111;
908 let Inst{26-23} = 0b0100;
909 let Inst{22-20} = opcod;
910 let Inst{19-16} = 0b1111; // Rn
911 let Inst{15-12} = 0b1111;
912 let Inst{7} = 1;
913 let Inst{5-4} = 0b00; // rotate
914 }
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000915 def r_rot : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, i32imm:$rot), IIC_iEXTr,
916 opc, ".w\t$Rd, $Rm, ror $rot",
917 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000918 let Inst{31-27} = 0b11111;
919 let Inst{26-23} = 0b0100;
920 let Inst{22-20} = opcod;
921 let Inst{19-16} = 0b1111; // Rn
922 let Inst{15-12} = 0b1111;
923 let Inst{7} = 1;
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000924
925 bits<2> rot;
926 let Inst{5-4} = rot{1-0}; // rotate
Johnny Chend68e1192009-12-15 17:24:14 +0000927 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000928}
929
Eli Friedman761fa7a2010-06-24 18:20:04 +0000930// UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000931multiclass T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode> {
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000932 def r : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iEXTr,
933 opc, "\t$Rd, $Rm",
934 [(set rGPR:$Rd, (opnode rGPR:$Rm))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000935 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000936 let Inst{31-27} = 0b11111;
937 let Inst{26-23} = 0b0100;
938 let Inst{22-20} = opcod;
939 let Inst{19-16} = 0b1111; // Rn
940 let Inst{15-12} = 0b1111;
941 let Inst{7} = 1;
942 let Inst{5-4} = 0b00; // rotate
943 }
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000944 def r_rot : T2TwoReg<(outs rGPR:$dst), (ins rGPR:$Rm, i32imm:$rot), IIC_iEXTr,
945 opc, "\t$dst, $Rm, ror $rot",
946 [(set rGPR:$dst, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000947 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000948 let Inst{31-27} = 0b11111;
949 let Inst{26-23} = 0b0100;
950 let Inst{22-20} = opcod;
951 let Inst{19-16} = 0b1111; // Rn
952 let Inst{15-12} = 0b1111;
953 let Inst{7} = 1;
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000954
955 bits<2> rot;
956 let Inst{5-4} = rot{1-0}; // rotate
Johnny Chen267124c2010-03-04 22:24:41 +0000957 }
958}
959
Eli Friedman761fa7a2010-06-24 18:20:04 +0000960// SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
961// supported yet.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000962multiclass T2I_ext_rrot_sxtb16<bits<3> opcod, string opc> {
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000963 def r : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iEXTr,
964 opc, "\t$Rd, $Rm", []> {
Johnny Chen93042d12010-03-02 18:14:57 +0000965 let Inst{31-27} = 0b11111;
966 let Inst{26-23} = 0b0100;
967 let Inst{22-20} = opcod;
968 let Inst{19-16} = 0b1111; // Rn
969 let Inst{15-12} = 0b1111;
970 let Inst{7} = 1;
971 let Inst{5-4} = 0b00; // rotate
972 }
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000973 def r_rot : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, i32imm:$rot), IIC_iEXTr,
974 opc, "\t$Rd, $Rm, ror $rot", []> {
Johnny Chen93042d12010-03-02 18:14:57 +0000975 let Inst{31-27} = 0b11111;
976 let Inst{26-23} = 0b0100;
977 let Inst{22-20} = opcod;
978 let Inst{19-16} = 0b1111; // Rn
979 let Inst{15-12} = 0b1111;
980 let Inst{7} = 1;
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000981
982 bits<2> rot;
983 let Inst{5-4} = rot{1-0}; // rotate
Johnny Chen93042d12010-03-02 18:14:57 +0000984 }
985}
986
Evan Cheng0e55fd62010-09-30 01:08:25 +0000987/// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +0000988/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000989multiclass T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode> {
Owen Anderson2c4c45d2010-11-15 21:12:05 +0000990 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iEXTAr,
991 opc, "\t$Rd, $Rn, $Rm",
992 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000993 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000994 let Inst{31-27} = 0b11111;
995 let Inst{26-23} = 0b0100;
996 let Inst{22-20} = opcod;
997 let Inst{15-12} = 0b1111;
998 let Inst{7} = 1;
999 let Inst{5-4} = 0b00; // rotate
1000 }
Owen Anderson2c4c45d2010-11-15 21:12:05 +00001001 def rr_rot : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, i32imm:$rot),
1002 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm, ror $rot",
1003 [(set rGPR:$Rd, (opnode rGPR:$Rn,
1004 (rotr rGPR:$Rm, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001005 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001006 let Inst{31-27} = 0b11111;
1007 let Inst{26-23} = 0b0100;
1008 let Inst{22-20} = opcod;
1009 let Inst{15-12} = 0b1111;
1010 let Inst{7} = 1;
Owen Anderson2c4c45d2010-11-15 21:12:05 +00001011
1012 bits<2> rot;
1013 let Inst{5-4} = rot{1-0}; // rotate
Johnny Chend68e1192009-12-15 17:24:14 +00001014 }
Evan Chengd27c9fc2009-07-03 01:43:10 +00001015}
1016
Johnny Chen93042d12010-03-02 18:14:57 +00001017// DO variant - disassembly only, no pattern
1018
Evan Cheng0e55fd62010-09-30 01:08:25 +00001019multiclass T2I_exta_rrot_DO<bits<3> opcod, string opc> {
Owen Anderson2c4c45d2010-11-15 21:12:05 +00001020 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iEXTAr,
1021 opc, "\t$Rd, $Rn, $Rm", []> {
Johnny Chen93042d12010-03-02 18:14:57 +00001022 let Inst{31-27} = 0b11111;
1023 let Inst{26-23} = 0b0100;
1024 let Inst{22-20} = opcod;
1025 let Inst{15-12} = 0b1111;
1026 let Inst{7} = 1;
1027 let Inst{5-4} = 0b00; // rotate
1028 }
Owen Anderson2c4c45d2010-11-15 21:12:05 +00001029 def rr_rot : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, i32imm:$rot),
1030 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm, ror $rot", []> {
Johnny Chen93042d12010-03-02 18:14:57 +00001031 let Inst{31-27} = 0b11111;
1032 let Inst{26-23} = 0b0100;
1033 let Inst{22-20} = opcod;
1034 let Inst{15-12} = 0b1111;
1035 let Inst{7} = 1;
Owen Anderson2c4c45d2010-11-15 21:12:05 +00001036
1037 bits<2> rot;
1038 let Inst{5-4} = rot{1-0}; // rotate
Johnny Chen93042d12010-03-02 18:14:57 +00001039 }
1040}
1041
Anton Korobeynikov52237112009-06-17 18:13:58 +00001042//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +00001043// Instructions
1044//===----------------------------------------------------------------------===//
1045
1046//===----------------------------------------------------------------------===//
Evan Chenga09b9ca2009-06-24 23:47:58 +00001047// Miscellaneous Instructions.
1048//
1049
Evan Chenga09b9ca2009-06-24 23:47:58 +00001050// LEApcrel - Load a pc-relative address into a register without offending the
1051// assembler.
Evan Chengea420b22010-05-19 01:52:25 +00001052let neverHasSideEffects = 1 in {
Evan Cheng9085f982010-05-19 07:28:01 +00001053let isReMaterializable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001054def t2LEApcrel : T2XI<(outs rGPR:$dst), (ins i32imm:$label, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +00001055 "adr${p}.w\t$dst, #$label", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001056 let Inst{31-27} = 0b11110;
1057 let Inst{25-24} = 0b10;
1058 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1059 let Inst{22} = 0;
1060 let Inst{20} = 0;
1061 let Inst{19-16} = 0b1111; // Rn
1062 let Inst{15} = 0;
1063}
Jim Grosbacha967d112010-06-21 21:27:27 +00001064} // neverHasSideEffects
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001065def t2LEApcrelJT : T2XI<(outs rGPR:$dst),
Bob Wilson4f38b382009-08-21 21:58:55 +00001066 (ins i32imm:$label, nohash_imm:$id, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +00001067 "adr${p}.w\t$dst, #${label}_${id}", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001068 let Inst{31-27} = 0b11110;
1069 let Inst{25-24} = 0b10;
1070 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1071 let Inst{22} = 0;
1072 let Inst{20} = 0;
1073 let Inst{19-16} = 0b1111; // Rn
1074 let Inst{15} = 0;
1075}
Evan Chenga09b9ca2009-06-24 23:47:58 +00001076
Evan Cheng86198642009-08-07 00:34:42 +00001077// ADD r, sp, {so_imm|i12}
Owen Andersonb9a643e2010-11-12 23:36:03 +00001078def t2ADDrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
1079 IIC_iALUi, "add", ".w\t$dst, $sp, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001080 let Inst{31-27} = 0b11110;
1081 let Inst{25} = 0;
1082 let Inst{24-21} = 0b1000;
1083 let Inst{20} = ?; // The S bit.
Owen Andersonb9a643e2010-11-12 23:36:03 +00001084 let Inst{19-16} = 0b1101; // Rn = sp
Johnny Chend68e1192009-12-15 17:24:14 +00001085 let Inst{15} = 0;
1086}
Owen Andersonb9a643e2010-11-12 23:36:03 +00001087def t2ADDrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
1088 IIC_iALUi, "addw", "\t$dst, $sp, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001089 let Inst{31-27} = 0b11110;
1090 let Inst{25} = 1;
1091 let Inst{24-21} = 0b0000;
1092 let Inst{20} = 0; // The S bit.
1093 let Inst{19-16} = 0b1101; // Rn = sp
1094 let Inst{15} = 0;
1095}
Evan Cheng86198642009-08-07 00:34:42 +00001096
1097// ADD r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +00001098def t2ADDrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00001099 IIC_iALUsi, "add", ".w\t$dst, $sp, $rhs", []> {
1100 let Inst{31-27} = 0b11101;
1101 let Inst{26-25} = 0b01;
1102 let Inst{24-21} = 0b1000;
1103 let Inst{20} = ?; // The S bit.
1104 let Inst{19-16} = 0b1101; // Rn = sp
1105 let Inst{15} = 0;
1106}
Evan Cheng86198642009-08-07 00:34:42 +00001107
1108// SUB r, sp, {so_imm|i12}
David Goodwin5d598aa2009-08-19 18:00:44 +00001109def t2SUBrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +00001110 IIC_iALUi, "sub", ".w\t$dst, $sp, $imm", []> {
1111 let Inst{31-27} = 0b11110;
1112 let Inst{25} = 0;
1113 let Inst{24-21} = 0b1101;
1114 let Inst{20} = ?; // The S bit.
1115 let Inst{19-16} = 0b1101; // Rn = sp
1116 let Inst{15} = 0;
1117}
David Goodwin5d598aa2009-08-19 18:00:44 +00001118def t2SUBrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +00001119 IIC_iALUi, "subw", "\t$dst, $sp, $imm", []> {
1120 let Inst{31-27} = 0b11110;
1121 let Inst{25} = 1;
1122 let Inst{24-21} = 0b0101;
1123 let Inst{20} = 0; // The S bit.
1124 let Inst{19-16} = 0b1101; // Rn = sp
1125 let Inst{15} = 0;
1126}
Evan Cheng86198642009-08-07 00:34:42 +00001127
1128// SUB r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +00001129def t2SUBrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
1130 IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001131 "sub", "\t$dst, $sp, $rhs", []> {
1132 let Inst{31-27} = 0b11101;
1133 let Inst{26-25} = 0b01;
1134 let Inst{24-21} = 0b1101;
1135 let Inst{20} = ?; // The S bit.
1136 let Inst{19-16} = 0b1101; // Rn = sp
1137 let Inst{15} = 0;
1138}
Evan Cheng86198642009-08-07 00:34:42 +00001139
Jim Grosbachb1dc3932010-05-05 20:44:35 +00001140// Signed and unsigned division on v7-M
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001141def t2SDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +00001142 "sdiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001143 [(set rGPR:$dst, (sdiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +00001144 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +00001145 let Inst{31-27} = 0b11111;
1146 let Inst{26-21} = 0b011100;
1147 let Inst{20} = 0b1;
1148 let Inst{15-12} = 0b1111;
1149 let Inst{7-4} = 0b1111;
1150}
1151
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001152def t2UDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +00001153 "udiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001154 [(set rGPR:$dst, (udiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +00001155 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +00001156 let Inst{31-27} = 0b11111;
1157 let Inst{26-21} = 0b011101;
1158 let Inst{20} = 0b1;
1159 let Inst{15-12} = 0b1111;
1160 let Inst{7-4} = 0b1111;
1161}
1162
Evan Chenga09b9ca2009-06-24 23:47:58 +00001163//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +00001164// Load / store Instructions.
1165//
1166
Evan Cheng055b0312009-06-29 07:51:04 +00001167// Load
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001168let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng7e2fe912010-10-28 06:47:08 +00001169defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001170 UnOpFrag<(load node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001171
Evan Chengf3c21b82009-06-30 02:15:48 +00001172// Loads with zero extension
Evan Cheng7e2fe912010-10-28 06:47:08 +00001173defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001174 UnOpFrag<(zextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001175defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001176 UnOpFrag<(zextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001177
Evan Chengf3c21b82009-06-30 02:15:48 +00001178// Loads with sign extension
Evan Cheng7e2fe912010-10-28 06:47:08 +00001179defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001180 UnOpFrag<(sextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001181defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001182 UnOpFrag<(sextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001183
Chris Lattnera1ca91a2010-11-02 23:40:41 +00001184let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
1185 isCodeGenOnly = 1 in { // $dst doesn't exist in asmstring?
Evan Chengf3c21b82009-06-30 02:15:48 +00001186// Load doubleword
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001187def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Chenge298ab22009-09-27 09:46:04 +00001188 (ins t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001189 IIC_iLoad_d_i, "ldrd", "\t$dst1, $addr", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001190def t2LDRDpci : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001191 (ins i32imm:$addr), IIC_iLoad_d_i,
Johnny Chen83142992010-01-05 22:37:28 +00001192 "ldrd", "\t$dst1, $addr", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001193 let Inst{19-16} = 0b1111; // Rn
1194}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001195} // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
Evan Chengf3c21b82009-06-30 02:15:48 +00001196
1197// zextload i1 -> zextload i8
1198def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1199 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1200def : T2Pat<(zextloadi1 t2addrmode_imm8:$addr),
1201 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1202def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1203 (t2LDRBs t2addrmode_so_reg:$addr)>;
1204def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1205 (t2LDRBpci tconstpool:$addr)>;
1206
1207// extload -> zextload
1208// FIXME: Reduce the number of patterns by legalizing extload to zextload
1209// earlier?
1210def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1211 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1212def : T2Pat<(extloadi1 t2addrmode_imm8:$addr),
1213 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1214def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1215 (t2LDRBs t2addrmode_so_reg:$addr)>;
1216def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1217 (t2LDRBpci tconstpool:$addr)>;
1218
1219def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1220 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1221def : T2Pat<(extloadi8 t2addrmode_imm8:$addr),
1222 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1223def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1224 (t2LDRBs t2addrmode_so_reg:$addr)>;
1225def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1226 (t2LDRBpci tconstpool:$addr)>;
1227
1228def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1229 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1230def : T2Pat<(extloadi16 t2addrmode_imm8:$addr),
1231 (t2LDRHi8 t2addrmode_imm8:$addr)>;
1232def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1233 (t2LDRHs t2addrmode_so_reg:$addr)>;
1234def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1235 (t2LDRHpci tconstpool:$addr)>;
Evan Cheng055b0312009-06-29 07:51:04 +00001236
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001237// FIXME: The destination register of the loads and stores can't be PC, but
1238// can be SP. We need another regclass (similar to rGPR) to represent
1239// that. Not a pressing issue since these are selected manually,
1240// not via pattern.
1241
Evan Chenge88d5ce2009-07-02 07:28:31 +00001242// Indexed loads
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001243let mayLoad = 1, neverHasSideEffects = 1 in {
Johnny Chend68e1192009-12-15 17:24:14 +00001244def t2LDR_PRE : T2Iidxldst<0, 0b10, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001245 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001246 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001247 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001248 []>;
1249
Johnny Chend68e1192009-12-15 17:24:14 +00001250def t2LDR_POST : T2Iidxldst<0, 0b10, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001251 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001252 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001253 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001254 []>;
1255
Johnny Chend68e1192009-12-15 17:24:14 +00001256def t2LDRB_PRE : T2Iidxldst<0, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001257 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001258 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001259 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001260 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001261def t2LDRB_POST : T2Iidxldst<0, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001262 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001263 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001264 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001265 []>;
1266
Johnny Chend68e1192009-12-15 17:24:14 +00001267def t2LDRH_PRE : T2Iidxldst<0, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001268 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001269 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001270 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001271 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001272def t2LDRH_POST : T2Iidxldst<0, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001273 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001274 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001275 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001276 []>;
1277
Johnny Chend68e1192009-12-15 17:24:14 +00001278def t2LDRSB_PRE : T2Iidxldst<1, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001279 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001280 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001281 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001282 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001283def t2LDRSB_POST : T2Iidxldst<1, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001284 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001285 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001286 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001287 []>;
1288
Johnny Chend68e1192009-12-15 17:24:14 +00001289def t2LDRSH_PRE : T2Iidxldst<1, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001290 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001291 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001292 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001293 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001294def t2LDRSH_POST : T2Iidxldst<1, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001295 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001296 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001297 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001298 []>;
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001299} // mayLoad = 1, neverHasSideEffects = 1
Evan Cheng4fbb9962009-07-02 23:16:11 +00001300
Johnny Chene54a3ef2010-03-03 18:45:36 +00001301// LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110) and are
1302// for disassembly only.
1303// Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001304class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1305 : T2Ii8<(outs GPR:$dst), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001306 "\t$dst, $addr", []> {
1307 let Inst{31-27} = 0b11111;
1308 let Inst{26-25} = 0b00;
1309 let Inst{24} = signed;
1310 let Inst{23} = 0;
1311 let Inst{22-21} = type;
1312 let Inst{20} = 1; // load
1313 let Inst{11} = 1;
1314 let Inst{10-8} = 0b110; // PUW.
1315}
1316
Evan Cheng0e55fd62010-09-30 01:08:25 +00001317def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1318def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1319def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1320def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1321def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
Johnny Chene54a3ef2010-03-03 18:45:36 +00001322
David Goodwin73b8f162009-06-30 22:11:34 +00001323// Store
Evan Cheng7e2fe912010-10-28 06:47:08 +00001324defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001325 BinOpFrag<(store node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001326defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001327 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001328defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001329 BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
David Goodwin73b8f162009-06-30 22:11:34 +00001330
David Goodwin6647cea2009-06-30 22:50:01 +00001331// Store doubleword
Chris Lattnera1ca91a2010-11-02 23:40:41 +00001332let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1333 isCodeGenOnly = 1 in // $src2 doesn't exist in asm string
Johnny Chend68e1192009-12-15 17:24:14 +00001334def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
Evan Chenge298ab22009-09-27 09:46:04 +00001335 (ins GPR:$src1, GPR:$src2, t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001336 IIC_iStore_d_r, "strd", "\t$src1, $addr", []>;
David Goodwin6647cea2009-06-30 22:50:01 +00001337
Evan Cheng6d94f112009-07-03 00:06:39 +00001338// Indexed stores
Johnny Chend68e1192009-12-15 17:24:14 +00001339def t2STR_PRE : T2Iidxldst<0, 0b10, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001340 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001341 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001342 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001343 [(set GPR:$base_wb,
1344 (pre_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1345
Johnny Chend68e1192009-12-15 17:24:14 +00001346def t2STR_POST : T2Iidxldst<0, 0b10, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001347 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001348 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001349 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001350 [(set GPR:$base_wb,
Jim Grosbach6935efc2009-11-24 00:20:27 +00001351 (post_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001352
Johnny Chend68e1192009-12-15 17:24:14 +00001353def t2STRH_PRE : T2Iidxldst<0, 0b01, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001354 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001355 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001356 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001357 [(set GPR:$base_wb,
1358 (pre_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1359
Johnny Chend68e1192009-12-15 17:24:14 +00001360def t2STRH_POST : T2Iidxldst<0, 0b01, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001361 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001362 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001363 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001364 [(set GPR:$base_wb,
1365 (post_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1366
Johnny Chend68e1192009-12-15 17:24:14 +00001367def t2STRB_PRE : T2Iidxldst<0, 0b00, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001368 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001369 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001370 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001371 [(set GPR:$base_wb,
1372 (pre_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1373
Johnny Chend68e1192009-12-15 17:24:14 +00001374def t2STRB_POST : T2Iidxldst<0, 0b00, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001375 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001376 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001377 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001378 [(set GPR:$base_wb,
1379 (post_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1380
Johnny Chene54a3ef2010-03-03 18:45:36 +00001381// STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1382// only.
1383// Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001384class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1385 : T2Ii8<(outs GPR:$src), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001386 "\t$src, $addr", []> {
1387 let Inst{31-27} = 0b11111;
1388 let Inst{26-25} = 0b00;
1389 let Inst{24} = 0; // not signed
1390 let Inst{23} = 0;
1391 let Inst{22-21} = type;
1392 let Inst{20} = 0; // store
1393 let Inst{11} = 1;
1394 let Inst{10-8} = 0b110; // PUW
1395}
1396
Evan Cheng0e55fd62010-09-30 01:08:25 +00001397def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1398def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1399def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
David Goodwind1fa1202009-07-01 00:01:13 +00001400
Johnny Chenae1757b2010-03-11 01:13:36 +00001401// ldrd / strd pre / post variants
1402// For disassembly only.
1403
1404def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001405 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001406 "ldrd", "\t$dst1, $dst2, [$base, $imm]!", []>;
1407
1408def t2LDRD_POST : T2Ii8s4<0, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001409 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001410 "ldrd", "\t$dst1, $dst2, [$base], $imm", []>;
1411
1412def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs),
1413 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001414 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base, $imm]!", []>;
Johnny Chenae1757b2010-03-11 01:13:36 +00001415
1416def t2STRD_POST : T2Ii8s4<0, 1, 0, (outs),
1417 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001418 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base], $imm", []>;
Evan Cheng2889cce2009-07-03 00:18:36 +00001419
Johnny Chen0635fc52010-03-04 17:40:44 +00001420// T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1421// data/instruction access. These are for disassembly only.
Evan Chengdfed19f2010-11-03 06:34:55 +00001422// instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1423// (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
Evan Cheng416941d2010-11-04 05:19:35 +00001424multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001425
Evan Chengdfed19f2010-11-03 06:34:55 +00001426 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001427 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001428 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001429 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001430 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001431 let Inst{23} = 1; // U = 1
1432 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001433 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001434 let Inst{20} = 1;
1435 let Inst{15-12} = 0b1111;
1436 }
1437
Evan Chengdfed19f2010-11-03 06:34:55 +00001438 def i8 : T2Ii8<(outs), (ins t2addrmode_imm8:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001439 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001440 [(ARMPreload t2addrmode_imm8:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001441 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001442 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001443 let Inst{23} = 0; // U = 0
1444 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001445 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001446 let Inst{20} = 1;
1447 let Inst{15-12} = 0b1111;
1448 let Inst{11-8} = 0b1100;
1449 }
1450
Evan Chengdfed19f2010-11-03 06:34:55 +00001451 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001452 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001453 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
Evan Chengbc7deb02010-11-03 05:14:24 +00001454 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001455 let Inst{24} = instr;
Evan Chengbc7deb02010-11-03 05:14:24 +00001456 let Inst{23} = 0; // add = TRUE for T1
1457 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001458 let Inst{21} = write;
Evan Chengbc7deb02010-11-03 05:14:24 +00001459 let Inst{20} = 1;
1460 let Inst{15-12} = 0b1111;
1461 let Inst{11-6} = 0000000;
1462 }
1463
1464 let isCodeGenOnly = 1 in
Evan Chengdfed19f2010-11-03 06:34:55 +00001465 def pci : T2Ipc<(outs), (ins i32imm:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001466 "\t$addr",
1467 []> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001468 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001469 let Inst{24} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001470 let Inst{23} = ?; // add = (U == 1)
1471 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001472 let Inst{21} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001473 let Inst{20} = 1;
1474 let Inst{19-16} = 0b1111; // Rn = 0b1111
1475 let Inst{15-12} = 0b1111;
1476 }
Johnny Chen0635fc52010-03-04 17:40:44 +00001477}
1478
Evan Cheng416941d2010-11-04 05:19:35 +00001479defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1480defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1481defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
Johnny Chen0635fc52010-03-04 17:40:44 +00001482
Evan Cheng2889cce2009-07-03 00:18:36 +00001483//===----------------------------------------------------------------------===//
1484// Load / store multiple Instructions.
1485//
1486
Bill Wendling6c470b82010-11-13 09:09:38 +00001487multiclass thumb2_ldst_mult<string asm, InstrItinClass itin,
1488 InstrItinClass itin_upd, bit L_bit> {
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001489 def ia :
Bill Wendling6c470b82010-11-13 09:09:38 +00001490 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1491 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
1492 bits<4> Rn;
1493 bits<16> regs;
1494
1495 let Inst{31-27} = 0b11101;
1496 let Inst{26-25} = 0b00;
1497 let Inst{24-23} = 0b01; // Increment After
1498 let Inst{22} = 0;
1499 let Inst{21} = 0; // No writeback
1500 let Inst{20} = L_bit;
1501 let Inst{19-16} = Rn;
1502 let Inst{15-0} = regs;
1503 }
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001504 def ia_UPD :
Bill Wendling6c470b82010-11-13 09:09:38 +00001505 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1506 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1507 bits<4> Rn;
1508 bits<16> regs;
1509
1510 let Inst{31-27} = 0b11101;
1511 let Inst{26-25} = 0b00;
1512 let Inst{24-23} = 0b01; // Increment After
1513 let Inst{22} = 0;
1514 let Inst{21} = 1; // Writeback
1515 let Inst{20} = L_bit;
1516 let Inst{19-16} = Rn;
1517 let Inst{15-0} = regs;
1518 }
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001519 def db :
Bill Wendling6c470b82010-11-13 09:09:38 +00001520 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1521 itin, !strconcat(asm, "db${p}.w\t$Rn, $regs"), []> {
1522 bits<4> Rn;
1523 bits<16> regs;
1524
1525 let Inst{31-27} = 0b11101;
1526 let Inst{26-25} = 0b00;
1527 let Inst{24-23} = 0b10; // Decrement Before
1528 let Inst{22} = 0;
1529 let Inst{21} = 0; // No writeback
1530 let Inst{20} = L_bit;
1531 let Inst{19-16} = Rn;
1532 let Inst{15-0} = regs;
1533 }
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001534 def db_UPD :
Bill Wendling6c470b82010-11-13 09:09:38 +00001535 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1536 itin_upd, !strconcat(asm, "db${p}.w\t$Rn, $regs"), "$Rn = $wb", []> {
1537 bits<4> Rn;
1538 bits<16> regs;
1539
1540 let Inst{31-27} = 0b11101;
1541 let Inst{26-25} = 0b00;
1542 let Inst{24-23} = 0b10; // Decrement Before
1543 let Inst{22} = 0;
1544 let Inst{21} = 1; // Writeback
1545 let Inst{20} = L_bit;
1546 let Inst{19-16} = Rn;
1547 let Inst{15-0} = regs;
1548 }
1549}
1550
Bill Wendlingc93989a2010-11-13 11:20:05 +00001551/* TODO:
1552let neverHasSideEffects = 1 in {
Bill Wendlingddc918b2010-11-13 10:57:02 +00001553
1554let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1555defm t2LDM : thumb2_ldst_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>;
1556
1557let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1558defm t2STM : thumb2_ldst_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>;
1559
1560} // neverHasSideEffects
Bill Wendlingc93989a2010-11-13 11:20:05 +00001561*/
Bill Wendlingddc918b2010-11-13 10:57:02 +00001562
Chris Lattner39ee0362010-10-31 19:10:56 +00001563let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
1564 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001565def t2LDM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001566 reglist:$dsts, variable_ops), IIC_iLoad_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001567 "ldm${amode}${p}.w\t$Rn, $dsts", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001568 let Inst{31-27} = 0b11101;
1569 let Inst{26-25} = 0b00;
1570 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1571 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001572 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001573 let Inst{20} = 1; // Load
1574}
Evan Cheng2889cce2009-07-03 00:18:36 +00001575
Jim Grosbache6913602010-11-03 01:01:43 +00001576def t2LDM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001577 reglist:$dsts, variable_ops),
1578 IIC_iLoad_mu,
Jim Grosbache6913602010-11-03 01:01:43 +00001579 "ldm${amode}${p}.w\t$Rn!, $dsts",
1580 "$Rn = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001581 let Inst{31-27} = 0b11101;
1582 let Inst{26-25} = 0b00;
1583 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1584 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001585 let Inst{21} = 1; // The W bit.
1586 let Inst{20} = 1; // Load
1587}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001588} // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001589
Chris Lattner39ee0362010-10-31 19:10:56 +00001590let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1591 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001592def t2STM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001593 reglist:$srcs, variable_ops), IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001594 "stm${amode}${p}.w\t$Rn, $srcs", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +00001595 let Inst{31-27} = 0b11101;
1596 let Inst{26-25} = 0b00;
1597 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1598 let Inst{22} = 0;
1599 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001600 let Inst{20} = 0; // Store
1601}
Evan Cheng2889cce2009-07-03 00:18:36 +00001602
Jim Grosbache6913602010-11-03 01:01:43 +00001603def t2STM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +00001604 reglist:$srcs, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00001605 IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001606 "stm${amode}${p}.w\t$Rn!, $srcs",
1607 "$Rn = $wb", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +00001608 let Inst{31-27} = 0b11101;
1609 let Inst{26-25} = 0b00;
1610 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1611 let Inst{22} = 0;
1612 let Inst{21} = 1; // The W bit.
1613 let Inst{20} = 0; // Store
1614}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001615} // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001616
Evan Cheng9cb9e672009-06-27 02:26:13 +00001617//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001618// Move Instructions.
1619//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001620
Evan Chengf49810c2009-06-23 17:48:47 +00001621let neverHasSideEffects = 1 in
David Goodwin5d598aa2009-08-19 18:00:44 +00001622def t2MOVr : T2sI<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVr,
Johnny Chend68e1192009-12-15 17:24:14 +00001623 "mov", ".w\t$dst, $src", []> {
1624 let Inst{31-27} = 0b11101;
1625 let Inst{26-25} = 0b01;
1626 let Inst{24-21} = 0b0010;
1627 let Inst{20} = ?; // The S bit.
1628 let Inst{19-16} = 0b1111; // Rn
1629 let Inst{14-12} = 0b000;
1630 let Inst{7-4} = 0b0000;
1631}
Evan Chengf49810c2009-06-23 17:48:47 +00001632
Evan Cheng5adb66a2009-09-28 09:14:39 +00001633// AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1634let isReMaterializable = 1, isAsCheapAsAMove = 1, AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001635def t2MOVi : T2sI<(outs rGPR:$dst), (ins t2_so_imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001636 "mov", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001637 [(set rGPR:$dst, t2_so_imm:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001638 let Inst{31-27} = 0b11110;
1639 let Inst{25} = 0;
1640 let Inst{24-21} = 0b0010;
1641 let Inst{20} = ?; // The S bit.
1642 let Inst{19-16} = 0b1111; // Rn
1643 let Inst{15} = 0;
1644}
David Goodwin83b35932009-06-26 16:10:07 +00001645
1646let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001647def t2MOVi16 : T2I<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001648 "movw", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001649 [(set rGPR:$dst, imm0_65535:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001650 let Inst{31-27} = 0b11110;
1651 let Inst{25} = 1;
1652 let Inst{24-21} = 0b0010;
1653 let Inst{20} = 0; // The S bit.
1654 let Inst{15} = 0;
1655}
Evan Chengf49810c2009-06-23 17:48:47 +00001656
Evan Cheng3850a6a2009-06-23 05:23:49 +00001657let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001658def t2MOVTi16 : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$imm), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001659 "movt", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001660 [(set rGPR:$dst,
1661 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001662 let Inst{31-27} = 0b11110;
1663 let Inst{25} = 1;
1664 let Inst{24-21} = 0b0110;
1665 let Inst{20} = 0; // The S bit.
1666 let Inst{15} = 0;
1667}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001668
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001669def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
Evan Cheng20956592009-10-21 08:15:52 +00001670
Anton Korobeynikov52237112009-06-17 18:13:58 +00001671//===----------------------------------------------------------------------===//
Evan Chengd27c9fc2009-07-03 01:43:10 +00001672// Extend Instructions.
1673//
1674
1675// Sign extenders
1676
Evan Cheng0e55fd62010-09-30 01:08:25 +00001677defm t2SXTB : T2I_ext_rrot<0b100, "sxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001678 UnOpFrag<(sext_inreg node:$Src, i8)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001679defm t2SXTH : T2I_ext_rrot<0b000, "sxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001680 UnOpFrag<(sext_inreg node:$Src, i16)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001681defm t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001682
Evan Cheng0e55fd62010-09-30 01:08:25 +00001683defm t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001684 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001685defm t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001686 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001687defm t2SXTAB16 : T2I_exta_rrot_DO<0b010, "sxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001688
Johnny Chen93042d12010-03-02 18:14:57 +00001689// TODO: SXT(A){B|H}16 - done for disassembly only
Evan Chengd27c9fc2009-07-03 01:43:10 +00001690
1691// Zero extenders
1692
1693let AddedComplexity = 16 in {
Evan Cheng0e55fd62010-09-30 01:08:25 +00001694defm t2UXTB : T2I_ext_rrot<0b101, "uxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001695 UnOpFrag<(and node:$Src, 0x000000FF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001696defm t2UXTH : T2I_ext_rrot<0b001, "uxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001697 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001698defm t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
Johnny Chend68e1192009-12-15 17:24:14 +00001699 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001700
Jim Grosbach79464942010-07-28 23:17:45 +00001701// FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1702// The transformation should probably be done as a combiner action
1703// instead so we can include a check for masking back in the upper
1704// eight bits of the source into the lower eight bits of the result.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001705//def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001706// (t2UXTB16r_rot rGPR:$Src, 24)>,
1707// Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001708def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001709 (t2UXTB16r_rot rGPR:$Src, 8)>,
1710 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001711
Evan Cheng0e55fd62010-09-30 01:08:25 +00001712defm t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001713 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001714defm t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001715 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001716defm t2UXTAB16 : T2I_exta_rrot_DO<0b011, "uxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001717}
1718
1719//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001720// Arithmetic Instructions.
1721//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001722
Johnny Chend68e1192009-12-15 17:24:14 +00001723defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1724 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1725defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1726 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001727
Evan Chengf49810c2009-06-23 17:48:47 +00001728// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
Johnny Chend68e1192009-12-15 17:24:14 +00001729defm t2ADDS : T2I_bin_s_irs <0b1000, "add",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001730 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001731 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1732defm t2SUBS : T2I_bin_s_irs <0b1101, "sub",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001733 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001734 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001735
Johnny Chend68e1192009-12-15 17:24:14 +00001736defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001737 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00001738defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001739 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001740defm t2ADCS : T2I_adde_sube_s_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001741 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001742defm t2SBCS : T2I_adde_sube_s_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001743 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001744
David Goodwin752aa7d2009-07-27 16:39:05 +00001745// RSB
Bob Wilson20d8e4e2010-08-13 23:24:25 +00001746defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
Johnny Chend68e1192009-12-15 17:24:14 +00001747 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1748defm t2RSBS : T2I_rbin_s_is <0b1110, "rsb",
1749 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001750
1751// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001752// The assume-no-carry-in form uses the negation of the input since add/sub
1753// assume opposite meanings of the carry flag (i.e., carry == !borrow).
1754// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1755// details.
1756// The AddedComplexity preferences the first variant over the others since
1757// it can be shrunk to a 16-bit wide encoding, while the others cannot.
Evan Chengfa2ea1a2009-08-04 01:41:15 +00001758let AddedComplexity = 1 in
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001759def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1760 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1761def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1762 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1763def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1764 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1765let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001766def : T2Pat<(addc rGPR:$src, imm0_255_neg:$imm),
1767 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1768def : T2Pat<(addc rGPR:$src, t2_so_imm_neg:$imm),
1769 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001770// The with-carry-in form matches bitwise not instead of the negation.
1771// Effectively, the inverse interpretation of the carry flag already accounts
1772// for part of the negation.
1773let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001774def : T2Pat<(adde rGPR:$src, imm0_255_not:$imm),
1775 (t2SBCSri rGPR:$src, imm0_255_not:$imm)>;
1776def : T2Pat<(adde rGPR:$src, t2_so_imm_not:$imm),
1777 (t2SBCSri rGPR:$src, t2_so_imm_not:$imm)>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001778
Johnny Chen93042d12010-03-02 18:14:57 +00001779// Select Bytes -- for disassembly only
1780
1781def t2SEL : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), NoItinerary, "sel",
1782 "\t$dst, $a, $b", []> {
1783 let Inst{31-27} = 0b11111;
1784 let Inst{26-24} = 0b010;
1785 let Inst{23} = 0b1;
1786 let Inst{22-20} = 0b010;
1787 let Inst{15-12} = 0b1111;
1788 let Inst{7} = 0b1;
1789 let Inst{6-4} = 0b000;
1790}
1791
Johnny Chenadc77332010-02-26 22:04:29 +00001792// A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1793// And Miscellaneous operations -- for disassembly only
Nate Begeman692433b2010-07-29 17:56:55 +00001794class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
1795 list<dag> pat = [/* For disassembly only; pattern left blank */]>
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001796 : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), NoItinerary, opc,
Nate Begeman692433b2010-07-29 17:56:55 +00001797 "\t$dst, $a, $b", pat> {
Johnny Chenadc77332010-02-26 22:04:29 +00001798 let Inst{31-27} = 0b11111;
1799 let Inst{26-23} = 0b0101;
1800 let Inst{22-20} = op22_20;
1801 let Inst{15-12} = 0b1111;
1802 let Inst{7-4} = op7_4;
1803}
1804
1805// Saturating add/subtract -- for disassembly only
1806
Nate Begeman692433b2010-07-29 17:56:55 +00001807def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001808 [(set rGPR:$dst, (int_arm_qadd rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001809def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
1810def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
1811def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
1812def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd">;
1813def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub">;
1814def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
Nate Begeman692433b2010-07-29 17:56:55 +00001815def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001816 [(set rGPR:$dst, (int_arm_qsub rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001817def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
1818def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
1819def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
1820def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
1821def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
1822def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
1823def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
1824def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
1825
1826// Signed/Unsigned add/subtract -- for disassembly only
1827
1828def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
1829def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
1830def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
1831def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
1832def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
1833def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
1834def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
1835def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
1836def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
1837def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
1838def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
1839def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
1840
1841// Signed/Unsigned halving add/subtract -- for disassembly only
1842
1843def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
1844def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
1845def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
1846def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
1847def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
1848def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
1849def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
1850def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
1851def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
1852def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
1853def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
1854def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
1855
1856// Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
1857
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001858def t2USAD8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1859 (ins rGPR:$a, rGPR:$b),
Johnny Chenadc77332010-02-26 22:04:29 +00001860 NoItinerary, "usad8", "\t$dst, $a, $b", []> {
1861 let Inst{15-12} = 0b1111;
1862}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001863def t2USADA8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1864 (ins rGPR:$a, rGPR:$b, rGPR:$acc), NoItinerary, "usada8",
Johnny Chenadc77332010-02-26 22:04:29 +00001865 "\t$dst, $a, $b, $acc", []>;
1866
1867// Signed/Unsigned saturate -- for disassembly only
1868
Bob Wilson22f5dc72010-08-16 18:27:34 +00001869def t2SSAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001870 NoItinerary, "ssat", "\t$dst, $bit_pos, $a$sh",
1871 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001872 let Inst{31-27} = 0b11110;
1873 let Inst{25-22} = 0b1100;
1874 let Inst{20} = 0;
1875 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001876}
1877
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001878def t2SSAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001879 "ssat16", "\t$dst, $bit_pos, $a",
1880 [/* For disassembly only; pattern left blank */]> {
1881 let Inst{31-27} = 0b11110;
1882 let Inst{25-22} = 0b1100;
1883 let Inst{20} = 0;
1884 let Inst{15} = 0;
1885 let Inst{21} = 1; // sh = '1'
1886 let Inst{14-12} = 0b000; // imm3 = '000'
1887 let Inst{7-6} = 0b00; // imm2 = '00'
1888}
1889
Bob Wilson22f5dc72010-08-16 18:27:34 +00001890def t2USAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001891 NoItinerary, "usat", "\t$dst, $bit_pos, $a$sh",
1892 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001893 let Inst{31-27} = 0b11110;
1894 let Inst{25-22} = 0b1110;
1895 let Inst{20} = 0;
1896 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001897}
1898
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001899def t2USAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001900 "usat16", "\t$dst, $bit_pos, $a",
1901 [/* For disassembly only; pattern left blank */]> {
1902 let Inst{31-27} = 0b11110;
1903 let Inst{25-22} = 0b1110;
1904 let Inst{20} = 0;
1905 let Inst{15} = 0;
1906 let Inst{21} = 1; // sh = '1'
1907 let Inst{14-12} = 0b000; // imm3 = '000'
1908 let Inst{7-6} = 0b00; // imm2 = '00'
1909}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001910
Bob Wilson38aa2872010-08-13 21:48:10 +00001911def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
1912def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
Nate Begeman0e0a20e2010-07-29 22:48:09 +00001913
Evan Chengf49810c2009-06-23 17:48:47 +00001914//===----------------------------------------------------------------------===//
Evan Chenga67efd12009-06-23 19:39:13 +00001915// Shift and rotate Instructions.
1916//
1917
Johnny Chend68e1192009-12-15 17:24:14 +00001918defm t2LSL : T2I_sh_ir<0b00, "lsl", BinOpFrag<(shl node:$LHS, node:$RHS)>>;
1919defm t2LSR : T2I_sh_ir<0b01, "lsr", BinOpFrag<(srl node:$LHS, node:$RHS)>>;
1920defm t2ASR : T2I_sh_ir<0b10, "asr", BinOpFrag<(sra node:$LHS, node:$RHS)>>;
1921defm t2ROR : T2I_sh_ir<0b11, "ror", BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
Evan Chenga67efd12009-06-23 19:39:13 +00001922
David Goodwinca01a8d2009-09-01 18:32:09 +00001923let Uses = [CPSR] in {
Jim Grosbach792e9792010-10-14 20:43:44 +00001924def t2RRX : T2sI<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +00001925 "rrx", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001926 [(set rGPR:$dst, (ARMrrx rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001927 let Inst{31-27} = 0b11101;
1928 let Inst{26-25} = 0b01;
1929 let Inst{24-21} = 0b0010;
1930 let Inst{20} = ?; // The S bit.
1931 let Inst{19-16} = 0b1111; // Rn
1932 let Inst{14-12} = 0b000;
1933 let Inst{7-4} = 0b0011;
1934}
David Goodwinca01a8d2009-09-01 18:32:09 +00001935}
Evan Chenga67efd12009-06-23 19:39:13 +00001936
David Goodwin3583df72009-07-28 17:06:49 +00001937let Defs = [CPSR] in {
Owen Andersonbb6315d2010-11-15 19:58:36 +00001938def t2MOVsrl_flag : T2TwoRegShiftImm<
1939 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
1940 "lsrs", ".w\t$Rd, $Rm, #1",
1941 [(set rGPR:$Rd, (ARMsrl_flag rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001942 let Inst{31-27} = 0b11101;
1943 let Inst{26-25} = 0b01;
1944 let Inst{24-21} = 0b0010;
1945 let Inst{20} = 1; // The S bit.
1946 let Inst{19-16} = 0b1111; // Rn
1947 let Inst{5-4} = 0b01; // Shift type.
1948 // Shift amount = Inst{14-12:7-6} = 1.
1949 let Inst{14-12} = 0b000;
1950 let Inst{7-6} = 0b01;
1951}
Owen Andersonbb6315d2010-11-15 19:58:36 +00001952def t2MOVsra_flag : T2TwoRegShiftImm<
1953 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
1954 "asrs", ".w\t$Rd, $Rm, #1",
1955 [(set rGPR:$Rd, (ARMsra_flag rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001956 let Inst{31-27} = 0b11101;
1957 let Inst{26-25} = 0b01;
1958 let Inst{24-21} = 0b0010;
1959 let Inst{20} = 1; // The S bit.
1960 let Inst{19-16} = 0b1111; // Rn
1961 let Inst{5-4} = 0b10; // Shift type.
1962 // Shift amount = Inst{14-12:7-6} = 1.
1963 let Inst{14-12} = 0b000;
1964 let Inst{7-6} = 0b01;
1965}
David Goodwin3583df72009-07-28 17:06:49 +00001966}
1967
Evan Chenga67efd12009-06-23 19:39:13 +00001968//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +00001969// Bitwise Instructions.
1970//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001971
Johnny Chend68e1192009-12-15 17:24:14 +00001972defm t2AND : T2I_bin_w_irs<0b0000, "and",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001973 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001974 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1975defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001976 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001977 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1978defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001979 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001980 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Evan Chengf49810c2009-06-23 17:48:47 +00001981
Johnny Chend68e1192009-12-15 17:24:14 +00001982defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001983 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001984 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001985
Evan Chengf49810c2009-06-23 17:48:47 +00001986let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001987def t2BFC : T2I<(outs rGPR:$dst), (ins rGPR:$src, bf_inv_mask_imm:$imm),
David Goodwin2f54a2f2009-11-02 17:28:36 +00001988 IIC_iUNAsi, "bfc", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001989 [(set rGPR:$dst, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001990 let Inst{31-27} = 0b11110;
1991 let Inst{25} = 1;
1992 let Inst{24-20} = 0b10110;
1993 let Inst{19-16} = 0b1111; // Rn
1994 let Inst{15} = 0;
1995}
Evan Chengf49810c2009-06-23 17:48:47 +00001996
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001997def t2SBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001998 IIC_iUNAsi, "sbfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001999 let Inst{31-27} = 0b11110;
2000 let Inst{25} = 1;
2001 let Inst{24-20} = 0b10100;
2002 let Inst{15} = 0;
2003}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00002004
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002005def t2UBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00002006 IIC_iUNAsi, "ubfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002007 let Inst{31-27} = 0b11110;
2008 let Inst{25} = 1;
2009 let Inst{24-20} = 0b11100;
2010 let Inst{15} = 0;
2011}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00002012
Johnny Chen9474d552010-02-02 19:31:58 +00002013// A8.6.18 BFI - Bitfield insert (Encoding T1)
Jim Grosbach469bbdb2010-07-16 23:05:05 +00002014let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002015def t2BFI : T2I<(outs rGPR:$dst),
2016 (ins rGPR:$src, rGPR:$val, bf_inv_mask_imm:$imm),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002017 IIC_iBITi, "bfi", "\t$dst, $val, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002018 [(set rGPR:$dst, (ARMbfi rGPR:$src, rGPR:$val,
Jim Grosbach469bbdb2010-07-16 23:05:05 +00002019 bf_inv_mask_imm:$imm))]> {
Johnny Chen9474d552010-02-02 19:31:58 +00002020 let Inst{31-27} = 0b11110;
2021 let Inst{25} = 1;
2022 let Inst{24-20} = 0b10110;
2023 let Inst{15} = 0;
2024}
Evan Chengf49810c2009-06-23 17:48:47 +00002025
Evan Cheng7e1bf302010-09-29 00:27:46 +00002026defm t2ORN : T2I_bin_irs<0b0011, "orn",
2027 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2028 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002029
2030// Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
2031let AddedComplexity = 1 in
Evan Cheng5d42c562010-09-29 00:49:25 +00002032defm t2MVN : T2I_un_irs <0b0011, "mvn",
Evan Cheng3881cb72010-09-29 22:42:35 +00002033 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
Evan Cheng5d42c562010-09-29 00:49:25 +00002034 UnOpFrag<(not node:$Src)>, 1, 1>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002035
2036
Jim Grosbachf084a5e2010-07-20 16:07:04 +00002037let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002038def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
2039 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002040
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002041// FIXME: Disable this pattern on Darwin to workaround an assembler bug.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002042def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
2043 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
Evan Chengea253b92009-08-12 01:56:42 +00002044 Requires<[IsThumb2]>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002045
2046def : T2Pat<(t2_so_imm_not:$src),
2047 (t2MVNi t2_so_imm_not:$src)>;
2048
Evan Chengf49810c2009-06-23 17:48:47 +00002049//===----------------------------------------------------------------------===//
2050// Multiply Instructions.
2051//
Evan Cheng8de898a2009-06-26 00:19:44 +00002052let isCommutable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002053def t2MUL: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00002054 "mul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002055 [(set rGPR:$dst, (mul rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002056 let Inst{31-27} = 0b11111;
2057 let Inst{26-23} = 0b0110;
2058 let Inst{22-20} = 0b000;
2059 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2060 let Inst{7-4} = 0b0000; // Multiply
2061}
Evan Chengf49810c2009-06-23 17:48:47 +00002062
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002063def t2MLA: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00002064 "mla", "\t$dst, $a, $b, $c",
2065 [(set rGPR:$dst, (add (mul rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002066 let Inst{31-27} = 0b11111;
2067 let Inst{26-23} = 0b0110;
2068 let Inst{22-20} = 0b000;
2069 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2070 let Inst{7-4} = 0b0000; // Multiply
2071}
Evan Chengf49810c2009-06-23 17:48:47 +00002072
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002073def t2MLS: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00002074 "mls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002075 [(set rGPR:$dst, (sub rGPR:$c, (mul rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002076 let Inst{31-27} = 0b11111;
2077 let Inst{26-23} = 0b0110;
2078 let Inst{22-20} = 0b000;
2079 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2080 let Inst{7-4} = 0b0001; // Multiply and Subtract
2081}
Evan Chengf49810c2009-06-23 17:48:47 +00002082
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002083// Extra precision multiplies with low / high results
2084let neverHasSideEffects = 1 in {
2085let isCommutable = 1 in {
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002086def t2SMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2087 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00002088 "smull", "\t$ldst, $hdst, $a, $b", []> {
2089 let Inst{31-27} = 0b11111;
2090 let Inst{26-23} = 0b0111;
2091 let Inst{22-20} = 0b000;
2092 let Inst{7-4} = 0b0000;
2093}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002094
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002095def t2UMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2096 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00002097 "umull", "\t$ldst, $hdst, $a, $b", []> {
2098 let Inst{31-27} = 0b11111;
2099 let Inst{26-23} = 0b0111;
2100 let Inst{22-20} = 0b010;
2101 let Inst{7-4} = 0b0000;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002102}
Johnny Chend68e1192009-12-15 17:24:14 +00002103} // isCommutable
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002104
2105// Multiply + accumulate
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002106def t2SMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2107 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00002108 "smlal", "\t$ldst, $hdst, $a, $b", []>{
2109 let Inst{31-27} = 0b11111;
2110 let Inst{26-23} = 0b0111;
2111 let Inst{22-20} = 0b100;
2112 let Inst{7-4} = 0b0000;
2113}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002114
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002115def t2UMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2116 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00002117 "umlal", "\t$ldst, $hdst, $a, $b", []>{
2118 let Inst{31-27} = 0b11111;
2119 let Inst{26-23} = 0b0111;
2120 let Inst{22-20} = 0b110;
2121 let Inst{7-4} = 0b0000;
2122}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002123
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002124def t2UMAAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2125 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00002126 "umaal", "\t$ldst, $hdst, $a, $b", []>{
2127 let Inst{31-27} = 0b11111;
2128 let Inst{26-23} = 0b0111;
2129 let Inst{22-20} = 0b110;
2130 let Inst{7-4} = 0b0110;
2131}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002132} // neverHasSideEffects
2133
Johnny Chen93042d12010-03-02 18:14:57 +00002134// Rounding variants of the below included for disassembly only
2135
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002136// Most significant word multiply
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002137def t2SMMUL : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00002138 "smmul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002139 [(set rGPR:$dst, (mulhs rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002140 let Inst{31-27} = 0b11111;
2141 let Inst{26-23} = 0b0110;
2142 let Inst{22-20} = 0b101;
2143 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2144 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2145}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002146
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002147def t2SMMULR : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Johnny Chen93042d12010-03-02 18:14:57 +00002148 "smmulr", "\t$dst, $a, $b", []> {
2149 let Inst{31-27} = 0b11111;
2150 let Inst{26-23} = 0b0110;
2151 let Inst{22-20} = 0b101;
2152 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2153 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2154}
2155
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002156def t2SMMLA : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00002157 "smmla", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002158 [(set rGPR:$dst, (add (mulhs rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002159 let Inst{31-27} = 0b11111;
2160 let Inst{26-23} = 0b0110;
2161 let Inst{22-20} = 0b101;
2162 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2163 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2164}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002165
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002166def t2SMMLAR: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00002167 "smmlar", "\t$dst, $a, $b, $c", []> {
2168 let Inst{31-27} = 0b11111;
2169 let Inst{26-23} = 0b0110;
2170 let Inst{22-20} = 0b101;
2171 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2172 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2173}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002174
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002175def t2SMMLS: T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00002176 "smmls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002177 [(set rGPR:$dst, (sub rGPR:$c, (mulhs rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002178 let Inst{31-27} = 0b11111;
2179 let Inst{26-23} = 0b0110;
2180 let Inst{22-20} = 0b110;
2181 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2182 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2183}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002184
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002185def t2SMMLSR:T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00002186 "smmlsr", "\t$dst, $a, $b, $c", []> {
2187 let Inst{31-27} = 0b11111;
2188 let Inst{26-23} = 0b0110;
2189 let Inst{22-20} = 0b110;
2190 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2191 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2192}
2193
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002194multiclass T2I_smul<string opc, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +00002195 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002196 !strconcat(opc, "bb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002197 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
2198 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002199 let Inst{31-27} = 0b11111;
2200 let Inst{26-23} = 0b0110;
2201 let Inst{22-20} = 0b001;
2202 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2203 let Inst{7-6} = 0b00;
2204 let Inst{5-4} = 0b00;
2205 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002206
Evan Cheng0e55fd62010-09-30 01:08:25 +00002207 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002208 !strconcat(opc, "bt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002209 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
2210 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002211 let Inst{31-27} = 0b11111;
2212 let Inst{26-23} = 0b0110;
2213 let Inst{22-20} = 0b001;
2214 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2215 let Inst{7-6} = 0b00;
2216 let Inst{5-4} = 0b01;
2217 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002218
Evan Cheng0e55fd62010-09-30 01:08:25 +00002219 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002220 !strconcat(opc, "tb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002221 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
2222 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002223 let Inst{31-27} = 0b11111;
2224 let Inst{26-23} = 0b0110;
2225 let Inst{22-20} = 0b001;
2226 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2227 let Inst{7-6} = 0b00;
2228 let Inst{5-4} = 0b10;
2229 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002230
Evan Cheng0e55fd62010-09-30 01:08:25 +00002231 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002232 !strconcat(opc, "tt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002233 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
2234 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002235 let Inst{31-27} = 0b11111;
2236 let Inst{26-23} = 0b0110;
2237 let Inst{22-20} = 0b001;
2238 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2239 let Inst{7-6} = 0b00;
2240 let Inst{5-4} = 0b11;
2241 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002242
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002243 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002244 !strconcat(opc, "wb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002245 [(set rGPR:$dst, (sra (opnode rGPR:$a,
2246 (sext_inreg rGPR:$b, i16)), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002247 let Inst{31-27} = 0b11111;
2248 let Inst{26-23} = 0b0110;
2249 let Inst{22-20} = 0b011;
2250 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2251 let Inst{7-6} = 0b00;
2252 let Inst{5-4} = 0b00;
2253 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002254
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002255 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002256 !strconcat(opc, "wt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002257 [(set rGPR:$dst, (sra (opnode rGPR:$a,
2258 (sra rGPR:$b, (i32 16))), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002259 let Inst{31-27} = 0b11111;
2260 let Inst{26-23} = 0b0110;
2261 let Inst{22-20} = 0b011;
2262 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2263 let Inst{7-6} = 0b00;
2264 let Inst{5-4} = 0b01;
2265 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002266}
2267
2268
2269multiclass T2I_smla<string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002270 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002271 !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002272 [(set rGPR:$dst, (add rGPR:$acc,
2273 (opnode (sext_inreg rGPR:$a, i16),
2274 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002275 let Inst{31-27} = 0b11111;
2276 let Inst{26-23} = 0b0110;
2277 let Inst{22-20} = 0b001;
2278 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2279 let Inst{7-6} = 0b00;
2280 let Inst{5-4} = 0b00;
2281 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002282
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002283 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002284 !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002285 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sext_inreg rGPR:$a, i16),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002286 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002287 let Inst{31-27} = 0b11111;
2288 let Inst{26-23} = 0b0110;
2289 let Inst{22-20} = 0b001;
2290 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2291 let Inst{7-6} = 0b00;
2292 let Inst{5-4} = 0b01;
2293 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002294
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002295 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002296 !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002297 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002298 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002299 let Inst{31-27} = 0b11111;
2300 let Inst{26-23} = 0b0110;
2301 let Inst{22-20} = 0b001;
2302 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2303 let Inst{7-6} = 0b00;
2304 let Inst{5-4} = 0b10;
2305 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002306
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002307 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002308 !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002309 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002310 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002311 let Inst{31-27} = 0b11111;
2312 let Inst{26-23} = 0b0110;
2313 let Inst{22-20} = 0b001;
2314 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2315 let Inst{7-6} = 0b00;
2316 let Inst{5-4} = 0b11;
2317 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002318
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002319 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002320 !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002321 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002322 (sext_inreg rGPR:$b, i16)), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002323 let Inst{31-27} = 0b11111;
2324 let Inst{26-23} = 0b0110;
2325 let Inst{22-20} = 0b011;
2326 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2327 let Inst{7-6} = 0b00;
2328 let Inst{5-4} = 0b00;
2329 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002330
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002331 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002332 !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002333 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002334 (sra rGPR:$b, (i32 16))), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002335 let Inst{31-27} = 0b11111;
2336 let Inst{26-23} = 0b0110;
2337 let Inst{22-20} = 0b011;
2338 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2339 let Inst{7-6} = 0b00;
2340 let Inst{5-4} = 0b01;
2341 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002342}
2343
2344defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2345defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2346
Johnny Chenadc77332010-02-26 22:04:29 +00002347// Halfword multiple accumulate long: SMLAL<x><y> -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002348def t2SMLALBB : T2I_mac<1, 0b100, 0b1000, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002349 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002350 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002351def t2SMLALBT : T2I_mac<1, 0b100, 0b1001, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002352 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002353 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002354def t2SMLALTB : T2I_mac<1, 0b100, 0b1010, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002355 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002356 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002357def t2SMLALTT : T2I_mac<1, 0b100, 0b1011, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002358 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002359 [/* For disassembly only; pattern left blank */]>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002360
Johnny Chenadc77332010-02-26 22:04:29 +00002361// Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2362// These are for disassembly only.
2363
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002364def t2SMUAD: T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2365 IIC_iMAC32, "smuad", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002366 let Inst{15-12} = 0b1111;
2367}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002368def t2SMUADX:T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2369 IIC_iMAC32, "smuadx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002370 let Inst{15-12} = 0b1111;
2371}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002372def t2SMUSD: T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2373 IIC_iMAC32, "smusd", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002374 let Inst{15-12} = 0b1111;
2375}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002376def t2SMUSDX:T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2377 IIC_iMAC32, "smusdx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002378 let Inst{15-12} = 0b1111;
2379}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002380def t2SMLAD : T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst),
2381 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlad",
Johnny Chenadc77332010-02-26 22:04:29 +00002382 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002383def t2SMLADX : T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst),
2384 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smladx",
Johnny Chenadc77332010-02-26 22:04:29 +00002385 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002386def t2SMLSD : T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst),
2387 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsd",
Johnny Chenadc77332010-02-26 22:04:29 +00002388 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002389def t2SMLSDX : T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst),
2390 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsdx",
Johnny Chenadc77332010-02-26 22:04:29 +00002391 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002392def t2SMLALD : T2I_mac<1, 0b100, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2393 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlald",
Johnny Chenadc77332010-02-26 22:04:29 +00002394 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002395def t2SMLALDX : T2I_mac<1, 0b100, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2396 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002397 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002398def t2SMLSLD : T2I_mac<1, 0b101, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2399 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsld",
Johnny Chenadc77332010-02-26 22:04:29 +00002400 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002401def t2SMLSLDX : T2I_mac<1, 0b101, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2402 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002403 "\t$ldst, $hdst, $a, $b", []>;
Evan Chengf49810c2009-06-23 17:48:47 +00002404
2405//===----------------------------------------------------------------------===//
2406// Misc. Arithmetic Instructions.
2407//
2408
Jim Grosbach80dc1162010-02-16 21:23:02 +00002409class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2410 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00002411 : T2I<oops, iops, itin, opc, asm, pattern> {
2412 let Inst{31-27} = 0b11111;
2413 let Inst{26-22} = 0b01010;
2414 let Inst{21-20} = op1;
2415 let Inst{15-12} = 0b1111;
2416 let Inst{7-6} = 0b10;
2417 let Inst{5-4} = op2;
2418}
Evan Chengf49810c2009-06-23 17:48:47 +00002419
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002420def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
2421 "clz", "\t$dst, $src", [(set rGPR:$dst, (ctlz rGPR:$src))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002422
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002423def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Evan Chengf609bb82010-01-19 00:44:15 +00002424 "rbit", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002425 [(set rGPR:$dst, (ARMrbit rGPR:$src))]>;
Jim Grosbach3482c802010-01-18 19:58:49 +00002426
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002427def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002428 "rev", ".w\t$dst, $src", [(set rGPR:$dst, (bswap rGPR:$src))]>;
Johnny Chend68e1192009-12-15 17:24:14 +00002429
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002430def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002431 "rev16", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002432 [(set rGPR:$dst,
2433 (or (and (srl rGPR:$src, (i32 8)), 0xFF),
2434 (or (and (shl rGPR:$src, (i32 8)), 0xFF00),
2435 (or (and (srl rGPR:$src, (i32 8)), 0xFF0000),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002436 (and (shl rGPR:$src, (i32 8)), 0xFF000000)))))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002437
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002438def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002439 "revsh", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002440 [(set rGPR:$dst,
Evan Chengf49810c2009-06-23 17:48:47 +00002441 (sext_inreg
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002442 (or (srl (and rGPR:$src, 0xFF00), (i32 8)),
2443 (shl rGPR:$src, (i32 8))), i16))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002444
Bob Wilsonf955f292010-08-17 17:23:19 +00002445def t2PKHBT : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002446 IIC_iBITsi, "pkhbt", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002447 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF),
Bob Wilsonf955f292010-08-17 17:23:19 +00002448 (and (shl rGPR:$src2, lsl_amt:$sh),
Jim Grosbachb1dc3932010-05-05 20:44:35 +00002449 0xFFFF0000)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002450 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002451 let Inst{31-27} = 0b11101;
2452 let Inst{26-25} = 0b01;
2453 let Inst{24-20} = 0b01100;
2454 let Inst{5} = 0; // BT form
2455 let Inst{4} = 0;
2456}
Evan Cheng40289b02009-07-07 05:35:52 +00002457
2458// Alternate cases for PKHBT where identities eliminate some nodes.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002459def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2460 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002461 Requires<[HasT2ExtractPack, IsThumb2]>;
Bob Wilsonf955f292010-08-17 17:23:19 +00002462def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2463 (t2PKHBT rGPR:$src1, rGPR:$src2, (lsl_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002464 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Cheng40289b02009-07-07 05:35:52 +00002465
Bob Wilsondc66eda2010-08-16 22:26:55 +00002466// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2467// will match the pattern below.
Bob Wilsonf955f292010-08-17 17:23:19 +00002468def t2PKHTB : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002469 IIC_iBITsi, "pkhtb", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002470 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002471 (and (sra rGPR:$src2, asr_amt:$sh),
2472 0xFFFF)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002473 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002474 let Inst{31-27} = 0b11101;
2475 let Inst{26-25} = 0b01;
2476 let Inst{24-20} = 0b01100;
2477 let Inst{5} = 1; // TB form
2478 let Inst{4} = 0;
2479}
Evan Cheng40289b02009-07-07 05:35:52 +00002480
2481// Alternate cases for PKHTB where identities eliminate some nodes. Note that
2482// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilsondc66eda2010-08-16 22:26:55 +00002483def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
Bob Wilsonf955f292010-08-17 17:23:19 +00002484 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002485 Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002486def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002487 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2488 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm1_15:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002489 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002490
2491//===----------------------------------------------------------------------===//
2492// Comparison Instructions...
2493//
Johnny Chend68e1192009-12-15 17:24:14 +00002494defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002495 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002496 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2497defm t2CMPz : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002498 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002499 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002500
Dan Gohman4b7dff92010-08-26 15:50:25 +00002501//FIXME: Disable CMN, as CCodes are backwards from compare expectations
2502// Compare-to-zero still works out, just not the relationals
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002503//defm t2CMN : T2I_cmp_irs<0b1000, "cmn",
2504// BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002505defm t2CMNz : T2I_cmp_irs<0b1000, "cmn",
Evan Cheng5d42c562010-09-29 00:49:25 +00002506 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Dan Gohman4b7dff92010-08-26 15:50:25 +00002507 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2508
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002509//def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2510// (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002511
2512def : T2Pat<(ARMcmpZ GPR:$src, t2_so_imm_neg:$imm),
2513 (t2CMNzri GPR:$src, t2_so_imm_neg:$imm)>;
Evan Chengf49810c2009-06-23 17:48:47 +00002514
Johnny Chend68e1192009-12-15 17:24:14 +00002515defm t2TST : T2I_cmp_irs<0b0000, "tst",
Evan Cheng5d42c562010-09-29 00:49:25 +00002516 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002517 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>>;
2518defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
Evan Cheng5d42c562010-09-29 00:49:25 +00002519 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002520 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002521
Evan Chenge253c952009-07-07 20:39:03 +00002522// Conditional moves
2523// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach64171712010-02-16 21:07:46 +00002524// a two-value operand where a dag node expects two operands. :(
Evan Cheng63f35442010-11-13 02:25:14 +00002525let neverHasSideEffects = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002526def t2MOVCCr : T2I<(outs rGPR:$dst), (ins rGPR:$false, rGPR:$true), IIC_iCMOVr,
Evan Cheng699beba2009-10-27 00:08:59 +00002527 "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002528 [/*(set rGPR:$dst, (ARMcmov rGPR:$false, rGPR:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002529 RegConstraint<"$false = $dst"> {
2530 let Inst{31-27} = 0b11101;
2531 let Inst{26-25} = 0b01;
2532 let Inst{24-21} = 0b0010;
2533 let Inst{20} = 0; // The S bit.
2534 let Inst{19-16} = 0b1111; // Rn
2535 let Inst{14-12} = 0b000;
2536 let Inst{7-4} = 0b0000;
2537}
Evan Chenge253c952009-07-07 20:39:03 +00002538
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002539def t2MOVCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
Evan Cheng699beba2009-10-27 00:08:59 +00002540 IIC_iCMOVi, "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002541[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002542 RegConstraint<"$false = $dst"> {
2543 let Inst{31-27} = 0b11110;
2544 let Inst{25} = 0;
2545 let Inst{24-21} = 0b0010;
2546 let Inst{20} = 0; // The S bit.
2547 let Inst{19-16} = 0b1111; // Rn
2548 let Inst{15} = 0;
2549}
Evan Chengf49810c2009-06-23 17:48:47 +00002550
Jim Grosbacha4257162010-10-07 00:53:56 +00002551def t2MOVCCi16 : T2I<(outs rGPR:$dst), (ins rGPR:$false, i32imm:$src),
Evan Cheng875a6ac2010-11-12 22:42:47 +00002552 IIC_iCMOVi,
Jim Grosbacha4257162010-10-07 00:53:56 +00002553 "movw", "\t$dst, $src", []>,
2554 RegConstraint<"$false = $dst"> {
2555 let Inst{31-27} = 0b11110;
2556 let Inst{25} = 1;
2557 let Inst{24-21} = 0b0010;
2558 let Inst{20} = 0; // The S bit.
2559 let Inst{15} = 0;
2560}
2561
Evan Cheng63f35442010-11-13 02:25:14 +00002562def t2MOVCCi32imm : PseudoInst<(outs rGPR:$dst),
2563 (ins rGPR:$false, i32imm:$src, pred:$p),
Evan Chengc47f7d62010-11-13 05:14:20 +00002564 IIC_iCMOVix2, "", []>, RegConstraint<"$false = $dst">;
Evan Cheng63f35442010-11-13 02:25:14 +00002565
Evan Cheng875a6ac2010-11-12 22:42:47 +00002566def t2MVNCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
2567 IIC_iCMOVi, "mvn", ".w\t$dst, $true",
2568[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm_not:$true,
2569 imm:$cc, CCR:$ccr))*/]>,
2570 RegConstraint<"$false = $dst"> {
2571 let Inst{31-27} = 0b11110;
2572 let Inst{25} = 0;
2573 let Inst{24-21} = 0b0011;
2574 let Inst{20} = 0; // The S bit.
2575 let Inst{19-16} = 0b1111; // Rn
2576 let Inst{15} = 0;
2577}
2578
Johnny Chend68e1192009-12-15 17:24:14 +00002579class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
2580 string opc, string asm, list<dag> pattern>
Owen Andersonbb6315d2010-11-15 19:58:36 +00002581 : T2TwoRegShiftImm<oops, iops, itin, opc, asm, pattern> {
Johnny Chend68e1192009-12-15 17:24:14 +00002582 let Inst{31-27} = 0b11101;
2583 let Inst{26-25} = 0b01;
2584 let Inst{24-21} = 0b0010;
2585 let Inst{20} = 0; // The S bit.
2586 let Inst{19-16} = 0b1111; // Rn
2587 let Inst{5-4} = opcod; // Shift type.
2588}
Owen Andersonbb6315d2010-11-15 19:58:36 +00002589def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$Rd),
2590 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2591 IIC_iCMOVsi, "lsl", ".w\t$Rd, $Rm, $imm", []>,
2592 RegConstraint<"$false = $Rd">;
2593def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$Rd),
2594 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2595 IIC_iCMOVsi, "lsr", ".w\t$Rd, $Rm, $imm", []>,
2596 RegConstraint<"$false = $Rd">;
2597def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$Rd),
2598 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2599 IIC_iCMOVsi, "asr", ".w\t$Rd, $Rm, $imm", []>,
2600 RegConstraint<"$false = $Rd">;
2601def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$Rd),
2602 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2603 IIC_iCMOVsi, "ror", ".w\t$Rd, $Rm, $imm", []>,
2604 RegConstraint<"$false = $Rd">;
Owen Andersonf523e472010-09-23 23:45:25 +00002605} // neverHasSideEffects
Evan Cheng13f8b362009-08-01 01:43:45 +00002606
David Goodwin5e47a9a2009-06-30 18:04:13 +00002607//===----------------------------------------------------------------------===//
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002608// Atomic operations intrinsics
2609//
2610
2611// memory barriers protect the atomic sequences
2612let hasSideEffects = 1 in {
Bob Wilsonf74a4292010-10-30 00:54:37 +00002613def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2614 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
2615 Requires<[IsThumb, HasDB]> {
2616 bits<4> opt;
2617 let Inst{31-4} = 0xf3bf8f5;
2618 let Inst{3-0} = opt;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002619}
2620}
2621
Bob Wilsonf74a4292010-10-30 00:54:37 +00002622def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2623 "dsb", "\t$opt",
2624 [/* For disassembly only; pattern left blank */]>,
2625 Requires<[IsThumb, HasDB]> {
2626 bits<4> opt;
2627 let Inst{31-4} = 0xf3bf8f4;
2628 let Inst{3-0} = opt;
Johnny Chena4339822010-03-03 00:16:28 +00002629}
2630
Johnny Chena4339822010-03-03 00:16:28 +00002631// ISB has only full system option -- for disassembly only
Bob Wilsonf74a4292010-10-30 00:54:37 +00002632def t2ISB : T2I<(outs), (ins), NoItinerary, "isb", "",
2633 [/* For disassembly only; pattern left blank */]>,
2634 Requires<[IsThumb2, HasV7]> {
2635 let Inst{31-4} = 0xf3bf8f6;
Johnny Chena4339822010-03-03 00:16:28 +00002636 let Inst{3-0} = 0b1111;
2637}
2638
Johnny Chend68e1192009-12-15 17:24:14 +00002639class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2640 InstrItinClass itin, string opc, string asm, string cstr,
2641 list<dag> pattern, bits<4> rt2 = 0b1111>
2642 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2643 let Inst{31-27} = 0b11101;
2644 let Inst{26-20} = 0b0001101;
2645 let Inst{11-8} = rt2;
2646 let Inst{7-6} = 0b01;
2647 let Inst{5-4} = opcod;
2648 let Inst{3-0} = 0b1111;
2649}
2650class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2651 InstrItinClass itin, string opc, string asm, string cstr,
2652 list<dag> pattern, bits<4> rt2 = 0b1111>
2653 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2654 let Inst{31-27} = 0b11101;
2655 let Inst{26-20} = 0b0001100;
2656 let Inst{11-8} = rt2;
2657 let Inst{7-6} = 0b01;
2658 let Inst{5-4} = opcod;
2659}
2660
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002661let mayLoad = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002662def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002663 Size4Bytes, NoItinerary, "ldrexb", "\t$dest, [$ptr]",
2664 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002665def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002666 Size4Bytes, NoItinerary, "ldrexh", "\t$dest, [$ptr]",
2667 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002668def t2LDREX : Thumb2I<(outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002669 Size4Bytes, NoItinerary,
2670 "ldrex", "\t$dest, [$ptr]", "",
2671 []> {
2672 let Inst{31-27} = 0b11101;
2673 let Inst{26-20} = 0b0000101;
2674 let Inst{11-8} = 0b1111;
2675 let Inst{7-0} = 0b00000000; // imm8 = 0
2676}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002677def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$dest, rGPR:$dest2), (ins rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002678 AddrModeNone, Size4Bytes, NoItinerary,
2679 "ldrexd", "\t$dest, $dest2, [$ptr]", "",
2680 [], {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002681}
2682
Jim Grosbach587b0722009-12-16 19:44:06 +00002683let mayStore = 1, Constraints = "@earlyclobber $success" in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002684def t2STREXB : T2I_strex<0b00, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002685 AddrModeNone, Size4Bytes, NoItinerary,
2686 "strexb", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002687def t2STREXH : T2I_strex<0b01, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002688 AddrModeNone, Size4Bytes, NoItinerary,
2689 "strexh", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002690def t2STREX : Thumb2I<(outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002691 AddrModeNone, Size4Bytes, NoItinerary,
2692 "strex", "\t$success, $src, [$ptr]", "",
2693 []> {
2694 let Inst{31-27} = 0b11101;
2695 let Inst{26-20} = 0b0000100;
2696 let Inst{7-0} = 0b00000000; // imm8 = 0
2697}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002698def t2STREXD : T2I_strex<0b11, (outs rGPR:$success),
2699 (ins rGPR:$src, rGPR:$src2, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002700 AddrModeNone, Size4Bytes, NoItinerary,
2701 "strexd", "\t$success, $src, $src2, [$ptr]", "", [],
2702 {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002703}
2704
Johnny Chen10a77e12010-03-02 22:11:06 +00002705// Clear-Exclusive is for disassembly only.
2706def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "",
2707 [/* For disassembly only; pattern left blank */]>,
2708 Requires<[IsARM, HasV7]> {
2709 let Inst{31-20} = 0xf3b;
2710 let Inst{15-14} = 0b10;
2711 let Inst{12} = 0;
2712 let Inst{7-4} = 0b0010;
2713}
2714
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002715//===----------------------------------------------------------------------===//
David Goodwin334c2642009-07-08 16:09:28 +00002716// TLS Instructions
2717//
2718
2719// __aeabi_read_tp preserves the registers r1-r3.
2720let isCall = 1,
2721 Defs = [R0, R12, LR, CPSR] in {
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002722 def t2TPsoft : T2XI<(outs), (ins), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002723 "bl\t__aeabi_read_tp",
Johnny Chend68e1192009-12-15 17:24:14 +00002724 [(set R0, ARMthread_pointer)]> {
2725 let Inst{31-27} = 0b11110;
2726 let Inst{15-14} = 0b11;
2727 let Inst{12} = 1;
2728 }
David Goodwin334c2642009-07-08 16:09:28 +00002729}
2730
2731//===----------------------------------------------------------------------===//
Jim Grosbach5aa16842009-08-11 19:42:21 +00002732// SJLJ Exception handling intrinsics
Jim Grosbach1add6592009-08-13 15:11:43 +00002733// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach5aa16842009-08-11 19:42:21 +00002734// address and save #0 in R0 for the non-longjmp case.
2735// Since by its nature we may be coming from some other function to get
2736// here, and we're using the stack frame for the containing function to
2737// save/restore registers, we can't keep anything live in regs across
2738// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
2739// when we get here from a longjmp(). We force everthing out of registers
2740// except for our own input by listing the relevant registers in Defs. By
2741// doing so, we also cause the prologue/epilogue code to actively preserve
2742// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach0798edd2010-05-27 23:49:24 +00002743// $val is a scratch register for our use.
Jim Grosbacha87ded22010-02-08 23:22:00 +00002744let Defs =
Jim Grosbachf35d2162009-08-13 16:59:44 +00002745 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2746 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Jim Grosbach5aa16842009-08-11 19:42:21 +00002747 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002748 D31 ], hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002749 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002750 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002751 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002752 Requires<[IsThumb2, HasVFP2]>;
Jim Grosbach5aa16842009-08-11 19:42:21 +00002753}
2754
Bob Wilsonec80e262010-04-09 20:41:18 +00002755let Defs =
Jim Grosbach5caeff52010-05-28 17:37:40 +00002756 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ],
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002757 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002758 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002759 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002760 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002761 Requires<[IsThumb2, NoVFP]>;
2762}
Jim Grosbach5aa16842009-08-11 19:42:21 +00002763
2764
2765//===----------------------------------------------------------------------===//
David Goodwin5e47a9a2009-06-30 18:04:13 +00002766// Control-Flow Instructions
2767//
2768
Evan Chengc50a1cb2009-07-09 22:58:39 +00002769// FIXME: remove when we have a way to marking a MI with these properties.
2770// FIXME: $dst1 should be a def. But the extra ops must be in the end of the
2771// operand list.
2772// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng0d92f5f2009-10-01 08:22:27 +00002773let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
Chris Lattner39ee0362010-10-31 19:10:56 +00002774 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
Jim Grosbache6913602010-11-03 01:01:43 +00002775 def t2LDM_RET: T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
2776 reglist:$dsts, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00002777 IIC_iLoad_mBr,
Jim Grosbache6913602010-11-03 01:01:43 +00002778 "ldm${amode}${p}.w\t$Rn!, $dsts",
2779 "$Rn = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002780 let Inst{31-27} = 0b11101;
2781 let Inst{26-25} = 0b00;
2782 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
2783 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00002784 let Inst{21} = 1; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00002785 let Inst{20} = 1; // Load
2786}
Evan Chengc50a1cb2009-07-09 22:58:39 +00002787
David Goodwin5e47a9a2009-06-30 18:04:13 +00002788let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
2789let isPredicable = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002790def t2B : T2XI<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002791 "b.w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002792 [(br bb:$target)]> {
2793 let Inst{31-27} = 0b11110;
2794 let Inst{15-14} = 0b10;
2795 let Inst{12} = 1;
2796}
David Goodwin5e47a9a2009-06-30 18:04:13 +00002797
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002798let isNotDuplicable = 1, isIndirectBranch = 1,
2799 isCodeGenOnly = 1 in { // $id doesn't exist in asmstring, should be lowered.
Evan Cheng66ac5312009-07-25 00:33:29 +00002800def t2BR_JT :
Evan Cheng5657c012009-07-29 02:18:14 +00002801 T2JTI<(outs),
2802 (ins GPR:$target, GPR:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002803 IIC_Br, "mov\tpc, $target$jt",
Johnny Chend68e1192009-12-15 17:24:14 +00002804 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]> {
2805 let Inst{31-27} = 0b11101;
2806 let Inst{26-20} = 0b0100100;
2807 let Inst{19-16} = 0b1111;
2808 let Inst{14-12} = 0b000;
2809 let Inst{11-8} = 0b1111; // Rd = pc
2810 let Inst{7-4} = 0b0000;
2811}
Evan Cheng5657c012009-07-29 02:18:14 +00002812
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002813// FIXME: Add a non-pc based case that can be predicated.
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002814let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002815def t2TBB :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002816 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002817 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002818 IIC_Br, "tbb\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002819 let Inst{31-27} = 0b11101;
2820 let Inst{26-20} = 0b0001101;
2821 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2822 let Inst{15-8} = 0b11110000;
2823 let Inst{7-4} = 0b0000; // B form
2824}
Evan Cheng5657c012009-07-29 02:18:14 +00002825
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002826let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002827def t2TBH :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002828 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002829 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002830 IIC_Br, "tbh\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002831 let Inst{31-27} = 0b11101;
2832 let Inst{26-20} = 0b0001101;
2833 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2834 let Inst{15-8} = 0b11110000;
2835 let Inst{7-4} = 0b0001; // H form
2836}
Johnny Chen93042d12010-03-02 18:14:57 +00002837
2838// Generic versions of the above two instructions, for disassembly only
2839
2840def t2TBBgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2841 "tbb", "\t[$a, $b]", []>{
2842 let Inst{31-27} = 0b11101;
2843 let Inst{26-20} = 0b0001101;
2844 let Inst{15-8} = 0b11110000;
2845 let Inst{7-4} = 0b0000; // B form
2846}
2847
2848def t2TBHgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2849 "tbh", "\t[$a, $b, lsl #1]", []> {
2850 let Inst{31-27} = 0b11101;
2851 let Inst{26-20} = 0b0001101;
2852 let Inst{15-8} = 0b11110000;
2853 let Inst{7-4} = 0b0001; // H form
2854}
Evan Cheng5657c012009-07-29 02:18:14 +00002855} // isNotDuplicable, isIndirectBranch
2856
David Goodwinc9a59b52009-06-30 19:50:22 +00002857} // isBranch, isTerminator, isBarrier
David Goodwin5e47a9a2009-06-30 18:04:13 +00002858
2859// FIXME: should be able to write a pattern for ARMBrcond, but can't use
2860// a two-value operand where a dag node expects two operands. :(
2861let isBranch = 1, isTerminator = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002862def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002863 "b", ".w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002864 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
2865 let Inst{31-27} = 0b11110;
2866 let Inst{15-14} = 0b10;
2867 let Inst{12} = 0;
2868}
Evan Chengf49810c2009-06-23 17:48:47 +00002869
Evan Cheng06e16582009-07-10 01:54:42 +00002870
2871// IT block
Evan Cheng86050dc2010-06-18 23:09:54 +00002872let Defs = [ITSTATE] in
Evan Cheng06e16582009-07-10 01:54:42 +00002873def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
David Goodwin5d598aa2009-08-19 18:00:44 +00002874 AddrModeNone, Size2Bytes, IIC_iALUx,
Johnny Chend68e1192009-12-15 17:24:14 +00002875 "it$mask\t$cc", "", []> {
2876 // 16-bit instruction.
Johnny Chenbbc71b22009-12-16 02:32:54 +00002877 let Inst{31-16} = 0x0000;
Johnny Chend68e1192009-12-15 17:24:14 +00002878 let Inst{15-8} = 0b10111111;
2879}
Evan Cheng06e16582009-07-10 01:54:42 +00002880
Johnny Chence6275f2010-02-25 19:05:29 +00002881// Branch and Exchange Jazelle -- for disassembly only
2882// Rm = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002883def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func",
Johnny Chence6275f2010-02-25 19:05:29 +00002884 [/* For disassembly only; pattern left blank */]> {
2885 let Inst{31-27} = 0b11110;
2886 let Inst{26} = 0;
2887 let Inst{25-20} = 0b111100;
2888 let Inst{15-14} = 0b10;
2889 let Inst{12} = 0;
2890}
2891
Johnny Chen93042d12010-03-02 18:14:57 +00002892// Change Processor State is a system instruction -- for disassembly only.
2893// The singleton $opt operand contains the following information:
2894// opt{4-0} = mode from Inst{4-0}
2895// opt{5} = changemode from Inst{17}
2896// opt{8-6} = AIF from Inst{8-6}
2897// opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002898def t2CPS : T2XI<(outs),(ins cps_opt:$opt), NoItinerary, "cps$opt",
Johnny Chen93042d12010-03-02 18:14:57 +00002899 [/* For disassembly only; pattern left blank */]> {
2900 let Inst{31-27} = 0b11110;
2901 let Inst{26} = 0;
2902 let Inst{25-20} = 0b111010;
2903 let Inst{15-14} = 0b10;
2904 let Inst{12} = 0;
2905}
2906
Johnny Chen0f7866e2010-03-03 02:09:43 +00002907// A6.3.4 Branches and miscellaneous control
2908// Table A6-14 Change Processor State, and hint instructions
2909// Helper class for disassembly only.
2910class T2I_hint<bits<8> op7_0, string opc, string asm>
2911 : T2I<(outs), (ins), NoItinerary, opc, asm,
2912 [/* For disassembly only; pattern left blank */]> {
2913 let Inst{31-20} = 0xf3a;
2914 let Inst{15-14} = 0b10;
2915 let Inst{12} = 0;
2916 let Inst{10-8} = 0b000;
2917 let Inst{7-0} = op7_0;
2918}
2919
2920def t2NOP : T2I_hint<0b00000000, "nop", ".w">;
2921def t2YIELD : T2I_hint<0b00000001, "yield", ".w">;
2922def t2WFE : T2I_hint<0b00000010, "wfe", ".w">;
2923def t2WFI : T2I_hint<0b00000011, "wfi", ".w">;
2924def t2SEV : T2I_hint<0b00000100, "sev", ".w">;
2925
2926def t2DBG : T2I<(outs),(ins i32imm:$opt), NoItinerary, "dbg", "\t$opt",
2927 [/* For disassembly only; pattern left blank */]> {
2928 let Inst{31-20} = 0xf3a;
2929 let Inst{15-14} = 0b10;
2930 let Inst{12} = 0;
2931 let Inst{10-8} = 0b000;
2932 let Inst{7-4} = 0b1111;
2933}
2934
Johnny Chen6341c5a2010-02-25 20:25:24 +00002935// Secure Monitor Call is a system instruction -- for disassembly only
2936// Option = Inst{19-16}
2937def t2SMC : T2I<(outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
2938 [/* For disassembly only; pattern left blank */]> {
2939 let Inst{31-27} = 0b11110;
2940 let Inst{26-20} = 0b1111111;
2941 let Inst{15-12} = 0b1000;
2942}
2943
2944// Store Return State is a system instruction -- for disassembly only
2945def t2SRSDBW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp!, $mode",
2946 [/* For disassembly only; pattern left blank */]> {
2947 let Inst{31-27} = 0b11101;
2948 let Inst{26-20} = 0b0000010; // W = 1
2949}
2950
2951def t2SRSDB : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp, $mode",
2952 [/* For disassembly only; pattern left blank */]> {
2953 let Inst{31-27} = 0b11101;
2954 let Inst{26-20} = 0b0000000; // W = 0
2955}
2956
2957def t2SRSIAW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsia","\tsp!, $mode",
2958 [/* For disassembly only; pattern left blank */]> {
2959 let Inst{31-27} = 0b11101;
2960 let Inst{26-20} = 0b0011010; // W = 1
2961}
2962
2963def t2SRSIA : T2I<(outs), (ins i32imm:$mode),NoItinerary,"srsia","\tsp, $mode",
2964 [/* For disassembly only; pattern left blank */]> {
2965 let Inst{31-27} = 0b11101;
2966 let Inst{26-20} = 0b0011000; // W = 0
2967}
2968
2969// Return From Exception is a system instruction -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002970def t2RFEDBW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfedb", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002971 [/* For disassembly only; pattern left blank */]> {
2972 let Inst{31-27} = 0b11101;
2973 let Inst{26-20} = 0b0000011; // W = 1
2974}
2975
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002976def t2RFEDB : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeab", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002977 [/* For disassembly only; pattern left blank */]> {
2978 let Inst{31-27} = 0b11101;
2979 let Inst{26-20} = 0b0000001; // W = 0
2980}
2981
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002982def t2RFEIAW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002983 [/* For disassembly only; pattern left blank */]> {
2984 let Inst{31-27} = 0b11101;
2985 let Inst{26-20} = 0b0011011; // W = 1
2986}
2987
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002988def t2RFEIA : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002989 [/* For disassembly only; pattern left blank */]> {
2990 let Inst{31-27} = 0b11101;
2991 let Inst{26-20} = 0b0011001; // W = 0
2992}
2993
Evan Chengf49810c2009-06-23 17:48:47 +00002994//===----------------------------------------------------------------------===//
2995// Non-Instruction Patterns
2996//
2997
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002998// Two piece so_imms.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002999def : T2Pat<(or rGPR:$LHS, t2_so_imm2part:$RHS),
3000 (t2ORRri (t2ORRri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00003001 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003002def : T2Pat<(xor rGPR:$LHS, t2_so_imm2part:$RHS),
3003 (t2EORri (t2EORri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00003004 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003005def : T2Pat<(add rGPR:$LHS, t2_so_imm2part:$RHS),
3006 (t2ADDri (t2ADDri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00003007 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003008def : T2Pat<(add rGPR:$LHS, t2_so_neg_imm2part:$RHS),
3009 (t2SUBri (t2SUBri rGPR:$LHS, (t2_so_neg_imm2part_1 imm:$RHS)),
Jim Grosbach15e6ef82009-11-23 20:35:53 +00003010 (t2_so_neg_imm2part_2 imm:$RHS))>;
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00003011
Evan Cheng5adb66a2009-09-28 09:14:39 +00003012// 32-bit immediate using movw + movt.
Evan Cheng5be39222010-09-24 22:03:46 +00003013// This is a single pseudo instruction to make it re-materializable.
3014// FIXME: Remove this when we can do generalized remat.
Evan Cheng5adb66a2009-09-28 09:14:39 +00003015let isReMaterializable = 1 in
Jim Grosbach3c38f962010-10-06 22:01:26 +00003016def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
3017 "", [(set rGPR:$dst, (i32 imm:$src))]>,
3018 Requires<[IsThumb, HasV6T2]>;
Evan Chengb9803a82009-11-06 23:52:48 +00003019
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +00003020// ConstantPool, GlobalAddress, and JumpTable
3021def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
3022 Requires<[IsThumb2, DontUseMovt]>;
3023def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
3024def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
3025 Requires<[IsThumb2, UseMovt]>;
3026
3027def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3028 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
3029
Evan Chengb9803a82009-11-06 23:52:48 +00003030// Pseudo instruction that combines ldr from constpool and add pc. This should
3031// be expanded into two instructions late to allow if-conversion and
3032// scheduling.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00003033let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Chengb9803a82009-11-06 23:52:48 +00003034def t2LDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp),
Jim Grosbach78890f42010-10-01 23:21:38 +00003035 IIC_iLoadiALU, "",
Evan Chengb9803a82009-11-06 23:52:48 +00003036 [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
3037 imm:$cp))]>,
3038 Requires<[IsThumb2]>;
Johnny Chen23336552010-02-25 18:46:43 +00003039
3040//===----------------------------------------------------------------------===//
3041// Move between special register and ARM core register -- for disassembly only
3042//
3043
3044// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003045def t2MRS : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, cpsr",
Johnny Chen23336552010-02-25 18:46:43 +00003046 [/* For disassembly only; pattern left blank */]> {
3047 let Inst{31-27} = 0b11110;
3048 let Inst{26} = 0;
3049 let Inst{25-21} = 0b11111;
3050 let Inst{20} = 0; // The R bit.
3051 let Inst{15-14} = 0b10;
3052 let Inst{12} = 0;
3053}
3054
3055// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003056def t2MRSsys : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, spsr",
Johnny Chen23336552010-02-25 18:46:43 +00003057 [/* For disassembly only; pattern left blank */]> {
3058 let Inst{31-27} = 0b11110;
3059 let Inst{26} = 0;
3060 let Inst{25-21} = 0b11111;
3061 let Inst{20} = 1; // The R bit.
3062 let Inst{15-14} = 0b10;
3063 let Inst{12} = 0;
3064}
3065
Johnny Chen23336552010-02-25 18:46:43 +00003066// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003067def t2MSR : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00003068 "\tcpsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00003069 [/* For disassembly only; pattern left blank */]> {
3070 let Inst{31-27} = 0b11110;
3071 let Inst{26} = 0;
3072 let Inst{25-21} = 0b11100;
3073 let Inst{20} = 0; // The R bit.
3074 let Inst{15-14} = 0b10;
3075 let Inst{12} = 0;
3076}
3077
Johnny Chen23336552010-02-25 18:46:43 +00003078// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003079def t2MSRsys : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00003080 "\tspsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00003081 [/* For disassembly only; pattern left blank */]> {
3082 let Inst{31-27} = 0b11110;
3083 let Inst{26} = 0;
3084 let Inst{25-21} = 0b11100;
3085 let Inst{20} = 1; // The R bit.
3086 let Inst{15-14} = 0b10;
3087 let Inst{12} = 0;
3088}