blob: c9d709eb5222e3f0a29442c20ea7863286218f9f [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- ARMInstrThumb2.td - Thumb2 support for ARM ---------*- tablegen -*-===//
Anton Korobeynikovd4022c32009-05-29 23:41:08 +00002//
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
Jim Grosbach89df9962011-08-26 21:43:41 +000015def it_pred_asmoperand : AsmOperandClass {
16 let Name = "ITCondCode";
17 let ParserMethod = "parseITCondCode";
18}
Evan Cheng06e16582009-07-10 01:54:42 +000019def it_pred : Operand<i32> {
Johnny Chen9d3acaa2010-03-02 17:57:15 +000020 let PrintMethod = "printMandatoryPredicateOperand";
Jim Grosbach89df9962011-08-26 21:43:41 +000021 let ParserMatchClass = it_pred_asmoperand;
Evan Cheng06e16582009-07-10 01:54:42 +000022}
23
24// IT block condition mask
Jim Grosbach89df9962011-08-26 21:43:41 +000025def it_mask_asmoperand : AsmOperandClass { let Name = "ITMask"; }
Evan Cheng06e16582009-07-10 01:54:42 +000026def it_mask : Operand<i32> {
27 let PrintMethod = "printThumbITMask";
Jim Grosbach89df9962011-08-26 21:43:41 +000028 let ParserMatchClass = it_mask_asmoperand;
Evan Cheng06e16582009-07-10 01:54:42 +000029}
30
Owen Anderson0afa0092011-09-26 21:06:22 +000031// t2_shift_imm: An integer that encodes a shift amount and the type of shift
32// (asr or lsl). The 6-bit immediate encodes as:
33// {5} 0 ==> lsl
34// 1 asr
35// {4-0} imm5 shift amount.
36// asr #32 not allowed
37def t2_shift_imm : Operand<i32> {
38 let PrintMethod = "printShiftImmOperand";
39 let ParserMatchClass = ShifterImmAsmOperand;
40 let DecoderMethod = "DecodeT2ShifterImmOperand";
41}
42
Anton Korobeynikov52237112009-06-17 18:13:58 +000043// Shifted operands. No register controlled shifts for Thumb2.
44// Note: We do not support rrx shifted operands yet.
45def t2_so_reg : Operand<i32>, // reg imm
Evan Cheng9cb9e672009-06-27 02:26:13 +000046 ComplexPattern<i32, 2, "SelectT2ShifterOperandReg",
Anton Korobeynikov52237112009-06-17 18:13:58 +000047 [shl,srl,sra,rotr]> {
Chris Lattner2ac19022010-11-15 05:19:05 +000048 let EncoderMethod = "getT2SORegOpValue";
Evan Cheng9cb9e672009-06-27 02:26:13 +000049 let PrintMethod = "printT2SOOperand";
Owen Anderson2c9f8352011-08-22 23:10:16 +000050 let DecoderMethod = "DecodeSORegImmOperand";
Jim Grosbach72335d52011-08-31 18:23:08 +000051 let ParserMatchClass = ShiftedImmAsmOperand;
52 let MIOperandInfo = (ops rGPR, i32imm);
Anton Korobeynikov52237112009-06-17 18:13:58 +000053}
54
Evan Chengf49810c2009-06-23 17:48:47 +000055// t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
56def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{
Owen Anderson825b72b2009-08-11 20:47:22 +000057 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
Anton Korobeynikov52237112009-06-17 18:13:58 +000058}]>;
59
Evan Chengf49810c2009-06-23 17:48:47 +000060// t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
61def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
Owen Anderson825b72b2009-08-11 20:47:22 +000062 return CurDAG->getTargetConstant(-((int)N->getZExtValue()), MVT::i32);
Evan Chengf49810c2009-06-23 17:48:47 +000063}]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +000064
Joel Jones96ef2842012-06-18 14:51:32 +000065// so_imm_notSext_XFORM - Return a so_imm value packed into the format
66// described for so_imm_notSext def below, with sign extension from 16
67// bits.
68def t2_so_imm_notSext16_XFORM : SDNodeXForm<imm, [{
69 APInt apIntN = N->getAPIntValue();
70 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue();
71 return CurDAG->getTargetConstant(~N16bitSignExt, MVT::i32);
72}]>;
73
Evan Chengf49810c2009-06-23 17:48:47 +000074// t2_so_imm - Match a 32-bit immediate operand, which is an
75// 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
Bob Wilson09989942011-02-07 17:43:06 +000076// immediate splatted into multiple bytes of the word.
Jim Grosbach9588c102011-11-12 00:58:43 +000077def t2_so_imm_asmoperand : ImmAsmOperand { let Name = "T2SOImm"; }
Eli Friedmanc573e2c2011-04-29 22:48:03 +000078def t2_so_imm : Operand<i32>, ImmLeaf<i32, [{
79 return ARM_AM::getT2SOImmVal(Imm) != -1;
80 }]> {
Jim Grosbach6b8f1e32011-06-27 23:54:06 +000081 let ParserMatchClass = t2_so_imm_asmoperand;
Chris Lattner2ac19022010-11-15 05:19:05 +000082 let EncoderMethod = "getT2SOImmOpValue";
Owen Anderson8d7d2e12011-08-09 20:55:18 +000083 let DecoderMethod = "DecodeT2SOImm";
Owen Anderson5de6d842010-11-12 21:12:40 +000084}
Anton Korobeynikov52237112009-06-17 18:13:58 +000085
Jim Grosbach64171712010-02-16 21:07:46 +000086// t2_so_imm_not - Match an immediate that is a complement
Evan Chengf49810c2009-06-23 17:48:47 +000087// of a t2_so_imm.
Jim Grosbach89a63372011-10-28 22:36:30 +000088// Note: this pattern doesn't require an encoder method and such, as it's
89// only used on aliases (Pat<> and InstAlias<>). The actual encoding
90// is handled by the destination instructions, which use t2_so_imm.
91def t2_so_imm_not_asmoperand : AsmOperandClass { let Name = "T2SOImmNot"; }
Jim Grosbach3bc8a3d2011-12-08 00:31:07 +000092def t2_so_imm_not : Operand<i32>, PatLeaf<(imm), [{
Evan Chenge7cbe412009-07-08 21:03:57 +000093 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
Jim Grosbach89a63372011-10-28 22:36:30 +000094}], t2_so_imm_not_XFORM> {
95 let ParserMatchClass = t2_so_imm_not_asmoperand;
96}
Evan Chengf49810c2009-06-23 17:48:47 +000097
Joel Jones96ef2842012-06-18 14:51:32 +000098// t2_so_imm_notSext - match an immediate that is a complement of a t2_so_imm
99// if the upper 16 bits are zero.
100def t2_so_imm_notSext : Operand<i32>, PatLeaf<(imm), [{
101 APInt apIntN = N->getAPIntValue();
102 if (!apIntN.isIntN(16)) return false;
103 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue();
104 return ARM_AM::getT2SOImmVal(~N16bitSignExt) != -1;
105 }], t2_so_imm_notSext16_XFORM> {
106 let ParserMatchClass = t2_so_imm_not_asmoperand;
107}
108
Evan Chengf49810c2009-06-23 17:48:47 +0000109// t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
Jim Grosbach3bc8a3d2011-12-08 00:31:07 +0000110def t2_so_imm_neg_asmoperand : AsmOperandClass { let Name = "T2SOImmNeg"; }
111def t2_so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
Jim Grosbachb22e70d2012-03-29 21:19:52 +0000112 int64_t Value = -(int)N->getZExtValue();
113 return Value && ARM_AM::getT2SOImmVal(Value) != -1;
Jim Grosbach3bc8a3d2011-12-08 00:31:07 +0000114}], t2_so_imm_neg_XFORM> {
115 let ParserMatchClass = t2_so_imm_neg_asmoperand;
116}
Evan Chengf49810c2009-06-23 17:48:47 +0000117
118/// imm0_4095 predicate - True if the 32-bit immediate is in the range [0.4095].
Jim Grosbach4e53fe82012-04-05 20:57:13 +0000119def imm0_4095_asmoperand: ImmAsmOperand { let Name = "Imm0_4095"; }
120def imm0_4095 : Operand<i32>, ImmLeaf<i32, [{
Eric Christopher8f232d32011-04-28 05:49:04 +0000121 return Imm >= 0 && Imm < 4096;
Jim Grosbach4e53fe82012-04-05 20:57:13 +0000122}]> {
123 let ParserMatchClass = imm0_4095_asmoperand;
124}
Anton Korobeynikov52237112009-06-17 18:13:58 +0000125
Jim Grosbach4e53fe82012-04-05 20:57:13 +0000126def imm0_4095_neg_asmoperand: AsmOperandClass { let Name = "Imm0_4095Neg"; }
127def imm0_4095_neg : Operand<i32>, PatLeaf<(i32 imm), [{
Jim Grosbach64171712010-02-16 21:07:46 +0000128 return (uint32_t)(-N->getZExtValue()) < 4096;
Jim Grosbach4e53fe82012-04-05 20:57:13 +0000129}], imm_neg_XFORM> {
130 let ParserMatchClass = imm0_4095_neg_asmoperand;
131}
Anton Korobeynikov52237112009-06-17 18:13:58 +0000132
Nadav Rotem50b66382012-11-14 19:39:15 +0000133def imm1_255_neg : PatLeaf<(i32 imm), [{
134 uint32_t Val = -N->getZExtValue();
135 return (Val > 0 && Val < 255);
Jim Grosbach64171712010-02-16 21:07:46 +0000136}], imm_neg_XFORM>;
Evan Chengfa2ea1a2009-08-04 01:41:15 +0000137
Jim Grosbach502e0aa2010-07-14 17:45:16 +0000138def imm0_255_not : PatLeaf<(i32 imm), [{
139 return (uint32_t)(~N->getZExtValue()) < 255;
140}], imm_comp_XFORM>;
141
Andrew Trickd49ffe82011-04-29 14:18:15 +0000142def lo5AllOne : PatLeaf<(i32 imm), [{
143 // Returns true if all low 5-bits are 1.
144 return (((uint32_t)N->getZExtValue()) & 0x1FUL) == 0x1FUL;
145}]>;
146
Evan Cheng055b0312009-06-29 07:51:04 +0000147// Define Thumb2 specific addressing modes.
148
149// t2addrmode_imm12 := reg + imm12
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000150def t2addrmode_imm12_asmoperand : AsmOperandClass {let Name="MemUImm12Offset";}
Evan Cheng055b0312009-06-29 07:51:04 +0000151def t2addrmode_imm12 : Operand<i32>,
152 ComplexPattern<i32, 2, "SelectT2AddrModeImm12", []> {
Jim Grosbach458f2dc2010-10-25 20:00:01 +0000153 let PrintMethod = "printAddrModeImm12Operand";
Jim Grosbach683fc3e2010-12-10 20:53:44 +0000154 let EncoderMethod = "getAddrModeImm12OpValue";
Owen Anderson8d7d2e12011-08-09 20:55:18 +0000155 let DecoderMethod = "DecodeT2AddrModeImm12";
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000156 let ParserMatchClass = t2addrmode_imm12_asmoperand;
Evan Cheng055b0312009-06-29 07:51:04 +0000157 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
158}
159
Owen Andersonc9bd4962011-03-18 17:42:55 +0000160// t2ldrlabel := imm12
161def t2ldrlabel : Operand<i32> {
162 let EncoderMethod = "getAddrModeImm12OpValue";
Jim Grosbach8ba14742012-10-30 01:04:51 +0000163 let PrintMethod = "printThumbLdrLabelOperand";
Owen Andersonc9bd4962011-03-18 17:42:55 +0000164}
165
Jim Grosbach0b4c6732012-01-18 22:46:46 +0000166def t2ldr_pcrel_imm12_asmoperand : AsmOperandClass {let Name = "MemPCRelImm12";}
167def t2ldr_pcrel_imm12 : Operand<i32> {
168 let ParserMatchClass = t2ldr_pcrel_imm12_asmoperand;
169 // used for assembler pseudo instruction and maps to t2ldrlabel, so
170 // doesn't need encoder or print methods of its own.
171}
Owen Andersonc9bd4962011-03-18 17:42:55 +0000172
Owen Andersona838a252010-12-14 00:36:49 +0000173// ADR instruction labels.
174def t2adrlabel : Operand<i32> {
175 let EncoderMethod = "getT2AdrLabelOpValue";
Jiangning Liu1fb27ec2012-08-02 08:13:13 +0000176 let PrintMethod = "printAdrLabelOperand";
Owen Andersona838a252010-12-14 00:36:49 +0000177}
178
179
Jim Grosbachf0eee6e2011-09-07 23:39:14 +0000180// t2addrmode_posimm8 := reg + imm8
181def MemPosImm8OffsetAsmOperand : AsmOperandClass {let Name="MemPosImm8Offset";}
182def t2addrmode_posimm8 : Operand<i32> {
183 let PrintMethod = "printT2AddrModeImm8Operand";
184 let EncoderMethod = "getT2AddrModeImm8OpValue";
185 let DecoderMethod = "DecodeT2AddrModeImm8";
186 let ParserMatchClass = MemPosImm8OffsetAsmOperand;
187 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
188}
189
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000190// t2addrmode_negimm8 := reg - imm8
191def MemNegImm8OffsetAsmOperand : AsmOperandClass {let Name="MemNegImm8Offset";}
192def t2addrmode_negimm8 : Operand<i32>,
193 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
194 let PrintMethod = "printT2AddrModeImm8Operand";
195 let EncoderMethod = "getT2AddrModeImm8OpValue";
196 let DecoderMethod = "DecodeT2AddrModeImm8";
197 let ParserMatchClass = MemNegImm8OffsetAsmOperand;
198 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
199}
200
Johnny Chen0635fc52010-03-04 17:40:44 +0000201// t2addrmode_imm8 := reg +/- imm8
Jim Grosbach7ce05792011-08-03 23:50:40 +0000202def MemImm8OffsetAsmOperand : AsmOperandClass { let Name = "MemImm8Offset"; }
Evan Cheng055b0312009-06-29 07:51:04 +0000203def t2addrmode_imm8 : Operand<i32>,
204 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
205 let PrintMethod = "printT2AddrModeImm8Operand";
Jim Grosbach683fc3e2010-12-10 20:53:44 +0000206 let EncoderMethod = "getT2AddrModeImm8OpValue";
Owen Anderson8d7d2e12011-08-09 20:55:18 +0000207 let DecoderMethod = "DecodeT2AddrModeImm8";
Jim Grosbach7ce05792011-08-03 23:50:40 +0000208 let ParserMatchClass = MemImm8OffsetAsmOperand;
Evan Cheng055b0312009-06-29 07:51:04 +0000209 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
210}
211
Evan Cheng6d94f112009-07-03 00:06:39 +0000212def t2am_imm8_offset : Operand<i32>,
Chris Lattner52a261b2010-09-21 20:31:19 +0000213 ComplexPattern<i32, 1, "SelectT2AddrModeImm8Offset",
214 [], [SDNPWantRoot]> {
Evan Chenge88d5ce2009-07-02 07:28:31 +0000215 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
Jim Grosbach683fc3e2010-12-10 20:53:44 +0000216 let EncoderMethod = "getT2AddrModeImm8OffsetOpValue";
Owen Anderson8d7d2e12011-08-09 20:55:18 +0000217 let DecoderMethod = "DecodeT2Imm8";
Evan Chenge88d5ce2009-07-02 07:28:31 +0000218}
219
Evan Cheng5c874172009-07-09 22:21:59 +0000220// t2addrmode_imm8s4 := reg +/- (imm8 << 2)
Jim Grosbacha77295d2011-09-08 22:07:06 +0000221def MemImm8s4OffsetAsmOperand : AsmOperandClass {let Name = "MemImm8s4Offset";}
Chris Lattner979b0612010-09-05 22:51:11 +0000222def t2addrmode_imm8s4 : Operand<i32> {
Evan Cheng5c874172009-07-09 22:21:59 +0000223 let PrintMethod = "printT2AddrModeImm8s4Operand";
Jim Grosbach683fc3e2010-12-10 20:53:44 +0000224 let EncoderMethod = "getT2AddrModeImm8s4OpValue";
Owen Anderson8d7d2e12011-08-09 20:55:18 +0000225 let DecoderMethod = "DecodeT2AddrModeImm8s4";
Jim Grosbacha77295d2011-09-08 22:07:06 +0000226 let ParserMatchClass = MemImm8s4OffsetAsmOperand;
David Goodwin6647cea2009-06-30 22:50:01 +0000227 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
228}
229
Jim Grosbacha77295d2011-09-08 22:07:06 +0000230def t2am_imm8s4_offset_asmoperand : AsmOperandClass { let Name = "Imm8s4"; }
Johnny Chenae1757b2010-03-11 01:13:36 +0000231def t2am_imm8s4_offset : Operand<i32> {
232 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand";
Jim Grosbacha77295d2011-09-08 22:07:06 +0000233 let EncoderMethod = "getT2Imm8s4OpValue";
Owen Anderson14c903a2011-08-04 23:18:05 +0000234 let DecoderMethod = "DecodeT2Imm8S4";
Johnny Chenae1757b2010-03-11 01:13:36 +0000235}
236
Jim Grosbachb6aed502011-09-09 18:37:27 +0000237// t2addrmode_imm0_1020s4 := reg + (imm8 << 2)
238def MemImm0_1020s4OffsetAsmOperand : AsmOperandClass {
239 let Name = "MemImm0_1020s4Offset";
240}
241def t2addrmode_imm0_1020s4 : Operand<i32> {
242 let PrintMethod = "printT2AddrModeImm0_1020s4Operand";
243 let EncoderMethod = "getT2AddrModeImm0_1020s4OpValue";
244 let DecoderMethod = "DecodeT2AddrModeImm0_1020s4";
245 let ParserMatchClass = MemImm0_1020s4OffsetAsmOperand;
246 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
247}
248
Evan Chengcba962d2009-07-09 20:40:44 +0000249// t2addrmode_so_reg := reg + (reg << imm2)
Jim Grosbachab899c12011-09-07 23:10:15 +0000250def t2addrmode_so_reg_asmoperand : AsmOperandClass {let Name="T2MemRegOffset";}
Evan Cheng055b0312009-06-29 07:51:04 +0000251def t2addrmode_so_reg : Operand<i32>,
252 ComplexPattern<i32, 3, "SelectT2AddrModeSoReg", []> {
253 let PrintMethod = "printT2AddrModeSoRegOperand";
Jim Grosbach683fc3e2010-12-10 20:53:44 +0000254 let EncoderMethod = "getT2AddrModeSORegOpValue";
Owen Anderson8d7d2e12011-08-09 20:55:18 +0000255 let DecoderMethod = "DecodeT2AddrModeSOReg";
Jim Grosbachab899c12011-09-07 23:10:15 +0000256 let ParserMatchClass = t2addrmode_so_reg_asmoperand;
Jim Grosbach6ccfc502010-07-30 02:41:01 +0000257 let MIOperandInfo = (ops GPR:$base, rGPR:$offsreg, i32imm:$offsimm);
Evan Cheng055b0312009-06-29 07:51:04 +0000258}
259
Jim Grosbach7f739be2011-09-19 22:21:13 +0000260// Addresses for the TBB/TBH instructions.
261def addrmode_tbb_asmoperand : AsmOperandClass { let Name = "MemTBB"; }
262def addrmode_tbb : Operand<i32> {
263 let PrintMethod = "printAddrModeTBB";
264 let ParserMatchClass = addrmode_tbb_asmoperand;
265 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm);
266}
267def addrmode_tbh_asmoperand : AsmOperandClass { let Name = "MemTBH"; }
268def addrmode_tbh : Operand<i32> {
269 let PrintMethod = "printAddrModeTBH";
270 let ParserMatchClass = addrmode_tbh_asmoperand;
271 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm);
272}
273
Anton Korobeynikov52237112009-06-17 18:13:58 +0000274//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +0000275// Multiclass helpers...
Anton Korobeynikov52237112009-06-17 18:13:58 +0000276//
277
Owen Andersona99e7782010-11-15 18:45:17 +0000278
279class T2OneRegImm<dag oops, dag iops, InstrItinClass itin,
Owen Anderson83da6cd2010-11-14 05:37:38 +0000280 string opc, string asm, list<dag> pattern>
281 : T2I<oops, iops, itin, opc, asm, pattern> {
282 bits<4> Rd;
Owen Andersona99e7782010-11-15 18:45:17 +0000283 bits<12> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000284
Jim Grosbach86386922010-12-08 22:10:43 +0000285 let Inst{11-8} = Rd;
Owen Andersona99e7782010-11-15 18:45:17 +0000286 let Inst{26} = imm{11};
287 let Inst{14-12} = imm{10-8};
288 let Inst{7-0} = imm{7-0};
289}
290
Owen Andersonbb6315d2010-11-15 19:58:36 +0000291
Owen Andersona99e7782010-11-15 18:45:17 +0000292class T2sOneRegImm<dag oops, dag iops, InstrItinClass itin,
293 string opc, string asm, list<dag> pattern>
294 : T2sI<oops, iops, itin, opc, asm, pattern> {
295 bits<4> Rd;
Owen Anderson83da6cd2010-11-14 05:37:38 +0000296 bits<4> Rn;
297 bits<12> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000298
Jim Grosbach86386922010-12-08 22:10:43 +0000299 let Inst{11-8} = Rd;
Owen Anderson83da6cd2010-11-14 05:37:38 +0000300 let Inst{26} = imm{11};
301 let Inst{14-12} = imm{10-8};
302 let Inst{7-0} = imm{7-0};
303}
304
Owen Andersonbb6315d2010-11-15 19:58:36 +0000305class T2OneRegCmpImm<dag oops, dag iops, InstrItinClass itin,
306 string opc, string asm, list<dag> pattern>
307 : T2I<oops, iops, itin, opc, asm, pattern> {
308 bits<4> Rn;
309 bits<12> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000310
Jim Grosbach86386922010-12-08 22:10:43 +0000311 let Inst{19-16} = Rn;
Owen Andersonbb6315d2010-11-15 19:58:36 +0000312 let Inst{26} = imm{11};
313 let Inst{14-12} = imm{10-8};
314 let Inst{7-0} = imm{7-0};
315}
316
317
Owen Andersona99e7782010-11-15 18:45:17 +0000318class T2OneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
319 string opc, string asm, list<dag> pattern>
320 : T2I<oops, iops, itin, opc, asm, pattern> {
321 bits<4> Rd;
322 bits<12> ShiftedRm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000323
Jim Grosbach86386922010-12-08 22:10:43 +0000324 let Inst{11-8} = Rd;
Owen Andersona99e7782010-11-15 18:45:17 +0000325 let Inst{3-0} = ShiftedRm{3-0};
326 let Inst{5-4} = ShiftedRm{6-5};
327 let Inst{14-12} = ShiftedRm{11-9};
328 let Inst{7-6} = ShiftedRm{8-7};
329}
330
331class T2sOneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
332 string opc, string asm, list<dag> pattern>
Owen Andersonbdf71442010-12-07 20:50:15 +0000333 : T2sI<oops, iops, itin, opc, asm, pattern> {
Owen Andersona99e7782010-11-15 18:45:17 +0000334 bits<4> Rd;
335 bits<12> ShiftedRm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000336
Jim Grosbach86386922010-12-08 22:10:43 +0000337 let Inst{11-8} = Rd;
Owen Andersona99e7782010-11-15 18:45:17 +0000338 let Inst{3-0} = ShiftedRm{3-0};
339 let Inst{5-4} = ShiftedRm{6-5};
340 let Inst{14-12} = ShiftedRm{11-9};
341 let Inst{7-6} = ShiftedRm{8-7};
342}
343
Owen Andersonbb6315d2010-11-15 19:58:36 +0000344class T2OneRegCmpShiftedReg<dag oops, dag iops, InstrItinClass itin,
345 string opc, string asm, list<dag> pattern>
346 : T2I<oops, iops, itin, opc, asm, pattern> {
347 bits<4> Rn;
348 bits<12> ShiftedRm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000349
Jim Grosbach86386922010-12-08 22:10:43 +0000350 let Inst{19-16} = Rn;
Owen Andersonbb6315d2010-11-15 19:58:36 +0000351 let Inst{3-0} = ShiftedRm{3-0};
352 let Inst{5-4} = ShiftedRm{6-5};
353 let Inst{14-12} = ShiftedRm{11-9};
354 let Inst{7-6} = ShiftedRm{8-7};
355}
356
Owen Andersona99e7782010-11-15 18:45:17 +0000357class T2TwoReg<dag oops, dag iops, InstrItinClass itin,
358 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +0000359 : T2I<oops, iops, itin, opc, asm, pattern> {
Owen Andersona99e7782010-11-15 18:45:17 +0000360 bits<4> Rd;
361 bits<4> Rm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000362
Jim Grosbach86386922010-12-08 22:10:43 +0000363 let Inst{11-8} = Rd;
364 let Inst{3-0} = Rm;
Owen Andersona99e7782010-11-15 18:45:17 +0000365}
366
367class T2sTwoReg<dag oops, dag iops, InstrItinClass itin,
368 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +0000369 : T2sI<oops, iops, itin, opc, asm, pattern> {
Owen Andersona99e7782010-11-15 18:45:17 +0000370 bits<4> Rd;
371 bits<4> Rm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000372
Jim Grosbach86386922010-12-08 22:10:43 +0000373 let Inst{11-8} = Rd;
374 let Inst{3-0} = Rm;
Owen Andersona99e7782010-11-15 18:45:17 +0000375}
376
Owen Andersonbb6315d2010-11-15 19:58:36 +0000377class T2TwoRegCmp<dag oops, dag iops, InstrItinClass itin,
378 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +0000379 : T2I<oops, iops, itin, opc, asm, pattern> {
Owen Andersonbb6315d2010-11-15 19:58:36 +0000380 bits<4> Rn;
381 bits<4> Rm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000382
Jim Grosbach86386922010-12-08 22:10:43 +0000383 let Inst{19-16} = Rn;
384 let Inst{3-0} = Rm;
Owen Andersonbb6315d2010-11-15 19:58:36 +0000385}
386
Owen Andersona99e7782010-11-15 18:45:17 +0000387
388class T2TwoRegImm<dag oops, dag iops, InstrItinClass itin,
389 string opc, string asm, list<dag> pattern>
390 : T2I<oops, iops, itin, opc, asm, pattern> {
391 bits<4> Rd;
Jim Grosbach07e9b262010-12-08 23:04:16 +0000392 bits<4> Rn;
Jim Grosbach20e0fa62010-12-08 23:24:29 +0000393 bits<12> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000394
Jim Grosbach86386922010-12-08 22:10:43 +0000395 let Inst{11-8} = Rd;
Jim Grosbach20e0fa62010-12-08 23:24:29 +0000396 let Inst{19-16} = Rn;
397 let Inst{26} = imm{11};
398 let Inst{14-12} = imm{10-8};
399 let Inst{7-0} = imm{7-0};
Owen Andersona99e7782010-11-15 18:45:17 +0000400}
401
Owen Anderson83da6cd2010-11-14 05:37:38 +0000402class T2sTwoRegImm<dag oops, dag iops, InstrItinClass itin,
Owen Anderson5de6d842010-11-12 21:12:40 +0000403 string opc, string asm, list<dag> pattern>
404 : T2sI<oops, iops, itin, opc, asm, pattern> {
405 bits<4> Rd;
406 bits<4> Rn;
407 bits<12> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000408
Jim Grosbach86386922010-12-08 22:10:43 +0000409 let Inst{11-8} = Rd;
410 let Inst{19-16} = Rn;
Owen Anderson5de6d842010-11-12 21:12:40 +0000411 let Inst{26} = imm{11};
412 let Inst{14-12} = imm{10-8};
413 let Inst{7-0} = imm{7-0};
414}
415
Owen Andersonbb6315d2010-11-15 19:58:36 +0000416class T2TwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
417 string opc, string asm, list<dag> pattern>
418 : T2I<oops, iops, itin, opc, asm, pattern> {
419 bits<4> Rd;
420 bits<4> Rm;
421 bits<5> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000422
Jim Grosbach86386922010-12-08 22:10:43 +0000423 let Inst{11-8} = Rd;
424 let Inst{3-0} = Rm;
Owen Andersonbb6315d2010-11-15 19:58:36 +0000425 let Inst{14-12} = imm{4-2};
426 let Inst{7-6} = imm{1-0};
427}
428
429class T2sTwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
430 string opc, string asm, list<dag> pattern>
431 : T2sI<oops, iops, itin, opc, asm, pattern> {
432 bits<4> Rd;
433 bits<4> Rm;
434 bits<5> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000435
Jim Grosbach86386922010-12-08 22:10:43 +0000436 let Inst{11-8} = Rd;
437 let Inst{3-0} = Rm;
Owen Andersonbb6315d2010-11-15 19:58:36 +0000438 let Inst{14-12} = imm{4-2};
439 let Inst{7-6} = imm{1-0};
440}
441
Owen Anderson5de6d842010-11-12 21:12:40 +0000442class T2ThreeReg<dag oops, dag iops, InstrItinClass itin,
443 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +0000444 : T2I<oops, iops, itin, opc, asm, pattern> {
Owen Anderson83da6cd2010-11-14 05:37:38 +0000445 bits<4> Rd;
446 bits<4> Rn;
447 bits<4> Rm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000448
Jim Grosbach86386922010-12-08 22:10:43 +0000449 let Inst{11-8} = Rd;
450 let Inst{19-16} = Rn;
451 let Inst{3-0} = Rm;
Owen Anderson83da6cd2010-11-14 05:37:38 +0000452}
453
454class T2sThreeReg<dag oops, dag iops, InstrItinClass itin,
455 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +0000456 : T2sI<oops, iops, itin, opc, asm, pattern> {
Owen Anderson5de6d842010-11-12 21:12:40 +0000457 bits<4> Rd;
458 bits<4> Rn;
459 bits<4> Rm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000460
Jim Grosbach86386922010-12-08 22:10:43 +0000461 let Inst{11-8} = Rd;
462 let Inst{19-16} = Rn;
463 let Inst{3-0} = Rm;
Owen Anderson5de6d842010-11-12 21:12:40 +0000464}
465
466class T2TwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
467 string opc, string asm, list<dag> pattern>
Owen Anderson83da6cd2010-11-14 05:37:38 +0000468 : T2I<oops, iops, itin, opc, asm, pattern> {
469 bits<4> Rd;
470 bits<4> Rn;
471 bits<12> ShiftedRm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000472
Jim Grosbach86386922010-12-08 22:10:43 +0000473 let Inst{11-8} = Rd;
474 let Inst{19-16} = Rn;
Owen Anderson83da6cd2010-11-14 05:37:38 +0000475 let Inst{3-0} = ShiftedRm{3-0};
476 let Inst{5-4} = ShiftedRm{6-5};
477 let Inst{14-12} = ShiftedRm{11-9};
478 let Inst{7-6} = ShiftedRm{8-7};
479}
480
481class T2sTwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
482 string opc, string asm, list<dag> pattern>
Owen Anderson5de6d842010-11-12 21:12:40 +0000483 : T2sI<oops, iops, itin, opc, asm, pattern> {
484 bits<4> Rd;
485 bits<4> Rn;
486 bits<12> ShiftedRm;
Jim Grosbach7a088642010-11-19 17:11:02 +0000487
Jim Grosbach86386922010-12-08 22:10:43 +0000488 let Inst{11-8} = Rd;
489 let Inst{19-16} = Rn;
Owen Anderson5de6d842010-11-12 21:12:40 +0000490 let Inst{3-0} = ShiftedRm{3-0};
491 let Inst{5-4} = ShiftedRm{6-5};
492 let Inst{14-12} = ShiftedRm{11-9};
493 let Inst{7-6} = ShiftedRm{8-7};
494}
495
Owen Anderson35141a92010-11-18 01:08:42 +0000496class T2FourReg<dag oops, dag iops, InstrItinClass itin,
497 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +0000498 : T2I<oops, iops, itin, opc, asm, pattern> {
Owen Anderson35141a92010-11-18 01:08:42 +0000499 bits<4> Rd;
500 bits<4> Rn;
501 bits<4> Rm;
502 bits<4> Ra;
Jim Grosbach7a088642010-11-19 17:11:02 +0000503
Jim Grosbach86386922010-12-08 22:10:43 +0000504 let Inst{19-16} = Rn;
505 let Inst{15-12} = Ra;
506 let Inst{11-8} = Rd;
507 let Inst{3-0} = Rm;
Owen Anderson35141a92010-11-18 01:08:42 +0000508}
509
Jim Grosbach7c6d85a2010-12-08 22:38:41 +0000510class T2MulLong<bits<3> opc22_20, bits<4> opc7_4,
511 dag oops, dag iops, InstrItinClass itin,
512 string opc, string asm, list<dag> pattern>
Jim Grosbach52082042010-12-08 22:29:28 +0000513 : T2I<oops, iops, itin, opc, asm, pattern> {
514 bits<4> RdLo;
515 bits<4> RdHi;
516 bits<4> Rn;
517 bits<4> Rm;
518
Jim Grosbach7c6d85a2010-12-08 22:38:41 +0000519 let Inst{31-23} = 0b111110111;
520 let Inst{22-20} = opc22_20;
Jim Grosbach52082042010-12-08 22:29:28 +0000521 let Inst{19-16} = Rn;
522 let Inst{15-12} = RdLo;
523 let Inst{11-8} = RdHi;
Jim Grosbach7c6d85a2010-12-08 22:38:41 +0000524 let Inst{7-4} = opc7_4;
Jim Grosbach52082042010-12-08 22:29:28 +0000525 let Inst{3-0} = Rm;
526}
Arnold Schwaighofer67514e92012-09-04 14:37:49 +0000527class T2MlaLong<bits<3> opc22_20, bits<4> opc7_4,
528 dag oops, dag iops, InstrItinClass itin,
529 string opc, string asm, list<dag> pattern>
530 : T2I<oops, iops, itin, opc, asm, pattern> {
531 bits<4> RdLo;
532 bits<4> RdHi;
533 bits<4> Rn;
534 bits<4> Rm;
535
536 let Inst{31-23} = 0b111110111;
537 let Inst{22-20} = opc22_20;
538 let Inst{19-16} = Rn;
539 let Inst{15-12} = RdLo;
540 let Inst{11-8} = RdHi;
541 let Inst{7-4} = opc7_4;
542 let Inst{3-0} = Rm;
543}
Jim Grosbach52082042010-12-08 22:29:28 +0000544
Owen Anderson35141a92010-11-18 01:08:42 +0000545
Evan Chenga67efd12009-06-23 19:39:13 +0000546/// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
Bob Wilson4876bdb2010-05-25 04:43:08 +0000547/// binary operation that produces a value. These are predicable and can be
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000548/// changed to modify CPSR.
Evan Cheng7e1bf302010-09-29 00:27:46 +0000549multiclass T2I_bin_irs<bits<4> opcod, string opc,
550 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000551 PatFrag opnode, bit Commutable = 0,
Jim Grosbachadf73662011-06-28 00:19:13 +0000552 string wide = ""> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000553 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000554 def ri : T2sTwoRegImm<
555 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii,
556 opc, "\t$Rd, $Rn, $imm",
557 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000558 let Inst{31-27} = 0b11110;
559 let Inst{25} = 0;
560 let Inst{24-21} = opcod;
Johnny Chend68e1192009-12-15 17:24:14 +0000561 let Inst{15} = 0;
562 }
Evan Chenga67efd12009-06-23 19:39:13 +0000563 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000564 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir,
565 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"),
566 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000567 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000568 let Inst{31-27} = 0b11101;
569 let Inst{26-25} = 0b01;
570 let Inst{24-21} = opcod;
Johnny Chend68e1192009-12-15 17:24:14 +0000571 let Inst{14-12} = 0b000; // imm3
572 let Inst{7-6} = 0b00; // imm2
573 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000574 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000575 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000576 def rs : T2sTwoRegShiftedReg<
577 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
578 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"),
579 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000580 let Inst{31-27} = 0b11101;
581 let Inst{26-25} = 0b01;
582 let Inst{24-21} = opcod;
Bill Wendling4822bce2010-08-30 01:47:35 +0000583 }
Jim Grosbachadf73662011-06-28 00:19:13 +0000584 // Assembly aliases for optional destination operand when it's the same
585 // as the source operand.
Jim Grosbacha33b31b2011-08-22 18:04:24 +0000586 def : t2InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000587 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn,
Jim Grosbachadf73662011-06-28 00:19:13 +0000588 t2_so_imm:$imm, pred:$p,
Jim Grosbacha33b31b2011-08-22 18:04:24 +0000589 cc_out:$s)>;
590 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $Rm"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000591 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn,
Jim Grosbachadf73662011-06-28 00:19:13 +0000592 rGPR:$Rm, pred:$p,
Jim Grosbacha33b31b2011-08-22 18:04:24 +0000593 cc_out:$s)>;
594 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $shift"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000595 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn,
Jim Grosbachadf73662011-06-28 00:19:13 +0000596 t2_so_reg:$shift, pred:$p,
Jim Grosbacha33b31b2011-08-22 18:04:24 +0000597 cc_out:$s)>;
Bill Wendling4822bce2010-08-30 01:47:35 +0000598}
599
David Goodwin1f096272009-07-27 23:34:12 +0000600/// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
Jim Grosbachadf73662011-06-28 00:19:13 +0000601// the ".w" suffix to indicate that they are wide.
Evan Cheng7e1bf302010-09-29 00:27:46 +0000602multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
603 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000604 PatFrag opnode, bit Commutable = 0> :
605 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w"> {
Jim Grosbach9e931f62012-02-24 19:06:05 +0000606 // Assembler aliases w/ the ".w" suffix.
607 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rd, $Rn, $imm"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000608 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p,
609 cc_out:$s)>;
Jim Grosbach5c1ac552011-09-02 18:41:35 +0000610 // Assembler aliases w/o the ".w" suffix.
611 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000612 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
613 cc_out:$s)>;
Jim Grosbach5c1ac552011-09-02 18:41:35 +0000614 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $shift"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000615 (!cast<Instruction>(NAME#"rs") rGPR:$Rd, rGPR:$Rn, t2_so_reg:$shift,
616 pred:$p, cc_out:$s)>;
Jim Grosbach5c1ac552011-09-02 18:41:35 +0000617
618 // and with the optional destination operand, too.
Jim Grosbach11d5dc32012-03-16 22:18:29 +0000619 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rdn, $imm"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000620 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm,
621 pred:$p, cc_out:$s)>;
Jim Grosbach5c1ac552011-09-02 18:41:35 +0000622 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000623 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
624 cc_out:$s)>;
Jim Grosbach5c1ac552011-09-02 18:41:35 +0000625 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $shift"),
Jim Grosbach5c6c1282012-08-02 21:50:41 +0000626 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$shift,
627 pred:$p, cc_out:$s)>;
Jim Grosbach5c1ac552011-09-02 18:41:35 +0000628}
Bill Wendling1f7bf0e2010-08-29 03:55:31 +0000629
Evan Cheng1e249e32009-06-25 20:59:23 +0000630/// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000631/// reversed. The 'rr' form is only defined for the disassembler; for codegen
632/// it is equivalent to the T2I_bin_irs counterpart.
633multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Chengf49810c2009-06-23 17:48:47 +0000634 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000635 def ri : T2sTwoRegImm<
636 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
637 opc, ".w\t$Rd, $Rn, $imm",
638 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000639 let Inst{31-27} = 0b11110;
640 let Inst{25} = 0;
641 let Inst{24-21} = opcod;
Johnny Chend68e1192009-12-15 17:24:14 +0000642 let Inst{15} = 0;
643 }
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000644 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000645 def rr : T2sThreeReg<
646 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
647 opc, "\t$Rd, $Rn, $Rm",
Bob Wilson136e4912010-08-14 03:18:29 +0000648 [/* For disassembly only; pattern left blank */]> {
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000649 let Inst{31-27} = 0b11101;
650 let Inst{26-25} = 0b01;
651 let Inst{24-21} = opcod;
Bob Wilson20d8e4e2010-08-13 23:24:25 +0000652 let Inst{14-12} = 0b000; // imm3
653 let Inst{7-6} = 0b00; // imm2
654 let Inst{5-4} = 0b00; // type
655 }
Evan Chengf49810c2009-06-23 17:48:47 +0000656 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000657 def rs : T2sTwoRegShiftedReg<
658 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
659 IIC_iALUsir, opc, "\t$Rd, $Rn, $ShiftedRm",
660 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000661 let Inst{31-27} = 0b11101;
662 let Inst{26-25} = 0b01;
663 let Inst{24-21} = opcod;
Johnny Chend68e1192009-12-15 17:24:14 +0000664 }
Evan Chengf49810c2009-06-23 17:48:47 +0000665}
666
Evan Chenga67efd12009-06-23 19:39:13 +0000667/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
Anton Korobeynikov52237112009-06-17 18:13:58 +0000668/// instruction modifies the CPSR register.
Andrew Trick3be654f2011-09-21 02:20:46 +0000669///
670/// These opcodes will be converted to the real non-S opcodes by
671/// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
Andrew Trick90b7b122011-10-18 19:18:52 +0000672let hasPostISelHook = 1, Defs = [CPSR] in {
673multiclass T2I_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
674 InstrItinClass iis, PatFrag opnode,
675 bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000676 // shifted imm
Andrew Trick90b7b122011-10-18 19:18:52 +0000677 def ri : t2PseudoInst<(outs rGPR:$Rd),
678 (ins GPRnopc:$Rn, t2_so_imm:$imm, pred:$p),
679 4, iii,
680 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
681 t2_so_imm:$imm))]>;
Evan Chenga67efd12009-06-23 19:39:13 +0000682 // register
Andrew Trick90b7b122011-10-18 19:18:52 +0000683 def rr : t2PseudoInst<(outs rGPR:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm, pred:$p),
684 4, iir,
685 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
686 rGPR:$Rm))]> {
687 let isCommutable = Commutable;
688 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000689 // shifted register
Andrew Trick90b7b122011-10-18 19:18:52 +0000690 def rs : t2PseudoInst<(outs rGPR:$Rd),
691 (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
692 4, iis,
693 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
694 t2_so_reg:$ShiftedRm))]>;
695}
696}
697
698/// T2I_rbin_s_is - Same as T2I_bin_s_irs, except selection DAG
699/// operands are reversed.
700let hasPostISelHook = 1, Defs = [CPSR] in {
701multiclass T2I_rbin_s_is<PatFrag opnode> {
702 // shifted imm
703 def ri : t2PseudoInst<(outs rGPR:$Rd),
Jim Grosbachb551f0c2012-05-21 17:57:17 +0000704 (ins rGPR:$Rn, t2_so_imm:$imm, pred:$p),
Andrew Trick90b7b122011-10-18 19:18:52 +0000705 4, IIC_iALUi,
706 [(set rGPR:$Rd, CPSR, (opnode t2_so_imm:$imm,
Jim Grosbachb551f0c2012-05-21 17:57:17 +0000707 rGPR:$Rn))]>;
Andrew Trick90b7b122011-10-18 19:18:52 +0000708 // shifted register
709 def rs : t2PseudoInst<(outs rGPR:$Rd),
Jim Grosbachb551f0c2012-05-21 17:57:17 +0000710 (ins rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
Andrew Trick90b7b122011-10-18 19:18:52 +0000711 4, IIC_iALUsi,
712 [(set rGPR:$Rd, CPSR, (opnode t2_so_reg:$ShiftedRm,
Jim Grosbachb551f0c2012-05-21 17:57:17 +0000713 rGPR:$Rn))]>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000714}
715}
716
Evan Chenga67efd12009-06-23 19:39:13 +0000717/// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
718/// patterns for a binary operation that produces a value.
Johnny Chend68e1192009-12-15 17:24:14 +0000719multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
720 bit Commutable = 0> {
Evan Chengf49810c2009-06-23 17:48:47 +0000721 // shifted imm
Jim Grosbach663e3392010-08-30 19:49:58 +0000722 // The register-immediate version is re-materializable. This is useful
723 // in particular for taking the address of a local.
724 let isReMaterializable = 1 in {
Owen Anderson83da6cd2010-11-14 05:37:38 +0000725 def ri : T2sTwoRegImm<
Jim Grosbachb95ed6e2011-10-03 20:51:59 +0000726 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi,
727 opc, ".w\t$Rd, $Rn, $imm",
728 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000729 let Inst{31-27} = 0b11110;
730 let Inst{25} = 0;
731 let Inst{24} = 1;
732 let Inst{23-21} = op23_21;
Johnny Chend68e1192009-12-15 17:24:14 +0000733 let Inst{15} = 0;
734 }
Jim Grosbach663e3392010-08-30 19:49:58 +0000735 }
Evan Chengf49810c2009-06-23 17:48:47 +0000736 // 12-bit imm
Jim Grosbach07e9b262010-12-08 23:04:16 +0000737 def ri12 : T2I<
Jim Grosbachb95ed6e2011-10-03 20:51:59 +0000738 (outs GPRnopc:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi,
Owen Anderson83da6cd2010-11-14 05:37:38 +0000739 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +0000740 [(set GPRnopc:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> {
Jim Grosbach07e9b262010-12-08 23:04:16 +0000741 bits<4> Rd;
742 bits<4> Rn;
743 bits<12> imm;
Johnny Chend68e1192009-12-15 17:24:14 +0000744 let Inst{31-27} = 0b11110;
Jim Grosbach07e9b262010-12-08 23:04:16 +0000745 let Inst{26} = imm{11};
746 let Inst{25-24} = 0b10;
Johnny Chend68e1192009-12-15 17:24:14 +0000747 let Inst{23-21} = op23_21;
748 let Inst{20} = 0; // The S bit.
Jim Grosbach07e9b262010-12-08 23:04:16 +0000749 let Inst{19-16} = Rn;
Johnny Chend68e1192009-12-15 17:24:14 +0000750 let Inst{15} = 0;
Jim Grosbach07e9b262010-12-08 23:04:16 +0000751 let Inst{14-12} = imm{10-8};
752 let Inst{11-8} = Rd;
753 let Inst{7-0} = imm{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +0000754 }
Evan Chenga67efd12009-06-23 19:39:13 +0000755 // register
Jim Grosbachb95ed6e2011-10-03 20:51:59 +0000756 def rr : T2sThreeReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm),
757 IIC_iALUr, opc, ".w\t$Rd, $Rn, $Rm",
758 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000759 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000760 let Inst{31-27} = 0b11101;
761 let Inst{26-25} = 0b01;
762 let Inst{24} = 1;
763 let Inst{23-21} = op23_21;
Johnny Chend68e1192009-12-15 17:24:14 +0000764 let Inst{14-12} = 0b000; // imm3
765 let Inst{7-6} = 0b00; // imm2
766 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000767 }
Evan Chengf49810c2009-06-23 17:48:47 +0000768 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000769 def rs : T2sTwoRegShiftedReg<
Jim Grosbachb95ed6e2011-10-03 20:51:59 +0000770 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm),
Owen Anderson83da6cd2010-11-14 05:37:38 +0000771 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +0000772 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000773 let Inst{31-27} = 0b11101;
Johnny Chend68e1192009-12-15 17:24:14 +0000774 let Inst{26-25} = 0b01;
Johnny Chend248ffb2010-01-08 17:41:33 +0000775 let Inst{24} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +0000776 let Inst{23-21} = op23_21;
Johnny Chend68e1192009-12-15 17:24:14 +0000777 }
Evan Chengf49810c2009-06-23 17:48:47 +0000778}
779
Jim Grosbach6935efc2009-11-24 00:20:27 +0000780/// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000781/// for a binary operation that produces a value and use the carry
Jim Grosbach6935efc2009-11-24 00:20:27 +0000782/// bit. It's not predicable.
Evan Cheng342e3162011-08-30 01:34:54 +0000783let Defs = [CPSR], Uses = [CPSR] in {
Jim Grosbach80dc1162010-02-16 21:23:02 +0000784multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
785 bit Commutable = 0> {
Anton Korobeynikov52237112009-06-17 18:13:58 +0000786 // shifted imm
Owen Anderson83da6cd2010-11-14 05:37:38 +0000787 def ri : T2sTwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
Owen Anderson5de6d842010-11-12 21:12:40 +0000788 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
Evan Cheng342e3162011-08-30 01:34:54 +0000789 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_imm:$imm, CPSR))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000790 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000791 let Inst{31-27} = 0b11110;
792 let Inst{25} = 0;
793 let Inst{24-21} = opcod;
Johnny Chend68e1192009-12-15 17:24:14 +0000794 let Inst{15} = 0;
795 }
Evan Chenga67efd12009-06-23 19:39:13 +0000796 // register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000797 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
Owen Anderson5de6d842010-11-12 21:12:40 +0000798 opc, ".w\t$Rd, $Rn, $Rm",
Evan Cheng342e3162011-08-30 01:34:54 +0000799 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, rGPR:$Rm, CPSR))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000800 Requires<[IsThumb2]> {
Evan Cheng8de898a2009-06-26 00:19:44 +0000801 let isCommutable = Commutable;
Johnny Chend68e1192009-12-15 17:24:14 +0000802 let Inst{31-27} = 0b11101;
803 let Inst{26-25} = 0b01;
804 let Inst{24-21} = opcod;
Johnny Chend68e1192009-12-15 17:24:14 +0000805 let Inst{14-12} = 0b000; // imm3
806 let Inst{7-6} = 0b00; // imm2
807 let Inst{5-4} = 0b00; // type
Evan Cheng8de898a2009-06-26 00:19:44 +0000808 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000809 // shifted register
Owen Anderson83da6cd2010-11-14 05:37:38 +0000810 def rs : T2sTwoRegShiftedReg<
Jim Grosbach7a088642010-11-19 17:11:02 +0000811 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
Owen Anderson5de6d842010-11-12 21:12:40 +0000812 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
Evan Cheng342e3162011-08-30 01:34:54 +0000813 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm, CPSR))]>,
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000814 Requires<[IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000815 let Inst{31-27} = 0b11101;
816 let Inst{26-25} = 0b01;
817 let Inst{24-21} = opcod;
Johnny Chend68e1192009-12-15 17:24:14 +0000818 }
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000819}
Andrew Trick1c3af772011-04-23 03:55:32 +0000820}
Jim Grosbach39be8fc2010-02-16 20:42:29 +0000821
Evan Chenga67efd12009-06-23 19:39:13 +0000822/// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
823// rotate operation that produces a value.
Jim Grosbach9249ef32012-08-02 21:59:52 +0000824multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, PatFrag opnode> {
Evan Chenga67efd12009-06-23 19:39:13 +0000825 // 5-bit imm
Owen Andersonbb6315d2010-11-15 19:58:36 +0000826 def ri : T2sTwoRegShiftImm<
Owen Anderson6d746312011-08-08 20:42:17 +0000827 (outs rGPR:$Rd), (ins rGPR:$Rm, ty:$imm), IIC_iMOVsi,
Owen Andersonbb6315d2010-11-15 19:58:36 +0000828 opc, ".w\t$Rd, $Rm, $imm",
Jim Grosbach70939ee2011-08-17 21:51:27 +0000829 [(set rGPR:$Rd, (opnode rGPR:$Rm, (i32 ty:$imm)))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000830 let Inst{31-27} = 0b11101;
831 let Inst{26-21} = 0b010010;
832 let Inst{19-16} = 0b1111; // Rn
833 let Inst{5-4} = opcod;
834 }
Evan Chenga67efd12009-06-23 19:39:13 +0000835 // register
Owen Andersonbb6315d2010-11-15 19:58:36 +0000836 def rr : T2sThreeReg<
837 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMOVsr,
838 opc, ".w\t$Rd, $Rn, $Rm",
839 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000840 let Inst{31-27} = 0b11111;
841 let Inst{26-23} = 0b0100;
842 let Inst{22-21} = opcod;
843 let Inst{15-12} = 0b1111;
844 let Inst{7-4} = 0b0000;
845 }
Jim Grosbach5f25fb02011-09-02 21:28:54 +0000846
847 // Optional destination register
848 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000849 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
850 cc_out:$s)>;
Jim Grosbach5f25fb02011-09-02 21:28:54 +0000851 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000852 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
853 cc_out:$s)>;
Jim Grosbach5f25fb02011-09-02 21:28:54 +0000854
855 // Assembler aliases w/o the ".w" suffix.
856 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $imm"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000857 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, ty:$imm, pred:$p,
858 cc_out:$s)>;
Jim Grosbach5f25fb02011-09-02 21:28:54 +0000859 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000860 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
861 cc_out:$s)>;
Jim Grosbach5f25fb02011-09-02 21:28:54 +0000862
863 // and with the optional destination operand, too.
864 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $imm"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000865 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
866 cc_out:$s)>;
Jim Grosbach5f25fb02011-09-02 21:28:54 +0000867 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000868 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
869 cc_out:$s)>;
Evan Chenga67efd12009-06-23 19:39:13 +0000870}
Evan Chengf49810c2009-06-23 17:48:47 +0000871
Johnny Chend68e1192009-12-15 17:24:14 +0000872/// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
Evan Chenga67efd12009-06-23 19:39:13 +0000873/// patterns. Similar to T2I_bin_irs except the instruction does not produce
Evan Chengf49810c2009-06-23 17:48:47 +0000874/// a explicit result, only implicitly set CPSR.
Evan Cheng5d42c562010-09-29 00:49:25 +0000875multiclass T2I_cmp_irs<bits<4> opcod, string opc,
876 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
Jim Grosbach9249ef32012-08-02 21:59:52 +0000877 PatFrag opnode> {
Jim Grosbachef88a922011-09-06 21:44:58 +0000878let isCompare = 1, Defs = [CPSR] in {
Evan Chengf49810c2009-06-23 17:48:47 +0000879 // shifted imm
Owen Andersonbb6315d2010-11-15 19:58:36 +0000880 def ri : T2OneRegCmpImm<
Jim Grosbachef88a922011-09-06 21:44:58 +0000881 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), iii,
Owen Andersonbb6315d2010-11-15 19:58:36 +0000882 opc, ".w\t$Rn, $imm",
Jim Grosbachef88a922011-09-06 21:44:58 +0000883 [(opnode GPRnopc:$Rn, t2_so_imm:$imm)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000884 let Inst{31-27} = 0b11110;
885 let Inst{25} = 0;
886 let Inst{24-21} = opcod;
887 let Inst{20} = 1; // The S bit.
888 let Inst{15} = 0;
889 let Inst{11-8} = 0b1111; // Rd
890 }
Evan Chenga67efd12009-06-23 19:39:13 +0000891 // register
Owen Andersonbb6315d2010-11-15 19:58:36 +0000892 def rr : T2TwoRegCmp<
Jim Grosbachef88a922011-09-06 21:44:58 +0000893 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), iir,
Owen Andersone732cb02011-08-23 17:37:32 +0000894 opc, ".w\t$Rn, $Rm",
Jim Grosbachef88a922011-09-06 21:44:58 +0000895 [(opnode GPRnopc:$Rn, rGPR:$Rm)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000896 let Inst{31-27} = 0b11101;
897 let Inst{26-25} = 0b01;
898 let Inst{24-21} = opcod;
899 let Inst{20} = 1; // The S bit.
900 let Inst{14-12} = 0b000; // imm3
901 let Inst{11-8} = 0b1111; // Rd
902 let Inst{7-6} = 0b00; // imm2
903 let Inst{5-4} = 0b00; // type
904 }
Evan Chengf49810c2009-06-23 17:48:47 +0000905 // shifted register
Owen Andersonbb6315d2010-11-15 19:58:36 +0000906 def rs : T2OneRegCmpShiftedReg<
Jim Grosbachef88a922011-09-06 21:44:58 +0000907 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), iis,
Owen Andersonbb6315d2010-11-15 19:58:36 +0000908 opc, ".w\t$Rn, $ShiftedRm",
Jim Grosbachef88a922011-09-06 21:44:58 +0000909 [(opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm)]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000910 let Inst{31-27} = 0b11101;
911 let Inst{26-25} = 0b01;
912 let Inst{24-21} = opcod;
913 let Inst{20} = 1; // The S bit.
914 let Inst{11-8} = 0b1111; // Rd
915 }
Anton Korobeynikov52237112009-06-17 18:13:58 +0000916}
Jim Grosbachef88a922011-09-06 21:44:58 +0000917
918 // Assembler aliases w/o the ".w" suffix.
919 // No alias here for 'rr' version as not all instantiations of this
920 // multiclass want one (CMP in particular, does not).
921 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $imm"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000922 (!cast<Instruction>(NAME#"ri") GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
Jim Grosbachef88a922011-09-06 21:44:58 +0000923 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $shift"),
Jim Grosbach9249ef32012-08-02 21:59:52 +0000924 (!cast<Instruction>(NAME#"rs") GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
Anton Korobeynikov52237112009-06-17 18:13:58 +0000925}
926
Evan Chengf3c21b82009-06-30 02:15:48 +0000927/// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +0000928multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
Owen Anderson9fe72bc2011-08-11 20:40:40 +0000929 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
930 PatFrag opnode> {
931 def i12 : T2Ii12<(outs target:$Rt), (ins t2addrmode_imm12:$addr), iii,
Owen Anderson75579f72010-11-29 22:44:32 +0000932 opc, ".w\t$Rt, $addr",
Owen Anderson9fe72bc2011-08-11 20:40:40 +0000933 [(set target:$Rt, (opnode t2addrmode_imm12:$addr))]> {
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000934 bits<4> Rt;
935 bits<17> addr;
936 let Inst{31-25} = 0b1111100;
Johnny Chend68e1192009-12-15 17:24:14 +0000937 let Inst{24} = signed;
938 let Inst{23} = 1;
939 let Inst{22-21} = opcod;
940 let Inst{20} = 1; // load
Owen Anderson80dd3e02010-11-30 22:45:47 +0000941 let Inst{19-16} = addr{16-13}; // Rn
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000942 let Inst{15-12} = Rt;
Owen Anderson80dd3e02010-11-30 22:45:47 +0000943 let Inst{11-0} = addr{11-0}; // imm
Johnny Chend68e1192009-12-15 17:24:14 +0000944 }
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000945 def i8 : T2Ii8 <(outs target:$Rt), (ins t2addrmode_negimm8:$addr), iii,
Owen Anderson75579f72010-11-29 22:44:32 +0000946 opc, "\t$Rt, $addr",
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000947 [(set target:$Rt, (opnode t2addrmode_negimm8:$addr))]> {
948 bits<4> Rt;
949 bits<13> addr;
Johnny Chend68e1192009-12-15 17:24:14 +0000950 let Inst{31-27} = 0b11111;
951 let Inst{26-25} = 0b00;
952 let Inst{24} = signed;
953 let Inst{23} = 0;
954 let Inst{22-21} = opcod;
955 let Inst{20} = 1; // load
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000956 let Inst{19-16} = addr{12-9}; // Rn
957 let Inst{15-12} = Rt;
Johnny Chend68e1192009-12-15 17:24:14 +0000958 let Inst{11} = 1;
959 // Offset: index==TRUE, wback==FALSE
960 let Inst{10} = 1; // The P bit.
Owen Anderson75579f72010-11-29 22:44:32 +0000961 let Inst{9} = addr{8}; // U
Jim Grosbacha8307dd2011-09-07 20:58:57 +0000962 let Inst{8} = 0; // The W bit.
Owen Anderson75579f72010-11-29 22:44:32 +0000963 let Inst{7-0} = addr{7-0}; // imm
Johnny Chend68e1192009-12-15 17:24:14 +0000964 }
Owen Anderson9fe72bc2011-08-11 20:40:40 +0000965 def s : T2Iso <(outs target:$Rt), (ins t2addrmode_so_reg:$addr), iis,
Owen Anderson75579f72010-11-29 22:44:32 +0000966 opc, ".w\t$Rt, $addr",
Owen Anderson9fe72bc2011-08-11 20:40:40 +0000967 [(set target:$Rt, (opnode t2addrmode_so_reg:$addr))]> {
Johnny Chend68e1192009-12-15 17:24:14 +0000968 let Inst{31-27} = 0b11111;
969 let Inst{26-25} = 0b00;
970 let Inst{24} = signed;
971 let Inst{23} = 0;
972 let Inst{22-21} = opcod;
973 let Inst{20} = 1; // load
974 let Inst{11-6} = 0b000000;
Jim Grosbach7721e7f2010-12-02 23:05:38 +0000975
Owen Anderson75579f72010-11-29 22:44:32 +0000976 bits<4> Rt;
Jim Grosbach86386922010-12-08 22:10:43 +0000977 let Inst{15-12} = Rt;
Jim Grosbach7721e7f2010-12-02 23:05:38 +0000978
Owen Anderson75579f72010-11-29 22:44:32 +0000979 bits<10> addr;
980 let Inst{19-16} = addr{9-6}; // Rn
981 let Inst{3-0} = addr{5-2}; // Rm
982 let Inst{5-4} = addr{1-0}; // imm
Owen Anderson8d7d2e12011-08-09 20:55:18 +0000983
984 let DecoderMethod = "DecodeT2LoadShift";
Johnny Chend68e1192009-12-15 17:24:14 +0000985 }
Evan Chengbc7deb02010-11-03 05:14:24 +0000986
Jim Grosbach5aa53682012-01-18 22:04:42 +0000987 // pci variant is very similar to i12, but supports negative offsets
988 // from the PC.
Owen Anderson9fe72bc2011-08-11 20:40:40 +0000989 def pci : T2Ipc <(outs target:$Rt), (ins t2ldrlabel:$addr), iii,
Owen Anderson971b83b2011-02-08 22:39:40 +0000990 opc, ".w\t$Rt, $addr",
Owen Anderson9fe72bc2011-08-11 20:40:40 +0000991 [(set target:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> {
Owen Anderson971b83b2011-02-08 22:39:40 +0000992 let isReMaterializable = 1;
993 let Inst{31-27} = 0b11111;
994 let Inst{26-25} = 0b00;
995 let Inst{24} = signed;
996 let Inst{23} = ?; // add = (U == '1')
997 let Inst{22-21} = opcod;
998 let Inst{20} = 1; // load
999 let Inst{19-16} = 0b1111; // Rn
1000 bits<4> Rt;
1001 bits<12> addr;
1002 let Inst{15-12} = Rt{3-0};
1003 let Inst{11-0} = addr{11-0};
1004 }
Evan Chengf3c21b82009-06-30 02:15:48 +00001005}
1006
David Goodwin73b8f162009-06-30 22:11:34 +00001007/// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
Evan Cheng0e55fd62010-09-30 01:08:25 +00001008multiclass T2I_st<bits<2> opcod, string opc,
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001009 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
1010 PatFrag opnode> {
1011 def i12 : T2Ii12<(outs), (ins target:$Rt, t2addrmode_imm12:$addr), iii,
Owen Anderson75579f72010-11-29 22:44:32 +00001012 opc, ".w\t$Rt, $addr",
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001013 [(opnode target:$Rt, t2addrmode_imm12:$addr)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001014 let Inst{31-27} = 0b11111;
1015 let Inst{26-23} = 0b0001;
1016 let Inst{22-21} = opcod;
1017 let Inst{20} = 0; // !load
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001018
Owen Anderson75579f72010-11-29 22:44:32 +00001019 bits<4> Rt;
Jim Grosbach86386922010-12-08 22:10:43 +00001020 let Inst{15-12} = Rt;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001021
Owen Anderson80dd3e02010-11-30 22:45:47 +00001022 bits<17> addr;
Johnny Chenf9ce2cb2011-04-12 18:48:00 +00001023 let addr{12} = 1; // add = TRUE
Owen Anderson80dd3e02010-11-30 22:45:47 +00001024 let Inst{19-16} = addr{16-13}; // Rn
1025 let Inst{23} = addr{12}; // U
1026 let Inst{11-0} = addr{11-0}; // imm
Johnny Chend68e1192009-12-15 17:24:14 +00001027 }
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001028 def i8 : T2Ii8 <(outs), (ins target:$Rt, t2addrmode_negimm8:$addr), iii,
Owen Anderson75579f72010-11-29 22:44:32 +00001029 opc, "\t$Rt, $addr",
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001030 [(opnode target:$Rt, t2addrmode_negimm8:$addr)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001031 let Inst{31-27} = 0b11111;
1032 let Inst{26-23} = 0b0000;
1033 let Inst{22-21} = opcod;
1034 let Inst{20} = 0; // !load
1035 let Inst{11} = 1;
1036 // Offset: index==TRUE, wback==FALSE
1037 let Inst{10} = 1; // The P bit.
1038 let Inst{8} = 0; // The W bit.
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001039
Owen Anderson75579f72010-11-29 22:44:32 +00001040 bits<4> Rt;
Jim Grosbach86386922010-12-08 22:10:43 +00001041 let Inst{15-12} = Rt;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001042
Owen Anderson75579f72010-11-29 22:44:32 +00001043 bits<13> addr;
1044 let Inst{19-16} = addr{12-9}; // Rn
1045 let Inst{9} = addr{8}; // U
1046 let Inst{7-0} = addr{7-0}; // imm
Johnny Chend68e1192009-12-15 17:24:14 +00001047 }
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001048 def s : T2Iso <(outs), (ins target:$Rt, t2addrmode_so_reg:$addr), iis,
Owen Anderson75579f72010-11-29 22:44:32 +00001049 opc, ".w\t$Rt, $addr",
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001050 [(opnode target:$Rt, t2addrmode_so_reg:$addr)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001051 let Inst{31-27} = 0b11111;
1052 let Inst{26-23} = 0b0000;
1053 let Inst{22-21} = opcod;
1054 let Inst{20} = 0; // !load
1055 let Inst{11-6} = 0b000000;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001056
Owen Anderson75579f72010-11-29 22:44:32 +00001057 bits<4> Rt;
Jim Grosbach86386922010-12-08 22:10:43 +00001058 let Inst{15-12} = Rt;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001059
Owen Anderson75579f72010-11-29 22:44:32 +00001060 bits<10> addr;
1061 let Inst{19-16} = addr{9-6}; // Rn
1062 let Inst{3-0} = addr{5-2}; // Rm
1063 let Inst{5-4} = addr{1-0}; // imm
Johnny Chend68e1192009-12-15 17:24:14 +00001064 }
David Goodwin73b8f162009-06-30 22:11:34 +00001065}
1066
Evan Cheng0e55fd62010-09-30 01:08:25 +00001067/// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +00001068/// register and one whose operand is a register rotated by 8/16/24.
Jim Grosbachc5a8c862011-07-27 16:47:19 +00001069class T2I_ext_rrot<bits<3> opcod, string opc, PatFrag opnode>
1070 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
1071 opc, ".w\t$Rd, $Rm$rot",
Eli Friedman2cb1dfa2011-08-08 19:49:37 +00001072 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
1073 Requires<[IsThumb2]> {
Jim Grosbachc5a8c862011-07-27 16:47:19 +00001074 let Inst{31-27} = 0b11111;
1075 let Inst{26-23} = 0b0100;
1076 let Inst{22-20} = opcod;
1077 let Inst{19-16} = 0b1111; // Rn
1078 let Inst{15-12} = 0b1111;
1079 let Inst{7} = 1;
Jim Grosbach7a088642010-11-19 17:11:02 +00001080
Jim Grosbachc5a8c862011-07-27 16:47:19 +00001081 bits<2> rot;
1082 let Inst{5-4} = rot{1-0}; // rotate
Evan Chengd27c9fc2009-07-03 01:43:10 +00001083}
1084
Eli Friedman761fa7a2010-06-24 18:20:04 +00001085// UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
Jim Grosbach70327412011-07-27 17:48:13 +00001086class T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode>
Owen Andersone732cb02011-08-23 17:37:32 +00001087 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot),
1088 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1089 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
Jim Grosbach70327412011-07-27 17:48:13 +00001090 Requires<[HasT2ExtractPack, IsThumb2]> {
1091 bits<2> rot;
1092 let Inst{31-27} = 0b11111;
1093 let Inst{26-23} = 0b0100;
1094 let Inst{22-20} = opcod;
1095 let Inst{19-16} = 0b1111; // Rn
1096 let Inst{15-12} = 0b1111;
1097 let Inst{7} = 1;
1098 let Inst{5-4} = rot;
Johnny Chen267124c2010-03-04 22:24:41 +00001099}
1100
Eli Friedman761fa7a2010-06-24 18:20:04 +00001101// SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
1102// supported yet.
Jim Grosbach70327412011-07-27 17:48:13 +00001103class T2I_ext_rrot_sxtb16<bits<3> opcod, string opc>
1104 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
1105 opc, "\t$Rd, $Rm$rot", []>,
Jim Grosbacha7603982011-07-01 21:12:19 +00001106 Requires<[IsThumb2, HasT2ExtractPack]> {
Jim Grosbach70327412011-07-27 17:48:13 +00001107 bits<2> rot;
1108 let Inst{31-27} = 0b11111;
1109 let Inst{26-23} = 0b0100;
1110 let Inst{22-20} = opcod;
1111 let Inst{19-16} = 0b1111; // Rn
1112 let Inst{15-12} = 0b1111;
1113 let Inst{7} = 1;
1114 let Inst{5-4} = rot;
Johnny Chen93042d12010-03-02 18:14:57 +00001115}
1116
Evan Cheng0e55fd62010-09-30 01:08:25 +00001117/// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
Evan Chengd27c9fc2009-07-03 01:43:10 +00001118/// register and one whose operand is a register rotated by 8/16/24.
Jim Grosbach70327412011-07-27 17:48:13 +00001119class T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode>
1120 : T2ThreeReg<(outs rGPR:$Rd),
1121 (ins rGPR:$Rn, rGPR:$Rm, rot_imm:$rot),
1122 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot",
1123 [(set rGPR:$Rd, (opnode rGPR:$Rn, (rotr rGPR:$Rm,rot_imm:$rot)))]>,
1124 Requires<[HasT2ExtractPack, IsThumb2]> {
1125 bits<2> rot;
1126 let Inst{31-27} = 0b11111;
1127 let Inst{26-23} = 0b0100;
1128 let Inst{22-20} = opcod;
1129 let Inst{15-12} = 0b1111;
1130 let Inst{7} = 1;
1131 let Inst{5-4} = rot;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001132}
1133
Jim Grosbach70327412011-07-27 17:48:13 +00001134class T2I_exta_rrot_np<bits<3> opcod, string opc>
1135 : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm,rot_imm:$rot),
1136 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot", []> {
1137 bits<2> rot;
1138 let Inst{31-27} = 0b11111;
1139 let Inst{26-23} = 0b0100;
1140 let Inst{22-20} = opcod;
1141 let Inst{15-12} = 0b1111;
1142 let Inst{7} = 1;
1143 let Inst{5-4} = rot;
Johnny Chen93042d12010-03-02 18:14:57 +00001144}
1145
Anton Korobeynikov52237112009-06-17 18:13:58 +00001146//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +00001147// Instructions
1148//===----------------------------------------------------------------------===//
1149
1150//===----------------------------------------------------------------------===//
Evan Chenga09b9ca2009-06-24 23:47:58 +00001151// Miscellaneous Instructions.
1152//
1153
Owen Andersonda663f72010-11-15 21:30:39 +00001154class T2PCOneRegImm<dag oops, dag iops, InstrItinClass itin,
1155 string asm, list<dag> pattern>
1156 : T2XI<oops, iops, itin, asm, pattern> {
1157 bits<4> Rd;
1158 bits<12> label;
Jim Grosbach7a088642010-11-19 17:11:02 +00001159
Jim Grosbach86386922010-12-08 22:10:43 +00001160 let Inst{11-8} = Rd;
Owen Andersonda663f72010-11-15 21:30:39 +00001161 let Inst{26} = label{11};
1162 let Inst{14-12} = label{10-8};
1163 let Inst{7-0} = label{7-0};
1164}
1165
Evan Chenga09b9ca2009-06-24 23:47:58 +00001166// LEApcrel - Load a pc-relative address into a register without offending the
1167// assembler.
Owen Andersona838a252010-12-14 00:36:49 +00001168def t2ADR : T2PCOneRegImm<(outs rGPR:$Rd),
1169 (ins t2adrlabel:$addr, pred:$p),
Owen Anderson08fef882011-09-09 22:24:36 +00001170 IIC_iALUi, "adr{$p}.w\t$Rd, $addr", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001171 let Inst{31-27} = 0b11110;
1172 let Inst{25-24} = 0b10;
1173 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1174 let Inst{22} = 0;
1175 let Inst{20} = 0;
1176 let Inst{19-16} = 0b1111; // Rn
1177 let Inst{15} = 0;
Jim Grosbach00f25fa2010-12-14 20:46:39 +00001178
Owen Andersona838a252010-12-14 00:36:49 +00001179 bits<4> Rd;
1180 bits<13> addr;
1181 let Inst{11-8} = Rd;
1182 let Inst{23} = addr{12};
1183 let Inst{21} = addr{12};
1184 let Inst{26} = addr{11};
1185 let Inst{14-12} = addr{10-8};
1186 let Inst{7-0} = addr{7-0};
Owen Anderson08fef882011-09-09 22:24:36 +00001187
1188 let DecoderMethod = "DecodeT2Adr";
Owen Anderson6b8719f2010-12-13 22:51:08 +00001189}
Owen Andersona838a252010-12-14 00:36:49 +00001190
1191let neverHasSideEffects = 1, isReMaterializable = 1 in
Jim Grosbach41b1d4e2010-12-15 18:48:45 +00001192def t2LEApcrel : t2PseudoInst<(outs rGPR:$Rd), (ins i32imm:$label, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001193 4, IIC_iALUi, []>;
Jakob Stoklund Olesen7778ee12012-08-24 21:44:11 +00001194let hasSideEffects = 1 in
Jim Grosbach41b1d4e2010-12-15 18:48:45 +00001195def t2LEApcrelJT : t2PseudoInst<(outs rGPR:$Rd),
1196 (ins i32imm:$label, nohash_imm:$id, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001197 4, IIC_iALUi,
Jim Grosbach41b1d4e2010-12-15 18:48:45 +00001198 []>;
Evan Chenga09b9ca2009-06-24 23:47:58 +00001199
Jim Grosbach60fc2ed2010-12-08 23:30:19 +00001200
Evan Chenga09b9ca2009-06-24 23:47:58 +00001201//===----------------------------------------------------------------------===//
Evan Cheng9cb9e672009-06-27 02:26:13 +00001202// Load / store Instructions.
1203//
1204
Evan Cheng055b0312009-06-29 07:51:04 +00001205// Load
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001206let canFoldAsLoad = 1, isReMaterializable = 1 in
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001207defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si, GPR,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001208 UnOpFrag<(load node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001209
Evan Chengf3c21b82009-06-30 02:15:48 +00001210// Loads with zero extension
Evan Cheng7e2fe912010-10-28 06:47:08 +00001211defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001212 rGPR, UnOpFrag<(zextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001213defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001214 rGPR, UnOpFrag<(zextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001215
Evan Chengf3c21b82009-06-30 02:15:48 +00001216// Loads with sign extension
Evan Cheng7e2fe912010-10-28 06:47:08 +00001217defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001218 rGPR, UnOpFrag<(sextloadi16 node:$Src)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001219defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001220 rGPR, UnOpFrag<(sextloadi8 node:$Src)>>;
Evan Cheng055b0312009-06-29 07:51:04 +00001221
Owen Anderson9d63d902010-12-01 19:18:46 +00001222let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
Evan Chengf3c21b82009-06-30 02:15:48 +00001223// Load doubleword
Owen Anderson9d63d902010-12-01 19:18:46 +00001224def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$Rt, rGPR:$Rt2),
Evan Chenge298ab22009-09-27 09:46:04 +00001225 (ins t2addrmode_imm8s4:$addr),
Jim Grosbacha77295d2011-09-08 22:07:06 +00001226 IIC_iLoad_d_i, "ldrd", "\t$Rt, $Rt2, $addr", "", []>;
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001227} // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
Evan Chengf3c21b82009-06-30 02:15:48 +00001228
1229// zextload i1 -> zextload i8
1230def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1231 (t2LDRBi12 t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001232def : T2Pat<(zextloadi1 t2addrmode_negimm8:$addr),
1233 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
Evan Chengf3c21b82009-06-30 02:15:48 +00001234def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1235 (t2LDRBs t2addrmode_so_reg:$addr)>;
1236def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1237 (t2LDRBpci tconstpool:$addr)>;
1238
1239// extload -> zextload
1240// FIXME: Reduce the number of patterns by legalizing extload to zextload
1241// earlier?
1242def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1243 (t2LDRBi12 t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001244def : T2Pat<(extloadi1 t2addrmode_negimm8:$addr),
1245 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
Evan Chengf3c21b82009-06-30 02:15:48 +00001246def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1247 (t2LDRBs t2addrmode_so_reg:$addr)>;
1248def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1249 (t2LDRBpci tconstpool:$addr)>;
1250
1251def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1252 (t2LDRBi12 t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001253def : T2Pat<(extloadi8 t2addrmode_negimm8:$addr),
1254 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
Evan Chengf3c21b82009-06-30 02:15:48 +00001255def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1256 (t2LDRBs t2addrmode_so_reg:$addr)>;
1257def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1258 (t2LDRBpci tconstpool:$addr)>;
1259
1260def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1261 (t2LDRHi12 t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001262def : T2Pat<(extloadi16 t2addrmode_negimm8:$addr),
1263 (t2LDRHi8 t2addrmode_negimm8:$addr)>;
Evan Chengf3c21b82009-06-30 02:15:48 +00001264def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1265 (t2LDRHs t2addrmode_so_reg:$addr)>;
1266def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1267 (t2LDRHpci tconstpool:$addr)>;
Evan Cheng055b0312009-06-29 07:51:04 +00001268
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001269// FIXME: The destination register of the loads and stores can't be PC, but
1270// can be SP. We need another regclass (similar to rGPR) to represent
1271// that. Not a pressing issue since these are selected manually,
1272// not via pattern.
1273
Evan Chenge88d5ce2009-07-02 07:28:31 +00001274// Indexed loads
Owen Anderson6af50f72010-11-30 00:14:31 +00001275
Evan Cheng5fd1c9b2010-05-19 06:07:03 +00001276let mayLoad = 1, neverHasSideEffects = 1 in {
Jim Grosbacheeec0252011-09-08 00:39:19 +00001277def t2LDR_PRE : T2Ipreldst<0, 0b10, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001278 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001279 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
Jim Grosbacheeec0252011-09-08 00:39:19 +00001280 "ldr", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1281 []> {
1282 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1283}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001284
Jim Grosbacheeec0252011-09-08 00:39:19 +00001285def t2LDR_POST : T2Ipostldst<0, 0b10, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
Jim Grosbache64fb282011-09-08 01:01:32 +00001286 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1287 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001288 "ldr", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
Evan Chenge88d5ce2009-07-02 07:28:31 +00001289
Jim Grosbacheeec0252011-09-08 00:39:19 +00001290def t2LDRB_PRE : T2Ipreldst<0, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001291 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001292 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Jim Grosbacheeec0252011-09-08 00:39:19 +00001293 "ldrb", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1294 []> {
1295 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1296}
1297def t2LDRB_POST : T2Ipostldst<0, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
Jim Grosbache64fb282011-09-08 01:01:32 +00001298 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1299 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001300 "ldrb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
Evan Chenge88d5ce2009-07-02 07:28:31 +00001301
Jim Grosbacheeec0252011-09-08 00:39:19 +00001302def t2LDRH_PRE : T2Ipreldst<0, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
Evan Chenge88d5ce2009-07-02 07:28:31 +00001303 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001304 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Jim Grosbacheeec0252011-09-08 00:39:19 +00001305 "ldrh", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1306 []> {
1307 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1308}
1309def t2LDRH_POST : T2Ipostldst<0, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
Jim Grosbache64fb282011-09-08 01:01:32 +00001310 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1311 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001312 "ldrh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
Evan Chenge88d5ce2009-07-02 07:28:31 +00001313
Jim Grosbacheeec0252011-09-08 00:39:19 +00001314def t2LDRSB_PRE : T2Ipreldst<1, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001315 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001316 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Jim Grosbacheeec0252011-09-08 00:39:19 +00001317 "ldrsb", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1318 []> {
1319 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1320}
1321def t2LDRSB_POST : T2Ipostldst<1, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
Jim Grosbache64fb282011-09-08 01:01:32 +00001322 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1323 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001324 "ldrsb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
Evan Cheng4fbb9962009-07-02 23:16:11 +00001325
Jim Grosbacheeec0252011-09-08 00:39:19 +00001326def t2LDRSH_PRE : T2Ipreldst<1, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
Evan Cheng4fbb9962009-07-02 23:16:11 +00001327 (ins t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001328 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
Jim Grosbacheeec0252011-09-08 00:39:19 +00001329 "ldrsh", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1330 []> {
1331 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1332}
1333def t2LDRSH_POST : T2Ipostldst<1, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
Jim Grosbache64fb282011-09-08 01:01:32 +00001334 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1335 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001336 "ldrsh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
Jim Grosbach7a088642010-11-19 17:11:02 +00001337} // mayLoad = 1, neverHasSideEffects = 1
Evan Cheng4fbb9962009-07-02 23:16:11 +00001338
Jim Grosbachf0eee6e2011-09-07 23:39:14 +00001339// LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110).
Johnny Chene54a3ef2010-03-03 18:45:36 +00001340// Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001341class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
Jim Grosbachf0eee6e2011-09-07 23:39:14 +00001342 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_posimm8:$addr), ii, opc,
Owen Andersoneb05a8d2010-11-30 18:38:28 +00001343 "\t$Rt, $addr", []> {
Jim Grosbachf0eee6e2011-09-07 23:39:14 +00001344 bits<4> Rt;
1345 bits<13> addr;
Johnny Chene54a3ef2010-03-03 18:45:36 +00001346 let Inst{31-27} = 0b11111;
1347 let Inst{26-25} = 0b00;
1348 let Inst{24} = signed;
1349 let Inst{23} = 0;
1350 let Inst{22-21} = type;
1351 let Inst{20} = 1; // load
Jim Grosbachf0eee6e2011-09-07 23:39:14 +00001352 let Inst{19-16} = addr{12-9};
1353 let Inst{15-12} = Rt;
Johnny Chene54a3ef2010-03-03 18:45:36 +00001354 let Inst{11} = 1;
1355 let Inst{10-8} = 0b110; // PUW.
Jim Grosbachf0eee6e2011-09-07 23:39:14 +00001356 let Inst{7-0} = addr{7-0};
Johnny Chene54a3ef2010-03-03 18:45:36 +00001357}
1358
Evan Cheng0e55fd62010-09-30 01:08:25 +00001359def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1360def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1361def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1362def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1363def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
Johnny Chene54a3ef2010-03-03 18:45:36 +00001364
David Goodwin73b8f162009-06-30 22:11:34 +00001365// Store
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001366defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si, GPR,
Evan Cheng0e55fd62010-09-30 01:08:25 +00001367 BinOpFrag<(store node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001368defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001369 rGPR, BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
Evan Cheng7e2fe912010-10-28 06:47:08 +00001370defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
Owen Anderson9fe72bc2011-08-11 20:40:40 +00001371 rGPR, BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
David Goodwin73b8f162009-06-30 22:11:34 +00001372
David Goodwin6647cea2009-06-30 22:50:01 +00001373// Store doubleword
Cameron Zwarichd5751372011-10-16 06:38:06 +00001374let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
Johnny Chend68e1192009-12-15 17:24:14 +00001375def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
Owen Anderson9d63d902010-12-01 19:18:46 +00001376 (ins GPR:$Rt, GPR:$Rt2, t2addrmode_imm8s4:$addr),
Jim Grosbacha77295d2011-09-08 22:07:06 +00001377 IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", "", []>;
David Goodwin6647cea2009-06-30 22:50:01 +00001378
Evan Cheng6d94f112009-07-03 00:06:39 +00001379// Indexed stores
Cameron Zwarichdaada342011-10-16 06:38:10 +00001380
1381let mayStore = 1, neverHasSideEffects = 1 in {
Jim Grosbacheeec0252011-09-08 00:39:19 +00001382def t2STR_PRE : T2Ipreldst<0, 0b10, 0, 1, (outs GPRnopc:$Rn_wb),
Jim Grosbachb0659872011-12-13 21:10:25 +00001383 (ins GPRnopc:$Rt, t2addrmode_imm8:$addr),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001384 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
Jim Grosbachee2c2a42011-09-16 21:55:56 +00001385 "str", "\t$Rt, $addr!",
1386 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1387 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1388}
1389def t2STRH_PRE : T2Ipreldst<0, 0b01, 0, 1, (outs GPRnopc:$Rn_wb),
1390 (ins rGPR:$Rt, t2addrmode_imm8:$addr),
1391 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1392 "strh", "\t$Rt, $addr!",
1393 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1394 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1395}
1396
1397def t2STRB_PRE : T2Ipreldst<0, 0b00, 0, 1, (outs GPRnopc:$Rn_wb),
1398 (ins rGPR:$Rt, t2addrmode_imm8:$addr),
1399 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
1400 "strb", "\t$Rt, $addr!",
1401 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1402 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1403}
Eli Friedman0851a292011-10-18 03:17:34 +00001404} // mayStore = 1, neverHasSideEffects = 1
Evan Cheng6d94f112009-07-03 00:06:39 +00001405
Jim Grosbacheeec0252011-09-08 00:39:19 +00001406def t2STR_POST : T2Ipostldst<0, 0b10, 0, 0, (outs GPRnopc:$Rn_wb),
Jim Grosbachb0659872011-12-13 21:10:25 +00001407 (ins GPRnopc:$Rt, addr_offset_none:$Rn,
Jim Grosbach947a24c2011-09-16 21:09:00 +00001408 t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001409 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001410 "str", "\t$Rt, $Rn$offset",
Jim Grosbacheeec0252011-09-08 00:39:19 +00001411 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1412 [(set GPRnopc:$Rn_wb,
Jim Grosbachb0659872011-12-13 21:10:25 +00001413 (post_store GPRnopc:$Rt, addr_offset_none:$Rn,
Jim Grosbach947a24c2011-09-16 21:09:00 +00001414 t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001415
Jim Grosbacheeec0252011-09-08 00:39:19 +00001416def t2STRH_POST : T2Ipostldst<0, 0b01, 0, 0, (outs GPRnopc:$Rn_wb),
Jim Grosbach947a24c2011-09-16 21:09:00 +00001417 (ins rGPR:$Rt, addr_offset_none:$Rn,
1418 t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001419 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001420 "strh", "\t$Rt, $Rn$offset",
Jim Grosbacheeec0252011-09-08 00:39:19 +00001421 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1422 [(set GPRnopc:$Rn_wb,
Jim Grosbach947a24c2011-09-16 21:09:00 +00001423 (post_truncsti16 rGPR:$Rt, addr_offset_none:$Rn,
1424 t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001425
Jim Grosbacheeec0252011-09-08 00:39:19 +00001426def t2STRB_POST : T2Ipostldst<0, 0b00, 0, 0, (outs GPRnopc:$Rn_wb),
Jim Grosbach947a24c2011-09-16 21:09:00 +00001427 (ins rGPR:$Rt, addr_offset_none:$Rn,
1428 t2am_imm8_offset:$offset),
Evan Cheng0e55fd62010-09-30 01:08:25 +00001429 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
Owen Anderson0781c1f2011-09-23 21:26:40 +00001430 "strb", "\t$Rt, $Rn$offset",
Jim Grosbacheeec0252011-09-08 00:39:19 +00001431 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1432 [(set GPRnopc:$Rn_wb,
Jim Grosbach947a24c2011-09-16 21:09:00 +00001433 (post_truncsti8 rGPR:$Rt, addr_offset_none:$Rn,
1434 t2am_imm8_offset:$offset))]>;
Evan Cheng6d94f112009-07-03 00:06:39 +00001435
Jim Grosbachee2c2a42011-09-16 21:55:56 +00001436// Pseudo-instructions for pattern matching the pre-indexed stores. We can't
1437// put the patterns on the instruction definitions directly as ISel wants
1438// the address base and offset to be separate operands, not a single
1439// complex operand like we represent the instructions themselves. The
1440// pseudos map between the two.
1441let usesCustomInserter = 1,
1442 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
1443def t2STR_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1444 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1445 4, IIC_iStore_ru,
1446 [(set GPRnopc:$Rn_wb,
1447 (pre_store rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1448def t2STRB_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1449 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1450 4, IIC_iStore_ru,
1451 [(set GPRnopc:$Rn_wb,
1452 (pre_truncsti8 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1453def t2STRH_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1454 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1455 4, IIC_iStore_ru,
1456 [(set GPRnopc:$Rn_wb,
1457 (pre_truncsti16 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1458}
Jim Grosbachee2c2a42011-09-16 21:55:56 +00001459
Johnny Chene54a3ef2010-03-03 18:45:36 +00001460// STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1461// only.
1462// Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
Evan Cheng0e55fd62010-09-30 01:08:25 +00001463class T2IstT<bits<2> type, string opc, InstrItinClass ii>
Johnny Chen471d73d2011-04-13 21:04:32 +00001464 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_imm8:$addr), ii, opc,
Owen Andersoneb05a8d2010-11-30 18:38:28 +00001465 "\t$Rt, $addr", []> {
Johnny Chene54a3ef2010-03-03 18:45:36 +00001466 let Inst{31-27} = 0b11111;
1467 let Inst{26-25} = 0b00;
1468 let Inst{24} = 0; // not signed
1469 let Inst{23} = 0;
1470 let Inst{22-21} = type;
1471 let Inst{20} = 0; // store
1472 let Inst{11} = 1;
1473 let Inst{10-8} = 0b110; // PUW
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001474
Owen Andersoneb05a8d2010-11-30 18:38:28 +00001475 bits<4> Rt;
1476 bits<13> addr;
Jim Grosbach86386922010-12-08 22:10:43 +00001477 let Inst{15-12} = Rt;
Owen Andersoneb05a8d2010-11-30 18:38:28 +00001478 let Inst{19-16} = addr{12-9};
1479 let Inst{7-0} = addr{7-0};
Johnny Chene54a3ef2010-03-03 18:45:36 +00001480}
1481
Evan Cheng0e55fd62010-09-30 01:08:25 +00001482def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1483def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1484def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
David Goodwind1fa1202009-07-01 00:01:13 +00001485
Johnny Chenae1757b2010-03-11 01:13:36 +00001486// ldrd / strd pre / post variants
1487// For disassembly only.
1488
Jim Grosbacha77295d2011-09-08 22:07:06 +00001489def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1490 (ins t2addrmode_imm8s4:$addr), IIC_iLoad_d_ru,
1491 "ldrd", "\t$Rt, $Rt2, $addr!", "$addr.base = $wb", []> {
1492 let AsmMatchConverter = "cvtT2LdrdPre";
1493 let DecoderMethod = "DecodeT2LDRDPreInstruction";
1494}
Johnny Chenae1757b2010-03-11 01:13:36 +00001495
Jim Grosbacha77295d2011-09-08 22:07:06 +00001496def t2LDRD_POST : T2Ii8s4post<0, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1497 (ins addr_offset_none:$addr, t2am_imm8s4_offset:$imm),
Owen Anderson7782a582011-09-13 20:46:26 +00001498 IIC_iLoad_d_ru, "ldrd", "\t$Rt, $Rt2, $addr$imm",
Jim Grosbacha77295d2011-09-08 22:07:06 +00001499 "$addr.base = $wb", []>;
Johnny Chenae1757b2010-03-11 01:13:36 +00001500
Jim Grosbacha77295d2011-09-08 22:07:06 +00001501def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs GPR:$wb),
1502 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4:$addr),
1503 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr!",
1504 "$addr.base = $wb", []> {
1505 let AsmMatchConverter = "cvtT2StrdPre";
1506 let DecoderMethod = "DecodeT2STRDPreInstruction";
1507}
Johnny Chenae1757b2010-03-11 01:13:36 +00001508
Jim Grosbacha77295d2011-09-08 22:07:06 +00001509def t2STRD_POST : T2Ii8s4post<0, 1, 0, (outs GPR:$wb),
1510 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr,
1511 t2am_imm8s4_offset:$imm),
Owen Anderson7782a582011-09-13 20:46:26 +00001512 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr$imm",
Jim Grosbacha77295d2011-09-08 22:07:06 +00001513 "$addr.base = $wb", []>;
Evan Cheng2889cce2009-07-03 00:18:36 +00001514
Johnny Chen0635fc52010-03-04 17:40:44 +00001515// T2Ipl (Preload Data/Instruction) signals the memory system of possible future
Jim Grosbacha5813282011-10-26 22:22:01 +00001516// data/instruction access.
Evan Chengdfed19f2010-11-03 06:34:55 +00001517// instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1518// (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
Evan Cheng416941d2010-11-04 05:19:35 +00001519multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001520
Evan Chengdfed19f2010-11-03 06:34:55 +00001521 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001522 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001523 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001524 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001525 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001526 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001527 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001528 let Inst{20} = 1;
1529 let Inst{15-12} = 0b1111;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001530
Owen Anderson80dd3e02010-11-30 22:45:47 +00001531 bits<17> addr;
Johnny Chenf9ce2cb2011-04-12 18:48:00 +00001532 let addr{12} = 1; // add = TRUE
Owen Anderson80dd3e02010-11-30 22:45:47 +00001533 let Inst{19-16} = addr{16-13}; // Rn
1534 let Inst{23} = addr{12}; // U
Owen Anderson0e1bcdf2010-11-30 19:19:31 +00001535 let Inst{11-0} = addr{11-0}; // imm12
Johnny Chen0635fc52010-03-04 17:40:44 +00001536 }
1537
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001538 def i8 : T2Ii8<(outs), (ins t2addrmode_negimm8:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001539 "\t$addr",
Jim Grosbacha8307dd2011-09-07 20:58:57 +00001540 [(ARMPreload t2addrmode_negimm8:$addr, (i32 write), (i32 instr))]> {
Johnny Chen0635fc52010-03-04 17:40:44 +00001541 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001542 let Inst{24} = instr;
Johnny Chen0635fc52010-03-04 17:40:44 +00001543 let Inst{23} = 0; // U = 0
1544 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001545 let Inst{21} = write;
Johnny Chen0635fc52010-03-04 17:40:44 +00001546 let Inst{20} = 1;
1547 let Inst{15-12} = 0b1111;
1548 let Inst{11-8} = 0b1100;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001549
Owen Anderson0e1bcdf2010-11-30 19:19:31 +00001550 bits<13> addr;
1551 let Inst{19-16} = addr{12-9}; // Rn
1552 let Inst{7-0} = addr{7-0}; // imm8
Johnny Chen0635fc52010-03-04 17:40:44 +00001553 }
1554
Evan Chengdfed19f2010-11-03 06:34:55 +00001555 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
Evan Chengbc7deb02010-11-03 05:14:24 +00001556 "\t$addr",
Evan Cheng416941d2010-11-04 05:19:35 +00001557 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
Evan Chengbc7deb02010-11-03 05:14:24 +00001558 let Inst{31-25} = 0b1111100;
Evan Cheng416941d2010-11-04 05:19:35 +00001559 let Inst{24} = instr;
Evan Chengbc7deb02010-11-03 05:14:24 +00001560 let Inst{23} = 0; // add = TRUE for T1
1561 let Inst{22} = 0;
Evan Cheng416941d2010-11-04 05:19:35 +00001562 let Inst{21} = write;
Evan Chengbc7deb02010-11-03 05:14:24 +00001563 let Inst{20} = 1;
1564 let Inst{15-12} = 0b1111;
1565 let Inst{11-6} = 0000000;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00001566
Owen Anderson0e1bcdf2010-11-30 19:19:31 +00001567 bits<10> addr;
1568 let Inst{19-16} = addr{9-6}; // Rn
1569 let Inst{3-0} = addr{5-2}; // Rm
1570 let Inst{5-4} = addr{1-0}; // imm2
Owen Anderson8d7d2e12011-08-09 20:55:18 +00001571
1572 let DecoderMethod = "DecodeT2LoadShift";
Evan Chengbc7deb02010-11-03 05:14:24 +00001573 }
Jim Grosbacha5813282011-10-26 22:22:01 +00001574 // FIXME: We should have a separate 'pci' variant here. As-is we represent
1575 // it via the i12 variant, which it's related to, but that means we can
1576 // represent negative immediates, which aren't legal for anything except
1577 // the 'pci' case (Rn == 15).
Johnny Chen0635fc52010-03-04 17:40:44 +00001578}
1579
Evan Cheng416941d2010-11-04 05:19:35 +00001580defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1581defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1582defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
Johnny Chen0635fc52010-03-04 17:40:44 +00001583
Evan Cheng2889cce2009-07-03 00:18:36 +00001584//===----------------------------------------------------------------------===//
1585// Load / store multiple Instructions.
1586//
1587
Owen Andersoncd00dc62011-09-12 21:28:46 +00001588multiclass thumb2_ld_mult<string asm, InstrItinClass itin,
Bill Wendling6c470b82010-11-13 09:09:38 +00001589 InstrItinClass itin_upd, bit L_bit> {
Bill Wendling73fe34a2010-11-16 01:16:36 +00001590 def IA :
Bill Wendling6c470b82010-11-13 09:09:38 +00001591 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
Jim Grosbachffa5a762011-09-07 16:22:42 +00001592 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
Bill Wendling6c470b82010-11-13 09:09:38 +00001593 bits<4> Rn;
1594 bits<16> regs;
Jim Grosbach7a088642010-11-19 17:11:02 +00001595
Bill Wendling6c470b82010-11-13 09:09:38 +00001596 let Inst{31-27} = 0b11101;
1597 let Inst{26-25} = 0b00;
1598 let Inst{24-23} = 0b01; // Increment After
1599 let Inst{22} = 0;
1600 let Inst{21} = 0; // No writeback
1601 let Inst{20} = L_bit;
1602 let Inst{19-16} = Rn;
Jim Grosbachf8e74f82011-10-24 17:16:24 +00001603 let Inst{15-0} = regs;
Bill Wendling6c470b82010-11-13 09:09:38 +00001604 }
Bill Wendling73fe34a2010-11-16 01:16:36 +00001605 def IA_UPD :
Bill Wendling6c470b82010-11-13 09:09:38 +00001606 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
Jim Grosbachffa5a762011-09-07 16:22:42 +00001607 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +00001608 bits<4> Rn;
1609 bits<16> regs;
Jim Grosbach7a088642010-11-19 17:11:02 +00001610
Bill Wendling6c470b82010-11-13 09:09:38 +00001611 let Inst{31-27} = 0b11101;
1612 let Inst{26-25} = 0b00;
1613 let Inst{24-23} = 0b01; // Increment After
1614 let Inst{22} = 0;
1615 let Inst{21} = 1; // Writeback
1616 let Inst{20} = L_bit;
1617 let Inst{19-16} = Rn;
Jim Grosbachf8e74f82011-10-24 17:16:24 +00001618 let Inst{15-0} = regs;
Bill Wendling6c470b82010-11-13 09:09:38 +00001619 }
Bill Wendling73fe34a2010-11-16 01:16:36 +00001620 def DB :
Bill Wendling6c470b82010-11-13 09:09:38 +00001621 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
Jim Grosbachcfbb3a72011-09-07 18:39:47 +00001622 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
Bill Wendling6c470b82010-11-13 09:09:38 +00001623 bits<4> Rn;
1624 bits<16> regs;
1625
1626 let Inst{31-27} = 0b11101;
1627 let Inst{26-25} = 0b00;
1628 let Inst{24-23} = 0b10; // Decrement Before
1629 let Inst{22} = 0;
1630 let Inst{21} = 0; // No writeback
1631 let Inst{20} = L_bit;
1632 let Inst{19-16} = Rn;
Jim Grosbachf8e74f82011-10-24 17:16:24 +00001633 let Inst{15-0} = regs;
Bill Wendling6c470b82010-11-13 09:09:38 +00001634 }
Bill Wendling73fe34a2010-11-16 01:16:36 +00001635 def DB_UPD :
Bill Wendling6c470b82010-11-13 09:09:38 +00001636 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
Jim Grosbachcfbb3a72011-09-07 18:39:47 +00001637 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +00001638 bits<4> Rn;
1639 bits<16> regs;
1640
1641 let Inst{31-27} = 0b11101;
1642 let Inst{26-25} = 0b00;
1643 let Inst{24-23} = 0b10; // Decrement Before
1644 let Inst{22} = 0;
1645 let Inst{21} = 1; // Writeback
1646 let Inst{20} = L_bit;
1647 let Inst{19-16} = Rn;
Jim Grosbachf8e74f82011-10-24 17:16:24 +00001648 let Inst{15-0} = regs;
Bill Wendling6c470b82010-11-13 09:09:38 +00001649 }
1650}
1651
Bill Wendlingc93989a2010-11-13 11:20:05 +00001652let neverHasSideEffects = 1 in {
Bill Wendlingddc918b2010-11-13 10:57:02 +00001653
1654let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
Owen Andersoncd00dc62011-09-12 21:28:46 +00001655defm t2LDM : thumb2_ld_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>;
1656
1657multiclass thumb2_st_mult<string asm, InstrItinClass itin,
1658 InstrItinClass itin_upd, bit L_bit> {
1659 def IA :
1660 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1661 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
1662 bits<4> Rn;
1663 bits<16> regs;
1664
1665 let Inst{31-27} = 0b11101;
1666 let Inst{26-25} = 0b00;
1667 let Inst{24-23} = 0b01; // Increment After
1668 let Inst{22} = 0;
1669 let Inst{21} = 0; // No writeback
1670 let Inst{20} = L_bit;
1671 let Inst{19-16} = Rn;
1672 let Inst{15} = 0;
1673 let Inst{14} = regs{14};
1674 let Inst{13} = 0;
1675 let Inst{12-0} = regs{12-0};
1676 }
1677 def IA_UPD :
1678 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1679 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1680 bits<4> Rn;
1681 bits<16> regs;
1682
1683 let Inst{31-27} = 0b11101;
1684 let Inst{26-25} = 0b00;
1685 let Inst{24-23} = 0b01; // Increment After
1686 let Inst{22} = 0;
1687 let Inst{21} = 1; // Writeback
1688 let Inst{20} = L_bit;
1689 let Inst{19-16} = Rn;
1690 let Inst{15} = 0;
1691 let Inst{14} = regs{14};
1692 let Inst{13} = 0;
1693 let Inst{12-0} = regs{12-0};
1694 }
1695 def DB :
1696 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1697 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
1698 bits<4> Rn;
1699 bits<16> regs;
1700
1701 let Inst{31-27} = 0b11101;
1702 let Inst{26-25} = 0b00;
1703 let Inst{24-23} = 0b10; // Decrement Before
1704 let Inst{22} = 0;
1705 let Inst{21} = 0; // No writeback
1706 let Inst{20} = L_bit;
1707 let Inst{19-16} = Rn;
1708 let Inst{15} = 0;
1709 let Inst{14} = regs{14};
1710 let Inst{13} = 0;
1711 let Inst{12-0} = regs{12-0};
1712 }
1713 def DB_UPD :
1714 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1715 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1716 bits<4> Rn;
1717 bits<16> regs;
1718
1719 let Inst{31-27} = 0b11101;
1720 let Inst{26-25} = 0b00;
1721 let Inst{24-23} = 0b10; // Decrement Before
1722 let Inst{22} = 0;
1723 let Inst{21} = 1; // Writeback
1724 let Inst{20} = L_bit;
1725 let Inst{19-16} = Rn;
1726 let Inst{15} = 0;
1727 let Inst{14} = regs{14};
1728 let Inst{13} = 0;
1729 let Inst{12-0} = regs{12-0};
1730 }
1731}
1732
Bill Wendlingddc918b2010-11-13 10:57:02 +00001733
1734let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
Owen Andersoncd00dc62011-09-12 21:28:46 +00001735defm t2STM : thumb2_st_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>;
Bill Wendlingddc918b2010-11-13 10:57:02 +00001736
1737} // neverHasSideEffects
1738
Bob Wilson815baeb2010-03-13 01:08:20 +00001739
Evan Cheng9cb9e672009-06-27 02:26:13 +00001740//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001741// Move Instructions.
1742//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001743
Evan Chengf49810c2009-06-23 17:48:47 +00001744let neverHasSideEffects = 1 in
Jim Grosbach1ad60c22011-09-10 00:15:36 +00001745def t2MOVr : T2sTwoReg<(outs GPRnopc:$Rd), (ins GPR:$Rm), IIC_iMOVr,
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001746 "mov", ".w\t$Rd, $Rm", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00001747 let Inst{31-27} = 0b11101;
1748 let Inst{26-25} = 0b01;
1749 let Inst{24-21} = 0b0010;
Johnny Chend68e1192009-12-15 17:24:14 +00001750 let Inst{19-16} = 0b1111; // Rn
1751 let Inst{14-12} = 0b000;
1752 let Inst{7-4} = 0b0000;
1753}
Jim Grosbach9858a482011-10-18 17:09:35 +00001754def : t2InstAlias<"mov${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1755 pred:$p, zero_reg)>;
Jim Grosbach1ad60c22011-09-10 00:15:36 +00001756def : t2InstAlias<"movs${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1757 pred:$p, CPSR)>;
1758def : t2InstAlias<"movs${p} $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1759 pred:$p, CPSR)>;
Evan Chengf49810c2009-06-23 17:48:47 +00001760
Evan Cheng5adb66a2009-09-28 09:14:39 +00001761// AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
Evan Chengc4af4632010-11-17 20:13:28 +00001762let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1,
1763 AddedComplexity = 1 in
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001764def t2MOVi : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), IIC_iMOVi,
1765 "mov", ".w\t$Rd, $imm",
1766 [(set rGPR:$Rd, t2_so_imm:$imm)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001767 let Inst{31-27} = 0b11110;
1768 let Inst{25} = 0;
1769 let Inst{24-21} = 0b0010;
Johnny Chend68e1192009-12-15 17:24:14 +00001770 let Inst{19-16} = 0b1111; // Rn
1771 let Inst{15} = 0;
1772}
David Goodwin83b35932009-06-26 16:10:07 +00001773
Jim Grosbach1ad60c22011-09-10 00:15:36 +00001774// cc_out is handled as part of the explicit mnemonic in the parser for 'mov'.
1775// Use aliases to get that to play nice here.
1776def : t2InstAlias<"movs${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1777 pred:$p, CPSR)>;
1778def : t2InstAlias<"movs${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1779 pred:$p, CPSR)>;
1780
1781def : t2InstAlias<"mov${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1782 pred:$p, zero_reg)>;
1783def : t2InstAlias<"mov${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1784 pred:$p, zero_reg)>;
Jim Grosbach6b8f1e32011-06-27 23:54:06 +00001785
Evan Chengc4af4632010-11-17 20:13:28 +00001786let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
Jim Grosbachffa32252011-07-19 19:13:28 +00001787def t2MOVi16 : T2I<(outs rGPR:$Rd), (ins imm0_65535_expr:$imm), IIC_iMOVi,
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001788 "movw", "\t$Rd, $imm",
1789 [(set rGPR:$Rd, imm0_65535:$imm)]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001790 let Inst{31-27} = 0b11110;
1791 let Inst{25} = 1;
1792 let Inst{24-21} = 0b0010;
1793 let Inst{20} = 0; // The S bit.
1794 let Inst{15} = 0;
Jim Grosbach7a088642010-11-19 17:11:02 +00001795
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001796 bits<4> Rd;
1797 bits<16> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +00001798
Jim Grosbach86386922010-12-08 22:10:43 +00001799 let Inst{11-8} = Rd;
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001800 let Inst{19-16} = imm{15-12};
1801 let Inst{26} = imm{11};
1802 let Inst{14-12} = imm{10-8};
1803 let Inst{7-0} = imm{7-0};
Kevin Enderby9e5887b2011-10-04 22:44:48 +00001804 let DecoderMethod = "DecodeT2MOVTWInstruction";
Johnny Chend68e1192009-12-15 17:24:14 +00001805}
Evan Chengf49810c2009-06-23 17:48:47 +00001806
Evan Cheng53519f02011-01-21 18:55:51 +00001807def t2MOVi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
Evan Cheng5de5d4b2011-01-17 08:03:18 +00001808 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1809
1810let Constraints = "$src = $Rd" in {
Evan Cheng75972122011-01-13 07:58:56 +00001811def t2MOVTi16 : T2I<(outs rGPR:$Rd),
Jim Grosbachffa32252011-07-19 19:13:28 +00001812 (ins rGPR:$src, imm0_65535_expr:$imm), IIC_iMOVi,
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001813 "movt", "\t$Rd, $imm",
1814 [(set rGPR:$Rd,
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001815 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00001816 let Inst{31-27} = 0b11110;
1817 let Inst{25} = 1;
1818 let Inst{24-21} = 0b0110;
1819 let Inst{20} = 0; // The S bit.
1820 let Inst{15} = 0;
Jim Grosbach7a088642010-11-19 17:11:02 +00001821
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001822 bits<4> Rd;
1823 bits<16> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +00001824
Jim Grosbach86386922010-12-08 22:10:43 +00001825 let Inst{11-8} = Rd;
Owen Andersonc56dcbf2010-11-16 00:29:56 +00001826 let Inst{19-16} = imm{15-12};
1827 let Inst{26} = imm{11};
1828 let Inst{14-12} = imm{10-8};
1829 let Inst{7-0} = imm{7-0};
Kevin Enderby9e5887b2011-10-04 22:44:48 +00001830 let DecoderMethod = "DecodeT2MOVTWInstruction";
Johnny Chend68e1192009-12-15 17:24:14 +00001831}
Anton Korobeynikov52237112009-06-17 18:13:58 +00001832
Evan Cheng53519f02011-01-21 18:55:51 +00001833def t2MOVTi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
Evan Cheng5de5d4b2011-01-17 08:03:18 +00001834 (ins rGPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1835} // Constraints
1836
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001837def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
Evan Cheng20956592009-10-21 08:15:52 +00001838
Anton Korobeynikov52237112009-06-17 18:13:58 +00001839//===----------------------------------------------------------------------===//
Evan Chengd27c9fc2009-07-03 01:43:10 +00001840// Extend Instructions.
1841//
1842
1843// Sign extenders
1844
Jim Grosbachc5a8c862011-07-27 16:47:19 +00001845def t2SXTB : T2I_ext_rrot<0b100, "sxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001846 UnOpFrag<(sext_inreg node:$Src, i8)>>;
Jim Grosbachc5a8c862011-07-27 16:47:19 +00001847def t2SXTH : T2I_ext_rrot<0b000, "sxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001848 UnOpFrag<(sext_inreg node:$Src, i16)>>;
Jim Grosbach70327412011-07-27 17:48:13 +00001849def t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001850
Jim Grosbach70327412011-07-27 17:48:13 +00001851def t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001852 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Jim Grosbach70327412011-07-27 17:48:13 +00001853def t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
Evan Chengd27c9fc2009-07-03 01:43:10 +00001854 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Jim Grosbach70327412011-07-27 17:48:13 +00001855def t2SXTAB16 : T2I_exta_rrot_np<0b010, "sxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001856
Evan Chengd27c9fc2009-07-03 01:43:10 +00001857// Zero extenders
1858
1859let AddedComplexity = 16 in {
Jim Grosbachc5a8c862011-07-27 16:47:19 +00001860def t2UXTB : T2I_ext_rrot<0b101, "uxtb",
Johnny Chend68e1192009-12-15 17:24:14 +00001861 UnOpFrag<(and node:$Src, 0x000000FF)>>;
Jim Grosbachc5a8c862011-07-27 16:47:19 +00001862def t2UXTH : T2I_ext_rrot<0b001, "uxth",
Johnny Chend68e1192009-12-15 17:24:14 +00001863 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
Jim Grosbach70327412011-07-27 17:48:13 +00001864def t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
Johnny Chend68e1192009-12-15 17:24:14 +00001865 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001866
Jim Grosbach79464942010-07-28 23:17:45 +00001867// FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1868// The transformation should probably be done as a combiner action
1869// instead so we can include a check for masking back in the upper
1870// eight bits of the source into the lower eight bits of the result.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001871//def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach70327412011-07-27 17:48:13 +00001872// (t2UXTB16 rGPR:$Src, 3)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001873// Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001874def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
Jim Grosbach70327412011-07-27 17:48:13 +00001875 (t2UXTB16 rGPR:$Src, 1)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00001876 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001877
Jim Grosbach70327412011-07-27 17:48:13 +00001878def t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001879 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Jim Grosbach70327412011-07-27 17:48:13 +00001880def t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
Jim Grosbach6935efc2009-11-24 00:20:27 +00001881 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Jim Grosbach70327412011-07-27 17:48:13 +00001882def t2UXTAB16 : T2I_exta_rrot_np<0b011, "uxtab16">;
Evan Chengd27c9fc2009-07-03 01:43:10 +00001883}
1884
1885//===----------------------------------------------------------------------===//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001886// Arithmetic Instructions.
1887//
Anton Korobeynikov52237112009-06-17 18:13:58 +00001888
Johnny Chend68e1192009-12-15 17:24:14 +00001889defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1890 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1891defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1892 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001893
Evan Chengf49810c2009-06-23 17:48:47 +00001894// ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
Andrew Trick3be654f2011-09-21 02:20:46 +00001895//
1896// Currently, t2ADDS/t2SUBS are pseudo opcodes that exist only in the
1897// selection DAG. They are "lowered" to real t2ADD/t2SUB opcodes by
1898// AdjustInstrPostInstrSelection where we determine whether or not to
1899// set the "s" bit based on CPSR liveness.
1900//
1901// FIXME: Eliminate t2ADDS/t2SUBS pseudo opcodes after adding tablegen
1902// support for an optional CPSR definition that corresponds to the DAG
1903// node's second value. We can then eliminate the implicit def of CPSR.
Andrew Trick90b7b122011-10-18 19:18:52 +00001904defm t2ADDS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Evan Cheng342e3162011-08-30 01:34:54 +00001905 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
Andrew Trick90b7b122011-10-18 19:18:52 +00001906defm t2SUBS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi,
Evan Cheng342e3162011-08-30 01:34:54 +00001907 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001908
Andrew Trick83a80312011-09-20 18:22:31 +00001909let hasPostISelHook = 1 in {
Johnny Chend68e1192009-12-15 17:24:14 +00001910defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
Evan Cheng342e3162011-08-30 01:34:54 +00001911 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00001912defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
Evan Cheng342e3162011-08-30 01:34:54 +00001913 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
Andrew Trick83a80312011-09-20 18:22:31 +00001914}
Evan Chengf49810c2009-06-23 17:48:47 +00001915
David Goodwin752aa7d2009-07-27 16:39:05 +00001916// RSB
Bob Wilson20d8e4e2010-08-13 23:24:25 +00001917defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
Johnny Chend68e1192009-12-15 17:24:14 +00001918 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Evan Cheng4a517082011-09-06 18:52:20 +00001919
1920// FIXME: Eliminate them if we can write def : Pat patterns which defines
1921// CPSR and the implicit def of CPSR is not needed.
Andrew Trick90b7b122011-10-18 19:18:52 +00001922defm t2RSBS : T2I_rbin_s_is <BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00001923
1924// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001925// The assume-no-carry-in form uses the negation of the input since add/sub
1926// assume opposite meanings of the carry flag (i.e., carry == !borrow).
1927// See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1928// details.
1929// The AddedComplexity preferences the first variant over the others since
1930// it can be shrunk to a 16-bit wide encoding, while the others cannot.
Evan Chengfa2ea1a2009-08-04 01:41:15 +00001931let AddedComplexity = 1 in
Nadav Rotem50b66382012-11-14 19:39:15 +00001932def : T2Pat<(add GPR:$src, imm1_255_neg:$imm),
1933 (t2SUBri GPR:$src, imm1_255_neg:$imm)>;
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001934def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1935 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1936def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1937 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
Evan Chengfc472532012-06-23 00:29:06 +00001938def : T2Pat<(add GPR:$src, imm0_65535_neg:$imm),
1939 (t2SUBrr GPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
1940
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001941let AddedComplexity = 1 in
Nadav Rotem50b66382012-11-14 19:39:15 +00001942def : T2Pat<(ARMaddc rGPR:$src, imm1_255_neg:$imm),
1943 (t2SUBSri rGPR:$src, imm1_255_neg:$imm)>;
Evan Cheng342e3162011-08-30 01:34:54 +00001944def : T2Pat<(ARMaddc rGPR:$src, t2_so_imm_neg:$imm),
Jim Grosbach6ccfc502010-07-30 02:41:01 +00001945 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
Evan Chengfc472532012-06-23 00:29:06 +00001946def : T2Pat<(ARMaddc rGPR:$src, imm0_65535_neg:$imm),
1947 (t2SUBSrr rGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
Jim Grosbach502e0aa2010-07-14 17:45:16 +00001948// The with-carry-in form matches bitwise not instead of the negation.
1949// Effectively, the inverse interpretation of the carry flag already accounts
1950// for part of the negation.
1951let AddedComplexity = 1 in
Evan Cheng342e3162011-08-30 01:34:54 +00001952def : T2Pat<(ARMadde rGPR:$src, imm0_255_not:$imm, CPSR),
Andrew Trick1c3af772011-04-23 03:55:32 +00001953 (t2SBCri rGPR:$src, imm0_255_not:$imm)>;
Evan Cheng342e3162011-08-30 01:34:54 +00001954def : T2Pat<(ARMadde rGPR:$src, t2_so_imm_not:$imm, CPSR),
Andrew Trick1c3af772011-04-23 03:55:32 +00001955 (t2SBCri rGPR:$src, t2_so_imm_not:$imm)>;
Evan Chengfc472532012-06-23 00:29:06 +00001956def : T2Pat<(ARMadde rGPR:$src, imm0_65535_neg:$imm, CPSR),
Evan Chengd258eb32012-10-24 19:53:01 +00001957 (t2SBCrr rGPR:$src, (t2MOVi16 (imm_not_XFORM imm:$imm)))>;
Anton Korobeynikov52237112009-06-17 18:13:58 +00001958
Johnny Chen93042d12010-03-02 18:14:57 +00001959// Select Bytes -- for disassembly only
1960
Owen Andersonc7373f82010-11-30 20:00:01 +00001961def t2SEL : T2ThreeReg<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
Jim Grosbacha7603982011-07-01 21:12:19 +00001962 NoItinerary, "sel", "\t$Rd, $Rn, $Rm", []>,
1963 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chen93042d12010-03-02 18:14:57 +00001964 let Inst{31-27} = 0b11111;
1965 let Inst{26-24} = 0b010;
1966 let Inst{23} = 0b1;
1967 let Inst{22-20} = 0b010;
1968 let Inst{15-12} = 0b1111;
1969 let Inst{7} = 0b1;
1970 let Inst{6-4} = 0b000;
1971}
1972
Johnny Chenadc77332010-02-26 22:04:29 +00001973// A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1974// And Miscellaneous operations -- for disassembly only
Nate Begeman692433b2010-07-29 17:56:55 +00001975class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
Bruno Cardoso Lopes03016002011-01-21 14:07:40 +00001976 list<dag> pat = [/* For disassembly only; pattern left blank */],
1977 dag iops = (ins rGPR:$Rn, rGPR:$Rm),
1978 string asm = "\t$Rd, $Rn, $Rm">
Jim Grosbacha7603982011-07-01 21:12:19 +00001979 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, pat>,
1980 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chenadc77332010-02-26 22:04:29 +00001981 let Inst{31-27} = 0b11111;
1982 let Inst{26-23} = 0b0101;
1983 let Inst{22-20} = op22_20;
1984 let Inst{15-12} = 0b1111;
1985 let Inst{7-4} = op7_4;
Jim Grosbach7a088642010-11-19 17:11:02 +00001986
Owen Anderson46c478e2010-11-17 19:57:38 +00001987 bits<4> Rd;
1988 bits<4> Rn;
1989 bits<4> Rm;
Jim Grosbach7a088642010-11-19 17:11:02 +00001990
Jim Grosbach86386922010-12-08 22:10:43 +00001991 let Inst{11-8} = Rd;
1992 let Inst{19-16} = Rn;
1993 let Inst{3-0} = Rm;
Johnny Chenadc77332010-02-26 22:04:29 +00001994}
1995
1996// Saturating add/subtract -- for disassembly only
1997
Nate Begeman692433b2010-07-29 17:56:55 +00001998def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
Bruno Cardoso Lopes03016002011-01-21 14:07:40 +00001999 [(set rGPR:$Rd, (int_arm_qadd rGPR:$Rn, rGPR:$Rm))],
2000 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
Johnny Chenadc77332010-02-26 22:04:29 +00002001def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
2002def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
2003def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
Bruno Cardoso Lopes03016002011-01-21 14:07:40 +00002004def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd", [],
2005 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2006def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub", [],
2007 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
Johnny Chenadc77332010-02-26 22:04:29 +00002008def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
Nate Begeman692433b2010-07-29 17:56:55 +00002009def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
Bruno Cardoso Lopes03016002011-01-21 14:07:40 +00002010 [(set rGPR:$Rd, (int_arm_qsub rGPR:$Rn, rGPR:$Rm))],
2011 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
Johnny Chenadc77332010-02-26 22:04:29 +00002012def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
2013def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
2014def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
2015def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
2016def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
2017def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
2018def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
2019def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
2020
2021// Signed/Unsigned add/subtract -- for disassembly only
2022
2023def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
2024def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
2025def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
2026def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
2027def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
2028def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
2029def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
2030def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
2031def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
2032def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
2033def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
2034def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
2035
2036// Signed/Unsigned halving add/subtract -- for disassembly only
2037
2038def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
2039def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
2040def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
2041def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
2042def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
2043def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
2044def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
2045def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
2046def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
2047def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
2048def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
2049def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
2050
Owen Anderson821752e2010-11-18 20:32:18 +00002051// Helper class for disassembly only
2052// A6.3.16 & A6.3.17
2053// T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions.
2054class T2ThreeReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2055 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2056 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
2057 let Inst{31-27} = 0b11111;
2058 let Inst{26-24} = 0b011;
2059 let Inst{23} = long;
2060 let Inst{22-20} = op22_20;
2061 let Inst{7-4} = op7_4;
2062}
2063
2064class T2FourReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2065 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2066 : T2FourReg<oops, iops, itin, opc, asm, pattern> {
2067 let Inst{31-27} = 0b11111;
2068 let Inst{26-24} = 0b011;
2069 let Inst{23} = long;
2070 let Inst{22-20} = op22_20;
2071 let Inst{7-4} = op7_4;
2072}
2073
Jim Grosbach8c989842011-09-20 00:26:34 +00002074// Unsigned Sum of Absolute Differences [and Accumulate].
Owen Anderson821752e2010-11-18 20:32:18 +00002075def t2USAD8 : T2ThreeReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
2076 (ins rGPR:$Rn, rGPR:$Rm),
Jim Grosbacha7603982011-07-01 21:12:19 +00002077 NoItinerary, "usad8", "\t$Rd, $Rn, $Rm", []>,
2078 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chenadc77332010-02-26 22:04:29 +00002079 let Inst{15-12} = 0b1111;
2080}
Owen Anderson821752e2010-11-18 20:32:18 +00002081def t2USADA8 : T2FourReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
Jim Grosbach7a088642010-11-19 17:11:02 +00002082 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), NoItinerary,
Jim Grosbacha7603982011-07-01 21:12:19 +00002083 "usada8", "\t$Rd, $Rn, $Rm, $Ra", []>,
2084 Requires<[IsThumb2, HasThumb2DSP]>;
Johnny Chenadc77332010-02-26 22:04:29 +00002085
Jim Grosbach8c989842011-09-20 00:26:34 +00002086// Signed/Unsigned saturate.
Owen Anderson46c478e2010-11-17 19:57:38 +00002087class T2SatI<dag oops, dag iops, InstrItinClass itin,
2088 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +00002089 : T2I<oops, iops, itin, opc, asm, pattern> {
Owen Anderson46c478e2010-11-17 19:57:38 +00002090 bits<4> Rd;
2091 bits<4> Rn;
2092 bits<5> sat_imm;
2093 bits<7> sh;
Jim Grosbach7a088642010-11-19 17:11:02 +00002094
Jim Grosbach86386922010-12-08 22:10:43 +00002095 let Inst{11-8} = Rd;
2096 let Inst{19-16} = Rn;
Jim Grosbach580f4a92011-07-25 22:20:28 +00002097 let Inst{4-0} = sat_imm;
2098 let Inst{21} = sh{5};
Owen Anderson46c478e2010-11-17 19:57:38 +00002099 let Inst{14-12} = sh{4-2};
2100 let Inst{7-6} = sh{1-0};
2101}
2102
Owen Andersonc7373f82010-11-30 20:00:01 +00002103def t2SSAT: T2SatI<
Owen Anderson0afa0092011-09-26 21:06:22 +00002104 (outs rGPR:$Rd),
2105 (ins imm1_32:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
Jim Grosbach8c989842011-09-20 00:26:34 +00002106 NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002107 let Inst{31-27} = 0b11110;
2108 let Inst{25-22} = 0b1100;
2109 let Inst{20} = 0;
2110 let Inst{15} = 0;
Owen Anderson061c3c42011-09-19 20:00:02 +00002111 let Inst{5} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00002112}
2113
Owen Andersonc7373f82010-11-30 20:00:01 +00002114def t2SSAT16: T2SatI<
Jim Grosbachf4943352011-07-25 23:09:14 +00002115 (outs rGPR:$Rd), (ins imm1_16:$sat_imm, rGPR:$Rn), NoItinerary,
Jim Grosbach8c989842011-09-20 00:26:34 +00002116 "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
Jim Grosbacha7603982011-07-01 21:12:19 +00002117 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chenadc77332010-02-26 22:04:29 +00002118 let Inst{31-27} = 0b11110;
2119 let Inst{25-22} = 0b1100;
2120 let Inst{20} = 0;
2121 let Inst{15} = 0;
2122 let Inst{21} = 1; // sh = '1'
2123 let Inst{14-12} = 0b000; // imm3 = '000'
2124 let Inst{7-6} = 0b00; // imm2 = '00'
Owen Anderson8a28bdc2011-09-16 22:17:02 +00002125 let Inst{5-4} = 0b00;
Johnny Chenadc77332010-02-26 22:04:29 +00002126}
2127
Owen Andersonc7373f82010-11-30 20:00:01 +00002128def t2USAT: T2SatI<
Owen Anderson0afa0092011-09-26 21:06:22 +00002129 (outs rGPR:$Rd),
2130 (ins imm0_31:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
Jim Grosbach8c989842011-09-20 00:26:34 +00002131 NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
Johnny Chenadc77332010-02-26 22:04:29 +00002132 let Inst{31-27} = 0b11110;
2133 let Inst{25-22} = 0b1110;
2134 let Inst{20} = 0;
2135 let Inst{15} = 0;
Johnny Chenadc77332010-02-26 22:04:29 +00002136}
2137
Jim Grosbachb105b992011-09-16 18:32:30 +00002138def t2USAT16: T2SatI<(outs rGPR:$Rd), (ins imm0_15:$sat_imm, rGPR:$Rn),
Jim Grosbachf921c0fe2011-06-13 22:54:22 +00002139 NoItinerary,
Jim Grosbach8c989842011-09-20 00:26:34 +00002140 "usat16", "\t$Rd, $sat_imm, $Rn", []>,
Jim Grosbacha7603982011-07-01 21:12:19 +00002141 Requires<[IsThumb2, HasThumb2DSP]> {
Owen Anderson4a713572011-09-23 21:57:50 +00002142 let Inst{31-22} = 0b1111001110;
Johnny Chenadc77332010-02-26 22:04:29 +00002143 let Inst{20} = 0;
2144 let Inst{15} = 0;
2145 let Inst{21} = 1; // sh = '1'
2146 let Inst{14-12} = 0b000; // imm3 = '000'
2147 let Inst{7-6} = 0b00; // imm2 = '00'
Owen Anderson4a713572011-09-23 21:57:50 +00002148 let Inst{5-4} = 0b00;
Johnny Chenadc77332010-02-26 22:04:29 +00002149}
Anton Korobeynikov52237112009-06-17 18:13:58 +00002150
Bob Wilson38aa2872010-08-13 21:48:10 +00002151def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
2152def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
Nate Begeman0e0a20e2010-07-29 22:48:09 +00002153
Evan Chengf49810c2009-06-23 17:48:47 +00002154//===----------------------------------------------------------------------===//
Evan Chenga67efd12009-06-23 19:39:13 +00002155// Shift and rotate Instructions.
2156//
2157
Jim Grosbach5f25fb02011-09-02 21:28:54 +00002158defm t2LSL : T2I_sh_ir<0b00, "lsl", imm0_31,
Jim Grosbach9249ef32012-08-02 21:59:52 +00002159 BinOpFrag<(shl node:$LHS, node:$RHS)>>;
Jim Grosbachd2990102011-09-02 18:43:25 +00002160defm t2LSR : T2I_sh_ir<0b01, "lsr", imm_sr,
Jim Grosbach9249ef32012-08-02 21:59:52 +00002161 BinOpFrag<(srl node:$LHS, node:$RHS)>>;
Jim Grosbachd2990102011-09-02 18:43:25 +00002162defm t2ASR : T2I_sh_ir<0b10, "asr", imm_sr,
Jim Grosbach9249ef32012-08-02 21:59:52 +00002163 BinOpFrag<(sra node:$LHS, node:$RHS)>>;
Jim Grosbach5f25fb02011-09-02 21:28:54 +00002164defm t2ROR : T2I_sh_ir<0b11, "ror", imm0_31,
Jim Grosbach9249ef32012-08-02 21:59:52 +00002165 BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
Evan Chenga67efd12009-06-23 19:39:13 +00002166
Andrew Trickd49ffe82011-04-29 14:18:15 +00002167// (rotr x, (and y, 0x...1f)) ==> (ROR x, y)
Bob Wilsonac03af42012-07-02 17:22:47 +00002168def : T2Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)),
2169 (t2RORrr rGPR:$lhs, rGPR:$rhs)>;
Andrew Trickd49ffe82011-04-29 14:18:15 +00002170
David Goodwinca01a8d2009-09-01 18:32:09 +00002171let Uses = [CPSR] in {
Owen Anderson46c478e2010-11-17 19:57:38 +00002172def t2RRX : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2173 "rrx", "\t$Rd, $Rm",
2174 [(set rGPR:$Rd, (ARMrrx rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002175 let Inst{31-27} = 0b11101;
2176 let Inst{26-25} = 0b01;
2177 let Inst{24-21} = 0b0010;
Johnny Chend68e1192009-12-15 17:24:14 +00002178 let Inst{19-16} = 0b1111; // Rn
2179 let Inst{14-12} = 0b000;
2180 let Inst{7-4} = 0b0011;
2181}
David Goodwinca01a8d2009-09-01 18:32:09 +00002182}
Evan Chenga67efd12009-06-23 19:39:13 +00002183
Daniel Dunbar8d66b782011-01-10 15:26:39 +00002184let isCodeGenOnly = 1, Defs = [CPSR] in {
Owen Andersonbb6315d2010-11-15 19:58:36 +00002185def t2MOVsrl_flag : T2TwoRegShiftImm<
2186 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2187 "lsrs", ".w\t$Rd, $Rm, #1",
2188 [(set rGPR:$Rd, (ARMsrl_flag rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002189 let Inst{31-27} = 0b11101;
2190 let Inst{26-25} = 0b01;
2191 let Inst{24-21} = 0b0010;
2192 let Inst{20} = 1; // The S bit.
2193 let Inst{19-16} = 0b1111; // Rn
2194 let Inst{5-4} = 0b01; // Shift type.
2195 // Shift amount = Inst{14-12:7-6} = 1.
2196 let Inst{14-12} = 0b000;
2197 let Inst{7-6} = 0b01;
2198}
Owen Andersonbb6315d2010-11-15 19:58:36 +00002199def t2MOVsra_flag : T2TwoRegShiftImm<
2200 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2201 "asrs", ".w\t$Rd, $Rm, #1",
2202 [(set rGPR:$Rd, (ARMsra_flag rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002203 let Inst{31-27} = 0b11101;
2204 let Inst{26-25} = 0b01;
2205 let Inst{24-21} = 0b0010;
2206 let Inst{20} = 1; // The S bit.
2207 let Inst{19-16} = 0b1111; // Rn
2208 let Inst{5-4} = 0b10; // Shift type.
2209 // Shift amount = Inst{14-12:7-6} = 1.
2210 let Inst{14-12} = 0b000;
2211 let Inst{7-6} = 0b01;
2212}
David Goodwin3583df72009-07-28 17:06:49 +00002213}
2214
Evan Chenga67efd12009-06-23 19:39:13 +00002215//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +00002216// Bitwise Instructions.
2217//
Anton Korobeynikov52237112009-06-17 18:13:58 +00002218
Johnny Chend68e1192009-12-15 17:24:14 +00002219defm t2AND : T2I_bin_w_irs<0b0000, "and",
Evan Cheng7e1bf302010-09-29 00:27:46 +00002220 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Jim Grosbach5c6c1282012-08-02 21:50:41 +00002221 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00002222defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
Evan Cheng7e1bf302010-09-29 00:27:46 +00002223 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Jim Grosbach5c6c1282012-08-02 21:50:41 +00002224 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
Johnny Chend68e1192009-12-15 17:24:14 +00002225defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
Evan Cheng7e1bf302010-09-29 00:27:46 +00002226 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Jim Grosbach5c6c1282012-08-02 21:50:41 +00002227 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Evan Chengf49810c2009-06-23 17:48:47 +00002228
Johnny Chend68e1192009-12-15 17:24:14 +00002229defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
Evan Cheng7e1bf302010-09-29 00:27:46 +00002230 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Jim Grosbach5c6c1282012-08-02 21:50:41 +00002231 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002232
Owen Anderson2f7aed32010-11-17 22:16:31 +00002233class T2BitFI<dag oops, dag iops, InstrItinClass itin,
2234 string opc, string asm, list<dag> pattern>
Jim Grosbach7a088642010-11-19 17:11:02 +00002235 : T2I<oops, iops, itin, opc, asm, pattern> {
Owen Anderson2f7aed32010-11-17 22:16:31 +00002236 bits<4> Rd;
2237 bits<5> msb;
2238 bits<5> lsb;
Jim Grosbach7a088642010-11-19 17:11:02 +00002239
Jim Grosbach86386922010-12-08 22:10:43 +00002240 let Inst{11-8} = Rd;
Owen Anderson2f7aed32010-11-17 22:16:31 +00002241 let Inst{4-0} = msb{4-0};
2242 let Inst{14-12} = lsb{4-2};
2243 let Inst{7-6} = lsb{1-0};
2244}
2245
2246class T2TwoRegBitFI<dag oops, dag iops, InstrItinClass itin,
2247 string opc, string asm, list<dag> pattern>
2248 : T2BitFI<oops, iops, itin, opc, asm, pattern> {
2249 bits<4> Rn;
Jim Grosbach7a088642010-11-19 17:11:02 +00002250
Jim Grosbach86386922010-12-08 22:10:43 +00002251 let Inst{19-16} = Rn;
Owen Anderson2f7aed32010-11-17 22:16:31 +00002252}
2253
2254let Constraints = "$src = $Rd" in
2255def t2BFC : T2BitFI<(outs rGPR:$Rd), (ins rGPR:$src, bf_inv_mask_imm:$imm),
2256 IIC_iUNAsi, "bfc", "\t$Rd, $imm",
2257 [(set rGPR:$Rd, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002258 let Inst{31-27} = 0b11110;
Johnny Chen3a961222011-04-15 22:52:15 +00002259 let Inst{26} = 0; // should be 0.
Johnny Chend68e1192009-12-15 17:24:14 +00002260 let Inst{25} = 1;
2261 let Inst{24-20} = 0b10110;
2262 let Inst{19-16} = 0b1111; // Rn
2263 let Inst{15} = 0;
Johnny Chen3a961222011-04-15 22:52:15 +00002264 let Inst{5} = 0; // should be 0.
Jim Grosbach7a088642010-11-19 17:11:02 +00002265
Owen Anderson2f7aed32010-11-17 22:16:31 +00002266 bits<10> imm;
2267 let msb{4-0} = imm{9-5};
2268 let lsb{4-0} = imm{4-0};
Johnny Chend68e1192009-12-15 17:24:14 +00002269}
Evan Chengf49810c2009-06-23 17:48:47 +00002270
Owen Anderson2f7aed32010-11-17 22:16:31 +00002271def t2SBFX: T2TwoRegBitFI<
Jim Grosbachfb8989e2011-07-27 21:09:25 +00002272 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
Owen Anderson2f7aed32010-11-17 22:16:31 +00002273 IIC_iUNAsi, "sbfx", "\t$Rd, $Rn, $lsb, $msb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002274 let Inst{31-27} = 0b11110;
2275 let Inst{25} = 1;
2276 let Inst{24-20} = 0b10100;
2277 let Inst{15} = 0;
2278}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00002279
Owen Anderson2f7aed32010-11-17 22:16:31 +00002280def t2UBFX: T2TwoRegBitFI<
Jim Grosbachfb8989e2011-07-27 21:09:25 +00002281 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
Owen Anderson2f7aed32010-11-17 22:16:31 +00002282 IIC_iUNAsi, "ubfx", "\t$Rd, $Rn, $lsb, $msb", []> {
Johnny Chend68e1192009-12-15 17:24:14 +00002283 let Inst{31-27} = 0b11110;
2284 let Inst{25} = 1;
2285 let Inst{24-20} = 0b11100;
2286 let Inst{15} = 0;
2287}
Sandeep Patel47eedaa2009-10-13 18:59:48 +00002288
Johnny Chen9474d552010-02-02 19:31:58 +00002289// A8.6.18 BFI - Bitfield insert (Encoding T1)
Bruno Cardoso Lopesa461d422011-01-18 20:45:56 +00002290let Constraints = "$src = $Rd" in {
2291 def t2BFI : T2TwoRegBitFI<(outs rGPR:$Rd),
2292 (ins rGPR:$src, rGPR:$Rn, bf_inv_mask_imm:$imm),
2293 IIC_iBITi, "bfi", "\t$Rd, $Rn, $imm",
2294 [(set rGPR:$Rd, (ARMbfi rGPR:$src, rGPR:$Rn,
2295 bf_inv_mask_imm:$imm))]> {
2296 let Inst{31-27} = 0b11110;
Johnny Chen188ce9c2011-04-15 00:35:08 +00002297 let Inst{26} = 0; // should be 0.
Bruno Cardoso Lopesa461d422011-01-18 20:45:56 +00002298 let Inst{25} = 1;
2299 let Inst{24-20} = 0b10110;
2300 let Inst{15} = 0;
Johnny Chen188ce9c2011-04-15 00:35:08 +00002301 let Inst{5} = 0; // should be 0.
Jim Grosbach7a088642010-11-19 17:11:02 +00002302
Bruno Cardoso Lopesa461d422011-01-18 20:45:56 +00002303 bits<10> imm;
2304 let msb{4-0} = imm{9-5};
2305 let lsb{4-0} = imm{4-0};
2306 }
Johnny Chen9474d552010-02-02 19:31:58 +00002307}
Evan Chengf49810c2009-06-23 17:48:47 +00002308
Evan Cheng7e1bf302010-09-29 00:27:46 +00002309defm t2ORN : T2I_bin_irs<0b0011, "orn",
2310 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
Jim Grosbach5c6c1282012-08-02 21:50:41 +00002311 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002312
Jim Grosbachd32872f2011-09-14 21:24:41 +00002313/// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
2314/// unary operation that produces a value. These are predicable and can be
2315/// changed to modify CPSR.
2316multiclass T2I_un_irs<bits<4> opcod, string opc,
2317 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
Evan Cheng376642e2012-12-10 23:21:26 +00002318 PatFrag opnode,
2319 bit Cheap = 0, bit ReMat = 0, bit MoveImm = 0> {
Jim Grosbachd32872f2011-09-14 21:24:41 +00002320 // shifted imm
2321 def i : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), iii,
2322 opc, "\t$Rd, $imm",
2323 [(set rGPR:$Rd, (opnode t2_so_imm:$imm))]> {
2324 let isAsCheapAsAMove = Cheap;
2325 let isReMaterializable = ReMat;
Evan Cheng376642e2012-12-10 23:21:26 +00002326 let isMoveImm = MoveImm;
Jim Grosbachd32872f2011-09-14 21:24:41 +00002327 let Inst{31-27} = 0b11110;
2328 let Inst{25} = 0;
2329 let Inst{24-21} = opcod;
2330 let Inst{19-16} = 0b1111; // Rn
2331 let Inst{15} = 0;
2332 }
2333 // register
2334 def r : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), iir,
2335 opc, ".w\t$Rd, $Rm",
2336 [(set rGPR:$Rd, (opnode rGPR:$Rm))]> {
2337 let Inst{31-27} = 0b11101;
2338 let Inst{26-25} = 0b01;
2339 let Inst{24-21} = opcod;
2340 let Inst{19-16} = 0b1111; // Rn
2341 let Inst{14-12} = 0b000; // imm3
2342 let Inst{7-6} = 0b00; // imm2
2343 let Inst{5-4} = 0b00; // type
2344 }
2345 // shifted register
2346 def s : T2sOneRegShiftedReg<(outs rGPR:$Rd), (ins t2_so_reg:$ShiftedRm), iis,
2347 opc, ".w\t$Rd, $ShiftedRm",
2348 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm))]> {
2349 let Inst{31-27} = 0b11101;
2350 let Inst{26-25} = 0b01;
2351 let Inst{24-21} = opcod;
2352 let Inst{19-16} = 0b1111; // Rn
2353 }
2354}
2355
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002356// Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
2357let AddedComplexity = 1 in
Evan Cheng5d42c562010-09-29 00:49:25 +00002358defm t2MVN : T2I_un_irs <0b0011, "mvn",
Evan Cheng3881cb72010-09-29 22:42:35 +00002359 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
Evan Cheng376642e2012-12-10 23:21:26 +00002360 UnOpFrag<(not node:$Src)>, 1, 1, 1>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002361
Jim Grosbachf084a5e2010-07-20 16:07:04 +00002362let AddedComplexity = 1 in
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002363def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
2364 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002365
Joel Jones96ef2842012-06-18 14:51:32 +00002366// top16Zero - answer true if the upper 16 bits of $src are 0, false otherwise
2367def top16Zero: PatLeaf<(i32 rGPR:$src), [{
2368 return CurDAG->MaskedValueIsZero(SDValue(N,0), APInt::getHighBitsSet(32, 16));
2369 }]>;
2370
2371// so_imm_notSext is needed instead of so_imm_not, as the value of imm
2372// will match the extended, not the original bitWidth for $src.
2373def : T2Pat<(and top16Zero:$src, t2_so_imm_notSext:$imm),
2374 (t2BICri rGPR:$src, t2_so_imm_notSext:$imm)>;
2375
2376
Evan Cheng25f7cfc2009-08-01 06:13:52 +00002377// FIXME: Disable this pattern on Darwin to workaround an assembler bug.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002378def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
2379 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
Evan Chengea253b92009-08-12 01:56:42 +00002380 Requires<[IsThumb2]>;
Evan Cheng36a0aeb2009-07-06 22:23:46 +00002381
2382def : T2Pat<(t2_so_imm_not:$src),
2383 (t2MVNi t2_so_imm_not:$src)>;
2384
Evan Chengf49810c2009-06-23 17:48:47 +00002385//===----------------------------------------------------------------------===//
2386// Multiply Instructions.
2387//
Evan Cheng8de898a2009-06-26 00:19:44 +00002388let isCommutable = 1 in
Owen Anderson35141a92010-11-18 01:08:42 +00002389def t2MUL: T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2390 "mul", "\t$Rd, $Rn, $Rm",
2391 [(set rGPR:$Rd, (mul rGPR:$Rn, rGPR:$Rm))]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002392 let Inst{31-27} = 0b11111;
2393 let Inst{26-23} = 0b0110;
2394 let Inst{22-20} = 0b000;
2395 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2396 let Inst{7-4} = 0b0000; // Multiply
2397}
Evan Chengf49810c2009-06-23 17:48:47 +00002398
Owen Anderson35141a92010-11-18 01:08:42 +00002399def t2MLA: T2FourReg<
2400 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2401 "mla", "\t$Rd, $Rn, $Rm, $Ra",
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002402 [(set rGPR:$Rd, (add (mul rGPR:$Rn, rGPR:$Rm), rGPR:$Ra))]>,
2403 Requires<[IsThumb2, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002404 let Inst{31-27} = 0b11111;
2405 let Inst{26-23} = 0b0110;
2406 let Inst{22-20} = 0b000;
Johnny Chend68e1192009-12-15 17:24:14 +00002407 let Inst{7-4} = 0b0000; // Multiply
2408}
Evan Chengf49810c2009-06-23 17:48:47 +00002409
Owen Anderson35141a92010-11-18 01:08:42 +00002410def t2MLS: T2FourReg<
2411 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2412 "mls", "\t$Rd, $Rn, $Rm, $Ra",
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002413 [(set rGPR:$Rd, (sub rGPR:$Ra, (mul rGPR:$Rn, rGPR:$Rm)))]>,
2414 Requires<[IsThumb2, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002415 let Inst{31-27} = 0b11111;
2416 let Inst{26-23} = 0b0110;
2417 let Inst{22-20} = 0b000;
Johnny Chend68e1192009-12-15 17:24:14 +00002418 let Inst{7-4} = 0b0001; // Multiply and Subtract
2419}
Evan Chengf49810c2009-06-23 17:48:47 +00002420
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002421// Extra precision multiplies with low / high results
2422let neverHasSideEffects = 1 in {
2423let isCommutable = 1 in {
Jim Grosbach7c6d85a2010-12-08 22:38:41 +00002424def t2SMULL : T2MulLong<0b000, 0b0000,
Owen Anderson796c3652011-08-22 23:16:48 +00002425 (outs rGPR:$RdLo, rGPR:$RdHi),
Owen Anderson35141a92010-11-18 01:08:42 +00002426 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
Owen Anderson796c3652011-08-22 23:16:48 +00002427 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002428
Jim Grosbach7c6d85a2010-12-08 22:38:41 +00002429def t2UMULL : T2MulLong<0b010, 0b0000,
Jim Grosbach52082042010-12-08 22:29:28 +00002430 (outs rGPR:$RdLo, rGPR:$RdHi),
Owen Anderson35141a92010-11-18 01:08:42 +00002431 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
Jim Grosbach7c6d85a2010-12-08 22:38:41 +00002432 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
Johnny Chend68e1192009-12-15 17:24:14 +00002433} // isCommutable
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002434
2435// Multiply + accumulate
Arnold Schwaighofer67514e92012-09-04 14:37:49 +00002436def t2SMLAL : T2MlaLong<0b100, 0b0000,
Arnold Schwaighofera7016d62012-08-12 05:11:56 +00002437 (outs rGPR:$RdLo, rGPR:$RdHi),
Arnold Schwaighofer67514e92012-09-04 14:37:49 +00002438 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), IIC_iMAC64,
2439 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2440 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002441
Arnold Schwaighofer67514e92012-09-04 14:37:49 +00002442def t2UMLAL : T2MlaLong<0b110, 0b0000,
Arnold Schwaighofera7016d62012-08-12 05:11:56 +00002443 (outs rGPR:$RdLo, rGPR:$RdHi),
Arnold Schwaighofer67514e92012-09-04 14:37:49 +00002444 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), IIC_iMAC64,
2445 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2446 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002447
Jim Grosbach7c6d85a2010-12-08 22:38:41 +00002448def t2UMAAL : T2MulLong<0b110, 0b0110,
2449 (outs rGPR:$RdLo, rGPR:$RdHi),
Owen Anderson35141a92010-11-18 01:08:42 +00002450 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
Jim Grosbacha7603982011-07-01 21:12:19 +00002451 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2452 Requires<[IsThumb2, HasThumb2DSP]>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002453} // neverHasSideEffects
2454
Johnny Chen93042d12010-03-02 18:14:57 +00002455// Rounding variants of the below included for disassembly only
2456
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002457// Most significant word multiply
Owen Anderson821752e2010-11-18 20:32:18 +00002458def t2SMMUL : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2459 "smmul", "\t$Rd, $Rn, $Rm",
Jim Grosbacha7603982011-07-01 21:12:19 +00002460 [(set rGPR:$Rd, (mulhs rGPR:$Rn, rGPR:$Rm))]>,
2461 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002462 let Inst{31-27} = 0b11111;
2463 let Inst{26-23} = 0b0110;
2464 let Inst{22-20} = 0b101;
2465 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2466 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2467}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002468
Owen Anderson821752e2010-11-18 20:32:18 +00002469def t2SMMULR : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
Jim Grosbacha7603982011-07-01 21:12:19 +00002470 "smmulr", "\t$Rd, $Rn, $Rm", []>,
2471 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chen93042d12010-03-02 18:14:57 +00002472 let Inst{31-27} = 0b11111;
2473 let Inst{26-23} = 0b0110;
2474 let Inst{22-20} = 0b101;
2475 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2476 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2477}
2478
Owen Anderson821752e2010-11-18 20:32:18 +00002479def t2SMMLA : T2FourReg<
2480 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2481 "smmla", "\t$Rd, $Rn, $Rm, $Ra",
Jim Grosbacha7603982011-07-01 21:12:19 +00002482 [(set rGPR:$Rd, (add (mulhs rGPR:$Rm, rGPR:$Rn), rGPR:$Ra))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002483 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002484 let Inst{31-27} = 0b11111;
2485 let Inst{26-23} = 0b0110;
2486 let Inst{22-20} = 0b101;
Johnny Chend68e1192009-12-15 17:24:14 +00002487 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2488}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002489
Owen Anderson821752e2010-11-18 20:32:18 +00002490def t2SMMLAR: T2FourReg<
2491 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
Jim Grosbacha7603982011-07-01 21:12:19 +00002492 "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
2493 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chen93042d12010-03-02 18:14:57 +00002494 let Inst{31-27} = 0b11111;
2495 let Inst{26-23} = 0b0110;
2496 let Inst{22-20} = 0b101;
Johnny Chen93042d12010-03-02 18:14:57 +00002497 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2498}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002499
Owen Anderson821752e2010-11-18 20:32:18 +00002500def t2SMMLS: T2FourReg<
2501 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2502 "smmls", "\t$Rd, $Rn, $Rm, $Ra",
Jim Grosbacha7603982011-07-01 21:12:19 +00002503 [(set rGPR:$Rd, (sub rGPR:$Ra, (mulhs rGPR:$Rn, rGPR:$Rm)))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002504 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002505 let Inst{31-27} = 0b11111;
2506 let Inst{26-23} = 0b0110;
2507 let Inst{22-20} = 0b110;
Johnny Chend68e1192009-12-15 17:24:14 +00002508 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2509}
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002510
Owen Anderson821752e2010-11-18 20:32:18 +00002511def t2SMMLSR:T2FourReg<
2512 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
Jim Grosbacha7603982011-07-01 21:12:19 +00002513 "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
2514 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chen93042d12010-03-02 18:14:57 +00002515 let Inst{31-27} = 0b11111;
2516 let Inst{26-23} = 0b0110;
2517 let Inst{22-20} = 0b110;
Johnny Chen93042d12010-03-02 18:14:57 +00002518 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2519}
2520
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002521multiclass T2I_smul<string opc, PatFrag opnode> {
Owen Anderson821752e2010-11-18 20:32:18 +00002522 def BB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2523 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
2524 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
Jim Grosbacha7603982011-07-01 21:12:19 +00002525 (sext_inreg rGPR:$Rm, i16)))]>,
2526 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002527 let Inst{31-27} = 0b11111;
2528 let Inst{26-23} = 0b0110;
2529 let Inst{22-20} = 0b001;
2530 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2531 let Inst{7-6} = 0b00;
2532 let Inst{5-4} = 0b00;
2533 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002534
Owen Anderson821752e2010-11-18 20:32:18 +00002535 def BT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2536 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
2537 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
Jim Grosbacha7603982011-07-01 21:12:19 +00002538 (sra rGPR:$Rm, (i32 16))))]>,
2539 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002540 let Inst{31-27} = 0b11111;
2541 let Inst{26-23} = 0b0110;
2542 let Inst{22-20} = 0b001;
2543 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2544 let Inst{7-6} = 0b00;
2545 let Inst{5-4} = 0b01;
2546 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002547
Owen Anderson821752e2010-11-18 20:32:18 +00002548 def TB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2549 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
2550 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
Jim Grosbacha7603982011-07-01 21:12:19 +00002551 (sext_inreg rGPR:$Rm, i16)))]>,
2552 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002553 let Inst{31-27} = 0b11111;
2554 let Inst{26-23} = 0b0110;
2555 let Inst{22-20} = 0b001;
2556 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2557 let Inst{7-6} = 0b00;
2558 let Inst{5-4} = 0b10;
2559 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002560
Owen Anderson821752e2010-11-18 20:32:18 +00002561 def TT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2562 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
2563 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
Jim Grosbacha7603982011-07-01 21:12:19 +00002564 (sra rGPR:$Rm, (i32 16))))]>,
2565 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002566 let Inst{31-27} = 0b11111;
2567 let Inst{26-23} = 0b0110;
2568 let Inst{22-20} = 0b001;
2569 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2570 let Inst{7-6} = 0b00;
2571 let Inst{5-4} = 0b11;
2572 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002573
Owen Anderson821752e2010-11-18 20:32:18 +00002574 def WB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2575 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
2576 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
Jim Grosbacha7603982011-07-01 21:12:19 +00002577 (sext_inreg rGPR:$Rm, i16)), (i32 16)))]>,
2578 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002579 let Inst{31-27} = 0b11111;
2580 let Inst{26-23} = 0b0110;
2581 let Inst{22-20} = 0b011;
2582 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2583 let Inst{7-6} = 0b00;
2584 let Inst{5-4} = 0b00;
2585 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002586
Owen Anderson821752e2010-11-18 20:32:18 +00002587 def WT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2588 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
2589 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
Jim Grosbacha7603982011-07-01 21:12:19 +00002590 (sra rGPR:$Rm, (i32 16))), (i32 16)))]>,
2591 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002592 let Inst{31-27} = 0b11111;
2593 let Inst{26-23} = 0b0110;
2594 let Inst{22-20} = 0b011;
2595 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2596 let Inst{7-6} = 0b00;
2597 let Inst{5-4} = 0b01;
2598 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002599}
2600
2601
2602multiclass T2I_smla<string opc, PatFrag opnode> {
Owen Anderson821752e2010-11-18 20:32:18 +00002603 def BB : T2FourReg<
2604 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2605 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
2606 [(set rGPR:$Rd, (add rGPR:$Ra,
2607 (opnode (sext_inreg rGPR:$Rn, i16),
Jim Grosbacha7603982011-07-01 21:12:19 +00002608 (sext_inreg rGPR:$Rm, i16))))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002609 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002610 let Inst{31-27} = 0b11111;
2611 let Inst{26-23} = 0b0110;
2612 let Inst{22-20} = 0b001;
Johnny Chend68e1192009-12-15 17:24:14 +00002613 let Inst{7-6} = 0b00;
2614 let Inst{5-4} = 0b00;
2615 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002616
Owen Anderson821752e2010-11-18 20:32:18 +00002617 def BT : T2FourReg<
2618 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2619 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
2620 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sext_inreg rGPR:$Rn, i16),
Jim Grosbacha7603982011-07-01 21:12:19 +00002621 (sra rGPR:$Rm, (i32 16)))))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002622 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002623 let Inst{31-27} = 0b11111;
2624 let Inst{26-23} = 0b0110;
2625 let Inst{22-20} = 0b001;
Johnny Chend68e1192009-12-15 17:24:14 +00002626 let Inst{7-6} = 0b00;
2627 let Inst{5-4} = 0b01;
2628 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002629
Owen Anderson821752e2010-11-18 20:32:18 +00002630 def TB : T2FourReg<
2631 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2632 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
2633 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
Jim Grosbacha7603982011-07-01 21:12:19 +00002634 (sext_inreg rGPR:$Rm, i16))))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002635 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002636 let Inst{31-27} = 0b11111;
2637 let Inst{26-23} = 0b0110;
2638 let Inst{22-20} = 0b001;
Johnny Chend68e1192009-12-15 17:24:14 +00002639 let Inst{7-6} = 0b00;
2640 let Inst{5-4} = 0b10;
2641 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002642
Owen Anderson821752e2010-11-18 20:32:18 +00002643 def TT : T2FourReg<
2644 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2645 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
2646 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
Jim Grosbacha7603982011-07-01 21:12:19 +00002647 (sra rGPR:$Rm, (i32 16)))))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002648 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002649 let Inst{31-27} = 0b11111;
2650 let Inst{26-23} = 0b0110;
2651 let Inst{22-20} = 0b001;
Johnny Chend68e1192009-12-15 17:24:14 +00002652 let Inst{7-6} = 0b00;
2653 let Inst{5-4} = 0b11;
2654 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002655
Owen Anderson821752e2010-11-18 20:32:18 +00002656 def WB : T2FourReg<
2657 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2658 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
2659 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
Jim Grosbacha7603982011-07-01 21:12:19 +00002660 (sext_inreg rGPR:$Rm, i16)), (i32 16))))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002661 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002662 let Inst{31-27} = 0b11111;
2663 let Inst{26-23} = 0b0110;
2664 let Inst{22-20} = 0b011;
Johnny Chend68e1192009-12-15 17:24:14 +00002665 let Inst{7-6} = 0b00;
2666 let Inst{5-4} = 0b00;
2667 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002668
Owen Anderson821752e2010-11-18 20:32:18 +00002669 def WT : T2FourReg<
2670 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2671 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
2672 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
Jim Grosbacha7603982011-07-01 21:12:19 +00002673 (sra rGPR:$Rm, (i32 16))), (i32 16))))]>,
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002674 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002675 let Inst{31-27} = 0b11111;
2676 let Inst{26-23} = 0b0110;
2677 let Inst{22-20} = 0b011;
Johnny Chend68e1192009-12-15 17:24:14 +00002678 let Inst{7-6} = 0b00;
2679 let Inst{5-4} = 0b01;
2680 }
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002681}
2682
2683defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2684defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2685
Jim Grosbacheeca7582011-09-15 23:45:50 +00002686// Halfword multiple accumulate long: SMLAL<x><y>
Owen Anderson821752e2010-11-18 20:32:18 +00002687def t2SMLALBB : T2FourReg_mac<1, 0b100, 0b1000, (outs rGPR:$Ra,rGPR:$Rd),
2688 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbb", "\t$Ra, $Rd, $Rn, $Rm",
Jim Grosbacha7603982011-07-01 21:12:19 +00002689 [/* For disassembly only; pattern left blank */]>,
2690 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002691def t2SMLALBT : T2FourReg_mac<1, 0b100, 0b1001, (outs rGPR:$Ra,rGPR:$Rd),
2692 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbt", "\t$Ra, $Rd, $Rn, $Rm",
Jim Grosbacha7603982011-07-01 21:12:19 +00002693 [/* For disassembly only; pattern left blank */]>,
2694 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002695def t2SMLALTB : T2FourReg_mac<1, 0b100, 0b1010, (outs rGPR:$Ra,rGPR:$Rd),
2696 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltb", "\t$Ra, $Rd, $Rn, $Rm",
Jim Grosbacha7603982011-07-01 21:12:19 +00002697 [/* For disassembly only; pattern left blank */]>,
2698 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002699def t2SMLALTT : T2FourReg_mac<1, 0b100, 0b1011, (outs rGPR:$Ra,rGPR:$Rd),
2700 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltt", "\t$Ra, $Rd, $Rn, $Rm",
Jim Grosbacha7603982011-07-01 21:12:19 +00002701 [/* For disassembly only; pattern left blank */]>,
2702 Requires<[IsThumb2, HasThumb2DSP]>;
Evan Cheng5b9fcd12009-07-07 01:17:28 +00002703
Johnny Chenadc77332010-02-26 22:04:29 +00002704// Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
Owen Anderson821752e2010-11-18 20:32:18 +00002705def t2SMUAD: T2ThreeReg_mac<
2706 0, 0b010, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
Jim Grosbacha7603982011-07-01 21:12:19 +00002707 IIC_iMAC32, "smuad", "\t$Rd, $Rn, $Rm", []>,
2708 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chenadc77332010-02-26 22:04:29 +00002709 let Inst{15-12} = 0b1111;
2710}
Owen Anderson821752e2010-11-18 20:32:18 +00002711def t2SMUADX:T2ThreeReg_mac<
2712 0, 0b010, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
Jim Grosbacha7603982011-07-01 21:12:19 +00002713 IIC_iMAC32, "smuadx", "\t$Rd, $Rn, $Rm", []>,
2714 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chenadc77332010-02-26 22:04:29 +00002715 let Inst{15-12} = 0b1111;
2716}
Owen Anderson821752e2010-11-18 20:32:18 +00002717def t2SMUSD: T2ThreeReg_mac<
2718 0, 0b100, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
Jim Grosbacha7603982011-07-01 21:12:19 +00002719 IIC_iMAC32, "smusd", "\t$Rd, $Rn, $Rm", []>,
2720 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chenadc77332010-02-26 22:04:29 +00002721 let Inst{15-12} = 0b1111;
2722}
Owen Anderson821752e2010-11-18 20:32:18 +00002723def t2SMUSDX:T2ThreeReg_mac<
2724 0, 0b100, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
Jim Grosbacha7603982011-07-01 21:12:19 +00002725 IIC_iMAC32, "smusdx", "\t$Rd, $Rn, $Rm", []>,
2726 Requires<[IsThumb2, HasThumb2DSP]> {
Johnny Chenadc77332010-02-26 22:04:29 +00002727 let Inst{15-12} = 0b1111;
2728}
Owen Andersonc6788c82011-08-22 23:31:45 +00002729def t2SMLAD : T2FourReg_mac<
Owen Anderson821752e2010-11-18 20:32:18 +00002730 0, 0b010, 0b0000, (outs rGPR:$Rd),
2731 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlad",
Jim Grosbacha7603982011-07-01 21:12:19 +00002732 "\t$Rd, $Rn, $Rm, $Ra", []>,
2733 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002734def t2SMLADX : T2FourReg_mac<
2735 0, 0b010, 0b0001, (outs rGPR:$Rd),
2736 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smladx",
Jim Grosbacha7603982011-07-01 21:12:19 +00002737 "\t$Rd, $Rn, $Rm, $Ra", []>,
2738 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002739def t2SMLSD : T2FourReg_mac<0, 0b100, 0b0000, (outs rGPR:$Rd),
2740 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsd",
Jim Grosbacha7603982011-07-01 21:12:19 +00002741 "\t$Rd, $Rn, $Rm, $Ra", []>,
2742 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002743def t2SMLSDX : T2FourReg_mac<0, 0b100, 0b0001, (outs rGPR:$Rd),
2744 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsdx",
Jim Grosbacha7603982011-07-01 21:12:19 +00002745 "\t$Rd, $Rn, $Rm, $Ra", []>,
2746 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002747def t2SMLALD : T2FourReg_mac<1, 0b100, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
Jim Grosbach231948f2011-09-16 16:58:03 +00002748 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64, "smlald",
2749 "\t$Ra, $Rd, $Rn, $Rm", []>,
Jim Grosbacha7603982011-07-01 21:12:19 +00002750 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002751def t2SMLALDX : T2FourReg_mac<1, 0b100, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
Jim Grosbach231948f2011-09-16 16:58:03 +00002752 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaldx",
2753 "\t$Ra, $Rd, $Rn, $Rm", []>,
Jim Grosbacha7603982011-07-01 21:12:19 +00002754 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002755def t2SMLSLD : T2FourReg_mac<1, 0b101, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
Jim Grosbach7ff24722011-09-16 17:10:44 +00002756 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlsld",
2757 "\t$Ra, $Rd, $Rn, $Rm", []>,
Jim Grosbacha7603982011-07-01 21:12:19 +00002758 Requires<[IsThumb2, HasThumb2DSP]>;
Owen Anderson821752e2010-11-18 20:32:18 +00002759def t2SMLSLDX : T2FourReg_mac<1, 0b101, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
2760 (ins rGPR:$Rm,rGPR:$Rn), IIC_iMAC64, "smlsldx",
Jim Grosbach7ff24722011-09-16 17:10:44 +00002761 "\t$Ra, $Rd, $Rn, $Rm", []>,
Jim Grosbacha7603982011-07-01 21:12:19 +00002762 Requires<[IsThumb2, HasThumb2DSP]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002763
2764//===----------------------------------------------------------------------===//
Evan Cheng734f63b2011-06-21 19:00:54 +00002765// Division Instructions.
2766// Signed and unsigned division on v7-M
2767//
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002768def t2SDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV,
Evan Cheng734f63b2011-06-21 19:00:54 +00002769 "sdiv", "\t$Rd, $Rn, $Rm",
2770 [(set rGPR:$Rd, (sdiv rGPR:$Rn, rGPR:$Rm))]>,
2771 Requires<[HasDivide, IsThumb2]> {
2772 let Inst{31-27} = 0b11111;
2773 let Inst{26-21} = 0b011100;
2774 let Inst{20} = 0b1;
2775 let Inst{15-12} = 0b1111;
2776 let Inst{7-4} = 0b1111;
2777}
2778
Bob Wilsoneb1641d2012-09-29 21:43:49 +00002779def t2UDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV,
Evan Cheng734f63b2011-06-21 19:00:54 +00002780 "udiv", "\t$Rd, $Rn, $Rm",
2781 [(set rGPR:$Rd, (udiv rGPR:$Rn, rGPR:$Rm))]>,
2782 Requires<[HasDivide, IsThumb2]> {
2783 let Inst{31-27} = 0b11111;
2784 let Inst{26-21} = 0b011101;
2785 let Inst{20} = 0b1;
2786 let Inst{15-12} = 0b1111;
2787 let Inst{7-4} = 0b1111;
2788}
2789
2790//===----------------------------------------------------------------------===//
Evan Chengf49810c2009-06-23 17:48:47 +00002791// Misc. Arithmetic Instructions.
2792//
2793
Jim Grosbach80dc1162010-02-16 21:23:02 +00002794class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2795 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson612fb5b2010-11-18 21:15:19 +00002796 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
Johnny Chend68e1192009-12-15 17:24:14 +00002797 let Inst{31-27} = 0b11111;
2798 let Inst{26-22} = 0b01010;
2799 let Inst{21-20} = op1;
2800 let Inst{15-12} = 0b1111;
2801 let Inst{7-6} = 0b10;
2802 let Inst{5-4} = op2;
Jim Grosbach86386922010-12-08 22:10:43 +00002803 let Rn{3-0} = Rm;
Johnny Chend68e1192009-12-15 17:24:14 +00002804}
Evan Chengf49810c2009-06-23 17:48:47 +00002805
Owen Anderson612fb5b2010-11-18 21:15:19 +00002806def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2807 "clz", "\t$Rd, $Rm", [(set rGPR:$Rd, (ctlz rGPR:$Rm))]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002808
Owen Anderson612fb5b2010-11-18 21:15:19 +00002809def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2810 "rbit", "\t$Rd, $Rm",
2811 [(set rGPR:$Rd, (ARMrbit rGPR:$Rm))]>;
Jim Grosbach3482c802010-01-18 19:58:49 +00002812
Owen Anderson612fb5b2010-11-18 21:15:19 +00002813def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2814 "rev", ".w\t$Rd, $Rm", [(set rGPR:$Rd, (bswap rGPR:$Rm))]>;
Johnny Chend68e1192009-12-15 17:24:14 +00002815
Owen Anderson612fb5b2010-11-18 21:15:19 +00002816def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2817 "rev16", ".w\t$Rd, $Rm",
Evan Cheng9568e5c2011-06-21 06:01:08 +00002818 [(set rGPR:$Rd, (rotr (bswap rGPR:$Rm), (i32 16)))]>;
Evan Cheng6d6c55b2011-06-17 20:47:21 +00002819
Owen Anderson612fb5b2010-11-18 21:15:19 +00002820def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2821 "revsh", ".w\t$Rd, $Rm",
Evan Cheng9568e5c2011-06-21 06:01:08 +00002822 [(set rGPR:$Rd, (sra (bswap rGPR:$Rm), (i32 16)))]>;
Evan Cheng3f30af32011-03-18 21:52:42 +00002823
Evan Chengf60ceac2011-06-15 17:17:48 +00002824def : T2Pat<(or (sra (shl rGPR:$Rm, (i32 24)), (i32 16)),
Evan Cheng9568e5c2011-06-21 06:01:08 +00002825 (and (srl rGPR:$Rm, (i32 8)), 0xFF)),
Evan Chengf60ceac2011-06-15 17:17:48 +00002826 (t2REVSH rGPR:$Rm)>;
2827
Owen Anderson612fb5b2010-11-18 21:15:19 +00002828def t2PKHBT : T2ThreeReg<
Jim Grosbach0b692472011-09-14 23:16:41 +00002829 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_lsl_amt:$sh),
2830 IIC_iBITsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
Owen Anderson612fb5b2010-11-18 21:15:19 +00002831 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF),
Jim Grosbach1769a3d2011-07-20 20:49:03 +00002832 (and (shl rGPR:$Rm, pkh_lsl_amt:$sh),
Jim Grosbachb1dc3932010-05-05 20:44:35 +00002833 0xFFFF0000)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002834 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002835 let Inst{31-27} = 0b11101;
2836 let Inst{26-25} = 0b01;
2837 let Inst{24-20} = 0b01100;
2838 let Inst{5} = 0; // BT form
2839 let Inst{4} = 0;
Jim Grosbach7a088642010-11-19 17:11:02 +00002840
Jim Grosbacha0472dc2011-07-20 20:32:09 +00002841 bits<5> sh;
2842 let Inst{14-12} = sh{4-2};
2843 let Inst{7-6} = sh{1-0};
Johnny Chend68e1192009-12-15 17:24:14 +00002844}
Evan Cheng40289b02009-07-07 05:35:52 +00002845
2846// Alternate cases for PKHBT where identities eliminate some nodes.
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002847def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2848 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002849 Requires<[HasT2ExtractPack, IsThumb2]>;
Bob Wilsonf955f292010-08-17 17:23:19 +00002850def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
Jim Grosbacha0472dc2011-07-20 20:32:09 +00002851 (t2PKHBT rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002852 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Cheng40289b02009-07-07 05:35:52 +00002853
Bob Wilsondc66eda2010-08-16 22:26:55 +00002854// Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2855// will match the pattern below.
Owen Anderson612fb5b2010-11-18 21:15:19 +00002856def t2PKHTB : T2ThreeReg<
Jim Grosbach0b692472011-09-14 23:16:41 +00002857 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_asr_amt:$sh),
2858 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
Owen Anderson612fb5b2010-11-18 21:15:19 +00002859 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF0000),
Jim Grosbach1769a3d2011-07-20 20:49:03 +00002860 (and (sra rGPR:$Rm, pkh_asr_amt:$sh),
Bob Wilsonf955f292010-08-17 17:23:19 +00002861 0xFFFF)))]>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002862 Requires<[HasT2ExtractPack, IsThumb2]> {
Johnny Chend68e1192009-12-15 17:24:14 +00002863 let Inst{31-27} = 0b11101;
2864 let Inst{26-25} = 0b01;
2865 let Inst{24-20} = 0b01100;
2866 let Inst{5} = 1; // TB form
2867 let Inst{4} = 0;
Jim Grosbach7a088642010-11-19 17:11:02 +00002868
Jim Grosbacha0472dc2011-07-20 20:32:09 +00002869 bits<5> sh;
2870 let Inst{14-12} = sh{4-2};
2871 let Inst{7-6} = sh{1-0};
Johnny Chend68e1192009-12-15 17:24:14 +00002872}
Evan Cheng40289b02009-07-07 05:35:52 +00002873
2874// Alternate cases for PKHTB where identities eliminate some nodes. Note that
2875// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilsondc66eda2010-08-16 22:26:55 +00002876def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
Jim Grosbacha0472dc2011-07-20 20:32:09 +00002877 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002878 Requires<[HasT2ExtractPack, IsThumb2]>;
Jim Grosbach6ccfc502010-07-30 02:41:01 +00002879def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
Bob Wilsonf955f292010-08-17 17:23:19 +00002880 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
Jim Grosbacha0472dc2011-07-20 20:32:09 +00002881 (t2PKHTB rGPR:$src1, rGPR:$src2, imm1_15:$sh)>,
Jim Grosbach9729d2e2010-11-01 15:59:52 +00002882 Requires<[HasT2ExtractPack, IsThumb2]>;
Evan Chengf49810c2009-06-23 17:48:47 +00002883
2884//===----------------------------------------------------------------------===//
2885// Comparison Instructions...
2886//
Johnny Chend68e1192009-12-15 17:24:14 +00002887defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
Evan Cheng5d42c562010-09-29 00:49:25 +00002888 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
Jim Grosbach9249ef32012-08-02 21:59:52 +00002889 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
Jim Grosbach97a884d2010-12-07 20:41:06 +00002890
Jim Grosbachef88a922011-09-06 21:44:58 +00002891def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_imm:$imm),
2892 (t2CMPri GPRnopc:$lhs, t2_so_imm:$imm)>;
2893def : T2Pat<(ARMcmpZ GPRnopc:$lhs, rGPR:$rhs),
2894 (t2CMPrr GPRnopc:$lhs, rGPR:$rhs)>;
2895def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_reg:$rhs),
2896 (t2CMPrs GPRnopc:$lhs, t2_so_reg:$rhs)>;
Evan Chengf49810c2009-06-23 17:48:47 +00002897
Bill Wendlingad5c8802012-06-11 08:07:26 +00002898let isCompare = 1, Defs = [CPSR] in {
2899 // shifted imm
2900 def t2CMNri : T2OneRegCmpImm<
2901 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iCMPi,
2902 "cmn", ".w\t$Rn, $imm",
2903 [(ARMcmn GPRnopc:$Rn, (ineg t2_so_imm:$imm))]> {
2904 let Inst{31-27} = 0b11110;
2905 let Inst{25} = 0;
2906 let Inst{24-21} = 0b1000;
2907 let Inst{20} = 1; // The S bit.
2908 let Inst{15} = 0;
2909 let Inst{11-8} = 0b1111; // Rd
2910 }
2911 // register
2912 def t2CMNzrr : T2TwoRegCmp<
2913 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), IIC_iCMPr,
2914 "cmn", ".w\t$Rn, $Rm",
2915 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
2916 GPRnopc:$Rn, rGPR:$Rm)]> {
2917 let Inst{31-27} = 0b11101;
2918 let Inst{26-25} = 0b01;
2919 let Inst{24-21} = 0b1000;
2920 let Inst{20} = 1; // The S bit.
2921 let Inst{14-12} = 0b000; // imm3
2922 let Inst{11-8} = 0b1111; // Rd
2923 let Inst{7-6} = 0b00; // imm2
2924 let Inst{5-4} = 0b00; // type
2925 }
2926 // shifted register
2927 def t2CMNzrs : T2OneRegCmpShiftedReg<
2928 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), IIC_iCMPsi,
2929 "cmn", ".w\t$Rn, $ShiftedRm",
2930 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
2931 GPRnopc:$Rn, t2_so_reg:$ShiftedRm)]> {
2932 let Inst{31-27} = 0b11101;
2933 let Inst{26-25} = 0b01;
2934 let Inst{24-21} = 0b1000;
2935 let Inst{20} = 1; // The S bit.
2936 let Inst{11-8} = 0b1111; // Rd
2937 }
2938}
Dan Gohman4b7dff92010-08-26 15:50:25 +00002939
Bill Wendlingad5c8802012-06-11 08:07:26 +00002940// Assembler aliases w/o the ".w" suffix.
2941// No alias here for 'rr' version as not all instantiations of this multiclass
2942// want one (CMP in particular, does not).
Jim Grosbach9249ef32012-08-02 21:59:52 +00002943def : t2InstAlias<"cmn${p} $Rn, $imm",
2944 (t2CMNri GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
2945def : t2InstAlias<"cmn${p} $Rn, $shift",
2946 (t2CMNzrs GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
Dan Gohman4b7dff92010-08-26 15:50:25 +00002947
Bill Wendlingad5c8802012-06-11 08:07:26 +00002948def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2949 (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
2950
2951def : T2Pat<(ARMcmpZ GPRnopc:$src, t2_so_imm_neg:$imm),
2952 (t2CMNri GPRnopc:$src, t2_so_imm_neg:$imm)>;
Evan Chengf49810c2009-06-23 17:48:47 +00002953
Johnny Chend68e1192009-12-15 17:24:14 +00002954defm t2TST : T2I_cmp_irs<0b0000, "tst",
Evan Cheng5d42c562010-09-29 00:49:25 +00002955 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Jim Grosbach9249ef32012-08-02 21:59:52 +00002956 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>>;
Johnny Chend68e1192009-12-15 17:24:14 +00002957defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
Evan Cheng5d42c562010-09-29 00:49:25 +00002958 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
Jim Grosbach9249ef32012-08-02 21:59:52 +00002959 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>>;
Evan Chengf49810c2009-06-23 17:48:47 +00002960
Evan Chenge253c952009-07-07 20:39:03 +00002961// Conditional moves
2962// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach64171712010-02-16 21:07:46 +00002963// a two-value operand where a dag node expects two operands. :(
Evan Cheng63f35442010-11-13 02:25:14 +00002964let neverHasSideEffects = 1 in {
Jakob Stoklund Olesenc5041ca2012-04-04 18:23:42 +00002965
Jakob Stoklund Olesen053b5b02012-08-16 23:14:20 +00002966let isCommutable = 1, isSelect = 1 in
Jim Grosbachefeedce2011-07-01 17:14:11 +00002967def t2MOVCCr : t2PseudoInst<(outs rGPR:$Rd),
2968 (ins rGPR:$false, rGPR:$Rm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00002969 4, IIC_iCMOVr,
Owen Anderson8ee97792010-11-18 21:46:31 +00002970 [/*(set rGPR:$Rd, (ARMcmov rGPR:$false, rGPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
Jim Grosbachefeedce2011-07-01 17:14:11 +00002971 RegConstraint<"$false = $Rd">;
2972
2973let isMoveImm = 1 in
2974def t2MOVCCi : t2PseudoInst<(outs rGPR:$Rd),
2975 (ins rGPR:$false, t2_so_imm:$imm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00002976 4, IIC_iCMOVi,
Jim Grosbachefeedce2011-07-01 17:14:11 +00002977[/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
2978 RegConstraint<"$false = $Rd">;
Evan Chenge253c952009-07-07 20:39:03 +00002979
Jim Grosbach6b8f1e32011-06-27 23:54:06 +00002980// FIXME: Pseudo-ize these. For now, just mark codegen only.
2981let isCodeGenOnly = 1 in {
Evan Chengc4af4632010-11-17 20:13:28 +00002982let isMoveImm = 1 in
Jim Grosbachffa32252011-07-19 19:13:28 +00002983def t2MOVCCi16 : T2I<(outs rGPR:$Rd), (ins rGPR:$false, imm0_65535_expr:$imm),
Evan Cheng875a6ac2010-11-12 22:42:47 +00002984 IIC_iCMOVi,
Owen Andersonc56dcbf2010-11-16 00:29:56 +00002985 "movw", "\t$Rd, $imm", []>,
2986 RegConstraint<"$false = $Rd"> {
Jim Grosbacha4257162010-10-07 00:53:56 +00002987 let Inst{31-27} = 0b11110;
2988 let Inst{25} = 1;
2989 let Inst{24-21} = 0b0010;
2990 let Inst{20} = 0; // The S bit.
2991 let Inst{15} = 0;
Jim Grosbach7a088642010-11-19 17:11:02 +00002992
Owen Andersonc56dcbf2010-11-16 00:29:56 +00002993 bits<4> Rd;
2994 bits<16> imm;
Jim Grosbach7a088642010-11-19 17:11:02 +00002995
Jim Grosbach86386922010-12-08 22:10:43 +00002996 let Inst{11-8} = Rd;
Owen Andersonc56dcbf2010-11-16 00:29:56 +00002997 let Inst{19-16} = imm{15-12};
2998 let Inst{26} = imm{11};
2999 let Inst{14-12} = imm{10-8};
3000 let Inst{7-0} = imm{7-0};
Jim Grosbacha4257162010-10-07 00:53:56 +00003001}
3002
Evan Chengc4af4632010-11-17 20:13:28 +00003003let isMoveImm = 1 in
Evan Cheng63f35442010-11-13 02:25:14 +00003004def t2MOVCCi32imm : PseudoInst<(outs rGPR:$dst),
3005 (ins rGPR:$false, i32imm:$src, pred:$p),
Jim Grosbach99594eb2010-11-18 01:38:26 +00003006 IIC_iCMOVix2, []>, RegConstraint<"$false = $dst">;
Evan Cheng63f35442010-11-13 02:25:14 +00003007
Evan Chengc4af4632010-11-17 20:13:28 +00003008let isMoveImm = 1 in
Owen Anderson8ee97792010-11-18 21:46:31 +00003009def t2MVNCCi : T2OneRegImm<(outs rGPR:$Rd), (ins rGPR:$false, t2_so_imm:$imm),
Jim Grosbach9c5edc02011-10-26 17:28:15 +00003010 IIC_iCMOVi, "mvn", "\t$Rd, $imm",
Owen Anderson8ee97792010-11-18 21:46:31 +00003011[/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm_not:$imm,
Evan Cheng875a6ac2010-11-12 22:42:47 +00003012 imm:$cc, CCR:$ccr))*/]>,
Owen Anderson8ee97792010-11-18 21:46:31 +00003013 RegConstraint<"$false = $Rd"> {
Evan Cheng875a6ac2010-11-12 22:42:47 +00003014 let Inst{31-27} = 0b11110;
3015 let Inst{25} = 0;
3016 let Inst{24-21} = 0b0011;
3017 let Inst{20} = 0; // The S bit.
3018 let Inst{19-16} = 0b1111; // Rn
3019 let Inst{15} = 0;
3020}
3021
Johnny Chend68e1192009-12-15 17:24:14 +00003022class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
3023 string opc, string asm, list<dag> pattern>
Owen Andersonbb6315d2010-11-15 19:58:36 +00003024 : T2TwoRegShiftImm<oops, iops, itin, opc, asm, pattern> {
Johnny Chend68e1192009-12-15 17:24:14 +00003025 let Inst{31-27} = 0b11101;
3026 let Inst{26-25} = 0b01;
3027 let Inst{24-21} = 0b0010;
3028 let Inst{20} = 0; // The S bit.
3029 let Inst{19-16} = 0b1111; // Rn
3030 let Inst{5-4} = opcod; // Shift type.
3031}
Owen Andersonbb6315d2010-11-15 19:58:36 +00003032def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$Rd),
3033 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3034 IIC_iCMOVsi, "lsl", ".w\t$Rd, $Rm, $imm", []>,
3035 RegConstraint<"$false = $Rd">;
3036def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$Rd),
3037 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3038 IIC_iCMOVsi, "lsr", ".w\t$Rd, $Rm, $imm", []>,
3039 RegConstraint<"$false = $Rd">;
3040def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$Rd),
3041 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3042 IIC_iCMOVsi, "asr", ".w\t$Rd, $Rm, $imm", []>,
3043 RegConstraint<"$false = $Rd">;
3044def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$Rd),
3045 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3046 IIC_iCMOVsi, "ror", ".w\t$Rd, $Rm, $imm", []>,
3047 RegConstraint<"$false = $Rd">;
Evan Cheng03a18522012-03-20 21:28:05 +00003048} // isCodeGenOnly = 1
Evan Chengc892aeb2012-02-23 01:19:06 +00003049
Jim Grosbachefeedce2011-07-01 17:14:11 +00003050} // neverHasSideEffects
Evan Cheng13f8b362009-08-01 01:43:45 +00003051
David Goodwin5e47a9a2009-06-30 18:04:13 +00003052//===----------------------------------------------------------------------===//
Jim Grosbachc219e4d2009-12-14 18:56:47 +00003053// Atomic operations intrinsics
3054//
3055
3056// memory barriers protect the atomic sequences
3057let hasSideEffects = 1 in {
Bob Wilsonf74a4292010-10-30 00:54:37 +00003058def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3059 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
3060 Requires<[IsThumb, HasDB]> {
3061 bits<4> opt;
3062 let Inst{31-4} = 0xf3bf8f5;
3063 let Inst{3-0} = opt;
Jim Grosbachc219e4d2009-12-14 18:56:47 +00003064}
3065}
3066
Bob Wilsonf74a4292010-10-30 00:54:37 +00003067def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
Jim Grosbachaa833e52011-09-06 22:53:27 +00003068 "dsb", "\t$opt", []>,
Bob Wilsonf74a4292010-10-30 00:54:37 +00003069 Requires<[IsThumb, HasDB]> {
3070 bits<4> opt;
3071 let Inst{31-4} = 0xf3bf8f4;
3072 let Inst{3-0} = opt;
Johnny Chena4339822010-03-03 00:16:28 +00003073}
3074
Jim Grosbachaa833e52011-09-06 22:53:27 +00003075def t2ISB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3076 "isb", "\t$opt",
Evan Cheng97a45432012-04-27 01:27:19 +00003077 []>, Requires<[IsThumb, HasDB]> {
Jim Grosbachaa833e52011-09-06 22:53:27 +00003078 bits<4> opt;
Bob Wilsonf74a4292010-10-30 00:54:37 +00003079 let Inst{31-4} = 0xf3bf8f6;
Jim Grosbachaa833e52011-09-06 22:53:27 +00003080 let Inst{3-0} = opt;
Johnny Chena4339822010-03-03 00:16:28 +00003081}
3082
Owen Anderson16884412011-07-13 23:22:26 +00003083class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
Johnny Chend68e1192009-12-15 17:24:14 +00003084 InstrItinClass itin, string opc, string asm, string cstr,
3085 list<dag> pattern, bits<4> rt2 = 0b1111>
3086 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3087 let Inst{31-27} = 0b11101;
3088 let Inst{26-20} = 0b0001101;
3089 let Inst{11-8} = rt2;
3090 let Inst{7-6} = 0b01;
3091 let Inst{5-4} = opcod;
3092 let Inst{3-0} = 0b1111;
Jim Grosbach7a088642010-11-19 17:11:02 +00003093
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +00003094 bits<4> addr;
Owen Anderson91a7c592010-11-19 00:28:38 +00003095 bits<4> Rt;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +00003096 let Inst{19-16} = addr;
Jim Grosbach86386922010-12-08 22:10:43 +00003097 let Inst{15-12} = Rt;
Johnny Chend68e1192009-12-15 17:24:14 +00003098}
Owen Anderson16884412011-07-13 23:22:26 +00003099class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
Johnny Chend68e1192009-12-15 17:24:14 +00003100 InstrItinClass itin, string opc, string asm, string cstr,
3101 list<dag> pattern, bits<4> rt2 = 0b1111>
3102 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3103 let Inst{31-27} = 0b11101;
3104 let Inst{26-20} = 0b0001100;
3105 let Inst{11-8} = rt2;
3106 let Inst{7-6} = 0b01;
3107 let Inst{5-4} = opcod;
Jim Grosbach7a088642010-11-19 17:11:02 +00003108
Owen Anderson91a7c592010-11-19 00:28:38 +00003109 bits<4> Rd;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +00003110 bits<4> addr;
Owen Anderson91a7c592010-11-19 00:28:38 +00003111 bits<4> Rt;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +00003112 let Inst{3-0} = Rd;
3113 let Inst{19-16} = addr;
Jim Grosbach86386922010-12-08 22:10:43 +00003114 let Inst{15-12} = Rt;
Johnny Chend68e1192009-12-15 17:24:14 +00003115}
3116
Jim Grosbachc219e4d2009-12-14 18:56:47 +00003117let mayLoad = 1 in {
Jim Grosbachb6aed502011-09-09 18:37:27 +00003118def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003119 AddrModeNone, 4, NoItinerary,
Jim Grosbachf921c0fe2011-06-13 22:54:22 +00003120 "ldrexb", "\t$Rt, $addr", "", []>;
Jim Grosbachb6aed502011-09-09 18:37:27 +00003121def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003122 AddrModeNone, 4, NoItinerary,
Jim Grosbachf921c0fe2011-06-13 22:54:22 +00003123 "ldrexh", "\t$Rt, $addr", "", []>;
Jim Grosbachb6aed502011-09-09 18:37:27 +00003124def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins t2addrmode_imm0_1020s4:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003125 AddrModeNone, 4, NoItinerary,
Jim Grosbachf921c0fe2011-06-13 22:54:22 +00003126 "ldrex", "\t$Rt, $addr", "", []> {
Jim Grosbachb6aed502011-09-09 18:37:27 +00003127 bits<4> Rt;
3128 bits<12> addr;
Johnny Chend68e1192009-12-15 17:24:14 +00003129 let Inst{31-27} = 0b11101;
3130 let Inst{26-20} = 0b0000101;
Jim Grosbachb6aed502011-09-09 18:37:27 +00003131 let Inst{19-16} = addr{11-8};
Owen Anderson808c7d12010-12-10 21:52:38 +00003132 let Inst{15-12} = Rt;
Jim Grosbachb6aed502011-09-09 18:37:27 +00003133 let Inst{11-8} = 0b1111;
3134 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00003135}
Bruno Cardoso Lopesa0112d02011-05-28 04:07:29 +00003136let hasExtraDefRegAllocReq = 1 in
3137def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$Rt, rGPR:$Rt2),
Jim Grosbachb6aed502011-09-09 18:37:27 +00003138 (ins addr_offset_none:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003139 AddrModeNone, 4, NoItinerary,
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +00003140 "ldrexd", "\t$Rt, $Rt2, $addr", "",
Owen Anderson91a7c592010-11-19 00:28:38 +00003141 [], {?, ?, ?, ?}> {
3142 bits<4> Rt2;
Jim Grosbach86386922010-12-08 22:10:43 +00003143 let Inst{11-8} = Rt2;
Owen Anderson91a7c592010-11-19 00:28:38 +00003144}
Jim Grosbachc219e4d2009-12-14 18:56:47 +00003145}
3146
Owen Anderson91a7c592010-11-19 00:28:38 +00003147let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
Jim Grosbachf921c0fe2011-06-13 22:54:22 +00003148def t2STREXB : T2I_strex<0b00, (outs rGPR:$Rd),
Jim Grosbachb6aed502011-09-09 18:37:27 +00003149 (ins rGPR:$Rt, addr_offset_none:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003150 AddrModeNone, 4, NoItinerary,
Jim Grosbachf921c0fe2011-06-13 22:54:22 +00003151 "strexb", "\t$Rd, $Rt, $addr", "", []>;
3152def t2STREXH : T2I_strex<0b01, (outs rGPR:$Rd),
Jim Grosbachb6aed502011-09-09 18:37:27 +00003153 (ins rGPR:$Rt, addr_offset_none:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003154 AddrModeNone, 4, NoItinerary,
Jim Grosbachf921c0fe2011-06-13 22:54:22 +00003155 "strexh", "\t$Rd, $Rt, $addr", "", []>;
Jim Grosbachb6aed502011-09-09 18:37:27 +00003156def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt,
3157 t2addrmode_imm0_1020s4:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003158 AddrModeNone, 4, NoItinerary,
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +00003159 "strex", "\t$Rd, $Rt, $addr", "",
3160 []> {
Jim Grosbachb6aed502011-09-09 18:37:27 +00003161 bits<4> Rd;
3162 bits<4> Rt;
3163 bits<12> addr;
Johnny Chend68e1192009-12-15 17:24:14 +00003164 let Inst{31-27} = 0b11101;
3165 let Inst{26-20} = 0b0000100;
Jim Grosbachb6aed502011-09-09 18:37:27 +00003166 let Inst{19-16} = addr{11-8};
Owen Anderson808c7d12010-12-10 21:52:38 +00003167 let Inst{15-12} = Rt;
Jim Grosbachb6aed502011-09-09 18:37:27 +00003168 let Inst{11-8} = Rd;
3169 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00003170}
Anton Korobeynikov2c6d0f22012-01-23 22:57:52 +00003171let hasExtraSrcRegAllocReq = 1 in
Owen Anderson91a7c592010-11-19 00:28:38 +00003172def t2STREXD : T2I_strex<0b11, (outs rGPR:$Rd),
Jim Grosbachb6aed502011-09-09 18:37:27 +00003173 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr),
Owen Anderson16884412011-07-13 23:22:26 +00003174 AddrModeNone, 4, NoItinerary,
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +00003175 "strexd", "\t$Rd, $Rt, $Rt2, $addr", "", [],
Owen Anderson91a7c592010-11-19 00:28:38 +00003176 {?, ?, ?, ?}> {
3177 bits<4> Rt2;
Jim Grosbach86386922010-12-08 22:10:43 +00003178 let Inst{11-8} = Rt2;
Owen Anderson91a7c592010-11-19 00:28:38 +00003179}
Anton Korobeynikov2c6d0f22012-01-23 22:57:52 +00003180}
Jim Grosbachc219e4d2009-12-14 18:56:47 +00003181
Jim Grosbachad2dad92011-09-06 20:27:04 +00003182def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "", []>,
Bruno Cardoso Lopese47f3752011-01-20 19:18:32 +00003183 Requires<[IsThumb2, HasV7]> {
3184 let Inst{31-16} = 0xf3bf;
Johnny Chen10a77e12010-03-02 22:11:06 +00003185 let Inst{15-14} = 0b10;
Bruno Cardoso Lopese47f3752011-01-20 19:18:32 +00003186 let Inst{13} = 0;
Johnny Chen10a77e12010-03-02 22:11:06 +00003187 let Inst{12} = 0;
Bruno Cardoso Lopese47f3752011-01-20 19:18:32 +00003188 let Inst{11-8} = 0b1111;
Johnny Chen10a77e12010-03-02 22:11:06 +00003189 let Inst{7-4} = 0b0010;
Bruno Cardoso Lopese47f3752011-01-20 19:18:32 +00003190 let Inst{3-0} = 0b1111;
Johnny Chen10a77e12010-03-02 22:11:06 +00003191}
3192
Jim Grosbachc219e4d2009-12-14 18:56:47 +00003193//===----------------------------------------------------------------------===//
Jim Grosbach5aa16842009-08-11 19:42:21 +00003194// SJLJ Exception handling intrinsics
Jim Grosbach1add6592009-08-13 15:11:43 +00003195// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach5aa16842009-08-11 19:42:21 +00003196// address and save #0 in R0 for the non-longjmp case.
3197// Since by its nature we may be coming from some other function to get
3198// here, and we're using the stack frame for the containing function to
3199// save/restore registers, we can't keep anything live in regs across
3200// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
Chris Lattner7a2bdde2011-04-15 05:18:47 +00003201// when we get here from a longjmp(). We force everything out of registers
Jim Grosbach5aa16842009-08-11 19:42:21 +00003202// except for our own input by listing the relevant registers in Defs. By
3203// doing so, we also cause the prologue/epilogue code to actively preserve
3204// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach0798edd2010-05-27 23:49:24 +00003205// $val is a scratch register for our use.
Jim Grosbacha87ded22010-02-08 23:22:00 +00003206let Defs =
Andrew Tricka1099f12011-06-07 00:08:49 +00003207 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
Jakob Stoklund Olesenece8b732012-01-13 22:55:42 +00003208 Q0, Q1, Q2, Q3, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15],
Bill Wendling13a71212011-10-17 22:26:23 +00003209 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1,
3210 usesCustomInserter = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00003211 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Owen Anderson16884412011-07-13 23:22:26 +00003212 AddrModeNone, 0, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00003213 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00003214 Requires<[IsThumb2, HasVFP2]>;
Jim Grosbach5aa16842009-08-11 19:42:21 +00003215}
3216
Bob Wilsonec80e262010-04-09 20:41:18 +00003217let Defs =
Andrew Tricka1099f12011-06-07 00:08:49 +00003218 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
Bill Wendling13a71212011-10-17 22:26:23 +00003219 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1,
3220 usesCustomInserter = 1 in {
Jim Grosbach9f134b52010-08-26 17:02:47 +00003221 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
Owen Anderson16884412011-07-13 23:22:26 +00003222 AddrModeNone, 0, NoItinerary, "", "",
Jim Grosbach9f134b52010-08-26 17:02:47 +00003223 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
Bob Wilsonec80e262010-04-09 20:41:18 +00003224 Requires<[IsThumb2, NoVFP]>;
3225}
Jim Grosbach5aa16842009-08-11 19:42:21 +00003226
3227
3228//===----------------------------------------------------------------------===//
David Goodwin5e47a9a2009-06-30 18:04:13 +00003229// Control-Flow Instructions
3230//
3231
Evan Chengc50a1cb2009-07-09 22:58:39 +00003232// FIXME: remove when we have a way to marking a MI with these properties.
Evan Chengc50a1cb2009-07-09 22:58:39 +00003233// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng0d92f5f2009-10-01 08:22:27 +00003234let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
Chris Lattner39ee0362010-10-31 19:10:56 +00003235 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
Jim Grosbach53e3fc42011-07-08 17:40:42 +00003236def t2LDMIA_RET: t2PseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
Jim Grosbach16f99242011-06-30 18:25:42 +00003237 reglist:$regs, variable_ops),
Owen Anderson16884412011-07-13 23:22:26 +00003238 4, IIC_iLoad_mBr, [],
Jim Grosbach53e3fc42011-07-08 17:40:42 +00003239 (t2LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
Jim Grosbach16f99242011-06-30 18:25:42 +00003240 RegConstraint<"$Rn = $wb">;
Evan Chengc50a1cb2009-07-09 22:58:39 +00003241
David Goodwin5e47a9a2009-06-30 18:04:13 +00003242let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
3243let isPredicable = 1 in
Owen Anderson51f6a7a2011-09-09 21:48:23 +00003244def t2B : T2I<(outs), (ins uncondbrtarget:$target), IIC_Br,
3245 "b", ".w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00003246 [(br bb:$target)]> {
3247 let Inst{31-27} = 0b11110;
3248 let Inst{15-14} = 0b10;
3249 let Inst{12} = 1;
Owen Anderson05bf5952010-11-29 18:54:38 +00003250
Kevin Enderby445ba852012-10-29 23:27:20 +00003251 bits<24> target;
Owen Anderson05bf5952010-11-29 18:54:38 +00003252 let Inst{26} = target{19};
3253 let Inst{11} = target{18};
3254 let Inst{13} = target{17};
Kevin Enderby445ba852012-10-29 23:27:20 +00003255 let Inst{25-16} = target{20-11};
Owen Anderson05bf5952010-11-29 18:54:38 +00003256 let Inst{10-0} = target{10-0};
Kevin Enderby2a7d3a92012-04-12 23:13:34 +00003257 let DecoderMethod = "DecodeT2BInstruction";
Johnny Chend68e1192009-12-15 17:24:14 +00003258}
David Goodwin5e47a9a2009-06-30 18:04:13 +00003259
Jim Grosbacha0bb2532010-11-29 22:40:58 +00003260let isNotDuplicable = 1, isIndirectBranch = 1 in {
Jim Grosbachd4811102010-12-15 19:03:16 +00003261def t2BR_JT : t2PseudoInst<(outs),
Jim Grosbach5ca66692010-11-29 22:37:40 +00003262 (ins GPR:$target, GPR:$index, i32imm:$jt, i32imm:$id),
Owen Anderson16884412011-07-13 23:22:26 +00003263 0, IIC_Br,
Jim Grosbach5ca66692010-11-29 22:37:40 +00003264 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]>;
Evan Cheng5657c012009-07-29 02:18:14 +00003265
Evan Cheng25f7cfc2009-08-01 06:13:52 +00003266// FIXME: Add a non-pc based case that can be predicated.
Jim Grosbachd4811102010-12-15 19:03:16 +00003267def t2TBB_JT : t2PseudoInst<(outs),
Jim Grosbachbc80e942011-09-19 20:31:59 +00003268 (ins GPR:$index, i32imm:$jt, i32imm:$id), 0, IIC_Br, []>;
Jim Grosbach5ca66692010-11-29 22:37:40 +00003269
Jim Grosbachd4811102010-12-15 19:03:16 +00003270def t2TBH_JT : t2PseudoInst<(outs),
Jim Grosbachbc80e942011-09-19 20:31:59 +00003271 (ins GPR:$index, i32imm:$jt, i32imm:$id), 0, IIC_Br, []>;
Jim Grosbach5ca66692010-11-29 22:37:40 +00003272
Jim Grosbach7f739be2011-09-19 22:21:13 +00003273def t2TBB : T2I<(outs), (ins addrmode_tbb:$addr), IIC_Br,
3274 "tbb", "\t$addr", []> {
Jim Grosbach5ca66692010-11-29 22:37:40 +00003275 bits<4> Rn;
3276 bits<4> Rm;
Jim Grosbachf0db2612010-12-17 18:42:56 +00003277 let Inst{31-20} = 0b111010001101;
Jim Grosbach5ca66692010-11-29 22:37:40 +00003278 let Inst{19-16} = Rn;
3279 let Inst{15-5} = 0b11110000000;
3280 let Inst{4} = 0; // B form
3281 let Inst{3-0} = Rm;
Jim Grosbach7f739be2011-09-19 22:21:13 +00003282
3283 let DecoderMethod = "DecodeThumbTableBranch";
Johnny Chend68e1192009-12-15 17:24:14 +00003284}
Evan Cheng5657c012009-07-29 02:18:14 +00003285
Jim Grosbach7f739be2011-09-19 22:21:13 +00003286def t2TBH : T2I<(outs), (ins addrmode_tbh:$addr), IIC_Br,
3287 "tbh", "\t$addr", []> {
Jim Grosbach5ca66692010-11-29 22:37:40 +00003288 bits<4> Rn;
3289 bits<4> Rm;
Jim Grosbachf0db2612010-12-17 18:42:56 +00003290 let Inst{31-20} = 0b111010001101;
Jim Grosbach5ca66692010-11-29 22:37:40 +00003291 let Inst{19-16} = Rn;
3292 let Inst{15-5} = 0b11110000000;
3293 let Inst{4} = 1; // H form
3294 let Inst{3-0} = Rm;
Jim Grosbach7f739be2011-09-19 22:21:13 +00003295
3296 let DecoderMethod = "DecodeThumbTableBranch";
Johnny Chen93042d12010-03-02 18:14:57 +00003297}
Evan Cheng5657c012009-07-29 02:18:14 +00003298} // isNotDuplicable, isIndirectBranch
3299
David Goodwinc9a59b52009-06-30 19:50:22 +00003300} // isBranch, isTerminator, isBarrier
David Goodwin5e47a9a2009-06-30 18:04:13 +00003301
3302// FIXME: should be able to write a pattern for ARMBrcond, but can't use
Owen Anderson51f6a7a2011-09-09 21:48:23 +00003303// a two-value operand where a dag node expects ", "two operands. :(
David Goodwin5e47a9a2009-06-30 18:04:13 +00003304let isBranch = 1, isTerminator = 1 in
David Goodwin8b7d7ad2009-08-06 16:52:47 +00003305def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
Evan Cheng699beba2009-10-27 00:08:59 +00003306 "b", ".w\t$target",
Johnny Chend68e1192009-12-15 17:24:14 +00003307 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
3308 let Inst{31-27} = 0b11110;
3309 let Inst{15-14} = 0b10;
3310 let Inst{12} = 0;
Jim Grosbach00f25fa2010-12-14 20:46:39 +00003311
Owen Andersonfb20d892010-12-09 00:27:41 +00003312 bits<4> p;
3313 let Inst{25-22} = p;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00003314
Owen Andersonfb20d892010-12-09 00:27:41 +00003315 bits<21> target;
3316 let Inst{26} = target{20};
3317 let Inst{11} = target{19};
3318 let Inst{13} = target{18};
3319 let Inst{21-16} = target{17-12};
3320 let Inst{10-0} = target{11-1};
Owen Anderson8d7d2e12011-08-09 20:55:18 +00003321
3322 let DecoderMethod = "DecodeThumb2BCCInstruction";
Johnny Chend68e1192009-12-15 17:24:14 +00003323}
Evan Chengf49810c2009-06-23 17:48:47 +00003324
Evan Chengafff9412011-12-20 18:26:50 +00003325// Tail calls. The IOS version of thumb tail calls uses a t2 branch, so
Jim Grosbachaf7f2d62011-07-08 20:32:21 +00003326// it goes here.
3327let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
Evan Chengafff9412011-12-20 18:26:50 +00003328 // IOS version.
Jakob Stoklund Olesenc54f6342012-02-24 01:19:29 +00003329 let Uses = [SP] in
Owen Anderson51f6a7a2011-09-09 21:48:23 +00003330 def tTAILJMPd: tPseudoExpand<(outs),
Jakob Stoklund Olesen135fb452012-07-13 20:27:00 +00003331 (ins uncondbrtarget:$dst, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00003332 4, IIC_Br, [],
Owen Anderson51f6a7a2011-09-09 21:48:23 +00003333 (t2B uncondbrtarget:$dst, pred:$p)>,
Evan Chengafff9412011-12-20 18:26:50 +00003334 Requires<[IsThumb2, IsIOS]>;
Jim Grosbachaf7f2d62011-07-08 20:32:21 +00003335}
Evan Cheng06e16582009-07-10 01:54:42 +00003336
3337// IT block
Evan Cheng86050dc2010-06-18 23:09:54 +00003338let Defs = [ITSTATE] in
Evan Cheng06e16582009-07-10 01:54:42 +00003339def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
Owen Anderson16884412011-07-13 23:22:26 +00003340 AddrModeNone, 2, IIC_iALUx,
Johnny Chend68e1192009-12-15 17:24:14 +00003341 "it$mask\t$cc", "", []> {
3342 // 16-bit instruction.
Johnny Chenbbc71b22009-12-16 02:32:54 +00003343 let Inst{31-16} = 0x0000;
Johnny Chend68e1192009-12-15 17:24:14 +00003344 let Inst{15-8} = 0b10111111;
Owen Anderson05bf5952010-11-29 18:54:38 +00003345
3346 bits<4> cc;
3347 bits<4> mask;
Jim Grosbach86386922010-12-08 22:10:43 +00003348 let Inst{7-4} = cc;
3349 let Inst{3-0} = mask;
Owen Andersoneaca9282011-08-30 22:58:27 +00003350
3351 let DecoderMethod = "DecodeIT";
Johnny Chend68e1192009-12-15 17:24:14 +00003352}
Evan Cheng06e16582009-07-10 01:54:42 +00003353
Johnny Chence6275f2010-02-25 19:05:29 +00003354// Branch and Exchange Jazelle -- for disassembly only
3355// Rm = Inst{19-16}
Jim Grosbach6c3e11e2011-09-02 23:43:09 +00003356def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func", []> {
3357 bits<4> func;
Johnny Chence6275f2010-02-25 19:05:29 +00003358 let Inst{31-27} = 0b11110;
3359 let Inst{26} = 0;
3360 let Inst{25-20} = 0b111100;
Jim Grosbach86386922010-12-08 22:10:43 +00003361 let Inst{19-16} = func;
Jim Grosbach6c3e11e2011-09-02 23:43:09 +00003362 let Inst{15-0} = 0b1000111100000000;
Johnny Chence6275f2010-02-25 19:05:29 +00003363}
3364
Jim Grosbach11cca7a2011-08-18 17:51:36 +00003365// Compare and branch on zero / non-zero
3366let isBranch = 1, isTerminator = 1 in {
3367 def tCBZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3368 "cbz\t$Rn, $target", []>,
3369 T1Misc<{0,0,?,1,?,?,?}>,
3370 Requires<[IsThumb2]> {
3371 // A8.6.27
3372 bits<6> target;
3373 bits<3> Rn;
3374 let Inst{9} = target{5};
3375 let Inst{7-3} = target{4-0};
3376 let Inst{2-0} = Rn;
3377 }
3378
3379 def tCBNZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3380 "cbnz\t$Rn, $target", []>,
3381 T1Misc<{1,0,?,1,?,?,?}>,
3382 Requires<[IsThumb2]> {
3383 // A8.6.27
3384 bits<6> target;
3385 bits<3> Rn;
3386 let Inst{9} = target{5};
3387 let Inst{7-3} = target{4-0};
3388 let Inst{2-0} = Rn;
3389 }
3390}
3391
3392
Jim Grosbach32f36892011-09-19 23:38:34 +00003393// Change Processor State is a system instruction.
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +00003394// FIXME: Since the asm parser has currently no clean way to handle optional
3395// operands, create 3 versions of the same instruction. Once there's a clean
3396// framework to represent optional operands, change this behavior.
3397class t2CPS<dag iops, string asm_op> : T2XI<(outs), iops, NoItinerary,
Jim Grosbach32f36892011-09-19 23:38:34 +00003398 !strconcat("cps", asm_op), []> {
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +00003399 bits<2> imod;
3400 bits<3> iflags;
3401 bits<5> mode;
3402 bit M;
3403
Johnny Chen93042d12010-03-02 18:14:57 +00003404 let Inst{31-27} = 0b11110;
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +00003405 let Inst{26} = 0;
Johnny Chen93042d12010-03-02 18:14:57 +00003406 let Inst{25-20} = 0b111010;
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +00003407 let Inst{19-16} = 0b1111;
Johnny Chen93042d12010-03-02 18:14:57 +00003408 let Inst{15-14} = 0b10;
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +00003409 let Inst{12} = 0;
3410 let Inst{10-9} = imod;
3411 let Inst{8} = M;
3412 let Inst{7-5} = iflags;
3413 let Inst{4-0} = mode;
Owen Anderson6153a032011-08-23 17:45:18 +00003414 let DecoderMethod = "DecodeT2CPSInstruction";
Johnny Chen93042d12010-03-02 18:14:57 +00003415}
3416
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +00003417let M = 1 in
3418 def t2CPS3p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags, i32imm:$mode),
3419 "$imod.w\t$iflags, $mode">;
3420let mode = 0, M = 0 in
3421 def t2CPS2p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags),
3422 "$imod.w\t$iflags">;
3423let imod = 0, iflags = 0, M = 1 in
Jim Grosbach0efe2132011-09-19 23:58:31 +00003424 def t2CPS1p : t2CPS<(ins imm0_31:$mode), "\t$mode">;
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +00003425
Johnny Chen0f7866e2010-03-03 02:09:43 +00003426// A6.3.4 Branches and miscellaneous control
3427// Table A6-14 Change Processor State, and hint instructions
Jim Grosbach7e99a602012-06-18 19:45:50 +00003428def t2HINT : T2I<(outs), (ins imm0_255:$imm), NoItinerary, "hint", "\t$imm",[]>{
3429 bits<8> imm;
3430 let Inst{31-8} = 0b111100111010111110000000;
3431 let Inst{7-0} = imm;
Johnny Chen0f7866e2010-03-03 02:09:43 +00003432}
3433
Jim Grosbach7e99a602012-06-18 19:45:50 +00003434def : t2InstAlias<"hint$p.w $imm", (t2HINT imm0_255:$imm, pred:$p)>;
3435def : t2InstAlias<"nop$p.w", (t2HINT 0, pred:$p)>;
3436def : t2InstAlias<"yield$p.w", (t2HINT 1, pred:$p)>;
3437def : t2InstAlias<"wfe$p.w", (t2HINT 2, pred:$p)>;
3438def : t2InstAlias<"wfi$p.w", (t2HINT 3, pred:$p)>;
3439def : t2InstAlias<"sev$p.w", (t2HINT 4, pred:$p)>;
Johnny Chen0f7866e2010-03-03 02:09:43 +00003440
Jim Grosbach6f9f8842011-07-13 22:59:38 +00003441def t2DBG : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "dbg", "\t$opt", []> {
Owen Andersonc7373f82010-11-30 20:00:01 +00003442 bits<4> opt;
Jim Grosbach77951902011-09-06 22:06:40 +00003443 let Inst{31-20} = 0b111100111010;
3444 let Inst{19-16} = 0b1111;
3445 let Inst{15-8} = 0b10000000;
3446 let Inst{7-4} = 0b1111;
Jim Grosbach86386922010-12-08 22:10:43 +00003447 let Inst{3-0} = opt;
Johnny Chen0f7866e2010-03-03 02:09:43 +00003448}
3449
Jim Grosbach32f36892011-09-19 23:38:34 +00003450// Secure Monitor Call is a system instruction.
Johnny Chen6341c5a2010-02-25 20:25:24 +00003451// Option = Inst{19-16}
Jim Grosbach32f36892011-09-19 23:38:34 +00003452def t2SMC : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt", []> {
Johnny Chen6341c5a2010-02-25 20:25:24 +00003453 let Inst{31-27} = 0b11110;
3454 let Inst{26-20} = 0b1111111;
3455 let Inst{15-12} = 0b1000;
Jim Grosbach7721e7f2010-12-02 23:05:38 +00003456
Owen Andersond18a9c92010-11-29 19:22:08 +00003457 bits<4> opt;
Jim Grosbach86386922010-12-08 22:10:43 +00003458 let Inst{19-16} = opt;
Owen Andersond18a9c92010-11-29 19:22:08 +00003459}
3460
Jim Grosbach05ec8f72011-09-16 18:25:22 +00003461class T2SRS<bits<2> Op, bit W, dag oops, dag iops, InstrItinClass itin,
3462 string opc, string asm, list<dag> pattern>
Owen Andersond18a9c92010-11-29 19:22:08 +00003463 : T2I<oops, iops, itin, opc, asm, pattern> {
3464 bits<5> mode;
Jim Grosbach05ec8f72011-09-16 18:25:22 +00003465 let Inst{31-25} = 0b1110100;
3466 let Inst{24-23} = Op;
3467 let Inst{22} = 0;
3468 let Inst{21} = W;
3469 let Inst{20-16} = 0b01101;
3470 let Inst{15-5} = 0b11000000000;
Owen Andersond18a9c92010-11-29 19:22:08 +00003471 let Inst{4-0} = mode{4-0};
Johnny Chen6341c5a2010-02-25 20:25:24 +00003472}
3473
Jim Grosbach05ec8f72011-09-16 18:25:22 +00003474// Store Return State is a system instruction.
3475def t2SRSDB_UPD : T2SRS<0b00, 1, (outs), (ins imm0_31:$mode), NoItinerary,
3476 "srsdb", "\tsp!, $mode", []>;
3477def t2SRSDB : T2SRS<0b00, 0, (outs), (ins imm0_31:$mode), NoItinerary,
3478 "srsdb","\tsp, $mode", []>;
3479def t2SRSIA_UPD : T2SRS<0b11, 1, (outs), (ins imm0_31:$mode), NoItinerary,
3480 "srsia","\tsp!, $mode", []>;
3481def t2SRSIA : T2SRS<0b11, 0, (outs), (ins imm0_31:$mode), NoItinerary,
3482 "srsia","\tsp, $mode", []>;
Johnny Chen6341c5a2010-02-25 20:25:24 +00003483
Jim Grosbach1e8ed252013-02-23 00:52:09 +00003484
3485def : t2InstAlias<"srsdb${p} $mode", (t2SRSDB imm0_31:$mode, pred:$p)>;
3486def : t2InstAlias<"srsdb${p} $mode!", (t2SRSDB_UPD imm0_31:$mode, pred:$p)>;
3487
3488def : t2InstAlias<"srsia${p} $mode", (t2SRSIA imm0_31:$mode, pred:$p)>;
3489def : t2InstAlias<"srsia${p} $mode!", (t2SRSIA_UPD imm0_31:$mode, pred:$p)>;
3490
Jim Grosbach05ec8f72011-09-16 18:25:22 +00003491// Return From Exception is a system instruction.
Owen Anderson5404c2b2010-11-29 20:38:48 +00003492class T2RFE<bits<12> op31_20, dag oops, dag iops, InstrItinClass itin,
Owen Andersond18a9c92010-11-29 19:22:08 +00003493 string opc, string asm, list<dag> pattern>
3494 : T2I<oops, iops, itin, opc, asm, pattern> {
Owen Anderson5404c2b2010-11-29 20:38:48 +00003495 let Inst{31-20} = op31_20{11-0};
Jim Grosbach7721e7f2010-12-02 23:05:38 +00003496
Owen Andersond18a9c92010-11-29 19:22:08 +00003497 bits<4> Rn;
Jim Grosbach86386922010-12-08 22:10:43 +00003498 let Inst{19-16} = Rn;
Johnny Chenec51a622011-04-12 21:41:51 +00003499 let Inst{15-0} = 0xc000;
Owen Andersond18a9c92010-11-29 19:22:08 +00003500}
3501
Owen Anderson5404c2b2010-11-29 20:38:48 +00003502def t2RFEDBW : T2RFE<0b111010000011,
Johnny Chenec51a622011-04-12 21:41:51 +00003503 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn!",
Owen Anderson5404c2b2010-11-29 20:38:48 +00003504 [/* For disassembly only; pattern left blank */]>;
3505def t2RFEDB : T2RFE<0b111010000001,
Johnny Chenec51a622011-04-12 21:41:51 +00003506 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn",
Owen Anderson5404c2b2010-11-29 20:38:48 +00003507 [/* For disassembly only; pattern left blank */]>;
3508def t2RFEIAW : T2RFE<0b111010011011,
Johnny Chenec51a622011-04-12 21:41:51 +00003509 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn!",
Owen Anderson5404c2b2010-11-29 20:38:48 +00003510 [/* For disassembly only; pattern left blank */]>;
3511def t2RFEIA : T2RFE<0b111010011001,
Johnny Chenec51a622011-04-12 21:41:51 +00003512 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn",
Owen Anderson5404c2b2010-11-29 20:38:48 +00003513 [/* For disassembly only; pattern left blank */]>;
Johnny Chen6341c5a2010-02-25 20:25:24 +00003514
Evan Chengf49810c2009-06-23 17:48:47 +00003515//===----------------------------------------------------------------------===//
3516// Non-Instruction Patterns
3517//
3518
Evan Cheng5adb66a2009-09-28 09:14:39 +00003519// 32-bit immediate using movw + movt.
Evan Cheng5be39222010-09-24 22:03:46 +00003520// This is a single pseudo instruction to make it re-materializable.
3521// FIXME: Remove this when we can do generalized remat.
Evan Chengfc8475b2011-01-19 02:16:49 +00003522let isReMaterializable = 1, isMoveImm = 1 in
Jim Grosbach3c38f962010-10-06 22:01:26 +00003523def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
Jim Grosbach99594eb2010-11-18 01:38:26 +00003524 [(set rGPR:$dst, (i32 imm:$src))]>,
Jim Grosbach3c38f962010-10-06 22:01:26 +00003525 Requires<[IsThumb, HasV6T2]>;
Evan Chengb9803a82009-11-06 23:52:48 +00003526
Evan Cheng53519f02011-01-21 18:55:51 +00003527// Pseudo instruction that combines movw + movt + add pc (if pic).
Evan Cheng9fe20092011-01-20 08:34:58 +00003528// It also makes it possible to rematerialize the instructions.
3529// FIXME: Remove this when we can do generalized remat and when machine licm
3530// can properly the instructions.
Evan Cheng53519f02011-01-21 18:55:51 +00003531let isReMaterializable = 1 in {
3532def t2MOV_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3533 IIC_iMOVix2addpc,
Evan Cheng9fe20092011-01-20 08:34:58 +00003534 [(set rGPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
3535 Requires<[IsThumb2, UseMovt]>;
Evan Cheng5de5d4b2011-01-17 08:03:18 +00003536
Evan Cheng53519f02011-01-21 18:55:51 +00003537def t2MOV_ga_dyn : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3538 IIC_iMOVix2,
3539 [(set rGPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
3540 Requires<[IsThumb2, UseMovt]>;
3541}
3542
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +00003543// ConstantPool, GlobalAddress, and JumpTable
3544def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
3545 Requires<[IsThumb2, DontUseMovt]>;
3546def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
3547def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
3548 Requires<[IsThumb2, UseMovt]>;
3549
3550def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3551 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
3552
Evan Chengb9803a82009-11-06 23:52:48 +00003553// Pseudo instruction that combines ldr from constpool and add pc. This should
3554// be expanded into two instructions late to allow if-conversion and
3555// scheduling.
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00003556let canFoldAsLoad = 1, isReMaterializable = 1 in
Evan Cheng9fe20092011-01-20 08:34:58 +00003557def t2LDRpci_pic : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr, pclabel:$cp),
Jim Grosbach99594eb2010-11-18 01:38:26 +00003558 IIC_iLoadiALU,
Evan Cheng9fe20092011-01-20 08:34:58 +00003559 [(set rGPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
Evan Chengb9803a82009-11-06 23:52:48 +00003560 imm:$cp))]>,
3561 Requires<[IsThumb2]>;
Bill Wendlingef2c86f2011-10-10 22:59:55 +00003562
Andrew Trick7f5f0da2011-10-18 18:40:53 +00003563// Pseudo isntruction that combines movs + predicated rsbmi
Bill Wendlingef2c86f2011-10-10 22:59:55 +00003564// to implement integer ABS
3565let usesCustomInserter = 1, Defs = [CPSR] in {
3566def t2ABS : PseudoInst<(outs rGPR:$dst), (ins rGPR:$src),
3567 NoItinerary, []>, Requires<[IsThumb2]>;
3568}
3569
Owen Anderson8a83f712011-09-07 21:10:42 +00003570//===----------------------------------------------------------------------===//
3571// Coprocessor load/store -- for disassembly only
3572//
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003573class T2CI<bits<4> op31_28, dag oops, dag iops, string opc, string asm>
Owen Anderson8a83f712011-09-07 21:10:42 +00003574 : T2I<oops, iops, NoItinerary, opc, asm, []> {
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003575 let Inst{31-28} = op31_28;
Owen Anderson8a83f712011-09-07 21:10:42 +00003576 let Inst{27-25} = 0b110;
3577}
3578
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003579multiclass t2LdStCop<bits<4> op31_28, bit load, bit Dbit, string asm> {
3580 def _OFFSET : T2CI<op31_28,
3581 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
3582 asm, "\t$cop, $CRd, $addr"> {
3583 bits<13> addr;
3584 bits<4> cop;
3585 bits<4> CRd;
Owen Anderson8a83f712011-09-07 21:10:42 +00003586 let Inst{24} = 1; // P = 1
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003587 let Inst{23} = addr{8};
3588 let Inst{22} = Dbit;
Owen Anderson8a83f712011-09-07 21:10:42 +00003589 let Inst{21} = 0; // W = 0
Owen Anderson8a83f712011-09-07 21:10:42 +00003590 let Inst{20} = load;
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003591 let Inst{19-16} = addr{12-9};
3592 let Inst{15-12} = CRd;
3593 let Inst{11-8} = cop;
3594 let Inst{7-0} = addr{7-0};
Owen Anderson8a83f712011-09-07 21:10:42 +00003595 let DecoderMethod = "DecodeCopMemInstruction";
3596 }
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003597 def _PRE : T2CI<op31_28,
3598 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
3599 asm, "\t$cop, $CRd, $addr!"> {
3600 bits<13> addr;
3601 bits<4> cop;
3602 bits<4> CRd;
Owen Anderson8a83f712011-09-07 21:10:42 +00003603 let Inst{24} = 1; // P = 1
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003604 let Inst{23} = addr{8};
3605 let Inst{22} = Dbit;
Owen Anderson8a83f712011-09-07 21:10:42 +00003606 let Inst{21} = 1; // W = 1
Owen Anderson8a83f712011-09-07 21:10:42 +00003607 let Inst{20} = load;
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003608 let Inst{19-16} = addr{12-9};
3609 let Inst{15-12} = CRd;
3610 let Inst{11-8} = cop;
3611 let Inst{7-0} = addr{7-0};
Owen Anderson8a83f712011-09-07 21:10:42 +00003612 let DecoderMethod = "DecodeCopMemInstruction";
3613 }
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003614 def _POST: T2CI<op31_28,
3615 (outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
3616 postidx_imm8s4:$offset),
3617 asm, "\t$cop, $CRd, $addr, $offset"> {
3618 bits<9> offset;
3619 bits<4> addr;
3620 bits<4> cop;
3621 bits<4> CRd;
Owen Anderson8a83f712011-09-07 21:10:42 +00003622 let Inst{24} = 0; // P = 0
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003623 let Inst{23} = offset{8};
3624 let Inst{22} = Dbit;
Owen Anderson8a83f712011-09-07 21:10:42 +00003625 let Inst{21} = 1; // W = 1
Owen Anderson8a83f712011-09-07 21:10:42 +00003626 let Inst{20} = load;
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003627 let Inst{19-16} = addr;
3628 let Inst{15-12} = CRd;
3629 let Inst{11-8} = cop;
3630 let Inst{7-0} = offset{7-0};
Owen Anderson8a83f712011-09-07 21:10:42 +00003631 let DecoderMethod = "DecodeCopMemInstruction";
3632 }
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003633 def _OPTION : T2CI<op31_28, (outs),
3634 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
3635 coproc_option_imm:$option),
3636 asm, "\t$cop, $CRd, $addr, $option"> {
3637 bits<8> option;
3638 bits<4> addr;
3639 bits<4> cop;
3640 bits<4> CRd;
Owen Anderson8a83f712011-09-07 21:10:42 +00003641 let Inst{24} = 0; // P = 0
3642 let Inst{23} = 1; // U = 1
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003643 let Inst{22} = Dbit;
Owen Anderson8a83f712011-09-07 21:10:42 +00003644 let Inst{21} = 0; // W = 0
Owen Anderson8a83f712011-09-07 21:10:42 +00003645 let Inst{20} = load;
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003646 let Inst{19-16} = addr;
3647 let Inst{15-12} = CRd;
3648 let Inst{11-8} = cop;
3649 let Inst{7-0} = option;
Owen Anderson8a83f712011-09-07 21:10:42 +00003650 let DecoderMethod = "DecodeCopMemInstruction";
3651 }
3652}
3653
Jim Grosbachc66e7af2011-10-12 20:54:17 +00003654defm t2LDC : t2LdStCop<0b1110, 1, 0, "ldc">;
3655defm t2LDCL : t2LdStCop<0b1110, 1, 1, "ldcl">;
3656defm t2STC : t2LdStCop<0b1110, 0, 0, "stc">;
3657defm t2STCL : t2LdStCop<0b1110, 0, 1, "stcl">;
3658defm t2LDC2 : t2LdStCop<0b1111, 1, 0, "ldc2">;
3659defm t2LDC2L : t2LdStCop<0b1111, 1, 1, "ldc2l">;
3660defm t2STC2 : t2LdStCop<0b1111, 0, 0, "stc2">;
3661defm t2STC2L : t2LdStCop<0b1111, 0, 1, "stc2l">;
Owen Anderson8a83f712011-09-07 21:10:42 +00003662
Johnny Chen23336552010-02-25 18:46:43 +00003663
3664//===----------------------------------------------------------------------===//
3665// Move between special register and ARM core register -- for disassembly only
3666//
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003667// Move to ARM core register from Special Register
James Molloyacad68d2011-09-28 14:21:38 +00003668
3669// A/R class MRS.
3670//
3671// A/R class can only move from CPSR or SPSR.
Jim Grosbachc92ba4e2012-04-23 22:04:10 +00003672def t2MRS_AR : T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, apsr",
3673 []>, Requires<[IsThumb2,IsARClass]> {
Owen Anderson00a035f2010-11-29 19:29:15 +00003674 bits<4> Rd;
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003675 let Inst{31-12} = 0b11110011111011111000;
Jim Grosbach86386922010-12-08 22:10:43 +00003676 let Inst{11-8} = Rd;
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003677 let Inst{7-0} = 0b0000;
Owen Anderson00a035f2010-11-29 19:29:15 +00003678}
3679
James Molloyacad68d2011-09-28 14:21:38 +00003680def : t2InstAlias<"mrs${p} $Rd, cpsr", (t2MRS_AR GPR:$Rd, pred:$p)>;
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003681
Jim Grosbachc92ba4e2012-04-23 22:04:10 +00003682def t2MRSsys_AR: T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, spsr",
3683 []>, Requires<[IsThumb2,IsARClass]> {
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003684 bits<4> Rd;
3685 let Inst{31-12} = 0b11110011111111111000;
3686 let Inst{11-8} = Rd;
3687 let Inst{7-0} = 0b0000;
3688}
Johnny Chen23336552010-02-25 18:46:43 +00003689
James Molloyacad68d2011-09-28 14:21:38 +00003690// M class MRS.
3691//
3692// This MRS has a mask field in bits 7-0 and can take more values than
3693// the A/R class (a full msr_mask).
3694def t2MRS_M : T2I<(outs rGPR:$Rd), (ins msr_mask:$mask), NoItinerary,
3695 "mrs", "\t$Rd, $mask", []>,
Evan Cheng97a45432012-04-27 01:27:19 +00003696 Requires<[IsThumb,IsMClass]> {
James Molloyacad68d2011-09-28 14:21:38 +00003697 bits<4> Rd;
3698 bits<8> mask;
3699 let Inst{31-12} = 0b11110011111011111000;
3700 let Inst{11-8} = Rd;
3701 let Inst{19-16} = 0b1111;
3702 let Inst{7-0} = mask;
3703}
3704
3705
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +00003706// Move from ARM core register to Special Register
3707//
James Molloyacad68d2011-09-28 14:21:38 +00003708// A/R class MSR.
3709//
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +00003710// No need to have both system and application versions, the encodings are the
3711// same and the assembly parser has no way to distinguish between them. The mask
3712// operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
3713// the mask with the fields to be accessed in the special register.
James Molloyacad68d2011-09-28 14:21:38 +00003714def t2MSR_AR : T2I<(outs), (ins msr_mask:$mask, rGPR:$Rn),
3715 NoItinerary, "msr", "\t$mask, $Rn", []>,
3716 Requires<[IsThumb2,IsARClass]> {
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +00003717 bits<5> mask;
Owen Anderson00a035f2010-11-29 19:29:15 +00003718 bits<4> Rn;
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003719 let Inst{31-21} = 0b11110011100;
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +00003720 let Inst{20} = mask{4}; // R Bit
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003721 let Inst{19-16} = Rn;
3722 let Inst{15-12} = 0b1000;
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +00003723 let Inst{11-8} = mask{3-0};
Jim Grosbachbf841cf2011-09-14 20:03:46 +00003724 let Inst{7-0} = 0;
Owen Anderson00a035f2010-11-29 19:29:15 +00003725}
3726
James Molloyacad68d2011-09-28 14:21:38 +00003727// M class MSR.
3728//
3729// Move from ARM core register to Special Register
3730def t2MSR_M : T2I<(outs), (ins msr_mask:$SYSm, rGPR:$Rn),
3731 NoItinerary, "msr", "\t$SYSm, $Rn", []>,
Evan Cheng97a45432012-04-27 01:27:19 +00003732 Requires<[IsThumb,IsMClass]> {
Kevin Enderby0fd4f3c2012-05-17 22:18:01 +00003733 bits<12> SYSm;
James Molloyacad68d2011-09-28 14:21:38 +00003734 bits<4> Rn;
3735 let Inst{31-21} = 0b11110011100;
3736 let Inst{20} = 0b0;
3737 let Inst{19-16} = Rn;
3738 let Inst{15-12} = 0b1000;
Kevin Enderby0fd4f3c2012-05-17 22:18:01 +00003739 let Inst{11-0} = SYSm;
James Molloyacad68d2011-09-28 14:21:38 +00003740}
3741
3742
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00003743//===----------------------------------------------------------------------===//
Jim Grosbach9bb098a2011-07-13 21:14:23 +00003744// Move between coprocessor and ARM core register
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00003745//
3746
Jim Grosbache35c5e02011-07-13 21:35:10 +00003747class t2MovRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops,
3748 list<dag> pattern>
3749 : T2Cop<Op, oops, iops,
Jim Grosbach0d8dae22011-07-13 21:17:59 +00003750 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"),
Jim Grosbach9bb098a2011-07-13 21:14:23 +00003751 pattern> {
3752 let Inst{27-24} = 0b1110;
3753 let Inst{20} = direction;
3754 let Inst{4} = 1;
3755
3756 bits<4> Rt;
3757 bits<4> cop;
3758 bits<3> opc1;
3759 bits<3> opc2;
3760 bits<4> CRm;
3761 bits<4> CRn;
3762
3763 let Inst{15-12} = Rt;
3764 let Inst{11-8} = cop;
3765 let Inst{23-21} = opc1;
3766 let Inst{7-5} = opc2;
3767 let Inst{3-0} = CRm;
3768 let Inst{19-16} = CRn;
3769}
3770
Jim Grosbache35c5e02011-07-13 21:35:10 +00003771class t2MovRRCopro<bits<4> Op, string opc, bit direction,
3772 list<dag> pattern = []>
3773 : T2Cop<Op, (outs),
Jim Grosbachc8ae39e2011-07-14 21:26:42 +00003774 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
Jim Grosbache35c5e02011-07-13 21:35:10 +00003775 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
3776 let Inst{27-24} = 0b1100;
3777 let Inst{23-21} = 0b010;
3778 let Inst{20} = direction;
3779
3780 bits<4> Rt;
3781 bits<4> Rt2;
3782 bits<4> cop;
3783 bits<4> opc1;
3784 bits<4> CRm;
3785
3786 let Inst{15-12} = Rt;
3787 let Inst{19-16} = Rt2;
3788 let Inst{11-8} = cop;
3789 let Inst{7-4} = opc1;
3790 let Inst{3-0} = CRm;
3791}
3792
3793/* from ARM core register to coprocessor */
3794def t2MCR : t2MovRCopro<0b1110, "mcr", 0,
Jim Grosbach9bb098a2011-07-13 21:14:23 +00003795 (outs),
Jim Grosbache540c742011-07-14 21:19:17 +00003796 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3797 c_imm:$CRm, imm0_7:$opc2),
Jim Grosbach9bb098a2011-07-13 21:14:23 +00003798 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3799 imm:$CRm, imm:$opc2)]>;
Jim Grosbach213d2e72012-03-16 00:45:58 +00003800def : t2InstAlias<"mcr $cop, $opc1, $Rt, $CRn, $CRm",
3801 (t2MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3802 c_imm:$CRm, 0)>;
Jim Grosbache35c5e02011-07-13 21:35:10 +00003803def t2MCR2 : t2MovRCopro<0b1111, "mcr2", 0,
Jim Grosbache540c742011-07-14 21:19:17 +00003804 (outs), (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3805 c_imm:$CRm, imm0_7:$opc2),
Bruno Cardoso Lopes0a69ba32011-05-03 17:29:29 +00003806 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3807 imm:$CRm, imm:$opc2)]>;
Jim Grosbach213d2e72012-03-16 00:45:58 +00003808def : t2InstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
3809 (t2MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3810 c_imm:$CRm, 0)>;
Jim Grosbache35c5e02011-07-13 21:35:10 +00003811
3812/* from coprocessor to ARM core register */
3813def t2MRC : t2MovRCopro<0b1110, "mrc", 1,
Jim Grosbachccfd9312011-07-19 20:35:35 +00003814 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3815 c_imm:$CRm, imm0_7:$opc2), []>;
Jim Grosbach213d2e72012-03-16 00:45:58 +00003816def : t2InstAlias<"mrc $cop, $opc1, $Rt, $CRn, $CRm",
3817 (t2MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3818 c_imm:$CRm, 0)>;
Jim Grosbache35c5e02011-07-13 21:35:10 +00003819
3820def t2MRC2 : t2MovRCopro<0b1111, "mrc2", 1,
Jim Grosbachccfd9312011-07-19 20:35:35 +00003821 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3822 c_imm:$CRm, imm0_7:$opc2), []>;
Jim Grosbach213d2e72012-03-16 00:45:58 +00003823def : t2InstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
3824 (t2MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3825 c_imm:$CRm, 0)>;
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00003826
Jim Grosbache35c5e02011-07-13 21:35:10 +00003827def : T2v6Pat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
3828 (t2MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3829
3830def : T2v6Pat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
Bruno Cardoso Lopes54ad87a2011-05-03 17:29:22 +00003831 (t2MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3832
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00003833
Jim Grosbache35c5e02011-07-13 21:35:10 +00003834/* from ARM core register to coprocessor */
3835def t2MCRR : t2MovRRCopro<0b1110, "mcrr", 0,
3836 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
3837 imm:$CRm)]>;
3838def t2MCRR2 : t2MovRRCopro<0b1111, "mcrr2", 0,
Bruno Cardoso Lopes0a69ba32011-05-03 17:29:29 +00003839 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt,
3840 GPR:$Rt2, imm:$CRm)]>;
Jim Grosbache35c5e02011-07-13 21:35:10 +00003841/* from coprocessor to ARM core register */
3842def t2MRRC : t2MovRRCopro<0b1110, "mrrc", 1>;
3843
3844def t2MRRC2 : t2MovRRCopro<0b1111, "mrrc2", 1>;
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00003845
Bruno Cardoso Lopes8dd37f72011-01-20 18:32:09 +00003846//===----------------------------------------------------------------------===//
Jim Grosbach9bb098a2011-07-13 21:14:23 +00003847// Other Coprocessor Instructions.
Bruno Cardoso Lopes8dd37f72011-01-20 18:32:09 +00003848//
3849
Jim Grosbach1cbb0c12011-07-13 22:06:11 +00003850def tCDP : T2Cop<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
Jim Grosbach83ab0702011-07-13 22:01:08 +00003851 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
Jim Grosbach9bb098a2011-07-13 21:14:23 +00003852 "cdp\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
3853 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3854 imm:$CRm, imm:$opc2)]> {
3855 let Inst{27-24} = 0b1110;
3856
3857 bits<4> opc1;
3858 bits<4> CRn;
3859 bits<4> CRd;
3860 bits<4> cop;
3861 bits<3> opc2;
3862 bits<4> CRm;
3863
3864 let Inst{3-0} = CRm;
3865 let Inst{4} = 0;
3866 let Inst{7-5} = opc2;
3867 let Inst{11-8} = cop;
3868 let Inst{15-12} = CRd;
3869 let Inst{19-16} = CRn;
3870 let Inst{23-20} = opc1;
3871}
3872
Jim Grosbach1cbb0c12011-07-13 22:06:11 +00003873def t2CDP2 : T2Cop<0b1111, (outs), (ins p_imm:$cop, imm0_15:$opc1,
Jim Grosbach83ab0702011-07-13 22:01:08 +00003874 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
Bruno Cardoso Lopes8dd37f72011-01-20 18:32:09 +00003875 "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
Bruno Cardoso Lopes0a69ba32011-05-03 17:29:29 +00003876 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3877 imm:$CRm, imm:$opc2)]> {
Bruno Cardoso Lopes8dd37f72011-01-20 18:32:09 +00003878 let Inst{27-24} = 0b1110;
3879
3880 bits<4> opc1;
3881 bits<4> CRn;
3882 bits<4> CRd;
3883 bits<4> cop;
3884 bits<3> opc2;
3885 bits<4> CRm;
3886
3887 let Inst{3-0} = CRm;
3888 let Inst{4} = 0;
3889 let Inst{7-5} = opc2;
3890 let Inst{11-8} = cop;
3891 let Inst{15-12} = CRd;
3892 let Inst{19-16} = CRn;
3893 let Inst{23-20} = opc1;
3894}
Jim Grosbachc5a8c862011-07-27 16:47:19 +00003895
3896
3897
3898//===----------------------------------------------------------------------===//
3899// Non-Instruction Patterns
3900//
3901
3902// SXT/UXT with no rotate
Jim Grosbach70327412011-07-27 17:48:13 +00003903let AddedComplexity = 16 in {
3904def : T2Pat<(and rGPR:$Rm, 0x000000FF), (t2UXTB rGPR:$Rm, 0)>,
Eli Friedman2cb1dfa2011-08-08 19:49:37 +00003905 Requires<[IsThumb2]>;
Jim Grosbach70327412011-07-27 17:48:13 +00003906def : T2Pat<(and rGPR:$Rm, 0x0000FFFF), (t2UXTH rGPR:$Rm, 0)>,
Eli Friedman2cb1dfa2011-08-08 19:49:37 +00003907 Requires<[IsThumb2]>;
Jim Grosbach70327412011-07-27 17:48:13 +00003908def : T2Pat<(and rGPR:$Rm, 0x00FF00FF), (t2UXTB16 rGPR:$Rm, 0)>,
3909 Requires<[HasT2ExtractPack, IsThumb2]>;
3910def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0x00FF)),
3911 (t2UXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
3912 Requires<[HasT2ExtractPack, IsThumb2]>;
3913def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0xFFFF)),
3914 (t2UXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
3915 Requires<[HasT2ExtractPack, IsThumb2]>;
3916}
Jim Grosbachc5a8c862011-07-27 16:47:19 +00003917
Jim Grosbach70327412011-07-27 17:48:13 +00003918def : T2Pat<(sext_inreg rGPR:$Src, i8), (t2SXTB rGPR:$Src, 0)>,
Eli Friedman2cb1dfa2011-08-08 19:49:37 +00003919 Requires<[IsThumb2]>;
Jim Grosbach70327412011-07-27 17:48:13 +00003920def : T2Pat<(sext_inreg rGPR:$Src, i16), (t2SXTH rGPR:$Src, 0)>,
Eli Friedman2cb1dfa2011-08-08 19:49:37 +00003921 Requires<[IsThumb2]>;
Jim Grosbach70327412011-07-27 17:48:13 +00003922def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i8)),
3923 (t2SXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
3924 Requires<[HasT2ExtractPack, IsThumb2]>;
3925def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i16)),
3926 (t2SXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
3927 Requires<[HasT2ExtractPack, IsThumb2]>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003928
3929// Atomic load/store patterns
Jakob Stoklund Olesencff9baa2012-08-28 03:11:27 +00003930def : T2Pat<(atomic_load_8 t2addrmode_imm12:$addr),
3931 (t2LDRBi12 t2addrmode_imm12:$addr)>;
3932def : T2Pat<(atomic_load_8 t2addrmode_negimm8:$addr),
3933 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003934def : T2Pat<(atomic_load_8 t2addrmode_so_reg:$addr),
Jakob Stoklund Olesencff9baa2012-08-28 03:11:27 +00003935 (t2LDRBs t2addrmode_so_reg:$addr)>;
3936def : T2Pat<(atomic_load_16 t2addrmode_imm12:$addr),
3937 (t2LDRHi12 t2addrmode_imm12:$addr)>;
3938def : T2Pat<(atomic_load_16 t2addrmode_negimm8:$addr),
3939 (t2LDRHi8 t2addrmode_negimm8:$addr)>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003940def : T2Pat<(atomic_load_16 t2addrmode_so_reg:$addr),
Jakob Stoklund Olesencff9baa2012-08-28 03:11:27 +00003941 (t2LDRHs t2addrmode_so_reg:$addr)>;
3942def : T2Pat<(atomic_load_32 t2addrmode_imm12:$addr),
3943 (t2LDRi12 t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00003944def : T2Pat<(atomic_load_32 t2addrmode_negimm8:$addr),
Jakob Stoklund Olesencff9baa2012-08-28 03:11:27 +00003945 (t2LDRi8 t2addrmode_negimm8:$addr)>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003946def : T2Pat<(atomic_load_32 t2addrmode_so_reg:$addr),
Jakob Stoklund Olesencff9baa2012-08-28 03:11:27 +00003947 (t2LDRs t2addrmode_so_reg:$addr)>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003948def : T2Pat<(atomic_store_8 t2addrmode_imm12:$addr, GPR:$val),
3949 (t2STRBi12 GPR:$val, t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00003950def : T2Pat<(atomic_store_8 t2addrmode_negimm8:$addr, GPR:$val),
3951 (t2STRBi8 GPR:$val, t2addrmode_negimm8:$addr)>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003952def : T2Pat<(atomic_store_8 t2addrmode_so_reg:$addr, GPR:$val),
3953 (t2STRBs GPR:$val, t2addrmode_so_reg:$addr)>;
3954def : T2Pat<(atomic_store_16 t2addrmode_imm12:$addr, GPR:$val),
3955 (t2STRHi12 GPR:$val, t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00003956def : T2Pat<(atomic_store_16 t2addrmode_negimm8:$addr, GPR:$val),
3957 (t2STRHi8 GPR:$val, t2addrmode_negimm8:$addr)>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003958def : T2Pat<(atomic_store_16 t2addrmode_so_reg:$addr, GPR:$val),
3959 (t2STRHs GPR:$val, t2addrmode_so_reg:$addr)>;
3960def : T2Pat<(atomic_store_32 t2addrmode_imm12:$addr, GPR:$val),
3961 (t2STRi12 GPR:$val, t2addrmode_imm12:$addr)>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00003962def : T2Pat<(atomic_store_32 t2addrmode_negimm8:$addr, GPR:$val),
3963 (t2STRi8 GPR:$val, t2addrmode_negimm8:$addr)>;
Eli Friedman069e2ed2011-08-26 02:59:24 +00003964def : T2Pat<(atomic_store_32 t2addrmode_so_reg:$addr, GPR:$val),
3965 (t2STRs GPR:$val, t2addrmode_so_reg:$addr)>;
Jim Grosbach72335d52011-08-31 18:23:08 +00003966
3967
3968//===----------------------------------------------------------------------===//
3969// Assembler aliases
3970//
3971
3972// Aliases for ADC without the ".w" optional width specifier.
3973def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $Rm",
3974 (t2ADCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3975def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $ShiftedRm",
3976 (t2ADCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
3977 pred:$p, cc_out:$s)>;
3978
3979// Aliases for SBC without the ".w" optional width specifier.
3980def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $Rm",
3981 (t2SBCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3982def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $ShiftedRm",
3983 (t2SBCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
3984 pred:$p, cc_out:$s)>;
3985
Jim Grosbachf0851e52011-09-02 18:14:46 +00003986// Aliases for ADD without the ".w" optional width specifier.
Jim Grosbach20ed2e72011-09-01 00:28:52 +00003987def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00003988 (t2ADDri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
Jim Grosbach20ed2e72011-09-01 00:28:52 +00003989def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00003990 (t2ADDri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
Jim Grosbachf0851e52011-09-02 18:14:46 +00003991def : t2InstAlias<"add${s}${p} $Rd, $Rn, $Rm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00003992 (t2ADDrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
Jim Grosbachf0851e52011-09-02 18:14:46 +00003993def : t2InstAlias<"add${s}${p} $Rd, $Rn, $ShiftedRm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00003994 (t2ADDrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
Jim Grosbachf0851e52011-09-02 18:14:46 +00003995 pred:$p, cc_out:$s)>;
Jim Grosbach5d0492c2011-10-28 16:57:07 +00003996// ... and with the destination and source register combined.
3997def : t2InstAlias<"add${s}${p} $Rdn, $imm",
3998 (t2ADDri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
3999def : t2InstAlias<"add${p} $Rdn, $imm",
4000 (t2ADDri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095:$imm, pred:$p)>;
4001def : t2InstAlias<"add${s}${p} $Rdn, $Rm",
4002 (t2ADDrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4003def : t2InstAlias<"add${s}${p} $Rdn, $ShiftedRm",
4004 (t2ADDrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
4005 pred:$p, cc_out:$s)>;
Jim Grosbachef88a922011-09-06 21:44:58 +00004006
Jim Grosbach4e53fe82012-04-05 20:57:13 +00004007// add w/ negative immediates is just a sub.
4008def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
4009 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
4010 cc_out:$s)>;
4011def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
4012 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
4013def : t2InstAlias<"add${s}${p} $Rdn, $imm",
4014 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm_neg:$imm, pred:$p,
4015 cc_out:$s)>;
4016def : t2InstAlias<"add${p} $Rdn, $imm",
4017 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
4018
Jim Grosbach54319e22012-05-01 21:17:34 +00004019def : t2InstAlias<"add${s}${p}.w $Rd, $Rn, $imm",
4020 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
4021 cc_out:$s)>;
4022def : t2InstAlias<"addw${p} $Rd, $Rn, $imm",
4023 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
4024def : t2InstAlias<"add${s}${p}.w $Rdn, $imm",
4025 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm_neg:$imm, pred:$p,
4026 cc_out:$s)>;
4027def : t2InstAlias<"addw${p} $Rdn, $imm",
4028 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
4029
Jim Grosbach4e53fe82012-04-05 20:57:13 +00004030
Jim Grosbachf67e8552011-09-16 22:58:42 +00004031// Aliases for SUB without the ".w" optional width specifier.
4032def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00004033 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
Jim Grosbachf67e8552011-09-16 22:58:42 +00004034def : t2InstAlias<"sub${p} $Rd, $Rn, $imm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00004035 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
Jim Grosbachf67e8552011-09-16 22:58:42 +00004036def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $Rm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00004037 (t2SUBrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
Jim Grosbachf67e8552011-09-16 22:58:42 +00004038def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $ShiftedRm",
Jim Grosbachb95ed6e2011-10-03 20:51:59 +00004039 (t2SUBrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
Jim Grosbachf67e8552011-09-16 22:58:42 +00004040 pred:$p, cc_out:$s)>;
Jim Grosbach5d0492c2011-10-28 16:57:07 +00004041// ... and with the destination and source register combined.
4042def : t2InstAlias<"sub${s}${p} $Rdn, $imm",
4043 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4044def : t2InstAlias<"sub${p} $Rdn, $imm",
4045 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095:$imm, pred:$p)>;
Jim Grosbacha23ecc22012-04-10 17:31:55 +00004046def : t2InstAlias<"sub${s}${p}.w $Rdn, $Rm",
4047 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
Jim Grosbach5d0492c2011-10-28 16:57:07 +00004048def : t2InstAlias<"sub${s}${p} $Rdn, $Rm",
4049 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4050def : t2InstAlias<"sub${s}${p} $Rdn, $ShiftedRm",
4051 (t2SUBrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
4052 pred:$p, cc_out:$s)>;
4053
Jim Grosbachef88a922011-09-06 21:44:58 +00004054// Alias for compares without the ".w" optional width specifier.
4055def : t2InstAlias<"cmn${p} $Rn, $Rm",
4056 (t2CMNzrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4057def : t2InstAlias<"teq${p} $Rn, $Rm",
4058 (t2TEQrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4059def : t2InstAlias<"tst${p} $Rn, $Rm",
4060 (t2TSTrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4061
Jim Grosbach06c1a512011-09-06 22:14:58 +00004062// Memory barriers
Evan Cheng97a45432012-04-27 01:27:19 +00004063def : InstAlias<"dmb", (t2DMB 0xf)>, Requires<[IsThumb, HasDB]>;
4064def : InstAlias<"dsb", (t2DSB 0xf)>, Requires<[IsThumb, HasDB]>;
4065def : InstAlias<"isb", (t2ISB 0xf)>, Requires<[IsThumb, HasDB]>;
Jim Grosbacha8307dd2011-09-07 20:58:57 +00004066
Jim Grosbach0811fe12011-09-09 19:42:40 +00004067// Alias for LDR, LDRB, LDRH, LDRSB, and LDRSH without the ".w" optional
4068// width specifier.
Jim Grosbach8bb5a862011-09-07 21:41:25 +00004069def : t2InstAlias<"ldr${p} $Rt, $addr",
4070 (t2LDRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4071def : t2InstAlias<"ldrb${p} $Rt, $addr",
4072 (t2LDRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4073def : t2InstAlias<"ldrh${p} $Rt, $addr",
4074 (t2LDRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
Jim Grosbach0811fe12011-09-09 19:42:40 +00004075def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4076 (t2LDRSBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4077def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4078 (t2LDRSHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4079
Jim Grosbachab899c12011-09-07 23:10:15 +00004080def : t2InstAlias<"ldr${p} $Rt, $addr",
4081 (t2LDRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4082def : t2InstAlias<"ldrb${p} $Rt, $addr",
4083 (t2LDRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4084def : t2InstAlias<"ldrh${p} $Rt, $addr",
4085 (t2LDRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
Jim Grosbach0811fe12011-09-09 19:42:40 +00004086def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4087 (t2LDRSBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4088def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4089 (t2LDRSHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
Jim Grosbachd32872f2011-09-14 21:24:41 +00004090
Jim Grosbacha5813282011-10-26 22:22:01 +00004091def : t2InstAlias<"ldr${p} $Rt, $addr",
4092 (t2LDRpci GPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4093def : t2InstAlias<"ldrb${p} $Rt, $addr",
4094 (t2LDRBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4095def : t2InstAlias<"ldrh${p} $Rt, $addr",
4096 (t2LDRHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4097def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4098 (t2LDRSBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4099def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4100 (t2LDRSHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4101
Jim Grosbach036a67d2011-10-27 17:16:55 +00004102// Alias for MVN with(out) the ".w" optional width specifier.
4103def : t2InstAlias<"mvn${s}${p}.w $Rd, $imm",
4104 (t2MVNi rGPR:$Rd, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
Jim Grosbachd32872f2011-09-14 21:24:41 +00004105def : t2InstAlias<"mvn${s}${p} $Rd, $Rm",
4106 (t2MVNr rGPR:$Rd, rGPR:$Rm, pred:$p, cc_out:$s)>;
4107def : t2InstAlias<"mvn${s}${p} $Rd, $ShiftedRm",
4108 (t2MVNs rGPR:$Rd, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>;
Jim Grosbach0b692472011-09-14 23:16:41 +00004109
4110// PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4111// shift amount is zero (i.e., unspecified).
4112def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4113 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>,
4114 Requires<[HasT2ExtractPack, IsThumb2]>;
4115def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4116 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>,
4117 Requires<[HasT2ExtractPack, IsThumb2]>;
4118
Jim Grosbach57b21e42011-09-15 15:55:04 +00004119// PUSH/POP aliases for STM/LDM
4120def : t2InstAlias<"push${p}.w $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
4121def : t2InstAlias<"push${p} $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
4122def : t2InstAlias<"pop${p}.w $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4123def : t2InstAlias<"pop${p} $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4124
Jim Grosbach8524bca2011-12-07 18:32:28 +00004125// STMIA/STMIA_UPD aliases w/o the optional .w suffix
4126def : t2InstAlias<"stm${p} $Rn, $regs",
4127 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4128def : t2InstAlias<"stm${p} $Rn!, $regs",
4129 (t2STMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4130
4131// LDMIA/LDMIA_UPD aliases w/o the optional .w suffix
4132def : t2InstAlias<"ldm${p} $Rn, $regs",
4133 (t2LDMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4134def : t2InstAlias<"ldm${p} $Rn!, $regs",
4135 (t2LDMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4136
Jim Grosbach3c5d6e42011-11-09 23:44:23 +00004137// STMDB/STMDB_UPD aliases w/ the optional .w suffix
4138def : t2InstAlias<"stmdb${p}.w $Rn, $regs",
4139 (t2STMDB GPR:$Rn, pred:$p, reglist:$regs)>;
4140def : t2InstAlias<"stmdb${p}.w $Rn!, $regs",
4141 (t2STMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4142
Jim Grosbach88484c02011-10-27 17:33:59 +00004143// LDMDB/LDMDB_UPD aliases w/ the optional .w suffix
4144def : t2InstAlias<"ldmdb${p}.w $Rn, $regs",
4145 (t2LDMDB GPR:$Rn, pred:$p, reglist:$regs)>;
4146def : t2InstAlias<"ldmdb${p}.w $Rn!, $regs",
4147 (t2LDMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4148
Jim Grosbach689b86e2011-09-15 19:46:13 +00004149// Alias for REV/REV16/REVSH without the ".w" optional width specifier.
Jim Grosbach1b69a122011-09-15 18:13:30 +00004150def : t2InstAlias<"rev${p} $Rd, $Rm", (t2REV rGPR:$Rd, rGPR:$Rm, pred:$p)>;
Jim Grosbach689b86e2011-09-15 19:46:13 +00004151def : t2InstAlias<"rev16${p} $Rd, $Rm", (t2REV16 rGPR:$Rd, rGPR:$Rm, pred:$p)>;
4152def : t2InstAlias<"revsh${p} $Rd, $Rm", (t2REVSH rGPR:$Rd, rGPR:$Rm, pred:$p)>;
Jim Grosbach191d33f2011-09-15 20:54:14 +00004153
4154
4155// Alias for RSB without the ".w" optional width specifier, and with optional
4156// implied destination register.
4157def : t2InstAlias<"rsb${s}${p} $Rd, $Rn, $imm",
4158 (t2RSBri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4159def : t2InstAlias<"rsb${s}${p} $Rdn, $imm",
4160 (t2RSBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4161def : t2InstAlias<"rsb${s}${p} $Rdn, $Rm",
4162 (t2RSBrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4163def : t2InstAlias<"rsb${s}${p} $Rdn, $ShiftedRm",
4164 (t2RSBrs rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p,
4165 cc_out:$s)>;
Jim Grosbachb105b992011-09-16 18:32:30 +00004166
4167// SSAT/USAT optional shift operand.
4168def : t2InstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4169 (t2SSAT rGPR:$Rd, imm1_32:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
4170def : t2InstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4171 (t2USAT rGPR:$Rd, imm0_31:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
4172
Jim Grosbach8213c962011-09-16 20:50:13 +00004173// STM w/o the .w suffix.
4174def : t2InstAlias<"stm${p} $Rn, $regs",
4175 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
Jim Grosbach642caea2011-09-16 21:06:12 +00004176
4177// Alias for STR, STRB, and STRH without the ".w" optional
4178// width specifier.
4179def : t2InstAlias<"str${p} $Rt, $addr",
4180 (t2STRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4181def : t2InstAlias<"strb${p} $Rt, $addr",
4182 (t2STRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4183def : t2InstAlias<"strh${p} $Rt, $addr",
4184 (t2STRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4185
4186def : t2InstAlias<"str${p} $Rt, $addr",
4187 (t2STRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4188def : t2InstAlias<"strb${p} $Rt, $addr",
4189 (t2STRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4190def : t2InstAlias<"strh${p} $Rt, $addr",
4191 (t2STRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
Jim Grosbach8a8d28b2011-09-19 17:56:37 +00004192
4193// Extend instruction optional rotate operand.
4194def : t2InstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4195 (t2SXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4196def : t2InstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4197 (t2SXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4198def : t2InstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4199 (t2SXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
Jim Grosbach25ddc2b2011-09-27 22:18:54 +00004200
Jim Grosbach326efe52011-09-19 20:29:33 +00004201def : t2InstAlias<"sxtb${p} $Rd, $Rm",
4202 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4203def : t2InstAlias<"sxtb16${p} $Rd, $Rm",
4204 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4205def : t2InstAlias<"sxth${p} $Rd, $Rm",
4206 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
Jim Grosbach25ddc2b2011-09-27 22:18:54 +00004207def : t2InstAlias<"sxtb${p}.w $Rd, $Rm",
4208 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4209def : t2InstAlias<"sxth${p}.w $Rd, $Rm",
4210 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
Jim Grosbach326efe52011-09-19 20:29:33 +00004211
Jim Grosbach50f1c372011-09-20 00:46:54 +00004212def : t2InstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4213 (t2UXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4214def : t2InstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4215 (t2UXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4216def : t2InstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4217 (t2UXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4218def : t2InstAlias<"uxtb${p} $Rd, $Rm",
4219 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4220def : t2InstAlias<"uxtb16${p} $Rd, $Rm",
4221 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4222def : t2InstAlias<"uxth${p} $Rd, $Rm",
4223 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4224
Jim Grosbach25ddc2b2011-09-27 22:18:54 +00004225def : t2InstAlias<"uxtb${p}.w $Rd, $Rm",
4226 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4227def : t2InstAlias<"uxth${p}.w $Rd, $Rm",
4228 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4229
Jim Grosbach326efe52011-09-19 20:29:33 +00004230// Extend instruction w/o the ".w" optional width specifier.
Jim Grosbach50f1c372011-09-20 00:46:54 +00004231def : t2InstAlias<"uxtb${p} $Rd, $Rm$rot",
4232 (t2UXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4233def : t2InstAlias<"uxtb16${p} $Rd, $Rm$rot",
4234 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4235def : t2InstAlias<"uxth${p} $Rd, $Rm$rot",
4236 (t2UXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4237
Jim Grosbach326efe52011-09-19 20:29:33 +00004238def : t2InstAlias<"sxtb${p} $Rd, $Rm$rot",
4239 (t2SXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4240def : t2InstAlias<"sxtb16${p} $Rd, $Rm$rot",
4241 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4242def : t2InstAlias<"sxth${p} $Rd, $Rm$rot",
4243 (t2SXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
Jim Grosbach89a63372011-10-28 22:36:30 +00004244
4245
4246// "mov Rd, t2_so_imm_not" can be handled via "mvn" in assembly, just like
4247// for isel.
4248def : t2InstAlias<"mov${p} $Rd, $imm",
4249 (t2MVNi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>;
Jim Grosbach46777082011-12-14 17:56:51 +00004250def : t2InstAlias<"mvn${p} $Rd, $imm",
4251 (t2MOVi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>;
Jim Grosbach840bf7e2011-12-09 22:02:17 +00004252// Same for AND <--> BIC
4253def : t2InstAlias<"bic${s}${p} $Rd, $Rn, $imm",
4254 (t2ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
4255 pred:$p, cc_out:$s)>;
4256def : t2InstAlias<"bic${s}${p} $Rdn, $imm",
4257 (t2ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
4258 pred:$p, cc_out:$s)>;
4259def : t2InstAlias<"and${s}${p} $Rd, $Rn, $imm",
4260 (t2BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
4261 pred:$p, cc_out:$s)>;
4262def : t2InstAlias<"and${s}${p} $Rdn, $imm",
4263 (t2BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
4264 pred:$p, cc_out:$s)>;
Jim Grosbach8d11c632011-12-14 17:30:24 +00004265// Likewise, "add Rd, t2_so_imm_neg" -> sub
Jim Grosbach3bc8a3d2011-12-08 00:31:07 +00004266def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
4267 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm,
4268 pred:$p, cc_out:$s)>;
4269def : t2InstAlias<"add${s}${p} $Rd, $imm",
4270 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rd, t2_so_imm_neg:$imm,
4271 pred:$p, cc_out:$s)>;
Jim Grosbach8d11c632011-12-14 17:30:24 +00004272// Same for CMP <--> CMN via t2_so_imm_neg
4273def : t2InstAlias<"cmp${p} $Rd, $imm",
Bill Wendlingad5c8802012-06-11 08:07:26 +00004274 (t2CMNri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
Jim Grosbach8d11c632011-12-14 17:30:24 +00004275def : t2InstAlias<"cmn${p} $Rd, $imm",
4276 (t2CMPri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
Jim Grosbach7f1ec952011-11-15 19:55:16 +00004277
4278
4279// Wide 'mul' encoding can be specified with only two operands.
4280def : t2InstAlias<"mul${p} $Rn, $Rm",
Jim Grosbachcf9814d2011-12-06 05:03:45 +00004281 (t2MUL rGPR:$Rn, rGPR:$Rm, rGPR:$Rn, pred:$p)>;
Jim Grosbache91e7bc2011-12-13 20:23:22 +00004282
4283// "neg" is and alias for "rsb rd, rn, #0"
4284def : t2InstAlias<"neg${s}${p} $Rd, $Rm",
4285 (t2RSBri rGPR:$Rd, rGPR:$Rm, 0, pred:$p, cc_out:$s)>;
Jim Grosbach863d2af2011-12-13 22:45:11 +00004286
4287// MOV so_reg assembler pseudos. InstAlias isn't expressive enough for
4288// these, unfortunately.
4289def t2MOVsi: t2AsmPseudo<"mov${p} $Rd, $shift",
4290 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
4291def t2MOVSsi: t2AsmPseudo<"movs${p} $Rd, $shift",
4292 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
Jim Grosbachb6744db2011-12-15 23:52:17 +00004293
Jim Grosbach2cc5cda2011-12-21 20:54:00 +00004294def t2MOVsr: t2AsmPseudo<"mov${p} $Rd, $shift",
4295 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
4296def t2MOVSsr: t2AsmPseudo<"movs${p} $Rd, $shift",
4297 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
4298
Jim Grosbachb6744db2011-12-15 23:52:17 +00004299// ADR w/o the .w suffix
4300def : t2InstAlias<"adr${p} $Rd, $addr",
4301 (t2ADR rGPR:$Rd, t2adrlabel:$addr, pred:$p)>;
Jim Grosbach0b4c6732012-01-18 22:46:46 +00004302
4303// LDR(literal) w/ alternate [pc, #imm] syntax.
4304def t2LDRpcrel : t2AsmPseudo<"ldr${p} $Rt, $addr",
4305 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4306def t2LDRBpcrel : t2AsmPseudo<"ldrb${p} $Rt, $addr",
4307 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4308def t2LDRHpcrel : t2AsmPseudo<"ldrh${p} $Rt, $addr",
4309 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4310def t2LDRSBpcrel : t2AsmPseudo<"ldrsb${p} $Rt, $addr",
4311 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4312def t2LDRSHpcrel : t2AsmPseudo<"ldrsh${p} $Rt, $addr",
4313 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4314 // Version w/ the .w suffix.
4315def : t2InstAlias<"ldr${p}.w $Rt, $addr",
4316 (t2LDRpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4317def : t2InstAlias<"ldrb${p}.w $Rt, $addr",
4318 (t2LDRBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4319def : t2InstAlias<"ldrh${p}.w $Rt, $addr",
4320 (t2LDRHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4321def : t2InstAlias<"ldrsb${p}.w $Rt, $addr",
4322 (t2LDRSBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4323def : t2InstAlias<"ldrsh${p}.w $Rt, $addr",
4324 (t2LDRSHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
Jim Grosbach12a88632012-01-21 00:07:56 +00004325
4326def : t2InstAlias<"add${p} $Rd, pc, $imm",
4327 (t2ADR rGPR:$Rd, imm0_4095:$imm, pred:$p)>;