blob: 8ea5bc887ea0b2d53d7cb6d380beeeaa360667ea [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]> {
Owen Anderson5de6d842010-11-12 21:12:40 +000034 string 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); }]> {
56 string EncoderMethod = "getT2SOImmOpValue";
57}
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 Anderson7a6b8102010-11-12 23:18:11 +0000173class T2TwoRegImm<dag oops, dag iops, InstrItinClass itin,
Owen Anderson5de6d842010-11-12 21:12:40 +0000174 string opc, string asm, list<dag> pattern>
175 : T2sI<oops, iops, itin, opc, asm, pattern> {
176 bits<4> Rd;
177 bits<4> Rn;
178 bits<12> imm;
179
180 let Inst{11-8} = Rd{3-0};
181 let Inst{19-16} = Rn{3-0};
182 let Inst{26} = imm{11};
183 let Inst{14-12} = imm{10-8};
184 let Inst{7-0} = imm{7-0};
185}
186
187class T2ThreeReg<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;
191 bits<4> Rn;
192 bits<4> Rm;
193
194 let Inst{11-8} = Rd{3-0};
195 let Inst{19-16} = Rn{3-0};
196 let Inst{3-0} = Rm{3-0};
197}
198
199class T2TwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
200 string opc, string asm, list<dag> pattern>
201 : T2sI<oops, iops, itin, opc, asm, pattern> {
202 bits<4> Rd;
203 bits<4> Rn;
204 bits<12> ShiftedRm;
205
206 let Inst{11-8} = Rd{3-0};
207 let Inst{19-16} = Rn{3-0};
208 let Inst{3-0} = ShiftedRm{3-0};
209 let Inst{5-4} = ShiftedRm{6-5};
210 let Inst{14-12} = ShiftedRm{11-9};
211 let Inst{7-6} = ShiftedRm{8-7};
212}
213
Evan Chenga67efd12009-06-23 19:39:13 +0000214/// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000215/// unary operation that produces a value. These are predicable and can be
216/// changed to modify CPSR.
Evan Cheng5d42c562010-09-29 00:49:25 +0000217multiclass T2I_un_irs<bits<4> opcod, string opc,
218 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
219 PatFrag opnode, bit Cheap = 0, bit ReMat = 0> {
Evan Chenga67efd12009-06-23 19:39:13 +0000220 // shifted imm
Evan Cheng5d42c562010-09-29 00:49:25 +0000221 def i : T2sI<(outs rGPR:$dst), (ins t2_so_imm:$src), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000222 opc, "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000223 [(set rGPR:$dst, (opnode t2_so_imm:$src))]> {
Evan Chenga67efd12009-06-23 19:39:13 +0000224 let isAsCheapAsAMove = Cheap;
225 let isReMaterializable = ReMat;
Johnny Chend68e1192009-12-15 17:24:14 +0000226 let Inst{31-27} = 0b11110;
227 let Inst{25} = 0;
228 let Inst{24-21} = opcod;
229 let Inst{20} = ?; // The S bit.
230 let Inst{19-16} = 0b1111; // Rn
231 let Inst{15} = 0;
Evan Chenga67efd12009-06-23 19:39:13 +0000232 }
233 // register
Evan Cheng5d42c562010-09-29 00:49:25 +0000234 def r : T2sI<(outs rGPR:$dst), (ins rGPR:$src), iir,
Bob Wilsonc21763f2010-05-24 22:41:19 +0000235 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000236 [(set rGPR:$dst, (opnode rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000237 let Inst{31-27} = 0b11101;
238 let Inst{26-25} = 0b01;
239 let Inst{24-21} = opcod;
240 let Inst{20} = ?; // The S bit.
241 let Inst{19-16} = 0b1111; // Rn
242 let Inst{14-12} = 0b000; // imm3
243 let Inst{7-6} = 0b00; // imm2
244 let Inst{5-4} = 0b00; // type
245 }
Evan Chenga67efd12009-06-23 19:39:13 +0000246 // shifted register
Evan Cheng5d42c562010-09-29 00:49:25 +0000247 def s : T2sI<(outs rGPR:$dst), (ins t2_so_reg:$src), iis,
Bob Wilsonc21763f2010-05-24 22:41:19 +0000248 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000249 [(set rGPR:$dst, (opnode t2_so_reg:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000250 let Inst{31-27} = 0b11101;
251 let Inst{26-25} = 0b01;
252 let Inst{24-21} = opcod;
253 let Inst{20} = ?; // The S bit.
254 let Inst{19-16} = 0b1111; // Rn
255 }
Evan Chenga67efd12009-06-23 19:39:13 +0000256}
257
258/// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
Bob Wilson4876bdb2010-05-25 04:43:08 +0000259/// binary operation that produces a value. These are predicable and can be
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000260/// changed to modify CPSR.
Evan Cheng7e1bf302010-09-29 00:27:46 +0000261multiclass T2I_bin_irs<bits<4> opcod, string opc,
262 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
263 PatFrag opnode, bit Commutable = 0, string wide = ""> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000264 // shifted imm
Owen Anderson7a6b8102010-11-12 23:18:11 +0000265 def ri : T2TwoRegImm<
266 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii,
267 opc, "\t$Rd, $Rn, $imm",
268 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000269 let Inst{31-27} = 0b11110;
270 let Inst{25} = 0;
271 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000272 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000273 let Inst{15} = 0;
274 }
Evan Chenga67efd12009-06-23 19:39:13 +0000275 // register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000276 def rr : T2ThreeReg<
277 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir,
278 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"),
279 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000280 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000281 let Inst{31-27} = 0b11101;
282 let Inst{26-25} = 0b01;
283 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000284 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000285 let Inst{14-12} = 0b000; // imm3
286 let Inst{7-6} = 0b00; // imm2
287 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000288 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000289 // shifted register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000290 def rs : T2TwoRegShiftedReg<
291 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
292 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"),
293 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000294 let Inst{31-27} = 0b11101;
295 let Inst{26-25} = 0b01;
296 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000297 let Inst{20} = ?; // The S bit.
298 }
299}
300
David Goodwin1f096272009-07-27 23:34:12 +0000301/// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
302// the ".w" prefix to indicate that they are wide.
Evan Cheng7e1bf302010-09-29 00:27:46 +0000303multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
304 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
305 PatFrag opnode, bit Commutable = 0> :
306 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w">;
Bill Wendling1f7bf0e2010-08-29 03:55:31 +0000307
Evan Cheng1e249e32009-06-25 20:59:23 +0000308/// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000309/// reversed. The 'rr' form is only defined for the disassembler; for codegen
310/// it is equivalent to the T2I_bin_irs counterpart.
311multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000312 // shifted imm
Owen Anderson7a6b8102010-11-12 23:18:11 +0000313 def ri : T2TwoRegImm<
314 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
315 opc, ".w\t$Rd, $imm, $Rn",
316 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000317 let Inst{31-27} = 0b11110;
318 let Inst{25} = 0;
319 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000320 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000321 let Inst{15} = 0;
322 }
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000323 // register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000324 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
325 opc, "\t$Rd, $Rm, $Rn",
Bob Wilson136e4912010-08-14 03:18:29 +0000326 [/* For disassembly only; pattern left blank */]> {
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000327 let Inst{31-27} = 0b11101;
328 let Inst{26-25} = 0b01;
329 let Inst{24-21} = opcod;
330 let Inst{20} = ?; // The S bit.
331 let Inst{14-12} = 0b000; // imm3
332 let Inst{7-6} = 0b00; // imm2
333 let Inst{5-4} = 0b00; // type
334 }
Evan Chengf49810c2009-06-23 17:48:47 +0000335 // shifted register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000336 def rs : T2TwoRegShiftedReg<
337 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
338 IIC_iALUsir, opc, "\t$Rd, $ShiftedRm, $Rn",
339 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000340 let Inst{31-27} = 0b11101;
341 let Inst{26-25} = 0b01;
342 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000343 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000344 }
Evan Chengf49810c2009-06-23 17:48:47 +0000345}
346
Evan Chenga67efd12009-06-23 19:39:13 +0000347/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
Anton Korobeynikov52237112009-06-17 18:13:58 +0000348/// instruction modifies the CPSR register.
349let Defs = [CPSR] in {
Evan Cheng7e1bf302010-09-29 00:27:46 +0000350multiclass T2I_bin_s_irs<bits<4> opcod, string opc,
351 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
352 PatFrag opnode, bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000353 // shifted imm
Owen Anderson7a6b8102010-11-12 23:18:11 +0000354 def ri : T2TwoRegImm<(outs rGPR:$Rd), (ins GPR:$Rn, t2_so_imm:$imm), iii,
355 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $imm",
356 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000357 let Inst{31-27} = 0b11110;
358 let Inst{25} = 0;
359 let Inst{24-21} = opcod;
360 let Inst{20} = 1; // The S bit.
361 let Inst{15} = 0;
362 }
Evan Chenga67efd12009-06-23 19:39:13 +0000363 // register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000364 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins GPR:$Rn, rGPR:$Rm), iir,
365 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $Rm",
366 [(set rGPR:$Rd, (opnode GPR:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000367 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000368 let Inst{31-27} = 0b11101;
369 let Inst{26-25} = 0b01;
370 let Inst{24-21} = opcod;
371 let Inst{20} = 1; // The S bit.
372 let Inst{14-12} = 0b000; // imm3
373 let Inst{7-6} = 0b00; // imm2
374 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000375 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000376 // shifted register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000377 def rs : T2TwoRegShiftedReg<
378 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_reg:$ShiftedRm), iis,
379 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $ShiftedRm",
380 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000381 let Inst{31-27} = 0b11101;
382 let Inst{26-25} = 0b01;
383 let Inst{24-21} = opcod;
384 let Inst{20} = 1; // The S bit.
385 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000386}
387}
388
Evan Chenga67efd12009-06-23 19:39:13 +0000389/// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
390/// patterns for a binary operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000391multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
392 bit Commutable = 0> {
Evan Chengf49810c2009-06-23 17:48:47 +0000393 // shifted imm
Jim Grosbach663e3392010-08-30 19:49:58 +0000394 // The register-immediate version is re-materializable. This is useful
395 // in particular for taking the address of a local.
396 let isReMaterializable = 1 in {
Owen Anderson7a6b8102010-11-12 23:18:11 +0000397 def ri : T2TwoRegImm<
398 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
399 opc, ".w\t$Rd, $Rn, $imm",
400 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000401 let Inst{31-27} = 0b11110;
402 let Inst{25} = 0;
403 let Inst{24} = 1;
404 let Inst{23-21} = op23_21;
405 let Inst{20} = 0; // The S bit.
406 let Inst{15} = 0;
407 }
Jim Grosbach663e3392010-08-30 19:49:58 +0000408 }
Evan Chengf49810c2009-06-23 17:48:47 +0000409 // 12-bit imm
Owen Anderson7a6b8102010-11-12 23:18:11 +0000410 def ri12 : T2TwoRegImm<
411 (outs rGPR:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi,
412 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
413 [(set rGPR:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000414 let Inst{31-27} = 0b11110;
415 let Inst{25} = 1;
416 let Inst{24} = 0;
417 let Inst{23-21} = op23_21;
418 let Inst{20} = 0; // The S bit.
419 let Inst{15} = 0;
420 }
Evan Chenga67efd12009-06-23 19:39:13 +0000421 // register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000422 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins GPR:$Rn, rGPR:$Rm), IIC_iALUr,
423 opc, ".w\t$Rd, $Rn, $Rm",
424 [(set rGPR:$Rd, (opnode GPR:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000425 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000426 let Inst{31-27} = 0b11101;
427 let Inst{26-25} = 0b01;
428 let Inst{24} = 1;
429 let Inst{23-21} = op23_21;
430 let Inst{20} = 0; // The S bit.
431 let Inst{14-12} = 0b000; // imm3
432 let Inst{7-6} = 0b00; // imm2
433 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000434 }
Evan Chengf49810c2009-06-23 17:48:47 +0000435 // shifted register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000436 def rs : T2TwoRegShiftedReg<
437 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_reg:$ShiftedRm),
438 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
439 [(set rGPR:$Rd, (opnode GPR:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000440 let Inst{31-27} = 0b11101;
Johnny Chend68e1192009-12-15 17:24:14 +0000441 let Inst{26-25} = 0b01;
Johnny Chend248ffb2010-01-08 17:41:33 +0000442 let Inst{24} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000443 let Inst{23-21} = op23_21;
444 let Inst{20} = 0; // The S bit.
445 }
Evan Chengf49810c2009-06-23 17:48:47 +0000446}
447
Jim Grosbach6935efc2009-11-24 00:20:27 +0000448/// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000449/// for a binary operation that produces a value and use the carry
Jim Grosbach6935efc2009-11-24 00:20:27 +0000450/// bit. It's not predicable.
Evan Cheng62674222009-06-25 23:34:10 +0000451let Uses = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000452multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
453 bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000454 // shifted imm
Owen Anderson7a6b8102010-11-12 23:18:11 +0000455 def ri : T2TwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
Owen Anderson5de6d842010-11-12 21:12:40 +0000456 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
457 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000458 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000459 let Inst{31-27} = 0b11110;
460 let Inst{25} = 0;
461 let Inst{24-21} = opcod;
462 let Inst{20} = 0; // The S bit.
463 let Inst{15} = 0;
464 }
Evan Chenga67efd12009-06-23 19:39:13 +0000465 // register
Owen Anderson5de6d842010-11-12 21:12:40 +0000466 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
467 opc, ".w\t$Rd, $Rn, $Rm",
468 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000469 Requires<[IsThumb2]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000470 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000471 let Inst{31-27} = 0b11101;
472 let Inst{26-25} = 0b01;
473 let Inst{24-21} = opcod;
474 let Inst{20} = 0; // The S bit.
475 let Inst{14-12} = 0b000; // imm3
476 let Inst{7-6} = 0b00; // imm2
477 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000478 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000479 // shifted register
Owen Anderson5de6d842010-11-12 21:12:40 +0000480 def rs : T2TwoRegShiftedReg<
481 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
482 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
483 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000484 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000485 let Inst{31-27} = 0b11101;
486 let Inst{26-25} = 0b01;
487 let Inst{24-21} = opcod;
488 let Inst{20} = 0; // The S bit.
489 }
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000490}
491
492// Carry setting variants
493let Defs = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000494multiclass T2I_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
495 bit Commutable = 0> {
Evan Cheng62674222009-06-25 23:34:10 +0000496 // shifted imm
Owen Anderson7a6b8102010-11-12 23:18:11 +0000497 def ri : T2TwoRegImm<
Owen Anderson5de6d842010-11-12 21:12:40 +0000498 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
499 opc, "\t$Rd, $Rn, $imm",
500 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000501 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000502 let Inst{31-27} = 0b11110;
503 let Inst{25} = 0;
504 let Inst{24-21} = opcod;
505 let Inst{20} = 1; // The S bit.
506 let Inst{15} = 0;
507 }
Evan Cheng62674222009-06-25 23:34:10 +0000508 // register
Owen Anderson5de6d842010-11-12 21:12:40 +0000509 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
510 opc, ".w\t$Rd, $Rn, $Rm",
511 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000512 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000513 let isCommutable = Commutable;
514 let Inst{31-27} = 0b11101;
515 let Inst{26-25} = 0b01;
516 let Inst{24-21} = opcod;
517 let Inst{20} = 1; // The S bit.
518 let Inst{14-12} = 0b000; // imm3
519 let Inst{7-6} = 0b00; // imm2
520 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000521 }
Evan Cheng62674222009-06-25 23:34:10 +0000522 // shifted register
Owen Anderson5de6d842010-11-12 21:12:40 +0000523 def rs : T2TwoRegShiftedReg<
524 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
525 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
526 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000527 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000528 let Inst{31-27} = 0b11101;
529 let Inst{26-25} = 0b01;
530 let Inst{24-21} = opcod;
531 let Inst{20} = 1; // The S bit.
Evan Cheng8de898a2009-06-26 00:19:44 +0000532 }
Evan Chengf49810c2009-06-23 17:48:47 +0000533}
534}
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000535}
Evan Chengf49810c2009-06-23 17:48:47 +0000536
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000537/// T2I_rbin_s_is - Same as T2I_rbin_irs except sets 's' bit and the register
538/// version is not needed since this is only for codegen.
Evan Cheng1e249e32009-06-25 20:59:23 +0000539let Defs = [CPSR] in {
Johnny Chend68e1192009-12-15 17:24:14 +0000540multiclass T2I_rbin_s_is<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000541 // shifted imm
Owen Anderson7a6b8102010-11-12 23:18:11 +0000542 def ri : T2TwoRegImm<
543 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
544 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $imm",
545 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000546 let Inst{31-27} = 0b11110;
547 let Inst{25} = 0;
548 let Inst{24-21} = opcod;
549 let Inst{20} = 1; // The S bit.
550 let Inst{15} = 0;
551 }
Evan Chengf49810c2009-06-23 17:48:47 +0000552 // shifted register
Owen Anderson7a6b8102010-11-12 23:18:11 +0000553 def rs : T2TwoRegShiftedReg<
554 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
555 IIC_iALUsi, !strconcat(opc, "s"), "\t$Rd, $Rn, $ShiftedRm",
556 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000557 let Inst{31-27} = 0b11101;
558 let Inst{26-25} = 0b01;
559 let Inst{24-21} = opcod;
560 let Inst{20} = 1; // The S bit.
561 }
Evan Chengf49810c2009-06-23 17:48:47 +0000562}
563}
564
Evan Chenga67efd12009-06-23 19:39:13 +0000565/// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
566// rotate operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000567multiclass T2I_sh_ir<bits<2> opcod, string opc, PatFrag opnode> {
Evan Chenga67efd12009-06-23 19:39:13 +0000568 // 5-bit imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000569 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, i32imm:$rhs), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000570 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000571 [(set rGPR:$dst, (opnode rGPR:$lhs, imm1_31:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000572 let Inst{31-27} = 0b11101;
573 let Inst{26-21} = 0b010010;
574 let Inst{19-16} = 0b1111; // Rn
575 let Inst{5-4} = opcod;
576 }
Evan Chenga67efd12009-06-23 19:39:13 +0000577 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000578 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs), IIC_iMOVsr,
Evan Cheng699beba2009-10-27 00:08:59 +0000579 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000580 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000581 let Inst{31-27} = 0b11111;
582 let Inst{26-23} = 0b0100;
583 let Inst{22-21} = opcod;
584 let Inst{15-12} = 0b1111;
585 let Inst{7-4} = 0b0000;
586 }
Evan Chenga67efd12009-06-23 19:39:13 +0000587}
Evan Chengf49810c2009-06-23 17:48:47 +0000588
Johnny Chend68e1192009-12-15 17:24:14 +0000589/// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
Evan Chenga67efd12009-06-23 19:39:13 +0000590/// patterns. Similar to T2I_bin_irs except the instruction does not produce
Evan Chengf49810c2009-06-23 17:48:47 +0000591/// a explicit result, only implicitly set CPSR.
Bill Wendlingf0e132c2010-08-19 00:05:48 +0000592let isCompare = 1, Defs = [CPSR] in {
Evan Cheng5d42c562010-09-29 00:49:25 +0000593multiclass T2I_cmp_irs<bits<4> opcod, string opc,
594 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
595 PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000596 // shifted imm
Evan Cheng5d42c562010-09-29 00:49:25 +0000597 def ri : T2I<(outs), (ins GPR:$lhs, t2_so_imm:$rhs), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000598 opc, ".w\t$lhs, $rhs",
Johnny Chend68e1192009-12-15 17:24:14 +0000599 [(opnode GPR:$lhs, t2_so_imm:$rhs)]> {
600 let Inst{31-27} = 0b11110;
601 let Inst{25} = 0;
602 let Inst{24-21} = opcod;
603 let Inst{20} = 1; // The S bit.
604 let Inst{15} = 0;
605 let Inst{11-8} = 0b1111; // Rd
606 }
Evan Chenga67efd12009-06-23 19:39:13 +0000607 // register
Evan Cheng5d42c562010-09-29 00:49:25 +0000608 def rr : T2I<(outs), (ins GPR:$lhs, rGPR:$rhs), iir,
Evan Cheng699beba2009-10-27 00:08:59 +0000609 opc, ".w\t$lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000610 [(opnode GPR:$lhs, rGPR:$rhs)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000611 let Inst{31-27} = 0b11101;
612 let Inst{26-25} = 0b01;
613 let Inst{24-21} = opcod;
614 let Inst{20} = 1; // The S bit.
615 let Inst{14-12} = 0b000; // imm3
616 let Inst{11-8} = 0b1111; // Rd
617 let Inst{7-6} = 0b00; // imm2
618 let Inst{5-4} = 0b00; // type
619 }
Evan Chengf49810c2009-06-23 17:48:47 +0000620 // shifted register
Evan Cheng5d42c562010-09-29 00:49:25 +0000621 def rs : T2I<(outs), (ins GPR:$lhs, t2_so_reg:$rhs), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000622 opc, ".w\t$lhs, $rhs",
Johnny Chend68e1192009-12-15 17:24:14 +0000623 [(opnode GPR:$lhs, t2_so_reg:$rhs)]> {
624 let Inst{31-27} = 0b11101;
625 let Inst{26-25} = 0b01;
626 let Inst{24-21} = opcod;
627 let Inst{20} = 1; // The S bit.
628 let Inst{11-8} = 0b1111; // Rd
629 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000630}
631}
632
Evan Chengf3c21b82009-06-30 02:15:48 +0000633/// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000634multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
Evan Cheng7e2fe912010-10-28 06:47:08 +0000635 InstrItinClass iii, InstrItinClass iis, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +0000636 def i12 : T2Ii12<(outs GPR:$dst), (ins t2addrmode_imm12:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000637 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000638 [(set GPR:$dst, (opnode t2addrmode_imm12:$addr))]> {
639 let Inst{31-27} = 0b11111;
640 let Inst{26-25} = 0b00;
641 let Inst{24} = signed;
642 let Inst{23} = 1;
643 let Inst{22-21} = opcod;
644 let Inst{20} = 1; // load
645 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000646 def i8 : T2Ii8 <(outs GPR:$dst), (ins t2addrmode_imm8:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000647 opc, "\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000648 [(set GPR:$dst, (opnode t2addrmode_imm8:$addr))]> {
649 let Inst{31-27} = 0b11111;
650 let Inst{26-25} = 0b00;
651 let Inst{24} = signed;
652 let Inst{23} = 0;
653 let Inst{22-21} = opcod;
654 let Inst{20} = 1; // load
655 let Inst{11} = 1;
656 // Offset: index==TRUE, wback==FALSE
657 let Inst{10} = 1; // The P bit.
658 let Inst{8} = 0; // The W bit.
659 }
Evan Cheng7e2fe912010-10-28 06:47:08 +0000660 def s : T2Iso <(outs GPR:$dst), (ins t2addrmode_so_reg:$addr), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000661 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000662 [(set GPR:$dst, (opnode t2addrmode_so_reg:$addr))]> {
663 let Inst{31-27} = 0b11111;
664 let Inst{26-25} = 0b00;
665 let Inst{24} = signed;
666 let Inst{23} = 0;
667 let Inst{22-21} = opcod;
668 let Inst{20} = 1; // load
669 let Inst{11-6} = 0b000000;
670 }
Evan Chengbc7deb02010-11-03 05:14:24 +0000671
672 // FIXME: Is the pci variant actually needed?
Evan Cheng0e55fd62010-09-30 01:08:25 +0000673 def pci : T2Ipc <(outs GPR:$dst), (ins i32imm:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000674 opc, ".w\t$dst, $addr",
Evan Cheng9eda6892009-10-31 03:39:36 +0000675 [(set GPR:$dst, (opnode (ARMWrapper tconstpool:$addr)))]> {
676 let isReMaterializable = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000677 let Inst{31-27} = 0b11111;
678 let Inst{26-25} = 0b00;
679 let Inst{24} = signed;
680 let Inst{23} = ?; // add = (U == '1')
681 let Inst{22-21} = opcod;
682 let Inst{20} = 1; // load
683 let Inst{19-16} = 0b1111; // Rn
Evan Cheng9eda6892009-10-31 03:39:36 +0000684 }
Evan Chengf3c21b82009-06-30 02:15:48 +0000685}
686
David Goodwin73b8f162009-06-30 22:11:34 +0000687/// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000688multiclass T2I_st<bits<2> opcod, string opc,
Evan Cheng7e2fe912010-10-28 06:47:08 +0000689 InstrItinClass iii, InstrItinClass iis, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +0000690 def i12 : T2Ii12<(outs), (ins GPR:$src, t2addrmode_imm12:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000691 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000692 [(opnode GPR:$src, t2addrmode_imm12:$addr)]> {
693 let Inst{31-27} = 0b11111;
694 let Inst{26-23} = 0b0001;
695 let Inst{22-21} = opcod;
696 let Inst{20} = 0; // !load
697 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000698 def i8 : T2Ii8 <(outs), (ins GPR:$src, t2addrmode_imm8:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000699 opc, "\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000700 [(opnode GPR:$src, t2addrmode_imm8:$addr)]> {
701 let Inst{31-27} = 0b11111;
702 let Inst{26-23} = 0b0000;
703 let Inst{22-21} = opcod;
704 let Inst{20} = 0; // !load
705 let Inst{11} = 1;
706 // Offset: index==TRUE, wback==FALSE
707 let Inst{10} = 1; // The P bit.
708 let Inst{8} = 0; // The W bit.
709 }
Evan Cheng7e2fe912010-10-28 06:47:08 +0000710 def s : T2Iso <(outs), (ins GPR:$src, t2addrmode_so_reg:$addr), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000711 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000712 [(opnode GPR:$src, t2addrmode_so_reg:$addr)]> {
713 let Inst{31-27} = 0b11111;
714 let Inst{26-23} = 0b0000;
715 let Inst{22-21} = opcod;
716 let Inst{20} = 0; // !load
717 let Inst{11-6} = 0b000000;
718 }
David Goodwin73b8f162009-06-30 22:11:34 +0000719}
720
Evan Cheng0e55fd62010-09-30 01:08:25 +0000721/// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +0000722/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000723multiclass T2I_ext_rrot<bits<3> opcod, string opc, PatFrag opnode> {
724 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Evan Cheng699beba2009-10-27 00:08:59 +0000725 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000726 [(set rGPR:$dst, (opnode rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000727 let Inst{31-27} = 0b11111;
728 let Inst{26-23} = 0b0100;
729 let Inst{22-20} = opcod;
730 let Inst{19-16} = 0b1111; // Rn
731 let Inst{15-12} = 0b1111;
732 let Inst{7} = 1;
733 let Inst{5-4} = 0b00; // rotate
734 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000735 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Evan Cheng699beba2009-10-27 00:08:59 +0000736 opc, ".w\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000737 [(set rGPR:$dst, (opnode (rotr rGPR:$src, rot_imm:$rot)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000738 let Inst{31-27} = 0b11111;
739 let Inst{26-23} = 0b0100;
740 let Inst{22-20} = opcod;
741 let Inst{19-16} = 0b1111; // Rn
742 let Inst{15-12} = 0b1111;
743 let Inst{7} = 1;
744 let Inst{5-4} = {?,?}; // rotate
745 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000746}
747
Eli Friedman761fa7a2010-06-24 18:20:04 +0000748// UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000749multiclass T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode> {
750 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Johnny Chen267124c2010-03-04 22:24:41 +0000751 opc, "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000752 [(set rGPR:$dst, (opnode rGPR:$src))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000753 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000754 let Inst{31-27} = 0b11111;
755 let Inst{26-23} = 0b0100;
756 let Inst{22-20} = opcod;
757 let Inst{19-16} = 0b1111; // Rn
758 let Inst{15-12} = 0b1111;
759 let Inst{7} = 1;
760 let Inst{5-4} = 0b00; // rotate
761 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000762 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Johnny Chen267124c2010-03-04 22:24:41 +0000763 opc, "\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000764 [(set rGPR:$dst, (opnode (rotr rGPR:$src, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000765 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000766 let Inst{31-27} = 0b11111;
767 let Inst{26-23} = 0b0100;
768 let Inst{22-20} = opcod;
769 let Inst{19-16} = 0b1111; // Rn
770 let Inst{15-12} = 0b1111;
771 let Inst{7} = 1;
772 let Inst{5-4} = {?,?}; // rotate
773 }
774}
775
Eli Friedman761fa7a2010-06-24 18:20:04 +0000776// SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
777// supported yet.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000778multiclass T2I_ext_rrot_sxtb16<bits<3> opcod, string opc> {
779 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Johnny Chen93042d12010-03-02 18:14:57 +0000780 opc, "\t$dst, $src", []> {
781 let Inst{31-27} = 0b11111;
782 let Inst{26-23} = 0b0100;
783 let Inst{22-20} = opcod;
784 let Inst{19-16} = 0b1111; // Rn
785 let Inst{15-12} = 0b1111;
786 let Inst{7} = 1;
787 let Inst{5-4} = 0b00; // rotate
788 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000789 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Johnny Chen93042d12010-03-02 18:14:57 +0000790 opc, "\t$dst, $src, ror $rot", []> {
791 let Inst{31-27} = 0b11111;
792 let Inst{26-23} = 0b0100;
793 let Inst{22-20} = opcod;
794 let Inst{19-16} = 0b1111; // Rn
795 let Inst{15-12} = 0b1111;
796 let Inst{7} = 1;
797 let Inst{5-4} = {?,?}; // rotate
798 }
799}
800
Evan Cheng0e55fd62010-09-30 01:08:25 +0000801/// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +0000802/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000803multiclass T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode> {
804 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iEXTAr,
Evan Cheng699beba2009-10-27 00:08:59 +0000805 opc, "\t$dst, $LHS, $RHS",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000806 [(set rGPR:$dst, (opnode rGPR:$LHS, rGPR:$RHS))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000807 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000808 let Inst{31-27} = 0b11111;
809 let Inst{26-23} = 0b0100;
810 let Inst{22-20} = opcod;
811 let Inst{15-12} = 0b1111;
812 let Inst{7} = 1;
813 let Inst{5-4} = 0b00; // rotate
814 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000815 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Evan Cheng0e55fd62010-09-30 01:08:25 +0000816 IIC_iEXTAsr, opc, "\t$dst, $LHS, $RHS, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000817 [(set rGPR:$dst, (opnode rGPR:$LHS,
818 (rotr rGPR:$RHS, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000819 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000820 let Inst{31-27} = 0b11111;
821 let Inst{26-23} = 0b0100;
822 let Inst{22-20} = opcod;
823 let Inst{15-12} = 0b1111;
824 let Inst{7} = 1;
825 let Inst{5-4} = {?,?}; // rotate
826 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000827}
828
Johnny Chen93042d12010-03-02 18:14:57 +0000829// DO variant - disassembly only, no pattern
830
Evan Cheng0e55fd62010-09-30 01:08:25 +0000831multiclass T2I_exta_rrot_DO<bits<3> opcod, string opc> {
Evan Cheng7e1bf302010-09-29 00:27:46 +0000832 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iEXTAr,
Johnny Chen93042d12010-03-02 18:14:57 +0000833 opc, "\t$dst, $LHS, $RHS", []> {
834 let Inst{31-27} = 0b11111;
835 let Inst{26-23} = 0b0100;
836 let Inst{22-20} = opcod;
837 let Inst{15-12} = 0b1111;
838 let Inst{7} = 1;
839 let Inst{5-4} = 0b00; // rotate
840 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000841 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Evan Cheng7e1bf302010-09-29 00:27:46 +0000842 IIC_iEXTAsr, opc, "\t$dst, $LHS, $RHS, ror $rot", []> {
Johnny Chen93042d12010-03-02 18:14:57 +0000843 let Inst{31-27} = 0b11111;
844 let Inst{26-23} = 0b0100;
845 let Inst{22-20} = opcod;
846 let Inst{15-12} = 0b1111;
847 let Inst{7} = 1;
848 let Inst{5-4} = {?,?}; // rotate
849 }
850}
851
Anton Korobeynikov52237112009-06-17 18:13:58 +0000852//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000853// Instructions
854//===----------------------------------------------------------------------===//
855
856//===----------------------------------------------------------------------===//
Evan Chenga09b9ca2009-06-24 23:47:58 +0000857// Miscellaneous Instructions.
858//
859
Evan Chenga09b9ca2009-06-24 23:47:58 +0000860// LEApcrel - Load a pc-relative address into a register without offending the
861// assembler.
Evan Chengea420b22010-05-19 01:52:25 +0000862let neverHasSideEffects = 1 in {
Evan Cheng9085f982010-05-19 07:28:01 +0000863let isReMaterializable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000864def t2LEApcrel : T2XI<(outs rGPR:$dst), (ins i32imm:$label, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +0000865 "adr${p}.w\t$dst, #$label", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000866 let Inst{31-27} = 0b11110;
867 let Inst{25-24} = 0b10;
868 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
869 let Inst{22} = 0;
870 let Inst{20} = 0;
871 let Inst{19-16} = 0b1111; // Rn
872 let Inst{15} = 0;
873}
Jim Grosbacha967d112010-06-21 21:27:27 +0000874} // neverHasSideEffects
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000875def t2LEApcrelJT : T2XI<(outs rGPR:$dst),
Bob Wilson4f38b382009-08-21 21:58:55 +0000876 (ins i32imm:$label, nohash_imm:$id, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +0000877 "adr${p}.w\t$dst, #${label}_${id}", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000878 let Inst{31-27} = 0b11110;
879 let Inst{25-24} = 0b10;
880 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
881 let Inst{22} = 0;
882 let Inst{20} = 0;
883 let Inst{19-16} = 0b1111; // Rn
884 let Inst{15} = 0;
885}
Evan Chenga09b9ca2009-06-24 23:47:58 +0000886
Evan Cheng86198642009-08-07 00:34:42 +0000887// ADD r, sp, {so_imm|i12}
Owen Anderson7a6b8102010-11-12 23:18:11 +0000888def t2ADDrSPi : T2TwoRegImm<
889 (outs GPR:$Rd), (ins GPR:$Rn, t2_so_imm:$imm),
890 IIC_iALUi, "add", ".w\t$Rn, $Rn, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000891 let Inst{31-27} = 0b11110;
892 let Inst{25} = 0;
893 let Inst{24-21} = 0b1000;
894 let Inst{20} = ?; // The S bit.
Owen Anderson7a6b8102010-11-12 23:18:11 +0000895 let Inst{19-16} = 0b1101;
Johnny Chend68e1192009-12-15 17:24:14 +0000896 let Inst{15} = 0;
897}
Owen Anderson7a6b8102010-11-12 23:18:11 +0000898def t2ADDrSPi12 : T2TwoRegImm<
899 (outs GPR:$Rd), (ins GPR:$Rn, imm0_4095:$imm),
900 IIC_iALUi, "addw", "\t$Rd, $Rn, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000901 let Inst{31-27} = 0b11110;
902 let Inst{25} = 1;
903 let Inst{24-21} = 0b0000;
904 let Inst{20} = 0; // The S bit.
905 let Inst{19-16} = 0b1101; // Rn = sp
906 let Inst{15} = 0;
907}
Evan Cheng86198642009-08-07 00:34:42 +0000908
909// ADD r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +0000910def t2ADDrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +0000911 IIC_iALUsi, "add", ".w\t$dst, $sp, $rhs", []> {
912 let Inst{31-27} = 0b11101;
913 let Inst{26-25} = 0b01;
914 let Inst{24-21} = 0b1000;
915 let Inst{20} = ?; // The S bit.
916 let Inst{19-16} = 0b1101; // Rn = sp
917 let Inst{15} = 0;
918}
Evan Cheng86198642009-08-07 00:34:42 +0000919
920// SUB r, sp, {so_imm|i12}
David Goodwin5d598aa2009-08-19 18:00:44 +0000921def t2SUBrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000922 IIC_iALUi, "sub", ".w\t$dst, $sp, $imm", []> {
923 let Inst{31-27} = 0b11110;
924 let Inst{25} = 0;
925 let Inst{24-21} = 0b1101;
926 let Inst{20} = ?; // The S bit.
927 let Inst{19-16} = 0b1101; // Rn = sp
928 let Inst{15} = 0;
929}
David Goodwin5d598aa2009-08-19 18:00:44 +0000930def t2SUBrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000931 IIC_iALUi, "subw", "\t$dst, $sp, $imm", []> {
932 let Inst{31-27} = 0b11110;
933 let Inst{25} = 1;
934 let Inst{24-21} = 0b0101;
935 let Inst{20} = 0; // The S bit.
936 let Inst{19-16} = 0b1101; // Rn = sp
937 let Inst{15} = 0;
938}
Evan Cheng86198642009-08-07 00:34:42 +0000939
940// SUB r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +0000941def t2SUBrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
942 IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +0000943 "sub", "\t$dst, $sp, $rhs", []> {
944 let Inst{31-27} = 0b11101;
945 let Inst{26-25} = 0b01;
946 let Inst{24-21} = 0b1101;
947 let Inst{20} = ?; // The S bit.
948 let Inst{19-16} = 0b1101; // Rn = sp
949 let Inst{15} = 0;
950}
Evan Cheng86198642009-08-07 00:34:42 +0000951
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000952// Signed and unsigned division on v7-M
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000953def t2SDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000954 "sdiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000955 [(set rGPR:$dst, (sdiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000956 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +0000957 let Inst{31-27} = 0b11111;
958 let Inst{26-21} = 0b011100;
959 let Inst{20} = 0b1;
960 let Inst{15-12} = 0b1111;
961 let Inst{7-4} = 0b1111;
962}
963
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000964def t2UDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000965 "udiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000966 [(set rGPR:$dst, (udiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000967 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +0000968 let Inst{31-27} = 0b11111;
969 let Inst{26-21} = 0b011101;
970 let Inst{20} = 0b1;
971 let Inst{15-12} = 0b1111;
972 let Inst{7-4} = 0b1111;
973}
974
Evan Chenga09b9ca2009-06-24 23:47:58 +0000975//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000976// Load / store Instructions.
977//
978
Evan Cheng055b0312009-06-29 07:51:04 +0000979// Load
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000980let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng7e2fe912010-10-28 06:47:08 +0000981defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000982 UnOpFrag<(load node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000983
Evan Chengf3c21b82009-06-30 02:15:48 +0000984// Loads with zero extension
Evan Cheng7e2fe912010-10-28 06:47:08 +0000985defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000986 UnOpFrag<(zextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +0000987defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000988 UnOpFrag<(zextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000989
Evan Chengf3c21b82009-06-30 02:15:48 +0000990// Loads with sign extension
Evan Cheng7e2fe912010-10-28 06:47:08 +0000991defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000992 UnOpFrag<(sextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +0000993defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000994 UnOpFrag<(sextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000995
Chris Lattnera1ca91a2010-11-02 23:40:41 +0000996let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
997 isCodeGenOnly = 1 in { // $dst doesn't exist in asmstring?
Evan Chengf3c21b82009-06-30 02:15:48 +0000998// Load doubleword
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000999def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Chenge298ab22009-09-27 09:46:04 +00001000 (ins t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001001 IIC_iLoad_d_i, "ldrd", "\t$dst1, $addr", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001002def t2LDRDpci : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001003 (ins i32imm:$addr), IIC_iLoad_d_i,
Johnny Chen83142992010-01-05 22:37:28 +00001004 "ldrd", "\t$dst1, $addr", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001005 let Inst{19-16} = 0b1111; // Rn
1006}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001007} // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
Evan Chengf3c21b82009-06-30 02:15:48 +00001008
1009// zextload i1 -> zextload i8
1010def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1011 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1012def : T2Pat<(zextloadi1 t2addrmode_imm8:$addr),
1013 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1014def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1015 (t2LDRBs t2addrmode_so_reg:$addr)>;
1016def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1017 (t2LDRBpci tconstpool:$addr)>;
1018
1019// extload -> zextload
1020// FIXME: Reduce the number of patterns by legalizing extload to zextload
1021// earlier?
1022def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1023 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1024def : T2Pat<(extloadi1 t2addrmode_imm8:$addr),
1025 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1026def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1027 (t2LDRBs t2addrmode_so_reg:$addr)>;
1028def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1029 (t2LDRBpci tconstpool:$addr)>;
1030
1031def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1032 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1033def : T2Pat<(extloadi8 t2addrmode_imm8:$addr),
1034 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1035def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1036 (t2LDRBs t2addrmode_so_reg:$addr)>;
1037def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1038 (t2LDRBpci tconstpool:$addr)>;
1039
1040def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1041 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1042def : T2Pat<(extloadi16 t2addrmode_imm8:$addr),
1043 (t2LDRHi8 t2addrmode_imm8:$addr)>;
1044def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1045 (t2LDRHs t2addrmode_so_reg:$addr)>;
1046def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1047 (t2LDRHpci tconstpool:$addr)>;
Evan Cheng055b0312009-06-29 07:51:04 +00001048
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001049// FIXME: The destination register of the loads and stores can't be PC, but
1050// can be SP. We need another regclass (similar to rGPR) to represent
1051// that. Not a pressing issue since these are selected manually,
1052// not via pattern.
1053
Evan Chenge88d5ce2009-07-02 07:28:31 +00001054// Indexed loads
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001055let mayLoad = 1, neverHasSideEffects = 1 in {
Johnny Chend68e1192009-12-15 17:24:14 +00001056def t2LDR_PRE : T2Iidxldst<0, 0b10, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001057 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001058 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001059 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001060 []>;
1061
Johnny Chend68e1192009-12-15 17:24:14 +00001062def t2LDR_POST : T2Iidxldst<0, 0b10, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001063 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001064 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001065 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001066 []>;
1067
Johnny Chend68e1192009-12-15 17:24:14 +00001068def t2LDRB_PRE : T2Iidxldst<0, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001069 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001070 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001071 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001072 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001073def t2LDRB_POST : T2Iidxldst<0, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001074 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001075 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001076 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001077 []>;
1078
Johnny Chend68e1192009-12-15 17:24:14 +00001079def t2LDRH_PRE : T2Iidxldst<0, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001080 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001081 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001082 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001083 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001084def t2LDRH_POST : T2Iidxldst<0, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001085 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001086 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001087 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001088 []>;
1089
Johnny Chend68e1192009-12-15 17:24:14 +00001090def t2LDRSB_PRE : T2Iidxldst<1, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001091 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001092 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001093 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001094 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001095def t2LDRSB_POST : T2Iidxldst<1, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001096 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001097 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001098 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001099 []>;
1100
Johnny Chend68e1192009-12-15 17:24:14 +00001101def t2LDRSH_PRE : T2Iidxldst<1, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001102 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001103 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001104 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001105 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001106def t2LDRSH_POST : T2Iidxldst<1, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001107 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001108 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001109 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001110 []>;
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001111} // mayLoad = 1, neverHasSideEffects = 1
Evan Cheng4fbb9962009-07-02 23:16:11 +00001112
Johnny Chene54a3ef2010-03-03 18:45:36 +00001113// LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110) and are
1114// for disassembly only.
1115// Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001116class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1117 : T2Ii8<(outs GPR:$dst), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001118 "\t$dst, $addr", []> {
1119 let Inst{31-27} = 0b11111;
1120 let Inst{26-25} = 0b00;
1121 let Inst{24} = signed;
1122 let Inst{23} = 0;
1123 let Inst{22-21} = type;
1124 let Inst{20} = 1; // load
1125 let Inst{11} = 1;
1126 let Inst{10-8} = 0b110; // PUW.
1127}
1128
Evan Cheng0e55fd62010-09-30 01:08:25 +00001129def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1130def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1131def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1132def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1133def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
Johnny Chene54a3ef2010-03-03 18:45:36 +00001134
David Goodwin73b8f162009-06-30 22:11:34 +00001135// Store
Evan Cheng7e2fe912010-10-28 06:47:08 +00001136defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001137 BinOpFrag<(store node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001138defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001139 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001140defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001141 BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
David Goodwin73b8f162009-06-30 22:11:34 +00001142
David Goodwin6647cea2009-06-30 22:50:01 +00001143// Store doubleword
Chris Lattnera1ca91a2010-11-02 23:40:41 +00001144let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1145 isCodeGenOnly = 1 in // $src2 doesn't exist in asm string
Johnny Chend68e1192009-12-15 17:24:14 +00001146def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
Evan Chenge298ab22009-09-27 09:46:04 +00001147 (ins GPR:$src1, GPR:$src2, t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001148 IIC_iStore_d_r, "strd", "\t$src1, $addr", []>;
David Goodwin6647cea2009-06-30 22:50:01 +00001149
Evan Cheng6d94f112009-07-03 00:06:39 +00001150// Indexed stores
Johnny Chend68e1192009-12-15 17:24:14 +00001151def t2STR_PRE : T2Iidxldst<0, 0b10, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001152 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001153 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001154 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001155 [(set GPR:$base_wb,
1156 (pre_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1157
Johnny Chend68e1192009-12-15 17:24:14 +00001158def t2STR_POST : T2Iidxldst<0, 0b10, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001159 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001160 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001161 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001162 [(set GPR:$base_wb,
Jim Grosbach6935efc2009-11-24 00:20:27 +00001163 (post_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001164
Johnny Chend68e1192009-12-15 17:24:14 +00001165def t2STRH_PRE : T2Iidxldst<0, 0b01, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001166 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001167 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001168 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001169 [(set GPR:$base_wb,
1170 (pre_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1171
Johnny Chend68e1192009-12-15 17:24:14 +00001172def t2STRH_POST : T2Iidxldst<0, 0b01, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001173 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001174 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001175 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001176 [(set GPR:$base_wb,
1177 (post_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1178
Johnny Chend68e1192009-12-15 17:24:14 +00001179def t2STRB_PRE : T2Iidxldst<0, 0b00, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001180 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001181 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001182 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001183 [(set GPR:$base_wb,
1184 (pre_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1185
Johnny Chend68e1192009-12-15 17:24:14 +00001186def t2STRB_POST : T2Iidxldst<0, 0b00, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001187 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001188 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001189 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001190 [(set GPR:$base_wb,
1191 (post_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1192
Johnny Chene54a3ef2010-03-03 18:45:36 +00001193// STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1194// only.
1195// Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001196class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1197 : T2Ii8<(outs GPR:$src), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001198 "\t$src, $addr", []> {
1199 let Inst{31-27} = 0b11111;
1200 let Inst{26-25} = 0b00;
1201 let Inst{24} = 0; // not signed
1202 let Inst{23} = 0;
1203 let Inst{22-21} = type;
1204 let Inst{20} = 0; // store
1205 let Inst{11} = 1;
1206 let Inst{10-8} = 0b110; // PUW
1207}
1208
Evan Cheng0e55fd62010-09-30 01:08:25 +00001209def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1210def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1211def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
David Goodwind1fa1202009-07-01 00:01:13 +00001212
Johnny Chenae1757b2010-03-11 01:13:36 +00001213// ldrd / strd pre / post variants
1214// For disassembly only.
1215
1216def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001217 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001218 "ldrd", "\t$dst1, $dst2, [$base, $imm]!", []>;
1219
1220def t2LDRD_POST : T2Ii8s4<0, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001221 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001222 "ldrd", "\t$dst1, $dst2, [$base], $imm", []>;
1223
1224def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs),
1225 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001226 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base, $imm]!", []>;
Johnny Chenae1757b2010-03-11 01:13:36 +00001227
1228def t2STRD_POST : T2Ii8s4<0, 1, 0, (outs),
1229 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001230 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base], $imm", []>;
Evan Cheng2889cce2009-07-03 00:18:36 +00001231
Johnny Chen0635fc52010-03-04 17:40:44 +00001232// T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1233// data/instruction access. These are for disassembly only.
Evan Chengdfed19f2010-11-03 06:34:55 +00001234// instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1235// (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
Evan Cheng416941d2010-11-04 05:19:35 +00001236multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001237
Evan Chengdfed19f2010-11-03 06:34:55 +00001238 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001239 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001240 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001241 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001242 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001243 let Inst{23} = 1; // U = 1
1244 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001245 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001246 let Inst{20} = 1;
1247 let Inst{15-12} = 0b1111;
1248 }
1249
Evan Chengdfed19f2010-11-03 06:34:55 +00001250 def i8 : T2Ii8<(outs), (ins t2addrmode_imm8:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001251 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001252 [(ARMPreload t2addrmode_imm8:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001253 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001254 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001255 let Inst{23} = 0; // U = 0
1256 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001257 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001258 let Inst{20} = 1;
1259 let Inst{15-12} = 0b1111;
1260 let Inst{11-8} = 0b1100;
1261 }
1262
Evan Chengdfed19f2010-11-03 06:34:55 +00001263 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001264 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001265 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
Evan Chengbc7deb02010-11-03 05:14:24 +00001266 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001267 let Inst{24} = instr;
Evan Chengbc7deb02010-11-03 05:14:24 +00001268 let Inst{23} = 0; // add = TRUE for T1
1269 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001270 let Inst{21} = write;
Evan Chengbc7deb02010-11-03 05:14:24 +00001271 let Inst{20} = 1;
1272 let Inst{15-12} = 0b1111;
1273 let Inst{11-6} = 0000000;
1274 }
1275
1276 let isCodeGenOnly = 1 in
Evan Chengdfed19f2010-11-03 06:34:55 +00001277 def pci : T2Ipc<(outs), (ins i32imm:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001278 "\t$addr",
1279 []> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001280 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001281 let Inst{24} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001282 let Inst{23} = ?; // add = (U == 1)
1283 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001284 let Inst{21} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001285 let Inst{20} = 1;
1286 let Inst{19-16} = 0b1111; // Rn = 0b1111
1287 let Inst{15-12} = 0b1111;
1288 }
Johnny Chen0635fc52010-03-04 17:40:44 +00001289}
1290
Evan Cheng416941d2010-11-04 05:19:35 +00001291defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1292defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1293defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
Johnny Chen0635fc52010-03-04 17:40:44 +00001294
Evan Cheng2889cce2009-07-03 00:18:36 +00001295//===----------------------------------------------------------------------===//
1296// Load / store multiple Instructions.
1297//
1298
Chris Lattner39ee0362010-10-31 19:10:56 +00001299let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
1300 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001301def t2LDM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001302 reglist:$dsts, variable_ops), IIC_iLoad_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001303 "ldm${amode}${p}.w\t$Rn, $dsts", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001304 let Inst{31-27} = 0b11101;
1305 let Inst{26-25} = 0b00;
1306 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1307 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001308 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001309 let Inst{20} = 1; // Load
1310}
Evan Cheng2889cce2009-07-03 00:18:36 +00001311
Jim Grosbache6913602010-11-03 01:01:43 +00001312def t2LDM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001313 reglist:$dsts, variable_ops),
1314 IIC_iLoad_mu,
Jim Grosbache6913602010-11-03 01:01:43 +00001315 "ldm${amode}${p}.w\t$Rn!, $dsts",
1316 "$Rn = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001317 let Inst{31-27} = 0b11101;
1318 let Inst{26-25} = 0b00;
1319 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1320 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001321 let Inst{21} = 1; // The W bit.
1322 let Inst{20} = 1; // Load
1323}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001324} // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001325
Chris Lattner39ee0362010-10-31 19:10:56 +00001326let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1327 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001328def t2STM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001329 reglist:$srcs, variable_ops), IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001330 "stm${amode}${p}.w\t$Rn, $srcs", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +00001331 let Inst{31-27} = 0b11101;
1332 let Inst{26-25} = 0b00;
1333 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1334 let Inst{22} = 0;
1335 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001336 let Inst{20} = 0; // Store
1337}
Evan Cheng2889cce2009-07-03 00:18:36 +00001338
Jim Grosbache6913602010-11-03 01:01:43 +00001339def t2STM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +00001340 reglist:$srcs, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00001341 IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001342 "stm${amode}${p}.w\t$Rn!, $srcs",
1343 "$Rn = $wb", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +00001344 let Inst{31-27} = 0b11101;
1345 let Inst{26-25} = 0b00;
1346 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1347 let Inst{22} = 0;
1348 let Inst{21} = 1; // The W bit.
1349 let Inst{20} = 0; // Store
1350}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001351} // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001352
Evan Cheng9cb9e672009-06-27 02:26:13 +00001353//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001354// Move Instructions.
1355//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001356
Evan Chengf49810c2009-06-23 17:48:47 +00001357let neverHasSideEffects = 1 in
David Goodwin5d598aa2009-08-19 18:00:44 +00001358def t2MOVr : T2sI<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVr,
Johnny Chend68e1192009-12-15 17:24:14 +00001359 "mov", ".w\t$dst, $src", []> {
1360 let Inst{31-27} = 0b11101;
1361 let Inst{26-25} = 0b01;
1362 let Inst{24-21} = 0b0010;
1363 let Inst{20} = ?; // The S bit.
1364 let Inst{19-16} = 0b1111; // Rn
1365 let Inst{14-12} = 0b000;
1366 let Inst{7-4} = 0b0000;
1367}
Evan Chengf49810c2009-06-23 17:48:47 +00001368
Evan Cheng5adb66a2009-09-28 09:14:39 +00001369// AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1370let isReMaterializable = 1, isAsCheapAsAMove = 1, AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001371def t2MOVi : T2sI<(outs rGPR:$dst), (ins t2_so_imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001372 "mov", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001373 [(set rGPR:$dst, t2_so_imm:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001374 let Inst{31-27} = 0b11110;
1375 let Inst{25} = 0;
1376 let Inst{24-21} = 0b0010;
1377 let Inst{20} = ?; // The S bit.
1378 let Inst{19-16} = 0b1111; // Rn
1379 let Inst{15} = 0;
1380}
David Goodwin83b35932009-06-26 16:10:07 +00001381
1382let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001383def t2MOVi16 : T2I<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001384 "movw", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001385 [(set rGPR:$dst, imm0_65535:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001386 let Inst{31-27} = 0b11110;
1387 let Inst{25} = 1;
1388 let Inst{24-21} = 0b0010;
1389 let Inst{20} = 0; // The S bit.
1390 let Inst{15} = 0;
1391}
Evan Chengf49810c2009-06-23 17:48:47 +00001392
Evan Cheng3850a6a2009-06-23 05:23:49 +00001393let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001394def t2MOVTi16 : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$imm), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001395 "movt", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001396 [(set rGPR:$dst,
1397 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001398 let Inst{31-27} = 0b11110;
1399 let Inst{25} = 1;
1400 let Inst{24-21} = 0b0110;
1401 let Inst{20} = 0; // The S bit.
1402 let Inst{15} = 0;
1403}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001404
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001405def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
Evan Cheng20956592009-10-21 08:15:52 +00001406
Anton Korobeynikov52237112009-06-17 18:13:58 +00001407//===----------------------------------------------------------------------===//
Evan Chengd27c9fc2009-07-03 01:43:10 +00001408// Extend Instructions.
1409//
1410
1411// Sign extenders
1412
Evan Cheng0e55fd62010-09-30 01:08:25 +00001413defm t2SXTB : T2I_ext_rrot<0b100, "sxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001414 UnOpFrag<(sext_inreg node:$Src, i8)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001415defm t2SXTH : T2I_ext_rrot<0b000, "sxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001416 UnOpFrag<(sext_inreg node:$Src, i16)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001417defm t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001418
Evan Cheng0e55fd62010-09-30 01:08:25 +00001419defm t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001420 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001421defm t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001422 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001423defm t2SXTAB16 : T2I_exta_rrot_DO<0b010, "sxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001424
Johnny Chen93042d12010-03-02 18:14:57 +00001425// TODO: SXT(A){B|H}16 - done for disassembly only
Evan Chengd27c9fc2009-07-03 01:43:10 +00001426
1427// Zero extenders
1428
1429let AddedComplexity = 16 in {
Evan Cheng0e55fd62010-09-30 01:08:25 +00001430defm t2UXTB : T2I_ext_rrot<0b101, "uxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001431 UnOpFrag<(and node:$Src, 0x000000FF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001432defm t2UXTH : T2I_ext_rrot<0b001, "uxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001433 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001434defm t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
Johnny Chend68e1192009-12-15 17:24:14 +00001435 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001436
Jim Grosbach79464942010-07-28 23:17:45 +00001437// FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1438// The transformation should probably be done as a combiner action
1439// instead so we can include a check for masking back in the upper
1440// eight bits of the source into the lower eight bits of the result.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001441//def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001442// (t2UXTB16r_rot rGPR:$Src, 24)>,
1443// Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001444def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001445 (t2UXTB16r_rot rGPR:$Src, 8)>,
1446 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001447
Evan Cheng0e55fd62010-09-30 01:08:25 +00001448defm t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001449 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001450defm t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001451 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001452defm t2UXTAB16 : T2I_exta_rrot_DO<0b011, "uxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001453}
1454
1455//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001456// Arithmetic Instructions.
1457//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001458
Johnny Chend68e1192009-12-15 17:24:14 +00001459defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1460 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1461defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1462 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001463
Evan Chengf49810c2009-06-23 17:48:47 +00001464// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
Johnny Chend68e1192009-12-15 17:24:14 +00001465defm t2ADDS : T2I_bin_s_irs <0b1000, "add",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001466 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001467 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1468defm t2SUBS : T2I_bin_s_irs <0b1101, "sub",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001469 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001470 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001471
Johnny Chend68e1192009-12-15 17:24:14 +00001472defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001473 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00001474defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001475 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001476defm t2ADCS : T2I_adde_sube_s_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001477 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001478defm t2SBCS : T2I_adde_sube_s_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001479 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001480
David Goodwin752aa7d2009-07-27 16:39:05 +00001481// RSB
Bob Wilson20d8e4e2010-08-13 23:24:25 +00001482defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
Johnny Chend68e1192009-12-15 17:24:14 +00001483 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1484defm t2RSBS : T2I_rbin_s_is <0b1110, "rsb",
1485 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001486
1487// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001488// The assume-no-carry-in form uses the negation of the input since add/sub
1489// assume opposite meanings of the carry flag (i.e., carry == !borrow).
1490// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1491// details.
1492// The AddedComplexity preferences the first variant over the others since
1493// it can be shrunk to a 16-bit wide encoding, while the others cannot.
Evan Chengfa2ea1a2009-08-04 01:41:15 +00001494let AddedComplexity = 1 in
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001495def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1496 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1497def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1498 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1499def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1500 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1501let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001502def : T2Pat<(addc rGPR:$src, imm0_255_neg:$imm),
1503 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1504def : T2Pat<(addc rGPR:$src, t2_so_imm_neg:$imm),
1505 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001506// The with-carry-in form matches bitwise not instead of the negation.
1507// Effectively, the inverse interpretation of the carry flag already accounts
1508// for part of the negation.
1509let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001510def : T2Pat<(adde rGPR:$src, imm0_255_not:$imm),
1511 (t2SBCSri rGPR:$src, imm0_255_not:$imm)>;
1512def : T2Pat<(adde rGPR:$src, t2_so_imm_not:$imm),
1513 (t2SBCSri rGPR:$src, t2_so_imm_not:$imm)>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001514
Johnny Chen93042d12010-03-02 18:14:57 +00001515// Select Bytes -- for disassembly only
1516
1517def t2SEL : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), NoItinerary, "sel",
1518 "\t$dst, $a, $b", []> {
1519 let Inst{31-27} = 0b11111;
1520 let Inst{26-24} = 0b010;
1521 let Inst{23} = 0b1;
1522 let Inst{22-20} = 0b010;
1523 let Inst{15-12} = 0b1111;
1524 let Inst{7} = 0b1;
1525 let Inst{6-4} = 0b000;
1526}
1527
Johnny Chenadc77332010-02-26 22:04:29 +00001528// A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1529// And Miscellaneous operations -- for disassembly only
Nate Begeman692433b2010-07-29 17:56:55 +00001530class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
1531 list<dag> pat = [/* For disassembly only; pattern left blank */]>
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001532 : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), NoItinerary, opc,
Nate Begeman692433b2010-07-29 17:56:55 +00001533 "\t$dst, $a, $b", pat> {
Johnny Chenadc77332010-02-26 22:04:29 +00001534 let Inst{31-27} = 0b11111;
1535 let Inst{26-23} = 0b0101;
1536 let Inst{22-20} = op22_20;
1537 let Inst{15-12} = 0b1111;
1538 let Inst{7-4} = op7_4;
1539}
1540
1541// Saturating add/subtract -- for disassembly only
1542
Nate Begeman692433b2010-07-29 17:56:55 +00001543def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001544 [(set rGPR:$dst, (int_arm_qadd rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001545def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
1546def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
1547def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
1548def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd">;
1549def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub">;
1550def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
Nate Begeman692433b2010-07-29 17:56:55 +00001551def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001552 [(set rGPR:$dst, (int_arm_qsub rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001553def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
1554def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
1555def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
1556def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
1557def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
1558def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
1559def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
1560def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
1561
1562// Signed/Unsigned add/subtract -- for disassembly only
1563
1564def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
1565def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
1566def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
1567def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
1568def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
1569def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
1570def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
1571def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
1572def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
1573def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
1574def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
1575def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
1576
1577// Signed/Unsigned halving add/subtract -- for disassembly only
1578
1579def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
1580def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
1581def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
1582def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
1583def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
1584def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
1585def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
1586def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
1587def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
1588def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
1589def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
1590def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
1591
1592// Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
1593
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001594def t2USAD8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1595 (ins rGPR:$a, rGPR:$b),
Johnny Chenadc77332010-02-26 22:04:29 +00001596 NoItinerary, "usad8", "\t$dst, $a, $b", []> {
1597 let Inst{15-12} = 0b1111;
1598}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001599def t2USADA8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1600 (ins rGPR:$a, rGPR:$b, rGPR:$acc), NoItinerary, "usada8",
Johnny Chenadc77332010-02-26 22:04:29 +00001601 "\t$dst, $a, $b, $acc", []>;
1602
1603// Signed/Unsigned saturate -- for disassembly only
1604
Bob Wilson22f5dc72010-08-16 18:27:34 +00001605def t2SSAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001606 NoItinerary, "ssat", "\t$dst, $bit_pos, $a$sh",
1607 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001608 let Inst{31-27} = 0b11110;
1609 let Inst{25-22} = 0b1100;
1610 let Inst{20} = 0;
1611 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001612}
1613
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001614def t2SSAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001615 "ssat16", "\t$dst, $bit_pos, $a",
1616 [/* For disassembly only; pattern left blank */]> {
1617 let Inst{31-27} = 0b11110;
1618 let Inst{25-22} = 0b1100;
1619 let Inst{20} = 0;
1620 let Inst{15} = 0;
1621 let Inst{21} = 1; // sh = '1'
1622 let Inst{14-12} = 0b000; // imm3 = '000'
1623 let Inst{7-6} = 0b00; // imm2 = '00'
1624}
1625
Bob Wilson22f5dc72010-08-16 18:27:34 +00001626def t2USAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001627 NoItinerary, "usat", "\t$dst, $bit_pos, $a$sh",
1628 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001629 let Inst{31-27} = 0b11110;
1630 let Inst{25-22} = 0b1110;
1631 let Inst{20} = 0;
1632 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001633}
1634
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001635def t2USAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001636 "usat16", "\t$dst, $bit_pos, $a",
1637 [/* For disassembly only; pattern left blank */]> {
1638 let Inst{31-27} = 0b11110;
1639 let Inst{25-22} = 0b1110;
1640 let Inst{20} = 0;
1641 let Inst{15} = 0;
1642 let Inst{21} = 1; // sh = '1'
1643 let Inst{14-12} = 0b000; // imm3 = '000'
1644 let Inst{7-6} = 0b00; // imm2 = '00'
1645}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001646
Bob Wilson38aa2872010-08-13 21:48:10 +00001647def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
1648def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
Nate Begeman0e0a20e2010-07-29 22:48:09 +00001649
Evan Chengf49810c2009-06-23 17:48:47 +00001650//===----------------------------------------------------------------------===//
Evan Chenga67efd12009-06-23 19:39:13 +00001651// Shift and rotate Instructions.
1652//
1653
Johnny Chend68e1192009-12-15 17:24:14 +00001654defm t2LSL : T2I_sh_ir<0b00, "lsl", BinOpFrag<(shl node:$LHS, node:$RHS)>>;
1655defm t2LSR : T2I_sh_ir<0b01, "lsr", BinOpFrag<(srl node:$LHS, node:$RHS)>>;
1656defm t2ASR : T2I_sh_ir<0b10, "asr", BinOpFrag<(sra node:$LHS, node:$RHS)>>;
1657defm t2ROR : T2I_sh_ir<0b11, "ror", BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
Evan Chenga67efd12009-06-23 19:39:13 +00001658
David Goodwinca01a8d2009-09-01 18:32:09 +00001659let Uses = [CPSR] in {
Jim Grosbach792e9792010-10-14 20:43:44 +00001660def t2RRX : T2sI<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +00001661 "rrx", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001662 [(set rGPR:$dst, (ARMrrx rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001663 let Inst{31-27} = 0b11101;
1664 let Inst{26-25} = 0b01;
1665 let Inst{24-21} = 0b0010;
1666 let Inst{20} = ?; // The S bit.
1667 let Inst{19-16} = 0b1111; // Rn
1668 let Inst{14-12} = 0b000;
1669 let Inst{7-4} = 0b0011;
1670}
David Goodwinca01a8d2009-09-01 18:32:09 +00001671}
Evan Chenga67efd12009-06-23 19:39:13 +00001672
David Goodwin3583df72009-07-28 17:06:49 +00001673let Defs = [CPSR] in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001674def t2MOVsrl_flag : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Bob Wilsona85df802010-05-25 04:51:47 +00001675 "lsrs", ".w\t$dst, $src, #1",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001676 [(set rGPR:$dst, (ARMsrl_flag rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001677 let Inst{31-27} = 0b11101;
1678 let Inst{26-25} = 0b01;
1679 let Inst{24-21} = 0b0010;
1680 let Inst{20} = 1; // The S bit.
1681 let Inst{19-16} = 0b1111; // Rn
1682 let Inst{5-4} = 0b01; // Shift type.
1683 // Shift amount = Inst{14-12:7-6} = 1.
1684 let Inst{14-12} = 0b000;
1685 let Inst{7-6} = 0b01;
1686}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001687def t2MOVsra_flag : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Bob Wilsona85df802010-05-25 04:51:47 +00001688 "asrs", ".w\t$dst, $src, #1",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001689 [(set rGPR:$dst, (ARMsra_flag rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001690 let Inst{31-27} = 0b11101;
1691 let Inst{26-25} = 0b01;
1692 let Inst{24-21} = 0b0010;
1693 let Inst{20} = 1; // The S bit.
1694 let Inst{19-16} = 0b1111; // Rn
1695 let Inst{5-4} = 0b10; // Shift type.
1696 // Shift amount = Inst{14-12:7-6} = 1.
1697 let Inst{14-12} = 0b000;
1698 let Inst{7-6} = 0b01;
1699}
David Goodwin3583df72009-07-28 17:06:49 +00001700}
1701
Evan Chenga67efd12009-06-23 19:39:13 +00001702//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +00001703// Bitwise Instructions.
1704//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001705
Johnny Chend68e1192009-12-15 17:24:14 +00001706defm t2AND : T2I_bin_w_irs<0b0000, "and",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001707 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001708 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1709defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001710 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001711 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1712defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001713 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001714 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Evan Chengf49810c2009-06-23 17:48:47 +00001715
Johnny Chend68e1192009-12-15 17:24:14 +00001716defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001717 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001718 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001719
Evan Chengf49810c2009-06-23 17:48:47 +00001720let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001721def t2BFC : T2I<(outs rGPR:$dst), (ins rGPR:$src, bf_inv_mask_imm:$imm),
David Goodwin2f54a2f2009-11-02 17:28:36 +00001722 IIC_iUNAsi, "bfc", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001723 [(set rGPR:$dst, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001724 let Inst{31-27} = 0b11110;
1725 let Inst{25} = 1;
1726 let Inst{24-20} = 0b10110;
1727 let Inst{19-16} = 0b1111; // Rn
1728 let Inst{15} = 0;
1729}
Evan Chengf49810c2009-06-23 17:48:47 +00001730
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001731def t2SBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001732 IIC_iUNAsi, "sbfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001733 let Inst{31-27} = 0b11110;
1734 let Inst{25} = 1;
1735 let Inst{24-20} = 0b10100;
1736 let Inst{15} = 0;
1737}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00001738
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001739def t2UBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001740 IIC_iUNAsi, "ubfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001741 let Inst{31-27} = 0b11110;
1742 let Inst{25} = 1;
1743 let Inst{24-20} = 0b11100;
1744 let Inst{15} = 0;
1745}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00001746
Johnny Chen9474d552010-02-02 19:31:58 +00001747// A8.6.18 BFI - Bitfield insert (Encoding T1)
Jim Grosbach469bbdb2010-07-16 23:05:05 +00001748let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001749def t2BFI : T2I<(outs rGPR:$dst),
1750 (ins rGPR:$src, rGPR:$val, bf_inv_mask_imm:$imm),
Evan Cheng7e1bf302010-09-29 00:27:46 +00001751 IIC_iBITi, "bfi", "\t$dst, $val, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001752 [(set rGPR:$dst, (ARMbfi rGPR:$src, rGPR:$val,
Jim Grosbach469bbdb2010-07-16 23:05:05 +00001753 bf_inv_mask_imm:$imm))]> {
Johnny Chen9474d552010-02-02 19:31:58 +00001754 let Inst{31-27} = 0b11110;
1755 let Inst{25} = 1;
1756 let Inst{24-20} = 0b10110;
1757 let Inst{15} = 0;
1758}
Evan Chengf49810c2009-06-23 17:48:47 +00001759
Evan Cheng7e1bf302010-09-29 00:27:46 +00001760defm t2ORN : T2I_bin_irs<0b0011, "orn",
1761 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
1762 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001763
1764// Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
1765let AddedComplexity = 1 in
Evan Cheng5d42c562010-09-29 00:49:25 +00001766defm t2MVN : T2I_un_irs <0b0011, "mvn",
Evan Cheng3881cb72010-09-29 22:42:35 +00001767 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
Evan Cheng5d42c562010-09-29 00:49:25 +00001768 UnOpFrag<(not node:$Src)>, 1, 1>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001769
1770
Jim Grosbachf084a5e2010-07-20 16:07:04 +00001771let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001772def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
1773 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001774
Evan Cheng25f7cfc2009-08-01 06:13:52 +00001775// FIXME: Disable this pattern on Darwin to workaround an assembler bug.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001776def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
1777 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
Evan Chengea253b92009-08-12 01:56:42 +00001778 Requires<[IsThumb2]>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001779
1780def : T2Pat<(t2_so_imm_not:$src),
1781 (t2MVNi t2_so_imm_not:$src)>;
1782
Evan Chengf49810c2009-06-23 17:48:47 +00001783//===----------------------------------------------------------------------===//
1784// Multiply Instructions.
1785//
Evan Cheng8de898a2009-06-26 00:19:44 +00001786let isCommutable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001787def t2MUL: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001788 "mul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001789 [(set rGPR:$dst, (mul rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001790 let Inst{31-27} = 0b11111;
1791 let Inst{26-23} = 0b0110;
1792 let Inst{22-20} = 0b000;
1793 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1794 let Inst{7-4} = 0b0000; // Multiply
1795}
Evan Chengf49810c2009-06-23 17:48:47 +00001796
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001797def t2MLA: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00001798 "mla", "\t$dst, $a, $b, $c",
1799 [(set rGPR:$dst, (add (mul rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001800 let Inst{31-27} = 0b11111;
1801 let Inst{26-23} = 0b0110;
1802 let Inst{22-20} = 0b000;
1803 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1804 let Inst{7-4} = 0b0000; // Multiply
1805}
Evan Chengf49810c2009-06-23 17:48:47 +00001806
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001807def t2MLS: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00001808 "mls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001809 [(set rGPR:$dst, (sub rGPR:$c, (mul rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001810 let Inst{31-27} = 0b11111;
1811 let Inst{26-23} = 0b0110;
1812 let Inst{22-20} = 0b000;
1813 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1814 let Inst{7-4} = 0b0001; // Multiply and Subtract
1815}
Evan Chengf49810c2009-06-23 17:48:47 +00001816
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001817// Extra precision multiplies with low / high results
1818let neverHasSideEffects = 1 in {
1819let isCommutable = 1 in {
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001820def t2SMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1821 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00001822 "smull", "\t$ldst, $hdst, $a, $b", []> {
1823 let Inst{31-27} = 0b11111;
1824 let Inst{26-23} = 0b0111;
1825 let Inst{22-20} = 0b000;
1826 let Inst{7-4} = 0b0000;
1827}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001828
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001829def t2UMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1830 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00001831 "umull", "\t$ldst, $hdst, $a, $b", []> {
1832 let Inst{31-27} = 0b11111;
1833 let Inst{26-23} = 0b0111;
1834 let Inst{22-20} = 0b010;
1835 let Inst{7-4} = 0b0000;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001836}
Johnny Chend68e1192009-12-15 17:24:14 +00001837} // isCommutable
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001838
1839// Multiply + accumulate
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001840def t2SMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1841 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001842 "smlal", "\t$ldst, $hdst, $a, $b", []>{
1843 let Inst{31-27} = 0b11111;
1844 let Inst{26-23} = 0b0111;
1845 let Inst{22-20} = 0b100;
1846 let Inst{7-4} = 0b0000;
1847}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001848
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001849def t2UMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1850 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001851 "umlal", "\t$ldst, $hdst, $a, $b", []>{
1852 let Inst{31-27} = 0b11111;
1853 let Inst{26-23} = 0b0111;
1854 let Inst{22-20} = 0b110;
1855 let Inst{7-4} = 0b0000;
1856}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001857
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001858def t2UMAAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1859 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001860 "umaal", "\t$ldst, $hdst, $a, $b", []>{
1861 let Inst{31-27} = 0b11111;
1862 let Inst{26-23} = 0b0111;
1863 let Inst{22-20} = 0b110;
1864 let Inst{7-4} = 0b0110;
1865}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001866} // neverHasSideEffects
1867
Johnny Chen93042d12010-03-02 18:14:57 +00001868// Rounding variants of the below included for disassembly only
1869
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001870// Most significant word multiply
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001871def t2SMMUL : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001872 "smmul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001873 [(set rGPR:$dst, (mulhs rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001874 let Inst{31-27} = 0b11111;
1875 let Inst{26-23} = 0b0110;
1876 let Inst{22-20} = 0b101;
1877 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1878 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1879}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001880
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001881def t2SMMULR : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Johnny Chen93042d12010-03-02 18:14:57 +00001882 "smmulr", "\t$dst, $a, $b", []> {
1883 let Inst{31-27} = 0b11111;
1884 let Inst{26-23} = 0b0110;
1885 let Inst{22-20} = 0b101;
1886 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1887 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1888}
1889
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001890def t2SMMLA : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001891 "smmla", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001892 [(set rGPR:$dst, (add (mulhs rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001893 let Inst{31-27} = 0b11111;
1894 let Inst{26-23} = 0b0110;
1895 let Inst{22-20} = 0b101;
1896 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1897 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1898}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001899
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001900def t2SMMLAR: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00001901 "smmlar", "\t$dst, $a, $b, $c", []> {
1902 let Inst{31-27} = 0b11111;
1903 let Inst{26-23} = 0b0110;
1904 let Inst{22-20} = 0b101;
1905 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1906 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1907}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001908
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001909def t2SMMLS: T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001910 "smmls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001911 [(set rGPR:$dst, (sub rGPR:$c, (mulhs rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001912 let Inst{31-27} = 0b11111;
1913 let Inst{26-23} = 0b0110;
1914 let Inst{22-20} = 0b110;
1915 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1916 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1917}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001918
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001919def t2SMMLSR:T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00001920 "smmlsr", "\t$dst, $a, $b, $c", []> {
1921 let Inst{31-27} = 0b11111;
1922 let Inst{26-23} = 0b0110;
1923 let Inst{22-20} = 0b110;
1924 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1925 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1926}
1927
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001928multiclass T2I_smul<string opc, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +00001929 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001930 !strconcat(opc, "bb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001931 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
1932 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001933 let Inst{31-27} = 0b11111;
1934 let Inst{26-23} = 0b0110;
1935 let Inst{22-20} = 0b001;
1936 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1937 let Inst{7-6} = 0b00;
1938 let Inst{5-4} = 0b00;
1939 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001940
Evan Cheng0e55fd62010-09-30 01:08:25 +00001941 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001942 !strconcat(opc, "bt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001943 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
1944 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001945 let Inst{31-27} = 0b11111;
1946 let Inst{26-23} = 0b0110;
1947 let Inst{22-20} = 0b001;
1948 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1949 let Inst{7-6} = 0b00;
1950 let Inst{5-4} = 0b01;
1951 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001952
Evan Cheng0e55fd62010-09-30 01:08:25 +00001953 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001954 !strconcat(opc, "tb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001955 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
1956 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001957 let Inst{31-27} = 0b11111;
1958 let Inst{26-23} = 0b0110;
1959 let Inst{22-20} = 0b001;
1960 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1961 let Inst{7-6} = 0b00;
1962 let Inst{5-4} = 0b10;
1963 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001964
Evan Cheng0e55fd62010-09-30 01:08:25 +00001965 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001966 !strconcat(opc, "tt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001967 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
1968 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001969 let Inst{31-27} = 0b11111;
1970 let Inst{26-23} = 0b0110;
1971 let Inst{22-20} = 0b001;
1972 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1973 let Inst{7-6} = 0b00;
1974 let Inst{5-4} = 0b11;
1975 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001976
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001977 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001978 !strconcat(opc, "wb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001979 [(set rGPR:$dst, (sra (opnode rGPR:$a,
1980 (sext_inreg rGPR:$b, i16)), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001981 let Inst{31-27} = 0b11111;
1982 let Inst{26-23} = 0b0110;
1983 let Inst{22-20} = 0b011;
1984 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1985 let Inst{7-6} = 0b00;
1986 let Inst{5-4} = 0b00;
1987 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001988
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001989 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001990 !strconcat(opc, "wt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001991 [(set rGPR:$dst, (sra (opnode rGPR:$a,
1992 (sra rGPR:$b, (i32 16))), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001993 let Inst{31-27} = 0b11111;
1994 let Inst{26-23} = 0b0110;
1995 let Inst{22-20} = 0b011;
1996 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1997 let Inst{7-6} = 0b00;
1998 let Inst{5-4} = 0b01;
1999 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002000}
2001
2002
2003multiclass T2I_smla<string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002004 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002005 !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002006 [(set rGPR:$dst, (add rGPR:$acc,
2007 (opnode (sext_inreg rGPR:$a, i16),
2008 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002009 let Inst{31-27} = 0b11111;
2010 let Inst{26-23} = 0b0110;
2011 let Inst{22-20} = 0b001;
2012 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2013 let Inst{7-6} = 0b00;
2014 let Inst{5-4} = 0b00;
2015 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002016
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002017 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002018 !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002019 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sext_inreg rGPR:$a, i16),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002020 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002021 let Inst{31-27} = 0b11111;
2022 let Inst{26-23} = 0b0110;
2023 let Inst{22-20} = 0b001;
2024 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2025 let Inst{7-6} = 0b00;
2026 let Inst{5-4} = 0b01;
2027 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002028
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002029 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002030 !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002031 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002032 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002033 let Inst{31-27} = 0b11111;
2034 let Inst{26-23} = 0b0110;
2035 let Inst{22-20} = 0b001;
2036 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2037 let Inst{7-6} = 0b00;
2038 let Inst{5-4} = 0b10;
2039 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002040
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002041 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002042 !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002043 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002044 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002045 let Inst{31-27} = 0b11111;
2046 let Inst{26-23} = 0b0110;
2047 let Inst{22-20} = 0b001;
2048 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2049 let Inst{7-6} = 0b00;
2050 let Inst{5-4} = 0b11;
2051 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002052
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002053 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002054 !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002055 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002056 (sext_inreg rGPR:$b, i16)), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002057 let Inst{31-27} = 0b11111;
2058 let Inst{26-23} = 0b0110;
2059 let Inst{22-20} = 0b011;
2060 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2061 let Inst{7-6} = 0b00;
2062 let Inst{5-4} = 0b00;
2063 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002064
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002065 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002066 !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002067 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002068 (sra rGPR:$b, (i32 16))), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002069 let Inst{31-27} = 0b11111;
2070 let Inst{26-23} = 0b0110;
2071 let Inst{22-20} = 0b011;
2072 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2073 let Inst{7-6} = 0b00;
2074 let Inst{5-4} = 0b01;
2075 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002076}
2077
2078defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2079defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2080
Johnny Chenadc77332010-02-26 22:04:29 +00002081// Halfword multiple accumulate long: SMLAL<x><y> -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002082def t2SMLALBB : T2I_mac<1, 0b100, 0b1000, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002083 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002084 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002085def t2SMLALBT : T2I_mac<1, 0b100, 0b1001, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002086 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002087 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002088def t2SMLALTB : T2I_mac<1, 0b100, 0b1010, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002089 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002090 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002091def t2SMLALTT : T2I_mac<1, 0b100, 0b1011, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002092 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002093 [/* For disassembly only; pattern left blank */]>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002094
Johnny Chenadc77332010-02-26 22:04:29 +00002095// Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2096// These are for disassembly only.
2097
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002098def t2SMUAD: T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2099 IIC_iMAC32, "smuad", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002100 let Inst{15-12} = 0b1111;
2101}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002102def t2SMUADX:T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2103 IIC_iMAC32, "smuadx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002104 let Inst{15-12} = 0b1111;
2105}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002106def t2SMUSD: T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2107 IIC_iMAC32, "smusd", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002108 let Inst{15-12} = 0b1111;
2109}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002110def t2SMUSDX:T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2111 IIC_iMAC32, "smusdx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002112 let Inst{15-12} = 0b1111;
2113}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002114def t2SMLAD : T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst),
2115 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlad",
Johnny Chenadc77332010-02-26 22:04:29 +00002116 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002117def t2SMLADX : T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst),
2118 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smladx",
Johnny Chenadc77332010-02-26 22:04:29 +00002119 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002120def t2SMLSD : T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst),
2121 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsd",
Johnny Chenadc77332010-02-26 22:04:29 +00002122 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002123def t2SMLSDX : T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst),
2124 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsdx",
Johnny Chenadc77332010-02-26 22:04:29 +00002125 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002126def t2SMLALD : T2I_mac<1, 0b100, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2127 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlald",
Johnny Chenadc77332010-02-26 22:04:29 +00002128 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002129def t2SMLALDX : T2I_mac<1, 0b100, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2130 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002131 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002132def t2SMLSLD : T2I_mac<1, 0b101, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2133 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsld",
Johnny Chenadc77332010-02-26 22:04:29 +00002134 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002135def t2SMLSLDX : T2I_mac<1, 0b101, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2136 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002137 "\t$ldst, $hdst, $a, $b", []>;
Evan Chengf49810c2009-06-23 17:48:47 +00002138
2139//===----------------------------------------------------------------------===//
2140// Misc. Arithmetic Instructions.
2141//
2142
Jim Grosbach80dc1162010-02-16 21:23:02 +00002143class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2144 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00002145 : T2I<oops, iops, itin, opc, asm, pattern> {
2146 let Inst{31-27} = 0b11111;
2147 let Inst{26-22} = 0b01010;
2148 let Inst{21-20} = op1;
2149 let Inst{15-12} = 0b1111;
2150 let Inst{7-6} = 0b10;
2151 let Inst{5-4} = op2;
2152}
Evan Chengf49810c2009-06-23 17:48:47 +00002153
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002154def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
2155 "clz", "\t$dst, $src", [(set rGPR:$dst, (ctlz rGPR:$src))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002156
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002157def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Evan Chengf609bb82010-01-19 00:44:15 +00002158 "rbit", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002159 [(set rGPR:$dst, (ARMrbit rGPR:$src))]>;
Jim Grosbach3482c802010-01-18 19:58:49 +00002160
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002161def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002162 "rev", ".w\t$dst, $src", [(set rGPR:$dst, (bswap rGPR:$src))]>;
Johnny Chend68e1192009-12-15 17:24:14 +00002163
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002164def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002165 "rev16", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002166 [(set rGPR:$dst,
2167 (or (and (srl rGPR:$src, (i32 8)), 0xFF),
2168 (or (and (shl rGPR:$src, (i32 8)), 0xFF00),
2169 (or (and (srl rGPR:$src, (i32 8)), 0xFF0000),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002170 (and (shl rGPR:$src, (i32 8)), 0xFF000000)))))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002171
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002172def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002173 "revsh", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002174 [(set rGPR:$dst,
Evan Chengf49810c2009-06-23 17:48:47 +00002175 (sext_inreg
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002176 (or (srl (and rGPR:$src, 0xFF00), (i32 8)),
2177 (shl rGPR:$src, (i32 8))), i16))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002178
Bob Wilsonf955f292010-08-17 17:23:19 +00002179def t2PKHBT : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002180 IIC_iBITsi, "pkhbt", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002181 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF),
Bob Wilsonf955f292010-08-17 17:23:19 +00002182 (and (shl rGPR:$src2, lsl_amt:$sh),
Jim Grosbachb1dc3932010-05-05 20:44:35 +00002183 0xFFFF0000)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002184 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002185 let Inst{31-27} = 0b11101;
2186 let Inst{26-25} = 0b01;
2187 let Inst{24-20} = 0b01100;
2188 let Inst{5} = 0; // BT form
2189 let Inst{4} = 0;
2190}
Evan Cheng40289b02009-07-07 05:35:52 +00002191
2192// Alternate cases for PKHBT where identities eliminate some nodes.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002193def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2194 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002195 Requires<[HasT2ExtractPack, IsThumb2]>;
Bob Wilsonf955f292010-08-17 17:23:19 +00002196def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2197 (t2PKHBT rGPR:$src1, rGPR:$src2, (lsl_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002198 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Cheng40289b02009-07-07 05:35:52 +00002199
Bob Wilsondc66eda2010-08-16 22:26:55 +00002200// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2201// will match the pattern below.
Bob Wilsonf955f292010-08-17 17:23:19 +00002202def t2PKHTB : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002203 IIC_iBITsi, "pkhtb", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002204 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002205 (and (sra rGPR:$src2, asr_amt:$sh),
2206 0xFFFF)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002207 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002208 let Inst{31-27} = 0b11101;
2209 let Inst{26-25} = 0b01;
2210 let Inst{24-20} = 0b01100;
2211 let Inst{5} = 1; // TB form
2212 let Inst{4} = 0;
2213}
Evan Cheng40289b02009-07-07 05:35:52 +00002214
2215// Alternate cases for PKHTB where identities eliminate some nodes. Note that
2216// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilsondc66eda2010-08-16 22:26:55 +00002217def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
Bob Wilsonf955f292010-08-17 17:23:19 +00002218 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002219 Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002220def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002221 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2222 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm1_15:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002223 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002224
2225//===----------------------------------------------------------------------===//
2226// Comparison Instructions...
2227//
Johnny Chend68e1192009-12-15 17:24:14 +00002228defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002229 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002230 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2231defm t2CMPz : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002232 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002233 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002234
Dan Gohman4b7dff92010-08-26 15:50:25 +00002235//FIXME: Disable CMN, as CCodes are backwards from compare expectations
2236// Compare-to-zero still works out, just not the relationals
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002237//defm t2CMN : T2I_cmp_irs<0b1000, "cmn",
2238// BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002239defm t2CMNz : T2I_cmp_irs<0b1000, "cmn",
Evan Cheng5d42c562010-09-29 00:49:25 +00002240 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Dan Gohman4b7dff92010-08-26 15:50:25 +00002241 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2242
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002243//def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2244// (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002245
2246def : T2Pat<(ARMcmpZ GPR:$src, t2_so_imm_neg:$imm),
2247 (t2CMNzri GPR:$src, t2_so_imm_neg:$imm)>;
Evan Chengf49810c2009-06-23 17:48:47 +00002248
Johnny Chend68e1192009-12-15 17:24:14 +00002249defm t2TST : T2I_cmp_irs<0b0000, "tst",
Evan Cheng5d42c562010-09-29 00:49:25 +00002250 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002251 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>>;
2252defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
Evan Cheng5d42c562010-09-29 00:49:25 +00002253 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002254 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002255
Evan Chenge253c952009-07-07 20:39:03 +00002256// Conditional moves
2257// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach64171712010-02-16 21:07:46 +00002258// a two-value operand where a dag node expects two operands. :(
Evan Cheng875a6ac2010-11-12 22:42:47 +00002259let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002260def t2MOVCCr : T2I<(outs rGPR:$dst), (ins rGPR:$false, rGPR:$true), IIC_iCMOVr,
Evan Cheng699beba2009-10-27 00:08:59 +00002261 "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002262 [/*(set rGPR:$dst, (ARMcmov rGPR:$false, rGPR:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002263 RegConstraint<"$false = $dst"> {
2264 let Inst{31-27} = 0b11101;
2265 let Inst{26-25} = 0b01;
2266 let Inst{24-21} = 0b0010;
2267 let Inst{20} = 0; // The S bit.
2268 let Inst{19-16} = 0b1111; // Rn
2269 let Inst{14-12} = 0b000;
2270 let Inst{7-4} = 0b0000;
2271}
Evan Chenge253c952009-07-07 20:39:03 +00002272
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002273def t2MOVCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
Evan Cheng699beba2009-10-27 00:08:59 +00002274 IIC_iCMOVi, "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002275[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002276 RegConstraint<"$false = $dst"> {
2277 let Inst{31-27} = 0b11110;
2278 let Inst{25} = 0;
2279 let Inst{24-21} = 0b0010;
2280 let Inst{20} = 0; // The S bit.
2281 let Inst{19-16} = 0b1111; // Rn
2282 let Inst{15} = 0;
2283}
Evan Chengf49810c2009-06-23 17:48:47 +00002284
Jim Grosbacha4257162010-10-07 00:53:56 +00002285def t2MOVCCi16 : T2I<(outs rGPR:$dst), (ins rGPR:$false, i32imm:$src),
Evan Cheng875a6ac2010-11-12 22:42:47 +00002286 IIC_iCMOVi,
Jim Grosbacha4257162010-10-07 00:53:56 +00002287 "movw", "\t$dst, $src", []>,
2288 RegConstraint<"$false = $dst"> {
2289 let Inst{31-27} = 0b11110;
2290 let Inst{25} = 1;
2291 let Inst{24-21} = 0b0010;
2292 let Inst{20} = 0; // The S bit.
2293 let Inst{15} = 0;
2294}
2295
Evan Cheng875a6ac2010-11-12 22:42:47 +00002296def t2MVNCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
2297 IIC_iCMOVi, "mvn", ".w\t$dst, $true",
2298[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm_not:$true,
2299 imm:$cc, CCR:$ccr))*/]>,
2300 RegConstraint<"$false = $dst"> {
2301 let Inst{31-27} = 0b11110;
2302 let Inst{25} = 0;
2303 let Inst{24-21} = 0b0011;
2304 let Inst{20} = 0; // The S bit.
2305 let Inst{19-16} = 0b1111; // Rn
2306 let Inst{15} = 0;
2307}
2308
Johnny Chend68e1192009-12-15 17:24:14 +00002309class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
2310 string opc, string asm, list<dag> pattern>
2311 : T2I<oops, iops, itin, opc, asm, pattern> {
2312 let Inst{31-27} = 0b11101;
2313 let Inst{26-25} = 0b01;
2314 let Inst{24-21} = 0b0010;
2315 let Inst{20} = 0; // The S bit.
2316 let Inst{19-16} = 0b1111; // Rn
2317 let Inst{5-4} = opcod; // Shift type.
2318}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002319def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$dst),
2320 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002321 IIC_iCMOVsi, "lsl", ".w\t$dst, $true, $rhs", []>,
2322 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002323def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$dst),
2324 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002325 IIC_iCMOVsi, "lsr", ".w\t$dst, $true, $rhs", []>,
2326 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002327def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$dst),
2328 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002329 IIC_iCMOVsi, "asr", ".w\t$dst, $true, $rhs", []>,
2330 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002331def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$dst),
2332 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002333 IIC_iCMOVsi, "ror", ".w\t$dst, $true, $rhs", []>,
2334 RegConstraint<"$false = $dst">;
Owen Andersonf523e472010-09-23 23:45:25 +00002335} // neverHasSideEffects
Evan Cheng13f8b362009-08-01 01:43:45 +00002336
David Goodwin5e47a9a2009-06-30 18:04:13 +00002337//===----------------------------------------------------------------------===//
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002338// Atomic operations intrinsics
2339//
2340
2341// memory barriers protect the atomic sequences
2342let hasSideEffects = 1 in {
Bob Wilsonf74a4292010-10-30 00:54:37 +00002343def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2344 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
2345 Requires<[IsThumb, HasDB]> {
2346 bits<4> opt;
2347 let Inst{31-4} = 0xf3bf8f5;
2348 let Inst{3-0} = opt;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002349}
2350}
2351
Bob Wilsonf74a4292010-10-30 00:54:37 +00002352def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2353 "dsb", "\t$opt",
2354 [/* For disassembly only; pattern left blank */]>,
2355 Requires<[IsThumb, HasDB]> {
2356 bits<4> opt;
2357 let Inst{31-4} = 0xf3bf8f4;
2358 let Inst{3-0} = opt;
Johnny Chena4339822010-03-03 00:16:28 +00002359}
2360
Johnny Chena4339822010-03-03 00:16:28 +00002361// ISB has only full system option -- for disassembly only
Bob Wilsonf74a4292010-10-30 00:54:37 +00002362def t2ISB : T2I<(outs), (ins), NoItinerary, "isb", "",
2363 [/* For disassembly only; pattern left blank */]>,
2364 Requires<[IsThumb2, HasV7]> {
2365 let Inst{31-4} = 0xf3bf8f6;
Johnny Chena4339822010-03-03 00:16:28 +00002366 let Inst{3-0} = 0b1111;
2367}
2368
Johnny Chend68e1192009-12-15 17:24:14 +00002369class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2370 InstrItinClass itin, string opc, string asm, string cstr,
2371 list<dag> pattern, bits<4> rt2 = 0b1111>
2372 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2373 let Inst{31-27} = 0b11101;
2374 let Inst{26-20} = 0b0001101;
2375 let Inst{11-8} = rt2;
2376 let Inst{7-6} = 0b01;
2377 let Inst{5-4} = opcod;
2378 let Inst{3-0} = 0b1111;
2379}
2380class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2381 InstrItinClass itin, string opc, string asm, string cstr,
2382 list<dag> pattern, bits<4> rt2 = 0b1111>
2383 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2384 let Inst{31-27} = 0b11101;
2385 let Inst{26-20} = 0b0001100;
2386 let Inst{11-8} = rt2;
2387 let Inst{7-6} = 0b01;
2388 let Inst{5-4} = opcod;
2389}
2390
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002391let mayLoad = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002392def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002393 Size4Bytes, NoItinerary, "ldrexb", "\t$dest, [$ptr]",
2394 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002395def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002396 Size4Bytes, NoItinerary, "ldrexh", "\t$dest, [$ptr]",
2397 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002398def t2LDREX : Thumb2I<(outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002399 Size4Bytes, NoItinerary,
2400 "ldrex", "\t$dest, [$ptr]", "",
2401 []> {
2402 let Inst{31-27} = 0b11101;
2403 let Inst{26-20} = 0b0000101;
2404 let Inst{11-8} = 0b1111;
2405 let Inst{7-0} = 0b00000000; // imm8 = 0
2406}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002407def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$dest, rGPR:$dest2), (ins rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002408 AddrModeNone, Size4Bytes, NoItinerary,
2409 "ldrexd", "\t$dest, $dest2, [$ptr]", "",
2410 [], {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002411}
2412
Jim Grosbach587b0722009-12-16 19:44:06 +00002413let mayStore = 1, Constraints = "@earlyclobber $success" in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002414def t2STREXB : T2I_strex<0b00, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002415 AddrModeNone, Size4Bytes, NoItinerary,
2416 "strexb", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002417def t2STREXH : T2I_strex<0b01, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002418 AddrModeNone, Size4Bytes, NoItinerary,
2419 "strexh", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002420def t2STREX : Thumb2I<(outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002421 AddrModeNone, Size4Bytes, NoItinerary,
2422 "strex", "\t$success, $src, [$ptr]", "",
2423 []> {
2424 let Inst{31-27} = 0b11101;
2425 let Inst{26-20} = 0b0000100;
2426 let Inst{7-0} = 0b00000000; // imm8 = 0
2427}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002428def t2STREXD : T2I_strex<0b11, (outs rGPR:$success),
2429 (ins rGPR:$src, rGPR:$src2, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002430 AddrModeNone, Size4Bytes, NoItinerary,
2431 "strexd", "\t$success, $src, $src2, [$ptr]", "", [],
2432 {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002433}
2434
Johnny Chen10a77e12010-03-02 22:11:06 +00002435// Clear-Exclusive is for disassembly only.
2436def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "",
2437 [/* For disassembly only; pattern left blank */]>,
2438 Requires<[IsARM, HasV7]> {
2439 let Inst{31-20} = 0xf3b;
2440 let Inst{15-14} = 0b10;
2441 let Inst{12} = 0;
2442 let Inst{7-4} = 0b0010;
2443}
2444
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002445//===----------------------------------------------------------------------===//
David Goodwin334c2642009-07-08 16:09:28 +00002446// TLS Instructions
2447//
2448
2449// __aeabi_read_tp preserves the registers r1-r3.
2450let isCall = 1,
2451 Defs = [R0, R12, LR, CPSR] in {
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002452 def t2TPsoft : T2XI<(outs), (ins), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002453 "bl\t__aeabi_read_tp",
Johnny Chend68e1192009-12-15 17:24:14 +00002454 [(set R0, ARMthread_pointer)]> {
2455 let Inst{31-27} = 0b11110;
2456 let Inst{15-14} = 0b11;
2457 let Inst{12} = 1;
2458 }
David Goodwin334c2642009-07-08 16:09:28 +00002459}
2460
2461//===----------------------------------------------------------------------===//
Jim Grosbach5aa16842009-08-11 19:42:21 +00002462// SJLJ Exception handling intrinsics
Jim Grosbach1add6592009-08-13 15:11:43 +00002463// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach5aa16842009-08-11 19:42:21 +00002464// address and save #0 in R0 for the non-longjmp case.
2465// Since by its nature we may be coming from some other function to get
2466// here, and we're using the stack frame for the containing function to
2467// save/restore registers, we can't keep anything live in regs across
2468// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
2469// when we get here from a longjmp(). We force everthing out of registers
2470// except for our own input by listing the relevant registers in Defs. By
2471// doing so, we also cause the prologue/epilogue code to actively preserve
2472// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach0798edd2010-05-27 23:49:24 +00002473// $val is a scratch register for our use.
Jim Grosbacha87ded22010-02-08 23:22:00 +00002474let Defs =
Jim Grosbachf35d2162009-08-13 16:59:44 +00002475 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2476 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Jim Grosbach5aa16842009-08-11 19:42:21 +00002477 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002478 D31 ], hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002479 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002480 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002481 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002482 Requires<[IsThumb2, HasVFP2]>;
Jim Grosbach5aa16842009-08-11 19:42:21 +00002483}
2484
Bob Wilsonec80e262010-04-09 20:41:18 +00002485let Defs =
Jim Grosbach5caeff52010-05-28 17:37:40 +00002486 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ],
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002487 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002488 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002489 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002490 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002491 Requires<[IsThumb2, NoVFP]>;
2492}
Jim Grosbach5aa16842009-08-11 19:42:21 +00002493
2494
2495//===----------------------------------------------------------------------===//
David Goodwin5e47a9a2009-06-30 18:04:13 +00002496// Control-Flow Instructions
2497//
2498
Evan Chengc50a1cb2009-07-09 22:58:39 +00002499// FIXME: remove when we have a way to marking a MI with these properties.
2500// FIXME: $dst1 should be a def. But the extra ops must be in the end of the
2501// operand list.
2502// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng0d92f5f2009-10-01 08:22:27 +00002503let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
Chris Lattner39ee0362010-10-31 19:10:56 +00002504 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
Jim Grosbache6913602010-11-03 01:01:43 +00002505 def t2LDM_RET: T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
2506 reglist:$dsts, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00002507 IIC_iLoad_mBr,
Jim Grosbache6913602010-11-03 01:01:43 +00002508 "ldm${amode}${p}.w\t$Rn!, $dsts",
2509 "$Rn = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002510 let Inst{31-27} = 0b11101;
2511 let Inst{26-25} = 0b00;
2512 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
2513 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00002514 let Inst{21} = 1; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00002515 let Inst{20} = 1; // Load
2516}
Evan Chengc50a1cb2009-07-09 22:58:39 +00002517
David Goodwin5e47a9a2009-06-30 18:04:13 +00002518let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
2519let isPredicable = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002520def t2B : T2XI<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002521 "b.w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002522 [(br bb:$target)]> {
2523 let Inst{31-27} = 0b11110;
2524 let Inst{15-14} = 0b10;
2525 let Inst{12} = 1;
2526}
David Goodwin5e47a9a2009-06-30 18:04:13 +00002527
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002528let isNotDuplicable = 1, isIndirectBranch = 1,
2529 isCodeGenOnly = 1 in { // $id doesn't exist in asmstring, should be lowered.
Evan Cheng66ac5312009-07-25 00:33:29 +00002530def t2BR_JT :
Evan Cheng5657c012009-07-29 02:18:14 +00002531 T2JTI<(outs),
2532 (ins GPR:$target, GPR:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002533 IIC_Br, "mov\tpc, $target$jt",
Johnny Chend68e1192009-12-15 17:24:14 +00002534 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]> {
2535 let Inst{31-27} = 0b11101;
2536 let Inst{26-20} = 0b0100100;
2537 let Inst{19-16} = 0b1111;
2538 let Inst{14-12} = 0b000;
2539 let Inst{11-8} = 0b1111; // Rd = pc
2540 let Inst{7-4} = 0b0000;
2541}
Evan Cheng5657c012009-07-29 02:18:14 +00002542
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002543// FIXME: Add a non-pc based case that can be predicated.
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002544let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002545def t2TBB :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002546 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002547 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002548 IIC_Br, "tbb\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002549 let Inst{31-27} = 0b11101;
2550 let Inst{26-20} = 0b0001101;
2551 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2552 let Inst{15-8} = 0b11110000;
2553 let Inst{7-4} = 0b0000; // B form
2554}
Evan Cheng5657c012009-07-29 02:18:14 +00002555
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002556let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002557def t2TBH :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002558 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002559 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002560 IIC_Br, "tbh\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002561 let Inst{31-27} = 0b11101;
2562 let Inst{26-20} = 0b0001101;
2563 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2564 let Inst{15-8} = 0b11110000;
2565 let Inst{7-4} = 0b0001; // H form
2566}
Johnny Chen93042d12010-03-02 18:14:57 +00002567
2568// Generic versions of the above two instructions, for disassembly only
2569
2570def t2TBBgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2571 "tbb", "\t[$a, $b]", []>{
2572 let Inst{31-27} = 0b11101;
2573 let Inst{26-20} = 0b0001101;
2574 let Inst{15-8} = 0b11110000;
2575 let Inst{7-4} = 0b0000; // B form
2576}
2577
2578def t2TBHgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2579 "tbh", "\t[$a, $b, lsl #1]", []> {
2580 let Inst{31-27} = 0b11101;
2581 let Inst{26-20} = 0b0001101;
2582 let Inst{15-8} = 0b11110000;
2583 let Inst{7-4} = 0b0001; // H form
2584}
Evan Cheng5657c012009-07-29 02:18:14 +00002585} // isNotDuplicable, isIndirectBranch
2586
David Goodwinc9a59b52009-06-30 19:50:22 +00002587} // isBranch, isTerminator, isBarrier
David Goodwin5e47a9a2009-06-30 18:04:13 +00002588
2589// FIXME: should be able to write a pattern for ARMBrcond, but can't use
2590// a two-value operand where a dag node expects two operands. :(
2591let isBranch = 1, isTerminator = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002592def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002593 "b", ".w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002594 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
2595 let Inst{31-27} = 0b11110;
2596 let Inst{15-14} = 0b10;
2597 let Inst{12} = 0;
2598}
Evan Chengf49810c2009-06-23 17:48:47 +00002599
Evan Cheng06e16582009-07-10 01:54:42 +00002600
2601// IT block
Evan Cheng86050dc2010-06-18 23:09:54 +00002602let Defs = [ITSTATE] in
Evan Cheng06e16582009-07-10 01:54:42 +00002603def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
David Goodwin5d598aa2009-08-19 18:00:44 +00002604 AddrModeNone, Size2Bytes, IIC_iALUx,
Johnny Chend68e1192009-12-15 17:24:14 +00002605 "it$mask\t$cc", "", []> {
2606 // 16-bit instruction.
Johnny Chenbbc71b22009-12-16 02:32:54 +00002607 let Inst{31-16} = 0x0000;
Johnny Chend68e1192009-12-15 17:24:14 +00002608 let Inst{15-8} = 0b10111111;
2609}
Evan Cheng06e16582009-07-10 01:54:42 +00002610
Johnny Chence6275f2010-02-25 19:05:29 +00002611// Branch and Exchange Jazelle -- for disassembly only
2612// Rm = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002613def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func",
Johnny Chence6275f2010-02-25 19:05:29 +00002614 [/* For disassembly only; pattern left blank */]> {
2615 let Inst{31-27} = 0b11110;
2616 let Inst{26} = 0;
2617 let Inst{25-20} = 0b111100;
2618 let Inst{15-14} = 0b10;
2619 let Inst{12} = 0;
2620}
2621
Johnny Chen93042d12010-03-02 18:14:57 +00002622// Change Processor State is a system instruction -- for disassembly only.
2623// The singleton $opt operand contains the following information:
2624// opt{4-0} = mode from Inst{4-0}
2625// opt{5} = changemode from Inst{17}
2626// opt{8-6} = AIF from Inst{8-6}
2627// opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002628def t2CPS : T2XI<(outs),(ins cps_opt:$opt), NoItinerary, "cps$opt",
Johnny Chen93042d12010-03-02 18:14:57 +00002629 [/* For disassembly only; pattern left blank */]> {
2630 let Inst{31-27} = 0b11110;
2631 let Inst{26} = 0;
2632 let Inst{25-20} = 0b111010;
2633 let Inst{15-14} = 0b10;
2634 let Inst{12} = 0;
2635}
2636
Johnny Chen0f7866e2010-03-03 02:09:43 +00002637// A6.3.4 Branches and miscellaneous control
2638// Table A6-14 Change Processor State, and hint instructions
2639// Helper class for disassembly only.
2640class T2I_hint<bits<8> op7_0, string opc, string asm>
2641 : T2I<(outs), (ins), NoItinerary, opc, asm,
2642 [/* For disassembly only; pattern left blank */]> {
2643 let Inst{31-20} = 0xf3a;
2644 let Inst{15-14} = 0b10;
2645 let Inst{12} = 0;
2646 let Inst{10-8} = 0b000;
2647 let Inst{7-0} = op7_0;
2648}
2649
2650def t2NOP : T2I_hint<0b00000000, "nop", ".w">;
2651def t2YIELD : T2I_hint<0b00000001, "yield", ".w">;
2652def t2WFE : T2I_hint<0b00000010, "wfe", ".w">;
2653def t2WFI : T2I_hint<0b00000011, "wfi", ".w">;
2654def t2SEV : T2I_hint<0b00000100, "sev", ".w">;
2655
2656def t2DBG : T2I<(outs),(ins i32imm:$opt), NoItinerary, "dbg", "\t$opt",
2657 [/* For disassembly only; pattern left blank */]> {
2658 let Inst{31-20} = 0xf3a;
2659 let Inst{15-14} = 0b10;
2660 let Inst{12} = 0;
2661 let Inst{10-8} = 0b000;
2662 let Inst{7-4} = 0b1111;
2663}
2664
Johnny Chen6341c5a2010-02-25 20:25:24 +00002665// Secure Monitor Call is a system instruction -- for disassembly only
2666// Option = Inst{19-16}
2667def t2SMC : T2I<(outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
2668 [/* For disassembly only; pattern left blank */]> {
2669 let Inst{31-27} = 0b11110;
2670 let Inst{26-20} = 0b1111111;
2671 let Inst{15-12} = 0b1000;
2672}
2673
2674// Store Return State is a system instruction -- for disassembly only
2675def t2SRSDBW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp!, $mode",
2676 [/* For disassembly only; pattern left blank */]> {
2677 let Inst{31-27} = 0b11101;
2678 let Inst{26-20} = 0b0000010; // W = 1
2679}
2680
2681def t2SRSDB : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp, $mode",
2682 [/* For disassembly only; pattern left blank */]> {
2683 let Inst{31-27} = 0b11101;
2684 let Inst{26-20} = 0b0000000; // W = 0
2685}
2686
2687def t2SRSIAW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsia","\tsp!, $mode",
2688 [/* For disassembly only; pattern left blank */]> {
2689 let Inst{31-27} = 0b11101;
2690 let Inst{26-20} = 0b0011010; // W = 1
2691}
2692
2693def t2SRSIA : T2I<(outs), (ins i32imm:$mode),NoItinerary,"srsia","\tsp, $mode",
2694 [/* For disassembly only; pattern left blank */]> {
2695 let Inst{31-27} = 0b11101;
2696 let Inst{26-20} = 0b0011000; // W = 0
2697}
2698
2699// Return From Exception is a system instruction -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002700def t2RFEDBW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfedb", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002701 [/* For disassembly only; pattern left blank */]> {
2702 let Inst{31-27} = 0b11101;
2703 let Inst{26-20} = 0b0000011; // W = 1
2704}
2705
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002706def t2RFEDB : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeab", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002707 [/* For disassembly only; pattern left blank */]> {
2708 let Inst{31-27} = 0b11101;
2709 let Inst{26-20} = 0b0000001; // W = 0
2710}
2711
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002712def t2RFEIAW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002713 [/* For disassembly only; pattern left blank */]> {
2714 let Inst{31-27} = 0b11101;
2715 let Inst{26-20} = 0b0011011; // W = 1
2716}
2717
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002718def t2RFEIA : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002719 [/* For disassembly only; pattern left blank */]> {
2720 let Inst{31-27} = 0b11101;
2721 let Inst{26-20} = 0b0011001; // W = 0
2722}
2723
Evan Chengf49810c2009-06-23 17:48:47 +00002724//===----------------------------------------------------------------------===//
2725// Non-Instruction Patterns
2726//
2727
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002728// Two piece so_imms.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002729def : T2Pat<(or rGPR:$LHS, t2_so_imm2part:$RHS),
2730 (t2ORRri (t2ORRri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002731 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002732def : T2Pat<(xor rGPR:$LHS, t2_so_imm2part:$RHS),
2733 (t2EORri (t2EORri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002734 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002735def : T2Pat<(add rGPR:$LHS, t2_so_imm2part:$RHS),
2736 (t2ADDri (t2ADDri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002737 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002738def : T2Pat<(add rGPR:$LHS, t2_so_neg_imm2part:$RHS),
2739 (t2SUBri (t2SUBri rGPR:$LHS, (t2_so_neg_imm2part_1 imm:$RHS)),
Jim Grosbach15e6ef82009-11-23 20:35:53 +00002740 (t2_so_neg_imm2part_2 imm:$RHS))>;
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002741
Evan Cheng5adb66a2009-09-28 09:14:39 +00002742// 32-bit immediate using movw + movt.
Evan Cheng5be39222010-09-24 22:03:46 +00002743// This is a single pseudo instruction to make it re-materializable.
2744// FIXME: Remove this when we can do generalized remat.
Evan Cheng5adb66a2009-09-28 09:14:39 +00002745let isReMaterializable = 1 in
Jim Grosbach3c38f962010-10-06 22:01:26 +00002746def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
2747 "", [(set rGPR:$dst, (i32 imm:$src))]>,
2748 Requires<[IsThumb, HasV6T2]>;
Evan Chengb9803a82009-11-06 23:52:48 +00002749
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +00002750// ConstantPool, GlobalAddress, and JumpTable
2751def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
2752 Requires<[IsThumb2, DontUseMovt]>;
2753def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
2754def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
2755 Requires<[IsThumb2, UseMovt]>;
2756
2757def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
2758 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
2759
Evan Chengb9803a82009-11-06 23:52:48 +00002760// Pseudo instruction that combines ldr from constpool and add pc. This should
2761// be expanded into two instructions late to allow if-conversion and
2762// scheduling.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00002763let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Chengb9803a82009-11-06 23:52:48 +00002764def t2LDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp),
Jim Grosbach78890f42010-10-01 23:21:38 +00002765 IIC_iLoadiALU, "",
Evan Chengb9803a82009-11-06 23:52:48 +00002766 [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
2767 imm:$cp))]>,
2768 Requires<[IsThumb2]>;
Johnny Chen23336552010-02-25 18:46:43 +00002769
2770//===----------------------------------------------------------------------===//
2771// Move between special register and ARM core register -- for disassembly only
2772//
2773
2774// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002775def t2MRS : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, cpsr",
Johnny Chen23336552010-02-25 18:46:43 +00002776 [/* For disassembly only; pattern left blank */]> {
2777 let Inst{31-27} = 0b11110;
2778 let Inst{26} = 0;
2779 let Inst{25-21} = 0b11111;
2780 let Inst{20} = 0; // The R bit.
2781 let Inst{15-14} = 0b10;
2782 let Inst{12} = 0;
2783}
2784
2785// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002786def t2MRSsys : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, spsr",
Johnny Chen23336552010-02-25 18:46:43 +00002787 [/* For disassembly only; pattern left blank */]> {
2788 let Inst{31-27} = 0b11110;
2789 let Inst{26} = 0;
2790 let Inst{25-21} = 0b11111;
2791 let Inst{20} = 1; // The R bit.
2792 let Inst{15-14} = 0b10;
2793 let Inst{12} = 0;
2794}
2795
Johnny Chen23336552010-02-25 18:46:43 +00002796// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002797def t2MSR : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002798 "\tcpsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00002799 [/* For disassembly only; pattern left blank */]> {
2800 let Inst{31-27} = 0b11110;
2801 let Inst{26} = 0;
2802 let Inst{25-21} = 0b11100;
2803 let Inst{20} = 0; // The R bit.
2804 let Inst{15-14} = 0b10;
2805 let Inst{12} = 0;
2806}
2807
Johnny Chen23336552010-02-25 18:46:43 +00002808// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002809def t2MSRsys : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002810 "\tspsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00002811 [/* For disassembly only; pattern left blank */]> {
2812 let Inst{31-27} = 0b11110;
2813 let Inst{26} = 0;
2814 let Inst{25-21} = 0b11100;
2815 let Inst{20} = 1; // The R bit.
2816 let Inst{15-14} = 0b10;
2817 let Inst{12} = 0;
2818}