blob: 9cad27e29b34764e2e1a2a9a3f8413377feb34a2 [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> {
904 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Evan Cheng699beba2009-10-27 00:08:59 +0000905 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000906 [(set rGPR:$dst, (opnode rGPR:$src))]> {
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 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000915 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Evan Cheng699beba2009-10-27 00:08:59 +0000916 opc, ".w\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000917 [(set rGPR:$dst, (opnode (rotr rGPR:$src, 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;
924 let Inst{5-4} = {?,?}; // rotate
925 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000926}
927
Eli Friedman761fa7a2010-06-24 18:20:04 +0000928// UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000929multiclass T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode> {
930 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Johnny Chen267124c2010-03-04 22:24:41 +0000931 opc, "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000932 [(set rGPR:$dst, (opnode rGPR:$src))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000933 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000934 let Inst{31-27} = 0b11111;
935 let Inst{26-23} = 0b0100;
936 let Inst{22-20} = opcod;
937 let Inst{19-16} = 0b1111; // Rn
938 let Inst{15-12} = 0b1111;
939 let Inst{7} = 1;
940 let Inst{5-4} = 0b00; // rotate
941 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000942 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Johnny Chen267124c2010-03-04 22:24:41 +0000943 opc, "\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000944 [(set rGPR:$dst, (opnode (rotr rGPR:$src, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000945 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000946 let Inst{31-27} = 0b11111;
947 let Inst{26-23} = 0b0100;
948 let Inst{22-20} = opcod;
949 let Inst{19-16} = 0b1111; // Rn
950 let Inst{15-12} = 0b1111;
951 let Inst{7} = 1;
952 let Inst{5-4} = {?,?}; // rotate
953 }
954}
955
Eli Friedman761fa7a2010-06-24 18:20:04 +0000956// SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
957// supported yet.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000958multiclass T2I_ext_rrot_sxtb16<bits<3> opcod, string opc> {
959 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Johnny Chen93042d12010-03-02 18:14:57 +0000960 opc, "\t$dst, $src", []> {
961 let Inst{31-27} = 0b11111;
962 let Inst{26-23} = 0b0100;
963 let Inst{22-20} = opcod;
964 let Inst{19-16} = 0b1111; // Rn
965 let Inst{15-12} = 0b1111;
966 let Inst{7} = 1;
967 let Inst{5-4} = 0b00; // rotate
968 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000969 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Johnny Chen93042d12010-03-02 18:14:57 +0000970 opc, "\t$dst, $src, ror $rot", []> {
971 let Inst{31-27} = 0b11111;
972 let Inst{26-23} = 0b0100;
973 let Inst{22-20} = opcod;
974 let Inst{19-16} = 0b1111; // Rn
975 let Inst{15-12} = 0b1111;
976 let Inst{7} = 1;
977 let Inst{5-4} = {?,?}; // rotate
978 }
979}
980
Evan Cheng0e55fd62010-09-30 01:08:25 +0000981/// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +0000982/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000983multiclass T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode> {
984 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iEXTAr,
Evan Cheng699beba2009-10-27 00:08:59 +0000985 opc, "\t$dst, $LHS, $RHS",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000986 [(set rGPR:$dst, (opnode rGPR:$LHS, rGPR:$RHS))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000987 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000988 let Inst{31-27} = 0b11111;
989 let Inst{26-23} = 0b0100;
990 let Inst{22-20} = opcod;
991 let Inst{15-12} = 0b1111;
992 let Inst{7} = 1;
993 let Inst{5-4} = 0b00; // rotate
994 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000995 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Evan Cheng0e55fd62010-09-30 01:08:25 +0000996 IIC_iEXTAsr, opc, "\t$dst, $LHS, $RHS, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000997 [(set rGPR:$dst, (opnode rGPR:$LHS,
998 (rotr rGPR:$RHS, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000999 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001000 let Inst{31-27} = 0b11111;
1001 let Inst{26-23} = 0b0100;
1002 let Inst{22-20} = opcod;
1003 let Inst{15-12} = 0b1111;
1004 let Inst{7} = 1;
1005 let Inst{5-4} = {?,?}; // rotate
1006 }
Evan Chengd27c9fc2009-07-03 01:43:10 +00001007}
1008
Johnny Chen93042d12010-03-02 18:14:57 +00001009// DO variant - disassembly only, no pattern
1010
Evan Cheng0e55fd62010-09-30 01:08:25 +00001011multiclass T2I_exta_rrot_DO<bits<3> opcod, string opc> {
Evan Cheng7e1bf302010-09-29 00:27:46 +00001012 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iEXTAr,
Johnny Chen93042d12010-03-02 18:14:57 +00001013 opc, "\t$dst, $LHS, $RHS", []> {
1014 let Inst{31-27} = 0b11111;
1015 let Inst{26-23} = 0b0100;
1016 let Inst{22-20} = opcod;
1017 let Inst{15-12} = 0b1111;
1018 let Inst{7} = 1;
1019 let Inst{5-4} = 0b00; // rotate
1020 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001021 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Evan Cheng7e1bf302010-09-29 00:27:46 +00001022 IIC_iEXTAsr, opc, "\t$dst, $LHS, $RHS, ror $rot", []> {
Johnny Chen93042d12010-03-02 18:14:57 +00001023 let Inst{31-27} = 0b11111;
1024 let Inst{26-23} = 0b0100;
1025 let Inst{22-20} = opcod;
1026 let Inst{15-12} = 0b1111;
1027 let Inst{7} = 1;
1028 let Inst{5-4} = {?,?}; // rotate
1029 }
1030}
1031
Anton Korobeynikov52237112009-06-17 18:13:58 +00001032//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +00001033// Instructions
1034//===----------------------------------------------------------------------===//
1035
1036//===----------------------------------------------------------------------===//
Evan Chenga09b9ca2009-06-24 23:47:58 +00001037// Miscellaneous Instructions.
1038//
1039
Evan Chenga09b9ca2009-06-24 23:47:58 +00001040// LEApcrel - Load a pc-relative address into a register without offending the
1041// assembler.
Evan Chengea420b22010-05-19 01:52:25 +00001042let neverHasSideEffects = 1 in {
Evan Cheng9085f982010-05-19 07:28:01 +00001043let isReMaterializable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001044def t2LEApcrel : T2XI<(outs rGPR:$dst), (ins i32imm:$label, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +00001045 "adr${p}.w\t$dst, #$label", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001046 let Inst{31-27} = 0b11110;
1047 let Inst{25-24} = 0b10;
1048 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1049 let Inst{22} = 0;
1050 let Inst{20} = 0;
1051 let Inst{19-16} = 0b1111; // Rn
1052 let Inst{15} = 0;
1053}
Jim Grosbacha967d112010-06-21 21:27:27 +00001054} // neverHasSideEffects
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001055def t2LEApcrelJT : T2XI<(outs rGPR:$dst),
Bob Wilson4f38b382009-08-21 21:58:55 +00001056 (ins i32imm:$label, nohash_imm:$id, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +00001057 "adr${p}.w\t$dst, #${label}_${id}", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001058 let Inst{31-27} = 0b11110;
1059 let Inst{25-24} = 0b10;
1060 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1061 let Inst{22} = 0;
1062 let Inst{20} = 0;
1063 let Inst{19-16} = 0b1111; // Rn
1064 let Inst{15} = 0;
1065}
Evan Chenga09b9ca2009-06-24 23:47:58 +00001066
Evan Cheng86198642009-08-07 00:34:42 +00001067// ADD r, sp, {so_imm|i12}
Owen Andersonb9a643e2010-11-12 23:36:03 +00001068def t2ADDrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
1069 IIC_iALUi, "add", ".w\t$dst, $sp, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001070 let Inst{31-27} = 0b11110;
1071 let Inst{25} = 0;
1072 let Inst{24-21} = 0b1000;
1073 let Inst{20} = ?; // The S bit.
Owen Andersonb9a643e2010-11-12 23:36:03 +00001074 let Inst{19-16} = 0b1101; // Rn = sp
Johnny Chend68e1192009-12-15 17:24:14 +00001075 let Inst{15} = 0;
1076}
Owen Andersonb9a643e2010-11-12 23:36:03 +00001077def t2ADDrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
1078 IIC_iALUi, "addw", "\t$dst, $sp, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001079 let Inst{31-27} = 0b11110;
1080 let Inst{25} = 1;
1081 let Inst{24-21} = 0b0000;
1082 let Inst{20} = 0; // The S bit.
1083 let Inst{19-16} = 0b1101; // Rn = sp
1084 let Inst{15} = 0;
1085}
Evan Cheng86198642009-08-07 00:34:42 +00001086
1087// ADD r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +00001088def t2ADDrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00001089 IIC_iALUsi, "add", ".w\t$dst, $sp, $rhs", []> {
1090 let Inst{31-27} = 0b11101;
1091 let Inst{26-25} = 0b01;
1092 let Inst{24-21} = 0b1000;
1093 let Inst{20} = ?; // The S bit.
1094 let Inst{19-16} = 0b1101; // Rn = sp
1095 let Inst{15} = 0;
1096}
Evan Cheng86198642009-08-07 00:34:42 +00001097
1098// SUB r, sp, {so_imm|i12}
David Goodwin5d598aa2009-08-19 18:00:44 +00001099def t2SUBrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +00001100 IIC_iALUi, "sub", ".w\t$dst, $sp, $imm", []> {
1101 let Inst{31-27} = 0b11110;
1102 let Inst{25} = 0;
1103 let Inst{24-21} = 0b1101;
1104 let Inst{20} = ?; // The S bit.
1105 let Inst{19-16} = 0b1101; // Rn = sp
1106 let Inst{15} = 0;
1107}
David Goodwin5d598aa2009-08-19 18:00:44 +00001108def t2SUBrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +00001109 IIC_iALUi, "subw", "\t$dst, $sp, $imm", []> {
1110 let Inst{31-27} = 0b11110;
1111 let Inst{25} = 1;
1112 let Inst{24-21} = 0b0101;
1113 let Inst{20} = 0; // The S bit.
1114 let Inst{19-16} = 0b1101; // Rn = sp
1115 let Inst{15} = 0;
1116}
Evan Cheng86198642009-08-07 00:34:42 +00001117
1118// SUB r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +00001119def t2SUBrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
1120 IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001121 "sub", "\t$dst, $sp, $rhs", []> {
1122 let Inst{31-27} = 0b11101;
1123 let Inst{26-25} = 0b01;
1124 let Inst{24-21} = 0b1101;
1125 let Inst{20} = ?; // The S bit.
1126 let Inst{19-16} = 0b1101; // Rn = sp
1127 let Inst{15} = 0;
1128}
Evan Cheng86198642009-08-07 00:34:42 +00001129
Jim Grosbachb1dc3932010-05-05 20:44:35 +00001130// Signed and unsigned division on v7-M
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001131def t2SDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +00001132 "sdiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001133 [(set rGPR:$dst, (sdiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +00001134 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +00001135 let Inst{31-27} = 0b11111;
1136 let Inst{26-21} = 0b011100;
1137 let Inst{20} = 0b1;
1138 let Inst{15-12} = 0b1111;
1139 let Inst{7-4} = 0b1111;
1140}
1141
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001142def t2UDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +00001143 "udiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001144 [(set rGPR:$dst, (udiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +00001145 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +00001146 let Inst{31-27} = 0b11111;
1147 let Inst{26-21} = 0b011101;
1148 let Inst{20} = 0b1;
1149 let Inst{15-12} = 0b1111;
1150 let Inst{7-4} = 0b1111;
1151}
1152
Evan Chenga09b9ca2009-06-24 23:47:58 +00001153//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +00001154// Load / store Instructions.
1155//
1156
Evan Cheng055b0312009-06-29 07:51:04 +00001157// Load
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001158let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng7e2fe912010-10-28 06:47:08 +00001159defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001160 UnOpFrag<(load node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001161
Evan Chengf3c21b82009-06-30 02:15:48 +00001162// Loads with zero extension
Evan Cheng7e2fe912010-10-28 06:47:08 +00001163defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001164 UnOpFrag<(zextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001165defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001166 UnOpFrag<(zextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001167
Evan Chengf3c21b82009-06-30 02:15:48 +00001168// Loads with sign extension
Evan Cheng7e2fe912010-10-28 06:47:08 +00001169defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001170 UnOpFrag<(sextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001171defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001172 UnOpFrag<(sextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001173
Chris Lattnera1ca91a2010-11-02 23:40:41 +00001174let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
1175 isCodeGenOnly = 1 in { // $dst doesn't exist in asmstring?
Evan Chengf3c21b82009-06-30 02:15:48 +00001176// Load doubleword
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001177def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Chenge298ab22009-09-27 09:46:04 +00001178 (ins t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001179 IIC_iLoad_d_i, "ldrd", "\t$dst1, $addr", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001180def t2LDRDpci : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001181 (ins i32imm:$addr), IIC_iLoad_d_i,
Johnny Chen83142992010-01-05 22:37:28 +00001182 "ldrd", "\t$dst1, $addr", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001183 let Inst{19-16} = 0b1111; // Rn
1184}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001185} // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
Evan Chengf3c21b82009-06-30 02:15:48 +00001186
1187// zextload i1 -> zextload i8
1188def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1189 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1190def : T2Pat<(zextloadi1 t2addrmode_imm8:$addr),
1191 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1192def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1193 (t2LDRBs t2addrmode_so_reg:$addr)>;
1194def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1195 (t2LDRBpci tconstpool:$addr)>;
1196
1197// extload -> zextload
1198// FIXME: Reduce the number of patterns by legalizing extload to zextload
1199// earlier?
1200def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1201 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1202def : T2Pat<(extloadi1 t2addrmode_imm8:$addr),
1203 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1204def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1205 (t2LDRBs t2addrmode_so_reg:$addr)>;
1206def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1207 (t2LDRBpci tconstpool:$addr)>;
1208
1209def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1210 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1211def : T2Pat<(extloadi8 t2addrmode_imm8:$addr),
1212 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1213def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1214 (t2LDRBs t2addrmode_so_reg:$addr)>;
1215def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1216 (t2LDRBpci tconstpool:$addr)>;
1217
1218def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1219 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1220def : T2Pat<(extloadi16 t2addrmode_imm8:$addr),
1221 (t2LDRHi8 t2addrmode_imm8:$addr)>;
1222def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1223 (t2LDRHs t2addrmode_so_reg:$addr)>;
1224def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1225 (t2LDRHpci tconstpool:$addr)>;
Evan Cheng055b0312009-06-29 07:51:04 +00001226
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001227// FIXME: The destination register of the loads and stores can't be PC, but
1228// can be SP. We need another regclass (similar to rGPR) to represent
1229// that. Not a pressing issue since these are selected manually,
1230// not via pattern.
1231
Evan Chenge88d5ce2009-07-02 07:28:31 +00001232// Indexed loads
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001233let mayLoad = 1, neverHasSideEffects = 1 in {
Johnny Chend68e1192009-12-15 17:24:14 +00001234def t2LDR_PRE : T2Iidxldst<0, 0b10, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001235 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001236 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001237 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001238 []>;
1239
Johnny Chend68e1192009-12-15 17:24:14 +00001240def t2LDR_POST : T2Iidxldst<0, 0b10, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001241 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001242 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001243 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001244 []>;
1245
Johnny Chend68e1192009-12-15 17:24:14 +00001246def t2LDRB_PRE : T2Iidxldst<0, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001247 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001248 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001249 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001250 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001251def t2LDRB_POST : T2Iidxldst<0, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001252 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001253 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001254 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001255 []>;
1256
Johnny Chend68e1192009-12-15 17:24:14 +00001257def t2LDRH_PRE : T2Iidxldst<0, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001258 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001259 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001260 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001261 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001262def t2LDRH_POST : T2Iidxldst<0, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001263 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001264 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001265 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001266 []>;
1267
Johnny Chend68e1192009-12-15 17:24:14 +00001268def t2LDRSB_PRE : T2Iidxldst<1, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001269 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001270 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001271 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001272 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001273def t2LDRSB_POST : T2Iidxldst<1, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001274 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001275 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001276 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001277 []>;
1278
Johnny Chend68e1192009-12-15 17:24:14 +00001279def t2LDRSH_PRE : T2Iidxldst<1, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001280 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001281 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001282 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001283 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001284def t2LDRSH_POST : T2Iidxldst<1, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001285 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001286 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001287 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001288 []>;
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001289} // mayLoad = 1, neverHasSideEffects = 1
Evan Cheng4fbb9962009-07-02 23:16:11 +00001290
Johnny Chene54a3ef2010-03-03 18:45:36 +00001291// LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110) and are
1292// for disassembly only.
1293// Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001294class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1295 : T2Ii8<(outs GPR:$dst), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001296 "\t$dst, $addr", []> {
1297 let Inst{31-27} = 0b11111;
1298 let Inst{26-25} = 0b00;
1299 let Inst{24} = signed;
1300 let Inst{23} = 0;
1301 let Inst{22-21} = type;
1302 let Inst{20} = 1; // load
1303 let Inst{11} = 1;
1304 let Inst{10-8} = 0b110; // PUW.
1305}
1306
Evan Cheng0e55fd62010-09-30 01:08:25 +00001307def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1308def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1309def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1310def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1311def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
Johnny Chene54a3ef2010-03-03 18:45:36 +00001312
David Goodwin73b8f162009-06-30 22:11:34 +00001313// Store
Evan Cheng7e2fe912010-10-28 06:47:08 +00001314defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001315 BinOpFrag<(store node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001316defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001317 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001318defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001319 BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
David Goodwin73b8f162009-06-30 22:11:34 +00001320
David Goodwin6647cea2009-06-30 22:50:01 +00001321// Store doubleword
Chris Lattnera1ca91a2010-11-02 23:40:41 +00001322let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1323 isCodeGenOnly = 1 in // $src2 doesn't exist in asm string
Johnny Chend68e1192009-12-15 17:24:14 +00001324def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
Evan Chenge298ab22009-09-27 09:46:04 +00001325 (ins GPR:$src1, GPR:$src2, t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001326 IIC_iStore_d_r, "strd", "\t$src1, $addr", []>;
David Goodwin6647cea2009-06-30 22:50:01 +00001327
Evan Cheng6d94f112009-07-03 00:06:39 +00001328// Indexed stores
Johnny Chend68e1192009-12-15 17:24:14 +00001329def t2STR_PRE : T2Iidxldst<0, 0b10, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001330 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001331 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001332 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001333 [(set GPR:$base_wb,
1334 (pre_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1335
Johnny Chend68e1192009-12-15 17:24:14 +00001336def t2STR_POST : T2Iidxldst<0, 0b10, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001337 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001338 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001339 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001340 [(set GPR:$base_wb,
Jim Grosbach6935efc2009-11-24 00:20:27 +00001341 (post_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001342
Johnny Chend68e1192009-12-15 17:24:14 +00001343def t2STRH_PRE : T2Iidxldst<0, 0b01, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001344 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001345 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001346 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001347 [(set GPR:$base_wb,
1348 (pre_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1349
Johnny Chend68e1192009-12-15 17:24:14 +00001350def t2STRH_POST : T2Iidxldst<0, 0b01, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001351 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001352 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001353 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001354 [(set GPR:$base_wb,
1355 (post_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1356
Johnny Chend68e1192009-12-15 17:24:14 +00001357def t2STRB_PRE : T2Iidxldst<0, 0b00, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001358 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001359 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001360 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001361 [(set GPR:$base_wb,
1362 (pre_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1363
Johnny Chend68e1192009-12-15 17:24:14 +00001364def t2STRB_POST : T2Iidxldst<0, 0b00, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001365 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001366 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001367 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001368 [(set GPR:$base_wb,
1369 (post_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1370
Johnny Chene54a3ef2010-03-03 18:45:36 +00001371// STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1372// only.
1373// Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001374class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1375 : T2Ii8<(outs GPR:$src), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001376 "\t$src, $addr", []> {
1377 let Inst{31-27} = 0b11111;
1378 let Inst{26-25} = 0b00;
1379 let Inst{24} = 0; // not signed
1380 let Inst{23} = 0;
1381 let Inst{22-21} = type;
1382 let Inst{20} = 0; // store
1383 let Inst{11} = 1;
1384 let Inst{10-8} = 0b110; // PUW
1385}
1386
Evan Cheng0e55fd62010-09-30 01:08:25 +00001387def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1388def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1389def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
David Goodwind1fa1202009-07-01 00:01:13 +00001390
Johnny Chenae1757b2010-03-11 01:13:36 +00001391// ldrd / strd pre / post variants
1392// For disassembly only.
1393
1394def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001395 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001396 "ldrd", "\t$dst1, $dst2, [$base, $imm]!", []>;
1397
1398def t2LDRD_POST : T2Ii8s4<0, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001399 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001400 "ldrd", "\t$dst1, $dst2, [$base], $imm", []>;
1401
1402def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs),
1403 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001404 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base, $imm]!", []>;
Johnny Chenae1757b2010-03-11 01:13:36 +00001405
1406def t2STRD_POST : T2Ii8s4<0, 1, 0, (outs),
1407 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001408 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base], $imm", []>;
Evan Cheng2889cce2009-07-03 00:18:36 +00001409
Johnny Chen0635fc52010-03-04 17:40:44 +00001410// T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1411// data/instruction access. These are for disassembly only.
Evan Chengdfed19f2010-11-03 06:34:55 +00001412// instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1413// (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
Evan Cheng416941d2010-11-04 05:19:35 +00001414multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001415
Evan Chengdfed19f2010-11-03 06:34:55 +00001416 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001417 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001418 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001419 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001420 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001421 let Inst{23} = 1; // U = 1
1422 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001423 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001424 let Inst{20} = 1;
1425 let Inst{15-12} = 0b1111;
1426 }
1427
Evan Chengdfed19f2010-11-03 06:34:55 +00001428 def i8 : T2Ii8<(outs), (ins t2addrmode_imm8:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001429 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001430 [(ARMPreload t2addrmode_imm8:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001431 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001432 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001433 let Inst{23} = 0; // U = 0
1434 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001435 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001436 let Inst{20} = 1;
1437 let Inst{15-12} = 0b1111;
1438 let Inst{11-8} = 0b1100;
1439 }
1440
Evan Chengdfed19f2010-11-03 06:34:55 +00001441 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001442 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001443 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
Evan Chengbc7deb02010-11-03 05:14:24 +00001444 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001445 let Inst{24} = instr;
Evan Chengbc7deb02010-11-03 05:14:24 +00001446 let Inst{23} = 0; // add = TRUE for T1
1447 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001448 let Inst{21} = write;
Evan Chengbc7deb02010-11-03 05:14:24 +00001449 let Inst{20} = 1;
1450 let Inst{15-12} = 0b1111;
1451 let Inst{11-6} = 0000000;
1452 }
1453
1454 let isCodeGenOnly = 1 in
Evan Chengdfed19f2010-11-03 06:34:55 +00001455 def pci : T2Ipc<(outs), (ins i32imm:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001456 "\t$addr",
1457 []> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001458 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001459 let Inst{24} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001460 let Inst{23} = ?; // add = (U == 1)
1461 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001462 let Inst{21} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001463 let Inst{20} = 1;
1464 let Inst{19-16} = 0b1111; // Rn = 0b1111
1465 let Inst{15-12} = 0b1111;
1466 }
Johnny Chen0635fc52010-03-04 17:40:44 +00001467}
1468
Evan Cheng416941d2010-11-04 05:19:35 +00001469defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1470defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1471defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
Johnny Chen0635fc52010-03-04 17:40:44 +00001472
Evan Cheng2889cce2009-07-03 00:18:36 +00001473//===----------------------------------------------------------------------===//
1474// Load / store multiple Instructions.
1475//
1476
Bill Wendling6c470b82010-11-13 09:09:38 +00001477multiclass thumb2_ldst_mult<string asm, InstrItinClass itin,
1478 InstrItinClass itin_upd, bit L_bit> {
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001479 def ia :
Bill Wendling6c470b82010-11-13 09:09:38 +00001480 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1481 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
1482 bits<4> Rn;
1483 bits<16> regs;
1484
1485 let Inst{31-27} = 0b11101;
1486 let Inst{26-25} = 0b00;
1487 let Inst{24-23} = 0b01; // Increment After
1488 let Inst{22} = 0;
1489 let Inst{21} = 0; // No writeback
1490 let Inst{20} = L_bit;
1491 let Inst{19-16} = Rn;
1492 let Inst{15-0} = regs;
1493 }
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001494 def ia_UPD :
Bill Wendling6c470b82010-11-13 09:09:38 +00001495 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1496 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1497 bits<4> Rn;
1498 bits<16> regs;
1499
1500 let Inst{31-27} = 0b11101;
1501 let Inst{26-25} = 0b00;
1502 let Inst{24-23} = 0b01; // Increment After
1503 let Inst{22} = 0;
1504 let Inst{21} = 1; // Writeback
1505 let Inst{20} = L_bit;
1506 let Inst{19-16} = Rn;
1507 let Inst{15-0} = regs;
1508 }
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001509 def db :
Bill Wendling6c470b82010-11-13 09:09:38 +00001510 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1511 itin, !strconcat(asm, "db${p}.w\t$Rn, $regs"), []> {
1512 bits<4> Rn;
1513 bits<16> regs;
1514
1515 let Inst{31-27} = 0b11101;
1516 let Inst{26-25} = 0b00;
1517 let Inst{24-23} = 0b10; // Decrement Before
1518 let Inst{22} = 0;
1519 let Inst{21} = 0; // No writeback
1520 let Inst{20} = L_bit;
1521 let Inst{19-16} = Rn;
1522 let Inst{15-0} = regs;
1523 }
Bill Wendling1f4abcf2010-11-13 10:43:34 +00001524 def db_UPD :
Bill Wendling6c470b82010-11-13 09:09:38 +00001525 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1526 itin_upd, !strconcat(asm, "db${p}.w\t$Rn, $regs"), "$Rn = $wb", []> {
1527 bits<4> Rn;
1528 bits<16> regs;
1529
1530 let Inst{31-27} = 0b11101;
1531 let Inst{26-25} = 0b00;
1532 let Inst{24-23} = 0b10; // Decrement Before
1533 let Inst{22} = 0;
1534 let Inst{21} = 1; // Writeback
1535 let Inst{20} = L_bit;
1536 let Inst{19-16} = Rn;
1537 let Inst{15-0} = regs;
1538 }
1539}
1540
Bill Wendlingc93989a2010-11-13 11:20:05 +00001541/* TODO:
1542let neverHasSideEffects = 1 in {
Bill Wendlingddc918b2010-11-13 10:57:02 +00001543
1544let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1545defm t2LDM : thumb2_ldst_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>;
1546
1547let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1548defm t2STM : thumb2_ldst_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>;
1549
1550} // neverHasSideEffects
Bill Wendlingc93989a2010-11-13 11:20:05 +00001551*/
Bill Wendlingddc918b2010-11-13 10:57:02 +00001552
Chris Lattner39ee0362010-10-31 19:10:56 +00001553let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
1554 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001555def t2LDM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001556 reglist:$dsts, variable_ops), IIC_iLoad_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001557 "ldm${amode}${p}.w\t$Rn, $dsts", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001558 let Inst{31-27} = 0b11101;
1559 let Inst{26-25} = 0b00;
1560 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1561 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001562 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001563 let Inst{20} = 1; // Load
1564}
Evan Cheng2889cce2009-07-03 00:18:36 +00001565
Jim Grosbache6913602010-11-03 01:01:43 +00001566def t2LDM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001567 reglist:$dsts, variable_ops),
1568 IIC_iLoad_mu,
Jim Grosbache6913602010-11-03 01:01:43 +00001569 "ldm${amode}${p}.w\t$Rn!, $dsts",
1570 "$Rn = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001571 let Inst{31-27} = 0b11101;
1572 let Inst{26-25} = 0b00;
1573 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1574 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001575 let Inst{21} = 1; // The W bit.
1576 let Inst{20} = 1; // Load
1577}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001578} // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001579
Chris Lattner39ee0362010-10-31 19:10:56 +00001580let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1581 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001582def t2STM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001583 reglist:$srcs, variable_ops), IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001584 "stm${amode}${p}.w\t$Rn, $srcs", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +00001585 let Inst{31-27} = 0b11101;
1586 let Inst{26-25} = 0b00;
1587 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1588 let Inst{22} = 0;
1589 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001590 let Inst{20} = 0; // Store
1591}
Evan Cheng2889cce2009-07-03 00:18:36 +00001592
Jim Grosbache6913602010-11-03 01:01:43 +00001593def t2STM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +00001594 reglist:$srcs, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00001595 IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001596 "stm${amode}${p}.w\t$Rn!, $srcs",
1597 "$Rn = $wb", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +00001598 let Inst{31-27} = 0b11101;
1599 let Inst{26-25} = 0b00;
1600 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1601 let Inst{22} = 0;
1602 let Inst{21} = 1; // The W bit.
1603 let Inst{20} = 0; // Store
1604}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001605} // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001606
Evan Cheng9cb9e672009-06-27 02:26:13 +00001607//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001608// Move Instructions.
1609//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001610
Evan Chengf49810c2009-06-23 17:48:47 +00001611let neverHasSideEffects = 1 in
David Goodwin5d598aa2009-08-19 18:00:44 +00001612def t2MOVr : T2sI<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVr,
Johnny Chend68e1192009-12-15 17:24:14 +00001613 "mov", ".w\t$dst, $src", []> {
1614 let Inst{31-27} = 0b11101;
1615 let Inst{26-25} = 0b01;
1616 let Inst{24-21} = 0b0010;
1617 let Inst{20} = ?; // The S bit.
1618 let Inst{19-16} = 0b1111; // Rn
1619 let Inst{14-12} = 0b000;
1620 let Inst{7-4} = 0b0000;
1621}
Evan Chengf49810c2009-06-23 17:48:47 +00001622
Evan Cheng5adb66a2009-09-28 09:14:39 +00001623// AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1624let isReMaterializable = 1, isAsCheapAsAMove = 1, AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001625def t2MOVi : T2sI<(outs rGPR:$dst), (ins t2_so_imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001626 "mov", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001627 [(set rGPR:$dst, t2_so_imm:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001628 let Inst{31-27} = 0b11110;
1629 let Inst{25} = 0;
1630 let Inst{24-21} = 0b0010;
1631 let Inst{20} = ?; // The S bit.
1632 let Inst{19-16} = 0b1111; // Rn
1633 let Inst{15} = 0;
1634}
David Goodwin83b35932009-06-26 16:10:07 +00001635
1636let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001637def t2MOVi16 : T2I<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001638 "movw", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001639 [(set rGPR:$dst, imm0_65535:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001640 let Inst{31-27} = 0b11110;
1641 let Inst{25} = 1;
1642 let Inst{24-21} = 0b0010;
1643 let Inst{20} = 0; // The S bit.
1644 let Inst{15} = 0;
1645}
Evan Chengf49810c2009-06-23 17:48:47 +00001646
Evan Cheng3850a6a2009-06-23 05:23:49 +00001647let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001648def t2MOVTi16 : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$imm), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001649 "movt", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001650 [(set rGPR:$dst,
1651 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001652 let Inst{31-27} = 0b11110;
1653 let Inst{25} = 1;
1654 let Inst{24-21} = 0b0110;
1655 let Inst{20} = 0; // The S bit.
1656 let Inst{15} = 0;
1657}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001658
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001659def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
Evan Cheng20956592009-10-21 08:15:52 +00001660
Anton Korobeynikov52237112009-06-17 18:13:58 +00001661//===----------------------------------------------------------------------===//
Evan Chengd27c9fc2009-07-03 01:43:10 +00001662// Extend Instructions.
1663//
1664
1665// Sign extenders
1666
Evan Cheng0e55fd62010-09-30 01:08:25 +00001667defm t2SXTB : T2I_ext_rrot<0b100, "sxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001668 UnOpFrag<(sext_inreg node:$Src, i8)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001669defm t2SXTH : T2I_ext_rrot<0b000, "sxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001670 UnOpFrag<(sext_inreg node:$Src, i16)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001671defm t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001672
Evan Cheng0e55fd62010-09-30 01:08:25 +00001673defm t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001674 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001675defm t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001676 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001677defm t2SXTAB16 : T2I_exta_rrot_DO<0b010, "sxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001678
Johnny Chen93042d12010-03-02 18:14:57 +00001679// TODO: SXT(A){B|H}16 - done for disassembly only
Evan Chengd27c9fc2009-07-03 01:43:10 +00001680
1681// Zero extenders
1682
1683let AddedComplexity = 16 in {
Evan Cheng0e55fd62010-09-30 01:08:25 +00001684defm t2UXTB : T2I_ext_rrot<0b101, "uxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001685 UnOpFrag<(and node:$Src, 0x000000FF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001686defm t2UXTH : T2I_ext_rrot<0b001, "uxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001687 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001688defm t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
Johnny Chend68e1192009-12-15 17:24:14 +00001689 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001690
Jim Grosbach79464942010-07-28 23:17:45 +00001691// FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1692// The transformation should probably be done as a combiner action
1693// instead so we can include a check for masking back in the upper
1694// eight bits of the source into the lower eight bits of the result.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001695//def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001696// (t2UXTB16r_rot rGPR:$Src, 24)>,
1697// Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001698def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001699 (t2UXTB16r_rot rGPR:$Src, 8)>,
1700 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001701
Evan Cheng0e55fd62010-09-30 01:08:25 +00001702defm t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001703 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001704defm t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001705 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001706defm t2UXTAB16 : T2I_exta_rrot_DO<0b011, "uxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001707}
1708
1709//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001710// Arithmetic Instructions.
1711//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001712
Johnny Chend68e1192009-12-15 17:24:14 +00001713defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1714 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1715defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1716 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001717
Evan Chengf49810c2009-06-23 17:48:47 +00001718// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
Johnny Chend68e1192009-12-15 17:24:14 +00001719defm t2ADDS : T2I_bin_s_irs <0b1000, "add",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001720 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001721 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1722defm t2SUBS : T2I_bin_s_irs <0b1101, "sub",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001723 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001724 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001725
Johnny Chend68e1192009-12-15 17:24:14 +00001726defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001727 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00001728defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001729 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001730defm t2ADCS : T2I_adde_sube_s_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001731 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001732defm t2SBCS : T2I_adde_sube_s_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001733 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001734
David Goodwin752aa7d2009-07-27 16:39:05 +00001735// RSB
Bob Wilson20d8e4e2010-08-13 23:24:25 +00001736defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
Johnny Chend68e1192009-12-15 17:24:14 +00001737 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1738defm t2RSBS : T2I_rbin_s_is <0b1110, "rsb",
1739 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001740
1741// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001742// The assume-no-carry-in form uses the negation of the input since add/sub
1743// assume opposite meanings of the carry flag (i.e., carry == !borrow).
1744// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1745// details.
1746// The AddedComplexity preferences the first variant over the others since
1747// it can be shrunk to a 16-bit wide encoding, while the others cannot.
Evan Chengfa2ea1a2009-08-04 01:41:15 +00001748let AddedComplexity = 1 in
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001749def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1750 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1751def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1752 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1753def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1754 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1755let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001756def : T2Pat<(addc rGPR:$src, imm0_255_neg:$imm),
1757 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1758def : T2Pat<(addc rGPR:$src, t2_so_imm_neg:$imm),
1759 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001760// The with-carry-in form matches bitwise not instead of the negation.
1761// Effectively, the inverse interpretation of the carry flag already accounts
1762// for part of the negation.
1763let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001764def : T2Pat<(adde rGPR:$src, imm0_255_not:$imm),
1765 (t2SBCSri rGPR:$src, imm0_255_not:$imm)>;
1766def : T2Pat<(adde rGPR:$src, t2_so_imm_not:$imm),
1767 (t2SBCSri rGPR:$src, t2_so_imm_not:$imm)>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001768
Johnny Chen93042d12010-03-02 18:14:57 +00001769// Select Bytes -- for disassembly only
1770
1771def t2SEL : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), NoItinerary, "sel",
1772 "\t$dst, $a, $b", []> {
1773 let Inst{31-27} = 0b11111;
1774 let Inst{26-24} = 0b010;
1775 let Inst{23} = 0b1;
1776 let Inst{22-20} = 0b010;
1777 let Inst{15-12} = 0b1111;
1778 let Inst{7} = 0b1;
1779 let Inst{6-4} = 0b000;
1780}
1781
Johnny Chenadc77332010-02-26 22:04:29 +00001782// A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1783// And Miscellaneous operations -- for disassembly only
Nate Begeman692433b2010-07-29 17:56:55 +00001784class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
1785 list<dag> pat = [/* For disassembly only; pattern left blank */]>
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001786 : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), NoItinerary, opc,
Nate Begeman692433b2010-07-29 17:56:55 +00001787 "\t$dst, $a, $b", pat> {
Johnny Chenadc77332010-02-26 22:04:29 +00001788 let Inst{31-27} = 0b11111;
1789 let Inst{26-23} = 0b0101;
1790 let Inst{22-20} = op22_20;
1791 let Inst{15-12} = 0b1111;
1792 let Inst{7-4} = op7_4;
1793}
1794
1795// Saturating add/subtract -- for disassembly only
1796
Nate Begeman692433b2010-07-29 17:56:55 +00001797def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001798 [(set rGPR:$dst, (int_arm_qadd rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001799def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
1800def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
1801def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
1802def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd">;
1803def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub">;
1804def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
Nate Begeman692433b2010-07-29 17:56:55 +00001805def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001806 [(set rGPR:$dst, (int_arm_qsub rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001807def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
1808def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
1809def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
1810def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
1811def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
1812def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
1813def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
1814def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
1815
1816// Signed/Unsigned add/subtract -- for disassembly only
1817
1818def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
1819def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
1820def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
1821def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
1822def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
1823def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
1824def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
1825def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
1826def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
1827def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
1828def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
1829def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
1830
1831// Signed/Unsigned halving add/subtract -- for disassembly only
1832
1833def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
1834def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
1835def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
1836def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
1837def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
1838def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
1839def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
1840def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
1841def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
1842def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
1843def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
1844def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
1845
1846// Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
1847
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001848def t2USAD8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1849 (ins rGPR:$a, rGPR:$b),
Johnny Chenadc77332010-02-26 22:04:29 +00001850 NoItinerary, "usad8", "\t$dst, $a, $b", []> {
1851 let Inst{15-12} = 0b1111;
1852}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001853def t2USADA8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1854 (ins rGPR:$a, rGPR:$b, rGPR:$acc), NoItinerary, "usada8",
Johnny Chenadc77332010-02-26 22:04:29 +00001855 "\t$dst, $a, $b, $acc", []>;
1856
1857// Signed/Unsigned saturate -- for disassembly only
1858
Bob Wilson22f5dc72010-08-16 18:27:34 +00001859def t2SSAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001860 NoItinerary, "ssat", "\t$dst, $bit_pos, $a$sh",
1861 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001862 let Inst{31-27} = 0b11110;
1863 let Inst{25-22} = 0b1100;
1864 let Inst{20} = 0;
1865 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001866}
1867
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001868def t2SSAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001869 "ssat16", "\t$dst, $bit_pos, $a",
1870 [/* For disassembly only; pattern left blank */]> {
1871 let Inst{31-27} = 0b11110;
1872 let Inst{25-22} = 0b1100;
1873 let Inst{20} = 0;
1874 let Inst{15} = 0;
1875 let Inst{21} = 1; // sh = '1'
1876 let Inst{14-12} = 0b000; // imm3 = '000'
1877 let Inst{7-6} = 0b00; // imm2 = '00'
1878}
1879
Bob Wilson22f5dc72010-08-16 18:27:34 +00001880def t2USAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001881 NoItinerary, "usat", "\t$dst, $bit_pos, $a$sh",
1882 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001883 let Inst{31-27} = 0b11110;
1884 let Inst{25-22} = 0b1110;
1885 let Inst{20} = 0;
1886 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001887}
1888
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001889def t2USAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001890 "usat16", "\t$dst, $bit_pos, $a",
1891 [/* For disassembly only; pattern left blank */]> {
1892 let Inst{31-27} = 0b11110;
1893 let Inst{25-22} = 0b1110;
1894 let Inst{20} = 0;
1895 let Inst{15} = 0;
1896 let Inst{21} = 1; // sh = '1'
1897 let Inst{14-12} = 0b000; // imm3 = '000'
1898 let Inst{7-6} = 0b00; // imm2 = '00'
1899}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001900
Bob Wilson38aa2872010-08-13 21:48:10 +00001901def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
1902def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
Nate Begeman0e0a20e2010-07-29 22:48:09 +00001903
Evan Chengf49810c2009-06-23 17:48:47 +00001904//===----------------------------------------------------------------------===//
Evan Chenga67efd12009-06-23 19:39:13 +00001905// Shift and rotate Instructions.
1906//
1907
Johnny Chend68e1192009-12-15 17:24:14 +00001908defm t2LSL : T2I_sh_ir<0b00, "lsl", BinOpFrag<(shl node:$LHS, node:$RHS)>>;
1909defm t2LSR : T2I_sh_ir<0b01, "lsr", BinOpFrag<(srl node:$LHS, node:$RHS)>>;
1910defm t2ASR : T2I_sh_ir<0b10, "asr", BinOpFrag<(sra node:$LHS, node:$RHS)>>;
1911defm t2ROR : T2I_sh_ir<0b11, "ror", BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
Evan Chenga67efd12009-06-23 19:39:13 +00001912
David Goodwinca01a8d2009-09-01 18:32:09 +00001913let Uses = [CPSR] in {
Jim Grosbach792e9792010-10-14 20:43:44 +00001914def t2RRX : T2sI<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +00001915 "rrx", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001916 [(set rGPR:$dst, (ARMrrx rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001917 let Inst{31-27} = 0b11101;
1918 let Inst{26-25} = 0b01;
1919 let Inst{24-21} = 0b0010;
1920 let Inst{20} = ?; // The S bit.
1921 let Inst{19-16} = 0b1111; // Rn
1922 let Inst{14-12} = 0b000;
1923 let Inst{7-4} = 0b0011;
1924}
David Goodwinca01a8d2009-09-01 18:32:09 +00001925}
Evan Chenga67efd12009-06-23 19:39:13 +00001926
David Goodwin3583df72009-07-28 17:06:49 +00001927let Defs = [CPSR] in {
Owen Andersonbb6315d2010-11-15 19:58:36 +00001928def t2MOVsrl_flag : T2TwoRegShiftImm<
1929 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
1930 "lsrs", ".w\t$Rd, $Rm, #1",
1931 [(set rGPR:$Rd, (ARMsrl_flag rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001932 let Inst{31-27} = 0b11101;
1933 let Inst{26-25} = 0b01;
1934 let Inst{24-21} = 0b0010;
1935 let Inst{20} = 1; // The S bit.
1936 let Inst{19-16} = 0b1111; // Rn
1937 let Inst{5-4} = 0b01; // Shift type.
1938 // Shift amount = Inst{14-12:7-6} = 1.
1939 let Inst{14-12} = 0b000;
1940 let Inst{7-6} = 0b01;
1941}
Owen Andersonbb6315d2010-11-15 19:58:36 +00001942def t2MOVsra_flag : T2TwoRegShiftImm<
1943 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
1944 "asrs", ".w\t$Rd, $Rm, #1",
1945 [(set rGPR:$Rd, (ARMsra_flag rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001946 let Inst{31-27} = 0b11101;
1947 let Inst{26-25} = 0b01;
1948 let Inst{24-21} = 0b0010;
1949 let Inst{20} = 1; // The S bit.
1950 let Inst{19-16} = 0b1111; // Rn
1951 let Inst{5-4} = 0b10; // Shift type.
1952 // Shift amount = Inst{14-12:7-6} = 1.
1953 let Inst{14-12} = 0b000;
1954 let Inst{7-6} = 0b01;
1955}
David Goodwin3583df72009-07-28 17:06:49 +00001956}
1957
Evan Chenga67efd12009-06-23 19:39:13 +00001958//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +00001959// Bitwise Instructions.
1960//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001961
Johnny Chend68e1192009-12-15 17:24:14 +00001962defm t2AND : T2I_bin_w_irs<0b0000, "and",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001963 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001964 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1965defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001966 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001967 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1968defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001969 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001970 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Evan Chengf49810c2009-06-23 17:48:47 +00001971
Johnny Chend68e1192009-12-15 17:24:14 +00001972defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
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, (not node:$RHS))>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001975
Evan Chengf49810c2009-06-23 17:48:47 +00001976let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001977def t2BFC : T2I<(outs rGPR:$dst), (ins rGPR:$src, bf_inv_mask_imm:$imm),
David Goodwin2f54a2f2009-11-02 17:28:36 +00001978 IIC_iUNAsi, "bfc", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001979 [(set rGPR:$dst, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001980 let Inst{31-27} = 0b11110;
1981 let Inst{25} = 1;
1982 let Inst{24-20} = 0b10110;
1983 let Inst{19-16} = 0b1111; // Rn
1984 let Inst{15} = 0;
1985}
Evan Chengf49810c2009-06-23 17:48:47 +00001986
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001987def t2SBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001988 IIC_iUNAsi, "sbfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001989 let Inst{31-27} = 0b11110;
1990 let Inst{25} = 1;
1991 let Inst{24-20} = 0b10100;
1992 let Inst{15} = 0;
1993}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00001994
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001995def t2UBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001996 IIC_iUNAsi, "ubfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001997 let Inst{31-27} = 0b11110;
1998 let Inst{25} = 1;
1999 let Inst{24-20} = 0b11100;
2000 let Inst{15} = 0;
2001}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00002002
Johnny Chen9474d552010-02-02 19:31:58 +00002003// A8.6.18 BFI - Bitfield insert (Encoding T1)
Jim Grosbach469bbdb2010-07-16 23:05:05 +00002004let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002005def t2BFI : T2I<(outs rGPR:$dst),
2006 (ins rGPR:$src, rGPR:$val, bf_inv_mask_imm:$imm),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002007 IIC_iBITi, "bfi", "\t$dst, $val, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002008 [(set rGPR:$dst, (ARMbfi rGPR:$src, rGPR:$val,
Jim Grosbach469bbdb2010-07-16 23:05:05 +00002009 bf_inv_mask_imm:$imm))]> {
Johnny Chen9474d552010-02-02 19:31:58 +00002010 let Inst{31-27} = 0b11110;
2011 let Inst{25} = 1;
2012 let Inst{24-20} = 0b10110;
2013 let Inst{15} = 0;
2014}
Evan Chengf49810c2009-06-23 17:48:47 +00002015
Evan Cheng7e1bf302010-09-29 00:27:46 +00002016defm t2ORN : T2I_bin_irs<0b0011, "orn",
2017 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2018 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002019
2020// Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
2021let AddedComplexity = 1 in
Evan Cheng5d42c562010-09-29 00:49:25 +00002022defm t2MVN : T2I_un_irs <0b0011, "mvn",
Evan Cheng3881cb72010-09-29 22:42:35 +00002023 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
Evan Cheng5d42c562010-09-29 00:49:25 +00002024 UnOpFrag<(not node:$Src)>, 1, 1>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002025
2026
Jim Grosbachf084a5e2010-07-20 16:07:04 +00002027let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002028def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
2029 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002030
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002031// FIXME: Disable this pattern on Darwin to workaround an assembler bug.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002032def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
2033 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
Evan Chengea253b92009-08-12 01:56:42 +00002034 Requires<[IsThumb2]>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002035
2036def : T2Pat<(t2_so_imm_not:$src),
2037 (t2MVNi t2_so_imm_not:$src)>;
2038
Evan Chengf49810c2009-06-23 17:48:47 +00002039//===----------------------------------------------------------------------===//
2040// Multiply Instructions.
2041//
Evan Cheng8de898a2009-06-26 00:19:44 +00002042let isCommutable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002043def t2MUL: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00002044 "mul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002045 [(set rGPR:$dst, (mul rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002046 let Inst{31-27} = 0b11111;
2047 let Inst{26-23} = 0b0110;
2048 let Inst{22-20} = 0b000;
2049 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2050 let Inst{7-4} = 0b0000; // Multiply
2051}
Evan Chengf49810c2009-06-23 17:48:47 +00002052
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002053def t2MLA: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00002054 "mla", "\t$dst, $a, $b, $c",
2055 [(set rGPR:$dst, (add (mul rGPR:$a, rGPR:$b), rGPR:$c))]> {
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} = {?, ?, ?, ?}; // Ra
2060 let Inst{7-4} = 0b0000; // Multiply
2061}
Evan Chengf49810c2009-06-23 17:48:47 +00002062
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002063def t2MLS: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00002064 "mls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002065 [(set rGPR:$dst, (sub rGPR:$c, (mul rGPR:$a, rGPR:$b)))]> {
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} = 0b0001; // Multiply and Subtract
2071}
Evan Chengf49810c2009-06-23 17:48:47 +00002072
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002073// Extra precision multiplies with low / high results
2074let neverHasSideEffects = 1 in {
2075let isCommutable = 1 in {
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002076def t2SMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2077 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00002078 "smull", "\t$ldst, $hdst, $a, $b", []> {
2079 let Inst{31-27} = 0b11111;
2080 let Inst{26-23} = 0b0111;
2081 let Inst{22-20} = 0b000;
2082 let Inst{7-4} = 0b0000;
2083}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002084
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002085def t2UMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2086 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00002087 "umull", "\t$ldst, $hdst, $a, $b", []> {
2088 let Inst{31-27} = 0b11111;
2089 let Inst{26-23} = 0b0111;
2090 let Inst{22-20} = 0b010;
2091 let Inst{7-4} = 0b0000;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002092}
Johnny Chend68e1192009-12-15 17:24:14 +00002093} // isCommutable
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002094
2095// Multiply + accumulate
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002096def t2SMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2097 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00002098 "smlal", "\t$ldst, $hdst, $a, $b", []>{
2099 let Inst{31-27} = 0b11111;
2100 let Inst{26-23} = 0b0111;
2101 let Inst{22-20} = 0b100;
2102 let Inst{7-4} = 0b0000;
2103}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002104
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002105def t2UMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2106 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00002107 "umlal", "\t$ldst, $hdst, $a, $b", []>{
2108 let Inst{31-27} = 0b11111;
2109 let Inst{26-23} = 0b0111;
2110 let Inst{22-20} = 0b110;
2111 let Inst{7-4} = 0b0000;
2112}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002113
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002114def t2UMAAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
2115 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00002116 "umaal", "\t$ldst, $hdst, $a, $b", []>{
2117 let Inst{31-27} = 0b11111;
2118 let Inst{26-23} = 0b0111;
2119 let Inst{22-20} = 0b110;
2120 let Inst{7-4} = 0b0110;
2121}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002122} // neverHasSideEffects
2123
Johnny Chen93042d12010-03-02 18:14:57 +00002124// Rounding variants of the below included for disassembly only
2125
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002126// Most significant word multiply
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002127def t2SMMUL : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00002128 "smmul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002129 [(set rGPR:$dst, (mulhs rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002130 let Inst{31-27} = 0b11111;
2131 let Inst{26-23} = 0b0110;
2132 let Inst{22-20} = 0b101;
2133 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2134 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2135}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002136
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002137def t2SMMULR : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Johnny Chen93042d12010-03-02 18:14:57 +00002138 "smmulr", "\t$dst, $a, $b", []> {
2139 let Inst{31-27} = 0b11111;
2140 let Inst{26-23} = 0b0110;
2141 let Inst{22-20} = 0b101;
2142 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2143 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2144}
2145
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002146def t2SMMLA : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00002147 "smmla", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002148 [(set rGPR:$dst, (add (mulhs rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002149 let Inst{31-27} = 0b11111;
2150 let Inst{26-23} = 0b0110;
2151 let Inst{22-20} = 0b101;
2152 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2153 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2154}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002155
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002156def t2SMMLAR: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00002157 "smmlar", "\t$dst, $a, $b, $c", []> {
2158 let Inst{31-27} = 0b11111;
2159 let Inst{26-23} = 0b0110;
2160 let Inst{22-20} = 0b101;
2161 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2162 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2163}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002164
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002165def t2SMMLS: T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00002166 "smmls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002167 [(set rGPR:$dst, (sub rGPR:$c, (mulhs rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002168 let Inst{31-27} = 0b11111;
2169 let Inst{26-23} = 0b0110;
2170 let Inst{22-20} = 0b110;
2171 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2172 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2173}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002174
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002175def t2SMMLSR:T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00002176 "smmlsr", "\t$dst, $a, $b, $c", []> {
2177 let Inst{31-27} = 0b11111;
2178 let Inst{26-23} = 0b0110;
2179 let Inst{22-20} = 0b110;
2180 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2181 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2182}
2183
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002184multiclass T2I_smul<string opc, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +00002185 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002186 !strconcat(opc, "bb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002187 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
2188 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002189 let Inst{31-27} = 0b11111;
2190 let Inst{26-23} = 0b0110;
2191 let Inst{22-20} = 0b001;
2192 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2193 let Inst{7-6} = 0b00;
2194 let Inst{5-4} = 0b00;
2195 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002196
Evan Cheng0e55fd62010-09-30 01:08:25 +00002197 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002198 !strconcat(opc, "bt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002199 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
2200 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002201 let Inst{31-27} = 0b11111;
2202 let Inst{26-23} = 0b0110;
2203 let Inst{22-20} = 0b001;
2204 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2205 let Inst{7-6} = 0b00;
2206 let Inst{5-4} = 0b01;
2207 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002208
Evan Cheng0e55fd62010-09-30 01:08:25 +00002209 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002210 !strconcat(opc, "tb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002211 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
2212 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002213 let Inst{31-27} = 0b11111;
2214 let Inst{26-23} = 0b0110;
2215 let Inst{22-20} = 0b001;
2216 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2217 let Inst{7-6} = 0b00;
2218 let Inst{5-4} = 0b10;
2219 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002220
Evan Cheng0e55fd62010-09-30 01:08:25 +00002221 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002222 !strconcat(opc, "tt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002223 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
2224 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002225 let Inst{31-27} = 0b11111;
2226 let Inst{26-23} = 0b0110;
2227 let Inst{22-20} = 0b001;
2228 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2229 let Inst{7-6} = 0b00;
2230 let Inst{5-4} = 0b11;
2231 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002232
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002233 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002234 !strconcat(opc, "wb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002235 [(set rGPR:$dst, (sra (opnode rGPR:$a,
2236 (sext_inreg rGPR:$b, i16)), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002237 let Inst{31-27} = 0b11111;
2238 let Inst{26-23} = 0b0110;
2239 let Inst{22-20} = 0b011;
2240 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2241 let Inst{7-6} = 0b00;
2242 let Inst{5-4} = 0b00;
2243 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002244
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002245 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00002246 !strconcat(opc, "wt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002247 [(set rGPR:$dst, (sra (opnode rGPR:$a,
2248 (sra rGPR:$b, (i32 16))), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002249 let Inst{31-27} = 0b11111;
2250 let Inst{26-23} = 0b0110;
2251 let Inst{22-20} = 0b011;
2252 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2253 let Inst{7-6} = 0b00;
2254 let Inst{5-4} = 0b01;
2255 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002256}
2257
2258
2259multiclass T2I_smla<string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002260 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002261 !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002262 [(set rGPR:$dst, (add rGPR:$acc,
2263 (opnode (sext_inreg rGPR:$a, i16),
2264 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002265 let Inst{31-27} = 0b11111;
2266 let Inst{26-23} = 0b0110;
2267 let Inst{22-20} = 0b001;
2268 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2269 let Inst{7-6} = 0b00;
2270 let Inst{5-4} = 0b00;
2271 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002272
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002273 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002274 !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002275 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sext_inreg rGPR:$a, i16),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002276 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002277 let Inst{31-27} = 0b11111;
2278 let Inst{26-23} = 0b0110;
2279 let Inst{22-20} = 0b001;
2280 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2281 let Inst{7-6} = 0b00;
2282 let Inst{5-4} = 0b01;
2283 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002284
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002285 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002286 !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002287 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002288 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002289 let Inst{31-27} = 0b11111;
2290 let Inst{26-23} = 0b0110;
2291 let Inst{22-20} = 0b001;
2292 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2293 let Inst{7-6} = 0b00;
2294 let Inst{5-4} = 0b10;
2295 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002296
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002297 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002298 !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002299 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002300 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002301 let Inst{31-27} = 0b11111;
2302 let Inst{26-23} = 0b0110;
2303 let Inst{22-20} = 0b001;
2304 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2305 let Inst{7-6} = 0b00;
2306 let Inst{5-4} = 0b11;
2307 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002308
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002309 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002310 !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002311 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002312 (sext_inreg rGPR:$b, i16)), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002313 let Inst{31-27} = 0b11111;
2314 let Inst{26-23} = 0b0110;
2315 let Inst{22-20} = 0b011;
2316 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2317 let Inst{7-6} = 0b00;
2318 let Inst{5-4} = 0b00;
2319 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002320
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002321 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002322 !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002323 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002324 (sra rGPR:$b, (i32 16))), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002325 let Inst{31-27} = 0b11111;
2326 let Inst{26-23} = 0b0110;
2327 let Inst{22-20} = 0b011;
2328 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2329 let Inst{7-6} = 0b00;
2330 let Inst{5-4} = 0b01;
2331 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002332}
2333
2334defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2335defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2336
Johnny Chenadc77332010-02-26 22:04:29 +00002337// Halfword multiple accumulate long: SMLAL<x><y> -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002338def t2SMLALBB : T2I_mac<1, 0b100, 0b1000, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002339 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002340 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002341def t2SMLALBT : T2I_mac<1, 0b100, 0b1001, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002342 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002343 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002344def t2SMLALTB : T2I_mac<1, 0b100, 0b1010, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002345 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002346 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002347def t2SMLALTT : T2I_mac<1, 0b100, 0b1011, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002348 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002349 [/* For disassembly only; pattern left blank */]>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002350
Johnny Chenadc77332010-02-26 22:04:29 +00002351// Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2352// These are for disassembly only.
2353
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002354def t2SMUAD: T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2355 IIC_iMAC32, "smuad", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002356 let Inst{15-12} = 0b1111;
2357}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002358def t2SMUADX:T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2359 IIC_iMAC32, "smuadx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002360 let Inst{15-12} = 0b1111;
2361}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002362def t2SMUSD: T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2363 IIC_iMAC32, "smusd", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002364 let Inst{15-12} = 0b1111;
2365}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002366def t2SMUSDX:T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2367 IIC_iMAC32, "smusdx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002368 let Inst{15-12} = 0b1111;
2369}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002370def t2SMLAD : T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst),
2371 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlad",
Johnny Chenadc77332010-02-26 22:04:29 +00002372 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002373def t2SMLADX : T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst),
2374 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smladx",
Johnny Chenadc77332010-02-26 22:04:29 +00002375 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002376def t2SMLSD : T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst),
2377 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsd",
Johnny Chenadc77332010-02-26 22:04:29 +00002378 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002379def t2SMLSDX : T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst),
2380 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsdx",
Johnny Chenadc77332010-02-26 22:04:29 +00002381 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002382def t2SMLALD : T2I_mac<1, 0b100, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2383 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlald",
Johnny Chenadc77332010-02-26 22:04:29 +00002384 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002385def t2SMLALDX : T2I_mac<1, 0b100, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2386 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002387 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002388def t2SMLSLD : T2I_mac<1, 0b101, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2389 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsld",
Johnny Chenadc77332010-02-26 22:04:29 +00002390 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002391def t2SMLSLDX : T2I_mac<1, 0b101, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2392 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002393 "\t$ldst, $hdst, $a, $b", []>;
Evan Chengf49810c2009-06-23 17:48:47 +00002394
2395//===----------------------------------------------------------------------===//
2396// Misc. Arithmetic Instructions.
2397//
2398
Jim Grosbach80dc1162010-02-16 21:23:02 +00002399class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2400 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00002401 : T2I<oops, iops, itin, opc, asm, pattern> {
2402 let Inst{31-27} = 0b11111;
2403 let Inst{26-22} = 0b01010;
2404 let Inst{21-20} = op1;
2405 let Inst{15-12} = 0b1111;
2406 let Inst{7-6} = 0b10;
2407 let Inst{5-4} = op2;
2408}
Evan Chengf49810c2009-06-23 17:48:47 +00002409
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002410def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
2411 "clz", "\t$dst, $src", [(set rGPR:$dst, (ctlz rGPR:$src))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002412
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002413def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Evan Chengf609bb82010-01-19 00:44:15 +00002414 "rbit", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002415 [(set rGPR:$dst, (ARMrbit rGPR:$src))]>;
Jim Grosbach3482c802010-01-18 19:58:49 +00002416
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002417def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002418 "rev", ".w\t$dst, $src", [(set rGPR:$dst, (bswap rGPR:$src))]>;
Johnny Chend68e1192009-12-15 17:24:14 +00002419
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002420def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002421 "rev16", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002422 [(set rGPR:$dst,
2423 (or (and (srl rGPR:$src, (i32 8)), 0xFF),
2424 (or (and (shl rGPR:$src, (i32 8)), 0xFF00),
2425 (or (and (srl rGPR:$src, (i32 8)), 0xFF0000),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002426 (and (shl rGPR:$src, (i32 8)), 0xFF000000)))))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002427
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002428def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002429 "revsh", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002430 [(set rGPR:$dst,
Evan Chengf49810c2009-06-23 17:48:47 +00002431 (sext_inreg
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002432 (or (srl (and rGPR:$src, 0xFF00), (i32 8)),
2433 (shl rGPR:$src, (i32 8))), i16))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002434
Bob Wilsonf955f292010-08-17 17:23:19 +00002435def t2PKHBT : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002436 IIC_iBITsi, "pkhbt", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002437 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF),
Bob Wilsonf955f292010-08-17 17:23:19 +00002438 (and (shl rGPR:$src2, lsl_amt:$sh),
Jim Grosbachb1dc3932010-05-05 20:44:35 +00002439 0xFFFF0000)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002440 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002441 let Inst{31-27} = 0b11101;
2442 let Inst{26-25} = 0b01;
2443 let Inst{24-20} = 0b01100;
2444 let Inst{5} = 0; // BT form
2445 let Inst{4} = 0;
2446}
Evan Cheng40289b02009-07-07 05:35:52 +00002447
2448// Alternate cases for PKHBT where identities eliminate some nodes.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002449def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2450 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002451 Requires<[HasT2ExtractPack, IsThumb2]>;
Bob Wilsonf955f292010-08-17 17:23:19 +00002452def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2453 (t2PKHBT rGPR:$src1, rGPR:$src2, (lsl_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002454 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Cheng40289b02009-07-07 05:35:52 +00002455
Bob Wilsondc66eda2010-08-16 22:26:55 +00002456// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2457// will match the pattern below.
Bob Wilsonf955f292010-08-17 17:23:19 +00002458def t2PKHTB : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002459 IIC_iBITsi, "pkhtb", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002460 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002461 (and (sra rGPR:$src2, asr_amt:$sh),
2462 0xFFFF)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002463 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002464 let Inst{31-27} = 0b11101;
2465 let Inst{26-25} = 0b01;
2466 let Inst{24-20} = 0b01100;
2467 let Inst{5} = 1; // TB form
2468 let Inst{4} = 0;
2469}
Evan Cheng40289b02009-07-07 05:35:52 +00002470
2471// Alternate cases for PKHTB where identities eliminate some nodes. Note that
2472// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilsondc66eda2010-08-16 22:26:55 +00002473def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
Bob Wilsonf955f292010-08-17 17:23:19 +00002474 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002475 Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002476def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002477 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2478 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm1_15:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002479 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002480
2481//===----------------------------------------------------------------------===//
2482// Comparison Instructions...
2483//
Johnny Chend68e1192009-12-15 17:24:14 +00002484defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002485 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002486 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2487defm t2CMPz : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002488 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002489 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002490
Dan Gohman4b7dff92010-08-26 15:50:25 +00002491//FIXME: Disable CMN, as CCodes are backwards from compare expectations
2492// Compare-to-zero still works out, just not the relationals
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002493//defm t2CMN : T2I_cmp_irs<0b1000, "cmn",
2494// BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002495defm t2CMNz : T2I_cmp_irs<0b1000, "cmn",
Evan Cheng5d42c562010-09-29 00:49:25 +00002496 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Dan Gohman4b7dff92010-08-26 15:50:25 +00002497 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2498
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002499//def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2500// (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002501
2502def : T2Pat<(ARMcmpZ GPR:$src, t2_so_imm_neg:$imm),
2503 (t2CMNzri GPR:$src, t2_so_imm_neg:$imm)>;
Evan Chengf49810c2009-06-23 17:48:47 +00002504
Johnny Chend68e1192009-12-15 17:24:14 +00002505defm t2TST : T2I_cmp_irs<0b0000, "tst",
Evan Cheng5d42c562010-09-29 00:49:25 +00002506 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002507 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>>;
2508defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
Evan Cheng5d42c562010-09-29 00:49:25 +00002509 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002510 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002511
Evan Chenge253c952009-07-07 20:39:03 +00002512// Conditional moves
2513// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach64171712010-02-16 21:07:46 +00002514// a two-value operand where a dag node expects two operands. :(
Evan Cheng63f35442010-11-13 02:25:14 +00002515let neverHasSideEffects = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002516def t2MOVCCr : T2I<(outs rGPR:$dst), (ins rGPR:$false, rGPR:$true), IIC_iCMOVr,
Evan Cheng699beba2009-10-27 00:08:59 +00002517 "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002518 [/*(set rGPR:$dst, (ARMcmov rGPR:$false, rGPR:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002519 RegConstraint<"$false = $dst"> {
2520 let Inst{31-27} = 0b11101;
2521 let Inst{26-25} = 0b01;
2522 let Inst{24-21} = 0b0010;
2523 let Inst{20} = 0; // The S bit.
2524 let Inst{19-16} = 0b1111; // Rn
2525 let Inst{14-12} = 0b000;
2526 let Inst{7-4} = 0b0000;
2527}
Evan Chenge253c952009-07-07 20:39:03 +00002528
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002529def t2MOVCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
Evan Cheng699beba2009-10-27 00:08:59 +00002530 IIC_iCMOVi, "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002531[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002532 RegConstraint<"$false = $dst"> {
2533 let Inst{31-27} = 0b11110;
2534 let Inst{25} = 0;
2535 let Inst{24-21} = 0b0010;
2536 let Inst{20} = 0; // The S bit.
2537 let Inst{19-16} = 0b1111; // Rn
2538 let Inst{15} = 0;
2539}
Evan Chengf49810c2009-06-23 17:48:47 +00002540
Jim Grosbacha4257162010-10-07 00:53:56 +00002541def t2MOVCCi16 : T2I<(outs rGPR:$dst), (ins rGPR:$false, i32imm:$src),
Evan Cheng875a6ac2010-11-12 22:42:47 +00002542 IIC_iCMOVi,
Jim Grosbacha4257162010-10-07 00:53:56 +00002543 "movw", "\t$dst, $src", []>,
2544 RegConstraint<"$false = $dst"> {
2545 let Inst{31-27} = 0b11110;
2546 let Inst{25} = 1;
2547 let Inst{24-21} = 0b0010;
2548 let Inst{20} = 0; // The S bit.
2549 let Inst{15} = 0;
2550}
2551
Evan Cheng63f35442010-11-13 02:25:14 +00002552def t2MOVCCi32imm : PseudoInst<(outs rGPR:$dst),
2553 (ins rGPR:$false, i32imm:$src, pred:$p),
Evan Chengc47f7d62010-11-13 05:14:20 +00002554 IIC_iCMOVix2, "", []>, RegConstraint<"$false = $dst">;
Evan Cheng63f35442010-11-13 02:25:14 +00002555
Evan Cheng875a6ac2010-11-12 22:42:47 +00002556def t2MVNCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
2557 IIC_iCMOVi, "mvn", ".w\t$dst, $true",
2558[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm_not:$true,
2559 imm:$cc, CCR:$ccr))*/]>,
2560 RegConstraint<"$false = $dst"> {
2561 let Inst{31-27} = 0b11110;
2562 let Inst{25} = 0;
2563 let Inst{24-21} = 0b0011;
2564 let Inst{20} = 0; // The S bit.
2565 let Inst{19-16} = 0b1111; // Rn
2566 let Inst{15} = 0;
2567}
2568
Johnny Chend68e1192009-12-15 17:24:14 +00002569class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
2570 string opc, string asm, list<dag> pattern>
Owen Andersonbb6315d2010-11-15 19:58:36 +00002571 : T2TwoRegShiftImm<oops, iops, itin, opc, asm, pattern> {
Johnny Chend68e1192009-12-15 17:24:14 +00002572 let Inst{31-27} = 0b11101;
2573 let Inst{26-25} = 0b01;
2574 let Inst{24-21} = 0b0010;
2575 let Inst{20} = 0; // The S bit.
2576 let Inst{19-16} = 0b1111; // Rn
2577 let Inst{5-4} = opcod; // Shift type.
2578}
Owen Andersonbb6315d2010-11-15 19:58:36 +00002579def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$Rd),
2580 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2581 IIC_iCMOVsi, "lsl", ".w\t$Rd, $Rm, $imm", []>,
2582 RegConstraint<"$false = $Rd">;
2583def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$Rd),
2584 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2585 IIC_iCMOVsi, "lsr", ".w\t$Rd, $Rm, $imm", []>,
2586 RegConstraint<"$false = $Rd">;
2587def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$Rd),
2588 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2589 IIC_iCMOVsi, "asr", ".w\t$Rd, $Rm, $imm", []>,
2590 RegConstraint<"$false = $Rd">;
2591def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$Rd),
2592 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2593 IIC_iCMOVsi, "ror", ".w\t$Rd, $Rm, $imm", []>,
2594 RegConstraint<"$false = $Rd">;
Owen Andersonf523e472010-09-23 23:45:25 +00002595} // neverHasSideEffects
Evan Cheng13f8b362009-08-01 01:43:45 +00002596
David Goodwin5e47a9a2009-06-30 18:04:13 +00002597//===----------------------------------------------------------------------===//
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002598// Atomic operations intrinsics
2599//
2600
2601// memory barriers protect the atomic sequences
2602let hasSideEffects = 1 in {
Bob Wilsonf74a4292010-10-30 00:54:37 +00002603def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2604 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
2605 Requires<[IsThumb, HasDB]> {
2606 bits<4> opt;
2607 let Inst{31-4} = 0xf3bf8f5;
2608 let Inst{3-0} = opt;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002609}
2610}
2611
Bob Wilsonf74a4292010-10-30 00:54:37 +00002612def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2613 "dsb", "\t$opt",
2614 [/* For disassembly only; pattern left blank */]>,
2615 Requires<[IsThumb, HasDB]> {
2616 bits<4> opt;
2617 let Inst{31-4} = 0xf3bf8f4;
2618 let Inst{3-0} = opt;
Johnny Chena4339822010-03-03 00:16:28 +00002619}
2620
Johnny Chena4339822010-03-03 00:16:28 +00002621// ISB has only full system option -- for disassembly only
Bob Wilsonf74a4292010-10-30 00:54:37 +00002622def t2ISB : T2I<(outs), (ins), NoItinerary, "isb", "",
2623 [/* For disassembly only; pattern left blank */]>,
2624 Requires<[IsThumb2, HasV7]> {
2625 let Inst{31-4} = 0xf3bf8f6;
Johnny Chena4339822010-03-03 00:16:28 +00002626 let Inst{3-0} = 0b1111;
2627}
2628
Johnny Chend68e1192009-12-15 17:24:14 +00002629class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2630 InstrItinClass itin, string opc, string asm, string cstr,
2631 list<dag> pattern, bits<4> rt2 = 0b1111>
2632 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2633 let Inst{31-27} = 0b11101;
2634 let Inst{26-20} = 0b0001101;
2635 let Inst{11-8} = rt2;
2636 let Inst{7-6} = 0b01;
2637 let Inst{5-4} = opcod;
2638 let Inst{3-0} = 0b1111;
2639}
2640class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2641 InstrItinClass itin, string opc, string asm, string cstr,
2642 list<dag> pattern, bits<4> rt2 = 0b1111>
2643 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2644 let Inst{31-27} = 0b11101;
2645 let Inst{26-20} = 0b0001100;
2646 let Inst{11-8} = rt2;
2647 let Inst{7-6} = 0b01;
2648 let Inst{5-4} = opcod;
2649}
2650
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002651let mayLoad = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002652def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002653 Size4Bytes, NoItinerary, "ldrexb", "\t$dest, [$ptr]",
2654 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002655def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002656 Size4Bytes, NoItinerary, "ldrexh", "\t$dest, [$ptr]",
2657 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002658def t2LDREX : Thumb2I<(outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002659 Size4Bytes, NoItinerary,
2660 "ldrex", "\t$dest, [$ptr]", "",
2661 []> {
2662 let Inst{31-27} = 0b11101;
2663 let Inst{26-20} = 0b0000101;
2664 let Inst{11-8} = 0b1111;
2665 let Inst{7-0} = 0b00000000; // imm8 = 0
2666}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002667def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$dest, rGPR:$dest2), (ins rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002668 AddrModeNone, Size4Bytes, NoItinerary,
2669 "ldrexd", "\t$dest, $dest2, [$ptr]", "",
2670 [], {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002671}
2672
Jim Grosbach587b0722009-12-16 19:44:06 +00002673let mayStore = 1, Constraints = "@earlyclobber $success" in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002674def t2STREXB : T2I_strex<0b00, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002675 AddrModeNone, Size4Bytes, NoItinerary,
2676 "strexb", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002677def t2STREXH : T2I_strex<0b01, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002678 AddrModeNone, Size4Bytes, NoItinerary,
2679 "strexh", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002680def t2STREX : Thumb2I<(outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002681 AddrModeNone, Size4Bytes, NoItinerary,
2682 "strex", "\t$success, $src, [$ptr]", "",
2683 []> {
2684 let Inst{31-27} = 0b11101;
2685 let Inst{26-20} = 0b0000100;
2686 let Inst{7-0} = 0b00000000; // imm8 = 0
2687}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002688def t2STREXD : T2I_strex<0b11, (outs rGPR:$success),
2689 (ins rGPR:$src, rGPR:$src2, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002690 AddrModeNone, Size4Bytes, NoItinerary,
2691 "strexd", "\t$success, $src, $src2, [$ptr]", "", [],
2692 {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002693}
2694
Johnny Chen10a77e12010-03-02 22:11:06 +00002695// Clear-Exclusive is for disassembly only.
2696def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "",
2697 [/* For disassembly only; pattern left blank */]>,
2698 Requires<[IsARM, HasV7]> {
2699 let Inst{31-20} = 0xf3b;
2700 let Inst{15-14} = 0b10;
2701 let Inst{12} = 0;
2702 let Inst{7-4} = 0b0010;
2703}
2704
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002705//===----------------------------------------------------------------------===//
David Goodwin334c2642009-07-08 16:09:28 +00002706// TLS Instructions
2707//
2708
2709// __aeabi_read_tp preserves the registers r1-r3.
2710let isCall = 1,
2711 Defs = [R0, R12, LR, CPSR] in {
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002712 def t2TPsoft : T2XI<(outs), (ins), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002713 "bl\t__aeabi_read_tp",
Johnny Chend68e1192009-12-15 17:24:14 +00002714 [(set R0, ARMthread_pointer)]> {
2715 let Inst{31-27} = 0b11110;
2716 let Inst{15-14} = 0b11;
2717 let Inst{12} = 1;
2718 }
David Goodwin334c2642009-07-08 16:09:28 +00002719}
2720
2721//===----------------------------------------------------------------------===//
Jim Grosbach5aa16842009-08-11 19:42:21 +00002722// SJLJ Exception handling intrinsics
Jim Grosbach1add6592009-08-13 15:11:43 +00002723// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach5aa16842009-08-11 19:42:21 +00002724// address and save #0 in R0 for the non-longjmp case.
2725// Since by its nature we may be coming from some other function to get
2726// here, and we're using the stack frame for the containing function to
2727// save/restore registers, we can't keep anything live in regs across
2728// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
2729// when we get here from a longjmp(). We force everthing out of registers
2730// except for our own input by listing the relevant registers in Defs. By
2731// doing so, we also cause the prologue/epilogue code to actively preserve
2732// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach0798edd2010-05-27 23:49:24 +00002733// $val is a scratch register for our use.
Jim Grosbacha87ded22010-02-08 23:22:00 +00002734let Defs =
Jim Grosbachf35d2162009-08-13 16:59:44 +00002735 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2736 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Jim Grosbach5aa16842009-08-11 19:42:21 +00002737 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002738 D31 ], hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002739 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002740 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002741 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002742 Requires<[IsThumb2, HasVFP2]>;
Jim Grosbach5aa16842009-08-11 19:42:21 +00002743}
2744
Bob Wilsonec80e262010-04-09 20:41:18 +00002745let Defs =
Jim Grosbach5caeff52010-05-28 17:37:40 +00002746 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ],
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002747 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002748 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002749 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002750 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002751 Requires<[IsThumb2, NoVFP]>;
2752}
Jim Grosbach5aa16842009-08-11 19:42:21 +00002753
2754
2755//===----------------------------------------------------------------------===//
David Goodwin5e47a9a2009-06-30 18:04:13 +00002756// Control-Flow Instructions
2757//
2758
Evan Chengc50a1cb2009-07-09 22:58:39 +00002759// FIXME: remove when we have a way to marking a MI with these properties.
2760// FIXME: $dst1 should be a def. But the extra ops must be in the end of the
2761// operand list.
2762// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng0d92f5f2009-10-01 08:22:27 +00002763let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
Chris Lattner39ee0362010-10-31 19:10:56 +00002764 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
Jim Grosbache6913602010-11-03 01:01:43 +00002765 def t2LDM_RET: T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
2766 reglist:$dsts, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00002767 IIC_iLoad_mBr,
Jim Grosbache6913602010-11-03 01:01:43 +00002768 "ldm${amode}${p}.w\t$Rn!, $dsts",
2769 "$Rn = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002770 let Inst{31-27} = 0b11101;
2771 let Inst{26-25} = 0b00;
2772 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
2773 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00002774 let Inst{21} = 1; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00002775 let Inst{20} = 1; // Load
2776}
Evan Chengc50a1cb2009-07-09 22:58:39 +00002777
David Goodwin5e47a9a2009-06-30 18:04:13 +00002778let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
2779let isPredicable = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002780def t2B : T2XI<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002781 "b.w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002782 [(br bb:$target)]> {
2783 let Inst{31-27} = 0b11110;
2784 let Inst{15-14} = 0b10;
2785 let Inst{12} = 1;
2786}
David Goodwin5e47a9a2009-06-30 18:04:13 +00002787
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002788let isNotDuplicable = 1, isIndirectBranch = 1,
2789 isCodeGenOnly = 1 in { // $id doesn't exist in asmstring, should be lowered.
Evan Cheng66ac5312009-07-25 00:33:29 +00002790def t2BR_JT :
Evan Cheng5657c012009-07-29 02:18:14 +00002791 T2JTI<(outs),
2792 (ins GPR:$target, GPR:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002793 IIC_Br, "mov\tpc, $target$jt",
Johnny Chend68e1192009-12-15 17:24:14 +00002794 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]> {
2795 let Inst{31-27} = 0b11101;
2796 let Inst{26-20} = 0b0100100;
2797 let Inst{19-16} = 0b1111;
2798 let Inst{14-12} = 0b000;
2799 let Inst{11-8} = 0b1111; // Rd = pc
2800 let Inst{7-4} = 0b0000;
2801}
Evan Cheng5657c012009-07-29 02:18:14 +00002802
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002803// FIXME: Add a non-pc based case that can be predicated.
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002804let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002805def t2TBB :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002806 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002807 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002808 IIC_Br, "tbb\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002809 let Inst{31-27} = 0b11101;
2810 let Inst{26-20} = 0b0001101;
2811 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2812 let Inst{15-8} = 0b11110000;
2813 let Inst{7-4} = 0b0000; // B form
2814}
Evan Cheng5657c012009-07-29 02:18:14 +00002815
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002816let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002817def t2TBH :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002818 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002819 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002820 IIC_Br, "tbh\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002821 let Inst{31-27} = 0b11101;
2822 let Inst{26-20} = 0b0001101;
2823 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2824 let Inst{15-8} = 0b11110000;
2825 let Inst{7-4} = 0b0001; // H form
2826}
Johnny Chen93042d12010-03-02 18:14:57 +00002827
2828// Generic versions of the above two instructions, for disassembly only
2829
2830def t2TBBgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2831 "tbb", "\t[$a, $b]", []>{
2832 let Inst{31-27} = 0b11101;
2833 let Inst{26-20} = 0b0001101;
2834 let Inst{15-8} = 0b11110000;
2835 let Inst{7-4} = 0b0000; // B form
2836}
2837
2838def t2TBHgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2839 "tbh", "\t[$a, $b, lsl #1]", []> {
2840 let Inst{31-27} = 0b11101;
2841 let Inst{26-20} = 0b0001101;
2842 let Inst{15-8} = 0b11110000;
2843 let Inst{7-4} = 0b0001; // H form
2844}
Evan Cheng5657c012009-07-29 02:18:14 +00002845} // isNotDuplicable, isIndirectBranch
2846
David Goodwinc9a59b52009-06-30 19:50:22 +00002847} // isBranch, isTerminator, isBarrier
David Goodwin5e47a9a2009-06-30 18:04:13 +00002848
2849// FIXME: should be able to write a pattern for ARMBrcond, but can't use
2850// a two-value operand where a dag node expects two operands. :(
2851let isBranch = 1, isTerminator = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002852def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002853 "b", ".w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002854 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
2855 let Inst{31-27} = 0b11110;
2856 let Inst{15-14} = 0b10;
2857 let Inst{12} = 0;
2858}
Evan Chengf49810c2009-06-23 17:48:47 +00002859
Evan Cheng06e16582009-07-10 01:54:42 +00002860
2861// IT block
Evan Cheng86050dc2010-06-18 23:09:54 +00002862let Defs = [ITSTATE] in
Evan Cheng06e16582009-07-10 01:54:42 +00002863def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
David Goodwin5d598aa2009-08-19 18:00:44 +00002864 AddrModeNone, Size2Bytes, IIC_iALUx,
Johnny Chend68e1192009-12-15 17:24:14 +00002865 "it$mask\t$cc", "", []> {
2866 // 16-bit instruction.
Johnny Chenbbc71b22009-12-16 02:32:54 +00002867 let Inst{31-16} = 0x0000;
Johnny Chend68e1192009-12-15 17:24:14 +00002868 let Inst{15-8} = 0b10111111;
2869}
Evan Cheng06e16582009-07-10 01:54:42 +00002870
Johnny Chence6275f2010-02-25 19:05:29 +00002871// Branch and Exchange Jazelle -- for disassembly only
2872// Rm = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002873def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func",
Johnny Chence6275f2010-02-25 19:05:29 +00002874 [/* For disassembly only; pattern left blank */]> {
2875 let Inst{31-27} = 0b11110;
2876 let Inst{26} = 0;
2877 let Inst{25-20} = 0b111100;
2878 let Inst{15-14} = 0b10;
2879 let Inst{12} = 0;
2880}
2881
Johnny Chen93042d12010-03-02 18:14:57 +00002882// Change Processor State is a system instruction -- for disassembly only.
2883// The singleton $opt operand contains the following information:
2884// opt{4-0} = mode from Inst{4-0}
2885// opt{5} = changemode from Inst{17}
2886// opt{8-6} = AIF from Inst{8-6}
2887// opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002888def t2CPS : T2XI<(outs),(ins cps_opt:$opt), NoItinerary, "cps$opt",
Johnny Chen93042d12010-03-02 18:14:57 +00002889 [/* For disassembly only; pattern left blank */]> {
2890 let Inst{31-27} = 0b11110;
2891 let Inst{26} = 0;
2892 let Inst{25-20} = 0b111010;
2893 let Inst{15-14} = 0b10;
2894 let Inst{12} = 0;
2895}
2896
Johnny Chen0f7866e2010-03-03 02:09:43 +00002897// A6.3.4 Branches and miscellaneous control
2898// Table A6-14 Change Processor State, and hint instructions
2899// Helper class for disassembly only.
2900class T2I_hint<bits<8> op7_0, string opc, string asm>
2901 : T2I<(outs), (ins), NoItinerary, opc, asm,
2902 [/* For disassembly only; pattern left blank */]> {
2903 let Inst{31-20} = 0xf3a;
2904 let Inst{15-14} = 0b10;
2905 let Inst{12} = 0;
2906 let Inst{10-8} = 0b000;
2907 let Inst{7-0} = op7_0;
2908}
2909
2910def t2NOP : T2I_hint<0b00000000, "nop", ".w">;
2911def t2YIELD : T2I_hint<0b00000001, "yield", ".w">;
2912def t2WFE : T2I_hint<0b00000010, "wfe", ".w">;
2913def t2WFI : T2I_hint<0b00000011, "wfi", ".w">;
2914def t2SEV : T2I_hint<0b00000100, "sev", ".w">;
2915
2916def t2DBG : T2I<(outs),(ins i32imm:$opt), NoItinerary, "dbg", "\t$opt",
2917 [/* For disassembly only; pattern left blank */]> {
2918 let Inst{31-20} = 0xf3a;
2919 let Inst{15-14} = 0b10;
2920 let Inst{12} = 0;
2921 let Inst{10-8} = 0b000;
2922 let Inst{7-4} = 0b1111;
2923}
2924
Johnny Chen6341c5a2010-02-25 20:25:24 +00002925// Secure Monitor Call is a system instruction -- for disassembly only
2926// Option = Inst{19-16}
2927def t2SMC : T2I<(outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
2928 [/* For disassembly only; pattern left blank */]> {
2929 let Inst{31-27} = 0b11110;
2930 let Inst{26-20} = 0b1111111;
2931 let Inst{15-12} = 0b1000;
2932}
2933
2934// Store Return State is a system instruction -- for disassembly only
2935def t2SRSDBW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp!, $mode",
2936 [/* For disassembly only; pattern left blank */]> {
2937 let Inst{31-27} = 0b11101;
2938 let Inst{26-20} = 0b0000010; // W = 1
2939}
2940
2941def t2SRSDB : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp, $mode",
2942 [/* For disassembly only; pattern left blank */]> {
2943 let Inst{31-27} = 0b11101;
2944 let Inst{26-20} = 0b0000000; // W = 0
2945}
2946
2947def t2SRSIAW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsia","\tsp!, $mode",
2948 [/* For disassembly only; pattern left blank */]> {
2949 let Inst{31-27} = 0b11101;
2950 let Inst{26-20} = 0b0011010; // W = 1
2951}
2952
2953def t2SRSIA : T2I<(outs), (ins i32imm:$mode),NoItinerary,"srsia","\tsp, $mode",
2954 [/* For disassembly only; pattern left blank */]> {
2955 let Inst{31-27} = 0b11101;
2956 let Inst{26-20} = 0b0011000; // W = 0
2957}
2958
2959// Return From Exception is a system instruction -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002960def t2RFEDBW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfedb", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002961 [/* For disassembly only; pattern left blank */]> {
2962 let Inst{31-27} = 0b11101;
2963 let Inst{26-20} = 0b0000011; // W = 1
2964}
2965
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002966def t2RFEDB : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeab", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002967 [/* For disassembly only; pattern left blank */]> {
2968 let Inst{31-27} = 0b11101;
2969 let Inst{26-20} = 0b0000001; // W = 0
2970}
2971
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002972def t2RFEIAW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002973 [/* For disassembly only; pattern left blank */]> {
2974 let Inst{31-27} = 0b11101;
2975 let Inst{26-20} = 0b0011011; // W = 1
2976}
2977
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002978def t2RFEIA : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002979 [/* For disassembly only; pattern left blank */]> {
2980 let Inst{31-27} = 0b11101;
2981 let Inst{26-20} = 0b0011001; // W = 0
2982}
2983
Evan Chengf49810c2009-06-23 17:48:47 +00002984//===----------------------------------------------------------------------===//
2985// Non-Instruction Patterns
2986//
2987
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002988// Two piece so_imms.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002989def : T2Pat<(or rGPR:$LHS, t2_so_imm2part:$RHS),
2990 (t2ORRri (t2ORRri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002991 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002992def : T2Pat<(xor rGPR:$LHS, t2_so_imm2part:$RHS),
2993 (t2EORri (t2EORri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002994 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002995def : T2Pat<(add rGPR:$LHS, t2_so_imm2part:$RHS),
2996 (t2ADDri (t2ADDri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002997 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002998def : T2Pat<(add rGPR:$LHS, t2_so_neg_imm2part:$RHS),
2999 (t2SUBri (t2SUBri rGPR:$LHS, (t2_so_neg_imm2part_1 imm:$RHS)),
Jim Grosbach15e6ef82009-11-23 20:35:53 +00003000 (t2_so_neg_imm2part_2 imm:$RHS))>;
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00003001
Evan Cheng5adb66a2009-09-28 09:14:39 +00003002// 32-bit immediate using movw + movt.
Evan Cheng5be39222010-09-24 22:03:46 +00003003// This is a single pseudo instruction to make it re-materializable.
3004// FIXME: Remove this when we can do generalized remat.
Evan Cheng5adb66a2009-09-28 09:14:39 +00003005let isReMaterializable = 1 in
Jim Grosbach3c38f962010-10-06 22:01:26 +00003006def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
3007 "", [(set rGPR:$dst, (i32 imm:$src))]>,
3008 Requires<[IsThumb, HasV6T2]>;
Evan Chengb9803a82009-11-06 23:52:48 +00003009
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +00003010// ConstantPool, GlobalAddress, and JumpTable
3011def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
3012 Requires<[IsThumb2, DontUseMovt]>;
3013def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
3014def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
3015 Requires<[IsThumb2, UseMovt]>;
3016
3017def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3018 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
3019
Evan Chengb9803a82009-11-06 23:52:48 +00003020// Pseudo instruction that combines ldr from constpool and add pc. This should
3021// be expanded into two instructions late to allow if-conversion and
3022// scheduling.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00003023let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Chengb9803a82009-11-06 23:52:48 +00003024def t2LDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp),
Jim Grosbach78890f42010-10-01 23:21:38 +00003025 IIC_iLoadiALU, "",
Evan Chengb9803a82009-11-06 23:52:48 +00003026 [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
3027 imm:$cp))]>,
3028 Requires<[IsThumb2]>;
Johnny Chen23336552010-02-25 18:46:43 +00003029
3030//===----------------------------------------------------------------------===//
3031// Move between special register and ARM core register -- for disassembly only
3032//
3033
3034// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003035def t2MRS : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, cpsr",
Johnny Chen23336552010-02-25 18:46:43 +00003036 [/* For disassembly only; pattern left blank */]> {
3037 let Inst{31-27} = 0b11110;
3038 let Inst{26} = 0;
3039 let Inst{25-21} = 0b11111;
3040 let Inst{20} = 0; // The R bit.
3041 let Inst{15-14} = 0b10;
3042 let Inst{12} = 0;
3043}
3044
3045// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003046def t2MRSsys : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, spsr",
Johnny Chen23336552010-02-25 18:46:43 +00003047 [/* For disassembly only; pattern left blank */]> {
3048 let Inst{31-27} = 0b11110;
3049 let Inst{26} = 0;
3050 let Inst{25-21} = 0b11111;
3051 let Inst{20} = 1; // The R bit.
3052 let Inst{15-14} = 0b10;
3053 let Inst{12} = 0;
3054}
3055
Johnny Chen23336552010-02-25 18:46:43 +00003056// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003057def t2MSR : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00003058 "\tcpsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00003059 [/* For disassembly only; pattern left blank */]> {
3060 let Inst{31-27} = 0b11110;
3061 let Inst{26} = 0;
3062 let Inst{25-21} = 0b11100;
3063 let Inst{20} = 0; // The R bit.
3064 let Inst{15-14} = 0b10;
3065 let Inst{12} = 0;
3066}
3067
Johnny Chen23336552010-02-25 18:46:43 +00003068// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00003069def t2MSRsys : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00003070 "\tspsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00003071 [/* For disassembly only; pattern left blank */]> {
3072 let Inst{31-27} = 0b11110;
3073 let Inst{26} = 0;
3074 let Inst{25-21} = 0b11100;
3075 let Inst{20} = 1; // The R bit.
3076 let Inst{15-14} = 0b10;
3077 let Inst{12} = 0;
3078}