blob: 96577412bf356f6355ce47a88a93767f853d0aa8 [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
Evan Cheng96581d32008-11-11 02:11:05 +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
Evan Cheng4aedb612009-11-20 19:57:15 +000057let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 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",
Evan Chenga8e29892007-01-19 07:51:42 +000060 [(set DPR:$dst, (load addrmode5:$addr))]>;
61
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",
Evan Chenga8e29892007-01-19 07:51:42 +000069 [(store DPR:$src, addrmode5:$addr)]>;
70
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 Cheng0d92f5f2009-10-01 08:22:27 +000079let mayLoad = 1, hasExtraDefRegAllocReq = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +000080def VLDMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$wb,
David Goodwinb2bb7db2009-09-21 20:52:17 +000081 variable_ops), IIC_fpLoadm,
Jim Grosbache5165492009-11-09 00:11:35 +000082 "vldm${addr:submode}${p}\t${addr:base}, $wb",
Evan Chengcd8e66a2008-11-11 21:48:44 +000083 []> {
84 let Inst{20} = 1;
85}
Evan Chenga8e29892007-01-19 07:51:42 +000086
Jim Grosbache5165492009-11-09 00:11:35 +000087def VLDMS : AXSI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$wb,
David Goodwinb2bb7db2009-09-21 20:52:17 +000088 variable_ops), IIC_fpLoadm,
Jim Grosbache5165492009-11-09 00:11:35 +000089 "vldm${addr:submode}${p}\t${addr:base}, $wb",
Evan Chengcd8e66a2008-11-11 21:48:44 +000090 []> {
91 let Inst{20} = 1;
92}
Evan Cheng0d92f5f2009-10-01 08:22:27 +000093} // mayLoad, hasExtraDefRegAllocReq
Evan Chenga8e29892007-01-19 07:51:42 +000094
Evan Cheng0d92f5f2009-10-01 08:22:27 +000095let mayStore = 1, hasExtraSrcRegAllocReq = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +000096def VSTMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$wb,
David Goodwinb2bb7db2009-09-21 20:52:17 +000097 variable_ops), IIC_fpStorem,
Jim Grosbache5165492009-11-09 00:11:35 +000098 "vstm${addr:submode}${p}\t${addr:base}, $wb",
Evan Chengcd8e66a2008-11-11 21:48:44 +000099 []> {
100 let Inst{20} = 0;
101}
Evan Chenga8e29892007-01-19 07:51:42 +0000102
Jim Grosbache5165492009-11-09 00:11:35 +0000103def VSTMS : AXSI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$wb,
David Goodwinb2bb7db2009-09-21 20:52:17 +0000104 variable_ops), IIC_fpStorem,
Jim Grosbache5165492009-11-09 00:11:35 +0000105 "vstm${addr:submode}${p}\t${addr:base}, $wb",
Evan Chengcd8e66a2008-11-11 21:48:44 +0000106 []> {
107 let Inst{20} = 0;
108}
Evan Cheng0d92f5f2009-10-01 08:22:27 +0000109} // mayStore, hasExtraSrcRegAllocReq
Evan Chenga8e29892007-01-19 07:51:42 +0000110
111// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
112
113//===----------------------------------------------------------------------===//
114// FP Binary Operations.
115//
116
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000117def VADDD : ADbI<0b11100, 0b11, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000118 IIC_fpALU64, "vadd", ".f64\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000119 [(set DPR:$dst, (fadd DPR:$a, DPR:$b))]>;
120
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000121def VADDS : ASbIn<0b11100, 0b11, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000122 IIC_fpALU32, "vadd", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000123 [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000124
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000125// These are encoded as unary instructions.
Evan Cheng91449a82009-07-20 02:12:31 +0000126let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000127def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000128 IIC_fpCMP64, "vcmpe", ".f64\t$a, $b",
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000129 [(arm_cmpfp DPR:$a, DPR:$b)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000130
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000131def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0, (outs), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000132 IIC_fpCMP32, "vcmpe", ".f32\t$a, $b",
Evan Cheng3c4a4ff2008-11-12 07:18:38 +0000133 [(arm_cmpfp SPR:$a, SPR:$b)]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000134}
Evan Chenga8e29892007-01-19 07:51:42 +0000135
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000136def VDIVD : ADbI<0b11101, 0b00, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000137 IIC_fpDIV64, "vdiv", ".f64\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000138 [(set DPR:$dst, (fdiv DPR:$a, DPR:$b))]>;
139
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000140def VDIVS : ASbI<0b11101, 0b00, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000141 IIC_fpDIV32, "vdiv", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000142 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
143
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000144def VMULD : ADbI<0b11100, 0b10, 0, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000145 IIC_fpMUL64, "vmul", ".f64\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000146 [(set DPR:$dst, (fmul DPR:$a, DPR:$b))]>;
147
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000148def VMULS : ASbIn<0b11100, 0b10, 0, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000149 IIC_fpMUL32, "vmul", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000150 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
Jim Grosbache5165492009-11-09 00:11:35 +0000151
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000152def VNMULD : ADbI<0b11100, 0b10, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000153 IIC_fpMUL64, "vnmul", ".f64\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000154 [(set DPR:$dst, (fneg (fmul DPR:$a, DPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000155
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000156def VNMULS : ASbI<0b11100, 0b10, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000157 IIC_fpMUL32, "vnmul", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000158 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000159
Chris Lattner72939122007-05-03 00:32:00 +0000160// Match reassociated forms only if not sign dependent rounding.
161def : Pat<(fmul (fneg DPR:$a), DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000162 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000163def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000164 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000165
166
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000167def VSUBD : ADbI<0b11100, 0b11, 1, 0, (outs DPR:$dst), (ins DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000168 IIC_fpALU64, "vsub", ".f64\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000169 [(set DPR:$dst, (fsub DPR:$a, DPR:$b))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000170
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000171def VSUBS : ASbIn<0b11100, 0b11, 1, 0, (outs SPR:$dst), (ins SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000172 IIC_fpALU32, "vsub", ".f32\t$dst, $a, $b",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000173 [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000174
175//===----------------------------------------------------------------------===//
176// FP Unary Operations.
177//
178
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000179def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000180 IIC_fpUNA64, "vabs", ".f64\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000181 [(set DPR:$dst, (fabs DPR:$a))]>;
182
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000183def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000184 IIC_fpUNA32, "vabs", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000185 [(set SPR:$dst, (fabs SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000186
Evan Cheng91449a82009-07-20 02:12:31 +0000187let Defs = [FPSCR] in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000188def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins DPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000189 IIC_fpCMP64, "vcmpe", ".f64\t$a, #0",
Evan Chenga8e29892007-01-19 07:51:42 +0000190 [(arm_cmpfp0 DPR:$a)]>;
191
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000192def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0, (outs), (ins SPR:$a),
Jim Grosbach43cca692009-11-09 15:27:51 +0000193 IIC_fpCMP32, "vcmpe", ".f32\t$a, #0",
Evan Chenga8e29892007-01-19 07:51:42 +0000194 [(arm_cmpfp0 SPR:$a)]>;
Evan Cheng91449a82009-07-20 02:12:31 +0000195}
Evan Chenga8e29892007-01-19 07:51:42 +0000196
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000197def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000198 IIC_fpCVTDS, "vcvt", ".f64.f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000199 [(set DPR:$dst, (fextend SPR:$a))]>;
200
Evan Cheng96581d32008-11-11 02:11:05 +0000201// Special case encoding: bits 11-8 is 0b1011.
Jim Grosbache5165492009-11-09 00:11:35 +0000202def VCVTSD : VFPAI<(outs SPR:$dst), (ins DPR:$a), VFPUnaryFrm,
203 IIC_fpCVTSD, "vcvt", ".f32.f64\t$dst, $a",
David Goodwin3ca524e2009-07-10 17:03:29 +0000204 [(set SPR:$dst, (fround DPR:$a))]> {
Evan Cheng96581d32008-11-11 02:11:05 +0000205 let Inst{27-23} = 0b11101;
206 let Inst{21-16} = 0b110111;
207 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000208 let Inst{7-6} = 0b11;
209 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000210}
Evan Chenga8e29892007-01-19 07:51:42 +0000211
Evan Chengcd799b92009-06-12 20:46:18 +0000212let neverHasSideEffects = 1 in {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000213def VMOVD: ADuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000214 IIC_fpUNA64, "vmov", ".f64\t$dst, $a", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000215
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000216def VMOVS: ASuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000217 IIC_fpUNA32, "vmov", ".f32\t$dst, $a", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000218} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000219
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000220def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000221 IIC_fpUNA64, "vneg", ".f64\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000222 [(set DPR:$dst, (fneg DPR:$a))]>;
223
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000224def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,(outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000225 IIC_fpUNA32, "vneg", ".f32\t$dst, $a",
David Goodwin53e44712009-08-04 20:39:05 +0000226 [(set SPR:$dst, (fneg SPR:$a))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000227
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000228def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000229 IIC_fpSQRT64, "vsqrt", ".f64\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000230 [(set DPR:$dst, (fsqrt DPR:$a))]>;
231
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000232def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000233 IIC_fpSQRT32, "vsqrt", ".f32\t$dst, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000234 [(set SPR:$dst, (fsqrt SPR:$a))]>;
235
236//===----------------------------------------------------------------------===//
237// FP <-> GPR Copies. Int <-> FP Conversions.
238//
239
Jim Grosbache5165492009-11-09 00:11:35 +0000240def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
241 IIC_VMOVSI, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000242 [(set GPR:$dst, (bitconvert SPR:$src))]>;
243
Jim Grosbache5165492009-11-09 00:11:35 +0000244def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
245 IIC_VMOVIS, "vmov", "\t$dst, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000246 [(set SPR:$dst, (bitconvert GPR:$src))]>;
247
Jim Grosbache5165492009-11-09 00:11:35 +0000248def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Evan Chengd20d6582009-10-01 01:33:39 +0000249 (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
Jim Grosbache5165492009-11-09 00:11:35 +0000250 IIC_VMOVDI, "vmov", "\t$wb, $dst2, $src",
Evan Chenga8e29892007-01-19 07:51:42 +0000251 [/* FIXME: Can't write pattern for multiple result instr*/]>;
252
253// FMDHR: GPR -> SPR
254// FMDLR: GPR -> SPR
255
Jim Grosbache5165492009-11-09 00:11:35 +0000256def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Evan Cheng38b6fd62008-12-11 22:02:02 +0000257 (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
Jim Grosbache5165492009-11-09 00:11:35 +0000258 IIC_VMOVID, "vmov", "\t$dst, $src1, $src2",
Evan Chenga8e29892007-01-19 07:51:42 +0000259 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]>;
260
261// FMRDH: SPR -> GPR
262// FMRDL: SPR -> GPR
263// FMRRS: SPR -> GPR
264// FMRX : SPR system reg -> GPR
265
266// FMSRR: GPR -> SPR
267
Evan Chenga8e29892007-01-19 07:51:42 +0000268// FMXR: GPR -> VFP Sstem reg
269
270
271// Int to FP:
272
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000273def VSITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
274 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000275 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a",
Evan Cheng78be83d2008-11-11 19:40:26 +0000276 [(set DPR:$dst, (arm_sitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000277 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000278}
Evan Chenga8e29892007-01-19 07:51:42 +0000279
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000280def VSITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
281 (outs SPR:$dst),(ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000282 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a",
Evan Cheng78be83d2008-11-11 19:40:26 +0000283 [(set SPR:$dst, (arm_sitof SPR:$a))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000284 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000285}
Evan Chenga8e29892007-01-19 07:51:42 +0000286
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000287def VUITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
288 (outs DPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000289 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000290 [(set DPR:$dst, (arm_uitof SPR:$a))]> {
291 let Inst{7} = 0; // u32
292}
Evan Chenga8e29892007-01-19 07:51:42 +0000293
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000294def VUITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
295 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000296 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a",
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000297 [(set SPR:$dst, (arm_uitof SPR:$a))]> {
298 let Inst{7} = 0; // u32
299}
Evan Chenga8e29892007-01-19 07:51:42 +0000300
301// FP to Int:
302// Always set Z bit in the instruction, i.e. "round towards zero" variants.
303
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000304def VTOSIZD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000305 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000306 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a",
Evan Cheng78be83d2008-11-11 19:40:26 +0000307 [(set SPR:$dst, (arm_ftosi DPR:$a))]> {
308 let Inst{7} = 1; // Z bit
309}
Evan Chenga8e29892007-01-19 07:51:42 +0000310
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000311def VTOSIZS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000312 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000313 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a",
Evan Cheng78be83d2008-11-11 19:40:26 +0000314 [(set SPR:$dst, (arm_ftosi SPR:$a))]> {
315 let Inst{7} = 1; // Z bit
316}
Evan Chenga8e29892007-01-19 07:51:42 +0000317
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000318def VTOUIZD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
Evan Cheng78be83d2008-11-11 19:40:26 +0000319 (outs SPR:$dst), (ins DPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000320 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a",
Evan Cheng78be83d2008-11-11 19:40:26 +0000321 [(set SPR:$dst, (arm_ftoui DPR:$a))]> {
322 let Inst{7} = 1; // Z bit
323}
Evan Chenga8e29892007-01-19 07:51:42 +0000324
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000325def VTOUIZS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
David Goodwin338268c2009-08-10 22:17:39 +0000326 (outs SPR:$dst), (ins SPR:$a),
Jim Grosbache5165492009-11-09 00:11:35 +0000327 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a",
Evan Cheng78be83d2008-11-11 19:40:26 +0000328 [(set SPR:$dst, (arm_ftoui SPR:$a))]> {
329 let Inst{7} = 1; // Z bit
330}
Evan Chenga8e29892007-01-19 07:51:42 +0000331
332//===----------------------------------------------------------------------===//
333// FP FMA Operations.
334//
335
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000336def VMLAD : ADbI<0b11100, 0b00, 0, 0,
337 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000338 IIC_fpMAC64, "vmla", ".f64\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000339 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
340 RegConstraint<"$dstin = $dst">;
341
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000342def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
343 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000344 IIC_fpMAC32, "vmla", ".f32\t$dst, $a, $b",
David Goodwin42a83f22009-08-04 17:53:06 +0000345 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
346 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000347
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000348def VNMLSD : ADbI<0b11100, 0b01, 0, 0,
349 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000350 IIC_fpMAC64, "vnmls", ".f64\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000351 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
352 RegConstraint<"$dstin = $dst">;
353
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000354def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
355 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000356 IIC_fpMAC32, "vnmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000357 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
358 RegConstraint<"$dstin = $dst">;
359
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000360def VMLSD : ADbI<0b11100, 0b00, 1, 0,
361 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000362 IIC_fpMAC64, "vmls", ".f64\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000363 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000364 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000365
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000366def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
367 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000368 IIC_fpMAC32, "vmls", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000369 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000370 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000371
David Goodwinb84f3d42009-08-04 18:44:29 +0000372def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000373 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000374def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000375 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000376
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000377def VNMLAD : ADbI<0b11100, 0b01, 1, 0,
378 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000379 IIC_fpMAC64, "vnmla", ".f64\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000380 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000381 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000382
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000383def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
384 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000385 IIC_fpMAC32, "vnmla", ".f32\t$dst, $a, $b",
Evan Chenga8e29892007-01-19 07:51:42 +0000386 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000387 RegConstraint<"$dstin = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000388
389//===----------------------------------------------------------------------===//
390// FP Conditional moves.
391//
392
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000393def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000394 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000395 IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000396 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
397 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000398
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000399def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000400 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000401 IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000402 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
403 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000404
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000405def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000406 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000407 IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000408 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
409 RegConstraint<"$false = $dst">;
Evan Chenga8e29892007-01-19 07:51:42 +0000410
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000411def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
Evan Cheng78be83d2008-11-11 19:40:26 +0000412 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
Jim Grosbache5165492009-11-09 00:11:35 +0000413 IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
Evan Chengc85e8322007-07-05 07:13:32 +0000414 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
415 RegConstraint<"$false = $dst">;
Evan Cheng78be83d2008-11-11 19:40:26 +0000416
417
418//===----------------------------------------------------------------------===//
419// Misc.
420//
421
Evan Cheng1e13c792009-11-10 19:44:56 +0000422// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
423// to APSR.
Evan Cheng91449a82009-07-20 02:12:31 +0000424let Defs = [CPSR], Uses = [FPSCR] in
Jim Grosbache5165492009-11-09 00:11:35 +0000425def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
Jim Grosbachf4cbc0e2009-11-13 01:17:22 +0000426 "\tapsr_nzcv, fpscr",
Evan Chengdd22a452009-10-27 00:20:49 +0000427 [(arm_fmstat)]> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000428 let Inst{27-20} = 0b11101111;
429 let Inst{19-16} = 0b0001;
430 let Inst{15-12} = 0b1111;
431 let Inst{11-8} = 0b1010;
432 let Inst{7} = 0;
433 let Inst{4} = 1;
434}
Evan Cheng39382422009-10-28 01:44:26 +0000435
436
437// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +0000438let isReMaterializable = 1 in {
439def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
440 VFPMiscFrm, IIC_VMOVImm,
Evan Cheng9d172d52009-11-24 01:05:23 +0000441 "vmov", ".f64\t$dst, $imm",
Jim Grosbache5165492009-11-09 00:11:35 +0000442 [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
443 let Inst{27-23} = 0b11101;
444 let Inst{21-20} = 0b11;
445 let Inst{11-9} = 0b101;
446 let Inst{8} = 1;
447 let Inst{7-4} = 0b0000;
448}
449
Evan Cheng39382422009-10-28 01:44:26 +0000450def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
451 VFPMiscFrm, IIC_VMOVImm,
Evan Cheng9d172d52009-11-24 01:05:23 +0000452 "vmov", ".f32\t$dst, $imm",
Evan Cheng39382422009-10-28 01:44:26 +0000453 [(set SPR:$dst, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
454 let Inst{27-23} = 0b11101;
455 let Inst{21-20} = 0b11;
456 let Inst{11-9} = 0b101;
457 let Inst{8} = 0;
458 let Inst{7-4} = 0b0000;
459}
Evan Cheng39382422009-10-28 01:44:26 +0000460}