blob: df58a1e640feb29d6e03a989141ae8c6b4e1dd4c [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]> {
Evan Cheng9cb9e672009-06-27 02:26:13 +000034 let PrintMethod = "printT2SOOperand";
Jim Grosbach6ccfc502010-07-30 02:41:01 +000035 let MIOperandInfo = (ops rGPR, i32imm);
Anton Korobeynikov52237112009-06-17 18:13:58 +000036}
37
Evan Chengf49810c2009-06-23 17:48:47 +000038// t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
39def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{
Owen Anderson825b72b2009-08-11 20:47:22 +000040 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
Anton Korobeynikov52237112009-06-17 18:13:58 +000041}]>;
42
Evan Chengf49810c2009-06-23 17:48:47 +000043// t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
44def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
Owen Anderson825b72b2009-08-11 20:47:22 +000045 return CurDAG->getTargetConstant(-((int)N->getZExtValue()), MVT::i32);
Evan Chengf49810c2009-06-23 17:48:47 +000046}]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +000047
Evan Chengf49810c2009-06-23 17:48:47 +000048// t2_so_imm - Match a 32-bit immediate operand, which is an
49// 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
50// immediate splatted into multiple bytes of the word. t2_so_imm values are
51// represented in the imm field in the same 12-bit form that they are encoded
Jim Grosbach6935efc2009-11-24 00:20:27 +000052// into t2_so_imm instructions: the 8-bit immediate is the least significant
53// bits [bits 0-7], the 4-bit shift/splat amount is the next 4 bits [bits 8-11].
Jakob Stoklund Olesen00d3dda2010-08-17 20:39:04 +000054def t2_so_imm : Operand<i32>, PatLeaf<(imm), [{ return Pred_t2_so_imm(N); }]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +000055
Jim Grosbach64171712010-02-16 21:07:46 +000056// t2_so_imm_not - Match an immediate that is a complement
Evan Chengf49810c2009-06-23 17:48:47 +000057// of a t2_so_imm.
58def t2_so_imm_not : Operand<i32>,
59 PatLeaf<(imm), [{
Evan Chenge7cbe412009-07-08 21:03:57 +000060 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
61}], t2_so_imm_not_XFORM>;
Evan Chengf49810c2009-06-23 17:48:47 +000062
63// t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
64def t2_so_imm_neg : Operand<i32>,
65 PatLeaf<(imm), [{
Evan Chenge7cbe412009-07-08 21:03:57 +000066 return ARM_AM::getT2SOImmVal(-((int)N->getZExtValue())) != -1;
67}], t2_so_imm_neg_XFORM>;
Evan Chengf49810c2009-06-23 17:48:47 +000068
Jim Grosbach65b7f3a2009-10-21 20:44:34 +000069// Break t2_so_imm's up into two pieces. This handles immediates with up to 16
70// bits set in them. This uses t2_so_imm2part to match and t2_so_imm2part_[12]
71// to get the first/second pieces.
72def t2_so_imm2part : Operand<i32>,
73 PatLeaf<(imm), [{
74 return ARM_AM::isT2SOImmTwoPartVal((unsigned)N->getZExtValue());
75 }]> {
76}
77
78def t2_so_imm2part_1 : SDNodeXForm<imm, [{
79 unsigned V = ARM_AM::getT2SOImmTwoPartFirst((unsigned)N->getZExtValue());
80 return CurDAG->getTargetConstant(V, MVT::i32);
81}]>;
82
83def t2_so_imm2part_2 : SDNodeXForm<imm, [{
84 unsigned V = ARM_AM::getT2SOImmTwoPartSecond((unsigned)N->getZExtValue());
85 return CurDAG->getTargetConstant(V, MVT::i32);
86}]>;
87
Jim Grosbach15e6ef82009-11-23 20:35:53 +000088def t2_so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
89 return ARM_AM::isT2SOImmTwoPartVal(-(int)N->getZExtValue());
90 }]> {
91}
92
93def t2_so_neg_imm2part_1 : SDNodeXForm<imm, [{
94 unsigned V = ARM_AM::getT2SOImmTwoPartFirst(-(int)N->getZExtValue());
95 return CurDAG->getTargetConstant(V, MVT::i32);
96}]>;
97
98def t2_so_neg_imm2part_2 : SDNodeXForm<imm, [{
99 unsigned V = ARM_AM::getT2SOImmTwoPartSecond(-(int)N->getZExtValue());
100 return CurDAG->getTargetConstant(V, MVT::i32);
101}]>;
102
Evan Chenga67efd12009-06-23 19:39:13 +0000103/// imm1_31 predicate - True if the 32-bit immediate is in the range [1,31].
104def imm1_31 : PatLeaf<(i32 imm), [{
105 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 32;
106}]>;
107
Evan Chengf49810c2009-06-23 17:48:47 +0000108/// imm0_4095 predicate - True if the 32-bit immediate is in the range [0.4095].
Evan Cheng86198642009-08-07 00:34:42 +0000109def imm0_4095 : Operand<i32>,
110 PatLeaf<(i32 imm), [{
Evan Chengf49810c2009-06-23 17:48:47 +0000111 return (uint32_t)N->getZExtValue() < 4096;
112}]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000113
Jim Grosbach64171712010-02-16 21:07:46 +0000114def imm0_4095_neg : PatLeaf<(i32 imm), [{
115 return (uint32_t)(-N->getZExtValue()) < 4096;
116}], imm_neg_XFORM>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000117
Evan Chengfa2ea1a2009-08-04 01:41:15 +0000118def imm0_255_neg : PatLeaf<(i32 imm), [{
119 return (uint32_t)(-N->getZExtValue()) < 255;
Jim Grosbach64171712010-02-16 21:07:46 +0000120}], imm_neg_XFORM>;
Evan Chengfa2ea1a2009-08-04 01:41:15 +0000121
Jim Grosbach502e0aa2010-07-14 17:45:16 +0000122def imm0_255_not : PatLeaf<(i32 imm), [{
123 return (uint32_t)(~N->getZExtValue()) < 255;
124}], imm_comp_XFORM>;
125
Evan Cheng055b0312009-06-29 07:51:04 +0000126// Define Thumb2 specific addressing modes.
127
128// t2addrmode_imm12 := reg + imm12
129def t2addrmode_imm12 : Operand<i32>,
130 ComplexPattern<i32, 2, "SelectT2AddrModeImm12", []> {
131 let PrintMethod = "printT2AddrModeImm12Operand";
132 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
133}
134
Johnny Chen0635fc52010-03-04 17:40:44 +0000135// t2addrmode_imm8 := reg +/- imm8
Evan Cheng055b0312009-06-29 07:51:04 +0000136def t2addrmode_imm8 : Operand<i32>,
137 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
138 let PrintMethod = "printT2AddrModeImm8Operand";
139 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
140}
141
Evan Cheng6d94f112009-07-03 00:06:39 +0000142def t2am_imm8_offset : Operand<i32>,
143 ComplexPattern<i32, 1, "SelectT2AddrModeImm8Offset", []>{
Evan Chenge88d5ce2009-07-02 07:28:31 +0000144 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
145}
146
Evan Cheng5c874172009-07-09 22:21:59 +0000147// t2addrmode_imm8s4 := reg +/- (imm8 << 2)
David Goodwin6647cea2009-06-30 22:50:01 +0000148def t2addrmode_imm8s4 : Operand<i32>,
149 ComplexPattern<i32, 2, "SelectT2AddrModeImm8s4", []> {
Evan Cheng5c874172009-07-09 22:21:59 +0000150 let PrintMethod = "printT2AddrModeImm8s4Operand";
David Goodwin6647cea2009-06-30 22:50:01 +0000151 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
152}
153
Johnny Chenae1757b2010-03-11 01:13:36 +0000154def t2am_imm8s4_offset : Operand<i32> {
155 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand";
156}
157
Evan Chengcba962d2009-07-09 20:40:44 +0000158// t2addrmode_so_reg := reg + (reg << imm2)
Evan Cheng055b0312009-06-29 07:51:04 +0000159def t2addrmode_so_reg : Operand<i32>,
160 ComplexPattern<i32, 3, "SelectT2AddrModeSoReg", []> {
161 let PrintMethod = "printT2AddrModeSoRegOperand";
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000162 let MIOperandInfo = (ops GPR:$base, rGPR:$offsreg, i32imm:$offsimm);
Evan Cheng055b0312009-06-29 07:51:04 +0000163}
164
165
Anton Korobeynikov52237112009-06-17 18:13:58 +0000166//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000167// Multiclass helpers...
Anton Korobeynikov52237112009-06-17 18:13:58 +0000168//
169
Evan Chenga67efd12009-06-23 19:39:13 +0000170/// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000171/// unary operation that produces a value. These are predicable and can be
172/// changed to modify CPSR.
Johnny Chend68e1192009-12-15 17:24:14 +0000173multiclass T2I_un_irs<bits<4> opcod, string opc, PatFrag opnode,
174 bit Cheap = 0, bit ReMat = 0> {
Evan Chenga67efd12009-06-23 19:39:13 +0000175 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000176 def i : T2sI<(outs rGPR:$dst), (ins t2_so_imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +0000177 opc, "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000178 [(set rGPR:$dst, (opnode t2_so_imm:$src))]> {
Evan Chenga67efd12009-06-23 19:39:13 +0000179 let isAsCheapAsAMove = Cheap;
180 let isReMaterializable = ReMat;
Johnny Chend68e1192009-12-15 17:24:14 +0000181 let Inst{31-27} = 0b11110;
182 let Inst{25} = 0;
183 let Inst{24-21} = opcod;
184 let Inst{20} = ?; // The S bit.
185 let Inst{19-16} = 0b1111; // Rn
186 let Inst{15} = 0;
Evan Chenga67efd12009-06-23 19:39:13 +0000187 }
188 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000189 def r : T2sI<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVr,
Bob Wilsonc21763f2010-05-24 22:41:19 +0000190 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000191 [(set rGPR:$dst, (opnode rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000192 let Inst{31-27} = 0b11101;
193 let Inst{26-25} = 0b01;
194 let Inst{24-21} = opcod;
195 let Inst{20} = ?; // The S bit.
196 let Inst{19-16} = 0b1111; // Rn
197 let Inst{14-12} = 0b000; // imm3
198 let Inst{7-6} = 0b00; // imm2
199 let Inst{5-4} = 0b00; // type
200 }
Evan Chenga67efd12009-06-23 19:39:13 +0000201 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000202 def s : T2sI<(outs rGPR:$dst), (ins t2_so_reg:$src), IIC_iMOVsi,
Bob Wilsonc21763f2010-05-24 22:41:19 +0000203 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000204 [(set rGPR:$dst, (opnode t2_so_reg:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000205 let Inst{31-27} = 0b11101;
206 let Inst{26-25} = 0b01;
207 let Inst{24-21} = opcod;
208 let Inst{20} = ?; // The S bit.
209 let Inst{19-16} = 0b1111; // Rn
210 }
Evan Chenga67efd12009-06-23 19:39:13 +0000211}
212
213/// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
Bob Wilson4876bdb2010-05-25 04:43:08 +0000214/// binary operation that produces a value. These are predicable and can be
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000215/// changed to modify CPSR.
Jim Grosbach64171712010-02-16 21:07:46 +0000216multiclass T2I_bin_irs<bits<4> opcod, string opc, PatFrag opnode,
Bill Wendling4822bce2010-08-30 01:47:35 +0000217 bit Commutable = 0, string wide = ""> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000218 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000219 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_imm:$rhs), IIC_iALUi,
Evan Cheng699beba2009-10-27 00:08:59 +0000220 opc, "\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000221 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_imm:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000222 let Inst{31-27} = 0b11110;
223 let Inst{25} = 0;
224 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000225 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000226 let Inst{15} = 0;
227 }
Evan Chenga67efd12009-06-23 19:39:13 +0000228 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000229 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs), IIC_iALUr,
Evan Cheng699beba2009-10-27 00:08:59 +0000230 opc, !strconcat(wide, "\t$dst, $lhs, $rhs"),
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000231 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000232 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000233 let Inst{31-27} = 0b11101;
234 let Inst{26-25} = 0b01;
235 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000236 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000237 let Inst{14-12} = 0b000; // imm3
238 let Inst{7-6} = 0b00; // imm2
239 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000240 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000241 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000242 def rs : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000243 opc, !strconcat(wide, "\t$dst, $lhs, $rhs"),
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000244 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_reg:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000245 let Inst{31-27} = 0b11101;
246 let Inst{26-25} = 0b01;
247 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000248 let Inst{20} = ?; // The S bit.
249 }
250}
251
252/// T2I_bin_cpsr_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for
253/// a binary operation that produces a value. These are predicable and modify
254/// CPSR.
255multiclass T2I_bin_cpsr_irs<bits<4> opcod, string opc, PatFrag opnode,
256 bit Commutable = 0, string wide = ""> {
257 // shifted imm
258 def ri : T2sI_cpsr<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_imm:$rhs),
259 IIC_iALUi, opc, "\t$dst, $lhs, $rhs",
260 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_imm:$rhs))]> {
261 let Inst{31-27} = 0b11110;
262 let Inst{25} = 0;
263 let Inst{24-21} = opcod;
264 let Inst{20} = 1; // The S bit.
265 let Inst{15} = 0;
266 }
267 // register
268 def rr : T2sI_cpsr<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs),
269 IIC_iALUr, opc, !strconcat(wide, "\t$dst, $lhs, $rhs"),
270 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> {
271 let isCommutable = Commutable;
272 let Inst{31-27} = 0b11101;
273 let Inst{26-25} = 0b01;
274 let Inst{24-21} = opcod;
275 let Inst{20} = 1; // The S bit.
276 let Inst{14-12} = 0b000; // imm3
277 let Inst{7-6} = 0b00; // imm2
278 let Inst{5-4} = 0b00; // type
279 }
280 // shifted register
281 def rs : T2sI_cpsr<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_reg:$rhs),
282 IIC_iALUsi, opc, !strconcat(wide, "\t$dst, $lhs, $rhs"),
283 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_reg:$rhs))]> {
284 let Inst{31-27} = 0b11101;
285 let Inst{26-25} = 0b01;
286 let Inst{24-21} = opcod;
287 let Inst{20} = 1; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000288 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000289}
290
David Goodwin1f096272009-07-27 23:34:12 +0000291/// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
292// the ".w" prefix to indicate that they are wide.
Johnny Chend68e1192009-12-15 17:24:14 +0000293multiclass T2I_bin_w_irs<bits<4> opcod, string opc, PatFrag opnode,
294 bit Commutable = 0> :
Bill Wendling4822bce2010-08-30 01:47:35 +0000295 T2I_bin_irs<opcod, opc, opnode, Commutable, ".w">;
Bill Wendling1f7bf0e2010-08-29 03:55:31 +0000296
297/// T2I_bin_sw_irs - Same as T2I_bin_w_irs except these operations set
298// the 'S' bit.
299multiclass T2I_bin_sw_irs<bits<4> opcod, string opc, PatFrag opnode,
300 bit Commutable = 0> :
Bill Wendling4822bce2010-08-30 01:47:35 +0000301 T2I_bin_cpsr_irs<opcod, opc, opnode, Commutable, ".w">;
David Goodwin1f096272009-07-27 23:34:12 +0000302
Evan Cheng1e249e32009-06-25 20:59:23 +0000303/// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000304/// reversed. The 'rr' form is only defined for the disassembler; for codegen
305/// it is equivalent to the T2I_bin_irs counterpart.
306multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000307 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000308 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_imm:$lhs), IIC_iALUi,
Bob Wilson4876bdb2010-05-25 04:43:08 +0000309 opc, ".w\t$dst, $rhs, $lhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000310 [(set rGPR:$dst, (opnode t2_so_imm:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000311 let Inst{31-27} = 0b11110;
312 let Inst{25} = 0;
313 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000314 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000315 let Inst{15} = 0;
316 }
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000317 // register
318 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, rGPR:$lhs), IIC_iALUr,
319 opc, "\t$dst, $rhs, $lhs",
Bob Wilson136e4912010-08-14 03:18:29 +0000320 [/* For disassembly only; pattern left blank */]> {
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000321 let Inst{31-27} = 0b11101;
322 let Inst{26-25} = 0b01;
323 let Inst{24-21} = opcod;
324 let Inst{20} = ?; // The S bit.
325 let Inst{14-12} = 0b000; // imm3
326 let Inst{7-6} = 0b00; // imm2
327 let Inst{5-4} = 0b00; // type
328 }
Evan Chengf49810c2009-06-23 17:48:47 +0000329 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000330 def rs : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_reg:$lhs), IIC_iALUsi,
Bob Wilson4876bdb2010-05-25 04:43:08 +0000331 opc, "\t$dst, $rhs, $lhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000332 [(set rGPR:$dst, (opnode t2_so_reg:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000333 let Inst{31-27} = 0b11101;
334 let Inst{26-25} = 0b01;
335 let Inst{24-21} = opcod;
Bob Wilson4876bdb2010-05-25 04:43:08 +0000336 let Inst{20} = ?; // The S bit.
Johnny Chend68e1192009-12-15 17:24:14 +0000337 }
Evan Chengf49810c2009-06-23 17:48:47 +0000338}
339
Evan Chenga67efd12009-06-23 19:39:13 +0000340/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
Anton Korobeynikov52237112009-06-17 18:13:58 +0000341/// instruction modifies the CPSR register.
342let Defs = [CPSR] in {
Johnny Chend68e1192009-12-15 17:24:14 +0000343multiclass T2I_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode,
344 bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000345 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000346 def ri : T2I<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi,
Evan Cheng699beba2009-10-27 00:08:59 +0000347 !strconcat(opc, "s"), ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000348 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000349 let Inst{31-27} = 0b11110;
350 let Inst{25} = 0;
351 let Inst{24-21} = opcod;
352 let Inst{20} = 1; // The S bit.
353 let Inst{15} = 0;
354 }
Evan Chenga67efd12009-06-23 19:39:13 +0000355 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000356 def rr : T2I<(outs rGPR:$dst), (ins GPR:$lhs, rGPR:$rhs), IIC_iALUr,
Evan Cheng699beba2009-10-27 00:08:59 +0000357 !strconcat(opc, "s"), ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000358 [(set rGPR:$dst, (opnode GPR:$lhs, rGPR:$rhs))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000359 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000360 let Inst{31-27} = 0b11101;
361 let Inst{26-25} = 0b01;
362 let Inst{24-21} = opcod;
363 let Inst{20} = 1; // The S bit.
364 let Inst{14-12} = 0b000; // imm3
365 let Inst{7-6} = 0b00; // imm2
366 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000367 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000368 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000369 def rs : T2I<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000370 !strconcat(opc, "s"), ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000371 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000372 let Inst{31-27} = 0b11101;
373 let Inst{26-25} = 0b01;
374 let Inst{24-21} = opcod;
375 let Inst{20} = 1; // The S bit.
376 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000377}
378}
379
Evan Chenga67efd12009-06-23 19:39:13 +0000380/// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
381/// patterns for a binary operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000382multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
383 bit Commutable = 0> {
Evan Chengf49810c2009-06-23 17:48:47 +0000384 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000385 def ri : T2sI<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi,
Evan Cheng699beba2009-10-27 00:08:59 +0000386 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000387 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000388 let Inst{31-27} = 0b11110;
389 let Inst{25} = 0;
390 let Inst{24} = 1;
391 let Inst{23-21} = op23_21;
392 let Inst{20} = 0; // The S bit.
393 let Inst{15} = 0;
394 }
Evan Chengf49810c2009-06-23 17:48:47 +0000395 // 12-bit imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000396 def ri12 : T2I<(outs rGPR:$dst), (ins GPR:$lhs, imm0_4095:$rhs), IIC_iALUi,
Bob Wilsonf5fd4992010-03-08 22:56:15 +0000397 !strconcat(opc, "w"), "\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000398 [(set rGPR:$dst, (opnode GPR:$lhs, imm0_4095:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000399 let Inst{31-27} = 0b11110;
400 let Inst{25} = 1;
401 let Inst{24} = 0;
402 let Inst{23-21} = op23_21;
403 let Inst{20} = 0; // The S bit.
404 let Inst{15} = 0;
405 }
Evan Chenga67efd12009-06-23 19:39:13 +0000406 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000407 def rr : T2sI<(outs rGPR:$dst), (ins GPR:$lhs, rGPR:$rhs), IIC_iALUr,
Evan Cheng699beba2009-10-27 00:08:59 +0000408 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000409 [(set rGPR:$dst, (opnode GPR:$lhs, rGPR:$rhs))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000410 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000411 let Inst{31-27} = 0b11101;
412 let Inst{26-25} = 0b01;
413 let Inst{24} = 1;
414 let Inst{23-21} = op23_21;
415 let Inst{20} = 0; // The S bit.
416 let Inst{14-12} = 0b000; // imm3
417 let Inst{7-6} = 0b00; // imm2
418 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000419 }
Evan Chengf49810c2009-06-23 17:48:47 +0000420 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000421 def rs : T2sI<(outs rGPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000422 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000423 [(set rGPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000424 let Inst{31-27} = 0b11101;
Johnny Chend68e1192009-12-15 17:24:14 +0000425 let Inst{26-25} = 0b01;
Johnny Chend248ffb2010-01-08 17:41:33 +0000426 let Inst{24} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000427 let Inst{23-21} = op23_21;
428 let Inst{20} = 0; // The S bit.
429 }
Evan Chengf49810c2009-06-23 17:48:47 +0000430}
431
Jim Grosbach6935efc2009-11-24 00:20:27 +0000432/// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000433/// for a binary operation that produces a value and use the carry
Jim Grosbach6935efc2009-11-24 00:20:27 +0000434/// bit. It's not predicable.
Evan Cheng62674222009-06-25 23:34:10 +0000435let Uses = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000436multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
437 bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000438 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000439 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_imm:$rhs), IIC_iALUi,
Evan Cheng699beba2009-10-27 00:08:59 +0000440 opc, "\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000441 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_imm:$rhs))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000442 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000443 let Inst{31-27} = 0b11110;
444 let Inst{25} = 0;
445 let Inst{24-21} = opcod;
446 let Inst{20} = 0; // The S bit.
447 let Inst{15} = 0;
448 }
Evan Chenga67efd12009-06-23 19:39:13 +0000449 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000450 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs), IIC_iALUr,
Evan Cheng699beba2009-10-27 00:08:59 +0000451 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000452 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000453 Requires<[IsThumb2]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000454 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000455 let Inst{31-27} = 0b11101;
456 let Inst{26-25} = 0b01;
457 let Inst{24-21} = opcod;
458 let Inst{20} = 0; // The S bit.
459 let Inst{14-12} = 0b000; // imm3
460 let Inst{7-6} = 0b00; // imm2
461 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000462 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000463 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000464 def rs : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000465 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000466 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_reg:$rhs))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000467 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000468 let Inst{31-27} = 0b11101;
469 let Inst{26-25} = 0b01;
470 let Inst{24-21} = opcod;
471 let Inst{20} = 0; // The S bit.
472 }
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000473}
474
475// Carry setting variants
476let Defs = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000477multiclass T2I_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
478 bit Commutable = 0> {
Evan Cheng62674222009-06-25 23:34:10 +0000479 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000480 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_imm:$rhs), IIC_iALUi,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000481 opc, "\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000482 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_imm:$rhs))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000483 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000484 let Inst{31-27} = 0b11110;
485 let Inst{25} = 0;
486 let Inst{24-21} = opcod;
487 let Inst{20} = 1; // The S bit.
488 let Inst{15} = 0;
489 }
Evan Cheng62674222009-06-25 23:34:10 +0000490 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000491 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs), IIC_iALUr,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000492 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000493 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000494 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000495 let isCommutable = Commutable;
496 let Inst{31-27} = 0b11101;
497 let Inst{26-25} = 0b01;
498 let Inst{24-21} = opcod;
499 let Inst{20} = 1; // The S bit.
500 let Inst{14-12} = 0b000; // imm3
501 let Inst{7-6} = 0b00; // imm2
502 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000503 }
Evan Cheng62674222009-06-25 23:34:10 +0000504 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000505 def rs : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000506 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000507 [(set rGPR:$dst, (opnode rGPR:$lhs, t2_so_reg:$rhs))]>,
Johnny Chenb5031ad2010-03-02 19:38:59 +0000508 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000509 let Inst{31-27} = 0b11101;
510 let Inst{26-25} = 0b01;
511 let Inst{24-21} = opcod;
512 let Inst{20} = 1; // The S bit.
Evan Cheng8de898a2009-06-26 00:19:44 +0000513 }
Evan Chengf49810c2009-06-23 17:48:47 +0000514}
515}
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000516}
Evan Chengf49810c2009-06-23 17:48:47 +0000517
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000518/// T2I_rbin_s_is - Same as T2I_rbin_irs except sets 's' bit and the register
519/// version is not needed since this is only for codegen.
Evan Cheng1e249e32009-06-25 20:59:23 +0000520let Defs = [CPSR] in {
Johnny Chend68e1192009-12-15 17:24:14 +0000521multiclass T2I_rbin_s_is<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000522 // shifted imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000523 def ri : T2I<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_imm:$lhs), IIC_iALUi,
Bob Wilson4876bdb2010-05-25 04:43:08 +0000524 !strconcat(opc, "s"), ".w\t$dst, $rhs, $lhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000525 [(set rGPR:$dst, (opnode t2_so_imm:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000526 let Inst{31-27} = 0b11110;
527 let Inst{25} = 0;
528 let Inst{24-21} = opcod;
529 let Inst{20} = 1; // The S bit.
530 let Inst{15} = 0;
531 }
Evan Chengf49810c2009-06-23 17:48:47 +0000532 // shifted register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000533 def rs : T2I<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_reg:$lhs), IIC_iALUsi,
Bob Wilson4876bdb2010-05-25 04:43:08 +0000534 !strconcat(opc, "s"), "\t$dst, $rhs, $lhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000535 [(set rGPR:$dst, (opnode t2_so_reg:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000536 let Inst{31-27} = 0b11101;
537 let Inst{26-25} = 0b01;
538 let Inst{24-21} = opcod;
539 let Inst{20} = 1; // The S bit.
540 }
Evan Chengf49810c2009-06-23 17:48:47 +0000541}
542}
543
Evan Chenga67efd12009-06-23 19:39:13 +0000544/// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
545// rotate operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000546multiclass T2I_sh_ir<bits<2> opcod, string opc, PatFrag opnode> {
Evan Chenga67efd12009-06-23 19:39:13 +0000547 // 5-bit imm
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000548 def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, i32imm:$rhs), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000549 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000550 [(set rGPR:$dst, (opnode rGPR:$lhs, imm1_31:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000551 let Inst{31-27} = 0b11101;
552 let Inst{26-21} = 0b010010;
553 let Inst{19-16} = 0b1111; // Rn
554 let Inst{5-4} = opcod;
555 }
Evan Chenga67efd12009-06-23 19:39:13 +0000556 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000557 def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$lhs, rGPR:$rhs), IIC_iMOVsr,
Evan Cheng699beba2009-10-27 00:08:59 +0000558 opc, ".w\t$dst, $lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000559 [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000560 let Inst{31-27} = 0b11111;
561 let Inst{26-23} = 0b0100;
562 let Inst{22-21} = opcod;
563 let Inst{15-12} = 0b1111;
564 let Inst{7-4} = 0b0000;
565 }
Evan Chenga67efd12009-06-23 19:39:13 +0000566}
Evan Chengf49810c2009-06-23 17:48:47 +0000567
Johnny Chend68e1192009-12-15 17:24:14 +0000568/// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
Evan Chenga67efd12009-06-23 19:39:13 +0000569/// patterns. Similar to T2I_bin_irs except the instruction does not produce
Evan Chengf49810c2009-06-23 17:48:47 +0000570/// a explicit result, only implicitly set CPSR.
Bill Wendlingf0e132c2010-08-19 00:05:48 +0000571let isCompare = 1, Defs = [CPSR] in {
Johnny Chend68e1192009-12-15 17:24:14 +0000572multiclass T2I_cmp_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000573 // shifted imm
David Goodwin5d598aa2009-08-19 18:00:44 +0000574 def ri : T2I<(outs), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iCMPi,
Evan Cheng699beba2009-10-27 00:08:59 +0000575 opc, ".w\t$lhs, $rhs",
Johnny Chend68e1192009-12-15 17:24:14 +0000576 [(opnode GPR:$lhs, t2_so_imm:$rhs)]> {
577 let Inst{31-27} = 0b11110;
578 let Inst{25} = 0;
579 let Inst{24-21} = opcod;
580 let Inst{20} = 1; // The S bit.
581 let Inst{15} = 0;
582 let Inst{11-8} = 0b1111; // Rd
583 }
Evan Chenga67efd12009-06-23 19:39:13 +0000584 // register
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000585 def rr : T2I<(outs), (ins GPR:$lhs, rGPR:$rhs), IIC_iCMPr,
Evan Cheng699beba2009-10-27 00:08:59 +0000586 opc, ".w\t$lhs, $rhs",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000587 [(opnode GPR:$lhs, rGPR:$rhs)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000588 let Inst{31-27} = 0b11101;
589 let Inst{26-25} = 0b01;
590 let Inst{24-21} = opcod;
591 let Inst{20} = 1; // The S bit.
592 let Inst{14-12} = 0b000; // imm3
593 let Inst{11-8} = 0b1111; // Rd
594 let Inst{7-6} = 0b00; // imm2
595 let Inst{5-4} = 0b00; // type
596 }
Evan Chengf49810c2009-06-23 17:48:47 +0000597 // shifted register
David Goodwin5d598aa2009-08-19 18:00:44 +0000598 def rs : T2I<(outs), (ins GPR:$lhs, t2_so_reg:$rhs), IIC_iCMPsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000599 opc, ".w\t$lhs, $rhs",
Johnny Chend68e1192009-12-15 17:24:14 +0000600 [(opnode GPR:$lhs, t2_so_reg:$rhs)]> {
601 let Inst{31-27} = 0b11101;
602 let Inst{26-25} = 0b01;
603 let Inst{24-21} = opcod;
604 let Inst{20} = 1; // The S bit.
605 let Inst{11-8} = 0b1111; // Rd
606 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000607}
608}
609
Evan Chengf3c21b82009-06-30 02:15:48 +0000610/// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
Johnny Chend68e1192009-12-15 17:24:14 +0000611multiclass T2I_ld<bit signed, bits<2> opcod, string opc, PatFrag opnode> {
David Goodwin5d598aa2009-08-19 18:00:44 +0000612 def i12 : T2Ii12<(outs GPR:$dst), (ins t2addrmode_imm12:$addr), IIC_iLoadi,
Evan Cheng699beba2009-10-27 00:08:59 +0000613 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000614 [(set GPR:$dst, (opnode t2addrmode_imm12:$addr))]> {
615 let Inst{31-27} = 0b11111;
616 let Inst{26-25} = 0b00;
617 let Inst{24} = signed;
618 let Inst{23} = 1;
619 let Inst{22-21} = opcod;
620 let Inst{20} = 1; // load
621 }
David Goodwin5d598aa2009-08-19 18:00:44 +0000622 def i8 : T2Ii8 <(outs GPR:$dst), (ins t2addrmode_imm8:$addr), IIC_iLoadi,
Evan Cheng699beba2009-10-27 00:08:59 +0000623 opc, "\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000624 [(set GPR:$dst, (opnode t2addrmode_imm8:$addr))]> {
625 let Inst{31-27} = 0b11111;
626 let Inst{26-25} = 0b00;
627 let Inst{24} = signed;
628 let Inst{23} = 0;
629 let Inst{22-21} = opcod;
630 let Inst{20} = 1; // load
631 let Inst{11} = 1;
632 // Offset: index==TRUE, wback==FALSE
633 let Inst{10} = 1; // The P bit.
634 let Inst{8} = 0; // The W bit.
635 }
David Goodwin5d598aa2009-08-19 18:00:44 +0000636 def s : T2Iso <(outs GPR:$dst), (ins t2addrmode_so_reg:$addr), IIC_iLoadr,
Evan Cheng699beba2009-10-27 00:08:59 +0000637 opc, ".w\t$dst, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000638 [(set GPR:$dst, (opnode t2addrmode_so_reg:$addr))]> {
639 let Inst{31-27} = 0b11111;
640 let Inst{26-25} = 0b00;
641 let Inst{24} = signed;
642 let Inst{23} = 0;
643 let Inst{22-21} = opcod;
644 let Inst{20} = 1; // load
645 let Inst{11-6} = 0b000000;
646 }
David Goodwin5d598aa2009-08-19 18:00:44 +0000647 def pci : T2Ipc <(outs GPR:$dst), (ins i32imm:$addr), IIC_iLoadi,
Evan Cheng699beba2009-10-27 00:08:59 +0000648 opc, ".w\t$dst, $addr",
Evan Cheng9eda6892009-10-31 03:39:36 +0000649 [(set GPR:$dst, (opnode (ARMWrapper tconstpool:$addr)))]> {
650 let isReMaterializable = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000651 let Inst{31-27} = 0b11111;
652 let Inst{26-25} = 0b00;
653 let Inst{24} = signed;
654 let Inst{23} = ?; // add = (U == '1')
655 let Inst{22-21} = opcod;
656 let Inst{20} = 1; // load
657 let Inst{19-16} = 0b1111; // Rn
Evan Cheng9eda6892009-10-31 03:39:36 +0000658 }
Evan Chengf3c21b82009-06-30 02:15:48 +0000659}
660
David Goodwin73b8f162009-06-30 22:11:34 +0000661/// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
Johnny Chend68e1192009-12-15 17:24:14 +0000662multiclass T2I_st<bits<2> opcod, string opc, PatFrag opnode> {
David Goodwin5d598aa2009-08-19 18:00:44 +0000663 def i12 : T2Ii12<(outs), (ins GPR:$src, t2addrmode_imm12:$addr), IIC_iStorei,
Evan Cheng699beba2009-10-27 00:08:59 +0000664 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000665 [(opnode GPR:$src, t2addrmode_imm12:$addr)]> {
666 let Inst{31-27} = 0b11111;
667 let Inst{26-23} = 0b0001;
668 let Inst{22-21} = opcod;
669 let Inst{20} = 0; // !load
670 }
David Goodwin5d598aa2009-08-19 18:00:44 +0000671 def i8 : T2Ii8 <(outs), (ins GPR:$src, t2addrmode_imm8:$addr), IIC_iStorei,
Evan Cheng699beba2009-10-27 00:08:59 +0000672 opc, "\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000673 [(opnode GPR:$src, t2addrmode_imm8:$addr)]> {
674 let Inst{31-27} = 0b11111;
675 let Inst{26-23} = 0b0000;
676 let Inst{22-21} = opcod;
677 let Inst{20} = 0; // !load
678 let Inst{11} = 1;
679 // Offset: index==TRUE, wback==FALSE
680 let Inst{10} = 1; // The P bit.
681 let Inst{8} = 0; // The W bit.
682 }
David Goodwin5d598aa2009-08-19 18:00:44 +0000683 def s : T2Iso <(outs), (ins GPR:$src, t2addrmode_so_reg:$addr), IIC_iStorer,
Evan Cheng699beba2009-10-27 00:08:59 +0000684 opc, ".w\t$src, $addr",
Johnny Chend68e1192009-12-15 17:24:14 +0000685 [(opnode GPR:$src, t2addrmode_so_reg:$addr)]> {
686 let Inst{31-27} = 0b11111;
687 let Inst{26-23} = 0b0000;
688 let Inst{22-21} = opcod;
689 let Inst{20} = 0; // !load
690 let Inst{11-6} = 0b000000;
691 }
David Goodwin73b8f162009-06-30 22:11:34 +0000692}
693
Evan Chengd27c9fc2009-07-03 01:43:10 +0000694/// T2I_unary_rrot - A unary operation with two forms: one whose operand is a
695/// register and one whose operand is a register rotated by 8/16/24.
Johnny Chend68e1192009-12-15 17:24:14 +0000696multiclass T2I_unary_rrot<bits<3> opcod, string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000697 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Evan Cheng699beba2009-10-27 00:08:59 +0000698 opc, ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000699 [(set rGPR:$dst, (opnode rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000700 let Inst{31-27} = 0b11111;
701 let Inst{26-23} = 0b0100;
702 let Inst{22-20} = opcod;
703 let Inst{19-16} = 0b1111; // Rn
704 let Inst{15-12} = 0b1111;
705 let Inst{7} = 1;
706 let Inst{5-4} = 0b00; // rotate
707 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000708 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iUNAsi,
Evan Cheng699beba2009-10-27 00:08:59 +0000709 opc, ".w\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000710 [(set rGPR:$dst, (opnode (rotr rGPR:$src, rot_imm:$rot)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000711 let Inst{31-27} = 0b11111;
712 let Inst{26-23} = 0b0100;
713 let Inst{22-20} = opcod;
714 let Inst{19-16} = 0b1111; // Rn
715 let Inst{15-12} = 0b1111;
716 let Inst{7} = 1;
717 let Inst{5-4} = {?,?}; // rotate
718 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000719}
720
Eli Friedman761fa7a2010-06-24 18:20:04 +0000721// UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
722multiclass T2I_unary_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000723 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chen267124c2010-03-04 22:24:41 +0000724 opc, "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000725 [(set rGPR:$dst, (opnode rGPR:$src))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000726 Requires<[HasT2ExtractPack]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000727 let Inst{31-27} = 0b11111;
728 let Inst{26-23} = 0b0100;
729 let Inst{22-20} = opcod;
730 let Inst{19-16} = 0b1111; // Rn
731 let Inst{15-12} = 0b1111;
732 let Inst{7} = 1;
733 let Inst{5-4} = 0b00; // rotate
734 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000735 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iUNAsi,
Johnny Chen267124c2010-03-04 22:24:41 +0000736 opc, "\t$dst, $src, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000737 [(set rGPR:$dst, (opnode (rotr rGPR:$src, rot_imm:$rot)))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000738 Requires<[HasT2ExtractPack]> {
Johnny Chen267124c2010-03-04 22:24:41 +0000739 let Inst{31-27} = 0b11111;
740 let Inst{26-23} = 0b0100;
741 let Inst{22-20} = opcod;
742 let Inst{19-16} = 0b1111; // Rn
743 let Inst{15-12} = 0b1111;
744 let Inst{7} = 1;
745 let Inst{5-4} = {?,?}; // rotate
746 }
747}
748
Eli Friedman761fa7a2010-06-24 18:20:04 +0000749// SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
750// supported yet.
751multiclass T2I_unary_rrot_sxtb16<bits<3> opcod, string opc> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000752 def r : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chen93042d12010-03-02 18:14:57 +0000753 opc, "\t$dst, $src", []> {
754 let Inst{31-27} = 0b11111;
755 let Inst{26-23} = 0b0100;
756 let Inst{22-20} = opcod;
757 let Inst{19-16} = 0b1111; // Rn
758 let Inst{15-12} = 0b1111;
759 let Inst{7} = 1;
760 let Inst{5-4} = 0b00; // rotate
761 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000762 def r_rot : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$rot), IIC_iUNAsi,
Johnny Chen93042d12010-03-02 18:14:57 +0000763 opc, "\t$dst, $src, ror $rot", []> {
764 let Inst{31-27} = 0b11111;
765 let Inst{26-23} = 0b0100;
766 let Inst{22-20} = opcod;
767 let Inst{19-16} = 0b1111; // Rn
768 let Inst{15-12} = 0b1111;
769 let Inst{7} = 1;
770 let Inst{5-4} = {?,?}; // rotate
771 }
772}
773
Evan Chengd27c9fc2009-07-03 01:43:10 +0000774/// T2I_bin_rrot - A binary operation with two forms: one whose operand is a
775/// register and one whose operand is a register rotated by 8/16/24.
Johnny Chend68e1192009-12-15 17:24:14 +0000776multiclass T2I_bin_rrot<bits<3> opcod, string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000777 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iALUr,
Evan Cheng699beba2009-10-27 00:08:59 +0000778 opc, "\t$dst, $LHS, $RHS",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000779 [(set rGPR:$dst, (opnode rGPR:$LHS, rGPR:$RHS))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000780 Requires<[HasT2ExtractPack]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000781 let Inst{31-27} = 0b11111;
782 let Inst{26-23} = 0b0100;
783 let Inst{22-20} = opcod;
784 let Inst{15-12} = 0b1111;
785 let Inst{7} = 1;
786 let Inst{5-4} = 0b00; // rotate
787 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000788 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Evan Cheng699beba2009-10-27 00:08:59 +0000789 IIC_iALUsr, opc, "\t$dst, $LHS, $RHS, ror $rot",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000790 [(set rGPR:$dst, (opnode rGPR:$LHS,
791 (rotr rGPR:$RHS, rot_imm:$rot)))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000792 Requires<[HasT2ExtractPack]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000793 let Inst{31-27} = 0b11111;
794 let Inst{26-23} = 0b0100;
795 let Inst{22-20} = opcod;
796 let Inst{15-12} = 0b1111;
797 let Inst{7} = 1;
798 let Inst{5-4} = {?,?}; // rotate
799 }
Evan Chengd27c9fc2009-07-03 01:43:10 +0000800}
801
Johnny Chen93042d12010-03-02 18:14:57 +0000802// DO variant - disassembly only, no pattern
803
804multiclass T2I_bin_rrot_DO<bits<3> opcod, string opc> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000805 def rr : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS), IIC_iALUr,
Johnny Chen93042d12010-03-02 18:14:57 +0000806 opc, "\t$dst, $LHS, $RHS", []> {
807 let Inst{31-27} = 0b11111;
808 let Inst{26-23} = 0b0100;
809 let Inst{22-20} = opcod;
810 let Inst{15-12} = 0b1111;
811 let Inst{7} = 1;
812 let Inst{5-4} = 0b00; // rotate
813 }
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000814 def rr_rot : T2I<(outs rGPR:$dst), (ins rGPR:$LHS, rGPR:$RHS, i32imm:$rot),
Johnny Chen93042d12010-03-02 18:14:57 +0000815 IIC_iALUsr, opc, "\t$dst, $LHS, $RHS, ror $rot", []> {
816 let Inst{31-27} = 0b11111;
817 let Inst{26-23} = 0b0100;
818 let Inst{22-20} = opcod;
819 let Inst{15-12} = 0b1111;
820 let Inst{7} = 1;
821 let Inst{5-4} = {?,?}; // rotate
822 }
823}
824
Anton Korobeynikov52237112009-06-17 18:13:58 +0000825//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000826// Instructions
827//===----------------------------------------------------------------------===//
828
829//===----------------------------------------------------------------------===//
Evan Chenga09b9ca2009-06-24 23:47:58 +0000830// Miscellaneous Instructions.
831//
832
Evan Chenga09b9ca2009-06-24 23:47:58 +0000833// LEApcrel - Load a pc-relative address into a register without offending the
834// assembler.
Evan Chengea420b22010-05-19 01:52:25 +0000835let neverHasSideEffects = 1 in {
Evan Cheng9085f982010-05-19 07:28:01 +0000836let isReMaterializable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000837def t2LEApcrel : T2XI<(outs rGPR:$dst), (ins i32imm:$label, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +0000838 "adr${p}.w\t$dst, #$label", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000839 let Inst{31-27} = 0b11110;
840 let Inst{25-24} = 0b10;
841 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
842 let Inst{22} = 0;
843 let Inst{20} = 0;
844 let Inst{19-16} = 0b1111; // Rn
845 let Inst{15} = 0;
846}
Jim Grosbacha967d112010-06-21 21:27:27 +0000847} // neverHasSideEffects
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000848def t2LEApcrelJT : T2XI<(outs rGPR:$dst),
Bob Wilson4f38b382009-08-21 21:58:55 +0000849 (ins i32imm:$label, nohash_imm:$id, pred:$p), IIC_iALUi,
Daniel Dunbar9db683b2010-08-11 04:46:10 +0000850 "adr${p}.w\t$dst, #${label}_${id}", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000851 let Inst{31-27} = 0b11110;
852 let Inst{25-24} = 0b10;
853 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
854 let Inst{22} = 0;
855 let Inst{20} = 0;
856 let Inst{19-16} = 0b1111; // Rn
857 let Inst{15} = 0;
858}
Evan Chenga09b9ca2009-06-24 23:47:58 +0000859
Evan Cheng86198642009-08-07 00:34:42 +0000860// ADD r, sp, {so_imm|i12}
David Goodwin5d598aa2009-08-19 18:00:44 +0000861def t2ADDrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000862 IIC_iALUi, "add", ".w\t$dst, $sp, $imm", []> {
863 let Inst{31-27} = 0b11110;
864 let Inst{25} = 0;
865 let Inst{24-21} = 0b1000;
866 let Inst{20} = ?; // The S bit.
867 let Inst{19-16} = 0b1101; // Rn = sp
868 let Inst{15} = 0;
869}
Jim Grosbach64171712010-02-16 21:07:46 +0000870def t2ADDrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000871 IIC_iALUi, "addw", "\t$dst, $sp, $imm", []> {
872 let Inst{31-27} = 0b11110;
873 let Inst{25} = 1;
874 let Inst{24-21} = 0b0000;
875 let Inst{20} = 0; // The S bit.
876 let Inst{19-16} = 0b1101; // Rn = sp
877 let Inst{15} = 0;
878}
Evan Cheng86198642009-08-07 00:34:42 +0000879
880// ADD r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +0000881def t2ADDrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +0000882 IIC_iALUsi, "add", ".w\t$dst, $sp, $rhs", []> {
883 let Inst{31-27} = 0b11101;
884 let Inst{26-25} = 0b01;
885 let Inst{24-21} = 0b1000;
886 let Inst{20} = ?; // The S bit.
887 let Inst{19-16} = 0b1101; // Rn = sp
888 let Inst{15} = 0;
889}
Evan Cheng86198642009-08-07 00:34:42 +0000890
891// SUB r, sp, {so_imm|i12}
David Goodwin5d598aa2009-08-19 18:00:44 +0000892def t2SUBrSPi : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000893 IIC_iALUi, "sub", ".w\t$dst, $sp, $imm", []> {
894 let Inst{31-27} = 0b11110;
895 let Inst{25} = 0;
896 let Inst{24-21} = 0b1101;
897 let Inst{20} = ?; // The S bit.
898 let Inst{19-16} = 0b1101; // Rn = sp
899 let Inst{15} = 0;
900}
David Goodwin5d598aa2009-08-19 18:00:44 +0000901def t2SUBrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm),
Johnny Chend68e1192009-12-15 17:24:14 +0000902 IIC_iALUi, "subw", "\t$dst, $sp, $imm", []> {
903 let Inst{31-27} = 0b11110;
904 let Inst{25} = 1;
905 let Inst{24-21} = 0b0101;
906 let Inst{20} = 0; // The S bit.
907 let Inst{19-16} = 0b1101; // Rn = sp
908 let Inst{15} = 0;
909}
Evan Cheng86198642009-08-07 00:34:42 +0000910
911// SUB r, sp, so_reg
David Goodwin5d598aa2009-08-19 18:00:44 +0000912def t2SUBrSPs : T2sI<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs),
913 IIC_iALUsi,
Johnny Chend68e1192009-12-15 17:24:14 +0000914 "sub", "\t$dst, $sp, $rhs", []> {
915 let Inst{31-27} = 0b11101;
916 let Inst{26-25} = 0b01;
917 let Inst{24-21} = 0b1101;
918 let Inst{20} = ?; // The S bit.
919 let Inst{19-16} = 0b1101; // Rn = sp
920 let Inst{15} = 0;
921}
Evan Cheng86198642009-08-07 00:34:42 +0000922
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000923// Signed and unsigned division on v7-M
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000924def t2SDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000925 "sdiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000926 [(set rGPR:$dst, (sdiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000927 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +0000928 let Inst{31-27} = 0b11111;
929 let Inst{26-21} = 0b011100;
930 let Inst{20} = 0b1;
931 let Inst{15-12} = 0b1111;
932 let Inst{7-4} = 0b1111;
933}
934
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000935def t2UDIV : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iALUi,
Jim Grosbachb1dc3932010-05-05 20:44:35 +0000936 "udiv", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000937 [(set rGPR:$dst, (udiv rGPR:$a, rGPR:$b))]>,
Jim Grosbach29402132010-05-05 23:44:43 +0000938 Requires<[HasDivide]> {
Johnny Chen93042d12010-03-02 18:14:57 +0000939 let Inst{31-27} = 0b11111;
940 let Inst{26-21} = 0b011101;
941 let Inst{20} = 0b1;
942 let Inst{15-12} = 0b1111;
943 let Inst{7-4} = 0b1111;
944}
945
Evan Chenga09b9ca2009-06-24 23:47:58 +0000946//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000947// Load / store Instructions.
948//
949
Evan Cheng055b0312009-06-29 07:51:04 +0000950// Load
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000951let canFoldAsLoad = 1, isReMaterializable = 1 in
Johnny Chend68e1192009-12-15 17:24:14 +0000952defm t2LDR : T2I_ld<0, 0b10, "ldr", UnOpFrag<(load node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000953
Evan Chengf3c21b82009-06-30 02:15:48 +0000954// Loads with zero extension
Johnny Chend68e1192009-12-15 17:24:14 +0000955defm t2LDRH : T2I_ld<0, 0b01, "ldrh", UnOpFrag<(zextloadi16 node:$Src)>>;
956defm t2LDRB : T2I_ld<0, 0b00, "ldrb", UnOpFrag<(zextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000957
Evan Chengf3c21b82009-06-30 02:15:48 +0000958// Loads with sign extension
Johnny Chend68e1192009-12-15 17:24:14 +0000959defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", UnOpFrag<(sextloadi16 node:$Src)>>;
960defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", UnOpFrag<(sextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +0000961
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000962let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
Evan Chengf3c21b82009-06-30 02:15:48 +0000963// Load doubleword
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000964def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Chenge298ab22009-09-27 09:46:04 +0000965 (ins t2addrmode_imm8s4:$addr),
Johnny Chen83142992010-01-05 22:37:28 +0000966 IIC_iLoadi, "ldrd", "\t$dst1, $addr", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000967def t2LDRDpci : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
Evan Chenge298ab22009-09-27 09:46:04 +0000968 (ins i32imm:$addr), IIC_iLoadi,
Johnny Chen83142992010-01-05 22:37:28 +0000969 "ldrd", "\t$dst1, $addr", []> {
Johnny Chend68e1192009-12-15 17:24:14 +0000970 let Inst{19-16} = 0b1111; // Rn
971}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000972} // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
Evan Chengf3c21b82009-06-30 02:15:48 +0000973
974// zextload i1 -> zextload i8
975def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
976 (t2LDRBi12 t2addrmode_imm12:$addr)>;
977def : T2Pat<(zextloadi1 t2addrmode_imm8:$addr),
978 (t2LDRBi8 t2addrmode_imm8:$addr)>;
979def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
980 (t2LDRBs t2addrmode_so_reg:$addr)>;
981def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
982 (t2LDRBpci tconstpool:$addr)>;
983
984// extload -> zextload
985// FIXME: Reduce the number of patterns by legalizing extload to zextload
986// earlier?
987def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
988 (t2LDRBi12 t2addrmode_imm12:$addr)>;
989def : T2Pat<(extloadi1 t2addrmode_imm8:$addr),
990 (t2LDRBi8 t2addrmode_imm8:$addr)>;
991def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
992 (t2LDRBs t2addrmode_so_reg:$addr)>;
993def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
994 (t2LDRBpci tconstpool:$addr)>;
995
996def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
997 (t2LDRBi12 t2addrmode_imm12:$addr)>;
998def : T2Pat<(extloadi8 t2addrmode_imm8:$addr),
999 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1000def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1001 (t2LDRBs t2addrmode_so_reg:$addr)>;
1002def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1003 (t2LDRBpci tconstpool:$addr)>;
1004
1005def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1006 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1007def : T2Pat<(extloadi16 t2addrmode_imm8:$addr),
1008 (t2LDRHi8 t2addrmode_imm8:$addr)>;
1009def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1010 (t2LDRHs t2addrmode_so_reg:$addr)>;
1011def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1012 (t2LDRHpci tconstpool:$addr)>;
Evan Cheng055b0312009-06-29 07:51:04 +00001013
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001014// FIXME: The destination register of the loads and stores can't be PC, but
1015// can be SP. We need another regclass (similar to rGPR) to represent
1016// that. Not a pressing issue since these are selected manually,
1017// not via pattern.
1018
Evan Chenge88d5ce2009-07-02 07:28:31 +00001019// Indexed loads
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001020let mayLoad = 1, neverHasSideEffects = 1 in {
Johnny Chend68e1192009-12-15 17:24:14 +00001021def t2LDR_PRE : T2Iidxldst<0, 0b10, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001022 (ins t2addrmode_imm8:$addr),
David Goodwin5d598aa2009-08-19 18:00:44 +00001023 AddrModeT2_i8, IndexModePre, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001024 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001025 []>;
1026
Johnny Chend68e1192009-12-15 17:24:14 +00001027def t2LDR_POST : T2Iidxldst<0, 0b10, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001028 (ins GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001029 AddrModeT2_i8, IndexModePost, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001030 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001031 []>;
1032
Johnny Chend68e1192009-12-15 17:24:14 +00001033def t2LDRB_PRE : T2Iidxldst<0, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001034 (ins t2addrmode_imm8:$addr),
David Goodwin5d598aa2009-08-19 18:00:44 +00001035 AddrModeT2_i8, IndexModePre, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001036 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001037 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001038def t2LDRB_POST : T2Iidxldst<0, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001039 (ins GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001040 AddrModeT2_i8, IndexModePost, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001041 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001042 []>;
1043
Johnny Chend68e1192009-12-15 17:24:14 +00001044def t2LDRH_PRE : T2Iidxldst<0, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001045 (ins t2addrmode_imm8:$addr),
David Goodwin5d598aa2009-08-19 18:00:44 +00001046 AddrModeT2_i8, IndexModePre, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001047 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001048 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001049def t2LDRH_POST : T2Iidxldst<0, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001050 (ins GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001051 AddrModeT2_i8, IndexModePost, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001052 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Chenge88d5ce2009-07-02 07:28:31 +00001053 []>;
1054
Johnny Chend68e1192009-12-15 17:24:14 +00001055def t2LDRSB_PRE : T2Iidxldst<1, 0b00, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001056 (ins t2addrmode_imm8:$addr),
David Goodwin5d598aa2009-08-19 18:00:44 +00001057 AddrModeT2_i8, IndexModePre, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001058 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001059 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001060def t2LDRSB_POST : T2Iidxldst<1, 0b00, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001061 (ins GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001062 AddrModeT2_i8, IndexModePost, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001063 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001064 []>;
1065
Johnny Chend68e1192009-12-15 17:24:14 +00001066def t2LDRSH_PRE : T2Iidxldst<1, 0b01, 1, 1, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001067 (ins t2addrmode_imm8:$addr),
David Goodwin5d598aa2009-08-19 18:00:44 +00001068 AddrModeT2_i8, IndexModePre, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001069 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001070 []>;
Johnny Chend68e1192009-12-15 17:24:14 +00001071def t2LDRSH_POST : T2Iidxldst<1, 0b01, 1, 0, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001072 (ins GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001073 AddrModeT2_i8, IndexModePost, IIC_iLoadiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001074 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb",
Evan Cheng4fbb9962009-07-02 23:16:11 +00001075 []>;
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001076} // mayLoad = 1, neverHasSideEffects = 1
Evan Cheng4fbb9962009-07-02 23:16:11 +00001077
Johnny Chene54a3ef2010-03-03 18:45:36 +00001078// LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110) and are
1079// for disassembly only.
1080// Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
1081class T2IldT<bit signed, bits<2> type, string opc>
1082 : T2Ii8<(outs GPR:$dst), (ins t2addrmode_imm8:$addr), IIC_iLoadi, opc,
1083 "\t$dst, $addr", []> {
1084 let Inst{31-27} = 0b11111;
1085 let Inst{26-25} = 0b00;
1086 let Inst{24} = signed;
1087 let Inst{23} = 0;
1088 let Inst{22-21} = type;
1089 let Inst{20} = 1; // load
1090 let Inst{11} = 1;
1091 let Inst{10-8} = 0b110; // PUW.
1092}
1093
1094def t2LDRT : T2IldT<0, 0b10, "ldrt">;
1095def t2LDRBT : T2IldT<0, 0b00, "ldrbt">;
1096def t2LDRHT : T2IldT<0, 0b01, "ldrht">;
1097def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt">;
1098def t2LDRSHT : T2IldT<1, 0b01, "ldrsht">;
1099
David Goodwin73b8f162009-06-30 22:11:34 +00001100// Store
Jim Grosbach80dc1162010-02-16 21:23:02 +00001101defm t2STR :T2I_st<0b10,"str", BinOpFrag<(store node:$LHS, node:$RHS)>>;
1102defm t2STRB:T2I_st<0b00,"strb",BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
1103defm t2STRH:T2I_st<0b01,"strh",BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
David Goodwin73b8f162009-06-30 22:11:34 +00001104
David Goodwin6647cea2009-06-30 22:50:01 +00001105// Store doubleword
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001106let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
Johnny Chend68e1192009-12-15 17:24:14 +00001107def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
Evan Chenge298ab22009-09-27 09:46:04 +00001108 (ins GPR:$src1, GPR:$src2, t2addrmode_imm8s4:$addr),
Johnny Chen83142992010-01-05 22:37:28 +00001109 IIC_iStorer, "strd", "\t$src1, $addr", []>;
David Goodwin6647cea2009-06-30 22:50:01 +00001110
Evan Cheng6d94f112009-07-03 00:06:39 +00001111// Indexed stores
Johnny Chend68e1192009-12-15 17:24:14 +00001112def t2STR_PRE : T2Iidxldst<0, 0b10, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001113 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001114 AddrModeT2_i8, IndexModePre, IIC_iStoreiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001115 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001116 [(set GPR:$base_wb,
1117 (pre_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1118
Johnny Chend68e1192009-12-15 17:24:14 +00001119def t2STR_POST : T2Iidxldst<0, 0b10, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001120 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001121 AddrModeT2_i8, IndexModePost, IIC_iStoreiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001122 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001123 [(set GPR:$base_wb,
Jim Grosbach6935efc2009-11-24 00:20:27 +00001124 (post_store GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001125
Johnny Chend68e1192009-12-15 17:24:14 +00001126def t2STRH_PRE : T2Iidxldst<0, 0b01, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001127 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001128 AddrModeT2_i8, IndexModePre, IIC_iStoreiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001129 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001130 [(set GPR:$base_wb,
1131 (pre_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1132
Johnny Chend68e1192009-12-15 17:24:14 +00001133def t2STRH_POST : T2Iidxldst<0, 0b01, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001134 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001135 AddrModeT2_i8, IndexModePost, IIC_iStoreiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001136 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001137 [(set GPR:$base_wb,
1138 (post_truncsti16 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1139
Johnny Chend68e1192009-12-15 17:24:14 +00001140def t2STRB_PRE : T2Iidxldst<0, 0b00, 0, 1, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001141 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001142 AddrModeT2_i8, IndexModePre, IIC_iStoreiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001143 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001144 [(set GPR:$base_wb,
1145 (pre_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1146
Johnny Chend68e1192009-12-15 17:24:14 +00001147def t2STRB_POST : T2Iidxldst<0, 0b00, 0, 0, (outs GPR:$base_wb),
Evan Cheng6d94f112009-07-03 00:06:39 +00001148 (ins GPR:$src, GPR:$base, t2am_imm8_offset:$offset),
David Goodwin5d598aa2009-08-19 18:00:44 +00001149 AddrModeT2_i8, IndexModePost, IIC_iStoreiu,
Evan Cheng699beba2009-10-27 00:08:59 +00001150 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Evan Cheng6d94f112009-07-03 00:06:39 +00001151 [(set GPR:$base_wb,
1152 (post_truncsti8 GPR:$src, GPR:$base, t2am_imm8_offset:$offset))]>;
1153
Johnny Chene54a3ef2010-03-03 18:45:36 +00001154// STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1155// only.
1156// Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
1157class T2IstT<bits<2> type, string opc>
1158 : T2Ii8<(outs GPR:$src), (ins t2addrmode_imm8:$addr), IIC_iStorei, opc,
1159 "\t$src, $addr", []> {
1160 let Inst{31-27} = 0b11111;
1161 let Inst{26-25} = 0b00;
1162 let Inst{24} = 0; // not signed
1163 let Inst{23} = 0;
1164 let Inst{22-21} = type;
1165 let Inst{20} = 0; // store
1166 let Inst{11} = 1;
1167 let Inst{10-8} = 0b110; // PUW
1168}
1169
1170def t2STRT : T2IstT<0b10, "strt">;
1171def t2STRBT : T2IstT<0b00, "strbt">;
1172def t2STRHT : T2IstT<0b01, "strht">;
David Goodwind1fa1202009-07-01 00:01:13 +00001173
Johnny Chenae1757b2010-03-11 01:13:36 +00001174// ldrd / strd pre / post variants
1175// For disassembly only.
1176
1177def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs GPR:$dst1, GPR:$dst2),
1178 (ins GPR:$base, t2am_imm8s4_offset:$imm), NoItinerary,
1179 "ldrd", "\t$dst1, $dst2, [$base, $imm]!", []>;
1180
1181def t2LDRD_POST : T2Ii8s4<0, 1, 1, (outs GPR:$dst1, GPR:$dst2),
1182 (ins GPR:$base, t2am_imm8s4_offset:$imm), NoItinerary,
1183 "ldrd", "\t$dst1, $dst2, [$base], $imm", []>;
1184
1185def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs),
1186 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
1187 NoItinerary, "strd", "\t$src1, $src2, [$base, $imm]!", []>;
1188
1189def t2STRD_POST : T2Ii8s4<0, 1, 0, (outs),
1190 (ins GPR:$src1, GPR:$src2, GPR:$base, t2am_imm8s4_offset:$imm),
1191 NoItinerary, "strd", "\t$src1, $src2, [$base], $imm", []>;
Evan Cheng2889cce2009-07-03 00:18:36 +00001192
Johnny Chen0635fc52010-03-04 17:40:44 +00001193// T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1194// data/instruction access. These are for disassembly only.
Johnny Chendd0f3cf2010-03-10 18:59:38 +00001195//
1196// A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
1197// The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
Johnny Chen0635fc52010-03-04 17:40:44 +00001198multiclass T2Ipl<bit instr, bit write, string opc> {
1199
Johnny Chendd0f3cf2010-03-10 18:59:38 +00001200 def i12 : T2I<(outs), (ins GPR:$base, i32imm:$imm), IIC_iLoadi, opc,
1201 "\t[$base, $imm]", []> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001202 let Inst{31-25} = 0b1111100;
1203 let Inst{24} = instr;
1204 let Inst{23} = 1; // U = 1
1205 let Inst{22} = 0;
1206 let Inst{21} = write;
1207 let Inst{20} = 1;
1208 let Inst{15-12} = 0b1111;
1209 }
1210
Johnny Chendd0f3cf2010-03-10 18:59:38 +00001211 def i8 : T2I<(outs), (ins GPR:$base, neg_zero:$imm), IIC_iLoadi, opc,
1212 "\t[$base, $imm]", []> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001213 let Inst{31-25} = 0b1111100;
1214 let Inst{24} = instr;
1215 let Inst{23} = 0; // U = 0
1216 let Inst{22} = 0;
1217 let Inst{21} = write;
1218 let Inst{20} = 1;
1219 let Inst{15-12} = 0b1111;
1220 let Inst{11-8} = 0b1100;
1221 }
1222
Johnny Chendd0f3cf2010-03-10 18:59:38 +00001223 def pci : T2I<(outs), (ins GPR:$base, neg_zero:$imm), IIC_iLoadi, opc,
1224 "\t[pc, $imm]", []> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001225 let Inst{31-25} = 0b1111100;
1226 let Inst{24} = instr;
1227 let Inst{23} = ?; // add = (U == 1)
1228 let Inst{22} = 0;
1229 let Inst{21} = write;
1230 let Inst{20} = 1;
1231 let Inst{19-16} = 0b1111; // Rn = 0b1111
1232 let Inst{15-12} = 0b1111;
1233 }
1234
1235 def r : T2I<(outs), (ins GPR:$base, GPR:$a), IIC_iLoadi, opc,
1236 "\t[$base, $a]", []> {
1237 let Inst{31-25} = 0b1111100;
1238 let Inst{24} = instr;
1239 let Inst{23} = 0; // add = TRUE for T1
1240 let Inst{22} = 0;
1241 let Inst{21} = write;
1242 let Inst{20} = 1;
1243 let Inst{15-12} = 0b1111;
1244 let Inst{11-6} = 0000000;
1245 let Inst{5-4} = 0b00; // no shift is applied
1246 }
1247
1248 def s : T2I<(outs), (ins GPR:$base, GPR:$a, i32imm:$shamt), IIC_iLoadi, opc,
1249 "\t[$base, $a, lsl $shamt]", []> {
1250 let Inst{31-25} = 0b1111100;
1251 let Inst{24} = instr;
1252 let Inst{23} = 0; // add = TRUE for T1
1253 let Inst{22} = 0;
1254 let Inst{21} = write;
1255 let Inst{20} = 1;
1256 let Inst{15-12} = 0b1111;
1257 let Inst{11-6} = 0000000;
1258 }
1259}
1260
1261defm t2PLD : T2Ipl<0, 0, "pld">;
1262defm t2PLDW : T2Ipl<0, 1, "pldw">;
1263defm t2PLI : T2Ipl<1, 0, "pli">;
1264
Evan Cheng2889cce2009-07-03 00:18:36 +00001265//===----------------------------------------------------------------------===//
1266// Load / store multiple Instructions.
1267//
1268
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001269let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
Bob Wilson815baeb2010-03-13 01:08:20 +00001270def t2LDM : T2XI<(outs), (ins addrmode4:$addr, pred:$p,
1271 reglist:$dsts, variable_ops), IIC_iLoadm,
1272 "ldm${addr:submode}${p}${addr:wide}\t$addr, $dsts", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001273 let Inst{31-27} = 0b11101;
1274 let Inst{26-25} = 0b00;
1275 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1276 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001277 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001278 let Inst{20} = 1; // Load
1279}
Evan Cheng2889cce2009-07-03 00:18:36 +00001280
Bob Wilson815baeb2010-03-13 01:08:20 +00001281def t2LDM_UPD : T2XIt<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1282 reglist:$dsts, variable_ops), IIC_iLoadm,
Bob Wilsonab346052010-03-16 17:46:45 +00001283 "ldm${addr:submode}${p}${addr:wide}\t$addr!, $dsts",
Bob Wilson815baeb2010-03-13 01:08:20 +00001284 "$addr.addr = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001285 let Inst{31-27} = 0b11101;
1286 let Inst{26-25} = 0b00;
1287 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1288 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00001289 let Inst{21} = 1; // The W bit.
1290 let Inst{20} = 1; // Load
1291}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001292} // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001293
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001294let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
Bob Wilson815baeb2010-03-13 01:08:20 +00001295def t2STM : T2XI<(outs), (ins addrmode4:$addr, pred:$p,
1296 reglist:$srcs, variable_ops), IIC_iStorem,
1297 "stm${addr:submode}${p}${addr:wide}\t$addr, $srcs", []> {
1298 let Inst{31-27} = 0b11101;
1299 let Inst{26-25} = 0b00;
1300 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1301 let Inst{22} = 0;
1302 let Inst{21} = 0; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00001303 let Inst{20} = 0; // Store
1304}
Evan Cheng2889cce2009-07-03 00:18:36 +00001305
Bob Wilson815baeb2010-03-13 01:08:20 +00001306def t2STM_UPD : T2XIt<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1307 reglist:$srcs, variable_ops),
1308 IIC_iStorem,
Bob Wilsonab346052010-03-16 17:46:45 +00001309 "stm${addr:submode}${p}${addr:wide}\t$addr!, $srcs",
Bob Wilson815baeb2010-03-13 01:08:20 +00001310 "$addr.addr = $wb", []> {
1311 let Inst{31-27} = 0b11101;
1312 let Inst{26-25} = 0b00;
1313 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
1314 let Inst{22} = 0;
1315 let Inst{21} = 1; // The W bit.
1316 let Inst{20} = 0; // Store
1317}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001318} // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
Bob Wilson815baeb2010-03-13 01:08:20 +00001319
Evan Cheng9cb9e672009-06-27 02:26:13 +00001320//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001321// Move Instructions.
1322//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001323
Evan Chengf49810c2009-06-23 17:48:47 +00001324let neverHasSideEffects = 1 in
David Goodwin5d598aa2009-08-19 18:00:44 +00001325def t2MOVr : T2sI<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVr,
Johnny Chend68e1192009-12-15 17:24:14 +00001326 "mov", ".w\t$dst, $src", []> {
1327 let Inst{31-27} = 0b11101;
1328 let Inst{26-25} = 0b01;
1329 let Inst{24-21} = 0b0010;
1330 let Inst{20} = ?; // The S bit.
1331 let Inst{19-16} = 0b1111; // Rn
1332 let Inst{14-12} = 0b000;
1333 let Inst{7-4} = 0b0000;
1334}
Evan Chengf49810c2009-06-23 17:48:47 +00001335
Evan Cheng5adb66a2009-09-28 09:14:39 +00001336// AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1337let isReMaterializable = 1, isAsCheapAsAMove = 1, AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001338def t2MOVi : T2sI<(outs rGPR:$dst), (ins t2_so_imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001339 "mov", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001340 [(set rGPR:$dst, t2_so_imm:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001341 let Inst{31-27} = 0b11110;
1342 let Inst{25} = 0;
1343 let Inst{24-21} = 0b0010;
1344 let Inst{20} = ?; // The S bit.
1345 let Inst{19-16} = 0b1111; // Rn
1346 let Inst{15} = 0;
1347}
David Goodwin83b35932009-06-26 16:10:07 +00001348
1349let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001350def t2MOVi16 : T2I<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001351 "movw", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001352 [(set rGPR:$dst, imm0_65535:$src)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001353 let Inst{31-27} = 0b11110;
1354 let Inst{25} = 1;
1355 let Inst{24-21} = 0b0010;
1356 let Inst{20} = 0; // The S bit.
1357 let Inst{15} = 0;
1358}
Evan Chengf49810c2009-06-23 17:48:47 +00001359
Evan Cheng3850a6a2009-06-23 05:23:49 +00001360let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001361def t2MOVTi16 : T2I<(outs rGPR:$dst), (ins rGPR:$src, i32imm:$imm), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00001362 "movt", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001363 [(set rGPR:$dst,
1364 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001365 let Inst{31-27} = 0b11110;
1366 let Inst{25} = 1;
1367 let Inst{24-21} = 0b0110;
1368 let Inst{20} = 0; // The S bit.
1369 let Inst{15} = 0;
1370}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001371
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001372def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
Evan Cheng20956592009-10-21 08:15:52 +00001373
Anton Korobeynikov52237112009-06-17 18:13:58 +00001374//===----------------------------------------------------------------------===//
Evan Chengd27c9fc2009-07-03 01:43:10 +00001375// Extend Instructions.
1376//
1377
1378// Sign extenders
1379
Johnny Chend68e1192009-12-15 17:24:14 +00001380defm t2SXTB : T2I_unary_rrot<0b100, "sxtb",
1381 UnOpFrag<(sext_inreg node:$Src, i8)>>;
1382defm t2SXTH : T2I_unary_rrot<0b000, "sxth",
1383 UnOpFrag<(sext_inreg node:$Src, i16)>>;
Eli Friedman761fa7a2010-06-24 18:20:04 +00001384defm t2SXTB16 : T2I_unary_rrot_sxtb16<0b010, "sxtb16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001385
Johnny Chend68e1192009-12-15 17:24:14 +00001386defm t2SXTAB : T2I_bin_rrot<0b100, "sxtab",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001387 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Johnny Chend68e1192009-12-15 17:24:14 +00001388defm t2SXTAH : T2I_bin_rrot<0b000, "sxtah",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001389 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Johnny Chen93042d12010-03-02 18:14:57 +00001390defm t2SXTAB16 : T2I_bin_rrot_DO<0b010, "sxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001391
Johnny Chen93042d12010-03-02 18:14:57 +00001392// TODO: SXT(A){B|H}16 - done for disassembly only
Evan Chengd27c9fc2009-07-03 01:43:10 +00001393
1394// Zero extenders
1395
1396let AddedComplexity = 16 in {
Johnny Chend68e1192009-12-15 17:24:14 +00001397defm t2UXTB : T2I_unary_rrot<0b101, "uxtb",
1398 UnOpFrag<(and node:$Src, 0x000000FF)>>;
1399defm t2UXTH : T2I_unary_rrot<0b001, "uxth",
1400 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
Eli Friedman761fa7a2010-06-24 18:20:04 +00001401defm t2UXTB16 : T2I_unary_rrot_uxtb16<0b011, "uxtb16",
Johnny Chend68e1192009-12-15 17:24:14 +00001402 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001403
Jim Grosbach79464942010-07-28 23:17:45 +00001404// FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1405// The transformation should probably be done as a combiner action
1406// instead so we can include a check for masking back in the upper
1407// eight bits of the source into the lower eight bits of the result.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001408//def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
1409// (t2UXTB16r_rot rGPR:$Src, 24)>, Requires<[HasT2ExtractPack]>;
1410def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
1411 (t2UXTB16r_rot rGPR:$Src, 8)>, Requires<[HasT2ExtractPack]>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001412
Johnny Chend68e1192009-12-15 17:24:14 +00001413defm t2UXTAB : T2I_bin_rrot<0b101, "uxtab",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001414 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Johnny Chend68e1192009-12-15 17:24:14 +00001415defm t2UXTAH : T2I_bin_rrot<0b001, "uxtah",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001416 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Johnny Chen93042d12010-03-02 18:14:57 +00001417defm t2UXTAB16 : T2I_bin_rrot_DO<0b011, "uxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001418}
1419
1420//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001421// Arithmetic Instructions.
1422//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001423
Johnny Chend68e1192009-12-15 17:24:14 +00001424defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1425 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1426defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1427 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001428
Evan Chengf49810c2009-06-23 17:48:47 +00001429// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
Johnny Chend68e1192009-12-15 17:24:14 +00001430defm t2ADDS : T2I_bin_s_irs <0b1000, "add",
1431 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1432defm t2SUBS : T2I_bin_s_irs <0b1101, "sub",
1433 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001434
Johnny Chend68e1192009-12-15 17:24:14 +00001435defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001436 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00001437defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001438 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001439defm t2ADCS : T2I_adde_sube_s_irs<0b1010, "adc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001440 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
Johnny Chenb5031ad2010-03-02 19:38:59 +00001441defm t2SBCS : T2I_adde_sube_s_irs<0b1011, "sbc",
Jim Grosbach39be8fc2010-02-16 20:42:29 +00001442 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001443
David Goodwin752aa7d2009-07-27 16:39:05 +00001444// RSB
Bob Wilson20d8e4e2010-08-13 23:24:25 +00001445defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
Johnny Chend68e1192009-12-15 17:24:14 +00001446 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1447defm t2RSBS : T2I_rbin_s_is <0b1110, "rsb",
1448 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001449
1450// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001451// The assume-no-carry-in form uses the negation of the input since add/sub
1452// assume opposite meanings of the carry flag (i.e., carry == !borrow).
1453// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1454// details.
1455// The AddedComplexity preferences the first variant over the others since
1456// it can be shrunk to a 16-bit wide encoding, while the others cannot.
Evan Chengfa2ea1a2009-08-04 01:41:15 +00001457let AddedComplexity = 1 in
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001458def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1459 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1460def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1461 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1462def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1463 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1464let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001465def : T2Pat<(addc rGPR:$src, imm0_255_neg:$imm),
1466 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1467def : T2Pat<(addc rGPR:$src, t2_so_imm_neg:$imm),
1468 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001469// The with-carry-in form matches bitwise not instead of the negation.
1470// Effectively, the inverse interpretation of the carry flag already accounts
1471// for part of the negation.
1472let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001473def : T2Pat<(adde rGPR:$src, imm0_255_not:$imm),
1474 (t2SBCSri rGPR:$src, imm0_255_not:$imm)>;
1475def : T2Pat<(adde rGPR:$src, t2_so_imm_not:$imm),
1476 (t2SBCSri rGPR:$src, t2_so_imm_not:$imm)>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001477
Johnny Chen93042d12010-03-02 18:14:57 +00001478// Select Bytes -- for disassembly only
1479
1480def t2SEL : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b), NoItinerary, "sel",
1481 "\t$dst, $a, $b", []> {
1482 let Inst{31-27} = 0b11111;
1483 let Inst{26-24} = 0b010;
1484 let Inst{23} = 0b1;
1485 let Inst{22-20} = 0b010;
1486 let Inst{15-12} = 0b1111;
1487 let Inst{7} = 0b1;
1488 let Inst{6-4} = 0b000;
1489}
1490
Johnny Chenadc77332010-02-26 22:04:29 +00001491// A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1492// And Miscellaneous operations -- for disassembly only
Nate Begeman692433b2010-07-29 17:56:55 +00001493class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
1494 list<dag> pat = [/* For disassembly only; pattern left blank */]>
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001495 : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), NoItinerary, opc,
Nate Begeman692433b2010-07-29 17:56:55 +00001496 "\t$dst, $a, $b", pat> {
Johnny Chenadc77332010-02-26 22:04:29 +00001497 let Inst{31-27} = 0b11111;
1498 let Inst{26-23} = 0b0101;
1499 let Inst{22-20} = op22_20;
1500 let Inst{15-12} = 0b1111;
1501 let Inst{7-4} = op7_4;
1502}
1503
1504// Saturating add/subtract -- for disassembly only
1505
Nate Begeman692433b2010-07-29 17:56:55 +00001506def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001507 [(set rGPR:$dst, (int_arm_qadd rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001508def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
1509def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
1510def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
1511def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd">;
1512def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub">;
1513def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
Nate Begeman692433b2010-07-29 17:56:55 +00001514def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001515 [(set rGPR:$dst, (int_arm_qsub rGPR:$a, rGPR:$b))]>;
Johnny Chenadc77332010-02-26 22:04:29 +00001516def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
1517def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
1518def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
1519def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
1520def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
1521def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
1522def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
1523def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
1524
1525// Signed/Unsigned add/subtract -- for disassembly only
1526
1527def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
1528def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
1529def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
1530def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
1531def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
1532def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
1533def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
1534def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
1535def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
1536def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
1537def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
1538def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
1539
1540// Signed/Unsigned halving add/subtract -- for disassembly only
1541
1542def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
1543def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
1544def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
1545def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
1546def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
1547def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
1548def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
1549def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
1550def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
1551def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
1552def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
1553def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
1554
1555// Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
1556
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001557def t2USAD8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1558 (ins rGPR:$a, rGPR:$b),
Johnny Chenadc77332010-02-26 22:04:29 +00001559 NoItinerary, "usad8", "\t$dst, $a, $b", []> {
1560 let Inst{15-12} = 0b1111;
1561}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001562def t2USADA8 : T2I_mac<0, 0b111, 0b0000, (outs rGPR:$dst),
1563 (ins rGPR:$a, rGPR:$b, rGPR:$acc), NoItinerary, "usada8",
Johnny Chenadc77332010-02-26 22:04:29 +00001564 "\t$dst, $a, $b, $acc", []>;
1565
1566// Signed/Unsigned saturate -- for disassembly only
1567
Bob Wilson22f5dc72010-08-16 18:27:34 +00001568def t2SSAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001569 NoItinerary, "ssat", "\t$dst, $bit_pos, $a$sh",
1570 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001571 let Inst{31-27} = 0b11110;
1572 let Inst{25-22} = 0b1100;
1573 let Inst{20} = 0;
1574 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001575}
1576
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001577def t2SSAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001578 "ssat16", "\t$dst, $bit_pos, $a",
1579 [/* For disassembly only; pattern left blank */]> {
1580 let Inst{31-27} = 0b11110;
1581 let Inst{25-22} = 0b1100;
1582 let Inst{20} = 0;
1583 let Inst{15} = 0;
1584 let Inst{21} = 1; // sh = '1'
1585 let Inst{14-12} = 0b000; // imm3 = '000'
1586 let Inst{7-6} = 0b00; // imm2 = '00'
1587}
1588
Bob Wilson22f5dc72010-08-16 18:27:34 +00001589def t2USAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, shift_imm:$sh),
Bob Wilson38aa2872010-08-13 21:48:10 +00001590 NoItinerary, "usat", "\t$dst, $bit_pos, $a$sh",
1591 [/* For disassembly only; pattern left blank */]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001592 let Inst{31-27} = 0b11110;
1593 let Inst{25-22} = 0b1110;
1594 let Inst{20} = 0;
1595 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00001596}
1597
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001598def t2USAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary,
Johnny Chenadc77332010-02-26 22:04:29 +00001599 "usat16", "\t$dst, $bit_pos, $a",
1600 [/* For disassembly only; pattern left blank */]> {
1601 let Inst{31-27} = 0b11110;
1602 let Inst{25-22} = 0b1110;
1603 let Inst{20} = 0;
1604 let Inst{15} = 0;
1605 let Inst{21} = 1; // sh = '1'
1606 let Inst{14-12} = 0b000; // imm3 = '000'
1607 let Inst{7-6} = 0b00; // imm2 = '00'
1608}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001609
Bob Wilson38aa2872010-08-13 21:48:10 +00001610def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
1611def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
Nate Begeman0e0a20e2010-07-29 22:48:09 +00001612
Evan Chengf49810c2009-06-23 17:48:47 +00001613//===----------------------------------------------------------------------===//
Evan Chenga67efd12009-06-23 19:39:13 +00001614// Shift and rotate Instructions.
1615//
1616
Johnny Chend68e1192009-12-15 17:24:14 +00001617defm t2LSL : T2I_sh_ir<0b00, "lsl", BinOpFrag<(shl node:$LHS, node:$RHS)>>;
1618defm t2LSR : T2I_sh_ir<0b01, "lsr", BinOpFrag<(srl node:$LHS, node:$RHS)>>;
1619defm t2ASR : T2I_sh_ir<0b10, "asr", BinOpFrag<(sra node:$LHS, node:$RHS)>>;
1620defm t2ROR : T2I_sh_ir<0b11, "ror", BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
Evan Chenga67efd12009-06-23 19:39:13 +00001621
David Goodwinca01a8d2009-09-01 18:32:09 +00001622let Uses = [CPSR] in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001623def t2MOVrx : T2sI<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Evan Cheng699beba2009-10-27 00:08:59 +00001624 "rrx", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001625 [(set rGPR:$dst, (ARMrrx rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001626 let Inst{31-27} = 0b11101;
1627 let Inst{26-25} = 0b01;
1628 let Inst{24-21} = 0b0010;
1629 let Inst{20} = ?; // The S bit.
1630 let Inst{19-16} = 0b1111; // Rn
1631 let Inst{14-12} = 0b000;
1632 let Inst{7-4} = 0b0011;
1633}
David Goodwinca01a8d2009-09-01 18:32:09 +00001634}
Evan Chenga67efd12009-06-23 19:39:13 +00001635
David Goodwin3583df72009-07-28 17:06:49 +00001636let Defs = [CPSR] in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001637def t2MOVsrl_flag : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Bob Wilsona85df802010-05-25 04:51:47 +00001638 "lsrs", ".w\t$dst, $src, #1",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001639 [(set rGPR:$dst, (ARMsrl_flag rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001640 let Inst{31-27} = 0b11101;
1641 let Inst{26-25} = 0b01;
1642 let Inst{24-21} = 0b0010;
1643 let Inst{20} = 1; // The S bit.
1644 let Inst{19-16} = 0b1111; // Rn
1645 let Inst{5-4} = 0b01; // Shift type.
1646 // Shift amount = Inst{14-12:7-6} = 1.
1647 let Inst{14-12} = 0b000;
1648 let Inst{7-6} = 0b01;
1649}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001650def t2MOVsra_flag : T2I<(outs rGPR:$dst), (ins rGPR:$src), IIC_iMOVsi,
Bob Wilsona85df802010-05-25 04:51:47 +00001651 "asrs", ".w\t$dst, $src, #1",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001652 [(set rGPR:$dst, (ARMsra_flag rGPR:$src))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001653 let Inst{31-27} = 0b11101;
1654 let Inst{26-25} = 0b01;
1655 let Inst{24-21} = 0b0010;
1656 let Inst{20} = 1; // The S bit.
1657 let Inst{19-16} = 0b1111; // Rn
1658 let Inst{5-4} = 0b10; // Shift type.
1659 // Shift amount = Inst{14-12:7-6} = 1.
1660 let Inst{14-12} = 0b000;
1661 let Inst{7-6} = 0b01;
1662}
David Goodwin3583df72009-07-28 17:06:49 +00001663}
1664
Evan Chenga67efd12009-06-23 19:39:13 +00001665//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +00001666// Bitwise Instructions.
1667//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001668
Johnny Chend68e1192009-12-15 17:24:14 +00001669defm t2AND : T2I_bin_w_irs<0b0000, "and",
1670 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1671defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
1672 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1673defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
1674 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Evan Chengf49810c2009-06-23 17:48:47 +00001675
Johnny Chend68e1192009-12-15 17:24:14 +00001676defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
1677 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001678
Bill Wendling4822bce2010-08-30 01:47:35 +00001679//let Defs = [CPSR] in
Bill Wendling1f7bf0e2010-08-29 03:55:31 +00001680defm t2ANDS : T2I_bin_sw_irs<0b0000, "and",
1681 BinOpFrag<(ARMand node:$LHS, node:$RHS)>, 1>;
Bill Wendling0b4aa7d2010-08-29 03:02:11 +00001682
Evan Chengf49810c2009-06-23 17:48:47 +00001683let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001684def t2BFC : T2I<(outs rGPR:$dst), (ins rGPR:$src, bf_inv_mask_imm:$imm),
David Goodwin2f54a2f2009-11-02 17:28:36 +00001685 IIC_iUNAsi, "bfc", "\t$dst, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001686 [(set rGPR:$dst, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001687 let Inst{31-27} = 0b11110;
1688 let Inst{25} = 1;
1689 let Inst{24-20} = 0b10110;
1690 let Inst{19-16} = 0b1111; // Rn
1691 let Inst{15} = 0;
1692}
Evan Chengf49810c2009-06-23 17:48:47 +00001693
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001694def t2SBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Johnny Chend68e1192009-12-15 17:24:14 +00001695 IIC_iALUi, "sbfx", "\t$dst, $src, $lsb, $width", []> {
1696 let Inst{31-27} = 0b11110;
1697 let Inst{25} = 1;
1698 let Inst{24-20} = 0b10100;
1699 let Inst{15} = 0;
1700}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00001701
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001702def t2UBFX: T2I<(outs rGPR:$dst), (ins rGPR:$src, imm0_31:$lsb, imm0_31:$width),
Johnny Chend68e1192009-12-15 17:24:14 +00001703 IIC_iALUi, "ubfx", "\t$dst, $src, $lsb, $width", []> {
1704 let Inst{31-27} = 0b11110;
1705 let Inst{25} = 1;
1706 let Inst{24-20} = 0b11100;
1707 let Inst{15} = 0;
1708}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00001709
Johnny Chen9474d552010-02-02 19:31:58 +00001710// A8.6.18 BFI - Bitfield insert (Encoding T1)
Jim Grosbach469bbdb2010-07-16 23:05:05 +00001711let Constraints = "$src = $dst" in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001712def t2BFI : T2I<(outs rGPR:$dst),
1713 (ins rGPR:$src, rGPR:$val, bf_inv_mask_imm:$imm),
Jim Grosbach469bbdb2010-07-16 23:05:05 +00001714 IIC_iALUi, "bfi", "\t$dst, $val, $imm",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001715 [(set rGPR:$dst, (ARMbfi rGPR:$src, rGPR:$val,
Jim Grosbach469bbdb2010-07-16 23:05:05 +00001716 bf_inv_mask_imm:$imm))]> {
Johnny Chen9474d552010-02-02 19:31:58 +00001717 let Inst{31-27} = 0b11110;
1718 let Inst{25} = 1;
1719 let Inst{24-20} = 0b10110;
1720 let Inst{15} = 0;
1721}
Evan Chengf49810c2009-06-23 17:48:47 +00001722
Johnny Chend68e1192009-12-15 17:24:14 +00001723defm t2ORN : T2I_bin_irs<0b0011, "orn", BinOpFrag<(or node:$LHS,
Bill Wendling4822bce2010-08-30 01:47:35 +00001724 (not node:$RHS))>, 0, "">;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001725
1726// Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
1727let AddedComplexity = 1 in
Johnny Chend68e1192009-12-15 17:24:14 +00001728defm t2MVN : T2I_un_irs <0b0011, "mvn", UnOpFrag<(not node:$Src)>, 1, 1>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001729
1730
Jim Grosbachf084a5e2010-07-20 16:07:04 +00001731let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001732def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
1733 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001734
Evan Cheng25f7cfc2009-08-01 06:13:52 +00001735// FIXME: Disable this pattern on Darwin to workaround an assembler bug.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001736def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
1737 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
Evan Chengea253b92009-08-12 01:56:42 +00001738 Requires<[IsThumb2]>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00001739
1740def : T2Pat<(t2_so_imm_not:$src),
1741 (t2MVNi t2_so_imm_not:$src)>;
1742
Evan Chengf49810c2009-06-23 17:48:47 +00001743//===----------------------------------------------------------------------===//
1744// Multiply Instructions.
1745//
Evan Cheng8de898a2009-06-26 00:19:44 +00001746let isCommutable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001747def t2MUL: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001748 "mul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001749 [(set rGPR:$dst, (mul rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001750 let Inst{31-27} = 0b11111;
1751 let Inst{26-23} = 0b0110;
1752 let Inst{22-20} = 0b000;
1753 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1754 let Inst{7-4} = 0b0000; // Multiply
1755}
Evan Chengf49810c2009-06-23 17:48:47 +00001756
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001757def t2MLA: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001758 "mla", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001759 [(set rGPR:$dst, (add (mul rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001760 let Inst{31-27} = 0b11111;
1761 let Inst{26-23} = 0b0110;
1762 let Inst{22-20} = 0b000;
1763 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1764 let Inst{7-4} = 0b0000; // Multiply
1765}
Evan Chengf49810c2009-06-23 17:48:47 +00001766
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001767def t2MLS: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001768 "mls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001769 [(set rGPR:$dst, (sub rGPR:$c, (mul rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001770 let Inst{31-27} = 0b11111;
1771 let Inst{26-23} = 0b0110;
1772 let Inst{22-20} = 0b000;
1773 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1774 let Inst{7-4} = 0b0001; // Multiply and Subtract
1775}
Evan Chengf49810c2009-06-23 17:48:47 +00001776
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001777// Extra precision multiplies with low / high results
1778let neverHasSideEffects = 1 in {
1779let isCommutable = 1 in {
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001780def t2SMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1781 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00001782 "smull", "\t$ldst, $hdst, $a, $b", []> {
1783 let Inst{31-27} = 0b11111;
1784 let Inst{26-23} = 0b0111;
1785 let Inst{22-20} = 0b000;
1786 let Inst{7-4} = 0b0000;
1787}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001788
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001789def t2UMULL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1790 (ins rGPR:$a, rGPR:$b), IIC_iMUL64,
Johnny Chend68e1192009-12-15 17:24:14 +00001791 "umull", "\t$ldst, $hdst, $a, $b", []> {
1792 let Inst{31-27} = 0b11111;
1793 let Inst{26-23} = 0b0111;
1794 let Inst{22-20} = 0b010;
1795 let Inst{7-4} = 0b0000;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001796}
Johnny Chend68e1192009-12-15 17:24:14 +00001797} // isCommutable
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001798
1799// Multiply + accumulate
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001800def t2SMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1801 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001802 "smlal", "\t$ldst, $hdst, $a, $b", []>{
1803 let Inst{31-27} = 0b11111;
1804 let Inst{26-23} = 0b0111;
1805 let Inst{22-20} = 0b100;
1806 let Inst{7-4} = 0b0000;
1807}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001808
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001809def t2UMLAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1810 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001811 "umlal", "\t$ldst, $hdst, $a, $b", []>{
1812 let Inst{31-27} = 0b11111;
1813 let Inst{26-23} = 0b0111;
1814 let Inst{22-20} = 0b110;
1815 let Inst{7-4} = 0b0000;
1816}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001817
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001818def t2UMAAL : T2I<(outs rGPR:$ldst, rGPR:$hdst),
1819 (ins rGPR:$a, rGPR:$b), IIC_iMAC64,
Johnny Chend68e1192009-12-15 17:24:14 +00001820 "umaal", "\t$ldst, $hdst, $a, $b", []>{
1821 let Inst{31-27} = 0b11111;
1822 let Inst{26-23} = 0b0111;
1823 let Inst{22-20} = 0b110;
1824 let Inst{7-4} = 0b0110;
1825}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001826} // neverHasSideEffects
1827
Johnny Chen93042d12010-03-02 18:14:57 +00001828// Rounding variants of the below included for disassembly only
1829
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001830// Most significant word multiply
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001831def t2SMMUL : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001832 "smmul", "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001833 [(set rGPR:$dst, (mulhs rGPR:$a, rGPR:$b))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001834 let Inst{31-27} = 0b11111;
1835 let Inst{26-23} = 0b0110;
1836 let Inst{22-20} = 0b101;
1837 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1838 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1839}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001840
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001841def t2SMMULR : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Johnny Chen93042d12010-03-02 18:14:57 +00001842 "smmulr", "\t$dst, $a, $b", []> {
1843 let Inst{31-27} = 0b11111;
1844 let Inst{26-23} = 0b0110;
1845 let Inst{22-20} = 0b101;
1846 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1847 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1848}
1849
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001850def t2SMMLA : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001851 "smmla", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001852 [(set rGPR:$dst, (add (mulhs rGPR:$a, rGPR:$b), rGPR:$c))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001853 let Inst{31-27} = 0b11111;
1854 let Inst{26-23} = 0b0110;
1855 let Inst{22-20} = 0b101;
1856 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1857 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1858}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001859
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001860def t2SMMLAR: T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00001861 "smmlar", "\t$dst, $a, $b, $c", []> {
1862 let Inst{31-27} = 0b11111;
1863 let Inst{26-23} = 0b0110;
1864 let Inst{22-20} = 0b101;
1865 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1866 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1867}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001868
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001869def t2SMMLS: T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Evan Cheng699beba2009-10-27 00:08:59 +00001870 "smmls", "\t$dst, $a, $b, $c",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001871 [(set rGPR:$dst, (sub rGPR:$c, (mulhs rGPR:$a, rGPR:$b)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001872 let Inst{31-27} = 0b11111;
1873 let Inst{26-23} = 0b0110;
1874 let Inst{22-20} = 0b110;
1875 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1876 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
1877}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001878
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001879def t2SMMLSR:T2I <(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$c), IIC_iMAC32,
Johnny Chen93042d12010-03-02 18:14:57 +00001880 "smmlsr", "\t$dst, $a, $b, $c", []> {
1881 let Inst{31-27} = 0b11111;
1882 let Inst{26-23} = 0b0110;
1883 let Inst{22-20} = 0b110;
1884 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1885 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
1886}
1887
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001888multiclass T2I_smul<string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001889 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001890 !strconcat(opc, "bb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001891 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
1892 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001893 let Inst{31-27} = 0b11111;
1894 let Inst{26-23} = 0b0110;
1895 let Inst{22-20} = 0b001;
1896 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1897 let Inst{7-6} = 0b00;
1898 let Inst{5-4} = 0b00;
1899 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001900
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001901 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001902 !strconcat(opc, "bt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001903 [(set rGPR:$dst, (opnode (sext_inreg rGPR:$a, i16),
1904 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001905 let Inst{31-27} = 0b11111;
1906 let Inst{26-23} = 0b0110;
1907 let Inst{22-20} = 0b001;
1908 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1909 let Inst{7-6} = 0b00;
1910 let Inst{5-4} = 0b01;
1911 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001912
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001913 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001914 !strconcat(opc, "tb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001915 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
1916 (sext_inreg rGPR:$b, i16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001917 let Inst{31-27} = 0b11111;
1918 let Inst{26-23} = 0b0110;
1919 let Inst{22-20} = 0b001;
1920 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1921 let Inst{7-6} = 0b00;
1922 let Inst{5-4} = 0b10;
1923 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001924
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001925 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL32,
Evan Cheng699beba2009-10-27 00:08:59 +00001926 !strconcat(opc, "tt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001927 [(set rGPR:$dst, (opnode (sra rGPR:$a, (i32 16)),
1928 (sra rGPR:$b, (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001929 let Inst{31-27} = 0b11111;
1930 let Inst{26-23} = 0b0110;
1931 let Inst{22-20} = 0b001;
1932 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1933 let Inst{7-6} = 0b00;
1934 let Inst{5-4} = 0b11;
1935 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001936
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001937 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001938 !strconcat(opc, "wb"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001939 [(set rGPR:$dst, (sra (opnode rGPR:$a,
1940 (sext_inreg rGPR:$b, i16)), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001941 let Inst{31-27} = 0b11111;
1942 let Inst{26-23} = 0b0110;
1943 let Inst{22-20} = 0b011;
1944 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1945 let Inst{7-6} = 0b00;
1946 let Inst{5-4} = 0b00;
1947 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001948
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001949 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b), IIC_iMUL16,
Evan Cheng699beba2009-10-27 00:08:59 +00001950 !strconcat(opc, "wt"), "\t$dst, $a, $b",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001951 [(set rGPR:$dst, (sra (opnode rGPR:$a,
1952 (sra rGPR:$b, (i32 16))), (i32 16)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001953 let Inst{31-27} = 0b11111;
1954 let Inst{26-23} = 0b0110;
1955 let Inst{22-20} = 0b011;
1956 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
1957 let Inst{7-6} = 0b00;
1958 let Inst{5-4} = 0b01;
1959 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001960}
1961
1962
1963multiclass T2I_smla<string opc, PatFrag opnode> {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001964 def BB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00001965 !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001966 [(set rGPR:$dst, (add rGPR:$acc,
1967 (opnode (sext_inreg rGPR:$a, i16),
1968 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001969 let Inst{31-27} = 0b11111;
1970 let Inst{26-23} = 0b0110;
1971 let Inst{22-20} = 0b001;
1972 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1973 let Inst{7-6} = 0b00;
1974 let Inst{5-4} = 0b00;
1975 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001976
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001977 def BT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00001978 !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001979 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sext_inreg rGPR:$a, i16),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001980 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001981 let Inst{31-27} = 0b11111;
1982 let Inst{26-23} = 0b0110;
1983 let Inst{22-20} = 0b001;
1984 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1985 let Inst{7-6} = 0b00;
1986 let Inst{5-4} = 0b01;
1987 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00001988
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001989 def TB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00001990 !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001991 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00001992 (sext_inreg rGPR:$b, i16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001993 let Inst{31-27} = 0b11111;
1994 let Inst{26-23} = 0b0110;
1995 let Inst{22-20} = 0b001;
1996 let Inst{15-12} = {?, ?, ?, ?}; // Ra
1997 let Inst{7-6} = 0b00;
1998 let Inst{5-4} = 0b10;
1999 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002000
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002001 def TT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002002 !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002003 [(set rGPR:$dst, (add rGPR:$acc, (opnode (sra rGPR:$a, (i32 16)),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002004 (sra rGPR:$b, (i32 16)))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002005 let Inst{31-27} = 0b11111;
2006 let Inst{26-23} = 0b0110;
2007 let Inst{22-20} = 0b001;
2008 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2009 let Inst{7-6} = 0b00;
2010 let Inst{5-4} = 0b11;
2011 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002012
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002013 def WB : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002014 !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002015 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002016 (sext_inreg rGPR:$b, i16)), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002017 let Inst{31-27} = 0b11111;
2018 let Inst{26-23} = 0b0110;
2019 let Inst{22-20} = 0b011;
2020 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2021 let Inst{7-6} = 0b00;
2022 let Inst{5-4} = 0b00;
2023 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002024
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002025 def WT : T2I<(outs rGPR:$dst), (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC16,
Evan Cheng699beba2009-10-27 00:08:59 +00002026 !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002027 [(set rGPR:$dst, (add rGPR:$acc, (sra (opnode rGPR:$a,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002028 (sra rGPR:$b, (i32 16))), (i32 16))))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002029 let Inst{31-27} = 0b11111;
2030 let Inst{26-23} = 0b0110;
2031 let Inst{22-20} = 0b011;
2032 let Inst{15-12} = {?, ?, ?, ?}; // Ra
2033 let Inst{7-6} = 0b00;
2034 let Inst{5-4} = 0b01;
2035 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002036}
2037
2038defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2039defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2040
Johnny Chenadc77332010-02-26 22:04:29 +00002041// Halfword multiple accumulate long: SMLAL<x><y> -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002042def t2SMLALBB : T2I_mac<1, 0b100, 0b1000, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002043 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002044 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002045def t2SMLALBT : T2I_mac<1, 0b100, 0b1001, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002046 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002047 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002048def t2SMLALTB : T2I_mac<1, 0b100, 0b1010, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002049 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002050 [/* For disassembly only; pattern left blank */]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002051def t2SMLALTT : T2I_mac<1, 0b100, 0b1011, (outs rGPR:$ldst,rGPR:$hdst),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002052 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
Johnny Chenadc77332010-02-26 22:04:29 +00002053 [/* For disassembly only; pattern left blank */]>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002054
Johnny Chenadc77332010-02-26 22:04:29 +00002055// Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2056// These are for disassembly only.
2057
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002058def t2SMUAD: T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2059 IIC_iMAC32, "smuad", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002060 let Inst{15-12} = 0b1111;
2061}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002062def t2SMUADX:T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2063 IIC_iMAC32, "smuadx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002064 let Inst{15-12} = 0b1111;
2065}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002066def t2SMUSD: T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2067 IIC_iMAC32, "smusd", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002068 let Inst{15-12} = 0b1111;
2069}
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002070def t2SMUSDX:T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst), (ins rGPR:$a, rGPR:$b),
2071 IIC_iMAC32, "smusdx", "\t$dst, $a, $b", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002072 let Inst{15-12} = 0b1111;
2073}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002074def t2SMLAD : T2I_mac<0, 0b010, 0b0000, (outs rGPR:$dst),
2075 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlad",
Johnny Chenadc77332010-02-26 22:04:29 +00002076 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002077def t2SMLADX : T2I_mac<0, 0b010, 0b0001, (outs rGPR:$dst),
2078 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smladx",
Johnny Chenadc77332010-02-26 22:04:29 +00002079 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002080def t2SMLSD : T2I_mac<0, 0b100, 0b0000, (outs rGPR:$dst),
2081 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsd",
Johnny Chenadc77332010-02-26 22:04:29 +00002082 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002083def t2SMLSDX : T2I_mac<0, 0b100, 0b0001, (outs rGPR:$dst),
2084 (ins rGPR:$a, rGPR:$b, rGPR:$acc), IIC_iMAC32, "smlsdx",
Johnny Chenadc77332010-02-26 22:04:29 +00002085 "\t$dst, $a, $b, $acc", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002086def t2SMLALD : T2I_mac<1, 0b100, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2087 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlald",
Johnny Chenadc77332010-02-26 22:04:29 +00002088 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002089def t2SMLALDX : T2I_mac<1, 0b100, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2090 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlaldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002091 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002092def t2SMLSLD : T2I_mac<1, 0b101, 0b1100, (outs rGPR:$ldst,rGPR:$hdst),
2093 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsld",
Johnny Chenadc77332010-02-26 22:04:29 +00002094 "\t$ldst, $hdst, $a, $b", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002095def t2SMLSLDX : T2I_mac<1, 0b101, 0b1101, (outs rGPR:$ldst,rGPR:$hdst),
2096 (ins rGPR:$a,rGPR:$b), IIC_iMAC64, "smlsldx",
Johnny Chenadc77332010-02-26 22:04:29 +00002097 "\t$ldst, $hdst, $a, $b", []>;
Evan Chengf49810c2009-06-23 17:48:47 +00002098
2099//===----------------------------------------------------------------------===//
2100// Misc. Arithmetic Instructions.
2101//
2102
Jim Grosbach80dc1162010-02-16 21:23:02 +00002103class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2104 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00002105 : T2I<oops, iops, itin, opc, asm, pattern> {
2106 let Inst{31-27} = 0b11111;
2107 let Inst{26-22} = 0b01010;
2108 let Inst{21-20} = op1;
2109 let Inst{15-12} = 0b1111;
2110 let Inst{7-6} = 0b10;
2111 let Inst{5-4} = op2;
2112}
Evan Chengf49810c2009-06-23 17:48:47 +00002113
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002114def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
2115 "clz", "\t$dst, $src", [(set rGPR:$dst, (ctlz rGPR:$src))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002116
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002117def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Evan Chengf609bb82010-01-19 00:44:15 +00002118 "rbit", "\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002119 [(set rGPR:$dst, (ARMrbit rGPR:$src))]>;
Jim Grosbach3482c802010-01-18 19:58:49 +00002120
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002121def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002122 "rev", ".w\t$dst, $src", [(set rGPR:$dst, (bswap rGPR:$src))]>;
Johnny Chend68e1192009-12-15 17:24:14 +00002123
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002124def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002125 "rev16", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002126 [(set rGPR:$dst,
2127 (or (and (srl rGPR:$src, (i32 8)), 0xFF),
2128 (or (and (shl rGPR:$src, (i32 8)), 0xFF00),
2129 (or (and (srl rGPR:$src, (i32 8)), 0xFF0000),
Jim Grosbachc5ed0132010-08-17 18:39:16 +00002130 (and (shl rGPR:$src, (i32 8)), 0xFF000000)))))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002131
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002132def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$dst), (ins rGPR:$src), IIC_iUNAr,
Johnny Chend68e1192009-12-15 17:24:14 +00002133 "revsh", ".w\t$dst, $src",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002134 [(set rGPR:$dst,
Evan Chengf49810c2009-06-23 17:48:47 +00002135 (sext_inreg
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002136 (or (srl (and rGPR:$src, 0xFF00), (i32 8)),
2137 (shl rGPR:$src, (i32 8))), i16))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002138
Bob Wilsonf955f292010-08-17 17:23:19 +00002139def t2PKHBT : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
2140 IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002141 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF),
Bob Wilsonf955f292010-08-17 17:23:19 +00002142 (and (shl rGPR:$src2, lsl_amt:$sh),
Jim Grosbachb1dc3932010-05-05 20:44:35 +00002143 0xFFFF0000)))]>,
Jim Grosbach29402132010-05-05 23:44:43 +00002144 Requires<[HasT2ExtractPack]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002145 let Inst{31-27} = 0b11101;
2146 let Inst{26-25} = 0b01;
2147 let Inst{24-20} = 0b01100;
2148 let Inst{5} = 0; // BT form
2149 let Inst{4} = 0;
2150}
Evan Cheng40289b02009-07-07 05:35:52 +00002151
2152// Alternate cases for PKHBT where identities eliminate some nodes.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002153def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2154 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
Jim Grosbach29402132010-05-05 23:44:43 +00002155 Requires<[HasT2ExtractPack]>;
Bob Wilsonf955f292010-08-17 17:23:19 +00002156def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2157 (t2PKHBT rGPR:$src1, rGPR:$src2, (lsl_shift_imm imm16_31:$sh))>,
Jim Grosbach29402132010-05-05 23:44:43 +00002158 Requires<[HasT2ExtractPack]>;
Evan Cheng40289b02009-07-07 05:35:52 +00002159
Bob Wilsondc66eda2010-08-16 22:26:55 +00002160// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2161// will match the pattern below.
Bob Wilsonf955f292010-08-17 17:23:19 +00002162def t2PKHTB : T2I<(outs rGPR:$dst), (ins rGPR:$src1, rGPR:$src2, shift_imm:$sh),
2163 IIC_iALUsi, "pkhtb", "\t$dst, $src1, $src2$sh",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002164 [(set rGPR:$dst, (or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002165 (and (sra rGPR:$src2, asr_amt:$sh),
2166 0xFFFF)))]>,
Jim Grosbach29402132010-05-05 23:44:43 +00002167 Requires<[HasT2ExtractPack]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002168 let Inst{31-27} = 0b11101;
2169 let Inst{26-25} = 0b01;
2170 let Inst{24-20} = 0b01100;
2171 let Inst{5} = 1; // TB form
2172 let Inst{4} = 0;
2173}
Evan Cheng40289b02009-07-07 05:35:52 +00002174
2175// Alternate cases for PKHTB where identities eliminate some nodes. Note that
2176// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilsondc66eda2010-08-16 22:26:55 +00002177def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
Bob Wilsonf955f292010-08-17 17:23:19 +00002178 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm16_31:$sh))>,
Jim Grosbach29402132010-05-05 23:44:43 +00002179 Requires<[HasT2ExtractPack]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002180def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002181 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2182 (t2PKHTB rGPR:$src1, rGPR:$src2, (asr_shift_imm imm1_15:$sh))>,
Jim Grosbach29402132010-05-05 23:44:43 +00002183 Requires<[HasT2ExtractPack]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002184
2185//===----------------------------------------------------------------------===//
2186// Comparison Instructions...
2187//
Johnny Chend68e1192009-12-15 17:24:14 +00002188defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
2189 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2190defm t2CMPz : T2I_cmp_irs<0b1101, "cmp",
2191 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002192
Dan Gohman4b7dff92010-08-26 15:50:25 +00002193//FIXME: Disable CMN, as CCodes are backwards from compare expectations
2194// Compare-to-zero still works out, just not the relationals
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002195//defm t2CMN : T2I_cmp_irs<0b1000, "cmn",
2196// BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002197defm t2CMNz : T2I_cmp_irs<0b1000, "cmn",
2198 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2199
Jim Grosbachd5d2bae2010-01-22 00:08:13 +00002200//def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2201// (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002202
2203def : T2Pat<(ARMcmpZ GPR:$src, t2_so_imm_neg:$imm),
2204 (t2CMNzri GPR:$src, t2_so_imm_neg:$imm)>;
Evan Chengf49810c2009-06-23 17:48:47 +00002205
Johnny Chend68e1192009-12-15 17:24:14 +00002206defm t2TST : T2I_cmp_irs<0b0000, "tst",
2207 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>>;
2208defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
2209 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002210
Evan Chenge253c952009-07-07 20:39:03 +00002211// Conditional moves
2212// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach64171712010-02-16 21:07:46 +00002213// a two-value operand where a dag node expects two operands. :(
Evan Chengea420b22010-05-19 01:52:25 +00002214let neverHasSideEffects = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002215def t2MOVCCr : T2I<(outs rGPR:$dst), (ins rGPR:$false, rGPR:$true), IIC_iCMOVr,
Evan Cheng699beba2009-10-27 00:08:59 +00002216 "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002217 [/*(set rGPR:$dst, (ARMcmov rGPR:$false, rGPR:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002218 RegConstraint<"$false = $dst"> {
2219 let Inst{31-27} = 0b11101;
2220 let Inst{26-25} = 0b01;
2221 let Inst{24-21} = 0b0010;
2222 let Inst{20} = 0; // The S bit.
2223 let Inst{19-16} = 0b1111; // Rn
2224 let Inst{14-12} = 0b000;
2225 let Inst{7-4} = 0b0000;
2226}
Evan Chenge253c952009-07-07 20:39:03 +00002227
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002228def t2MOVCCi : T2I<(outs rGPR:$dst), (ins rGPR:$false, t2_so_imm:$true),
Evan Cheng699beba2009-10-27 00:08:59 +00002229 IIC_iCMOVi, "mov", ".w\t$dst, $true",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002230[/*(set rGPR:$dst,(ARMcmov rGPR:$false,t2_so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Johnny Chend68e1192009-12-15 17:24:14 +00002231 RegConstraint<"$false = $dst"> {
2232 let Inst{31-27} = 0b11110;
2233 let Inst{25} = 0;
2234 let Inst{24-21} = 0b0010;
2235 let Inst{20} = 0; // The S bit.
2236 let Inst{19-16} = 0b1111; // Rn
2237 let Inst{15} = 0;
2238}
Evan Chengf49810c2009-06-23 17:48:47 +00002239
Johnny Chend68e1192009-12-15 17:24:14 +00002240class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
2241 string opc, string asm, list<dag> pattern>
2242 : T2I<oops, iops, itin, opc, asm, pattern> {
2243 let Inst{31-27} = 0b11101;
2244 let Inst{26-25} = 0b01;
2245 let Inst{24-21} = 0b0010;
2246 let Inst{20} = 0; // The S bit.
2247 let Inst{19-16} = 0b1111; // Rn
2248 let Inst{5-4} = opcod; // Shift type.
2249}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002250def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$dst),
2251 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002252 IIC_iCMOVsi, "lsl", ".w\t$dst, $true, $rhs", []>,
2253 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002254def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$dst),
2255 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002256 IIC_iCMOVsi, "lsr", ".w\t$dst, $true, $rhs", []>,
2257 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002258def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$dst),
2259 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002260 IIC_iCMOVsi, "asr", ".w\t$dst, $true, $rhs", []>,
2261 RegConstraint<"$false = $dst">;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002262def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$dst),
2263 (ins rGPR:$false, rGPR:$true, i32imm:$rhs),
Johnny Chend68e1192009-12-15 17:24:14 +00002264 IIC_iCMOVsi, "ror", ".w\t$dst, $true, $rhs", []>,
2265 RegConstraint<"$false = $dst">;
Evan Chengea420b22010-05-19 01:52:25 +00002266} // neverHasSideEffects
Evan Cheng13f8b362009-08-01 01:43:45 +00002267
David Goodwin5e47a9a2009-06-30 18:04:13 +00002268//===----------------------------------------------------------------------===//
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002269// Atomic operations intrinsics
2270//
2271
2272// memory barriers protect the atomic sequences
2273let hasSideEffects = 1 in {
Evan Cheng11db0682010-08-11 06:22:01 +00002274def t2DMBsy : AInoP<(outs), (ins), ThumbFrm, NoItinerary, "dmb", "",
Evan Chengee349872010-08-11 06:36:31 +00002275 [(ARMMemBarrier)]>, Requires<[IsThumb, HasDB]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002276 let Inst{31-4} = 0xF3BF8F5;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002277 // FIXME: add support for options other than a full system DMB
Johnny Chend68e1192009-12-15 17:24:14 +00002278 let Inst{3-0} = 0b1111;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002279}
2280
Evan Cheng11db0682010-08-11 06:22:01 +00002281def t2DSBsy : AInoP<(outs), (ins), ThumbFrm, NoItinerary, "dsb", "",
Evan Chengee349872010-08-11 06:36:31 +00002282 [(ARMSyncBarrier)]>, Requires<[IsThumb, HasDB]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002283 let Inst{31-4} = 0xF3BF8F4;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002284 // FIXME: add support for options other than a full system DSB
Johnny Chend68e1192009-12-15 17:24:14 +00002285 let Inst{3-0} = 0b1111;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002286}
2287}
2288
Johnny Chena4339822010-03-03 00:16:28 +00002289// Helper class for multiclass T2MemB -- for disassembly only
2290class T2I_memb<string opc, string asm>
2291 : T2I<(outs), (ins), NoItinerary, opc, asm,
2292 [/* For disassembly only; pattern left blank */]>,
2293 Requires<[IsThumb2, HasV7]> {
2294 let Inst{31-20} = 0xf3b;
2295 let Inst{15-14} = 0b10;
2296 let Inst{12} = 0;
2297}
2298
2299multiclass T2MemB<bits<4> op7_4, string opc> {
2300
2301 def st : T2I_memb<opc, "\tst"> {
2302 let Inst{7-4} = op7_4;
2303 let Inst{3-0} = 0b1110;
2304 }
2305
2306 def ish : T2I_memb<opc, "\tish"> {
2307 let Inst{7-4} = op7_4;
2308 let Inst{3-0} = 0b1011;
2309 }
2310
2311 def ishst : T2I_memb<opc, "\tishst"> {
2312 let Inst{7-4} = op7_4;
2313 let Inst{3-0} = 0b1010;
2314 }
2315
2316 def nsh : T2I_memb<opc, "\tnsh"> {
2317 let Inst{7-4} = op7_4;
2318 let Inst{3-0} = 0b0111;
2319 }
2320
2321 def nshst : T2I_memb<opc, "\tnshst"> {
2322 let Inst{7-4} = op7_4;
2323 let Inst{3-0} = 0b0110;
2324 }
2325
2326 def osh : T2I_memb<opc, "\tosh"> {
2327 let Inst{7-4} = op7_4;
2328 let Inst{3-0} = 0b0011;
2329 }
2330
2331 def oshst : T2I_memb<opc, "\toshst"> {
2332 let Inst{7-4} = op7_4;
2333 let Inst{3-0} = 0b0010;
2334 }
2335}
2336
2337// These DMB variants are for disassembly only.
2338defm t2DMB : T2MemB<0b0101, "dmb">;
2339
2340// These DSB variants are for disassembly only.
2341defm t2DSB : T2MemB<0b0100, "dsb">;
2342
2343// ISB has only full system option -- for disassembly only
2344def t2ISBsy : T2I_memb<"isb", ""> {
2345 let Inst{7-4} = 0b0110;
2346 let Inst{3-0} = 0b1111;
2347}
2348
Johnny Chend68e1192009-12-15 17:24:14 +00002349class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2350 InstrItinClass itin, string opc, string asm, string cstr,
2351 list<dag> pattern, bits<4> rt2 = 0b1111>
2352 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2353 let Inst{31-27} = 0b11101;
2354 let Inst{26-20} = 0b0001101;
2355 let Inst{11-8} = rt2;
2356 let Inst{7-6} = 0b01;
2357 let Inst{5-4} = opcod;
2358 let Inst{3-0} = 0b1111;
2359}
2360class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
2361 InstrItinClass itin, string opc, string asm, string cstr,
2362 list<dag> pattern, bits<4> rt2 = 0b1111>
2363 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2364 let Inst{31-27} = 0b11101;
2365 let Inst{26-20} = 0b0001100;
2366 let Inst{11-8} = rt2;
2367 let Inst{7-6} = 0b01;
2368 let Inst{5-4} = opcod;
2369}
2370
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002371let mayLoad = 1 in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002372def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002373 Size4Bytes, NoItinerary, "ldrexb", "\t$dest, [$ptr]",
2374 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002375def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002376 Size4Bytes, NoItinerary, "ldrexh", "\t$dest, [$ptr]",
2377 "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002378def t2LDREX : Thumb2I<(outs rGPR:$dest), (ins rGPR:$ptr), AddrModeNone,
Johnny Chend68e1192009-12-15 17:24:14 +00002379 Size4Bytes, NoItinerary,
2380 "ldrex", "\t$dest, [$ptr]", "",
2381 []> {
2382 let Inst{31-27} = 0b11101;
2383 let Inst{26-20} = 0b0000101;
2384 let Inst{11-8} = 0b1111;
2385 let Inst{7-0} = 0b00000000; // imm8 = 0
2386}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002387def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$dest, rGPR:$dest2), (ins rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002388 AddrModeNone, Size4Bytes, NoItinerary,
2389 "ldrexd", "\t$dest, $dest2, [$ptr]", "",
2390 [], {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002391}
2392
Jim Grosbach587b0722009-12-16 19:44:06 +00002393let mayStore = 1, Constraints = "@earlyclobber $success" in {
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002394def t2STREXB : T2I_strex<0b00, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002395 AddrModeNone, Size4Bytes, NoItinerary,
2396 "strexb", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002397def t2STREXH : T2I_strex<0b01, (outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002398 AddrModeNone, Size4Bytes, NoItinerary,
2399 "strexh", "\t$success, $src, [$ptr]", "", []>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002400def t2STREX : Thumb2I<(outs rGPR:$success), (ins rGPR:$src, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002401 AddrModeNone, Size4Bytes, NoItinerary,
2402 "strex", "\t$success, $src, [$ptr]", "",
2403 []> {
2404 let Inst{31-27} = 0b11101;
2405 let Inst{26-20} = 0b0000100;
2406 let Inst{7-0} = 0b00000000; // imm8 = 0
2407}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002408def t2STREXD : T2I_strex<0b11, (outs rGPR:$success),
2409 (ins rGPR:$src, rGPR:$src2, rGPR:$ptr),
Johnny Chend68e1192009-12-15 17:24:14 +00002410 AddrModeNone, Size4Bytes, NoItinerary,
2411 "strexd", "\t$success, $src, $src2, [$ptr]", "", [],
2412 {?, ?, ?, ?}>;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002413}
2414
Johnny Chen10a77e12010-03-02 22:11:06 +00002415// Clear-Exclusive is for disassembly only.
2416def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "",
2417 [/* For disassembly only; pattern left blank */]>,
2418 Requires<[IsARM, HasV7]> {
2419 let Inst{31-20} = 0xf3b;
2420 let Inst{15-14} = 0b10;
2421 let Inst{12} = 0;
2422 let Inst{7-4} = 0b0010;
2423}
2424
Jim Grosbachc219e4d2009-12-14 18:56:47 +00002425//===----------------------------------------------------------------------===//
David Goodwin334c2642009-07-08 16:09:28 +00002426// TLS Instructions
2427//
2428
2429// __aeabi_read_tp preserves the registers r1-r3.
2430let isCall = 1,
2431 Defs = [R0, R12, LR, CPSR] in {
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002432 def t2TPsoft : T2XI<(outs), (ins), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002433 "bl\t__aeabi_read_tp",
Johnny Chend68e1192009-12-15 17:24:14 +00002434 [(set R0, ARMthread_pointer)]> {
2435 let Inst{31-27} = 0b11110;
2436 let Inst{15-14} = 0b11;
2437 let Inst{12} = 1;
2438 }
David Goodwin334c2642009-07-08 16:09:28 +00002439}
2440
2441//===----------------------------------------------------------------------===//
Jim Grosbach5aa16842009-08-11 19:42:21 +00002442// SJLJ Exception handling intrinsics
Jim Grosbach1add6592009-08-13 15:11:43 +00002443// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach5aa16842009-08-11 19:42:21 +00002444// address and save #0 in R0 for the non-longjmp case.
2445// Since by its nature we may be coming from some other function to get
2446// here, and we're using the stack frame for the containing function to
2447// save/restore registers, we can't keep anything live in regs across
2448// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
2449// when we get here from a longjmp(). We force everthing out of registers
2450// except for our own input by listing the relevant registers in Defs. By
2451// doing so, we also cause the prologue/epilogue code to actively preserve
2452// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach0798edd2010-05-27 23:49:24 +00002453// $val is a scratch register for our use.
Jim Grosbacha87ded22010-02-08 23:22:00 +00002454let Defs =
Jim Grosbachf35d2162009-08-13 16:59:44 +00002455 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2456 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Jim Grosbach5aa16842009-08-11 19:42:21 +00002457 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Jim Grosbach5caeff52010-05-28 17:37:40 +00002458 D31 ], hasSideEffects = 1, isBarrier = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002459 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Jim Grosbach5aa16842009-08-11 19:42:21 +00002460 AddrModeNone, SizeSpecial, NoItinerary,
Jim Grosbachc9792a32010-05-28 17:51:20 +00002461 "mov\t$val, pc\t${:comment} begin eh.setjmp\n\t"
2462 "adds\t$val, #7\n\t"
2463 "str\t$val, [$src, #4]\n\t"
2464 "movs\tr0, #0\n\t"
2465 "b\t1f\n\t"
2466 "movs\tr0, #1\t${:comment} end eh.setjmp\n\t"
Jim Grosbach8db5cce2009-08-13 15:12:16 +00002467 "1:", "",
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 ],
2474 hasSideEffects = 1, isBarrier = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00002475 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Bob Wilsonec80e262010-04-09 20:41:18 +00002476 AddrModeNone, SizeSpecial, NoItinerary,
Jim Grosbachc9792a32010-05-28 17:51:20 +00002477 "mov\t$val, pc\t${:comment} begin eh.setjmp\n\t"
2478 "adds\t$val, #7\n\t"
2479 "str\t$val, [$src, #4]\n\t"
2480 "movs\tr0, #0\n\t"
2481 "b\t1f\n\t"
2482 "movs\tr0, #1\t${:comment} end eh.setjmp\n\t"
Bob Wilsonec80e262010-04-09 20:41:18 +00002483 "1:", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00002484 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00002485 Requires<[IsThumb2, NoVFP]>;
2486}
Jim Grosbach5aa16842009-08-11 19:42:21 +00002487
2488
2489//===----------------------------------------------------------------------===//
David Goodwin5e47a9a2009-06-30 18:04:13 +00002490// Control-Flow Instructions
2491//
2492
Evan Chengc50a1cb2009-07-09 22:58:39 +00002493// FIXME: remove when we have a way to marking a MI with these properties.
2494// FIXME: $dst1 should be a def. But the extra ops must be in the end of the
2495// operand list.
2496// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng0d92f5f2009-10-01 08:22:27 +00002497let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2498 hasExtraDefRegAllocReq = 1 in
Bob Wilson815baeb2010-03-13 01:08:20 +00002499 def t2LDM_RET : T2XIt<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
2500 reglist:$dsts, variable_ops), IIC_Br,
Bob Wilsonfed76ff2010-07-14 16:02:13 +00002501 "ldm${addr:submode}${p}${addr:wide}\t$addr!, $dsts",
Bob Wilson815baeb2010-03-13 01:08:20 +00002502 "$addr.addr = $wb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002503 let Inst{31-27} = 0b11101;
2504 let Inst{26-25} = 0b00;
2505 let Inst{24-23} = {?, ?}; // IA: '01', DB: '10'
2506 let Inst{22} = 0;
Bob Wilson815baeb2010-03-13 01:08:20 +00002507 let Inst{21} = 1; // The W bit.
Johnny Chend68e1192009-12-15 17:24:14 +00002508 let Inst{20} = 1; // Load
2509}
Evan Chengc50a1cb2009-07-09 22:58:39 +00002510
David Goodwin5e47a9a2009-06-30 18:04:13 +00002511let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
2512let isPredicable = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002513def t2B : T2XI<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002514 "b.w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002515 [(br bb:$target)]> {
2516 let Inst{31-27} = 0b11110;
2517 let Inst{15-14} = 0b10;
2518 let Inst{12} = 1;
2519}
David Goodwin5e47a9a2009-06-30 18:04:13 +00002520
Evan Cheng5657c012009-07-29 02:18:14 +00002521let isNotDuplicable = 1, isIndirectBranch = 1 in {
Evan Cheng66ac5312009-07-25 00:33:29 +00002522def t2BR_JT :
Evan Cheng5657c012009-07-29 02:18:14 +00002523 T2JTI<(outs),
2524 (ins GPR:$target, GPR:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002525 IIC_Br, "mov\tpc, $target$jt",
Johnny Chend68e1192009-12-15 17:24:14 +00002526 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]> {
2527 let Inst{31-27} = 0b11101;
2528 let Inst{26-20} = 0b0100100;
2529 let Inst{19-16} = 0b1111;
2530 let Inst{14-12} = 0b000;
2531 let Inst{11-8} = 0b1111; // Rd = pc
2532 let Inst{7-4} = 0b0000;
2533}
Evan Cheng5657c012009-07-29 02:18:14 +00002534
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002535// FIXME: Add a non-pc based case that can be predicated.
Evan Cheng5657c012009-07-29 02:18:14 +00002536def t2TBB :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002537 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002538 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002539 IIC_Br, "tbb\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002540 let Inst{31-27} = 0b11101;
2541 let Inst{26-20} = 0b0001101;
2542 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2543 let Inst{15-8} = 0b11110000;
2544 let Inst{7-4} = 0b0000; // B form
2545}
Evan Cheng5657c012009-07-29 02:18:14 +00002546
2547def t2TBH :
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002548 T2JTI<(outs),
Evan Cheng5657c012009-07-29 02:18:14 +00002549 (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
Bob Wilsond4d188e2010-07-31 06:28:10 +00002550 IIC_Br, "tbh\t$index$jt", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002551 let Inst{31-27} = 0b11101;
2552 let Inst{26-20} = 0b0001101;
2553 let Inst{19-16} = 0b1111; // Rn = pc (table follows this instruction)
2554 let Inst{15-8} = 0b11110000;
2555 let Inst{7-4} = 0b0001; // H form
2556}
Johnny Chen93042d12010-03-02 18:14:57 +00002557
2558// Generic versions of the above two instructions, for disassembly only
2559
2560def t2TBBgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2561 "tbb", "\t[$a, $b]", []>{
2562 let Inst{31-27} = 0b11101;
2563 let Inst{26-20} = 0b0001101;
2564 let Inst{15-8} = 0b11110000;
2565 let Inst{7-4} = 0b0000; // B form
2566}
2567
2568def t2TBHgen : T2I<(outs), (ins GPR:$a, GPR:$b), IIC_Br,
2569 "tbh", "\t[$a, $b, lsl #1]", []> {
2570 let Inst{31-27} = 0b11101;
2571 let Inst{26-20} = 0b0001101;
2572 let Inst{15-8} = 0b11110000;
2573 let Inst{7-4} = 0b0001; // H form
2574}
Evan Cheng5657c012009-07-29 02:18:14 +00002575} // isNotDuplicable, isIndirectBranch
2576
David Goodwinc9a59b52009-06-30 19:50:22 +00002577} // isBranch, isTerminator, isBarrier
David Goodwin5e47a9a2009-06-30 18:04:13 +00002578
2579// FIXME: should be able to write a pattern for ARMBrcond, but can't use
2580// a two-value operand where a dag node expects two operands. :(
2581let isBranch = 1, isTerminator = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00002582def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00002583 "b", ".w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00002584 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
2585 let Inst{31-27} = 0b11110;
2586 let Inst{15-14} = 0b10;
2587 let Inst{12} = 0;
2588}
Evan Chengf49810c2009-06-23 17:48:47 +00002589
Evan Cheng06e16582009-07-10 01:54:42 +00002590
2591// IT block
Evan Cheng86050dc2010-06-18 23:09:54 +00002592let Defs = [ITSTATE] in
Evan Cheng06e16582009-07-10 01:54:42 +00002593def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
David Goodwin5d598aa2009-08-19 18:00:44 +00002594 AddrModeNone, Size2Bytes, IIC_iALUx,
Johnny Chend68e1192009-12-15 17:24:14 +00002595 "it$mask\t$cc", "", []> {
2596 // 16-bit instruction.
Johnny Chenbbc71b22009-12-16 02:32:54 +00002597 let Inst{31-16} = 0x0000;
Johnny Chend68e1192009-12-15 17:24:14 +00002598 let Inst{15-8} = 0b10111111;
2599}
Evan Cheng06e16582009-07-10 01:54:42 +00002600
Johnny Chence6275f2010-02-25 19:05:29 +00002601// Branch and Exchange Jazelle -- for disassembly only
2602// Rm = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002603def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func",
Johnny Chence6275f2010-02-25 19:05:29 +00002604 [/* For disassembly only; pattern left blank */]> {
2605 let Inst{31-27} = 0b11110;
2606 let Inst{26} = 0;
2607 let Inst{25-20} = 0b111100;
2608 let Inst{15-14} = 0b10;
2609 let Inst{12} = 0;
2610}
2611
Johnny Chen93042d12010-03-02 18:14:57 +00002612// Change Processor State is a system instruction -- for disassembly only.
2613// The singleton $opt operand contains the following information:
2614// opt{4-0} = mode from Inst{4-0}
2615// opt{5} = changemode from Inst{17}
2616// opt{8-6} = AIF from Inst{8-6}
2617// opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002618def t2CPS : T2XI<(outs),(ins cps_opt:$opt), NoItinerary, "cps$opt",
Johnny Chen93042d12010-03-02 18:14:57 +00002619 [/* For disassembly only; pattern left blank */]> {
2620 let Inst{31-27} = 0b11110;
2621 let Inst{26} = 0;
2622 let Inst{25-20} = 0b111010;
2623 let Inst{15-14} = 0b10;
2624 let Inst{12} = 0;
2625}
2626
Johnny Chen0f7866e2010-03-03 02:09:43 +00002627// A6.3.4 Branches and miscellaneous control
2628// Table A6-14 Change Processor State, and hint instructions
2629// Helper class for disassembly only.
2630class T2I_hint<bits<8> op7_0, string opc, string asm>
2631 : T2I<(outs), (ins), NoItinerary, opc, asm,
2632 [/* For disassembly only; pattern left blank */]> {
2633 let Inst{31-20} = 0xf3a;
2634 let Inst{15-14} = 0b10;
2635 let Inst{12} = 0;
2636 let Inst{10-8} = 0b000;
2637 let Inst{7-0} = op7_0;
2638}
2639
2640def t2NOP : T2I_hint<0b00000000, "nop", ".w">;
2641def t2YIELD : T2I_hint<0b00000001, "yield", ".w">;
2642def t2WFE : T2I_hint<0b00000010, "wfe", ".w">;
2643def t2WFI : T2I_hint<0b00000011, "wfi", ".w">;
2644def t2SEV : T2I_hint<0b00000100, "sev", ".w">;
2645
2646def t2DBG : T2I<(outs),(ins i32imm:$opt), NoItinerary, "dbg", "\t$opt",
2647 [/* For disassembly only; pattern left blank */]> {
2648 let Inst{31-20} = 0xf3a;
2649 let Inst{15-14} = 0b10;
2650 let Inst{12} = 0;
2651 let Inst{10-8} = 0b000;
2652 let Inst{7-4} = 0b1111;
2653}
2654
Johnny Chen6341c5a2010-02-25 20:25:24 +00002655// Secure Monitor Call is a system instruction -- for disassembly only
2656// Option = Inst{19-16}
2657def t2SMC : T2I<(outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
2658 [/* For disassembly only; pattern left blank */]> {
2659 let Inst{31-27} = 0b11110;
2660 let Inst{26-20} = 0b1111111;
2661 let Inst{15-12} = 0b1000;
2662}
2663
2664// Store Return State is a system instruction -- for disassembly only
2665def t2SRSDBW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp!, $mode",
2666 [/* For disassembly only; pattern left blank */]> {
2667 let Inst{31-27} = 0b11101;
2668 let Inst{26-20} = 0b0000010; // W = 1
2669}
2670
2671def t2SRSDB : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp, $mode",
2672 [/* For disassembly only; pattern left blank */]> {
2673 let Inst{31-27} = 0b11101;
2674 let Inst{26-20} = 0b0000000; // W = 0
2675}
2676
2677def t2SRSIAW : T2I<(outs),(ins i32imm:$mode),NoItinerary,"srsia","\tsp!, $mode",
2678 [/* For disassembly only; pattern left blank */]> {
2679 let Inst{31-27} = 0b11101;
2680 let Inst{26-20} = 0b0011010; // W = 1
2681}
2682
2683def t2SRSIA : T2I<(outs), (ins i32imm:$mode),NoItinerary,"srsia","\tsp, $mode",
2684 [/* For disassembly only; pattern left blank */]> {
2685 let Inst{31-27} = 0b11101;
2686 let Inst{26-20} = 0b0011000; // W = 0
2687}
2688
2689// Return From Exception is a system instruction -- for disassembly only
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002690def t2RFEDBW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfedb", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002691 [/* For disassembly only; pattern left blank */]> {
2692 let Inst{31-27} = 0b11101;
2693 let Inst{26-20} = 0b0000011; // W = 1
2694}
2695
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002696def t2RFEDB : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeab", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002697 [/* For disassembly only; pattern left blank */]> {
2698 let Inst{31-27} = 0b11101;
2699 let Inst{26-20} = 0b0000001; // W = 0
2700}
2701
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002702def t2RFEIAW : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base!",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002703 [/* For disassembly only; pattern left blank */]> {
2704 let Inst{31-27} = 0b11101;
2705 let Inst{26-20} = 0b0011011; // W = 1
2706}
2707
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002708def t2RFEIA : T2I<(outs), (ins rGPR:$base), NoItinerary, "rfeia", "\t$base",
Johnny Chen6341c5a2010-02-25 20:25:24 +00002709 [/* For disassembly only; pattern left blank */]> {
2710 let Inst{31-27} = 0b11101;
2711 let Inst{26-20} = 0b0011001; // W = 0
2712}
2713
Evan Chengf49810c2009-06-23 17:48:47 +00002714//===----------------------------------------------------------------------===//
2715// Non-Instruction Patterns
2716//
2717
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002718// Two piece so_imms.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002719def : T2Pat<(or rGPR:$LHS, t2_so_imm2part:$RHS),
2720 (t2ORRri (t2ORRri 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<(xor rGPR:$LHS, t2_so_imm2part:$RHS),
2723 (t2EORri (t2EORri 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_imm2part:$RHS),
2726 (t2ADDri (t2ADDri rGPR:$LHS, (t2_so_imm2part_1 imm:$RHS)),
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002727 (t2_so_imm2part_2 imm:$RHS))>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002728def : T2Pat<(add rGPR:$LHS, t2_so_neg_imm2part:$RHS),
2729 (t2SUBri (t2SUBri rGPR:$LHS, (t2_so_neg_imm2part_1 imm:$RHS)),
Jim Grosbach15e6ef82009-11-23 20:35:53 +00002730 (t2_so_neg_imm2part_2 imm:$RHS))>;
Jim Grosbach65b7f3a2009-10-21 20:44:34 +00002731
Evan Cheng5adb66a2009-09-28 09:14:39 +00002732// 32-bit immediate using movw + movt.
2733// This is a single pseudo instruction to make it re-materializable. Remove
2734// when we can do generalized remat.
2735let isReMaterializable = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002736def t2MOVi32imm : T2Ix2<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVi,
Evan Cheng699beba2009-10-27 00:08:59 +00002737 "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}",
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002738 [(set rGPR:$dst, (i32 imm:$src))]>;
Evan Chengb9803a82009-11-06 23:52:48 +00002739
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +00002740// ConstantPool, GlobalAddress, and JumpTable
2741def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
2742 Requires<[IsThumb2, DontUseMovt]>;
2743def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
2744def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
2745 Requires<[IsThumb2, UseMovt]>;
2746
2747def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
2748 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
2749
Evan Chengb9803a82009-11-06 23:52:48 +00002750// Pseudo instruction that combines ldr from constpool and add pc. This should
2751// be expanded into two instructions late to allow if-conversion and
2752// scheduling.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00002753let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Chengb9803a82009-11-06 23:52:48 +00002754def t2LDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp),
Jim Grosbach18f30e62010-06-02 21:53:11 +00002755 NoItinerary,
2756 "${:comment} ldr.w\t$dst, $addr\n$cp:\n\tadd\t$dst, pc",
Evan Chengb9803a82009-11-06 23:52:48 +00002757 [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
2758 imm:$cp))]>,
2759 Requires<[IsThumb2]>;
Johnny Chen23336552010-02-25 18:46:43 +00002760
2761//===----------------------------------------------------------------------===//
2762// Move between special register and ARM core register -- for disassembly only
2763//
2764
2765// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002766def t2MRS : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, cpsr",
Johnny Chen23336552010-02-25 18:46:43 +00002767 [/* For disassembly only; pattern left blank */]> {
2768 let Inst{31-27} = 0b11110;
2769 let Inst{26} = 0;
2770 let Inst{25-21} = 0b11111;
2771 let Inst{20} = 0; // The R bit.
2772 let Inst{15-14} = 0b10;
2773 let Inst{12} = 0;
2774}
2775
2776// Rd = Instr{11-8}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002777def t2MRSsys : T2I<(outs rGPR:$dst), (ins), NoItinerary, "mrs", "\t$dst, spsr",
Johnny Chen23336552010-02-25 18:46:43 +00002778 [/* For disassembly only; pattern left blank */]> {
2779 let Inst{31-27} = 0b11110;
2780 let Inst{26} = 0;
2781 let Inst{25-21} = 0b11111;
2782 let Inst{20} = 1; // The R bit.
2783 let Inst{15-14} = 0b10;
2784 let Inst{12} = 0;
2785}
2786
Johnny Chen23336552010-02-25 18:46:43 +00002787// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002788def t2MSR : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002789 "\tcpsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00002790 [/* For disassembly only; pattern left blank */]> {
2791 let Inst{31-27} = 0b11110;
2792 let Inst{26} = 0;
2793 let Inst{25-21} = 0b11100;
2794 let Inst{20} = 0; // The R bit.
2795 let Inst{15-14} = 0b10;
2796 let Inst{12} = 0;
2797}
2798
Johnny Chen23336552010-02-25 18:46:43 +00002799// Rn = Inst{19-16}
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002800def t2MSRsys : T2I<(outs), (ins rGPR:$src, msr_mask:$mask), NoItinerary, "msr",
Johnny Chendd0f3cf2010-03-10 18:59:38 +00002801 "\tspsr$mask, $src",
Johnny Chen23336552010-02-25 18:46:43 +00002802 [/* For disassembly only; pattern left blank */]> {
2803 let Inst{31-27} = 0b11110;
2804 let Inst{26} = 0;
2805 let Inst{25-21} = 0b11100;
2806 let Inst{20} = 1; // The R bit.
2807 let Inst{15-14} = 0b10;
2808 let Inst{12} = 0;
2809}