blob: 5fad39e7c98385936e6d2f586fa15b9e98aa668b [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
141//===----------------------------------------------------------------------===//
142// FP Binary Operations.
143//
144
Bill Wendling174777b2010-10-12 22:08:41 +0000145def VADDD : ADbI<0b11100, 0b11, 0, 0, (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
146 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
147 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]> {
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000148 // Instruction operands.
Bill Wendling174777b2010-10-12 22:08:41 +0000149 bits<5> Dd;
150 bits<5> Dn;
151 bits<5> Dm;
152
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000153 // Encode instruction operands.
Bill Wendling174777b2010-10-12 22:08:41 +0000154 let Inst{3-0} = Dm{3-0};
155 let Inst{5} = Dm{4};
156 let Inst{19-16} = Dn{3-0};
157 let Inst{7} = Dn{4};
158 let Inst{15-12} = Dd{3-0};
159 let Inst{22} = Dd{4};
160}
Evan Chenga8e29892007-01-19 07:51:42 +0000161
Jim Grosbach499e8862010-10-12 21:22:40 +0000162def VADDS : ASbIn<0b11100, 0b11, 0, 0, (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
163 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
164 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]> {
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000165 // Instruction operands.
Jim Grosbach499e8862010-10-12 21:22:40 +0000166 bits<5> Sd;
167 bits<5> Sn;
168 bits<5> Sm;
169
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000170 // Encode instruction operands.
Jim Grosbach499e8862010-10-12 21:22:40 +0000171 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}
Evan Chenga8e29892007-01-19 07:51:42 +0000178
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000179def VSUBD : ADbI<0b11100, 0b11, 1, 0, (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
180 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
181 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]> {
182 // Instruction operands.
183 bits<5> Dd;
184 bits<5> Dn;
185 bits<5> Dm;
Evan Chenga8e29892007-01-19 07:51:42 +0000186
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000187 // Encode instruction operands.
188 let Inst{3-0} = Dm{3-0};
189 let Inst{5} = Dm{4};
190 let Inst{19-16} = Dn{3-0};
191 let Inst{7} = Dn{4};
192 let Inst{15-12} = Dd{3-0};
193 let Inst{22} = Dd{4};
194}
Johnny Chen7edd8e32010-02-08 19:41:48 +0000195
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000196def VSUBS : ASbIn<0b11100, 0b11, 1, 0, (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
197 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
198 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]> {
199 // Instruction operands.
200 bits<5> Sd;
201 bits<5> Sn;
202 bits<5> Sm;
Johnny Chen7edd8e32010-02-08 19:41:48 +0000203
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000204 // Encode instruction operands.
205 let Inst{3-0} = Sm{4-1};
206 let Inst{5} = Sm{0};
207 let Inst{19-16} = Sn{4-1};
208 let Inst{7} = Sn{0};
209 let Inst{15-12} = Sd{4-1};
210 let Inst{22} = Sd{0};
Evan Cheng91449a82009-07-20 02:12:31 +0000211}
Evan Chenga8e29892007-01-19 07:51:42 +0000212
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000213def VDIVD : ADbI<0b11101, 0b00, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000214 IIC_fpDIV64, "vdiv", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000215 [(set DPR:$dst, (fdiv DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000216
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000217def VDIVS : ASbI<0b11101, 0b00, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000218 IIC_fpDIV32, "vdiv", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000219 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
220
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000221def VMULD : ADbI<0b11100, 0b10, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000222 IIC_fpMUL64, "vmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000223 [(set DPR:$dst, (fmul DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000224
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000225def VMULS : ASbIn<0b11100, 0b10, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000226 IIC_fpMUL32, "vmul", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000227 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
Jim Grosbache5165492009-11-09 00:11:35 +0000228
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000229def VNMULD : ADbI<0b11100, 0b10, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000230 IIC_fpMUL64, "vnmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000231 [(set DPR:$dst, (fneg (fmul DPR:$a, (f64 DPR:$b))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000232
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000233def VNMULS : ASbI<0b11100, 0b10, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000234 IIC_fpMUL32, "vnmul", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000235 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000236
Chris Lattner72939122007-05-03 00:32:00 +0000237// Match reassociated forms only if not sign dependent rounding.
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000238def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000239 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000240def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000241 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000242
243
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000244// These are encoded as unary instructions.
245let Defs = [FPSCR] in {
246def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs),(ins DPR:$Dd, DPR:$Dm),
247 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
248 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]> {
249 // Instruction operands.
250 bits<5> Dd;
251 bits<5> Dm;
Evan Chenga8e29892007-01-19 07:51:42 +0000252
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000253 // Encode instruction operands.
254 let Inst{3-0} = Dm{3-0};
255 let Inst{5} = Dm{4};
256 let Inst{15-12} = Dd{3-0};
257 let Inst{22} = Dd{4};
258}
259
260def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs),(ins SPR:$Sd, SPR:$Sm),
261 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
262 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> {
263 // Instruction operands.
264 bits<5> Sd;
265 bits<5> Sm;
266
267 // Encode instruction operands.
268 let Inst{3-0} = Sm{4-1};
269 let Inst{5} = Sm{0};
270 let Inst{15-12} = Sd{4-1};
271 let Inst{22} = Sd{0};
272}
273
274def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins DPR:$a, DPR:$b),
275 IIC_fpCMP64, "vcmp", ".f64\t$a, $b",
276 [/* For disassembly only; pattern left blank */]>;
277
278def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins SPR:$a, SPR:$b),
279 IIC_fpCMP32, "vcmp", ".f32\t$a, $b",
280 [/* For disassembly only; pattern left blank */]>;
281}
Evan Chenga8e29892007-01-19 07:51:42 +0000282
283//===----------------------------------------------------------------------===//
284// FP Unary Operations.
285//
286
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000287def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000288 IIC_fpUNA64, "vabs", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000289 [(set DPR:$dst, (fabs (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000290
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000291def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000292 IIC_fpUNA32, "vabs", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000293 [(set SPR:$dst, (fabs SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000294
Evan Cheng91449a82009-07-20 02:12:31 +0000295let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000296def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins DPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000297 IIC_fpCMP64, "vcmpe", ".f64\t$a, #0",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000298 [(arm_cmpfp0 (f64 DPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000299
Johnny Chen7edd8e32010-02-08 19:41:48 +0000300def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins DPR:$a),
301 IIC_fpCMP64, "vcmp", ".f64\t$a, #0",
302 [/* For disassembly only; pattern left blank */]>;
303
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000304def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins SPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000305 IIC_fpCMP32, "vcmpe", ".f32\t$a, #0",
Evan Chenga8e29892007-01-19 07:51:42 +0000306 [(arm_cmpfp0 SPR:$a)]>;
Johnny Chen7edd8e32010-02-08 19:41:48 +0000307
308def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins SPR:$a),
309 IIC_fpCMP32, "vcmp", ".f32\t$a, #0",
310 [/* For disassembly only; pattern left blank */]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000311}
Evan Chenga8e29892007-01-19 07:51:42 +0000312
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000313def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000314 IIC_fpCVTDS, "vcvt", ".f64.f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000315 [(set DPR:$dst, (fextend SPR:$a))]>;
316
Evan Cheng96581d32008-11-11 02:11:05 +0000317// Special case encoding: bits 11-8 is 0b1011.
Jim Grosbache5165492009-11-09 00:11:35 +0000318def VCVTSD : VFPAI<(outs SPR:$dst), (ins DPR:$a), VFPUnaryFrm,
319 IIC_fpCVTSD, "vcvt", ".f32.f64\t$dst, $a",
David Goodwin3ca524e2009-07-10 17:03:29 +0000320 [(set SPR:$dst, (fround DPR:$a))]> {
Evan Cheng96581d32008-11-11 02:11:05 +0000321 let Inst{27-23} = 0b11101;
322 let Inst{21-16} = 0b110111;
323 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000324 let Inst{7-6} = 0b11;
325 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000326}
Evan Chenga8e29892007-01-19 07:51:42 +0000327
Johnny Chen2d658df2010-02-09 17:21:56 +0000328// Between half-precision and single-precision. For disassembly only.
329
Jim Grosbach18f30e62010-06-02 21:53:11 +0000330def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000331 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000332 [/* For disassembly only; pattern left blank */]>;
333
Bob Wilson76a312b2010-03-19 22:51:32 +0000334def : ARMPat<(f32_to_f16 SPR:$a),
335 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000336
Jim Grosbach18f30e62010-06-02 21:53:11 +0000337def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000338 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000339 [/* For disassembly only; pattern left blank */]>;
340
Bob Wilson76a312b2010-03-19 22:51:32 +0000341def : ARMPat<(f16_to_f32 GPR:$a),
342 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000343
Jim Grosbach18f30e62010-06-02 21:53:11 +0000344def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000345 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000346 [/* For disassembly only; pattern left blank */]>;
347
Jim Grosbach18f30e62010-06-02 21:53:11 +0000348def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000349 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000350 [/* For disassembly only; pattern left blank */]>;
351
Evan Chengcd799b92009-06-12 20:46:18 +0000352let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000353def VMOVD: ADuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000354 IIC_fpUNA64, "vmov", ".f64\t$dst, $a", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000355
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000356def VMOVS: ASuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000357 IIC_fpUNA32, "vmov", ".f32\t$dst, $a", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000358} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000359
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000360def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000361 IIC_fpUNA64, "vneg", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000362 [(set DPR:$dst, (fneg (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000363
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000364def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000365 IIC_fpUNA32, "vneg", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000366 [(set SPR:$dst, (fneg SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000367
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000368def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000369 IIC_fpSQRT64, "vsqrt", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000370 [(set DPR:$dst, (fsqrt (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000371
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000372def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000373 IIC_fpSQRT32, "vsqrt", ".f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000374 [(set SPR:$dst, (fsqrt SPR:$a))]>;
375
376//===----------------------------------------------------------------------===//
377// FP <-> GPR Copies. Int <-> FP Conversions.
378//
379
Jim Grosbache5165492009-11-09 00:11:35 +0000380def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000381 IIC_fpMOVSI, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000382 [(set GPR:$dst, (bitconvert SPR:$src))]>;
383
Jim Grosbache5165492009-11-09 00:11:35 +0000384def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000385 IIC_fpMOVIS, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000386 [(set SPR:$dst, (bitconvert GPR:$src))]>;
387
Evan Cheng020cc1b2010-05-13 00:16:46 +0000388let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000389def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Evan Chengd20d6582009-10-01 01:33:39 +0000390 (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000391 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src",
Johnny Chen7acca672010-02-05 18:04:58 +0000392 [/* FIXME: Can't write pattern for multiple result instr*/]> {
393 let Inst{7-6} = 0b00;
394}
Evan Chenga8e29892007-01-19 07:51:42 +0000395
Johnny Chen23401d62010-02-08 17:26:09 +0000396def VMOVRRS : AVConv3I<0b11000101, 0b1010,
397 (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000398 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000399 [/* For disassembly only; pattern left blank */]> {
400 let Inst{7-6} = 0b00;
401}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000402} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000403
Evan Chenga8e29892007-01-19 07:51:42 +0000404// FMDHR: GPR -> SPR
405// FMDLR: GPR -> SPR
406
Jim Grosbache5165492009-11-09 00:11:35 +0000407def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Evan Cheng38b6fd62008-12-11 22:02:02 +0000408 (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000409 IIC_fpMOVID, "vmov", "\t$dst, $src1, $src2",
Johnny Chen7acca672010-02-05 18:04:58 +0000410 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]> {
411 let Inst{7-6} = 0b00;
412}
Evan Chenga8e29892007-01-19 07:51:42 +0000413
Evan Cheng020cc1b2010-05-13 00:16:46 +0000414let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000415def VMOVSRR : AVConv5I<0b11000100, 0b1010,
416 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000417 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000418 [/* For disassembly only; pattern left blank */]> {
419 let Inst{7-6} = 0b00;
420}
421
Evan Chenga8e29892007-01-19 07:51:42 +0000422// FMRDH: SPR -> GPR
423// FMRDL: SPR -> GPR
424// FMRRS: SPR -> GPR
425// FMRX : SPR system reg -> GPR
426
427// FMSRR: GPR -> SPR
428
Eric Christopher5371cab2010-09-28 00:35:33 +0000429// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000430
431
432// Int to FP:
433
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000434def VSITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
435 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000436 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000437 [(set DPR:$dst, (f64 (arm_sitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000438 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000439}
Evan Chenga8e29892007-01-19 07:51:42 +0000440
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000441def VSITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
442 (outs SPR:$dst),(ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000443 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000444 [(set SPR:$dst, (arm_sitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000445 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000446}
Evan Chenga8e29892007-01-19 07:51:42 +0000447
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000448def VUITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
449 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000450 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000451 [(set DPR:$dst, (f64 (arm_uitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000452 let Inst{7} = 0; // u32
453}
Evan Chenga8e29892007-01-19 07:51:42 +0000454
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000455def VUITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
456 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000457 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000458 [(set SPR:$dst, (arm_uitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000459 let Inst{7} = 0; // u32
460}
Evan Chenga8e29892007-01-19 07:51:42 +0000461
462// FP to Int:
463// Always set Z bit in the instruction, i.e. "round towards zero" variants.
464
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000465def VTOSIZD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000466 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000467 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000468 [(set SPR:$dst, (arm_ftosi (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000469 let Inst{7} = 1; // Z bit
470}
Evan Chenga8e29892007-01-19 07:51:42 +0000471
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000472def VTOSIZS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000473 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000474 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000475 [(set SPR:$dst, (arm_ftosi SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000476 let Inst{7} = 1; // Z bit
477}
Evan Chenga8e29892007-01-19 07:51:42 +0000478
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000479def VTOUIZD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000480 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000481 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000482 [(set SPR:$dst, (arm_ftoui (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000483 let Inst{7} = 1; // Z bit
484}
Evan Chenga8e29892007-01-19 07:51:42 +0000485
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000486def VTOUIZS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000487 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000488 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000489 [(set SPR:$dst, (arm_ftoui SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000490 let Inst{7} = 1; // Z bit
491}
Evan Chenga8e29892007-01-19 07:51:42 +0000492
Johnny Chen15b423f2010-02-08 22:02:41 +0000493// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
494// For disassembly only.
Nate Begemand1fb5832010-08-03 21:31:55 +0000495let Uses = [FPSCR] in {
Johnny Chen15b423f2010-02-08 22:02:41 +0000496def VTOSIRD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
497 (outs SPR:$dst), (ins DPR:$a),
498 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000499 [(set SPR:$dst, (int_arm_vcvtr (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000500 let Inst{7} = 0; // Z bit
501}
502
503def VTOSIRS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
504 (outs SPR:$dst), (ins SPR:$a),
505 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000506 [(set SPR:$dst, (int_arm_vcvtr SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000507 let Inst{7} = 0; // Z bit
508}
509
510def VTOUIRD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
511 (outs SPR:$dst), (ins DPR:$a),
512 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000513 [(set SPR:$dst, (int_arm_vcvtru (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000514 let Inst{7} = 0; // Z bit
515}
516
517def VTOUIRS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
518 (outs SPR:$dst), (ins SPR:$a),
519 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000520 [(set SPR:$dst, (int_arm_vcvtru SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000521 let Inst{7} = 0; // Z bit
522}
Nate Begemand1fb5832010-08-03 21:31:55 +0000523}
Johnny Chen15b423f2010-02-08 22:02:41 +0000524
Johnny Chen27bb8d02010-02-11 18:17:16 +0000525// Convert between floating-point and fixed-point
526// Data type for fixed-point naming convention:
527// S16 (U=0, sx=0) -> SH
528// U16 (U=1, sx=0) -> UH
529// S32 (U=0, sx=1) -> SL
530// U32 (U=1, sx=1) -> UL
531
532let Constraints = "$a = $dst" in {
533
534// FP to Fixed-Point:
535
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000536let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000537def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
538 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
539 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
540 [/* For disassembly only; pattern left blank */]>;
541
542def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
543 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
544 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
545 [/* For disassembly only; pattern left blank */]>;
546
547def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
548 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
549 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
550 [/* For disassembly only; pattern left blank */]>;
551
552def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
553 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
554 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
555 [/* For disassembly only; pattern left blank */]>;
556
557def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
558 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
559 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
560 [/* For disassembly only; pattern left blank */]>;
561
562def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
563 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
564 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
565 [/* For disassembly only; pattern left blank */]>;
566
567def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
568 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
569 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
570 [/* For disassembly only; pattern left blank */]>;
571
572def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
573 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
574 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
575 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000576}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000577
578// Fixed-Point to FP:
579
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000580let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000581def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
582 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
583 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
584 [/* For disassembly only; pattern left blank */]>;
585
586def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
587 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
588 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
589 [/* For disassembly only; pattern left blank */]>;
590
591def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
592 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
593 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
594 [/* For disassembly only; pattern left blank */]>;
595
596def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
597 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
598 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
599 [/* For disassembly only; pattern left blank */]>;
600
601def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
602 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
603 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
604 [/* For disassembly only; pattern left blank */]>;
605
606def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
607 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
608 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
609 [/* For disassembly only; pattern left blank */]>;
610
611def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
612 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
613 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
614 [/* For disassembly only; pattern left blank */]>;
615
616def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
617 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
618 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
619 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000620}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000621
622} // End of 'let Constraints = "$src = $dst" in'
623
Evan Chenga8e29892007-01-19 07:51:42 +0000624//===----------------------------------------------------------------------===//
625// FP FMA Operations.
626//
627
Jim Grosbach26767372010-03-24 22:31:46 +0000628def VMLAD : ADbI_vmlX<0b11100, 0b00, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000629 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000630 IIC_fpMAC64, "vmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000631 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b),
632 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000633 RegConstraint<"$dstin = $dst">;
634
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000635def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
636 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000637 IIC_fpMAC32, "vmla", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000638 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
639 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000640
Jim Grosbach26767372010-03-24 22:31:46 +0000641def VNMLSD : ADbI_vmlX<0b11100, 0b01, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000642 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000643 IIC_fpMAC64, "vnmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000644 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b),
645 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000646 RegConstraint<"$dstin = $dst">;
647
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000648def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
649 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000650 IIC_fpMAC32, "vnmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000651 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
652 RegConstraint<"$dstin = $dst">;
653
Jim Grosbach26767372010-03-24 22:31:46 +0000654def VMLSD : ADbI_vmlX<0b11100, 0b00, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000655 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000656 IIC_fpMAC64, "vmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000657 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)),
658 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000659 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000660
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000661def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
662 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000663 IIC_fpMAC32, "vmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000664 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000665 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000666
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000667def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
Jim Grosbache5165492009-11-09 00:11:35 +0000668 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000669def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000670 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000671
Jim Grosbach26767372010-03-24 22:31:46 +0000672def VNMLAD : ADbI_vmlX<0b11100, 0b01, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000673 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000674 IIC_fpMAC64, "vnmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000675 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)),
676 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000677 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000678
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000679def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
680 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000681 IIC_fpMAC32, "vnmla", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000682 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000683 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000684
685//===----------------------------------------------------------------------===//
686// FP Conditional moves.
687//
688
Evan Cheng020cc1b2010-05-13 00:16:46 +0000689let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000690def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000691 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000692 IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000693 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
694 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000695
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000696def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000697 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000698 IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000699 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
700 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000701
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000702def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000703 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000704 IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000705 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
706 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000707
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000708def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000709 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000710 IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000711 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
712 RegConstraint<"$false = $dst">;
Evan Cheng020cc1b2010-05-13 00:16:46 +0000713} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +0000714
715//===----------------------------------------------------------------------===//
716// Misc.
717//
718
Evan Cheng1e13c792009-11-10 19:44:56 +0000719// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
720// to APSR.
Evan Cheng91449a82009-07-20 02:12:31 +0000721let Defs = [CPSR], Uses = [FPSCR] in
Jim Grosbache5165492009-11-09 00:11:35 +0000722def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
Jim Grosbachf4cbc0e2009-11-13 01:17:22 +0000723 "\tapsr_nzcv, fpscr",
Evan Chengdd22a452009-10-27 00:20:49 +0000724 [(arm_fmstat)]> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000725 let Inst{27-20} = 0b11101111;
726 let Inst{19-16} = 0b0001;
727 let Inst{15-12} = 0b1111;
728 let Inst{11-8} = 0b1010;
729 let Inst{7} = 0;
730 let Inst{4} = 1;
731}
Evan Cheng39382422009-10-28 01:44:26 +0000732
Johnny Chenc9745042010-02-09 22:35:38 +0000733// FPSCR <-> GPR (for disassembly only)
Nate Begemand1fb5832010-08-03 21:31:55 +0000734let hasSideEffects = 1, Uses = [FPSCR] in
735def VMRS : VFPAI<(outs GPR:$dst), (ins), VFPMiscFrm, IIC_fpSTAT,
736 "vmrs", "\t$dst, fpscr",
737 [(set GPR:$dst, (int_arm_get_fpscr))]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000738 let Inst{27-20} = 0b11101111;
739 let Inst{19-16} = 0b0001;
740 let Inst{11-8} = 0b1010;
741 let Inst{7} = 0;
742 let Inst{4} = 1;
743}
Johnny Chenc9745042010-02-09 22:35:38 +0000744
Nate Begemand1fb5832010-08-03 21:31:55 +0000745let Defs = [FPSCR] in
746def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT,
747 "vmsr", "\tfpscr, $src",
748 [(int_arm_set_fpscr GPR:$src)]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000749 let Inst{27-20} = 0b11101110;
750 let Inst{19-16} = 0b0001;
751 let Inst{11-8} = 0b1010;
752 let Inst{7} = 0;
753 let Inst{4} = 1;
754}
Evan Cheng39382422009-10-28 01:44:26 +0000755
756// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +0000757let isReMaterializable = 1 in {
758def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000759 VFPMiscFrm, IIC_fpUNA64,
Evan Cheng9d172d52009-11-24 01:05:23 +0000760 "vmov", ".f64\t$dst, $imm",
Jim Grosbache5165492009-11-09 00:11:35 +0000761 [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
762 let Inst{27-23} = 0b11101;
763 let Inst{21-20} = 0b11;
764 let Inst{11-9} = 0b101;
765 let Inst{8} = 1;
766 let Inst{7-4} = 0b0000;
767}
768
Evan Cheng39382422009-10-28 01:44:26 +0000769def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000770 VFPMiscFrm, IIC_fpUNA32,
Evan Cheng9d172d52009-11-24 01:05:23 +0000771 "vmov", ".f32\t$dst, $imm",
Evan Cheng39382422009-10-28 01:44:26 +0000772 [(set SPR:$dst, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
773 let Inst{27-23} = 0b11101;
774 let Inst{21-20} = 0b11;
775 let Inst{11-9} = 0b101;
776 let Inst{8} = 0;
777 let Inst{7-4} = 0b0000;
778}
Evan Cheng39382422009-10-28 01:44:26 +0000779}