blob: 3fb8ebea4029b2c8ef4d3ebdba8bc986f3fe86f6 [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)))]> {
148 bits<5> Dd;
149 bits<5> Dn;
150 bits<5> Dm;
151
152 let Inst{3-0} = Dm{3-0};
153 let Inst{5} = Dm{4};
154 let Inst{19-16} = Dn{3-0};
155 let Inst{7} = Dn{4};
156 let Inst{15-12} = Dd{3-0};
157 let Inst{22} = Dd{4};
158}
Evan Chenga8e29892007-01-19 07:51:42 +0000159
Jim Grosbach499e8862010-10-12 21:22:40 +0000160def VADDS : ASbIn<0b11100, 0b11, 0, 0, (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
161 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
162 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]> {
163 bits<5> Sd;
164 bits<5> Sn;
165 bits<5> Sm;
166
167 let Inst{3-0} = Sm{4-1};
168 let Inst{5} = Sm{0};
169 let Inst{19-16} = Sn{4-1};
170 let Inst{7} = Sn{0};
171 let Inst{15-12} = Sd{4-1};
172 let Inst{22} = Sd{0};
173}
Evan Chenga8e29892007-01-19 07:51:42 +0000174
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000175// These are encoded as unary instructions.
Evan Cheng91449a82009-07-20 02:12:31 +0000176let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000177def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000178 IIC_fpCMP64, "vcmpe", ".f64\t$a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000179 [(arm_cmpfp DPR:$a, (f64 DPR:$b))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000180
Johnny Chen7edd8e32010-02-08 19:41:48 +0000181def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins DPR:$a, DPR:$b),
182 IIC_fpCMP64, "vcmp", ".f64\t$a, $b",
183 [/* For disassembly only; pattern left blank */]>;
184
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000185def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000186 IIC_fpCMP32, "vcmpe", ".f32\t$a, $b",
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000187 [(arm_cmpfp SPR:$a, SPR:$b)]>;
Johnny Chen7edd8e32010-02-08 19:41:48 +0000188
189def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins SPR:$a, SPR:$b),
190 IIC_fpCMP32, "vcmp", ".f32\t$a, $b",
191 [/* For disassembly only; pattern left blank */]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000192}
Evan Chenga8e29892007-01-19 07:51:42 +0000193
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000194def VDIVD : ADbI<0b11101, 0b00, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000195 IIC_fpDIV64, "vdiv", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000196 [(set DPR:$dst, (fdiv DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000197
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000198def VDIVS : ASbI<0b11101, 0b00, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000199 IIC_fpDIV32, "vdiv", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000200 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
201
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000202def VMULD : ADbI<0b11100, 0b10, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000203 IIC_fpMUL64, "vmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000204 [(set DPR:$dst, (fmul DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000205
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000206def VMULS : ASbIn<0b11100, 0b10, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000207 IIC_fpMUL32, "vmul", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000208 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
Jim Grosbache5165492009-11-09 00:11:35 +0000209
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000210def VNMULD : ADbI<0b11100, 0b10, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000211 IIC_fpMUL64, "vnmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000212 [(set DPR:$dst, (fneg (fmul DPR:$a, (f64 DPR:$b))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000213
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000214def VNMULS : ASbI<0b11100, 0b10, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000215 IIC_fpMUL32, "vnmul", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000216 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000217
Chris Lattner72939122007-05-03 00:32:00 +0000218// Match reassociated forms only if not sign dependent rounding.
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000219def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000220 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000221def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000222 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000223
224
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000225def VSUBD : ADbI<0b11100, 0b11, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000226 IIC_fpALU64, "vsub", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000227 [(set DPR:$dst, (fsub DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000228
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000229def VSUBS : ASbIn<0b11100, 0b11, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000230 IIC_fpALU32, "vsub", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000231 [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000232
233//===----------------------------------------------------------------------===//
234// FP Unary Operations.
235//
236
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000237def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000238 IIC_fpUNA64, "vabs", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000239 [(set DPR:$dst, (fabs (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000240
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000241def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000242 IIC_fpUNA32, "vabs", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000243 [(set SPR:$dst, (fabs SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000244
Evan Cheng91449a82009-07-20 02:12:31 +0000245let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000246def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins DPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000247 IIC_fpCMP64, "vcmpe", ".f64\t$a, #0",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000248 [(arm_cmpfp0 (f64 DPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000249
Johnny Chen7edd8e32010-02-08 19:41:48 +0000250def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins DPR:$a),
251 IIC_fpCMP64, "vcmp", ".f64\t$a, #0",
252 [/* For disassembly only; pattern left blank */]>;
253
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000254def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins SPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000255 IIC_fpCMP32, "vcmpe", ".f32\t$a, #0",
Evan Chenga8e29892007-01-19 07:51:42 +0000256 [(arm_cmpfp0 SPR:$a)]>;
Johnny Chen7edd8e32010-02-08 19:41:48 +0000257
258def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins SPR:$a),
259 IIC_fpCMP32, "vcmp", ".f32\t$a, #0",
260 [/* For disassembly only; pattern left blank */]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000261}
Evan Chenga8e29892007-01-19 07:51:42 +0000262
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000263def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000264 IIC_fpCVTDS, "vcvt", ".f64.f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000265 [(set DPR:$dst, (fextend SPR:$a))]>;
266
Evan Cheng96581d32008-11-11 02:11:05 +0000267// Special case encoding: bits 11-8 is 0b1011.
Jim Grosbache5165492009-11-09 00:11:35 +0000268def VCVTSD : VFPAI<(outs SPR:$dst), (ins DPR:$a), VFPUnaryFrm,
269 IIC_fpCVTSD, "vcvt", ".f32.f64\t$dst, $a",
David Goodwin3ca524e2009-07-10 17:03:29 +0000270 [(set SPR:$dst, (fround DPR:$a))]> {
Evan Cheng96581d32008-11-11 02:11:05 +0000271 let Inst{27-23} = 0b11101;
272 let Inst{21-16} = 0b110111;
273 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000274 let Inst{7-6} = 0b11;
275 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000276}
Evan Chenga8e29892007-01-19 07:51:42 +0000277
Johnny Chen2d658df2010-02-09 17:21:56 +0000278// Between half-precision and single-precision. For disassembly only.
279
Jim Grosbach18f30e62010-06-02 21:53:11 +0000280def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000281 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000282 [/* For disassembly only; pattern left blank */]>;
283
Bob Wilson76a312b2010-03-19 22:51:32 +0000284def : ARMPat<(f32_to_f16 SPR:$a),
285 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000286
Jim Grosbach18f30e62010-06-02 21:53:11 +0000287def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000288 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000289 [/* For disassembly only; pattern left blank */]>;
290
Bob Wilson76a312b2010-03-19 22:51:32 +0000291def : ARMPat<(f16_to_f32 GPR:$a),
292 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000293
Jim Grosbach18f30e62010-06-02 21:53:11 +0000294def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000295 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000296 [/* For disassembly only; pattern left blank */]>;
297
Jim Grosbach18f30e62010-06-02 21:53:11 +0000298def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000299 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000300 [/* For disassembly only; pattern left blank */]>;
301
Evan Chengcd799b92009-06-12 20:46:18 +0000302let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000303def VMOVD: ADuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000304 IIC_fpUNA64, "vmov", ".f64\t$dst, $a", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000305
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000306def VMOVS: ASuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000307 IIC_fpUNA32, "vmov", ".f32\t$dst, $a", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000308} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000309
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000310def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000311 IIC_fpUNA64, "vneg", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000312 [(set DPR:$dst, (fneg (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000313
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000314def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000315 IIC_fpUNA32, "vneg", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000316 [(set SPR:$dst, (fneg SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000317
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000318def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000319 IIC_fpSQRT64, "vsqrt", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000320 [(set DPR:$dst, (fsqrt (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000321
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000322def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000323 IIC_fpSQRT32, "vsqrt", ".f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000324 [(set SPR:$dst, (fsqrt SPR:$a))]>;
325
326//===----------------------------------------------------------------------===//
327// FP <-> GPR Copies. Int <-> FP Conversions.
328//
329
Jim Grosbache5165492009-11-09 00:11:35 +0000330def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000331 IIC_fpMOVSI, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000332 [(set GPR:$dst, (bitconvert SPR:$src))]>;
333
Jim Grosbache5165492009-11-09 00:11:35 +0000334def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000335 IIC_fpMOVIS, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000336 [(set SPR:$dst, (bitconvert GPR:$src))]>;
337
Evan Cheng020cc1b2010-05-13 00:16:46 +0000338let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000339def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Evan Chengd20d6582009-10-01 01:33:39 +0000340 (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000341 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src",
Johnny Chen7acca672010-02-05 18:04:58 +0000342 [/* FIXME: Can't write pattern for multiple result instr*/]> {
343 let Inst{7-6} = 0b00;
344}
Evan Chenga8e29892007-01-19 07:51:42 +0000345
Johnny Chen23401d62010-02-08 17:26:09 +0000346def VMOVRRS : AVConv3I<0b11000101, 0b1010,
347 (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000348 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000349 [/* For disassembly only; pattern left blank */]> {
350 let Inst{7-6} = 0b00;
351}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000352} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000353
Evan Chenga8e29892007-01-19 07:51:42 +0000354// FMDHR: GPR -> SPR
355// FMDLR: GPR -> SPR
356
Jim Grosbache5165492009-11-09 00:11:35 +0000357def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Evan Cheng38b6fd62008-12-11 22:02:02 +0000358 (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000359 IIC_fpMOVID, "vmov", "\t$dst, $src1, $src2",
Johnny Chen7acca672010-02-05 18:04:58 +0000360 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]> {
361 let Inst{7-6} = 0b00;
362}
Evan Chenga8e29892007-01-19 07:51:42 +0000363
Evan Cheng020cc1b2010-05-13 00:16:46 +0000364let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000365def VMOVSRR : AVConv5I<0b11000100, 0b1010,
366 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000367 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000368 [/* For disassembly only; pattern left blank */]> {
369 let Inst{7-6} = 0b00;
370}
371
Evan Chenga8e29892007-01-19 07:51:42 +0000372// FMRDH: SPR -> GPR
373// FMRDL: SPR -> GPR
374// FMRRS: SPR -> GPR
375// FMRX : SPR system reg -> GPR
376
377// FMSRR: GPR -> SPR
378
Eric Christopher5371cab2010-09-28 00:35:33 +0000379// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000380
381
382// Int to FP:
383
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000384def VSITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
385 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000386 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000387 [(set DPR:$dst, (f64 (arm_sitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000388 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000389}
Evan Chenga8e29892007-01-19 07:51:42 +0000390
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000391def VSITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
392 (outs SPR:$dst),(ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000393 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000394 [(set SPR:$dst, (arm_sitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000395 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000396}
Evan Chenga8e29892007-01-19 07:51:42 +0000397
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000398def VUITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
399 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000400 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000401 [(set DPR:$dst, (f64 (arm_uitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000402 let Inst{7} = 0; // u32
403}
Evan Chenga8e29892007-01-19 07:51:42 +0000404
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000405def VUITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
406 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000407 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000408 [(set SPR:$dst, (arm_uitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000409 let Inst{7} = 0; // u32
410}
Evan Chenga8e29892007-01-19 07:51:42 +0000411
412// FP to Int:
413// Always set Z bit in the instruction, i.e. "round towards zero" variants.
414
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000415def VTOSIZD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000416 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000417 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000418 [(set SPR:$dst, (arm_ftosi (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000419 let Inst{7} = 1; // Z bit
420}
Evan Chenga8e29892007-01-19 07:51:42 +0000421
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000422def VTOSIZS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000423 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000424 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000425 [(set SPR:$dst, (arm_ftosi SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000426 let Inst{7} = 1; // Z bit
427}
Evan Chenga8e29892007-01-19 07:51:42 +0000428
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000429def VTOUIZD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000430 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000431 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000432 [(set SPR:$dst, (arm_ftoui (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000433 let Inst{7} = 1; // Z bit
434}
Evan Chenga8e29892007-01-19 07:51:42 +0000435
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000436def VTOUIZS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000437 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000438 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000439 [(set SPR:$dst, (arm_ftoui SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000440 let Inst{7} = 1; // Z bit
441}
Evan Chenga8e29892007-01-19 07:51:42 +0000442
Johnny Chen15b423f2010-02-08 22:02:41 +0000443// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
444// For disassembly only.
Nate Begemand1fb5832010-08-03 21:31:55 +0000445let Uses = [FPSCR] in {
Johnny Chen15b423f2010-02-08 22:02:41 +0000446def VTOSIRD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
447 (outs SPR:$dst), (ins DPR:$a),
448 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000449 [(set SPR:$dst, (int_arm_vcvtr (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000450 let Inst{7} = 0; // Z bit
451}
452
453def VTOSIRS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
454 (outs SPR:$dst), (ins SPR:$a),
455 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000456 [(set SPR:$dst, (int_arm_vcvtr SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000457 let Inst{7} = 0; // Z bit
458}
459
460def VTOUIRD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
461 (outs SPR:$dst), (ins DPR:$a),
462 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000463 [(set SPR:$dst, (int_arm_vcvtru (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000464 let Inst{7} = 0; // Z bit
465}
466
467def VTOUIRS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
468 (outs SPR:$dst), (ins SPR:$a),
469 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000470 [(set SPR:$dst, (int_arm_vcvtru SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000471 let Inst{7} = 0; // Z bit
472}
Nate Begemand1fb5832010-08-03 21:31:55 +0000473}
Johnny Chen15b423f2010-02-08 22:02:41 +0000474
Johnny Chen27bb8d02010-02-11 18:17:16 +0000475// Convert between floating-point and fixed-point
476// Data type for fixed-point naming convention:
477// S16 (U=0, sx=0) -> SH
478// U16 (U=1, sx=0) -> UH
479// S32 (U=0, sx=1) -> SL
480// U32 (U=1, sx=1) -> UL
481
482let Constraints = "$a = $dst" in {
483
484// FP to Fixed-Point:
485
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000486let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000487def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
488 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
489 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
490 [/* For disassembly only; pattern left blank */]>;
491
492def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
493 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
494 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
495 [/* For disassembly only; pattern left blank */]>;
496
497def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
498 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
499 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
500 [/* For disassembly only; pattern left blank */]>;
501
502def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
503 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
504 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
505 [/* For disassembly only; pattern left blank */]>;
506
507def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
508 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
509 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
510 [/* For disassembly only; pattern left blank */]>;
511
512def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
513 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
514 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
515 [/* For disassembly only; pattern left blank */]>;
516
517def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
518 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
519 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
520 [/* For disassembly only; pattern left blank */]>;
521
522def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
523 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
524 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
525 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000526}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000527
528// Fixed-Point to FP:
529
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000530let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000531def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
532 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
533 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
534 [/* For disassembly only; pattern left blank */]>;
535
536def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
537 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
538 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
539 [/* For disassembly only; pattern left blank */]>;
540
541def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
542 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
543 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
544 [/* For disassembly only; pattern left blank */]>;
545
546def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
547 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
548 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
549 [/* For disassembly only; pattern left blank */]>;
550
551def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
552 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
553 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
554 [/* For disassembly only; pattern left blank */]>;
555
556def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
557 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
558 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
559 [/* For disassembly only; pattern left blank */]>;
560
561def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
562 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
563 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
564 [/* For disassembly only; pattern left blank */]>;
565
566def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
567 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
568 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
569 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000570}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000571
572} // End of 'let Constraints = "$src = $dst" in'
573
Evan Chenga8e29892007-01-19 07:51:42 +0000574//===----------------------------------------------------------------------===//
575// FP FMA Operations.
576//
577
Jim Grosbach26767372010-03-24 22:31:46 +0000578def VMLAD : ADbI_vmlX<0b11100, 0b00, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000579 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000580 IIC_fpMAC64, "vmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000581 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b),
582 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000583 RegConstraint<"$dstin = $dst">;
584
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000585def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
586 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000587 IIC_fpMAC32, "vmla", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000588 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
589 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000590
Jim Grosbach26767372010-03-24 22:31:46 +0000591def VNMLSD : ADbI_vmlX<0b11100, 0b01, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000592 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000593 IIC_fpMAC64, "vnmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000594 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b),
595 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000596 RegConstraint<"$dstin = $dst">;
597
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000598def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
599 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000600 IIC_fpMAC32, "vnmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000601 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
602 RegConstraint<"$dstin = $dst">;
603
Jim Grosbach26767372010-03-24 22:31:46 +0000604def VMLSD : ADbI_vmlX<0b11100, 0b00, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000605 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000606 IIC_fpMAC64, "vmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000607 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)),
608 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000609 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000610
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000611def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
612 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000613 IIC_fpMAC32, "vmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000614 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000615 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000616
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000617def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
Jim Grosbache5165492009-11-09 00:11:35 +0000618 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000619def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000620 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000621
Jim Grosbach26767372010-03-24 22:31:46 +0000622def VNMLAD : ADbI_vmlX<0b11100, 0b01, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000623 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000624 IIC_fpMAC64, "vnmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000625 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)),
626 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000627 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000628
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000629def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
630 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000631 IIC_fpMAC32, "vnmla", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000632 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000633 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000634
635//===----------------------------------------------------------------------===//
636// FP Conditional moves.
637//
638
Evan Cheng020cc1b2010-05-13 00:16:46 +0000639let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000640def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000641 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000642 IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000643 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
644 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000645
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000646def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000647 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000648 IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000649 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
650 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000651
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000652def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000653 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000654 IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000655 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
656 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000657
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000658def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000659 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000660 IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000661 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
662 RegConstraint<"$false = $dst">;
Evan Cheng020cc1b2010-05-13 00:16:46 +0000663} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +0000664
665//===----------------------------------------------------------------------===//
666// Misc.
667//
668
Evan Cheng1e13c792009-11-10 19:44:56 +0000669// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
670// to APSR.
Evan Cheng91449a82009-07-20 02:12:31 +0000671let Defs = [CPSR], Uses = [FPSCR] in
Jim Grosbache5165492009-11-09 00:11:35 +0000672def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
Jim Grosbachf4cbc0e2009-11-13 01:17:22 +0000673 "\tapsr_nzcv, fpscr",
Evan Chengdd22a452009-10-27 00:20:49 +0000674 [(arm_fmstat)]> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000675 let Inst{27-20} = 0b11101111;
676 let Inst{19-16} = 0b0001;
677 let Inst{15-12} = 0b1111;
678 let Inst{11-8} = 0b1010;
679 let Inst{7} = 0;
680 let Inst{4} = 1;
681}
Evan Cheng39382422009-10-28 01:44:26 +0000682
Johnny Chenc9745042010-02-09 22:35:38 +0000683// FPSCR <-> GPR (for disassembly only)
Nate Begemand1fb5832010-08-03 21:31:55 +0000684let hasSideEffects = 1, Uses = [FPSCR] in
685def VMRS : VFPAI<(outs GPR:$dst), (ins), VFPMiscFrm, IIC_fpSTAT,
686 "vmrs", "\t$dst, fpscr",
687 [(set GPR:$dst, (int_arm_get_fpscr))]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000688 let Inst{27-20} = 0b11101111;
689 let Inst{19-16} = 0b0001;
690 let Inst{11-8} = 0b1010;
691 let Inst{7} = 0;
692 let Inst{4} = 1;
693}
Johnny Chenc9745042010-02-09 22:35:38 +0000694
Nate Begemand1fb5832010-08-03 21:31:55 +0000695let Defs = [FPSCR] in
696def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT,
697 "vmsr", "\tfpscr, $src",
698 [(int_arm_set_fpscr GPR:$src)]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000699 let Inst{27-20} = 0b11101110;
700 let Inst{19-16} = 0b0001;
701 let Inst{11-8} = 0b1010;
702 let Inst{7} = 0;
703 let Inst{4} = 1;
704}
Evan Cheng39382422009-10-28 01:44:26 +0000705
706// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +0000707let isReMaterializable = 1 in {
708def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000709 VFPMiscFrm, IIC_fpUNA64,
Evan Cheng9d172d52009-11-24 01:05:23 +0000710 "vmov", ".f64\t$dst, $imm",
Jim Grosbache5165492009-11-09 00:11:35 +0000711 [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
712 let Inst{27-23} = 0b11101;
713 let Inst{21-20} = 0b11;
714 let Inst{11-9} = 0b101;
715 let Inst{8} = 1;
716 let Inst{7-4} = 0b0000;
717}
718
Evan Cheng39382422009-10-28 01:44:26 +0000719def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000720 VFPMiscFrm, IIC_fpUNA32,
Evan Cheng9d172d52009-11-24 01:05:23 +0000721 "vmov", ".f32\t$dst, $imm",
Evan Cheng39382422009-10-28 01:44:26 +0000722 [(set SPR:$dst, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
723 let Inst{27-23} = 0b11101;
724 let Inst{21-20} = 0b11;
725 let Inst{11-9} = 0b101;
726 let Inst{8} = 0;
727 let Inst{7-4} = 0b0000;
728}
Evan Cheng39382422009-10-28 01:44:26 +0000729}