blob: e233b45306d1414fb1644c22e6dd1993924d147a [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===- ARMInstrVFP.td - VFP support for ARM -------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
Jim Grosbache5d20f92008-09-11 21:41:29 +000010// This file describes the ARM VFP instruction set.
Evan Chenga8e29892007-01-19 07:51:42 +000011//
12//===----------------------------------------------------------------------===//
13
Evan Chenga8e29892007-01-19 07:51:42 +000014def SDT_FTOI :
15SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
16def SDT_ITOF :
17SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
18def SDT_CMPFP0 :
19SDTypeProfile<0, 1, [SDTCisFP<0>]>;
Jim Grosbache5165492009-11-09 00:11:35 +000020def SDT_VMOVDRR :
Evan Chenga8e29892007-01-19 07:51:42 +000021SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
22 SDTCisSameAs<1, 2>]>;
23
Bob Wilson76a312b2010-03-19 22:51:32 +000024def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
25def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
26def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
27def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
Chris Lattner48be23c2008-01-15 22:02:54 +000028def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInFlag,SDNPOutFlag]>;
Evan Cheng96581d32008-11-11 02:11:05 +000029def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
30def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0",SDT_CMPFP0, [SDNPOutFlag]>;
Jim Grosbache5165492009-11-09 00:11:35 +000031def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
Evan Chenga8e29892007-01-19 07:51:42 +000032
33//===----------------------------------------------------------------------===//
Evan Cheng39382422009-10-28 01:44:26 +000034// Operand Definitions.
35//
36
37
38def vfp_f32imm : Operand<f32>,
39 PatLeaf<(f32 fpimm), [{
40 return ARM::getVFPf32Imm(N->getValueAPF()) != -1;
41 }]> {
42 let PrintMethod = "printVFPf32ImmOperand";
43}
44
45def vfp_f64imm : Operand<f64>,
46 PatLeaf<(f64 fpimm), [{
47 return ARM::getVFPf64Imm(N->getValueAPF()) != -1;
48 }]> {
49 let PrintMethod = "printVFPf64ImmOperand";
50}
51
52
53//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +000054// Load / store Instructions.
55//
56
Dan Gohmanbc9d98b2010-02-27 23:47:46 +000057let canFoldAsLoad = 1, isReMaterializable = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +000058def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$dst), (ins addrmode5:$addr),
59 IIC_fpLoad64, "vldr", ".64\t$dst, $addr",
Chris Lattnerd10a53d2010-03-08 18:51:21 +000060 [(set DPR:$dst, (f64 (load addrmode5:$addr)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +000061
Jim Grosbache5165492009-11-09 00:11:35 +000062def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$dst), (ins addrmode5:$addr),
63 IIC_fpLoad32, "vldr", ".32\t$dst, $addr",
Evan Chenga8e29892007-01-19 07:51:42 +000064 [(set SPR:$dst, (load addrmode5:$addr))]>;
Dan Gohman15511cf2008-12-03 18:15:48 +000065} // canFoldAsLoad
Evan Chenga8e29892007-01-19 07:51:42 +000066
Jim Grosbache5165492009-11-09 00:11:35 +000067def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$src, addrmode5:$addr),
68 IIC_fpStore64, "vstr", ".64\t$src, $addr",
Chris Lattnerd10a53d2010-03-08 18:51:21 +000069 [(store (f64 DPR:$src), addrmode5:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +000070
Jim Grosbache5165492009-11-09 00:11:35 +000071def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$src, addrmode5:$addr),
72 IIC_fpStore32, "vstr", ".32\t$src, $addr",
Evan Chenga8e29892007-01-19 07:51:42 +000073 [(store SPR:$src, addrmode5:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +000074
75//===----------------------------------------------------------------------===//
76// Load / store multiple Instructions.
77//
78
Evan Cheng5fd1c9b2010-05-19 06:07:03 +000079let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
Jim Grosbach72db1822010-09-08 00:25:50 +000080def VLDMD : AXDI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$dsts,
Evan Cheng5a50cee2010-10-07 01:50:48 +000081 variable_ops), IndexModeNone, IIC_fpLoad_m,
Bob Wilsond4bfd542010-08-27 23:18:17 +000082 "vldm${addr:submode}${p}\t$addr, $dsts", "", []> {
Evan Chengcd8e66a2008-11-11 21:48:44 +000083 let Inst{20} = 1;
84}
Evan Chenga8e29892007-01-19 07:51:42 +000085
Jim Grosbach72db1822010-09-08 00:25:50 +000086def VLDMS : AXSI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$dsts,
Evan Cheng5a50cee2010-10-07 01:50:48 +000087 variable_ops), IndexModeNone, IIC_fpLoad_m,
Bob Wilsond4bfd542010-08-27 23:18:17 +000088 "vldm${addr:submode}${p}\t$addr, $dsts", "", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +000089 let Inst{20} = 1;
90}
91
Jim Grosbach72db1822010-09-08 00:25:50 +000092def VLDMD_UPD : AXDI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +000093 reglist:$dsts, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +000094 IndexModeUpd, IIC_fpLoad_mu,
Bob Wilsond4bfd542010-08-27 23:18:17 +000095 "vldm${addr:submode}${p}\t$addr!, $dsts",
96 "$addr.addr = $wb", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +000097 let Inst{20} = 1;
98}
99
Jim Grosbach72db1822010-09-08 00:25:50 +0000100def VLDMS_UPD : AXSI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +0000101 reglist:$dsts, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +0000102 IndexModeUpd, IIC_fpLoad_mu,
Bob Wilsond4bfd542010-08-27 23:18:17 +0000103 "vldm${addr:submode}${p}\t$addr!, $dsts",
104 "$addr.addr = $wb", []> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000105 let Inst{20} = 1;
106}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000107} // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
Evan Chenga8e29892007-01-19 07:51:42 +0000108
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000109let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
Jim Grosbach72db1822010-09-08 00:25:50 +0000110def VSTMD : AXDI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$srcs,
Evan Cheng5a50cee2010-10-07 01:50:48 +0000111 variable_ops), IndexModeNone, IIC_fpStore_m,
Bob Wilsond4bfd542010-08-27 23:18:17 +0000112 "vstm${addr:submode}${p}\t$addr, $srcs", "", []> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000113 let Inst{20} = 0;
114}
Evan Chenga8e29892007-01-19 07:51:42 +0000115
Jim Grosbach72db1822010-09-08 00:25:50 +0000116def VSTMS : AXSI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$srcs,
Evan Cheng5a50cee2010-10-07 01:50:48 +0000117 variable_ops), IndexModeNone, IIC_fpStore_m,
Bob Wilsond4bfd542010-08-27 23:18:17 +0000118 "vstm${addr:submode}${p}\t$addr, $srcs", "", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +0000119 let Inst{20} = 0;
120}
121
Jim Grosbach72db1822010-09-08 00:25:50 +0000122def VSTMD_UPD : AXDI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +0000123 reglist:$srcs, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +0000124 IndexModeUpd, IIC_fpStore_mu,
Bob Wilsond4bfd542010-08-27 23:18:17 +0000125 "vstm${addr:submode}${p}\t$addr!, $srcs",
126 "$addr.addr = $wb", []> {
Bob Wilson815baeb2010-03-13 01:08:20 +0000127 let Inst{20} = 0;
128}
129
Jim Grosbach72db1822010-09-08 00:25:50 +0000130def VSTMS_UPD : AXSI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +0000131 reglist:$srcs, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +0000132 IndexModeUpd, IIC_fpStore_mu,
Bob Wilsond4bfd542010-08-27 23:18:17 +0000133 "vstm${addr:submode}${p}\t$addr!, $srcs",
134 "$addr.addr = $wb", []> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000135 let Inst{20} = 0;
136}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000137} // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
Evan Chenga8e29892007-01-19 07:51:42 +0000138
139// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
140
Bill Wendling52061f82010-10-12 23:06:54 +0000141
142// FIXME: Can these be placed into the base class?
143class ADbI_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
144 dag iops, InstrItinClass itin, string opc, string asm,
145 list<dag> pattern>
146 : ADbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
147 // Instruction operands.
148 bits<5> Dd;
149 bits<5> Dn;
150 bits<5> Dm;
151
152 // Encode instruction operands.
153 let Inst{3-0} = Dm{3-0};
154 let Inst{5} = Dm{4};
155 let Inst{19-16} = Dn{3-0};
156 let Inst{7} = Dn{4};
157 let Inst{15-12} = Dd{3-0};
158 let Inst{22} = Dd{4};
159}
160
161class ASbIn_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
162 dag iops, InstrItinClass itin, string opc, string asm,
163 list<dag> pattern>
164 : ASbIn<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
165 // Instruction operands.
166 bits<5> Sd;
167 bits<5> Sn;
168 bits<5> Sm;
169
170 // Encode instruction operands.
171 let Inst{3-0} = Sm{4-1};
172 let Inst{5} = Sm{0};
173 let Inst{19-16} = Sn{4-1};
174 let Inst{7} = Sn{0};
175 let Inst{15-12} = Sd{4-1};
176 let Inst{22} = Sd{0};
177}
178
179
Evan Chenga8e29892007-01-19 07:51:42 +0000180//===----------------------------------------------------------------------===//
181// FP Binary Operations.
182//
183
Bill Wendling52061f82010-10-12 23:06:54 +0000184def VADDD : ADbI_Encode<0b11100, 0b11, 0, 0,
185 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
186 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
187 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
Bill Wendling174777b2010-10-12 22:08:41 +0000188
Bill Wendling52061f82010-10-12 23:06:54 +0000189def VADDS : ASbIn_Encode<0b11100, 0b11, 0, 0,
190 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
191 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
192 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000193
Bill Wendling52061f82010-10-12 23:06:54 +0000194def VSUBD : ADbI_Encode<0b11100, 0b11, 1, 0,
195 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
196 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
197 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
Jim Grosbach499e8862010-10-12 21:22:40 +0000198
Bill Wendling52061f82010-10-12 23:06:54 +0000199def VSUBS : ASbIn_Encode<0b11100, 0b11, 1, 0,
200 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
201 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
202 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000203
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000204def VDIVD : ADbI<0b11101, 0b00, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000205 IIC_fpDIV64, "vdiv", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000206 [(set DPR:$dst, (fdiv DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000207
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000208def VDIVS : ASbI<0b11101, 0b00, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000209 IIC_fpDIV32, "vdiv", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000210 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
211
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000212def VMULD : ADbI<0b11100, 0b10, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000213 IIC_fpMUL64, "vmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000214 [(set DPR:$dst, (fmul DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000215
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000216def VMULS : ASbIn<0b11100, 0b10, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000217 IIC_fpMUL32, "vmul", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000218 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
Jim Grosbache5165492009-11-09 00:11:35 +0000219
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000220def VNMULD : ADbI<0b11100, 0b10, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000221 IIC_fpMUL64, "vnmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000222 [(set DPR:$dst, (fneg (fmul DPR:$a, (f64 DPR:$b))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000223
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000224def VNMULS : ASbI<0b11100, 0b10, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000225 IIC_fpMUL32, "vnmul", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000226 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000227
Chris Lattner72939122007-05-03 00:32:00 +0000228// Match reassociated forms only if not sign dependent rounding.
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000229def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000230 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000231def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000232 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000233
234
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000235// These are encoded as unary instructions.
236let Defs = [FPSCR] in {
237def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs),(ins DPR:$Dd, DPR:$Dm),
238 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
239 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]> {
240 // Instruction operands.
241 bits<5> Dd;
242 bits<5> Dm;
Evan Chenga8e29892007-01-19 07:51:42 +0000243
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000244 // Encode instruction operands.
245 let Inst{3-0} = Dm{3-0};
246 let Inst{5} = Dm{4};
247 let Inst{15-12} = Dd{3-0};
248 let Inst{22} = Dd{4};
249}
250
251def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs),(ins SPR:$Sd, SPR:$Sm),
252 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
253 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> {
254 // Instruction operands.
255 bits<5> Sd;
256 bits<5> Sm;
257
258 // Encode instruction operands.
259 let Inst{3-0} = Sm{4-1};
260 let Inst{5} = Sm{0};
261 let Inst{15-12} = Sd{4-1};
262 let Inst{22} = Sd{0};
263}
264
265def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins DPR:$a, DPR:$b),
266 IIC_fpCMP64, "vcmp", ".f64\t$a, $b",
267 [/* For disassembly only; pattern left blank */]>;
268
269def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins SPR:$a, SPR:$b),
270 IIC_fpCMP32, "vcmp", ".f32\t$a, $b",
271 [/* For disassembly only; pattern left blank */]>;
272}
Evan Chenga8e29892007-01-19 07:51:42 +0000273
274//===----------------------------------------------------------------------===//
275// FP Unary Operations.
276//
277
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000278def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000279 IIC_fpUNA64, "vabs", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000280 [(set DPR:$dst, (fabs (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000281
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000282def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000283 IIC_fpUNA32, "vabs", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000284 [(set SPR:$dst, (fabs SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000285
Evan Cheng91449a82009-07-20 02:12:31 +0000286let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000287def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins DPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000288 IIC_fpCMP64, "vcmpe", ".f64\t$a, #0",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000289 [(arm_cmpfp0 (f64 DPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000290
Johnny Chen7edd8e32010-02-08 19:41:48 +0000291def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins DPR:$a),
292 IIC_fpCMP64, "vcmp", ".f64\t$a, #0",
293 [/* For disassembly only; pattern left blank */]>;
294
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000295def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins SPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000296 IIC_fpCMP32, "vcmpe", ".f32\t$a, #0",
Evan Chenga8e29892007-01-19 07:51:42 +0000297 [(arm_cmpfp0 SPR:$a)]>;
Johnny Chen7edd8e32010-02-08 19:41:48 +0000298
299def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins SPR:$a),
300 IIC_fpCMP32, "vcmp", ".f32\t$a, #0",
301 [/* For disassembly only; pattern left blank */]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000302}
Evan Chenga8e29892007-01-19 07:51:42 +0000303
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000304def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000305 IIC_fpCVTDS, "vcvt", ".f64.f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000306 [(set DPR:$dst, (fextend SPR:$a))]>;
307
Evan Cheng96581d32008-11-11 02:11:05 +0000308// Special case encoding: bits 11-8 is 0b1011.
Jim Grosbache5165492009-11-09 00:11:35 +0000309def VCVTSD : VFPAI<(outs SPR:$dst), (ins DPR:$a), VFPUnaryFrm,
310 IIC_fpCVTSD, "vcvt", ".f32.f64\t$dst, $a",
David Goodwin3ca524e2009-07-10 17:03:29 +0000311 [(set SPR:$dst, (fround DPR:$a))]> {
Evan Cheng96581d32008-11-11 02:11:05 +0000312 let Inst{27-23} = 0b11101;
313 let Inst{21-16} = 0b110111;
314 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000315 let Inst{7-6} = 0b11;
316 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000317}
Evan Chenga8e29892007-01-19 07:51:42 +0000318
Johnny Chen2d658df2010-02-09 17:21:56 +0000319// Between half-precision and single-precision. For disassembly only.
320
Jim Grosbach18f30e62010-06-02 21:53:11 +0000321def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000322 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000323 [/* For disassembly only; pattern left blank */]>;
324
Bob Wilson76a312b2010-03-19 22:51:32 +0000325def : ARMPat<(f32_to_f16 SPR:$a),
326 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000327
Jim Grosbach18f30e62010-06-02 21:53:11 +0000328def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000329 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000330 [/* For disassembly only; pattern left blank */]>;
331
Bob Wilson76a312b2010-03-19 22:51:32 +0000332def : ARMPat<(f16_to_f32 GPR:$a),
333 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000334
Jim Grosbach18f30e62010-06-02 21:53:11 +0000335def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000336 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000337 [/* For disassembly only; pattern left blank */]>;
338
Jim Grosbach18f30e62010-06-02 21:53:11 +0000339def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000340 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000341 [/* For disassembly only; pattern left blank */]>;
342
Evan Chengcd799b92009-06-12 20:46:18 +0000343let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000344def VMOVD: ADuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000345 IIC_fpUNA64, "vmov", ".f64\t$dst, $a", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000346
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000347def VMOVS: ASuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000348 IIC_fpUNA32, "vmov", ".f32\t$dst, $a", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000349} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000350
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000351def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000352 IIC_fpUNA64, "vneg", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000353 [(set DPR:$dst, (fneg (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000354
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000355def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000356 IIC_fpUNA32, "vneg", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000357 [(set SPR:$dst, (fneg SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000358
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000359def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000360 IIC_fpSQRT64, "vsqrt", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000361 [(set DPR:$dst, (fsqrt (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000362
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000363def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000364 IIC_fpSQRT32, "vsqrt", ".f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000365 [(set SPR:$dst, (fsqrt SPR:$a))]>;
366
367//===----------------------------------------------------------------------===//
368// FP <-> GPR Copies. Int <-> FP Conversions.
369//
370
Jim Grosbache5165492009-11-09 00:11:35 +0000371def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000372 IIC_fpMOVSI, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000373 [(set GPR:$dst, (bitconvert SPR:$src))]>;
374
Jim Grosbache5165492009-11-09 00:11:35 +0000375def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000376 IIC_fpMOVIS, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000377 [(set SPR:$dst, (bitconvert GPR:$src))]>;
378
Evan Cheng020cc1b2010-05-13 00:16:46 +0000379let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000380def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Evan Chengd20d6582009-10-01 01:33:39 +0000381 (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000382 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src",
Johnny Chen7acca672010-02-05 18:04:58 +0000383 [/* FIXME: Can't write pattern for multiple result instr*/]> {
384 let Inst{7-6} = 0b00;
385}
Evan Chenga8e29892007-01-19 07:51:42 +0000386
Johnny Chen23401d62010-02-08 17:26:09 +0000387def VMOVRRS : AVConv3I<0b11000101, 0b1010,
388 (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000389 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000390 [/* For disassembly only; pattern left blank */]> {
391 let Inst{7-6} = 0b00;
392}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000393} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000394
Evan Chenga8e29892007-01-19 07:51:42 +0000395// FMDHR: GPR -> SPR
396// FMDLR: GPR -> SPR
397
Jim Grosbache5165492009-11-09 00:11:35 +0000398def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Evan Cheng38b6fd62008-12-11 22:02:02 +0000399 (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000400 IIC_fpMOVID, "vmov", "\t$dst, $src1, $src2",
Johnny Chen7acca672010-02-05 18:04:58 +0000401 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]> {
402 let Inst{7-6} = 0b00;
403}
Evan Chenga8e29892007-01-19 07:51:42 +0000404
Evan Cheng020cc1b2010-05-13 00:16:46 +0000405let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000406def VMOVSRR : AVConv5I<0b11000100, 0b1010,
407 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000408 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000409 [/* For disassembly only; pattern left blank */]> {
410 let Inst{7-6} = 0b00;
411}
412
Evan Chenga8e29892007-01-19 07:51:42 +0000413// FMRDH: SPR -> GPR
414// FMRDL: SPR -> GPR
415// FMRRS: SPR -> GPR
416// FMRX : SPR system reg -> GPR
417
418// FMSRR: GPR -> SPR
419
Eric Christopher5371cab2010-09-28 00:35:33 +0000420// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000421
422
423// Int to FP:
424
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000425def VSITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
426 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000427 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000428 [(set DPR:$dst, (f64 (arm_sitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000429 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000430}
Evan Chenga8e29892007-01-19 07:51:42 +0000431
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000432def VSITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
433 (outs SPR:$dst),(ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000434 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000435 [(set SPR:$dst, (arm_sitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000436 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000437}
Evan Chenga8e29892007-01-19 07:51:42 +0000438
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000439def VUITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
440 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000441 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000442 [(set DPR:$dst, (f64 (arm_uitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000443 let Inst{7} = 0; // u32
444}
Evan Chenga8e29892007-01-19 07:51:42 +0000445
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000446def VUITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
447 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000448 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000449 [(set SPR:$dst, (arm_uitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000450 let Inst{7} = 0; // u32
451}
Evan Chenga8e29892007-01-19 07:51:42 +0000452
453// FP to Int:
454// Always set Z bit in the instruction, i.e. "round towards zero" variants.
455
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000456def VTOSIZD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000457 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000458 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000459 [(set SPR:$dst, (arm_ftosi (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000460 let Inst{7} = 1; // Z bit
461}
Evan Chenga8e29892007-01-19 07:51:42 +0000462
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000463def VTOSIZS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000464 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000465 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000466 [(set SPR:$dst, (arm_ftosi SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000467 let Inst{7} = 1; // Z bit
468}
Evan Chenga8e29892007-01-19 07:51:42 +0000469
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000470def VTOUIZD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000471 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000472 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000473 [(set SPR:$dst, (arm_ftoui (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000474 let Inst{7} = 1; // Z bit
475}
Evan Chenga8e29892007-01-19 07:51:42 +0000476
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000477def VTOUIZS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000478 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000479 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000480 [(set SPR:$dst, (arm_ftoui SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000481 let Inst{7} = 1; // Z bit
482}
Evan Chenga8e29892007-01-19 07:51:42 +0000483
Johnny Chen15b423f2010-02-08 22:02:41 +0000484// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
485// For disassembly only.
Nate Begemand1fb5832010-08-03 21:31:55 +0000486let Uses = [FPSCR] in {
Johnny Chen15b423f2010-02-08 22:02:41 +0000487def VTOSIRD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
488 (outs SPR:$dst), (ins DPR:$a),
489 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000490 [(set SPR:$dst, (int_arm_vcvtr (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000491 let Inst{7} = 0; // Z bit
492}
493
494def VTOSIRS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
495 (outs SPR:$dst), (ins SPR:$a),
496 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000497 [(set SPR:$dst, (int_arm_vcvtr SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000498 let Inst{7} = 0; // Z bit
499}
500
501def VTOUIRD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
502 (outs SPR:$dst), (ins DPR:$a),
503 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000504 [(set SPR:$dst, (int_arm_vcvtru (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000505 let Inst{7} = 0; // Z bit
506}
507
508def VTOUIRS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
509 (outs SPR:$dst), (ins SPR:$a),
510 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000511 [(set SPR:$dst, (int_arm_vcvtru SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000512 let Inst{7} = 0; // Z bit
513}
Nate Begemand1fb5832010-08-03 21:31:55 +0000514}
Johnny Chen15b423f2010-02-08 22:02:41 +0000515
Johnny Chen27bb8d02010-02-11 18:17:16 +0000516// Convert between floating-point and fixed-point
517// Data type for fixed-point naming convention:
518// S16 (U=0, sx=0) -> SH
519// U16 (U=1, sx=0) -> UH
520// S32 (U=0, sx=1) -> SL
521// U32 (U=1, sx=1) -> UL
522
523let Constraints = "$a = $dst" in {
524
525// FP to Fixed-Point:
526
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000527let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000528def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
529 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
530 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
531 [/* For disassembly only; pattern left blank */]>;
532
533def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
534 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
535 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
536 [/* For disassembly only; pattern left blank */]>;
537
538def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
539 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
540 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
541 [/* For disassembly only; pattern left blank */]>;
542
543def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
544 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
545 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
546 [/* For disassembly only; pattern left blank */]>;
547
548def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
549 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
550 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
551 [/* For disassembly only; pattern left blank */]>;
552
553def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
554 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
555 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
556 [/* For disassembly only; pattern left blank */]>;
557
558def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
559 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
560 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
561 [/* For disassembly only; pattern left blank */]>;
562
563def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
564 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
565 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
566 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000567}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000568
569// Fixed-Point to FP:
570
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000571let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000572def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
573 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
574 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
575 [/* For disassembly only; pattern left blank */]>;
576
577def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
578 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
579 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
580 [/* For disassembly only; pattern left blank */]>;
581
582def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
583 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
584 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
585 [/* For disassembly only; pattern left blank */]>;
586
587def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
588 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
589 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
590 [/* For disassembly only; pattern left blank */]>;
591
592def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
593 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
594 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
595 [/* For disassembly only; pattern left blank */]>;
596
597def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
598 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
599 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
600 [/* For disassembly only; pattern left blank */]>;
601
602def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
603 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
604 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
605 [/* For disassembly only; pattern left blank */]>;
606
607def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
608 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
609 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
610 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000611}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000612
613} // End of 'let Constraints = "$src = $dst" in'
614
Evan Chenga8e29892007-01-19 07:51:42 +0000615//===----------------------------------------------------------------------===//
616// FP FMA Operations.
617//
618
Jim Grosbach26767372010-03-24 22:31:46 +0000619def VMLAD : ADbI_vmlX<0b11100, 0b00, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000620 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000621 IIC_fpMAC64, "vmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000622 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b),
623 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000624 RegConstraint<"$dstin = $dst">;
625
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000626def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
627 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000628 IIC_fpMAC32, "vmla", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000629 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
630 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000631
Jim Grosbach26767372010-03-24 22:31:46 +0000632def VNMLSD : ADbI_vmlX<0b11100, 0b01, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000633 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000634 IIC_fpMAC64, "vnmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000635 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b),
636 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000637 RegConstraint<"$dstin = $dst">;
638
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000639def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
640 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000641 IIC_fpMAC32, "vnmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000642 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
643 RegConstraint<"$dstin = $dst">;
644
Jim Grosbach26767372010-03-24 22:31:46 +0000645def VMLSD : ADbI_vmlX<0b11100, 0b00, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000646 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000647 IIC_fpMAC64, "vmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000648 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)),
649 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000650 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000651
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000652def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
653 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000654 IIC_fpMAC32, "vmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000655 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000656 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000657
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000658def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
Jim Grosbache5165492009-11-09 00:11:35 +0000659 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000660def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000661 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000662
Jim Grosbach26767372010-03-24 22:31:46 +0000663def VNMLAD : ADbI_vmlX<0b11100, 0b01, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000664 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000665 IIC_fpMAC64, "vnmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000666 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)),
667 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000668 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000669
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000670def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
671 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000672 IIC_fpMAC32, "vnmla", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000673 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000674 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000675
676//===----------------------------------------------------------------------===//
677// FP Conditional moves.
678//
679
Evan Cheng020cc1b2010-05-13 00:16:46 +0000680let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000681def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000682 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000683 IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000684 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
685 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000686
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000687def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000688 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000689 IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000690 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
691 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000692
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000693def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000694 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000695 IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000696 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
697 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000698
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000699def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000700 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000701 IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000702 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
703 RegConstraint<"$false = $dst">;
Evan Cheng020cc1b2010-05-13 00:16:46 +0000704} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +0000705
706//===----------------------------------------------------------------------===//
707// Misc.
708//
709
Evan Cheng1e13c792009-11-10 19:44:56 +0000710// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
711// to APSR.
Evan Cheng91449a82009-07-20 02:12:31 +0000712let Defs = [CPSR], Uses = [FPSCR] in
Jim Grosbache5165492009-11-09 00:11:35 +0000713def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
Jim Grosbachf4cbc0e2009-11-13 01:17:22 +0000714 "\tapsr_nzcv, fpscr",
Evan Chengdd22a452009-10-27 00:20:49 +0000715 [(arm_fmstat)]> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000716 let Inst{27-20} = 0b11101111;
717 let Inst{19-16} = 0b0001;
718 let Inst{15-12} = 0b1111;
719 let Inst{11-8} = 0b1010;
720 let Inst{7} = 0;
721 let Inst{4} = 1;
722}
Evan Cheng39382422009-10-28 01:44:26 +0000723
Johnny Chenc9745042010-02-09 22:35:38 +0000724// FPSCR <-> GPR (for disassembly only)
Nate Begemand1fb5832010-08-03 21:31:55 +0000725let hasSideEffects = 1, Uses = [FPSCR] in
726def VMRS : VFPAI<(outs GPR:$dst), (ins), VFPMiscFrm, IIC_fpSTAT,
727 "vmrs", "\t$dst, fpscr",
728 [(set GPR:$dst, (int_arm_get_fpscr))]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000729 let Inst{27-20} = 0b11101111;
730 let Inst{19-16} = 0b0001;
731 let Inst{11-8} = 0b1010;
732 let Inst{7} = 0;
733 let Inst{4} = 1;
734}
Johnny Chenc9745042010-02-09 22:35:38 +0000735
Nate Begemand1fb5832010-08-03 21:31:55 +0000736let Defs = [FPSCR] in
737def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT,
738 "vmsr", "\tfpscr, $src",
739 [(int_arm_set_fpscr GPR:$src)]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000740 let Inst{27-20} = 0b11101110;
741 let Inst{19-16} = 0b0001;
742 let Inst{11-8} = 0b1010;
743 let Inst{7} = 0;
744 let Inst{4} = 1;
745}
Evan Cheng39382422009-10-28 01:44:26 +0000746
747// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +0000748let isReMaterializable = 1 in {
749def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000750 VFPMiscFrm, IIC_fpUNA64,
Evan Cheng9d172d52009-11-24 01:05:23 +0000751 "vmov", ".f64\t$dst, $imm",
Jim Grosbache5165492009-11-09 00:11:35 +0000752 [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
753 let Inst{27-23} = 0b11101;
754 let Inst{21-20} = 0b11;
755 let Inst{11-9} = 0b101;
756 let Inst{8} = 1;
757 let Inst{7-4} = 0b0000;
758}
759
Evan Cheng39382422009-10-28 01:44:26 +0000760def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000761 VFPMiscFrm, IIC_fpUNA32,
Evan Cheng9d172d52009-11-24 01:05:23 +0000762 "vmov", ".f32\t$dst, $imm",
Evan Cheng39382422009-10-28 01:44:26 +0000763 [(set SPR:$dst, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
764 let Inst{27-23} = 0b11101;
765 let Inst{21-20} = 0b11;
766 let Inst{11-9} = 0b101;
767 let Inst{8} = 0;
768 let Inst{7-4} = 0b0000;
769}
Evan Cheng39382422009-10-28 01:44:26 +0000770}