blob: 1d29ff88914623772b1890ee5f6094acbfa71627 [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
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000145def VADDD : ADbI<0b11100, 0b11, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000146 IIC_fpALU64, "vadd", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000147 [(set DPR:$dst, (fadd DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000148
Jim Grosbach499e8862010-10-12 21:22:40 +0000149def VADDS : ASbIn<0b11100, 0b11, 0, 0, (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
150 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
151 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]> {
152 bits<5> Sd;
153 bits<5> Sn;
154 bits<5> Sm;
155
156 let Inst{3-0} = Sm{4-1};
157 let Inst{5} = Sm{0};
158 let Inst{19-16} = Sn{4-1};
159 let Inst{7} = Sn{0};
160 let Inst{15-12} = Sd{4-1};
161 let Inst{22} = Sd{0};
162}
Evan Chenga8e29892007-01-19 07:51:42 +0000163
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000164// These are encoded as unary instructions.
Evan Cheng91449a82009-07-20 02:12:31 +0000165let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000166def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000167 IIC_fpCMP64, "vcmpe", ".f64\t$a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000168 [(arm_cmpfp DPR:$a, (f64 DPR:$b))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000169
Johnny Chen7edd8e32010-02-08 19:41:48 +0000170def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins DPR:$a, DPR:$b),
171 IIC_fpCMP64, "vcmp", ".f64\t$a, $b",
172 [/* For disassembly only; pattern left blank */]>;
173
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000174def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000175 IIC_fpCMP32, "vcmpe", ".f32\t$a, $b",
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000176 [(arm_cmpfp SPR:$a, SPR:$b)]>;
Johnny Chen7edd8e32010-02-08 19:41:48 +0000177
178def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins SPR:$a, SPR:$b),
179 IIC_fpCMP32, "vcmp", ".f32\t$a, $b",
180 [/* For disassembly only; pattern left blank */]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000181}
Evan Chenga8e29892007-01-19 07:51:42 +0000182
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000183def VDIVD : ADbI<0b11101, 0b00, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000184 IIC_fpDIV64, "vdiv", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000185 [(set DPR:$dst, (fdiv DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000186
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000187def VDIVS : ASbI<0b11101, 0b00, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000188 IIC_fpDIV32, "vdiv", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000189 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
190
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000191def VMULD : ADbI<0b11100, 0b10, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000192 IIC_fpMUL64, "vmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000193 [(set DPR:$dst, (fmul DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000194
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000195def VMULS : ASbIn<0b11100, 0b10, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000196 IIC_fpMUL32, "vmul", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000197 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
Jim Grosbache5165492009-11-09 00:11:35 +0000198
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000199def VNMULD : ADbI<0b11100, 0b10, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000200 IIC_fpMUL64, "vnmul", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000201 [(set DPR:$dst, (fneg (fmul DPR:$a, (f64 DPR:$b))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000202
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000203def VNMULS : ASbI<0b11100, 0b10, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000204 IIC_fpMUL32, "vnmul", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000205 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000206
Chris Lattner72939122007-05-03 00:32:00 +0000207// Match reassociated forms only if not sign dependent rounding.
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000208def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000209 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000210def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000211 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000212
213
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000214def VSUBD : ADbI<0b11100, 0b11, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000215 IIC_fpALU64, "vsub", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000216 [(set DPR:$dst, (fsub DPR:$a, (f64 DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000217
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000218def VSUBS : ASbIn<0b11100, 0b11, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000219 IIC_fpALU32, "vsub", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000220 [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000221
222//===----------------------------------------------------------------------===//
223// FP Unary Operations.
224//
225
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000226def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000227 IIC_fpUNA64, "vabs", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000228 [(set DPR:$dst, (fabs (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000229
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000230def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000231 IIC_fpUNA32, "vabs", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000232 [(set SPR:$dst, (fabs SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000233
Evan Cheng91449a82009-07-20 02:12:31 +0000234let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000235def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins DPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000236 IIC_fpCMP64, "vcmpe", ".f64\t$a, #0",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000237 [(arm_cmpfp0 (f64 DPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000238
Johnny Chen7edd8e32010-02-08 19:41:48 +0000239def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins DPR:$a),
240 IIC_fpCMP64, "vcmp", ".f64\t$a, #0",
241 [/* For disassembly only; pattern left blank */]>;
242
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000243def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins SPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000244 IIC_fpCMP32, "vcmpe", ".f32\t$a, #0",
Evan Chenga8e29892007-01-19 07:51:42 +0000245 [(arm_cmpfp0 SPR:$a)]>;
Johnny Chen7edd8e32010-02-08 19:41:48 +0000246
247def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins SPR:$a),
248 IIC_fpCMP32, "vcmp", ".f32\t$a, #0",
249 [/* For disassembly only; pattern left blank */]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000250}
Evan Chenga8e29892007-01-19 07:51:42 +0000251
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000252def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000253 IIC_fpCVTDS, "vcvt", ".f64.f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000254 [(set DPR:$dst, (fextend SPR:$a))]>;
255
Evan Cheng96581d32008-11-11 02:11:05 +0000256// Special case encoding: bits 11-8 is 0b1011.
Jim Grosbache5165492009-11-09 00:11:35 +0000257def VCVTSD : VFPAI<(outs SPR:$dst), (ins DPR:$a), VFPUnaryFrm,
258 IIC_fpCVTSD, "vcvt", ".f32.f64\t$dst, $a",
David Goodwin3ca524e2009-07-10 17:03:29 +0000259 [(set SPR:$dst, (fround DPR:$a))]> {
Evan Cheng96581d32008-11-11 02:11:05 +0000260 let Inst{27-23} = 0b11101;
261 let Inst{21-16} = 0b110111;
262 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000263 let Inst{7-6} = 0b11;
264 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000265}
Evan Chenga8e29892007-01-19 07:51:42 +0000266
Johnny Chen2d658df2010-02-09 17:21:56 +0000267// Between half-precision and single-precision. For disassembly only.
268
Jim Grosbach18f30e62010-06-02 21:53:11 +0000269def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000270 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000271 [/* For disassembly only; pattern left blank */]>;
272
Bob Wilson76a312b2010-03-19 22:51:32 +0000273def : ARMPat<(f32_to_f16 SPR:$a),
274 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000275
Jim Grosbach18f30e62010-06-02 21:53:11 +0000276def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000277 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000278 [/* For disassembly only; pattern left blank */]>;
279
Bob Wilson76a312b2010-03-19 22:51:32 +0000280def : ARMPat<(f16_to_f32 GPR:$a),
281 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000282
Jim Grosbach18f30e62010-06-02 21:53:11 +0000283def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000284 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000285 [/* For disassembly only; pattern left blank */]>;
286
Jim Grosbach18f30e62010-06-02 21:53:11 +0000287def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000288 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000289 [/* For disassembly only; pattern left blank */]>;
290
Evan Chengcd799b92009-06-12 20:46:18 +0000291let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000292def VMOVD: ADuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000293 IIC_fpUNA64, "vmov", ".f64\t$dst, $a", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000294
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000295def VMOVS: ASuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000296 IIC_fpUNA32, "vmov", ".f32\t$dst, $a", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000297} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000298
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000299def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000300 IIC_fpUNA64, "vneg", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000301 [(set DPR:$dst, (fneg (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000302
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000303def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000304 IIC_fpUNA32, "vneg", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000305 [(set SPR:$dst, (fneg SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000306
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000307def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000308 IIC_fpSQRT64, "vsqrt", ".f64\t$dst, $a",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000309 [(set DPR:$dst, (fsqrt (f64 DPR:$a)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000310
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000311def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000312 IIC_fpSQRT32, "vsqrt", ".f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000313 [(set SPR:$dst, (fsqrt SPR:$a))]>;
314
315//===----------------------------------------------------------------------===//
316// FP <-> GPR Copies. Int <-> FP Conversions.
317//
318
Jim Grosbache5165492009-11-09 00:11:35 +0000319def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000320 IIC_fpMOVSI, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000321 [(set GPR:$dst, (bitconvert SPR:$src))]>;
322
Jim Grosbache5165492009-11-09 00:11:35 +0000323def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000324 IIC_fpMOVIS, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000325 [(set SPR:$dst, (bitconvert GPR:$src))]>;
326
Evan Cheng020cc1b2010-05-13 00:16:46 +0000327let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000328def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Evan Chengd20d6582009-10-01 01:33:39 +0000329 (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000330 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src",
Johnny Chen7acca672010-02-05 18:04:58 +0000331 [/* FIXME: Can't write pattern for multiple result instr*/]> {
332 let Inst{7-6} = 0b00;
333}
Evan Chenga8e29892007-01-19 07:51:42 +0000334
Johnny Chen23401d62010-02-08 17:26:09 +0000335def VMOVRRS : AVConv3I<0b11000101, 0b1010,
336 (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000337 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000338 [/* For disassembly only; pattern left blank */]> {
339 let Inst{7-6} = 0b00;
340}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000341} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000342
Evan Chenga8e29892007-01-19 07:51:42 +0000343// FMDHR: GPR -> SPR
344// FMDLR: GPR -> SPR
345
Jim Grosbache5165492009-11-09 00:11:35 +0000346def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Evan Cheng38b6fd62008-12-11 22:02:02 +0000347 (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000348 IIC_fpMOVID, "vmov", "\t$dst, $src1, $src2",
Johnny Chen7acca672010-02-05 18:04:58 +0000349 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]> {
350 let Inst{7-6} = 0b00;
351}
Evan Chenga8e29892007-01-19 07:51:42 +0000352
Evan Cheng020cc1b2010-05-13 00:16:46 +0000353let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000354def VMOVSRR : AVConv5I<0b11000100, 0b1010,
355 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000356 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000357 [/* For disassembly only; pattern left blank */]> {
358 let Inst{7-6} = 0b00;
359}
360
Evan Chenga8e29892007-01-19 07:51:42 +0000361// FMRDH: SPR -> GPR
362// FMRDL: SPR -> GPR
363// FMRRS: SPR -> GPR
364// FMRX : SPR system reg -> GPR
365
366// FMSRR: GPR -> SPR
367
Eric Christopher5371cab2010-09-28 00:35:33 +0000368// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000369
370
371// Int to FP:
372
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000373def VSITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
374 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000375 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000376 [(set DPR:$dst, (f64 (arm_sitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000377 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000378}
Evan Chenga8e29892007-01-19 07:51:42 +0000379
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000380def VSITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
381 (outs SPR:$dst),(ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000382 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000383 [(set SPR:$dst, (arm_sitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000384 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000385}
Evan Chenga8e29892007-01-19 07:51:42 +0000386
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000387def VUITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
388 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000389 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000390 [(set DPR:$dst, (f64 (arm_uitof SPR:$a)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000391 let Inst{7} = 0; // u32
392}
Evan Chenga8e29892007-01-19 07:51:42 +0000393
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000394def VUITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
395 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000396 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000397 [(set SPR:$dst, (arm_uitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000398 let Inst{7} = 0; // u32
399}
Evan Chenga8e29892007-01-19 07:51:42 +0000400
401// FP to Int:
402// Always set Z bit in the instruction, i.e. "round towards zero" variants.
403
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000404def VTOSIZD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000405 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000406 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000407 [(set SPR:$dst, (arm_ftosi (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000408 let Inst{7} = 1; // Z bit
409}
Evan Chenga8e29892007-01-19 07:51:42 +0000410
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000411def VTOSIZS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000412 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000413 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000414 [(set SPR:$dst, (arm_ftosi SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000415 let Inst{7} = 1; // Z bit
416}
Evan Chenga8e29892007-01-19 07:51:42 +0000417
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000418def VTOUIZD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000419 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000420 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000421 [(set SPR:$dst, (arm_ftoui (f64 DPR:$a)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000422 let Inst{7} = 1; // Z bit
423}
Evan Chenga8e29892007-01-19 07:51:42 +0000424
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000425def VTOUIZS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000426 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000427 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a",
Bob Wilson76a312b2010-03-19 22:51:32 +0000428 [(set SPR:$dst, (arm_ftoui SPR:$a))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000429 let Inst{7} = 1; // Z bit
430}
Evan Chenga8e29892007-01-19 07:51:42 +0000431
Johnny Chen15b423f2010-02-08 22:02:41 +0000432// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
433// For disassembly only.
Nate Begemand1fb5832010-08-03 21:31:55 +0000434let Uses = [FPSCR] in {
Johnny Chen15b423f2010-02-08 22:02:41 +0000435def VTOSIRD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
436 (outs SPR:$dst), (ins DPR:$a),
437 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000438 [(set SPR:$dst, (int_arm_vcvtr (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000439 let Inst{7} = 0; // Z bit
440}
441
442def VTOSIRS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
443 (outs SPR:$dst), (ins SPR:$a),
444 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000445 [(set SPR:$dst, (int_arm_vcvtr SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000446 let Inst{7} = 0; // Z bit
447}
448
449def VTOUIRD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
450 (outs SPR:$dst), (ins DPR:$a),
451 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000452 [(set SPR:$dst, (int_arm_vcvtru (f64 DPR:$a)))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000453 let Inst{7} = 0; // Z bit
454}
455
456def VTOUIRS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
457 (outs SPR:$dst), (ins SPR:$a),
458 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$dst, $a",
Nate Begemand1fb5832010-08-03 21:31:55 +0000459 [(set SPR:$dst, (int_arm_vcvtru SPR:$a))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000460 let Inst{7} = 0; // Z bit
461}
Nate Begemand1fb5832010-08-03 21:31:55 +0000462}
Johnny Chen15b423f2010-02-08 22:02:41 +0000463
Johnny Chen27bb8d02010-02-11 18:17:16 +0000464// Convert between floating-point and fixed-point
465// Data type for fixed-point naming convention:
466// S16 (U=0, sx=0) -> SH
467// U16 (U=1, sx=0) -> UH
468// S32 (U=0, sx=1) -> SL
469// U32 (U=1, sx=1) -> UL
470
471let Constraints = "$a = $dst" in {
472
473// FP to Fixed-Point:
474
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000475let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000476def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
477 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
478 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
479 [/* For disassembly only; pattern left blank */]>;
480
481def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
482 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
483 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
484 [/* For disassembly only; pattern left blank */]>;
485
486def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
487 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
488 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
489 [/* For disassembly only; pattern left blank */]>;
490
491def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
492 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
493 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
494 [/* For disassembly only; pattern left blank */]>;
495
496def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
497 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
498 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
499 [/* For disassembly only; pattern left blank */]>;
500
501def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
502 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
503 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
504 [/* For disassembly only; pattern left blank */]>;
505
506def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
507 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
508 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
509 [/* For disassembly only; pattern left blank */]>;
510
511def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
512 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
513 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
514 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000515}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000516
517// Fixed-Point to FP:
518
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000519let isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000520def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
521 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
522 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
523 [/* For disassembly only; pattern left blank */]>;
524
525def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
526 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
527 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
528 [/* For disassembly only; pattern left blank */]>;
529
530def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
531 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
532 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
533 [/* For disassembly only; pattern left blank */]>;
534
535def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
536 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
537 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
538 [/* For disassembly only; pattern left blank */]>;
539
540def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
541 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
542 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
543 [/* For disassembly only; pattern left blank */]>;
544
545def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
546 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
547 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
548 [/* For disassembly only; pattern left blank */]>;
549
550def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
551 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
552 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
553 [/* For disassembly only; pattern left blank */]>;
554
555def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
556 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
557 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
558 [/* For disassembly only; pattern left blank */]>;
Daniel Dunbar3bcd9f72010-08-11 04:46:13 +0000559}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000560
561} // End of 'let Constraints = "$src = $dst" in'
562
Evan Chenga8e29892007-01-19 07:51:42 +0000563//===----------------------------------------------------------------------===//
564// FP FMA Operations.
565//
566
Jim Grosbach26767372010-03-24 22:31:46 +0000567def VMLAD : ADbI_vmlX<0b11100, 0b00, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000568 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000569 IIC_fpMAC64, "vmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000570 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b),
571 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000572 RegConstraint<"$dstin = $dst">;
573
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000574def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
575 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000576 IIC_fpMAC32, "vmla", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000577 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
578 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000579
Jim Grosbach26767372010-03-24 22:31:46 +0000580def VNMLSD : ADbI_vmlX<0b11100, 0b01, 0, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000581 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000582 IIC_fpMAC64, "vnmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000583 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b),
584 (f64 DPR:$dstin)))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000585 RegConstraint<"$dstin = $dst">;
586
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000587def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
588 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000589 IIC_fpMAC32, "vnmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000590 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
591 RegConstraint<"$dstin = $dst">;
592
Jim Grosbach26767372010-03-24 22:31:46 +0000593def VMLSD : ADbI_vmlX<0b11100, 0b00, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000594 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000595 IIC_fpMAC64, "vmls", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000596 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)),
597 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000598 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000599
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000600def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
601 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000602 IIC_fpMAC32, "vmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000603 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000604 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000605
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000606def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
Jim Grosbache5165492009-11-09 00:11:35 +0000607 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000608def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000609 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000610
Jim Grosbach26767372010-03-24 22:31:46 +0000611def VNMLAD : ADbI_vmlX<0b11100, 0b01, 1, 0,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000612 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000613 IIC_fpMAC64, "vnmla", ".f64\t$dst, $a, $b",
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000614 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)),
615 (f64 DPR:$dstin)))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000616 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000617
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000618def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
619 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000620 IIC_fpMAC32, "vnmla", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000621 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000622 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000623
624//===----------------------------------------------------------------------===//
625// FP Conditional moves.
626//
627
Evan Cheng020cc1b2010-05-13 00:16:46 +0000628let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000629def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000630 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000631 IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000632 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
633 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000634
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000635def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000636 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000637 IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000638 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
639 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000640
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000641def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000642 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000643 IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000644 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
645 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000646
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000647def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000648 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000649 IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000650 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
651 RegConstraint<"$false = $dst">;
Evan Cheng020cc1b2010-05-13 00:16:46 +0000652} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +0000653
654//===----------------------------------------------------------------------===//
655// Misc.
656//
657
Evan Cheng1e13c792009-11-10 19:44:56 +0000658// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
659// to APSR.
Evan Cheng91449a82009-07-20 02:12:31 +0000660let Defs = [CPSR], Uses = [FPSCR] in
Jim Grosbache5165492009-11-09 00:11:35 +0000661def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
Jim Grosbachf4cbc0e2009-11-13 01:17:22 +0000662 "\tapsr_nzcv, fpscr",
Evan Chengdd22a452009-10-27 00:20:49 +0000663 [(arm_fmstat)]> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000664 let Inst{27-20} = 0b11101111;
665 let Inst{19-16} = 0b0001;
666 let Inst{15-12} = 0b1111;
667 let Inst{11-8} = 0b1010;
668 let Inst{7} = 0;
669 let Inst{4} = 1;
670}
Evan Cheng39382422009-10-28 01:44:26 +0000671
Johnny Chenc9745042010-02-09 22:35:38 +0000672// FPSCR <-> GPR (for disassembly only)
Nate Begemand1fb5832010-08-03 21:31:55 +0000673let hasSideEffects = 1, Uses = [FPSCR] in
674def VMRS : VFPAI<(outs GPR:$dst), (ins), VFPMiscFrm, IIC_fpSTAT,
675 "vmrs", "\t$dst, fpscr",
676 [(set GPR:$dst, (int_arm_get_fpscr))]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000677 let Inst{27-20} = 0b11101111;
678 let Inst{19-16} = 0b0001;
679 let Inst{11-8} = 0b1010;
680 let Inst{7} = 0;
681 let Inst{4} = 1;
682}
Johnny Chenc9745042010-02-09 22:35:38 +0000683
Nate Begemand1fb5832010-08-03 21:31:55 +0000684let Defs = [FPSCR] in
685def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT,
686 "vmsr", "\tfpscr, $src",
687 [(int_arm_set_fpscr GPR:$src)]> {
Johnny Chenc9745042010-02-09 22:35:38 +0000688 let Inst{27-20} = 0b11101110;
689 let Inst{19-16} = 0b0001;
690 let Inst{11-8} = 0b1010;
691 let Inst{7} = 0;
692 let Inst{4} = 1;
693}
Evan Cheng39382422009-10-28 01:44:26 +0000694
695// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +0000696let isReMaterializable = 1 in {
697def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000698 VFPMiscFrm, IIC_fpUNA64,
Evan Cheng9d172d52009-11-24 01:05:23 +0000699 "vmov", ".f64\t$dst, $imm",
Jim Grosbache5165492009-11-09 00:11:35 +0000700 [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
701 let Inst{27-23} = 0b11101;
702 let Inst{21-20} = 0b11;
703 let Inst{11-9} = 0b101;
704 let Inst{8} = 1;
705 let Inst{7-4} = 0b0000;
706}
707
Evan Cheng39382422009-10-28 01:44:26 +0000708def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000709 VFPMiscFrm, IIC_fpUNA32,
Evan Cheng9d172d52009-11-24 01:05:23 +0000710 "vmov", ".f32\t$dst, $imm",
Evan Cheng39382422009-10-28 01:44:26 +0000711 [(set SPR:$dst, vfp_f32imm:$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} = 0;
716 let Inst{7-4} = 0b0000;
717}
Evan Cheng39382422009-10-28 01:44:26 +0000718}