blob: e0617e466208af8aedebc45e38b6bcd1c7b58418 [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
14// Shifted operands. No register controlled shifts for Thumb2.
15// Note: We do not support rrx shifted operands yet.
16def t2_so_reg : Operand<i32>, // reg imm
Evan Chenge499f972009-06-23 18:14:38 +000017 ComplexPattern<i32, 2, "SelectThumb2ShifterOperandReg",
Anton Korobeynikov52237112009-06-17 18:13:58 +000018 [shl,srl,sra,rotr]> {
19 let PrintMethod = "printSOOperand";
20 let MIOperandInfo = (ops GPR, i32imm);
21}
22
Evan Chengf49810c2009-06-23 17:48:47 +000023// t2_so_imm_XFORM - Return a t2_so_imm value packed into the format
24// described for t2_so_imm def below.
25def t2_so_imm_XFORM : SDNodeXForm<imm, [{
26 return CurDAG->getTargetConstant(
27 ARM_AM::getT2SOImmVal(N->getZExtValue()), MVT::i32);
Anton Korobeynikov52237112009-06-17 18:13:58 +000028}]>;
29
Evan Chengf49810c2009-06-23 17:48:47 +000030// t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
31def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{
32 return CurDAG->getTargetConstant(
33 ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())), MVT::i32);
Anton Korobeynikov52237112009-06-17 18:13:58 +000034}]>;
35
Evan Chengf49810c2009-06-23 17:48:47 +000036// t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
37def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
38 return CurDAG->getTargetConstant(
39 ARM_AM::getT2SOImmVal(-((int)N->getZExtValue())), MVT::i32);
40}]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +000041
Evan Chengf49810c2009-06-23 17:48:47 +000042// t2_so_imm - Match a 32-bit immediate operand, which is an
43// 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
44// immediate splatted into multiple bytes of the word. t2_so_imm values are
45// represented in the imm field in the same 12-bit form that they are encoded
46// into t2_so_imm instructions: the 8-bit immediate is the least significant bits
47// [bits 0-7], the 4-bit shift/splat amount is the next 4 bits [bits 8-11].
48def t2_so_imm : Operand<i32>,
49 PatLeaf<(imm), [{
50 return ARM_AM::getT2SOImmVal((uint32_t)N->getZExtValue()) != -1;
51 }], t2_so_imm_XFORM> {
52 let PrintMethod = "printT2SOImmOperand";
53}
Anton Korobeynikov52237112009-06-17 18:13:58 +000054
Evan Chengf49810c2009-06-23 17:48:47 +000055// t2_so_imm_not - Match an immediate that is a complement
56// of a t2_so_imm.
57def t2_so_imm_not : Operand<i32>,
58 PatLeaf<(imm), [{
59 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
60 }], t2_so_imm_not_XFORM> {
61 let PrintMethod = "printT2SOImmOperand";
62}
63
64// t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
65def t2_so_imm_neg : Operand<i32>,
66 PatLeaf<(imm), [{
67 return ARM_AM::getT2SOImmVal(-((int)N->getZExtValue())) != -1;
68 }], t2_so_imm_neg_XFORM> {
69 let PrintMethod = "printT2SOImmOperand";
70}
71
72/// imm0_4095 predicate - True if the 32-bit immediate is in the range [0.4095].
73def imm0_4095 : PatLeaf<(i32 imm), [{
74 return (uint32_t)N->getZExtValue() < 4096;
75}]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +000076
77def imm0_4095_neg : PatLeaf<(i32 imm), [{
Evan Chengf49810c2009-06-23 17:48:47 +000078 return (uint32_t)(-N->getZExtValue()) < 4096;
Anton Korobeynikov52237112009-06-17 18:13:58 +000079}], imm_neg_XFORM>;
80
Evan Chengf49810c2009-06-23 17:48:47 +000081/// imm0_65535 predicate - True if the 32-bit immediate is in the range
82/// [0.65535].
83def imm0_65535 : PatLeaf<(i32 imm), [{
84 return (uint32_t)N->getZExtValue() < 65536;
Anton Korobeynikov52237112009-06-17 18:13:58 +000085}]>;
86
87
Evan Chengf49810c2009-06-23 17:48:47 +000088/// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
89/// e.g., 0xf000ffff
90def bf_inv_mask_imm : Operand<i32>,
91 PatLeaf<(imm), [{
92 uint32_t v = (uint32_t)N->getZExtValue();
93 if (v == 0xffffffff)
94 return 0;
95 // naive checker. should do better, but simple is best for now since it's
96 // more likely to be correct.
97 while (v & 1) v >>= 1; // shift off the leading 1's
98 if (v)
99 {
100 while (!(v & 1)) v >>=1; // shift off the mask
101 while (v & 1) v >>= 1; // shift off the trailing 1's
102 }
103 // if this is a mask for clearing a bitfield, what's left should be zero.
104 return (v == 0);
105}] > {
106 let PrintMethod = "printBitfieldInvMaskImmOperand";
107}
108
109/// Split a 32-bit immediate into two 16 bit parts.
110def t2_lo16 : SDNodeXForm<imm, [{
111 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() & 0xffff,
112 MVT::i32);
113}]>;
114
115def t2_hi16 : SDNodeXForm<imm, [{
116 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
117}]>;
118
119def t2_lo16AllZero : PatLeaf<(i32 imm), [{
120 // Returns true if all low 16-bits are 0.
121 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
122 }], t2_hi16>;
123
Anton Korobeynikov52237112009-06-17 18:13:58 +0000124//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +0000125// Thumb2 to cover the functionality of the ARM instruction set.
Anton Korobeynikov52237112009-06-17 18:13:58 +0000126//
127
Evan Chengf49810c2009-06-23 17:48:47 +0000128/// T2I_bin_is - Defines a set of (op reg, {so_imm|so_reg}) patterns for a
Anton Korobeynikov52237112009-06-17 18:13:58 +0000129// binary operation that produces a value.
Evan Chengf49810c2009-06-23 17:48:47 +0000130multiclass T2I_bin_is<string opc, PatFrag opnode> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000131 // shifted imm
Evan Chengf49810c2009-06-23 17:48:47 +0000132 def ri : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs),
133 !strconcat(opc, " $dst, $lhs, $rhs"),
134 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000135 // shifted register
Evan Chengf49810c2009-06-23 17:48:47 +0000136 def rs : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs),
137 !strconcat(opc, " $dst, $lhs, $rhs"),
138 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000139}
140
Evan Chengf49810c2009-06-23 17:48:47 +0000141/// T2I_2bin_is - Same as T2I_bin_is except the order of operands are reversed.
142multiclass T2I_rbin_is<string opc, PatFrag opnode> {
143 // shifted imm
144 def ri : T2I<(outs GPR:$dst), (ins GPR:$rhs, t2_so_imm:$lhs),
145 !strconcat(opc, " $dst, $lhs, $rhs"),
146 [(set GPR:$dst, (opnode t2_so_imm:$lhs, GPR:$rhs))]>;
147 // shifted register
148 def rs : T2I<(outs GPR:$dst), (ins GPR:$rhs, t2_so_reg:$lhs),
149 !strconcat(opc, " $dst, $lhs, $rhs"),
150 [(set GPR:$dst, (opnode t2_so_reg:$lhs, GPR:$rhs))]>;
151}
152
153/// T2I_bin_s_is - Similar to T2I_bin_is except it sets the 's' bit so the
Anton Korobeynikov52237112009-06-17 18:13:58 +0000154/// instruction modifies the CPSR register.
155let Defs = [CPSR] in {
Evan Chengf49810c2009-06-23 17:48:47 +0000156multiclass T2I_bin_s_is<string opc, PatFrag opnode> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000157 // shifted imm
Evan Chengf49810c2009-06-23 17:48:47 +0000158 def ri : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs),
159 !strconcat(opc, "s $dst, $lhs, $rhs"),
160 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000161
162 // shifted register
Evan Chengf49810c2009-06-23 17:48:47 +0000163 def rs : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs),
164 !strconcat(opc, "s $dst, $lhs, $rhs"),
165 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000166}
167}
168
Evan Chengf49810c2009-06-23 17:48:47 +0000169/// T2I_rbin_s_is - Same as T2I_bin_s_is except the order of operands are
170/// reversed.
171let Defs = [CPSR] in {
172multiclass T2I_rbin_s_is<string opc, PatFrag opnode> {
173 // shifted imm
174 def ri : T2I<(outs GPR:$dst), (ins GPR:$rhs, t2_so_imm:$lhs),
175 !strconcat(opc, "s $dst, $lhs, $rhs"),
176 [(set GPR:$dst, (opnode t2_so_imm:$lhs, GPR:$rhs))]>;
177
178 // shifted register
179 def rs : T2I<(outs GPR:$dst), (ins GPR:$rhs, t2_so_reg:$lhs),
180 !strconcat(opc, "s $dst, $lhs, $rhs"),
181 [(set GPR:$dst, (opnode t2_so_reg:$lhs, GPR:$rhs))]>;
182}
183}
184
185/// T2I_bin_ii12s - Defines a set of (op reg, {so_imm|imm0_4095|so_reg}) patterns
186/// for a binary operation that produces a value.
187multiclass T2I_bin_ii12s<string opc, PatFrag opnode> {
188 // shifted imm
189 def ri : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs),
190 !strconcat(opc, " $dst, $lhs, $rhs"),
191 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>;
192 // 12-bit imm
193 def ri12 : T2I<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs),
194 !strconcat(opc, "w $dst, $lhs, $rhs"),
195 [(set GPR:$dst, (opnode GPR:$lhs, imm0_4095:$rhs))]>;
196 // shifted register
197 def rs : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs),
198 !strconcat(opc, " $dst, $lhs, $rhs"),
199 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>;
200}
201
202/// T2I_bin_c_is - Defines a set of (op reg, {so_imm|reg}) patterns for a
203// binary operation that produces a value and set the carry bit. It can also
204/// optionally set CPSR.
Anton Korobeynikov52237112009-06-17 18:13:58 +0000205let Uses = [CPSR] in {
Evan Chengf49810c2009-06-23 17:48:47 +0000206multiclass T2I_bin_c_is<string opc, PatFrag opnode> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000207 // shifted imm
Evan Chengf49810c2009-06-23 17:48:47 +0000208 def ri : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs, cc_out:$s),
209 !strconcat(opc, "${s} $dst, $lhs, $rhs"),
210 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000211
212 // shifted register
Evan Chengf49810c2009-06-23 17:48:47 +0000213 def rs : T2I<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs, cc_out:$s),
214 !strconcat(opc, "${s} $dst, $lhs, $rhs"),
215 [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>;
216}
217}
218
219/// T2I_rbin_c_is - Same as T2I_bin_c_is except the order of operands are
220/// reversed.
221let Uses = [CPSR] in {
222multiclass T2I_rbin_c_is<string opc, PatFrag opnode> {
223 // shifted imm
224 def ri : T2I<(outs GPR:$dst), (ins GPR:$rhs, t2_so_imm:$lhs, cc_out:$s),
225 !strconcat(opc, "${s} $dst, $lhs, $rhs"),
226 [(set GPR:$dst, (opnode t2_so_imm:$lhs, GPR:$rhs))]>;
227
228 // shifted register
229 def rs : T2I<(outs GPR:$dst), (ins GPR:$rhs, t2_so_reg:$lhs, cc_out:$s),
230 !strconcat(opc, "${s} $dst, $lhs, $rhs"),
231 [(set GPR:$dst, (opnode t2_so_reg:$lhs, GPR:$rhs))]>;
232}
233}
234
235
236/// T21_cmp_irs - Defines a set of (op r, {so_imm|so_reg}) cmp / test
237/// patterns. Similar to T2I_bin_is except the instruction does not produce
238/// a explicit result, only implicitly set CPSR.
239let Uses = [CPSR] in {
240multiclass T2I_cmp_is<string opc, PatFrag opnode> {
241 // shifted imm
242 def ri : T2I<(outs), (ins GPR:$lhs, t2_so_imm:$rhs),
243 !strconcat(opc, " $lhs, $rhs"),
244 [(opnode GPR:$lhs, t2_so_imm:$rhs)]>;
245
246 // shifted register
247 def rs : T2I<(outs), (ins GPR:$lhs, t2_so_reg:$rhs),
248 !strconcat(opc, " $lhs, $rhs"),
249 [(opnode GPR:$lhs, t2_so_reg:$rhs)]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000250}
251}
252
253//===----------------------------------------------------------------------===//
254// Arithmetic Instructions.
255//
256
257//===----------------------------------------------------------------------===//
258// Move Instructions.
259//
Anton Korobeynikov52237112009-06-17 18:13:58 +0000260
Evan Chengf49810c2009-06-23 17:48:47 +0000261let neverHasSideEffects = 1 in
262def t2MOVr : T2I<(outs GPR:$dst), (ins GPR:$src),
263 "mov $dst, $src", []>;
264
265def t2MOVi16 : T2I<(outs GPR:$dst), (ins i32imm:$src),
266 "movw $dst, $src",
267 [(set GPR:$dst, imm0_65535:$src)]>;
268
269
270// FIXME: Move (shifted register) is a pseudo-instruction for ASR, LSL, LSR,
271// ROR, and RRX. Consider splitting into multiple instructions.
Evan Cheng83a21292009-06-23 17:54:26 +0000272def t2MOVs : T2I<(outs GPR:$dst), (ins t2_so_reg:$src),
Evan Chengf49810c2009-06-23 17:48:47 +0000273 "mov $dst, $src",
Evan Cheng83a21292009-06-23 17:54:26 +0000274 [(set GPR:$dst, t2_so_reg:$src)]>;
Evan Chengf49810c2009-06-23 17:48:47 +0000275def t2MOVrx : T2I<(outs GPR:$dst), (ins GPR:$src),
276 "mov $dst, $src, rrx",
277 [(set GPR:$dst, (ARMrrx GPR:$src))]>;
278
279
280// FIXME: Also available in ARM mode.
Evan Cheng3850a6a2009-06-23 05:23:49 +0000281let Constraints = "$src = $dst" in
Evan Chengf49810c2009-06-23 17:48:47 +0000282def t2MOVTi16 : T2I<(outs GPR:$dst), (ins GPR:$src, i32imm:$imm),
283 "movt $dst, $imm",
284 [(set GPR:$dst,
285 (or (and GPR:$src, 0xffff), t2_lo16AllZero:$imm))]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000286
287//===----------------------------------------------------------------------===//
288// Arithmetic Instructions.
289//
Anton Korobeynikov52237112009-06-17 18:13:58 +0000290
Evan Chengf49810c2009-06-23 17:48:47 +0000291defm t2ADD : T2I_bin_ii12s<"add", BinOpFrag<(add node:$LHS, node:$RHS)>>;
292defm t2SUB : T2I_bin_ii12s<"sub", BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000293
Evan Chengf49810c2009-06-23 17:48:47 +0000294// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
295defm t2ADDS : T2I_bin_s_is<"add", BinOpFrag<(addc node:$LHS, node:$RHS)>>;
296defm t2SUBS : T2I_bin_s_is<"sub", BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000297
Evan Chengf49810c2009-06-23 17:48:47 +0000298// FIXME: predication support
299defm t2ADC : T2I_bin_c_is<"adc", BinOpFrag<(adde node:$LHS, node:$RHS)>>;
300defm t2SBC : T2I_bin_c_is<"sbc", BinOpFrag<(sube node:$LHS, node:$RHS)>>;
301
302// RSB, RSC
303defm t2RSB : T2I_rbin_is <"rsb", BinOpFrag<(sub node:$LHS, node:$RHS)>>;
304defm t2RSBS : T2I_rbin_c_is<"rsb", BinOpFrag<(subc node:$LHS, node:$RHS)>>;
305defm t2RSC : T2I_rbin_s_is<"rsc", BinOpFrag<(sube node:$LHS, node:$RHS)>>;
306
307// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
308def : Thumb2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
309 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
310def : Thumb2Pat<(add GPR:$src, imm0_4095_neg:$imm),
311 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000312
313
Evan Chengf49810c2009-06-23 17:48:47 +0000314//===----------------------------------------------------------------------===//
315// Bitwise Instructions.
316//
Anton Korobeynikov52237112009-06-17 18:13:58 +0000317
Evan Chengf49810c2009-06-23 17:48:47 +0000318defm t2AND : T2I_bin_is <"and", BinOpFrag<(and node:$LHS, node:$RHS)>>;
319defm t2ORR : T2I_bin_is <"orr", BinOpFrag<(or node:$LHS, node:$RHS)>>;
320defm t2EOR : T2I_bin_is <"eor", BinOpFrag<(xor node:$LHS, node:$RHS)>>;
321
322defm t2BIC : T2I_bin_is <"bic", BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
323
324def : Thumb2Pat<(and GPR:$src, t2_so_imm_not:$imm),
325 (t2BICri GPR:$src, t2_so_imm_not:$imm)>;
326
327defm t2ORN : T2I_bin_is <"orn", BinOpFrag<(or node:$LHS, (not node:$RHS))>>;
328
329def : Thumb2Pat<(or GPR:$src, t2_so_imm_not:$imm),
330 (t2ORNri GPR:$src, t2_so_imm_not:$imm)>;
331
332
333def t2MVNr : T2I<(outs GPR:$dst), (ins t2_so_reg:$rhs),
334 "mvn $dst, $rhs",
335 [(set GPR:$dst, (not t2_so_reg:$rhs))]>;
336let isReMaterializable = 1, isAsCheapAsAMove = 1 in
337def t2MVNi : T2I<(outs GPR:$dst), (ins t2_so_imm_not:$rhs),
338 "mvn $dst, $rhs",
339 [(set GPR:$dst, t2_so_imm_not:$rhs)]>;
340
341// A8.6.17 BFC - Bitfield clear
342// FIXME: Also available in ARM mode.
343let Constraints = "$src = $dst" in
344def t2BFC : T2I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
345 "bfc $dst, $imm",
346 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>;
347
348// FIXME: A8.6.18 BFI - Bitfield insert (Encoding T1)
349
350//===----------------------------------------------------------------------===//
351// Multiply Instructions.
352//
353def t2MUL: T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b),
354 "mul $dst, $a, $b",
355 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
356
357def t2MLA: T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
358 "mla $dst, $a, $b, $c",
359 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
360
361def t2MLS: T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
362 "mls $dst, $a, $b, $c",
363 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>;
364
365// FIXME: SMULL, etc.
366
367//===----------------------------------------------------------------------===//
368// Misc. Arithmetic Instructions.
369//
370
371/////
372/// A8.6.31 CLZ
373/////
374// FIXME not firing? but ARM version does...
375def t2CLZ : T2I<(outs GPR:$dst), (ins GPR:$src),
376 "clz $dst, $src",
377 [(set GPR:$dst, (ctlz GPR:$src))]>;
378
379def t2REV : T2I<(outs GPR:$dst), (ins GPR:$src),
380 "rev $dst, $src",
381 [(set GPR:$dst, (bswap GPR:$src))]>;
382
383def t2REV16 : T2I<(outs GPR:$dst), (ins GPR:$src),
384 "rev16 $dst, $src",
385 [(set GPR:$dst,
386 (or (and (srl GPR:$src, (i32 8)), 0xFF),
387 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
388 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
389 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>;
390
391/////
392/// A8.6.137 REVSH
393/////
394def t2REVSH : T2I<(outs GPR:$dst), (ins GPR:$src),
395 "revsh $dst, $src",
396 [(set GPR:$dst,
397 (sext_inreg
398 (or (srl (and GPR:$src, 0xFFFF), (i32 8)),
399 (shl GPR:$src, (i32 8))), i16))]>;
400
401// FIXME: PKHxx etc.
402
403//===----------------------------------------------------------------------===//
404// Comparison Instructions...
405//
406
407defm t2CMP : T2I_cmp_is<"cmp",
408 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
409defm t2CMPnz : T2I_cmp_is<"cmp",
410 BinOpFrag<(ARMcmpNZ node:$LHS, node:$RHS)>>;
411
412defm t2CMN : T2I_cmp_is<"cmn",
413 BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
414defm t2CMNnz : T2I_cmp_is<"cmn",
415 BinOpFrag<(ARMcmpNZ node:$LHS,(ineg node:$RHS))>>;
416
417def : Thumb2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
418 (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
419
420def : Thumb2Pat<(ARMcmpNZ GPR:$src, t2_so_imm_neg:$imm),
421 (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
422
423// FIXME: TST, TEQ, etc.
424
425// A8.6.27 CBNZ, CBZ - Compare and branch on (non)zero.
426// Short range conditional branch. Looks awesome for loops. Need to figure
427// out how to use this one.
428
429// FIXME: Conditional moves
430
431
432//===----------------------------------------------------------------------===//
433// Non-Instruction Patterns
434//
435
436// Large immediate handling.
437
438def : Thumb2Pat<(i32 imm:$src),
439 (t2MOVTi16 (t2MOVi16 (t2_lo16 imm:$src)),
440 (t2_hi16 imm:$src))>;