blob: 66f2259dbf39d55a6a474c8fede7a06f43532311 [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 Andersonb9a643e2010-11-12 23:36:03 +0000173class T2TwoRegShiftedImm<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 Andersonb9a643e2010-11-12 23:36:03 +0000265 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_imm:$rhs), iii,
266 opc, "\t$dst, $lhs, $rhs",
267 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_imm:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000268 let Inst{31-27} = 0b11110;
269 let Inst{25} = 0;
270 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000271 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000272 let Inst{15} = 0;
273 }
Evan Chenga67efd12009-06-23 19:39:13 +0000274 // register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000275 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs), iir,
276 opc, !strconcat(wide, "\t$dst, $lhs, $rhs"),
277 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000278 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000279 let Inst{31-27} = 0b11101;
280 let Inst{26-25} = 0b01;
281 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000282 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000283 let Inst{14-12} = 0b000; // imm3
284 let Inst{7-6} = 0b00; // imm2
285 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000286 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000287 // shifted register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000288 def rs : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_reg:$rhs), iis,
289 opc, !strconcat(wide, "\t$dst, $lhs, $rhs"),
290 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_reg:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000291 let Inst{31-27} = 0b11101;
292 let Inst{26-25} = 0b01;
293 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000294 let Inst{20} = ?; // The S bit.
295 }
296}
297
David Goodwin1f096272009-07-27 23:34:12 +0000298/// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
299// the ".w" prefix to indicate that they are wide.
Evan Cheng7e1bf302010-09-29 00:27:46 +0000300multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
301 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
302 PatFrag opnode, bit Commutable = 0> :
303 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w">;
Bill Wendling1f7bf0e2010-08-29 03:55:31 +0000304
Evan Cheng1e249e32009-06-25 20:59:23 +0000305/// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000306/// reversed. The 'rr' form is only defined for the disassembler; for codegen
307/// it is equivalent to the T2I_bin_irs counterpart.
308multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000309 // shifted imm
Owen Andersonb9a643e2010-11-12 23:36:03 +0000310 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_imm:$lhs), IIC_iALUi,
311 opc, ".w\t$dst, $rhs, $lhs",
312 [(set rGPR:$dst, (opnode t2_so_imm:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000313 let Inst{31-27} = 0b11110;
314 let Inst{25} = 0;
315 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000316 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000317 let Inst{15} = 0;
318 }
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000319 // register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000320 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, rGPR:$lhs), IIC_iALUr,
321 opc, "\t$dst, $rhs, $lhs",
Bob Wilson136e4912010-08-14 03:18:29 +0000322 [/* For disassembly only; pattern left blank */]> {
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000323 let Inst{31-27} = 0b11101;
324 let Inst{26-25} = 0b01;
325 let Inst{24-21} = opcod;
326 let Inst{20} = ?; // The S bit.
327 let Inst{14-12} = 0b000; // imm3
328 let Inst{7-6} = 0b00; // imm2
329 let Inst{5-4} = 0b00; // type
330 }
Evan Chengf49810c2009-06-23 17:48:47 +0000331 // shifted register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000332 def rs : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_reg:$lhs), IIC_iALUsir,
333 opc, "\t$dst, $rhs, $lhs",
334 [(set rGPR:$dst, (opnode t2_so_reg:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000335 let Inst{31-27} = 0b11101;
336 let Inst{26-25} = 0b01;
337 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000338 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000339 }
Evan Chengf49810c2009-06-23 17:48:47 +0000340}
341
Evan Chenga67efd12009-06-23 19:39:13 +0000342/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
Anton Korobeynikov52237112009-06-17 18:13:58 +0000343/// instruction modifies the CPSR register.
344let Defs = [CPSR] in {
Evan Cheng7e1bf302010-09-29 00:27:46 +0000345multiclass T2I_bin_s_irs<bits<4> opcod, string opc,
346 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
347 PatFrag opnode, bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000348 // shifted imm
Owen Andersonb9a643e2010-11-12 23:36:03 +0000349 def ri : T2I<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), iii,
350 !strconcat(opc, "s"), ".w\t$dst, $lhs, $rhs",
351 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000352 let Inst{31-27} = 0b11110;
353 let Inst{25} = 0;
354 let Inst{24-21} = opcod;
355 let Inst{20} = 1; // The S bit.
356 let Inst{15} = 0;
357 }
Evan Chenga67efd12009-06-23 19:39:13 +0000358 // register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000359 def rr : T2I<(outs rGPR:$dst), (ins GPR:$lhs, rGPR:$rhs), iir,
360 !strconcat(opc, "s"), ".w\t$dst, $lhs, $rhs",
361 [(set rGPR:$dst, (opnode GPR:$lhs, rGPR:$rhs))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000362 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000363 let Inst{31-27} = 0b11101;
364 let Inst{26-25} = 0b01;
365 let Inst{24-21} = opcod;
366 let Inst{20} = 1; // The S bit.
367 let Inst{14-12} = 0b000; // imm3
368 let Inst{7-6} = 0b00; // imm2
369 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000370 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000371 // shifted register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000372 def rs : T2I<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), iis,
373 !strconcat(opc, "s"), ".w\t$dst, $lhs, $rhs",
374 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000375 let Inst{31-27} = 0b11101;
376 let Inst{26-25} = 0b01;
377 let Inst{24-21} = opcod;
378 let Inst{20} = 1; // The S bit.
379 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000380}
381}
382
Evan Chenga67efd12009-06-23 19:39:13 +0000383/// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
384/// patterns for a binary operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000385multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
386 bit Commutable = 0> {
Evan Chengf49810c2009-06-23 17:48:47 +0000387 // shifted imm
Jim Grosbach663e3392010-08-30 19:49:58 +0000388 // The register-immediate version is re-materializable. This is useful
389 // in particular for taking the address of a local.
390 let isReMaterializable = 1 in {
Owen Andersonb9a643e2010-11-12 23:36:03 +0000391 def ri : T2sI<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi,
392 opc, ".w\t$dst, $lhs, $rhs",
393 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000394 let Inst{31-27} = 0b11110;
395 let Inst{25} = 0;
396 let Inst{24} = 1;
397 let Inst{23-21} = op23_21;
398 let Inst{20} = 0; // The S bit.
399 let Inst{15} = 0;
400 }
Jim Grosbach663e3392010-08-30 19:49:58 +0000401 }
Evan Chengf49810c2009-06-23 17:48:47 +0000402 // 12-bit imm
Owen Andersonb9a643e2010-11-12 23:36:03 +0000403 def ri12 : T2I<(outs rGPR:$dst), (ins GPR:$lhs, imm0_4095:$rhs), IIC_iALUi,
404 !strconcat(opc, "w"), "\t$dst, $lhs, $rhs",
405 [(set rGPR:$dst, (opnode GPR:$lhs, imm0_4095:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000406 let Inst{31-27} = 0b11110;
407 let Inst{25} = 1;
408 let Inst{24} = 0;
409 let Inst{23-21} = op23_21;
410 let Inst{20} = 0; // The S bit.
411 let Inst{15} = 0;
412 }
Evan Chenga67efd12009-06-23 19:39:13 +0000413 // register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000414 def rr : T2sI<(outs rGPR:$dst), (ins GPR:$lhs, rGPR:$rhs), IIC_iALUr,
415 opc, ".w\t$dst, $lhs, $rhs",
416 [(set rGPR:$dst, (opnode GPR:$lhs, rGPR:$rhs))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000417 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000418 let Inst{31-27} = 0b11101;
419 let Inst{26-25} = 0b01;
420 let Inst{24} = 1;
421 let Inst{23-21} = op23_21;
422 let Inst{20} = 0; // The S bit.
423 let Inst{14-12} = 0b000; // imm3
424 let Inst{7-6} = 0b00; // imm2
425 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000426 }
Evan Chengf49810c2009-06-23 17:48:47 +0000427 // shifted register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000428 def rs : T2sI<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi,
429 opc, ".w\t$dst, $lhs, $rhs",
430 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000431 let Inst{31-27} = 0b11101;
Johnny Chend68e1192009-12-15 17:24:14 +0000432 let Inst{26-25} = 0b01;
Johnny Chend248ffb2010-01-08 17:41:33 +0000433 let Inst{24} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000434 let Inst{23-21} = op23_21;
435 let Inst{20} = 0; // The S bit.
436 }
Evan Chengf49810c2009-06-23 17:48:47 +0000437}
438
Jim Grosbach6935efc2009-11-24 00:20:27 +0000439/// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000440/// for a binary operation that produces a value and use the carry
Jim Grosbach6935efc2009-11-24 00:20:27 +0000441/// bit. It's not predicable.
Evan Cheng62674222009-06-25 23:34:10 +0000442let Uses = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000443multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
444 bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000445 // shifted imm
Owen Andersonb9a643e2010-11-12 23:36:03 +0000446 def ri : T2TwoRegShiftedImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
Owen Anderson5de6d842010-11-12 21:12:40 +0000447 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
448 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000449 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000450 let Inst{31-27} = 0b11110;
451 let Inst{25} = 0;
452 let Inst{24-21} = opcod;
453 let Inst{20} = 0; // The S bit.
454 let Inst{15} = 0;
455 }
Evan Chenga67efd12009-06-23 19:39:13 +0000456 // register
Owen Anderson5de6d842010-11-12 21:12:40 +0000457 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
458 opc, ".w\t$Rd, $Rn, $Rm",
459 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000460 Requires<[IsThumb2]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000461 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000462 let Inst{31-27} = 0b11101;
463 let Inst{26-25} = 0b01;
464 let Inst{24-21} = opcod;
465 let Inst{20} = 0; // The S bit.
466 let Inst{14-12} = 0b000; // imm3
467 let Inst{7-6} = 0b00; // imm2
468 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000469 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000470 // shifted register
Owen Anderson5de6d842010-11-12 21:12:40 +0000471 def rs : T2TwoRegShiftedReg<
472 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
473 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
474 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000475 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000476 let Inst{31-27} = 0b11101;
477 let Inst{26-25} = 0b01;
478 let Inst{24-21} = opcod;
479 let Inst{20} = 0; // The S bit.
480 }
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000481}
482
483// Carry setting variants
484let Defs = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000485multiclass T2I_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
486 bit Commutable = 0> {
Evan Cheng62674222009-06-25 23:34:10 +0000487 // shifted imm
Owen Andersonb9a643e2010-11-12 23:36:03 +0000488 def ri : T2TwoRegShiftedImm<
Owen Anderson5de6d842010-11-12 21:12:40 +0000489 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
490 opc, "\t$Rd, $Rn, $imm",
491 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000492 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000493 let Inst{31-27} = 0b11110;
494 let Inst{25} = 0;
495 let Inst{24-21} = opcod;
496 let Inst{20} = 1; // The S bit.
497 let Inst{15} = 0;
498 }
Evan Cheng62674222009-06-25 23:34:10 +0000499 // register
Owen Anderson5de6d842010-11-12 21:12:40 +0000500 def rr : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
501 opc, ".w\t$Rd, $Rn, $Rm",
502 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000503 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000504 let isCommutable = Commutable;
505 let Inst{31-27} = 0b11101;
506 let Inst{26-25} = 0b01;
507 let Inst{24-21} = opcod;
508 let Inst{20} = 1; // The S bit.
509 let Inst{14-12} = 0b000; // imm3
510 let Inst{7-6} = 0b00; // imm2
511 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000512 }
Evan Cheng62674222009-06-25 23:34:10 +0000513 // shifted register
Owen Anderson5de6d842010-11-12 21:12:40 +0000514 def rs : T2TwoRegShiftedReg<
515 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
516 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
517 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000518 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000519 let Inst{31-27} = 0b11101;
520 let Inst{26-25} = 0b01;
521 let Inst{24-21} = opcod;
522 let Inst{20} = 1; // The S bit.
Evan Cheng8de898a2009-06-26 00:19:44 +0000523 }
Evan Chengf49810c2009-06-23 17:48:47 +0000524}
525}
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000526}
Evan Chengf49810c2009-06-23 17:48:47 +0000527
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000528/// T2I_rbin_s_is - Same as T2I_rbin_irs except sets 's' bit and the register
529/// version is not needed since this is only for codegen.
Evan Cheng1e249e32009-06-25 20:59:23 +0000530let Defs = [CPSR] in {
Johnny Chend68e1192009-12-15 17:24:14 +0000531multiclass T2I_rbin_s_is<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000532 // shifted imm
Owen Andersonb9a643e2010-11-12 23:36:03 +0000533 def ri : T2I<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_imm:$lhs), IIC_iALUi,
534 !strconcat(opc, "s"), ".w\t$dst, $rhs, $lhs",
535 [(set rGPR:$dst, (opnode t2_so_imm:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000536 let Inst{31-27} = 0b11110;
537 let Inst{25} = 0;
538 let Inst{24-21} = opcod;
539 let Inst{20} = 1; // The S bit.
540 let Inst{15} = 0;
541 }
Evan Chengf49810c2009-06-23 17:48:47 +0000542 // shifted register
Owen Andersonb9a643e2010-11-12 23:36:03 +0000543 def rs : T2I<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_reg:$lhs), IIC_iALUsi,
544 !strconcat(opc, "s"), "\t$dst, $rhs, $lhs",
545 [(set rGPR:$dst, (opnode t2_so_reg:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000546 let Inst{31-27} = 0b11101;
547 let Inst{26-25} = 0b01;
548 let Inst{24-21} = opcod;
549 let Inst{20} = 1; // The S bit.
550 }
Evan Chengf49810c2009-06-23 17:48:47 +0000551}
552}
553
Evan Chenga67efd12009-06-23 19:39:13 +0000554/// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
555// rotate operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000556multiclass T2I_sh_ir<bits<2> opcod, string opc, PatFrag opnode> {
Evan Chenga67efd12009-06-23 19:39:13 +0000557 // 5-bit imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000558 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, i32imm:$rhs), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000559 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000560 [(set rGPR:$dst, (opnode rGPR:$lhs, imm1_31:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000561 let Inst{31-27} = 0b11101;
562 let Inst{26-21} = 0b010010;
563 let Inst{19-16} = 0b1111; // Rn
564 let Inst{5-4} = opcod;
565 }
Evan Chenga67efd12009-06-23 19:39:13 +0000566 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000567 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs), IIC_iMOVsr,
Evan Cheng699beba2009-10-27 00:08:59 +0000568 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000569 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000570 let Inst{31-27} = 0b11111;
571 let Inst{26-23} = 0b0100;
572 let Inst{22-21} = opcod;
573 let Inst{15-12} = 0b1111;
574 let Inst{7-4} = 0b0000;
575 }
Evan Chenga67efd12009-06-23 19:39:13 +0000576}
Evan Chengf49810c2009-06-23 17:48:47 +0000577
Johnny Chend68e1192009-12-15 17:24:14 +0000578/// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
Evan Chenga67efd12009-06-23 19:39:13 +0000579/// patterns. Similar to T2I_bin_irs except the instruction does not produce
Evan Chengf49810c2009-06-23 17:48:47 +0000580/// a explicit result, only implicitly set CPSR.
Bill Wendlingf0e132c2010-08-19 00:05:48 +0000581let isCompare = 1, Defs = [CPSR] in {
Evan Cheng5d42c562010-09-29 00:49:25 +0000582multiclass T2I_cmp_irs<bits<4> opcod, string opc,
583 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
584 PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000585 // shifted imm
Evan Cheng5d42c562010-09-29 00:49:25 +0000586 def ri : T2I<(outs), (ins GPR:$lhs, t2_so_imm:$rhs), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000587 opc, ".w\t$lhs, $rhs",
Johnny Chend68e1192009-12-15 17:24:14 +0000588 [(opnode GPR:$lhs, t2_so_imm:$rhs)]> {
589 let Inst{31-27} = 0b11110;
590 let Inst{25} = 0;
591 let Inst{24-21} = opcod;
592 let Inst{20} = 1; // The S bit.
593 let Inst{15} = 0;
594 let Inst{11-8} = 0b1111; // Rd
595 }
Evan Chenga67efd12009-06-23 19:39:13 +0000596 // register
Evan Cheng5d42c562010-09-29 00:49:25 +0000597 def rr : T2I<(outs), (ins GPR:$lhs, rGPR:$rhs), iir,
Evan Cheng699beba2009-10-27 00:08:59 +0000598 opc, ".w\t$lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000599 [(opnode GPR:$lhs, rGPR:$rhs)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000600 let Inst{31-27} = 0b11101;
601 let Inst{26-25} = 0b01;
602 let Inst{24-21} = opcod;
603 let Inst{20} = 1; // The S bit.
604 let Inst{14-12} = 0b000; // imm3
605 let Inst{11-8} = 0b1111; // Rd
606 let Inst{7-6} = 0b00; // imm2
607 let Inst{5-4} = 0b00; // type
608 }
Evan Chengf49810c2009-06-23 17:48:47 +0000609 // shifted register
Evan Cheng5d42c562010-09-29 00:49:25 +0000610 def rs : T2I<(outs), (ins GPR:$lhs, t2_so_reg:$rhs), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000611 opc, ".w\t$lhs, $rhs",
Johnny Chend68e1192009-12-15 17:24:14 +0000612 [(opnode GPR:$lhs, t2_so_reg:$rhs)]> {
613 let Inst{31-27} = 0b11101;
614 let Inst{26-25} = 0b01;
615 let Inst{24-21} = opcod;
616 let Inst{20} = 1; // The S bit.
617 let Inst{11-8} = 0b1111; // Rd
618 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000619}
620}
621
Evan Chengf3c21b82009-06-30 02:15:48 +0000622/// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000623multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
Evan Cheng7e2fe912010-10-28 06:47:08 +0000624 InstrItinClass iii, InstrItinClass iis, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +0000625 def i12 : T2Ii12<(outs GPR:$dst), (ins t2addrmode_imm12:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000626 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000627 [(set GPR:$dst, (opnode t2addrmode_imm12:$addr))]> {
628 let Inst{31-27} = 0b11111;
629 let Inst{26-25} = 0b00;
630 let Inst{24} = signed;
631 let Inst{23} = 1;
632 let Inst{22-21} = opcod;
633 let Inst{20} = 1; // load
634 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000635 def i8 : T2Ii8 <(outs GPR:$dst), (ins t2addrmode_imm8:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000636 opc, "\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000637 [(set GPR:$dst, (opnode t2addrmode_imm8:$addr))]> {
638 let Inst{31-27} = 0b11111;
639 let Inst{26-25} = 0b00;
640 let Inst{24} = signed;
641 let Inst{23} = 0;
642 let Inst{22-21} = opcod;
643 let Inst{20} = 1; // load
644 let Inst{11} = 1;
645 // Offset: index==TRUE, wback==FALSE
646 let Inst{10} = 1; // The P bit.
647 let Inst{8} = 0; // The W bit.
648 }
Evan Cheng7e2fe912010-10-28 06:47:08 +0000649 def s : T2Iso <(outs GPR:$dst), (ins t2addrmode_so_reg:$addr), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000650 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000651 [(set GPR:$dst, (opnode t2addrmode_so_reg:$addr))]> {
652 let Inst{31-27} = 0b11111;
653 let Inst{26-25} = 0b00;
654 let Inst{24} = signed;
655 let Inst{23} = 0;
656 let Inst{22-21} = opcod;
657 let Inst{20} = 1; // load
658 let Inst{11-6} = 0b000000;
659 }
Evan Chengbc7deb02010-11-03 05:14:24 +0000660
661 // FIXME: Is the pci variant actually needed?
Evan Cheng0e55fd62010-09-30 01:08:25 +0000662 def pci : T2Ipc <(outs GPR:$dst), (ins i32imm:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000663 opc, ".w\t$dst, $addr",
Evan Cheng9eda6892009-10-31 03:39:36 +0000664 [(set GPR:$dst, (opnode (ARMWrapper tconstpool:$addr)))]> {
665 let isReMaterializable = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000666 let Inst{31-27} = 0b11111;
667 let Inst{26-25} = 0b00;
668 let Inst{24} = signed;
669 let Inst{23} = ?; // add = (U == '1')
670 let Inst{22-21} = opcod;
671 let Inst{20} = 1; // load
672 let Inst{19-16} = 0b1111; // Rn
Evan Cheng9eda6892009-10-31 03:39:36 +0000673 }
Evan Chengf3c21b82009-06-30 02:15:48 +0000674}
675
David Goodwin73b8f162009-06-30 22:11:34 +0000676/// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000677multiclass T2I_st<bits<2> opcod, string opc,
Evan Cheng7e2fe912010-10-28 06:47:08 +0000678 InstrItinClass iii, InstrItinClass iis, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +0000679 def i12 : T2Ii12<(outs), (ins GPR:$src, t2addrmode_imm12:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000680 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000681 [(opnode GPR:$src, t2addrmode_imm12:$addr)]> {
682 let Inst{31-27} = 0b11111;
683 let Inst{26-23} = 0b0001;
684 let Inst{22-21} = opcod;
685 let Inst{20} = 0; // !load
686 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000687 def i8 : T2Ii8 <(outs), (ins GPR:$src, t2addrmode_imm8:$addr), iii,
Evan Cheng699beba2009-10-27 00:08:59 +0000688 opc, "\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000689 [(opnode GPR:$src, t2addrmode_imm8:$addr)]> {
690 let Inst{31-27} = 0b11111;
691 let Inst{26-23} = 0b0000;
692 let Inst{22-21} = opcod;
693 let Inst{20} = 0; // !load
694 let Inst{11} = 1;
695 // Offset: index==TRUE, wback==FALSE
696 let Inst{10} = 1; // The P bit.
697 let Inst{8} = 0; // The W bit.
698 }
Evan Cheng7e2fe912010-10-28 06:47:08 +0000699 def s : T2Iso <(outs), (ins GPR:$src, t2addrmode_so_reg:$addr), iis,
Evan Cheng699beba2009-10-27 00:08:59 +0000700 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000701 [(opnode GPR:$src, t2addrmode_so_reg:$addr)]> {
702 let Inst{31-27} = 0b11111;
703 let Inst{26-23} = 0b0000;
704 let Inst{22-21} = opcod;
705 let Inst{20} = 0; // !load
706 let Inst{11-6} = 0b000000;
707 }
David Goodwin73b8f162009-06-30 22:11:34 +0000708}
709
Evan Cheng0e55fd62010-09-30 01:08:25 +0000710/// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +0000711/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000712multiclass T2I_ext_rrot<bits<3> opcod, string opc, PatFrag opnode> {
713 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Evan Cheng699beba2009-10-27 00:08:59 +0000714 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000715 [(set rGPR:$dst, (opnode rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000716 let Inst{31-27} = 0b11111;
717 let Inst{26-23} = 0b0100;
718 let Inst{22-20} = opcod;
719 let Inst{19-16} = 0b1111; // Rn
720 let Inst{15-12} = 0b1111;
721 let Inst{7} = 1;
722 let Inst{5-4} = 0b00; // rotate
723 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000724 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Evan Cheng699beba2009-10-27 00:08:59 +0000725 opc, ".w\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000726 [(set rGPR:$dst, (opnode (rotr rGPR:$src, rot_imm:$rot)))]> {
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} = {?,?}; // rotate
734 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000735}
736
Eli Friedman761fa7a2010-06-24 18:20:04 +0000737// UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000738multiclass T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode> {
739 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Johnny Chen267124c2010-03-04 22:24:41 +0000740 opc, "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000741 [(set rGPR:$dst, (opnode rGPR:$src))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000742 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000743 let Inst{31-27} = 0b11111;
744 let Inst{26-23} = 0b0100;
745 let Inst{22-20} = opcod;
746 let Inst{19-16} = 0b1111; // Rn
747 let Inst{15-12} = 0b1111;
748 let Inst{7} = 1;
749 let Inst{5-4} = 0b00; // rotate
750 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000751 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Johnny Chen267124c2010-03-04 22:24:41 +0000752 opc, "\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000753 [(set rGPR:$dst, (opnode (rotr rGPR:$src, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000754 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000755 let Inst{31-27} = 0b11111;
756 let Inst{26-23} = 0b0100;
757 let Inst{22-20} = opcod;
758 let Inst{19-16} = 0b1111; // Rn
759 let Inst{15-12} = 0b1111;
760 let Inst{7} = 1;
761 let Inst{5-4} = {?,?}; // rotate
762 }
763}
764
Eli Friedman761fa7a2010-06-24 18:20:04 +0000765// SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
766// supported yet.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000767multiclass T2I_ext_rrot_sxtb16<bits<3> opcod, string opc> {
768 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iEXTr,
Johnny Chen93042d12010-03-02 18:14:57 +0000769 opc, "\t$dst, $src", []> {
770 let Inst{31-27} = 0b11111;
771 let Inst{26-23} = 0b0100;
772 let Inst{22-20} = opcod;
773 let Inst{19-16} = 0b1111; // Rn
774 let Inst{15-12} = 0b1111;
775 let Inst{7} = 1;
776 let Inst{5-4} = 0b00; // rotate
777 }
Evan Cheng0e55fd62010-09-30 01:08:25 +0000778 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iEXTr,
Johnny Chen93042d12010-03-02 18:14:57 +0000779 opc, "\t$dst, $src, ror $rot", []> {
780 let Inst{31-27} = 0b11111;
781 let Inst{26-23} = 0b0100;
782 let Inst{22-20} = opcod;
783 let Inst{19-16} = 0b1111; // Rn
784 let Inst{15-12} = 0b1111;
785 let Inst{7} = 1;
786 let Inst{5-4} = {?,?}; // rotate
787 }
788}
789
Evan Cheng0e55fd62010-09-30 01:08:25 +0000790/// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +0000791/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000792multiclass T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode> {
793 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iEXTAr,
Evan Cheng699beba2009-10-27 00:08:59 +0000794 opc, "\t$dst, $LHS, $RHS",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000795 [(set rGPR:$dst, (opnode rGPR:$LHS, rGPR:$RHS))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000796 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000797 let Inst{31-27} = 0b11111;
798 let Inst{26-23} = 0b0100;
799 let Inst{22-20} = opcod;
800 let Inst{15-12} = 0b1111;
801 let Inst{7} = 1;
802 let Inst{5-4} = 0b00; // rotate
803 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000804 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Evan Cheng0e55fd62010-09-30 01:08:25 +0000805 IIC_iEXTAsr, opc, "\t$dst, $LHS, $RHS, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000806 [(set rGPR:$dst, (opnode rGPR:$LHS,
807 (rotr rGPR:$RHS, rot_imm:$rot)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +0000808 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000809 let Inst{31-27} = 0b11111;
810 let Inst{26-23} = 0b0100;
811 let Inst{22-20} = opcod;
812 let Inst{15-12} = 0b1111;
813 let Inst{7} = 1;
814 let Inst{5-4} = {?,?}; // rotate
815 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000816}
817
Johnny Chen93042d12010-03-02 18:14:57 +0000818// DO variant - disassembly only, no pattern
819
Evan Cheng0e55fd62010-09-30 01:08:25 +0000820multiclass T2I_exta_rrot_DO<bits<3> opcod, string opc> {
Evan Cheng7e1bf302010-09-29 00:27:46 +0000821 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iEXTAr,
Johnny Chen93042d12010-03-02 18:14:57 +0000822 opc, "\t$dst, $LHS, $RHS", []> {
823 let Inst{31-27} = 0b11111;
824 let Inst{26-23} = 0b0100;
825 let Inst{22-20} = opcod;
826 let Inst{15-12} = 0b1111;
827 let Inst{7} = 1;
828 let Inst{5-4} = 0b00; // rotate
829 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000830 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Evan Cheng7e1bf302010-09-29 00:27:46 +0000831 IIC_iEXTAsr, opc, "\t$dst, $LHS, $RHS, ror $rot", []> {
Johnny Chen93042d12010-03-02 18:14:57 +0000832 let Inst{31-27} = 0b11111;
833 let Inst{26-23} = 0b0100;
834 let Inst{22-20} = opcod;
835 let Inst{15-12} = 0b1111;
836 let Inst{7} = 1;
837 let Inst{5-4} = {?,?}; // rotate
838 }
839}
840
Anton Korobeynikov52237112009-06-17 18:13:58 +0000841//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000842// Instructions
843//===----------------------------------------------------------------------===//
844
845//===----------------------------------------------------------------------===//
Evan Chenga09b9ca2009-06-24 23:47:58 +0000846// Miscellaneous Instructions.
847//
848
Evan Chenga09b9ca2009-06-24 23:47:58 +0000849// LEApcrel - Load a pc-relative address into a register without offending the
850// assembler.
Evan Chengea420b22010-05-19 01:52:25 +0000851let neverHasSideEffects = 1 in {
Evan Cheng9085f982010-05-19 07:28:01 +0000852let isReMaterializable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000853def t2LEApcrel : T2XI<(outs rGPR:$dst), (ins i32imm:$label, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +0000854 "adr${p}.w\t$dst, #$label", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000855 let Inst{31-27} = 0b11110;
856 let Inst{25-24} = 0b10;
857 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
858 let Inst{22} = 0;
859 let Inst{20} = 0;
860 let Inst{19-16} = 0b1111; // Rn
861 let Inst{15} = 0;
862}
Jim Grosbacha967d112010-06-21 21:27:27 +0000863} // neverHasSideEffects
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000864def t2LEApcrelJT : T2XI<(outs rGPR:$dst),
Bob Wilson4f38b382009-08-21 21:58:55 +0000865 (ins i32imm:$label, nohash_imm:$id, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +0000866 "adr${p}.w\t$dst, #${label}_${id}", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000867 let Inst{31-27} = 0b11110;
868 let Inst{25-24} = 0b10;
869 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
870 let Inst{22} = 0;
871 let Inst{20} = 0;
872 let Inst{19-16} = 0b1111; // Rn
873 let Inst{15} = 0;
874}
Evan Chenga09b9ca2009-06-24 23:47:58 +0000875
Evan Cheng86198642009-08-07 00:34:42 +0000876// ADD r, sp, {so_imm|i12}
Owen Andersonb9a643e2010-11-12 23:36:03 +0000877def t2ADDrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
878 IIC_iALUi, "add", ".w\t$dst, $sp, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000879 let Inst{31-27} = 0b11110;
880 let Inst{25} = 0;
881 let Inst{24-21} = 0b1000;
882 let Inst{20} = ?; // The S bit.
Owen Andersonb9a643e2010-11-12 23:36:03 +0000883 let Inst{19-16} = 0b1101; // Rn = sp
Johnny Chend68e1192009-12-15 17:24:14 +0000884 let Inst{15} = 0;
885}
Owen Andersonb9a643e2010-11-12 23:36:03 +0000886def t2ADDrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
887 IIC_iALUi, "addw", "\t$dst, $sp, $imm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000888 let Inst{31-27} = 0b11110;
889 let Inst{25} = 1;
890 let Inst{24-21} = 0b0000;
891 let Inst{20} = 0; // The S bit.
892 let Inst{19-16} = 0b1101; // Rn = sp
893 let Inst{15} = 0;
894}
Evan Cheng86198642009-08-07 00:34:42 +0000895
896// ADD r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +0000897def t2ADDrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +0000898 IIC_iALUsi, "add", ".w\t$dst, $sp, $rhs", []> {
899 let Inst{31-27} = 0b11101;
900 let Inst{26-25} = 0b01;
901 let Inst{24-21} = 0b1000;
902 let Inst{20} = ?; // The S bit.
903 let Inst{19-16} = 0b1101; // Rn = sp
904 let Inst{15} = 0;
905}
Evan Cheng86198642009-08-07 00:34:42 +0000906
907// SUB r, sp, {so_imm|i12}
David Goodwin5d598aa2009-08-19 18:00:44 +0000908def t2SUBrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000909 IIC_iALUi, "sub", ".w\t$dst, $sp, $imm", []> {
910 let Inst{31-27} = 0b11110;
911 let Inst{25} = 0;
912 let Inst{24-21} = 0b1101;
913 let Inst{20} = ?; // The S bit.
914 let Inst{19-16} = 0b1101; // Rn = sp
915 let Inst{15} = 0;
916}
David Goodwin5d598aa2009-08-19 18:00:44 +0000917def t2SUBrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000918 IIC_iALUi, "subw", "\t$dst, $sp, $imm", []> {
919 let Inst{31-27} = 0b11110;
920 let Inst{25} = 1;
921 let Inst{24-21} = 0b0101;
922 let Inst{20} = 0; // The S bit.
923 let Inst{19-16} = 0b1101; // Rn = sp
924 let Inst{15} = 0;
925}
Evan Cheng86198642009-08-07 00:34:42 +0000926
927// SUB r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +0000928def t2SUBrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
929 IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +0000930 "sub", "\t$dst, $sp, $rhs", []> {
931 let Inst{31-27} = 0b11101;
932 let Inst{26-25} = 0b01;
933 let Inst{24-21} = 0b1101;
934 let Inst{20} = ?; // The S bit.
935 let Inst{19-16} = 0b1101; // Rn = sp
936 let Inst{15} = 0;
937}
Evan Cheng86198642009-08-07 00:34:42 +0000938
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000939// Signed and unsigned division on v7-M
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000940def t2SDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000941 "sdiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000942 [(set rGPR:$dst, (sdiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000943 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +0000944 let Inst{31-27} = 0b11111;
945 let Inst{26-21} = 0b011100;
946 let Inst{20} = 0b1;
947 let Inst{15-12} = 0b1111;
948 let Inst{7-4} = 0b1111;
949}
950
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000951def t2UDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000952 "udiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000953 [(set rGPR:$dst, (udiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000954 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +0000955 let Inst{31-27} = 0b11111;
956 let Inst{26-21} = 0b011101;
957 let Inst{20} = 0b1;
958 let Inst{15-12} = 0b1111;
959 let Inst{7-4} = 0b1111;
960}
961
Evan Chenga09b9ca2009-06-24 23:47:58 +0000962//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000963// Load / store Instructions.
964//
965
Evan Cheng055b0312009-06-29 07:51:04 +0000966// Load
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000967let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng7e2fe912010-10-28 06:47:08 +0000968defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000969 UnOpFrag<(load node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000970
Evan Chengf3c21b82009-06-30 02:15:48 +0000971// Loads with zero extension
Evan Cheng7e2fe912010-10-28 06:47:08 +0000972defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000973 UnOpFrag<(zextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +0000974defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000975 UnOpFrag<(zextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000976
Evan Chengf3c21b82009-06-30 02:15:48 +0000977// Loads with sign extension
Evan Cheng7e2fe912010-10-28 06:47:08 +0000978defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000979 UnOpFrag<(sextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +0000980defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +0000981 UnOpFrag<(sextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000982
Chris Lattnera1ca91a2010-11-02 23:40:41 +0000983let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
984 isCodeGenOnly = 1 in { // $dst doesn't exist in asmstring?
Evan Chengf3c21b82009-06-30 02:15:48 +0000985// Load doubleword
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000986def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Chenge298ab22009-09-27 09:46:04 +0000987 (ins t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +0000988 IIC_iLoad_d_i, "ldrd", "\t$dst1, $addr", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000989def t2LDRDpci : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +0000990 (ins i32imm:$addr), IIC_iLoad_d_i,
Johnny Chen83142992010-01-05 22:37:28 +0000991 "ldrd", "\t$dst1, $addr", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000992 let Inst{19-16} = 0b1111; // Rn
993}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000994} // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
Evan Chengf3c21b82009-06-30 02:15:48 +0000995
996// zextload i1 -> zextload i8
997def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
998 (t2LDRBi12 t2addrmode_imm12:$addr)>;
999def : T2Pat<(zextloadi1 t2addrmode_imm8:$addr),
1000 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1001def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1002 (t2LDRBs t2addrmode_so_reg:$addr)>;
1003def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1004 (t2LDRBpci tconstpool:$addr)>;
1005
1006// extload -> zextload
1007// FIXME: Reduce the number of patterns by legalizing extload to zextload
1008// earlier?
1009def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1010 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1011def : T2Pat<(extloadi1 t2addrmode_imm8:$addr),
1012 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1013def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1014 (t2LDRBs t2addrmode_so_reg:$addr)>;
1015def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1016 (t2LDRBpci tconstpool:$addr)>;
1017
1018def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1019 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1020def : T2Pat<(extloadi8 t2addrmode_imm8:$addr),
1021 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1022def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1023 (t2LDRBs t2addrmode_so_reg:$addr)>;
1024def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1025 (t2LDRBpci tconstpool:$addr)>;
1026
1027def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1028 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1029def : T2Pat<(extloadi16 t2addrmode_imm8:$addr),
1030 (t2LDRHi8 t2addrmode_imm8:$addr)>;
1031def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1032 (t2LDRHs t2addrmode_so_reg:$addr)>;
1033def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1034 (t2LDRHpci tconstpool:$addr)>;
Evan Cheng055b0312009-06-29 07:51:04 +00001035
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001036// FIXME: The destination register of the loads and stores can't be PC, but
1037// can be SP. We need another regclass (similar to rGPR) to represent
1038// that. Not a pressing issue since these are selected manually,
1039// not via pattern.
1040
Evan Chenge88d5ce2009-07-02 07:28:31 +00001041// Indexed loads
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001042let mayLoad = 1, neverHasSideEffects = 1 in {
Johnny Chend68e1192009-12-15 17:24:14 +00001043def t2LDR_PRE : T2Iidxldst<0, 0b10, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001044 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001045 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001046 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001047 []>;
1048
Johnny Chend68e1192009-12-15 17:24:14 +00001049def t2LDR_POST : T2Iidxldst<0, 0b10, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001050 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001051 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001052 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001053 []>;
1054
Johnny Chend68e1192009-12-15 17:24:14 +00001055def t2LDRB_PRE : T2Iidxldst<0, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001056 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001057 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001058 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001059 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001060def t2LDRB_POST : T2Iidxldst<0, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001061 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001062 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001063 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001064 []>;
1065
Johnny Chend68e1192009-12-15 17:24:14 +00001066def t2LDRH_PRE : T2Iidxldst<0, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001067 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001068 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001069 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001070 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001071def t2LDRH_POST : T2Iidxldst<0, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001072 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001073 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001074 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001075 []>;
1076
Johnny Chend68e1192009-12-15 17:24:14 +00001077def t2LDRSB_PRE : T2Iidxldst<1, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001078 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001079 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001080 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001081 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001082def t2LDRSB_POST : T2Iidxldst<1, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001083 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001084 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001085 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001086 []>;
1087
Johnny Chend68e1192009-12-15 17:24:14 +00001088def t2LDRSH_PRE : T2Iidxldst<1, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001089 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001090 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001091 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001092 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001093def t2LDRSH_POST : T2Iidxldst<1, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001094 (ins GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001095 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001096 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001097 []>;
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001098} // mayLoad = 1, neverHasSideEffects = 1
Evan Cheng4fbb9962009-07-02 23:16:11 +00001099
Johnny Chene54a3ef2010-03-03 18:45:36 +00001100// LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110) and are
1101// for disassembly only.
1102// Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001103class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1104 : T2Ii8<(outs GPR:$dst), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001105 "\t$dst, $addr", []> {
1106 let Inst{31-27} = 0b11111;
1107 let Inst{26-25} = 0b00;
1108 let Inst{24} = signed;
1109 let Inst{23} = 0;
1110 let Inst{22-21} = type;
1111 let Inst{20} = 1; // load
1112 let Inst{11} = 1;
1113 let Inst{10-8} = 0b110; // PUW.
1114}
1115
Evan Cheng0e55fd62010-09-30 01:08:25 +00001116def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1117def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1118def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1119def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1120def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
Johnny Chene54a3ef2010-03-03 18:45:36 +00001121
David Goodwin73b8f162009-06-30 22:11:34 +00001122// Store
Evan Cheng7e2fe912010-10-28 06:47:08 +00001123defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001124 BinOpFrag<(store node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001125defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001126 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001127defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001128 BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
David Goodwin73b8f162009-06-30 22:11:34 +00001129
David Goodwin6647cea2009-06-30 22:50:01 +00001130// Store doubleword
Chris Lattnera1ca91a2010-11-02 23:40:41 +00001131let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1132 isCodeGenOnly = 1 in // $src2 doesn't exist in asm string
Johnny Chend68e1192009-12-15 17:24:14 +00001133def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
Evan Chenge298ab22009-09-27 09:46:04 +00001134 (ins GPR:$src1, GPR:$src2, t2addrmode_imm8s4:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001135 IIC_iStore_d_r, "strd", "\t$src1, $addr", []>;
David Goodwin6647cea2009-06-30 22:50:01 +00001136
Evan Cheng6d94f112009-07-03 00:06:39 +00001137// Indexed stores
Johnny Chend68e1192009-12-15 17:24:14 +00001138def t2STR_PRE : T2Iidxldst<0, 0b10, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001139 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001140 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001141 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001142 [(set GPR:$base_wb,
1143 (pre_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1144
Johnny Chend68e1192009-12-15 17:24:14 +00001145def t2STR_POST : T2Iidxldst<0, 0b10, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001146 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001147 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001148 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001149 [(set GPR:$base_wb,
Jim Grosbach6935efc2009-11-24 00:20:27 +00001150 (post_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001151
Johnny Chend68e1192009-12-15 17:24:14 +00001152def t2STRH_PRE : T2Iidxldst<0, 0b01, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001153 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001154 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001155 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001156 [(set GPR:$base_wb,
1157 (pre_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1158
Johnny Chend68e1192009-12-15 17:24:14 +00001159def t2STRH_POST : T2Iidxldst<0, 0b01, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001160 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001161 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001162 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001163 [(set GPR:$base_wb,
1164 (post_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1165
Johnny Chend68e1192009-12-15 17:24:14 +00001166def t2STRB_PRE : T2Iidxldst<0, 0b00, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001167 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001168 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001169 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001170 [(set GPR:$base_wb,
1171 (pre_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1172
Johnny Chend68e1192009-12-15 17:24:14 +00001173def t2STRB_POST : T2Iidxldst<0, 0b00, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001174 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001175 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Evan Cheng699beba2009-10-27 00:08:59 +00001176 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001177 [(set GPR:$base_wb,
1178 (post_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1179
Johnny Chene54a3ef2010-03-03 18:45:36 +00001180// STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1181// only.
1182// Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001183class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1184 : T2Ii8<(outs GPR:$src), (ins t2addrmode_imm8:$addr), ii, opc,
Johnny Chene54a3ef2010-03-03 18:45:36 +00001185 "\t$src, $addr", []> {
1186 let Inst{31-27} = 0b11111;
1187 let Inst{26-25} = 0b00;
1188 let Inst{24} = 0; // not signed
1189 let Inst{23} = 0;
1190 let Inst{22-21} = type;
1191 let Inst{20} = 0; // store
1192 let Inst{11} = 1;
1193 let Inst{10-8} = 0b110; // PUW
1194}
1195
Evan Cheng0e55fd62010-09-30 01:08:25 +00001196def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1197def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1198def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
David Goodwind1fa1202009-07-01 00:01:13 +00001199
Johnny Chenae1757b2010-03-11 01:13:36 +00001200// ldrd / strd pre / post variants
1201// For disassembly only.
1202
1203def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001204 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001205 "ldrd", "\t$dst1, $dst2, [$base, $imm]!", []>;
1206
1207def t2LDRD_POST : T2Ii8s4<0, 1, 1, (outs GPR:$dst1, GPR:$dst2),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001208 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
Johnny Chenae1757b2010-03-11 01:13:36 +00001209 "ldrd", "\t$dst1, $dst2, [$base], $imm", []>;
1210
1211def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs),
1212 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001213 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base, $imm]!", []>;
Johnny Chenae1757b2010-03-11 01:13:36 +00001214
1215def t2STRD_POST : T2Ii8s4<0, 1, 0, (outs),
1216 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001217 IIC_iStore_d_ru, "strd", "\t$src1, $src2, [$base], $imm", []>;
Evan Cheng2889cce2009-07-03 00:18:36 +00001218
Johnny Chen0635fc52010-03-04 17:40:44 +00001219// T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1220// data/instruction access. These are for disassembly only.
Evan Chengdfed19f2010-11-03 06:34:55 +00001221// instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1222// (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
Evan Cheng416941d2010-11-04 05:19:35 +00001223multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001224
Evan Chengdfed19f2010-11-03 06:34:55 +00001225 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001226 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001227 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001228 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001229 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001230 let Inst{23} = 1; // U = 1
1231 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001232 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001233 let Inst{20} = 1;
1234 let Inst{15-12} = 0b1111;
1235 }
1236
Evan Chengdfed19f2010-11-03 06:34:55 +00001237 def i8 : T2Ii8<(outs), (ins t2addrmode_imm8:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001238 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001239 [(ARMPreload t2addrmode_imm8:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001240 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001241 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001242 let Inst{23} = 0; // U = 0
1243 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001244 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001245 let Inst{20} = 1;
1246 let Inst{15-12} = 0b1111;
1247 let Inst{11-8} = 0b1100;
1248 }
1249
Evan Chengdfed19f2010-11-03 06:34:55 +00001250 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001251 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001252 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
Evan Chengbc7deb02010-11-03 05:14:24 +00001253 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001254 let Inst{24} = instr;
Evan Chengbc7deb02010-11-03 05:14:24 +00001255 let Inst{23} = 0; // add = TRUE for T1
1256 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001257 let Inst{21} = write;
Evan Chengbc7deb02010-11-03 05:14:24 +00001258 let Inst{20} = 1;
1259 let Inst{15-12} = 0b1111;
1260 let Inst{11-6} = 0000000;
1261 }
1262
1263 let isCodeGenOnly = 1 in
Evan Chengdfed19f2010-11-03 06:34:55 +00001264 def pci : T2Ipc<(outs), (ins i32imm:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001265 "\t$addr",
1266 []> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001267 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001268 let Inst{24} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001269 let Inst{23} = ?; // add = (U == 1)
1270 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001271 let Inst{21} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001272 let Inst{20} = 1;
1273 let Inst{19-16} = 0b1111; // Rn = 0b1111
1274 let Inst{15-12} = 0b1111;
1275 }
Johnny Chen0635fc52010-03-04 17:40:44 +00001276}
1277
Evan Cheng416941d2010-11-04 05:19:35 +00001278defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1279defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1280defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
Johnny Chen0635fc52010-03-04 17:40:44 +00001281
Evan Cheng2889cce2009-07-03 00:18:36 +00001282//===----------------------------------------------------------------------===//
1283// Load / store multiple Instructions.
1284//
1285
Chris Lattner39ee0362010-10-31 19:10:56 +00001286let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
1287 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001288def t2LDM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001289 reglist:$dsts, variable_ops), IIC_iLoad_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001290 "ldm${amode}${p}.w\t$Rn, $dsts", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001291 let Inst{31-27} = 0b11101;
1292 let Inst{26-25} = 0b00;
1293 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1294 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001295 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001296 let Inst{20} = 1; // Load
1297}
Evan Cheng2889cce2009-07-03 00:18:36 +00001298
Jim Grosbache6913602010-11-03 01:01:43 +00001299def t2LDM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001300 reglist:$dsts, variable_ops),
1301 IIC_iLoad_mu,
Jim Grosbache6913602010-11-03 01:01:43 +00001302 "ldm${amode}${p}.w\t$Rn!, $dsts",
1303 "$Rn = $wb", []> {
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} = 1; // The W bit.
1309 let Inst{20} = 1; // Load
1310}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001311} // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001312
Chris Lattner39ee0362010-10-31 19:10:56 +00001313let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1314 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +00001315def t2STM : T2XI<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Evan Chenga0792de2010-10-06 06:27:31 +00001316 reglist:$srcs, variable_ops), IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001317 "stm${amode}${p}.w\t$Rn, $srcs", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +00001318 let Inst{31-27} = 0b11101;
1319 let Inst{26-25} = 0b00;
1320 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1321 let Inst{22} = 0;
1322 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001323 let Inst{20} = 0; // Store
1324}
Evan Cheng2889cce2009-07-03 00:18:36 +00001325
Jim Grosbache6913602010-11-03 01:01:43 +00001326def t2STM_UPD : T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +00001327 reglist:$srcs, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00001328 IIC_iStore_m,
Jim Grosbache6913602010-11-03 01:01:43 +00001329 "stm${amode}${p}.w\t$Rn!, $srcs",
1330 "$Rn = $wb", []> {
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} = 1; // The W bit.
1336 let Inst{20} = 0; // Store
1337}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001338} // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001339
Evan Cheng9cb9e672009-06-27 02:26:13 +00001340//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001341// Move Instructions.
1342//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001343
Evan Chengf49810c2009-06-23 17:48:47 +00001344let neverHasSideEffects = 1 in
David Goodwin5d598aa2009-08-19 18:00:44 +00001345def t2MOVr : T2sI<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVr,
Johnny Chend68e1192009-12-15 17:24:14 +00001346 "mov", ".w\t$dst, $src", []> {
1347 let Inst{31-27} = 0b11101;
1348 let Inst{26-25} = 0b01;
1349 let Inst{24-21} = 0b0010;
1350 let Inst{20} = ?; // The S bit.
1351 let Inst{19-16} = 0b1111; // Rn
1352 let Inst{14-12} = 0b000;
1353 let Inst{7-4} = 0b0000;
1354}
Evan Chengf49810c2009-06-23 17:48:47 +00001355
Evan Cheng5adb66a2009-09-28 09:14:39 +00001356// AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1357let isReMaterializable = 1, isAsCheapAsAMove = 1, AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001358def t2MOVi : T2sI<(outs rGPR:$dst), (ins t2_so_imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001359 "mov", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001360 [(set rGPR:$dst, t2_so_imm:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001361 let Inst{31-27} = 0b11110;
1362 let Inst{25} = 0;
1363 let Inst{24-21} = 0b0010;
1364 let Inst{20} = ?; // The S bit.
1365 let Inst{19-16} = 0b1111; // Rn
1366 let Inst{15} = 0;
1367}
David Goodwin83b35932009-06-26 16:10:07 +00001368
1369let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001370def t2MOVi16 : T2I<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001371 "movw", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001372 [(set rGPR:$dst, imm0_65535:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001373 let Inst{31-27} = 0b11110;
1374 let Inst{25} = 1;
1375 let Inst{24-21} = 0b0010;
1376 let Inst{20} = 0; // The S bit.
1377 let Inst{15} = 0;
1378}
Evan Chengf49810c2009-06-23 17:48:47 +00001379
Evan Cheng3850a6a2009-06-23 05:23:49 +00001380let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001381def t2MOVTi16 : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$imm), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001382 "movt", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001383 [(set rGPR:$dst,
1384 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001385 let Inst{31-27} = 0b11110;
1386 let Inst{25} = 1;
1387 let Inst{24-21} = 0b0110;
1388 let Inst{20} = 0; // The S bit.
1389 let Inst{15} = 0;
1390}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001391
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001392def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
Evan Cheng20956592009-10-21 08:15:52 +00001393
Anton Korobeynikov52237112009-06-17 18:13:58 +00001394//===----------------------------------------------------------------------===//
Evan Chengd27c9fc2009-07-03 01:43:10 +00001395// Extend Instructions.
1396//
1397
1398// Sign extenders
1399
Evan Cheng0e55fd62010-09-30 01:08:25 +00001400defm t2SXTB : T2I_ext_rrot<0b100, "sxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001401 UnOpFrag<(sext_inreg node:$Src, i8)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001402defm t2SXTH : T2I_ext_rrot<0b000, "sxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001403 UnOpFrag<(sext_inreg node:$Src, i16)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001404defm t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001405
Evan Cheng0e55fd62010-09-30 01:08:25 +00001406defm t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001407 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001408defm t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001409 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001410defm t2SXTAB16 : T2I_exta_rrot_DO<0b010, "sxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001411
Johnny Chen93042d12010-03-02 18:14:57 +00001412// TODO: SXT(A){B|H}16 - done for disassembly only
Evan Chengd27c9fc2009-07-03 01:43:10 +00001413
1414// Zero extenders
1415
1416let AddedComplexity = 16 in {
Evan Cheng0e55fd62010-09-30 01:08:25 +00001417defm t2UXTB : T2I_ext_rrot<0b101, "uxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001418 UnOpFrag<(and node:$Src, 0x000000FF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001419defm t2UXTH : T2I_ext_rrot<0b001, "uxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001420 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001421defm t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
Johnny Chend68e1192009-12-15 17:24:14 +00001422 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001423
Jim Grosbach79464942010-07-28 23:17:45 +00001424// FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1425// The transformation should probably be done as a combiner action
1426// instead so we can include a check for masking back in the upper
1427// eight bits of the source into the lower eight bits of the result.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001428//def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001429// (t2UXTB16r_rot rGPR:$Src, 24)>,
1430// Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001431def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001432 (t2UXTB16r_rot rGPR:$Src, 8)>,
1433 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001434
Evan Cheng0e55fd62010-09-30 01:08:25 +00001435defm t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001436 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001437defm t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001438 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Evan Cheng0e55fd62010-09-30 01:08:25 +00001439defm t2UXTAB16 : T2I_exta_rrot_DO<0b011, "uxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001440}
1441
1442//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001443// Arithmetic Instructions.
1444//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001445
Johnny Chend68e1192009-12-15 17:24:14 +00001446defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1447 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1448defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1449 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001450
Evan Chengf49810c2009-06-23 17:48:47 +00001451// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
Johnny Chend68e1192009-12-15 17:24:14 +00001452defm t2ADDS : T2I_bin_s_irs <0b1000, "add",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001453 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001454 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1455defm t2SUBS : T2I_bin_s_irs <0b1101, "sub",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001456 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001457 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001458
Johnny Chend68e1192009-12-15 17:24:14 +00001459defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001460 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00001461defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001462 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001463defm t2ADCS : T2I_adde_sube_s_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001464 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001465defm t2SBCS : T2I_adde_sube_s_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001466 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001467
David Goodwin752aa7d2009-07-27 16:39:05 +00001468// RSB
Bob Wilson20d8e4e2010-08-13 23:24:25 +00001469defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
Johnny Chend68e1192009-12-15 17:24:14 +00001470 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1471defm t2RSBS : T2I_rbin_s_is <0b1110, "rsb",
1472 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001473
1474// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001475// The assume-no-carry-in form uses the negation of the input since add/sub
1476// assume opposite meanings of the carry flag (i.e., carry == !borrow).
1477// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1478// details.
1479// The AddedComplexity preferences the first variant over the others since
1480// it can be shrunk to a 16-bit wide encoding, while the others cannot.
Evan Chengfa2ea1a2009-08-04 01:41:15 +00001481let AddedComplexity = 1 in
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001482def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1483 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1484def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1485 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1486def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1487 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1488let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001489def : T2Pat<(addc rGPR:$src, imm0_255_neg:$imm),
1490 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1491def : T2Pat<(addc rGPR:$src, t2_so_imm_neg:$imm),
1492 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001493// The with-carry-in form matches bitwise not instead of the negation.
1494// Effectively, the inverse interpretation of the carry flag already accounts
1495// for part of the negation.
1496let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001497def : T2Pat<(adde rGPR:$src, imm0_255_not:$imm),
1498 (t2SBCSri rGPR:$src, imm0_255_not:$imm)>;
1499def : T2Pat<(adde rGPR:$src, t2_so_imm_not:$imm),
1500 (t2SBCSri rGPR:$src, t2_so_imm_not:$imm)>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001501
Johnny Chen93042d12010-03-02 18:14:57 +00001502// Select Bytes -- for disassembly only
1503
1504def t2SEL : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), NoItinerary, "sel",
1505 "\t$dst, $a, $b", []> {
1506 let Inst{31-27} = 0b11111;
1507 let Inst{26-24} = 0b010;
1508 let Inst{23} = 0b1;
1509 let Inst{22-20} = 0b010;
1510 let Inst{15-12} = 0b1111;
1511 let Inst{7} = 0b1;
1512 let Inst{6-4} = 0b000;
1513}
1514
Johnny Chenadc77332010-02-26 22:04:29 +00001515// A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1516// And Miscellaneous operations -- for disassembly only
Nate Begeman692433b2010-07-29 17:56:55 +00001517class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
1518 list<dag> pat = [/* For disassembly only; pattern left blank */]>
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001519 : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), NoItinerary, opc,
Nate Begeman692433b2010-07-29 17:56:55 +00001520 "\t$dst, $a, $b", pat> {
Johnny Chenadc77332010-02-26 22:04:29 +00001521 let Inst{31-27} = 0b11111;
1522 let Inst{26-23} = 0b0101;
1523 let Inst{22-20} = op22_20;
1524 let Inst{15-12} = 0b1111;
1525 let Inst{7-4} = op7_4;
1526}
1527
1528// Saturating add/subtract -- for disassembly only
1529
Nate Begeman692433b2010-07-29 17:56:55 +00001530def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001531 [(set rGPR:$dst, (int_arm_qadd rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001532def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
1533def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
1534def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
1535def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd">;
1536def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub">;
1537def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
Nate Begeman692433b2010-07-29 17:56:55 +00001538def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001539 [(set rGPR:$dst, (int_arm_qsub rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001540def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
1541def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
1542def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
1543def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
1544def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
1545def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
1546def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
1547def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
1548
1549// Signed/Unsigned add/subtract -- for disassembly only
1550
1551def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
1552def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
1553def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
1554def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
1555def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
1556def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
1557def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
1558def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
1559def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
1560def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
1561def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
1562def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
1563
1564// Signed/Unsigned halving add/subtract -- for disassembly only
1565
1566def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
1567def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
1568def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
1569def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
1570def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
1571def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
1572def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
1573def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
1574def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
1575def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
1576def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
1577def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
1578
1579// Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
1580
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001581def t2USAD8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1582 (ins rGPR:$a, rGPR:$b),
Johnny Chenadc77332010-02-26 22:04:29 +00001583 NoItinerary, "usad8", "\t$dst, $a, $b", []> {
1584 let Inst{15-12} = 0b1111;
1585}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001586def t2USADA8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1587 (ins rGPR:$a, rGPR:$b, rGPR:$acc), NoItinerary, "usada8",
Johnny Chenadc77332010-02-26 22:04:29 +00001588 "\t$dst, $a, $b, $acc", []>;
1589
1590// Signed/Unsigned saturate -- for disassembly only
1591
Bob Wilson22f5dc72010-08-16 18:27:34 +00001592def t2SSAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001593 NoItinerary, "ssat", "\t$dst, $bit_pos, $a$sh",
1594 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001595 let Inst{31-27} = 0b11110;
1596 let Inst{25-22} = 0b1100;
1597 let Inst{20} = 0;
1598 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001599}
1600
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001601def t2SSAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001602 "ssat16", "\t$dst, $bit_pos, $a",
1603 [/* For disassembly only; pattern left blank */]> {
1604 let Inst{31-27} = 0b11110;
1605 let Inst{25-22} = 0b1100;
1606 let Inst{20} = 0;
1607 let Inst{15} = 0;
1608 let Inst{21} = 1; // sh = '1'
1609 let Inst{14-12} = 0b000; // imm3 = '000'
1610 let Inst{7-6} = 0b00; // imm2 = '00'
1611}
1612
Bob Wilson22f5dc72010-08-16 18:27:34 +00001613def t2USAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001614 NoItinerary, "usat", "\t$dst, $bit_pos, $a$sh",
1615 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001616 let Inst{31-27} = 0b11110;
1617 let Inst{25-22} = 0b1110;
1618 let Inst{20} = 0;
1619 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001620}
1621
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001622def t2USAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001623 "usat16", "\t$dst, $bit_pos, $a",
1624 [/* For disassembly only; pattern left blank */]> {
1625 let Inst{31-27} = 0b11110;
1626 let Inst{25-22} = 0b1110;
1627 let Inst{20} = 0;
1628 let Inst{15} = 0;
1629 let Inst{21} = 1; // sh = '1'
1630 let Inst{14-12} = 0b000; // imm3 = '000'
1631 let Inst{7-6} = 0b00; // imm2 = '00'
1632}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001633
Bob Wilson38aa2872010-08-13 21:48:10 +00001634def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
1635def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
Nate Begeman0e0a20e2010-07-29 22:48:09 +00001636
Evan Chengf49810c2009-06-23 17:48:47 +00001637//===----------------------------------------------------------------------===//
Evan Chenga67efd12009-06-23 19:39:13 +00001638// Shift and rotate Instructions.
1639//
1640
Johnny Chend68e1192009-12-15 17:24:14 +00001641defm t2LSL : T2I_sh_ir<0b00, "lsl", BinOpFrag<(shl node:$LHS, node:$RHS)>>;
1642defm t2LSR : T2I_sh_ir<0b01, "lsr", BinOpFrag<(srl node:$LHS, node:$RHS)>>;
1643defm t2ASR : T2I_sh_ir<0b10, "asr", BinOpFrag<(sra node:$LHS, node:$RHS)>>;
1644defm t2ROR : T2I_sh_ir<0b11, "ror", BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
Evan Chenga67efd12009-06-23 19:39:13 +00001645
David Goodwinca01a8d2009-09-01 18:32:09 +00001646let Uses = [CPSR] in {
Jim Grosbach792e9792010-10-14 20:43:44 +00001647def t2RRX : T2sI<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +00001648 "rrx", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001649 [(set rGPR:$dst, (ARMrrx rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001650 let Inst{31-27} = 0b11101;
1651 let Inst{26-25} = 0b01;
1652 let Inst{24-21} = 0b0010;
1653 let Inst{20} = ?; // The S bit.
1654 let Inst{19-16} = 0b1111; // Rn
1655 let Inst{14-12} = 0b000;
1656 let Inst{7-4} = 0b0011;
1657}
David Goodwinca01a8d2009-09-01 18:32:09 +00001658}
Evan Chenga67efd12009-06-23 19:39:13 +00001659
David Goodwin3583df72009-07-28 17:06:49 +00001660let Defs = [CPSR] in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001661def t2MOVsrl_flag : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Bob Wilsona85df802010-05-25 04:51:47 +00001662 "lsrs", ".w\t$dst, $src, #1",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001663 [(set rGPR:$dst, (ARMsrl_flag rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001664 let Inst{31-27} = 0b11101;
1665 let Inst{26-25} = 0b01;
1666 let Inst{24-21} = 0b0010;
1667 let Inst{20} = 1; // The S bit.
1668 let Inst{19-16} = 0b1111; // Rn
1669 let Inst{5-4} = 0b01; // Shift type.
1670 // Shift amount = Inst{14-12:7-6} = 1.
1671 let Inst{14-12} = 0b000;
1672 let Inst{7-6} = 0b01;
1673}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001674def t2MOVsra_flag : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Bob Wilsona85df802010-05-25 04:51:47 +00001675 "asrs", ".w\t$dst, $src, #1",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001676 [(set rGPR:$dst, (ARMsra_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} = 0b10; // Shift type.
1683 // Shift amount = Inst{14-12:7-6} = 1.
1684 let Inst{14-12} = 0b000;
1685 let Inst{7-6} = 0b01;
1686}
David Goodwin3583df72009-07-28 17:06:49 +00001687}
1688
Evan Chenga67efd12009-06-23 19:39:13 +00001689//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +00001690// Bitwise Instructions.
1691//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001692
Johnny Chend68e1192009-12-15 17:24:14 +00001693defm t2AND : T2I_bin_w_irs<0b0000, "and",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001694 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001695 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1696defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001697 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001698 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1699defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001700 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001701 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Evan Chengf49810c2009-06-23 17:48:47 +00001702
Johnny Chend68e1192009-12-15 17:24:14 +00001703defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
Evan Cheng7e1bf302010-09-29 00:27:46 +00001704 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Johnny Chend68e1192009-12-15 17:24:14 +00001705 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001706
Evan Chengf49810c2009-06-23 17:48:47 +00001707let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001708def t2BFC : T2I<(outs rGPR:$dst), (ins rGPR:$src, bf_inv_mask_imm:$imm),
David Goodwin2f54a2f2009-11-02 17:28:36 +00001709 IIC_iUNAsi, "bfc", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001710 [(set rGPR:$dst, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001711 let Inst{31-27} = 0b11110;
1712 let Inst{25} = 1;
1713 let Inst{24-20} = 0b10110;
1714 let Inst{19-16} = 0b1111; // Rn
1715 let Inst{15} = 0;
1716}
Evan Chengf49810c2009-06-23 17:48:47 +00001717
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001718def t2SBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001719 IIC_iUNAsi, "sbfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001720 let Inst{31-27} = 0b11110;
1721 let Inst{25} = 1;
1722 let Inst{24-20} = 0b10100;
1723 let Inst{15} = 0;
1724}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00001725
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001726def t2UBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001727 IIC_iUNAsi, "ubfx", "\t$dst, $src, $lsb, $width", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001728 let Inst{31-27} = 0b11110;
1729 let Inst{25} = 1;
1730 let Inst{24-20} = 0b11100;
1731 let Inst{15} = 0;
1732}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00001733
Johnny Chen9474d552010-02-02 19:31:58 +00001734// A8.6.18 BFI - Bitfield insert (Encoding T1)
Jim Grosbach469bbdb2010-07-16 23:05:05 +00001735let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001736def t2BFI : T2I<(outs rGPR:$dst),
1737 (ins rGPR:$src, rGPR:$val, bf_inv_mask_imm:$imm),
Evan Cheng7e1bf302010-09-29 00:27:46 +00001738 IIC_iBITi, "bfi", "\t$dst, $val, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001739 [(set rGPR:$dst, (ARMbfi rGPR:$src, rGPR:$val,
Jim Grosbach469bbdb2010-07-16 23:05:05 +00001740 bf_inv_mask_imm:$imm))]> {
Johnny Chen9474d552010-02-02 19:31:58 +00001741 let Inst{31-27} = 0b11110;
1742 let Inst{25} = 1;
1743 let Inst{24-20} = 0b10110;
1744 let Inst{15} = 0;
1745}
Evan Chengf49810c2009-06-23 17:48:47 +00001746
Evan Cheng7e1bf302010-09-29 00:27:46 +00001747defm t2ORN : T2I_bin_irs<0b0011, "orn",
1748 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
1749 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001750
1751// Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
1752let AddedComplexity = 1 in
Evan Cheng5d42c562010-09-29 00:49:25 +00001753defm t2MVN : T2I_un_irs <0b0011, "mvn",
Evan Cheng3881cb72010-09-29 22:42:35 +00001754 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
Evan Cheng5d42c562010-09-29 00:49:25 +00001755 UnOpFrag<(not node:$Src)>, 1, 1>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001756
1757
Jim Grosbachf084a5e2010-07-20 16:07:04 +00001758let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001759def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
1760 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001761
Evan Cheng25f7cfc2009-08-01 06:13:52 +00001762// FIXME: Disable this pattern on Darwin to workaround an assembler bug.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001763def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
1764 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
Evan Chengea253b92009-08-12 01:56:42 +00001765 Requires<[IsThumb2]>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001766
1767def : T2Pat<(t2_so_imm_not:$src),
1768 (t2MVNi t2_so_imm_not:$src)>;
1769
Evan Chengf49810c2009-06-23 17:48:47 +00001770//===----------------------------------------------------------------------===//
1771// Multiply Instructions.
1772//
Evan Cheng8de898a2009-06-26 00:19:44 +00001773let isCommutable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001774def t2MUL: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001775 "mul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001776 [(set rGPR:$dst, (mul rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001777 let Inst{31-27} = 0b11111;
1778 let Inst{26-23} = 0b0110;
1779 let Inst{22-20} = 0b000;
1780 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1781 let Inst{7-4} = 0b0000; // Multiply
1782}
Evan Chengf49810c2009-06-23 17:48:47 +00001783
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001784def t2MLA: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00001785 "mla", "\t$dst, $a, $b, $c",
1786 [(set rGPR:$dst, (add (mul rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001787 let Inst{31-27} = 0b11111;
1788 let Inst{26-23} = 0b0110;
1789 let Inst{22-20} = 0b000;
1790 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1791 let Inst{7-4} = 0b0000; // Multiply
1792}
Evan Chengf49810c2009-06-23 17:48:47 +00001793
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001794def t2MLS: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Jim Grosbachf38bfd12010-10-29 23:23:15 +00001795 "mls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001796 [(set rGPR:$dst, (sub rGPR:$c, (mul rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001797 let Inst{31-27} = 0b11111;
1798 let Inst{26-23} = 0b0110;
1799 let Inst{22-20} = 0b000;
1800 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1801 let Inst{7-4} = 0b0001; // Multiply and Subtract
1802}
Evan Chengf49810c2009-06-23 17:48:47 +00001803
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001804// Extra precision multiplies with low / high results
1805let neverHasSideEffects = 1 in {
1806let isCommutable = 1 in {
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001807def t2SMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1808 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00001809 "smull", "\t$ldst, $hdst, $a, $b", []> {
1810 let Inst{31-27} = 0b11111;
1811 let Inst{26-23} = 0b0111;
1812 let Inst{22-20} = 0b000;
1813 let Inst{7-4} = 0b0000;
1814}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001815
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001816def t2UMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1817 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00001818 "umull", "\t$ldst, $hdst, $a, $b", []> {
1819 let Inst{31-27} = 0b11111;
1820 let Inst{26-23} = 0b0111;
1821 let Inst{22-20} = 0b010;
1822 let Inst{7-4} = 0b0000;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001823}
Johnny Chend68e1192009-12-15 17:24:14 +00001824} // isCommutable
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001825
1826// Multiply + accumulate
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001827def t2SMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1828 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001829 "smlal", "\t$ldst, $hdst, $a, $b", []>{
1830 let Inst{31-27} = 0b11111;
1831 let Inst{26-23} = 0b0111;
1832 let Inst{22-20} = 0b100;
1833 let Inst{7-4} = 0b0000;
1834}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001835
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001836def t2UMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1837 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001838 "umlal", "\t$ldst, $hdst, $a, $b", []>{
1839 let Inst{31-27} = 0b11111;
1840 let Inst{26-23} = 0b0111;
1841 let Inst{22-20} = 0b110;
1842 let Inst{7-4} = 0b0000;
1843}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001844
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001845def t2UMAAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1846 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001847 "umaal", "\t$ldst, $hdst, $a, $b", []>{
1848 let Inst{31-27} = 0b11111;
1849 let Inst{26-23} = 0b0111;
1850 let Inst{22-20} = 0b110;
1851 let Inst{7-4} = 0b0110;
1852}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001853} // neverHasSideEffects
1854
Johnny Chen93042d12010-03-02 18:14:57 +00001855// Rounding variants of the below included for disassembly only
1856
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001857// Most significant word multiply
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001858def t2SMMUL : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001859 "smmul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001860 [(set rGPR:$dst, (mulhs rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001861 let Inst{31-27} = 0b11111;
1862 let Inst{26-23} = 0b0110;
1863 let Inst{22-20} = 0b101;
1864 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1865 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1866}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001867
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001868def t2SMMULR : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Johnny Chen93042d12010-03-02 18:14:57 +00001869 "smmulr", "\t$dst, $a, $b", []> {
1870 let Inst{31-27} = 0b11111;
1871 let Inst{26-23} = 0b0110;
1872 let Inst{22-20} = 0b101;
1873 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1874 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1875}
1876
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001877def t2SMMLA : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001878 "smmla", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001879 [(set rGPR:$dst, (add (mulhs rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001880 let Inst{31-27} = 0b11111;
1881 let Inst{26-23} = 0b0110;
1882 let Inst{22-20} = 0b101;
1883 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1884 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1885}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001886
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001887def t2SMMLAR: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00001888 "smmlar", "\t$dst, $a, $b, $c", []> {
1889 let Inst{31-27} = 0b11111;
1890 let Inst{26-23} = 0b0110;
1891 let Inst{22-20} = 0b101;
1892 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1893 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1894}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001895
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001896def t2SMMLS: T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001897 "smmls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001898 [(set rGPR:$dst, (sub rGPR:$c, (mulhs rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001899 let Inst{31-27} = 0b11111;
1900 let Inst{26-23} = 0b0110;
1901 let Inst{22-20} = 0b110;
1902 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1903 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1904}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001905
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001906def t2SMMLSR:T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00001907 "smmlsr", "\t$dst, $a, $b, $c", []> {
1908 let Inst{31-27} = 0b11111;
1909 let Inst{26-23} = 0b0110;
1910 let Inst{22-20} = 0b110;
1911 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1912 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1913}
1914
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001915multiclass T2I_smul<string opc, PatFrag opnode> {
Evan Cheng0e55fd62010-09-30 01:08:25 +00001916 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001917 !strconcat(opc, "bb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001918 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
1919 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001920 let Inst{31-27} = 0b11111;
1921 let Inst{26-23} = 0b0110;
1922 let Inst{22-20} = 0b001;
1923 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1924 let Inst{7-6} = 0b00;
1925 let Inst{5-4} = 0b00;
1926 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001927
Evan Cheng0e55fd62010-09-30 01:08:25 +00001928 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001929 !strconcat(opc, "bt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001930 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
1931 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001932 let Inst{31-27} = 0b11111;
1933 let Inst{26-23} = 0b0110;
1934 let Inst{22-20} = 0b001;
1935 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1936 let Inst{7-6} = 0b00;
1937 let Inst{5-4} = 0b01;
1938 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001939
Evan Cheng0e55fd62010-09-30 01:08:25 +00001940 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001941 !strconcat(opc, "tb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001942 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
1943 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001944 let Inst{31-27} = 0b11111;
1945 let Inst{26-23} = 0b0110;
1946 let Inst{22-20} = 0b001;
1947 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1948 let Inst{7-6} = 0b00;
1949 let Inst{5-4} = 0b10;
1950 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001951
Evan Cheng0e55fd62010-09-30 01:08:25 +00001952 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001953 !strconcat(opc, "tt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001954 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
1955 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001956 let Inst{31-27} = 0b11111;
1957 let Inst{26-23} = 0b0110;
1958 let Inst{22-20} = 0b001;
1959 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1960 let Inst{7-6} = 0b00;
1961 let Inst{5-4} = 0b11;
1962 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001963
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001964 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001965 !strconcat(opc, "wb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001966 [(set rGPR:$dst, (sra (opnode rGPR:$a,
1967 (sext_inreg rGPR:$b, i16)), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001968 let Inst{31-27} = 0b11111;
1969 let Inst{26-23} = 0b0110;
1970 let Inst{22-20} = 0b011;
1971 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1972 let Inst{7-6} = 0b00;
1973 let Inst{5-4} = 0b00;
1974 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001975
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001976 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001977 !strconcat(opc, "wt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001978 [(set rGPR:$dst, (sra (opnode rGPR:$a,
1979 (sra rGPR:$b, (i32 16))), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001980 let Inst{31-27} = 0b11111;
1981 let Inst{26-23} = 0b0110;
1982 let Inst{22-20} = 0b011;
1983 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1984 let Inst{7-6} = 0b00;
1985 let Inst{5-4} = 0b01;
1986 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001987}
1988
1989
1990multiclass T2I_smla<string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001991 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00001992 !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001993 [(set rGPR:$dst, (add rGPR:$acc,
1994 (opnode (sext_inreg rGPR:$a, i16),
1995 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001996 let Inst{31-27} = 0b11111;
1997 let Inst{26-23} = 0b0110;
1998 let Inst{22-20} = 0b001;
1999 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2000 let Inst{7-6} = 0b00;
2001 let Inst{5-4} = 0b00;
2002 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002003
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002004 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002005 !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002006 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sext_inreg rGPR:$a, i16),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002007 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002008 let Inst{31-27} = 0b11111;
2009 let Inst{26-23} = 0b0110;
2010 let Inst{22-20} = 0b001;
2011 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2012 let Inst{7-6} = 0b00;
2013 let Inst{5-4} = 0b01;
2014 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002015
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002016 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002017 !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002018 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002019 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002020 let Inst{31-27} = 0b11111;
2021 let Inst{26-23} = 0b0110;
2022 let Inst{22-20} = 0b001;
2023 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2024 let Inst{7-6} = 0b00;
2025 let Inst{5-4} = 0b10;
2026 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002027
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002028 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002029 !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002030 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002031 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002032 let Inst{31-27} = 0b11111;
2033 let Inst{26-23} = 0b0110;
2034 let Inst{22-20} = 0b001;
2035 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2036 let Inst{7-6} = 0b00;
2037 let Inst{5-4} = 0b11;
2038 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002039
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002040 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002041 !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002042 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002043 (sext_inreg rGPR:$b, i16)), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002044 let Inst{31-27} = 0b11111;
2045 let Inst{26-23} = 0b0110;
2046 let Inst{22-20} = 0b011;
2047 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2048 let Inst{7-6} = 0b00;
2049 let Inst{5-4} = 0b00;
2050 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002051
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002052 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002053 !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002054 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002055 (sra rGPR:$b, (i32 16))), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002056 let Inst{31-27} = 0b11111;
2057 let Inst{26-23} = 0b0110;
2058 let Inst{22-20} = 0b011;
2059 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2060 let Inst{7-6} = 0b00;
2061 let Inst{5-4} = 0b01;
2062 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002063}
2064
2065defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2066defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2067
Johnny Chenadc77332010-02-26 22:04:29 +00002068// Halfword multiple accumulate long: SMLAL<x><y> -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002069def t2SMLALBB : T2I_mac<1, 0b100, 0b1000, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002070 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002071 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002072def t2SMLALBT : T2I_mac<1, 0b100, 0b1001, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002073 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002074 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002075def t2SMLALTB : T2I_mac<1, 0b100, 0b1010, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002076 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002077 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002078def t2SMLALTT : T2I_mac<1, 0b100, 0b1011, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002079 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002080 [/* For disassembly only; pattern left blank */]>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002081
Johnny Chenadc77332010-02-26 22:04:29 +00002082// Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2083// These are for disassembly only.
2084
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002085def t2SMUAD: T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2086 IIC_iMAC32, "smuad", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002087 let Inst{15-12} = 0b1111;
2088}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002089def t2SMUADX:T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2090 IIC_iMAC32, "smuadx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002091 let Inst{15-12} = 0b1111;
2092}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002093def t2SMUSD: T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2094 IIC_iMAC32, "smusd", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002095 let Inst{15-12} = 0b1111;
2096}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002097def t2SMUSDX:T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2098 IIC_iMAC32, "smusdx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002099 let Inst{15-12} = 0b1111;
2100}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002101def t2SMLAD : T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst),
2102 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlad",
Johnny Chenadc77332010-02-26 22:04:29 +00002103 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002104def t2SMLADX : T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst),
2105 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smladx",
Johnny Chenadc77332010-02-26 22:04:29 +00002106 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002107def t2SMLSD : T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst),
2108 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsd",
Johnny Chenadc77332010-02-26 22:04:29 +00002109 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002110def t2SMLSDX : T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst),
2111 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsdx",
Johnny Chenadc77332010-02-26 22:04:29 +00002112 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002113def t2SMLALD : T2I_mac<1, 0b100, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2114 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlald",
Johnny Chenadc77332010-02-26 22:04:29 +00002115 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002116def t2SMLALDX : T2I_mac<1, 0b100, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2117 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002118 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002119def t2SMLSLD : T2I_mac<1, 0b101, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2120 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsld",
Johnny Chenadc77332010-02-26 22:04:29 +00002121 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002122def t2SMLSLDX : T2I_mac<1, 0b101, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2123 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002124 "\t$ldst, $hdst, $a, $b", []>;
Evan Chengf49810c2009-06-23 17:48:47 +00002125
2126//===----------------------------------------------------------------------===//
2127// Misc. Arithmetic Instructions.
2128//
2129
Jim Grosbach80dc1162010-02-16 21:23:02 +00002130class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2131 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00002132 : T2I<oops, iops, itin, opc, asm, pattern> {
2133 let Inst{31-27} = 0b11111;
2134 let Inst{26-22} = 0b01010;
2135 let Inst{21-20} = op1;
2136 let Inst{15-12} = 0b1111;
2137 let Inst{7-6} = 0b10;
2138 let Inst{5-4} = op2;
2139}
Evan Chengf49810c2009-06-23 17:48:47 +00002140
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002141def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
2142 "clz", "\t$dst, $src", [(set rGPR:$dst, (ctlz rGPR:$src))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002143
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002144def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Evan Chengf609bb82010-01-19 00:44:15 +00002145 "rbit", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002146 [(set rGPR:$dst, (ARMrbit rGPR:$src))]>;
Jim Grosbach3482c802010-01-18 19:58:49 +00002147
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002148def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002149 "rev", ".w\t$dst, $src", [(set rGPR:$dst, (bswap rGPR:$src))]>;
Johnny Chend68e1192009-12-15 17:24:14 +00002150
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002151def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002152 "rev16", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002153 [(set rGPR:$dst,
2154 (or (and (srl rGPR:$src, (i32 8)), 0xFF),
2155 (or (and (shl rGPR:$src, (i32 8)), 0xFF00),
2156 (or (and (srl rGPR:$src, (i32 8)), 0xFF0000),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002157 (and (shl rGPR:$src, (i32 8)), 0xFF000000)))))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002158
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002159def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002160 "revsh", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002161 [(set rGPR:$dst,
Evan Chengf49810c2009-06-23 17:48:47 +00002162 (sext_inreg
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002163 (or (srl (and rGPR:$src, 0xFF00), (i32 8)),
2164 (shl rGPR:$src, (i32 8))), i16))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002165
Bob Wilsonf955f292010-08-17 17:23:19 +00002166def t2PKHBT : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002167 IIC_iBITsi, "pkhbt", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002168 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF),
Bob Wilsonf955f292010-08-17 17:23:19 +00002169 (and (shl rGPR:$src2, lsl_amt:$sh),
Jim Grosbachb1dc3932010-05-05 20:44:35 +00002170 0xFFFF0000)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002171 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002172 let Inst{31-27} = 0b11101;
2173 let Inst{26-25} = 0b01;
2174 let Inst{24-20} = 0b01100;
2175 let Inst{5} = 0; // BT form
2176 let Inst{4} = 0;
2177}
Evan Cheng40289b02009-07-07 05:35:52 +00002178
2179// Alternate cases for PKHBT where identities eliminate some nodes.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002180def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2181 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002182 Requires<[HasT2ExtractPack, IsThumb2]>;
Bob Wilsonf955f292010-08-17 17:23:19 +00002183def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2184 (t2PKHBT rGPR:$src1, rGPR:$src2, (lsl_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002185 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Cheng40289b02009-07-07 05:35:52 +00002186
Bob Wilsondc66eda2010-08-16 22:26:55 +00002187// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2188// will match the pattern below.
Bob Wilsonf955f292010-08-17 17:23:19 +00002189def t2PKHTB : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
Evan Cheng7e1bf302010-09-29 00:27:46 +00002190 IIC_iBITsi, "pkhtb", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002191 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002192 (and (sra rGPR:$src2, asr_amt:$sh),
2193 0xFFFF)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002194 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002195 let Inst{31-27} = 0b11101;
2196 let Inst{26-25} = 0b01;
2197 let Inst{24-20} = 0b01100;
2198 let Inst{5} = 1; // TB form
2199 let Inst{4} = 0;
2200}
Evan Cheng40289b02009-07-07 05:35:52 +00002201
2202// Alternate cases for PKHTB where identities eliminate some nodes. Note that
2203// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilsondc66eda2010-08-16 22:26:55 +00002204def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
Bob Wilsonf955f292010-08-17 17:23:19 +00002205 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm16_31:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002206 Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002207def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002208 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2209 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm1_15:$sh))>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002210 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002211
2212//===----------------------------------------------------------------------===//
2213// Comparison Instructions...
2214//
Johnny Chend68e1192009-12-15 17:24:14 +00002215defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002216 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002217 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2218defm t2CMPz : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002219 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002220 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002221
Dan Gohman4b7dff92010-08-26 15:50:25 +00002222//FIXME: Disable CMN, as CCodes are backwards from compare expectations
2223// Compare-to-zero still works out, just not the relationals
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002224//defm t2CMN : T2I_cmp_irs<0b1000, "cmn",
2225// BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002226defm t2CMNz : T2I_cmp_irs<0b1000, "cmn",
Evan Cheng5d42c562010-09-29 00:49:25 +00002227 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Dan Gohman4b7dff92010-08-26 15:50:25 +00002228 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2229
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002230//def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2231// (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002232
2233def : T2Pat<(ARMcmpZ GPR:$src, t2_so_imm_neg:$imm),
2234 (t2CMNzri GPR:$src, t2_so_imm_neg:$imm)>;
Evan Chengf49810c2009-06-23 17:48:47 +00002235
Johnny Chend68e1192009-12-15 17:24:14 +00002236defm t2TST : T2I_cmp_irs<0b0000, "tst",
Evan Cheng5d42c562010-09-29 00:49:25 +00002237 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002238 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>>;
2239defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
Evan Cheng5d42c562010-09-29 00:49:25 +00002240 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Johnny Chend68e1192009-12-15 17:24:14 +00002241 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002242
Evan Chenge253c952009-07-07 20:39:03 +00002243// Conditional moves
2244// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach64171712010-02-16 21:07:46 +00002245// a two-value operand where a dag node expects two operands. :(
Evan Cheng875a6ac2010-11-12 22:42:47 +00002246let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002247def t2MOVCCr : T2I<(outs rGPR:$dst), (ins rGPR:$false, rGPR:$true), IIC_iCMOVr,
Evan Cheng699beba2009-10-27 00:08:59 +00002248 "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002249 [/*(set rGPR:$dst, (ARMcmov rGPR:$false, rGPR:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002250 RegConstraint<"$false = $dst"> {
2251 let Inst{31-27} = 0b11101;
2252 let Inst{26-25} = 0b01;
2253 let Inst{24-21} = 0b0010;
2254 let Inst{20} = 0; // The S bit.
2255 let Inst{19-16} = 0b1111; // Rn
2256 let Inst{14-12} = 0b000;
2257 let Inst{7-4} = 0b0000;
2258}
Evan Chenge253c952009-07-07 20:39:03 +00002259
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002260def t2MOVCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
Evan Cheng699beba2009-10-27 00:08:59 +00002261 IIC_iCMOVi, "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002262[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002263 RegConstraint<"$false = $dst"> {
2264 let Inst{31-27} = 0b11110;
2265 let Inst{25} = 0;
2266 let Inst{24-21} = 0b0010;
2267 let Inst{20} = 0; // The S bit.
2268 let Inst{19-16} = 0b1111; // Rn
2269 let Inst{15} = 0;
2270}
Evan Chengf49810c2009-06-23 17:48:47 +00002271
Jim Grosbacha4257162010-10-07 00:53:56 +00002272def t2MOVCCi16 : T2I<(outs rGPR:$dst), (ins rGPR:$false, i32imm:$src),
Evan Cheng875a6ac2010-11-12 22:42:47 +00002273 IIC_iCMOVi,
Jim Grosbacha4257162010-10-07 00:53:56 +00002274 "movw", "\t$dst, $src", []>,
2275 RegConstraint<"$false = $dst"> {
2276 let Inst{31-27} = 0b11110;
2277 let Inst{25} = 1;
2278 let Inst{24-21} = 0b0010;
2279 let Inst{20} = 0; // The S bit.
2280 let Inst{15} = 0;
2281}
2282
Evan Cheng875a6ac2010-11-12 22:42:47 +00002283def t2MVNCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
2284 IIC_iCMOVi, "mvn", ".w\t$dst, $true",
2285[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm_not:$true,
2286 imm:$cc, CCR:$ccr))*/]>,
2287 RegConstraint<"$false = $dst"> {
2288 let Inst{31-27} = 0b11110;
2289 let Inst{25} = 0;
2290 let Inst{24-21} = 0b0011;
2291 let Inst{20} = 0; // The S bit.
2292 let Inst{19-16} = 0b1111; // Rn
2293 let Inst{15} = 0;
2294}
2295
Johnny Chend68e1192009-12-15 17:24:14 +00002296class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
2297 string opc, string asm, list<dag> pattern>
2298 : T2I<oops, iops, itin, opc, asm, pattern> {
2299 let Inst{31-27} = 0b11101;
2300 let Inst{26-25} = 0b01;
2301 let Inst{24-21} = 0b0010;
2302 let Inst{20} = 0; // The S bit.
2303 let Inst{19-16} = 0b1111; // Rn
2304 let Inst{5-4} = opcod; // Shift type.
2305}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002306def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$dst),
2307 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002308 IIC_iCMOVsi, "lsl", ".w\t$dst, $true, $rhs", []>,
2309 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002310def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$dst),
2311 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002312 IIC_iCMOVsi, "lsr", ".w\t$dst, $true, $rhs", []>,
2313 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002314def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$dst),
2315 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002316 IIC_iCMOVsi, "asr", ".w\t$dst, $true, $rhs", []>,
2317 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002318def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$dst),
2319 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002320 IIC_iCMOVsi, "ror", ".w\t$dst, $true, $rhs", []>,
2321 RegConstraint<"$false = $dst">;
Owen Andersonf523e472010-09-23 23:45:25 +00002322} // neverHasSideEffects
Evan Cheng13f8b362009-08-01 01:43:45 +00002323
David Goodwin5e47a9a2009-06-30 18:04:13 +00002324//===----------------------------------------------------------------------===//
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002325// Atomic operations intrinsics
2326//
2327
2328// memory barriers protect the atomic sequences
2329let hasSideEffects = 1 in {
Bob Wilsonf74a4292010-10-30 00:54:37 +00002330def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2331 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
2332 Requires<[IsThumb, HasDB]> {
2333 bits<4> opt;
2334 let Inst{31-4} = 0xf3bf8f5;
2335 let Inst{3-0} = opt;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002336}
2337}
2338
Bob Wilsonf74a4292010-10-30 00:54:37 +00002339def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2340 "dsb", "\t$opt",
2341 [/* For disassembly only; pattern left blank */]>,
2342 Requires<[IsThumb, HasDB]> {
2343 bits<4> opt;
2344 let Inst{31-4} = 0xf3bf8f4;
2345 let Inst{3-0} = opt;
Johnny Chena4339822010-03-03 00:16:28 +00002346}
2347
Johnny Chena4339822010-03-03 00:16:28 +00002348// ISB has only full system option -- for disassembly only
Bob Wilsonf74a4292010-10-30 00:54:37 +00002349def t2ISB : T2I<(outs), (ins), NoItinerary, "isb", "",
2350 [/* For disassembly only; pattern left blank */]>,
2351 Requires<[IsThumb2, HasV7]> {
2352 let Inst{31-4} = 0xf3bf8f6;
Johnny Chena4339822010-03-03 00:16:28 +00002353 let Inst{3-0} = 0b1111;
2354}
2355
Johnny Chend68e1192009-12-15 17:24:14 +00002356class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2357 InstrItinClass itin, string opc, string asm, string cstr,
2358 list<dag> pattern, bits<4> rt2 = 0b1111>
2359 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2360 let Inst{31-27} = 0b11101;
2361 let Inst{26-20} = 0b0001101;
2362 let Inst{11-8} = rt2;
2363 let Inst{7-6} = 0b01;
2364 let Inst{5-4} = opcod;
2365 let Inst{3-0} = 0b1111;
2366}
2367class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2368 InstrItinClass itin, string opc, string asm, string cstr,
2369 list<dag> pattern, bits<4> rt2 = 0b1111>
2370 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2371 let Inst{31-27} = 0b11101;
2372 let Inst{26-20} = 0b0001100;
2373 let Inst{11-8} = rt2;
2374 let Inst{7-6} = 0b01;
2375 let Inst{5-4} = opcod;
2376}
2377
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002378let mayLoad = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002379def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002380 Size4Bytes, NoItinerary, "ldrexb", "\t$dest, [$ptr]",
2381 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002382def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002383 Size4Bytes, NoItinerary, "ldrexh", "\t$dest, [$ptr]",
2384 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002385def t2LDREX : Thumb2I<(outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002386 Size4Bytes, NoItinerary,
2387 "ldrex", "\t$dest, [$ptr]", "",
2388 []> {
2389 let Inst{31-27} = 0b11101;
2390 let Inst{26-20} = 0b0000101;
2391 let Inst{11-8} = 0b1111;
2392 let Inst{7-0} = 0b00000000; // imm8 = 0
2393}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002394def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$dest, rGPR:$dest2), (ins rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002395 AddrModeNone, Size4Bytes, NoItinerary,
2396 "ldrexd", "\t$dest, $dest2, [$ptr]", "",
2397 [], {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002398}
2399
Jim Grosbach587b0722009-12-16 19:44:06 +00002400let mayStore = 1, Constraints = "@earlyclobber $success" in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002401def t2STREXB : T2I_strex<0b00, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002402 AddrModeNone, Size4Bytes, NoItinerary,
2403 "strexb", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002404def t2STREXH : T2I_strex<0b01, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002405 AddrModeNone, Size4Bytes, NoItinerary,
2406 "strexh", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002407def t2STREX : Thumb2I<(outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002408 AddrModeNone, Size4Bytes, NoItinerary,
2409 "strex", "\t$success, $src, [$ptr]", "",
2410 []> {
2411 let Inst{31-27} = 0b11101;
2412 let Inst{26-20} = 0b0000100;
2413 let Inst{7-0} = 0b00000000; // imm8 = 0
2414}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002415def t2STREXD : T2I_strex<0b11, (outs rGPR:$success),
2416 (ins rGPR:$src, rGPR:$src2, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002417 AddrModeNone, Size4Bytes, NoItinerary,
2418 "strexd", "\t$success, $src, $src2, [$ptr]", "", [],
2419 {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002420}
2421
Johnny Chen10a77e12010-03-02 22:11:06 +00002422// Clear-Exclusive is for disassembly only.
2423def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "",
2424 [/* For disassembly only; pattern left blank */]>,
2425 Requires<[IsARM, HasV7]> {
2426 let Inst{31-20} = 0xf3b;
2427 let Inst{15-14} = 0b10;
2428 let Inst{12} = 0;
2429 let Inst{7-4} = 0b0010;
2430}
2431
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002432//===----------------------------------------------------------------------===//
David Goodwin334c2642009-07-08 16:09:28 +00002433// TLS Instructions
2434//
2435
2436// __aeabi_read_tp preserves the registers r1-r3.
2437let isCall = 1,
2438 Defs = [R0, R12, LR, CPSR] in {
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002439 def t2TPsoft : T2XI<(outs), (ins), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002440 "bl\t__aeabi_read_tp",
Johnny Chend68e1192009-12-15 17:24:14 +00002441 [(set R0, ARMthread_pointer)]> {
2442 let Inst{31-27} = 0b11110;
2443 let Inst{15-14} = 0b11;
2444 let Inst{12} = 1;
2445 }
David Goodwin334c2642009-07-08 16:09:28 +00002446}
2447
2448//===----------------------------------------------------------------------===//
Jim Grosbach5aa16842009-08-11 19:42:21 +00002449// SJLJ Exception handling intrinsics
Jim Grosbach1add6592009-08-13 15:11:43 +00002450// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach5aa16842009-08-11 19:42:21 +00002451// address and save #0 in R0 for the non-longjmp case.
2452// Since by its nature we may be coming from some other function to get
2453// here, and we're using the stack frame for the containing function to
2454// save/restore registers, we can't keep anything live in regs across
2455// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
2456// when we get here from a longjmp(). We force everthing out of registers
2457// except for our own input by listing the relevant registers in Defs. By
2458// doing so, we also cause the prologue/epilogue code to actively preserve
2459// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach0798edd2010-05-27 23:49:24 +00002460// $val is a scratch register for our use.
Jim Grosbacha87ded22010-02-08 23:22:00 +00002461let Defs =
Jim Grosbachf35d2162009-08-13 16:59:44 +00002462 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2463 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Jim Grosbach5aa16842009-08-11 19:42:21 +00002464 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002465 D31 ], hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002466 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002467 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002468 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002469 Requires<[IsThumb2, HasVFP2]>;
Jim Grosbach5aa16842009-08-11 19:42:21 +00002470}
2471
Bob Wilsonec80e262010-04-09 20:41:18 +00002472let Defs =
Jim Grosbach5caeff52010-05-28 17:37:40 +00002473 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ],
Chris Lattnera4a3a5e2010-10-31 19:15:18 +00002474 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002475 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach71d933a2010-09-30 16:56:53 +00002476 AddrModeNone, SizeSpecial, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002477 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002478 Requires<[IsThumb2, NoVFP]>;
2479}
Jim Grosbach5aa16842009-08-11 19:42:21 +00002480
2481
2482//===----------------------------------------------------------------------===//
David Goodwin5e47a9a2009-06-30 18:04:13 +00002483// Control-Flow Instructions
2484//
2485
Evan Chengc50a1cb2009-07-09 22:58:39 +00002486// FIXME: remove when we have a way to marking a MI with these properties.
2487// FIXME: $dst1 should be a def. But the extra ops must be in the end of the
2488// operand list.
2489// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng0d92f5f2009-10-01 08:22:27 +00002490let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
Chris Lattner39ee0362010-10-31 19:10:56 +00002491 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
Jim Grosbache6913602010-11-03 01:01:43 +00002492 def t2LDM_RET: T2XIt<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
2493 reglist:$dsts, variable_ops),
Evan Chenga0792de2010-10-06 06:27:31 +00002494 IIC_iLoad_mBr,
Jim Grosbache6913602010-11-03 01:01:43 +00002495 "ldm${amode}${p}.w\t$Rn!, $dsts",
2496 "$Rn = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002497 let Inst{31-27} = 0b11101;
2498 let Inst{26-25} = 0b00;
2499 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
2500 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00002501 let Inst{21} = 1; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00002502 let Inst{20} = 1; // Load
2503}
Evan Chengc50a1cb2009-07-09 22:58:39 +00002504
David Goodwin5e47a9a2009-06-30 18:04:13 +00002505let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
2506let isPredicable = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002507def t2B : T2XI<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002508 "b.w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002509 [(br bb:$target)]> {
2510 let Inst{31-27} = 0b11110;
2511 let Inst{15-14} = 0b10;
2512 let Inst{12} = 1;
2513}
David Goodwin5e47a9a2009-06-30 18:04:13 +00002514
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002515let isNotDuplicable = 1, isIndirectBranch = 1,
2516 isCodeGenOnly = 1 in { // $id doesn't exist in asmstring, should be lowered.
Evan Cheng66ac5312009-07-25 00:33:29 +00002517def t2BR_JT :
Evan Cheng5657c012009-07-29 02:18:14 +00002518 T2JTI<(outs),
2519 (ins GPR:$target, GPR:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002520 IIC_Br, "mov\tpc, $target$jt",
Johnny Chend68e1192009-12-15 17:24:14 +00002521 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]> {
2522 let Inst{31-27} = 0b11101;
2523 let Inst{26-20} = 0b0100100;
2524 let Inst{19-16} = 0b1111;
2525 let Inst{14-12} = 0b000;
2526 let Inst{11-8} = 0b1111; // Rd = pc
2527 let Inst{7-4} = 0b0000;
2528}
Evan Cheng5657c012009-07-29 02:18:14 +00002529
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002530// FIXME: Add a non-pc based case that can be predicated.
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002531let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002532def t2TBB :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002533 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002534 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002535 IIC_Br, "tbb\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002536 let Inst{31-27} = 0b11101;
2537 let Inst{26-20} = 0b0001101;
2538 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2539 let Inst{15-8} = 0b11110000;
2540 let Inst{7-4} = 0b0000; // B form
2541}
Evan Cheng5657c012009-07-29 02:18:14 +00002542
Chris Lattnera1ca91a2010-11-02 23:40:41 +00002543let isCodeGenOnly = 1 in // $id doesn't exist in asm string, should be lowered.
Evan Cheng5657c012009-07-29 02:18:14 +00002544def t2TBH :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002545 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002546 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002547 IIC_Br, "tbh\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002548 let Inst{31-27} = 0b11101;
2549 let Inst{26-20} = 0b0001101;
2550 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2551 let Inst{15-8} = 0b11110000;
2552 let Inst{7-4} = 0b0001; // H form
2553}
Johnny Chen93042d12010-03-02 18:14:57 +00002554
2555// Generic versions of the above two instructions, for disassembly only
2556
2557def t2TBBgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2558 "tbb", "\t[$a, $b]", []>{
2559 let Inst{31-27} = 0b11101;
2560 let Inst{26-20} = 0b0001101;
2561 let Inst{15-8} = 0b11110000;
2562 let Inst{7-4} = 0b0000; // B form
2563}
2564
2565def t2TBHgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2566 "tbh", "\t[$a, $b, lsl #1]", []> {
2567 let Inst{31-27} = 0b11101;
2568 let Inst{26-20} = 0b0001101;
2569 let Inst{15-8} = 0b11110000;
2570 let Inst{7-4} = 0b0001; // H form
2571}
Evan Cheng5657c012009-07-29 02:18:14 +00002572} // isNotDuplicable, isIndirectBranch
2573
David Goodwinc9a59b52009-06-30 19:50:22 +00002574} // isBranch, isTerminator, isBarrier
David Goodwin5e47a9a2009-06-30 18:04:13 +00002575
2576// FIXME: should be able to write a pattern for ARMBrcond, but can't use
2577// a two-value operand where a dag node expects two operands. :(
2578let isBranch = 1, isTerminator = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002579def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002580 "b", ".w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002581 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
2582 let Inst{31-27} = 0b11110;
2583 let Inst{15-14} = 0b10;
2584 let Inst{12} = 0;
2585}
Evan Chengf49810c2009-06-23 17:48:47 +00002586
Evan Cheng06e16582009-07-10 01:54:42 +00002587
2588// IT block
Evan Cheng86050dc2010-06-18 23:09:54 +00002589let Defs = [ITSTATE] in
Evan Cheng06e16582009-07-10 01:54:42 +00002590def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
David Goodwin5d598aa2009-08-19 18:00:44 +00002591 AddrModeNone, Size2Bytes, IIC_iALUx,
Johnny Chend68e1192009-12-15 17:24:14 +00002592 "it$mask\t$cc", "", []> {
2593 // 16-bit instruction.
Johnny Chenbbc71b22009-12-16 02:32:54 +00002594 let Inst{31-16} = 0x0000;
Johnny Chend68e1192009-12-15 17:24:14 +00002595 let Inst{15-8} = 0b10111111;
2596}
Evan Cheng06e16582009-07-10 01:54:42 +00002597
Johnny Chence6275f2010-02-25 19:05:29 +00002598// Branch and Exchange Jazelle -- for disassembly only
2599// Rm = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002600def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func",
Johnny Chence6275f2010-02-25 19:05:29 +00002601 [/* For disassembly only; pattern left blank */]> {
2602 let Inst{31-27} = 0b11110;
2603 let Inst{26} = 0;
2604 let Inst{25-20} = 0b111100;
2605 let Inst{15-14} = 0b10;
2606 let Inst{12} = 0;
2607}
2608
Johnny Chen93042d12010-03-02 18:14:57 +00002609// Change Processor State is a system instruction -- for disassembly only.
2610// The singleton $opt operand contains the following information:
2611// opt{4-0} = mode from Inst{4-0}
2612// opt{5} = changemode from Inst{17}
2613// opt{8-6} = AIF from Inst{8-6}
2614// opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002615def t2CPS : T2XI<(outs),(ins cps_opt:$opt), NoItinerary, "cps$opt",
Johnny Chen93042d12010-03-02 18:14:57 +00002616 [/* For disassembly only; pattern left blank */]> {
2617 let Inst{31-27} = 0b11110;
2618 let Inst{26} = 0;
2619 let Inst{25-20} = 0b111010;
2620 let Inst{15-14} = 0b10;
2621 let Inst{12} = 0;
2622}
2623
Johnny Chen0f7866e2010-03-03 02:09:43 +00002624// A6.3.4 Branches and miscellaneous control
2625// Table A6-14 Change Processor State, and hint instructions
2626// Helper class for disassembly only.
2627class T2I_hint<bits<8> op7_0, string opc, string asm>
2628 : T2I<(outs), (ins), NoItinerary, opc, asm,
2629 [/* For disassembly only; pattern left blank */]> {
2630 let Inst{31-20} = 0xf3a;
2631 let Inst{15-14} = 0b10;
2632 let Inst{12} = 0;
2633 let Inst{10-8} = 0b000;
2634 let Inst{7-0} = op7_0;
2635}
2636
2637def t2NOP : T2I_hint<0b00000000, "nop", ".w">;
2638def t2YIELD : T2I_hint<0b00000001, "yield", ".w">;
2639def t2WFE : T2I_hint<0b00000010, "wfe", ".w">;
2640def t2WFI : T2I_hint<0b00000011, "wfi", ".w">;
2641def t2SEV : T2I_hint<0b00000100, "sev", ".w">;
2642
2643def t2DBG : T2I<(outs),(ins i32imm:$opt), NoItinerary, "dbg", "\t$opt",
2644 [/* For disassembly only; pattern left blank */]> {
2645 let Inst{31-20} = 0xf3a;
2646 let Inst{15-14} = 0b10;
2647 let Inst{12} = 0;
2648 let Inst{10-8} = 0b000;
2649 let Inst{7-4} = 0b1111;
2650}
2651
Johnny Chen6341c5a2010-02-25 20:25:24 +00002652// Secure Monitor Call is a system instruction -- for disassembly only
2653// Option = Inst{19-16}
2654def t2SMC : T2I<(outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
2655 [/* For disassembly only; pattern left blank */]> {
2656 let Inst{31-27} = 0b11110;
2657 let Inst{26-20} = 0b1111111;
2658 let Inst{15-12} = 0b1000;
2659}
2660
2661// Store Return State is a system instruction -- for disassembly only
2662def t2SRSDBW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp!, $mode",
2663 [/* For disassembly only; pattern left blank */]> {
2664 let Inst{31-27} = 0b11101;
2665 let Inst{26-20} = 0b0000010; // W = 1
2666}
2667
2668def t2SRSDB : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp, $mode",
2669 [/* For disassembly only; pattern left blank */]> {
2670 let Inst{31-27} = 0b11101;
2671 let Inst{26-20} = 0b0000000; // W = 0
2672}
2673
2674def t2SRSIAW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsia","\tsp!, $mode",
2675 [/* For disassembly only; pattern left blank */]> {
2676 let Inst{31-27} = 0b11101;
2677 let Inst{26-20} = 0b0011010; // W = 1
2678}
2679
2680def t2SRSIA : T2I<(outs), (ins i32imm:$mode),NoItinerary,"srsia","\tsp, $mode",
2681 [/* For disassembly only; pattern left blank */]> {
2682 let Inst{31-27} = 0b11101;
2683 let Inst{26-20} = 0b0011000; // W = 0
2684}
2685
2686// Return From Exception is a system instruction -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002687def t2RFEDBW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfedb", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002688 [/* For disassembly only; pattern left blank */]> {
2689 let Inst{31-27} = 0b11101;
2690 let Inst{26-20} = 0b0000011; // W = 1
2691}
2692
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002693def t2RFEDB : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeab", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002694 [/* For disassembly only; pattern left blank */]> {
2695 let Inst{31-27} = 0b11101;
2696 let Inst{26-20} = 0b0000001; // W = 0
2697}
2698
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002699def t2RFEIAW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002700 [/* For disassembly only; pattern left blank */]> {
2701 let Inst{31-27} = 0b11101;
2702 let Inst{26-20} = 0b0011011; // W = 1
2703}
2704
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002705def t2RFEIA : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002706 [/* For disassembly only; pattern left blank */]> {
2707 let Inst{31-27} = 0b11101;
2708 let Inst{26-20} = 0b0011001; // W = 0
2709}
2710
Evan Chengf49810c2009-06-23 17:48:47 +00002711//===----------------------------------------------------------------------===//
2712// Non-Instruction Patterns
2713//
2714
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002715// Two piece so_imms.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002716def : T2Pat<(or rGPR:$LHS, t2_so_imm2part:$RHS),
2717 (t2ORRri (t2ORRri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002718 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002719def : T2Pat<(xor rGPR:$LHS, t2_so_imm2part:$RHS),
2720 (t2EORri (t2EORri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002721 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002722def : T2Pat<(add rGPR:$LHS, t2_so_imm2part:$RHS),
2723 (t2ADDri (t2ADDri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002724 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002725def : T2Pat<(add rGPR:$LHS, t2_so_neg_imm2part:$RHS),
2726 (t2SUBri (t2SUBri rGPR:$LHS, (t2_so_neg_imm2part_1 imm:$RHS)),
Jim Grosbach15e6ef82009-11-23 20:35:53 +00002727 (t2_so_neg_imm2part_2 imm:$RHS))>;
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002728
Evan Cheng5adb66a2009-09-28 09:14:39 +00002729// 32-bit immediate using movw + movt.
Evan Cheng5be39222010-09-24 22:03:46 +00002730// This is a single pseudo instruction to make it re-materializable.
2731// FIXME: Remove this when we can do generalized remat.
Evan Cheng5adb66a2009-09-28 09:14:39 +00002732let isReMaterializable = 1 in
Jim Grosbach3c38f962010-10-06 22:01:26 +00002733def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
2734 "", [(set rGPR:$dst, (i32 imm:$src))]>,
2735 Requires<[IsThumb, HasV6T2]>;
Evan Chengb9803a82009-11-06 23:52:48 +00002736
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +00002737// ConstantPool, GlobalAddress, and JumpTable
2738def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
2739 Requires<[IsThumb2, DontUseMovt]>;
2740def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
2741def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
2742 Requires<[IsThumb2, UseMovt]>;
2743
2744def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
2745 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
2746
Evan Chengb9803a82009-11-06 23:52:48 +00002747// Pseudo instruction that combines ldr from constpool and add pc. This should
2748// be expanded into two instructions late to allow if-conversion and
2749// scheduling.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00002750let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Chengb9803a82009-11-06 23:52:48 +00002751def t2LDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp),
Jim Grosbach78890f42010-10-01 23:21:38 +00002752 IIC_iLoadiALU, "",
Evan Chengb9803a82009-11-06 23:52:48 +00002753 [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
2754 imm:$cp))]>,
2755 Requires<[IsThumb2]>;
Johnny Chen23336552010-02-25 18:46:43 +00002756
2757//===----------------------------------------------------------------------===//
2758// Move between special register and ARM core register -- for disassembly only
2759//
2760
2761// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002762def t2MRS : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, cpsr",
Johnny Chen23336552010-02-25 18:46:43 +00002763 [/* For disassembly only; pattern left blank */]> {
2764 let Inst{31-27} = 0b11110;
2765 let Inst{26} = 0;
2766 let Inst{25-21} = 0b11111;
2767 let Inst{20} = 0; // The R bit.
2768 let Inst{15-14} = 0b10;
2769 let Inst{12} = 0;
2770}
2771
2772// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002773def t2MRSsys : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, spsr",
Johnny Chen23336552010-02-25 18:46:43 +00002774 [/* For disassembly only; pattern left blank */]> {
2775 let Inst{31-27} = 0b11110;
2776 let Inst{26} = 0;
2777 let Inst{25-21} = 0b11111;
2778 let Inst{20} = 1; // The R bit.
2779 let Inst{15-14} = 0b10;
2780 let Inst{12} = 0;
2781}
2782
Johnny Chen23336552010-02-25 18:46:43 +00002783// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002784def t2MSR : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002785 "\tcpsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00002786 [/* For disassembly only; pattern left blank */]> {
2787 let Inst{31-27} = 0b11110;
2788 let Inst{26} = 0;
2789 let Inst{25-21} = 0b11100;
2790 let Inst{20} = 0; // The R bit.
2791 let Inst{15-14} = 0b10;
2792 let Inst{12} = 0;
2793}
2794
Johnny Chen23336552010-02-25 18:46:43 +00002795// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002796def t2MSRsys : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002797 "\tspsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00002798 [/* For disassembly only; pattern left blank */]> {
2799 let Inst{31-27} = 0b11110;
2800 let Inst{26} = 0;
2801 let Inst{25-21} = 0b11100;
2802 let Inst{20} = 1; // The R bit.
2803 let Inst{15-14} = 0b10;
2804 let Inst{12} = 0;
2805}