blob: feb3e539e63a5908de575cd6ef245f43138477ce [file] [log] [blame]
Bill Wendling2695d8e2010-10-15 21:50:45 +00001//===- ARMInstrVFP.td - VFP support for ARM ----------------*- tablegen -*-===//
Evan Chenga8e29892007-01-19 07:51:42 +00002//
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
Bill Wendling2695d8e2010-10-15 21:50:45 +000014def SDT_FTOI : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
15def SDT_ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
16def SDT_CMPFP0 : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
17def SDT_VMOVDRR : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
18 SDTCisSameAs<1, 2>]>;
Evan Chenga8e29892007-01-19 07:51:42 +000019
Bill Wendling2695d8e2010-10-15 21:50:45 +000020def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
21def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
22def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
23def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
24def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInFlag, SDNPOutFlag]>;
25def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
26def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutFlag]>;
27def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
Evan Chenga8e29892007-01-19 07:51:42 +000028
Bill Wendling88cf0382010-10-14 01:02:08 +000029
Evan Chenga8e29892007-01-19 07:51:42 +000030//===----------------------------------------------------------------------===//
Evan Cheng39382422009-10-28 01:44:26 +000031// Operand Definitions.
32//
33
Evan Cheng39382422009-10-28 01:44:26 +000034def vfp_f32imm : Operand<f32>,
35 PatLeaf<(f32 fpimm), [{
36 return ARM::getVFPf32Imm(N->getValueAPF()) != -1;
37 }]> {
38 let PrintMethod = "printVFPf32ImmOperand";
39}
40
41def vfp_f64imm : Operand<f64>,
42 PatLeaf<(f64 fpimm), [{
43 return ARM::getVFPf64Imm(N->getValueAPF()) != -1;
44 }]> {
45 let PrintMethod = "printVFPf64ImmOperand";
46}
47
48
49//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +000050// Load / store Instructions.
51//
52
Dan Gohmanbc9d98b2010-02-27 23:47:46 +000053let canFoldAsLoad = 1, isReMaterializable = 1 in {
Bill Wendling92b5a2e2010-11-03 01:49:29 +000054
Bill Wendling7d31a162010-10-20 22:44:54 +000055def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr),
56 IIC_fpLoad64, "vldr", ".64\t$Dd, $addr",
Bill Wendling2f46f1f2010-11-04 00:59:42 +000057 [(set DPR:$Dd, (f64 (load addrmode5:$addr)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +000058
Bill Wendling92b5a2e2010-11-03 01:49:29 +000059def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr),
60 IIC_fpLoad32, "vldr", ".32\t$Sd, $addr",
Bill Wendling2f46f1f2010-11-04 00:59:42 +000061 [(set SPR:$Sd, (load addrmode5:$addr))]>;
Bill Wendling92b5a2e2010-11-03 01:49:29 +000062
63} // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in'
Evan Chenga8e29892007-01-19 07:51:42 +000064
Bill Wendling2f46f1f2010-11-04 00:59:42 +000065def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr),
66 IIC_fpStore64, "vstr", ".64\t$Dd, $addr",
67 [(store (f64 DPR:$Dd), addrmode5:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +000068
Bill Wendling2f46f1f2010-11-04 00:59:42 +000069def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr),
70 IIC_fpStore32, "vstr", ".32\t$Sd, $addr",
71 [(store SPR:$Sd, addrmode5:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +000072
73//===----------------------------------------------------------------------===//
74// Load / store multiple Instructions.
75//
76
Chris Lattner39ee0362010-10-31 19:10:56 +000077let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
78 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +000079def VLDMD : AXDI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
80 reglist:$dsts, variable_ops),
81 IndexModeNone, IIC_fpLoad_m,
82 "vldm${amode}${p}\t$Rn, $dsts", "", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +000083 let Inst{21} = 0; // wback = (W == '1')
84 let Inst{20} = 1; // Load
Evan Chengcd8e66a2008-11-11 21:48:44 +000085}
Evan Chenga8e29892007-01-19 07:51:42 +000086
Jim Grosbache6913602010-11-03 01:01:43 +000087def VLDMS : AXSI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
88 reglist:$dsts, variable_ops),
89 IndexModeNone, IIC_fpLoad_m,
90 "vldm${amode}${p}\t$Rn, $dsts", "", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +000091 let Inst{21} = 0; // wback = (W == '1')
92 let Inst{20} = 1; // Load
Bob Wilson815baeb2010-03-13 01:08:20 +000093}
94
Jim Grosbache6913602010-11-03 01:01:43 +000095def VLDMD_UPD : AXDI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +000096 reglist:$dsts, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +000097 IndexModeUpd, IIC_fpLoad_mu,
Jim Grosbache6913602010-11-03 01:01:43 +000098 "vldm${amode}${p}\t$Rn!, $dsts",
99 "$Rn = $wb", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +0000100 let Inst{21} = 1; // wback = (W == '1')
101 let Inst{20} = 1; // Load
Bob Wilson815baeb2010-03-13 01:08:20 +0000102}
103
Jim Grosbache6913602010-11-03 01:01:43 +0000104def VLDMS_UPD : AXSI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +0000105 reglist:$dsts, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +0000106 IndexModeUpd, IIC_fpLoad_mu,
Jim Grosbache6913602010-11-03 01:01:43 +0000107 "vldm${amode}${p}\t$Rn!, $dsts",
108 "$Rn = $wb", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +0000109 let Inst{21} = 1; // wback = (W == '1')
110 let Inst{20} = 1; // Load
Evan Chengcd8e66a2008-11-11 21:48:44 +0000111}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000112} // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
Evan Chenga8e29892007-01-19 07:51:42 +0000113
Chris Lattner39ee0362010-10-31 19:10:56 +0000114let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
115 isCodeGenOnly = 1 in {
Jim Grosbache6913602010-11-03 01:01:43 +0000116def VSTMD : AXDI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
117 reglist:$srcs, variable_ops),
118 IndexModeNone, IIC_fpStore_m,
119 "vstm${amode}${p}\t$Rn, $srcs", "", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +0000120 let Inst{21} = 0; // wback = (W == '1')
121 let Inst{20} = 0; // Store
Evan Chengcd8e66a2008-11-11 21:48:44 +0000122}
Evan Chenga8e29892007-01-19 07:51:42 +0000123
Jim Grosbache6913602010-11-03 01:01:43 +0000124def VSTMS : AXSI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
125 reglist:$srcs, variable_ops), IndexModeNone,
126 IIC_fpStore_m,
127 "vstm${amode}${p}\t$Rn, $srcs", "", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +0000128 let Inst{21} = 0; // wback = (W == '1')
129 let Inst{20} = 0; // Store
Bob Wilson815baeb2010-03-13 01:08:20 +0000130}
131
Jim Grosbache6913602010-11-03 01:01:43 +0000132def VSTMD_UPD : AXDI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +0000133 reglist:$srcs, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +0000134 IndexModeUpd, IIC_fpStore_mu,
Jim Grosbache6913602010-11-03 01:01:43 +0000135 "vstm${amode}${p}\t$Rn!, $srcs",
136 "$Rn = $wb", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +0000137 let Inst{21} = 1; // wback = (W == '1')
138 let Inst{20} = 0; // Store
Bob Wilson815baeb2010-03-13 01:08:20 +0000139}
140
Jim Grosbache6913602010-11-03 01:01:43 +0000141def VSTMS_UPD : AXSI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
Bob Wilson815baeb2010-03-13 01:08:20 +0000142 reglist:$srcs, variable_ops),
Evan Cheng5a50cee2010-10-07 01:50:48 +0000143 IndexModeUpd, IIC_fpStore_mu,
Jim Grosbache6913602010-11-03 01:01:43 +0000144 "vstm${amode}${p}\t$Rn!, $srcs",
145 "$Rn = $wb", []> {
Bill Wendling85c3f242010-11-08 21:28:03 +0000146 let Inst{21} = 1; // wback = (W == '1')
147 let Inst{20} = 0; // Store
Evan Chengcd8e66a2008-11-11 21:48:44 +0000148}
Evan Cheng5fd1c9b2010-05-19 06:07:03 +0000149} // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
Evan Chenga8e29892007-01-19 07:51:42 +0000150
151// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
152
153//===----------------------------------------------------------------------===//
154// FP Binary Operations.
155//
156
Bill Wendling69661192010-11-01 06:00:39 +0000157def VADDD : ADbI<0b11100, 0b11, 0, 0,
158 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
159 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
160 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
Bill Wendling174777b2010-10-12 22:08:41 +0000161
Bill Wendling69661192010-11-01 06:00:39 +0000162def VADDS : ASbIn<0b11100, 0b11, 0, 0,
163 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
164 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
165 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000166
Bill Wendling69661192010-11-01 06:00:39 +0000167def VSUBD : ADbI<0b11100, 0b11, 1, 0,
168 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
169 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
170 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
Jim Grosbach499e8862010-10-12 21:22:40 +0000171
Bill Wendling69661192010-11-01 06:00:39 +0000172def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
173 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
174 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
175 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000176
Bill Wendling69661192010-11-01 06:00:39 +0000177def VDIVD : ADbI<0b11101, 0b00, 0, 0,
178 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
179 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
180 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000181
Bill Wendling69661192010-11-01 06:00:39 +0000182def VDIVS : ASbI<0b11101, 0b00, 0, 0,
183 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
184 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
185 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000186
Bill Wendling69661192010-11-01 06:00:39 +0000187def VMULD : ADbI<0b11100, 0b10, 0, 0,
188 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
189 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
190 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000191
Bill Wendling69661192010-11-01 06:00:39 +0000192def VMULS : ASbIn<0b11100, 0b10, 0, 0,
193 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
194 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
195 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]>;
Jim Grosbache5165492009-11-09 00:11:35 +0000196
Bill Wendling69661192010-11-01 06:00:39 +0000197def VNMULD : ADbI<0b11100, 0b10, 1, 0,
198 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
199 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
200 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000201
Bill Wendling69661192010-11-01 06:00:39 +0000202def VNMULS : ASbI<0b11100, 0b10, 1, 0,
203 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
204 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
205 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]>;
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
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000213// These are encoded as unary instructions.
214let Defs = [FPSCR] in {
Bill Wendling69661192010-11-01 06:00:39 +0000215def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
216 (outs), (ins DPR:$Dd, DPR:$Dm),
217 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
218 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000219
Bill Wendling69661192010-11-01 06:00:39 +0000220def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
221 (outs), (ins SPR:$Sd, SPR:$Sm),
222 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
223 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]>;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000224
Bill Wendling67a704d2010-10-13 20:58:46 +0000225// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000226def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0,
227 (outs), (ins DPR:$Dd, DPR:$Dm),
228 IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
229 [/* For disassembly only; pattern left blank */]>;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000230
Bill Wendling69661192010-11-01 06:00:39 +0000231def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
232 (outs), (ins SPR:$Sd, SPR:$Sm),
233 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
234 [/* For disassembly only; pattern left blank */]>;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000235}
Evan Chenga8e29892007-01-19 07:51:42 +0000236
237//===----------------------------------------------------------------------===//
238// FP Unary Operations.
239//
240
Bill Wendling69661192010-11-01 06:00:39 +0000241def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0,
242 (outs DPR:$Dd), (ins DPR:$Dm),
243 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
244 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000245
Bill Wendling69661192010-11-01 06:00:39 +0000246def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
247 (outs SPR:$Sd), (ins SPR:$Sm),
248 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
249 [(set SPR:$Sd, (fabs SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000250
Evan Cheng91449a82009-07-20 02:12:31 +0000251let Defs = [FPSCR] in {
Bill Wendling69661192010-11-01 06:00:39 +0000252def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
253 (outs), (ins DPR:$Dd),
254 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
255 [(arm_cmpfp0 (f64 DPR:$Dd))]> {
256 let Inst{3-0} = 0b0000;
257 let Inst{5} = 0;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000258}
259
Bill Wendling69661192010-11-01 06:00:39 +0000260def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0,
261 (outs), (ins SPR:$Sd),
262 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
263 [(arm_cmpfp0 SPR:$Sd)]> {
264 let Inst{3-0} = 0b0000;
265 let Inst{5} = 0;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000266}
Evan Chenga8e29892007-01-19 07:51:42 +0000267
Bill Wendling67a704d2010-10-13 20:58:46 +0000268// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000269def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0,
270 (outs), (ins DPR:$Dd),
271 IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
272 [/* For disassembly only; pattern left blank */]> {
273 let Inst{3-0} = 0b0000;
274 let Inst{5} = 0;
Bill Wendling67a704d2010-10-13 20:58:46 +0000275}
Johnny Chen7edd8e32010-02-08 19:41:48 +0000276
Bill Wendling69661192010-11-01 06:00:39 +0000277def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
278 (outs), (ins SPR:$Sd),
279 IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
280 [/* For disassembly only; pattern left blank */]> {
281 let Inst{3-0} = 0b0000;
282 let Inst{5} = 0;
Bill Wendling67a704d2010-10-13 20:58:46 +0000283}
Evan Cheng91449a82009-07-20 02:12:31 +0000284}
Evan Chenga8e29892007-01-19 07:51:42 +0000285
Bill Wendling54908dd2010-10-13 00:56:35 +0000286def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
287 (outs DPR:$Dd), (ins SPR:$Sm),
288 IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
289 [(set DPR:$Dd, (fextend SPR:$Sm))]> {
290 // Instruction operands.
291 bits<5> Dd;
292 bits<5> Sm;
293
294 // Encode instruction operands.
295 let Inst{3-0} = Sm{4-1};
296 let Inst{5} = Sm{0};
297 let Inst{15-12} = Dd{3-0};
298 let Inst{22} = Dd{4};
299}
Evan Chenga8e29892007-01-19 07:51:42 +0000300
Evan Cheng96581d32008-11-11 02:11:05 +0000301// Special case encoding: bits 11-8 is 0b1011.
Bill Wendling54908dd2010-10-13 00:56:35 +0000302def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
303 IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
304 [(set SPR:$Sd, (fround DPR:$Dm))]> {
305 // Instruction operands.
306 bits<5> Sd;
307 bits<5> Dm;
308
309 // Encode instruction operands.
310 let Inst{3-0} = Dm{3-0};
311 let Inst{5} = Dm{4};
312 let Inst{15-12} = Sd{4-1};
313 let Inst{22} = Sd{0};
314
Evan Cheng96581d32008-11-11 02:11:05 +0000315 let Inst{27-23} = 0b11101;
316 let Inst{21-16} = 0b110111;
317 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000318 let Inst{7-6} = 0b11;
319 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000320}
Evan Chenga8e29892007-01-19 07:51:42 +0000321
Johnny Chen2d658df2010-02-09 17:21:56 +0000322// Between half-precision and single-precision. For disassembly only.
323
Bill Wendling67a704d2010-10-13 20:58:46 +0000324// FIXME: Verify encoding after integrated assembler is working.
Jim Grosbach18f30e62010-06-02 21:53:11 +0000325def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000326 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000327 [/* For disassembly only; pattern left blank */]>;
328
Bob Wilson76a312b2010-03-19 22:51:32 +0000329def : ARMPat<(f32_to_f16 SPR:$a),
330 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000331
Jim Grosbach18f30e62010-06-02 21:53:11 +0000332def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000333 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000334 [/* For disassembly only; pattern left blank */]>;
335
Bob Wilson76a312b2010-03-19 22:51:32 +0000336def : ARMPat<(f16_to_f32 GPR:$a),
337 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000338
Jim Grosbach18f30e62010-06-02 21:53:11 +0000339def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000340 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000341 [/* For disassembly only; pattern left blank */]>;
342
Jim Grosbach18f30e62010-06-02 21:53:11 +0000343def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
Anton Korobeynikovc492e092010-04-07 18:19:46 +0000344 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
Johnny Chen2d658df2010-02-09 17:21:56 +0000345 [/* For disassembly only; pattern left blank */]>;
346
Bill Wendling69661192010-11-01 06:00:39 +0000347def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
348 (outs DPR:$Dd), (ins DPR:$Dm),
349 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
350 [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000351
Bill Wendling69661192010-11-01 06:00:39 +0000352def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
353 (outs SPR:$Sd), (ins SPR:$Sm),
354 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
355 [(set SPR:$Sd, (fneg SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000356
Bill Wendling69661192010-11-01 06:00:39 +0000357def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0,
358 (outs DPR:$Dd), (ins DPR:$Dm),
359 IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
360 [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000361
Bill Wendling69661192010-11-01 06:00:39 +0000362def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0,
363 (outs SPR:$Sd), (ins SPR:$Sm),
364 IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
365 [(set SPR:$Sd, (fsqrt SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000366
Bill Wendling67a704d2010-10-13 20:58:46 +0000367let neverHasSideEffects = 1 in {
Bill Wendling69661192010-11-01 06:00:39 +0000368def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
369 (outs DPR:$Dd), (ins DPR:$Dm),
370 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000371
Bill Wendling69661192010-11-01 06:00:39 +0000372def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
373 (outs SPR:$Sd), (ins SPR:$Sm),
374 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000375} // neverHasSideEffects
376
Evan Chenga8e29892007-01-19 07:51:42 +0000377//===----------------------------------------------------------------------===//
378// FP <-> GPR Copies. Int <-> FP Conversions.
379//
380
Bill Wendling7d31a162010-10-20 22:44:54 +0000381def VMOVRS : AVConv2I<0b11100001, 0b1010,
382 (outs GPR:$Rt), (ins SPR:$Sn),
383 IIC_fpMOVSI, "vmov", "\t$Rt, $Sn",
384 [(set GPR:$Rt, (bitconvert SPR:$Sn))]> {
385 // Instruction operands.
386 bits<4> Rt;
387 bits<5> Sn;
Evan Chenga8e29892007-01-19 07:51:42 +0000388
Bill Wendling7d31a162010-10-20 22:44:54 +0000389 // Encode instruction operands.
390 let Inst{19-16} = Sn{4-1};
391 let Inst{7} = Sn{0};
392 let Inst{15-12} = Rt;
393
394 let Inst{6-5} = 0b00;
395 let Inst{3-0} = 0b0000;
396}
397
398def VMOVSR : AVConv4I<0b11100000, 0b1010,
399 (outs SPR:$Sn), (ins GPR:$Rt),
400 IIC_fpMOVIS, "vmov", "\t$Sn, $Rt",
401 [(set SPR:$Sn, (bitconvert GPR:$Rt))]> {
402 // Instruction operands.
403 bits<5> Sn;
404 bits<4> Rt;
405
406 // Encode instruction operands.
407 let Inst{19-16} = Sn{4-1};
408 let Inst{7} = Sn{0};
409 let Inst{15-12} = Rt;
410
411 let Inst{6-5} = 0b00;
412 let Inst{3-0} = 0b0000;
413}
Evan Chenga8e29892007-01-19 07:51:42 +0000414
Evan Cheng020cc1b2010-05-13 00:16:46 +0000415let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000416def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000417 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
418 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
Johnny Chen7acca672010-02-05 18:04:58 +0000419 [/* FIXME: Can't write pattern for multiple result instr*/]> {
Bill Wendling01aabda2010-10-20 23:37:40 +0000420 // Instruction operands.
421 bits<5> Dm;
422 bits<4> Rt;
423 bits<4> Rt2;
424
425 // Encode instruction operands.
426 let Inst{3-0} = Dm{3-0};
427 let Inst{5} = Dm{4};
428 let Inst{15-12} = Rt;
429 let Inst{19-16} = Rt2;
430
Johnny Chen7acca672010-02-05 18:04:58 +0000431 let Inst{7-6} = 0b00;
432}
Evan Chenga8e29892007-01-19 07:51:42 +0000433
Johnny Chen23401d62010-02-08 17:26:09 +0000434def VMOVRRS : AVConv3I<0b11000101, 0b1010,
435 (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000436 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000437 [/* For disassembly only; pattern left blank */]> {
438 let Inst{7-6} = 0b00;
439}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000440} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000441
Evan Chenga8e29892007-01-19 07:51:42 +0000442// FMDHR: GPR -> SPR
443// FMDLR: GPR -> SPR
444
Jim Grosbache5165492009-11-09 00:11:35 +0000445def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000446 (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2),
447 IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2",
448 [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]> {
449 // Instruction operands.
450 bits<5> Dm;
451 bits<4> Rt;
452 bits<4> Rt2;
453
454 // Encode instruction operands.
455 let Inst{3-0} = Dm{3-0};
456 let Inst{5} = Dm{4};
457 let Inst{15-12} = Rt;
458 let Inst{19-16} = Rt2;
459
460 let Inst{7-6} = 0b00;
Johnny Chen7acca672010-02-05 18:04:58 +0000461}
Evan Chenga8e29892007-01-19 07:51:42 +0000462
Evan Cheng020cc1b2010-05-13 00:16:46 +0000463let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000464def VMOVSRR : AVConv5I<0b11000100, 0b1010,
465 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000466 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000467 [/* For disassembly only; pattern left blank */]> {
468 let Inst{7-6} = 0b00;
469}
470
Evan Chenga8e29892007-01-19 07:51:42 +0000471// FMRDH: SPR -> GPR
472// FMRDL: SPR -> GPR
473// FMRRS: SPR -> GPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000474// FMRX: SPR system reg -> GPR
Evan Chenga8e29892007-01-19 07:51:42 +0000475// FMSRR: GPR -> SPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000476// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000477
478
Bill Wendling67a704d2010-10-13 20:58:46 +0000479// Int -> FP:
Evan Chenga8e29892007-01-19 07:51:42 +0000480
Bill Wendling67a704d2010-10-13 20:58:46 +0000481class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
482 bits<4> opcod4, dag oops, dag iops,
483 InstrItinClass itin, string opc, string asm,
484 list<dag> pattern>
485 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
486 pattern> {
487 // Instruction operands.
488 bits<5> Dd;
489 bits<5> Sm;
490
491 // Encode instruction operands.
492 let Inst{3-0} = Sm{4-1};
493 let Inst{5} = Sm{0};
494 let Inst{15-12} = Dd{3-0};
495 let Inst{22} = Dd{4};
496}
497
498class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
499 bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
500 string opc, string asm, list<dag> pattern>
501 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
502 pattern> {
503 // Instruction operands.
504 bits<5> Sd;
505 bits<5> Sm;
506
507 // Encode instruction operands.
508 let Inst{3-0} = Sm{4-1};
509 let Inst{5} = Sm{0};
510 let Inst{15-12} = Sd{4-1};
511 let Inst{22} = Sd{0};
512}
513
514def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
515 (outs DPR:$Dd), (ins SPR:$Sm),
516 IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
517 [(set DPR:$Dd, (f64 (arm_sitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000518 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000519}
Evan Chenga8e29892007-01-19 07:51:42 +0000520
Bill Wendling67a704d2010-10-13 20:58:46 +0000521def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
522 (outs SPR:$Sd),(ins SPR:$Sm),
523 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
524 [(set SPR:$Sd, (arm_sitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000525 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000526}
Evan Chenga8e29892007-01-19 07:51:42 +0000527
Bill Wendling67a704d2010-10-13 20:58:46 +0000528def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
529 (outs DPR:$Dd), (ins SPR:$Sm),
530 IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
531 [(set DPR:$Dd, (f64 (arm_uitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000532 let Inst{7} = 0; // u32
533}
Evan Chenga8e29892007-01-19 07:51:42 +0000534
Bill Wendling67a704d2010-10-13 20:58:46 +0000535def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
536 (outs SPR:$Sd), (ins SPR:$Sm),
537 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
538 [(set SPR:$Sd, (arm_uitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000539 let Inst{7} = 0; // u32
540}
Evan Chenga8e29892007-01-19 07:51:42 +0000541
Bill Wendling67a704d2010-10-13 20:58:46 +0000542// FP -> Int:
543
544class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
545 bits<4> opcod4, dag oops, dag iops,
546 InstrItinClass itin, string opc, string asm,
547 list<dag> pattern>
548 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
549 pattern> {
550 // Instruction operands.
551 bits<5> Sd;
552 bits<5> Dm;
553
554 // Encode instruction operands.
555 let Inst{3-0} = Dm{3-0};
556 let Inst{5} = Dm{4};
557 let Inst{15-12} = Sd{4-1};
558 let Inst{22} = Sd{0};
559}
560
561class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
562 bits<4> opcod4, dag oops, dag iops,
563 InstrItinClass itin, string opc, string asm,
564 list<dag> pattern>
565 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
566 pattern> {
567 // Instruction operands.
568 bits<5> Sd;
569 bits<5> Sm;
570
571 // Encode instruction operands.
572 let Inst{3-0} = Sm{4-1};
573 let Inst{5} = Sm{0};
574 let Inst{15-12} = Sd{4-1};
575 let Inst{22} = Sd{0};
576}
577
Evan Chenga8e29892007-01-19 07:51:42 +0000578// Always set Z bit in the instruction, i.e. "round towards zero" variants.
Bill Wendling67a704d2010-10-13 20:58:46 +0000579def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
580 (outs SPR:$Sd), (ins DPR:$Dm),
581 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
582 [(set SPR:$Sd, (arm_ftosi (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000583 let Inst{7} = 1; // Z bit
584}
Evan Chenga8e29892007-01-19 07:51:42 +0000585
Bill Wendling67a704d2010-10-13 20:58:46 +0000586def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
587 (outs SPR:$Sd), (ins SPR:$Sm),
588 IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
589 [(set SPR:$Sd, (arm_ftosi SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000590 let Inst{7} = 1; // Z bit
591}
Evan Chenga8e29892007-01-19 07:51:42 +0000592
Bill Wendling67a704d2010-10-13 20:58:46 +0000593def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
594 (outs SPR:$Sd), (ins DPR:$Dm),
595 IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
596 [(set SPR:$Sd, (arm_ftoui (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000597 let Inst{7} = 1; // Z bit
598}
Evan Chenga8e29892007-01-19 07:51:42 +0000599
Bill Wendling67a704d2010-10-13 20:58:46 +0000600def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
601 (outs SPR:$Sd), (ins SPR:$Sm),
602 IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
603 [(set SPR:$Sd, (arm_ftoui SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000604 let Inst{7} = 1; // Z bit
605}
Evan Chenga8e29892007-01-19 07:51:42 +0000606
Johnny Chen15b423f2010-02-08 22:02:41 +0000607// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
608// For disassembly only.
Nate Begemand1fb5832010-08-03 21:31:55 +0000609let Uses = [FPSCR] in {
Bill Wendling67a704d2010-10-13 20:58:46 +0000610// FIXME: Verify encoding after integrated assembler is working.
611def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
612 (outs SPR:$Sd), (ins DPR:$Dm),
613 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
614 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000615 let Inst{7} = 0; // Z bit
616}
617
Bill Wendling67a704d2010-10-13 20:58:46 +0000618def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
619 (outs SPR:$Sd), (ins SPR:$Sm),
620 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
621 [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000622 let Inst{7} = 0; // Z bit
623}
624
Bill Wendling67a704d2010-10-13 20:58:46 +0000625def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
626 (outs SPR:$Sd), (ins DPR:$Dm),
627 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
Bill Wendling88cf0382010-10-14 01:02:08 +0000628 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000629 let Inst{7} = 0; // Z bit
630}
631
Bill Wendling67a704d2010-10-13 20:58:46 +0000632def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
633 (outs SPR:$Sd), (ins SPR:$Sm),
634 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
635 [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000636 let Inst{7} = 0; // Z bit
637}
Nate Begemand1fb5832010-08-03 21:31:55 +0000638}
Johnny Chen15b423f2010-02-08 22:02:41 +0000639
Johnny Chen27bb8d02010-02-11 18:17:16 +0000640// Convert between floating-point and fixed-point
641// Data type for fixed-point naming convention:
642// S16 (U=0, sx=0) -> SH
643// U16 (U=1, sx=0) -> UH
644// S32 (U=0, sx=1) -> SL
645// U32 (U=1, sx=1) -> UL
646
Bill Wendling160acca2010-11-01 23:11:22 +0000647// FIXME: Marking these as codegen only seems wrong. They are real
648// instructions(?)
649let Constraints = "$a = $dst", isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000650
651// FP to Fixed-Point:
652
653def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
Bill Wendlingcd944a42010-11-01 23:17:54 +0000654 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
Johnny Chen27bb8d02010-02-11 18:17:16 +0000655 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
656 [/* For disassembly only; pattern left blank */]>;
657
658def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
659 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
660 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
661 [/* For disassembly only; pattern left blank */]>;
662
663def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
664 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
665 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
666 [/* For disassembly only; pattern left blank */]>;
667
668def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
669 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
670 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
671 [/* For disassembly only; pattern left blank */]>;
672
673def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
674 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
675 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
676 [/* For disassembly only; pattern left blank */]>;
677
678def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
679 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
680 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
681 [/* For disassembly only; pattern left blank */]>;
682
683def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
684 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
685 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
686 [/* For disassembly only; pattern left blank */]>;
687
688def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
689 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
690 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
691 [/* For disassembly only; pattern left blank */]>;
692
693// Fixed-Point to FP:
694
695def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
696 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
697 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
698 [/* For disassembly only; pattern left blank */]>;
699
700def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
701 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
702 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
703 [/* For disassembly only; pattern left blank */]>;
704
705def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
706 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
707 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
708 [/* For disassembly only; pattern left blank */]>;
709
710def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
711 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
712 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
713 [/* For disassembly only; pattern left blank */]>;
714
715def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
716 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
717 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
718 [/* For disassembly only; pattern left blank */]>;
719
720def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
721 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
722 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
723 [/* For disassembly only; pattern left blank */]>;
724
725def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
726 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
727 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
728 [/* For disassembly only; pattern left blank */]>;
729
730def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
731 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
732 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
733 [/* For disassembly only; pattern left blank */]>;
734
Bill Wendling160acca2010-11-01 23:11:22 +0000735} // End of 'let Constraints = "$a = $dst", isCodeGenOnly = 1 in'
Johnny Chen27bb8d02010-02-11 18:17:16 +0000736
Evan Chenga8e29892007-01-19 07:51:42 +0000737//===----------------------------------------------------------------------===//
738// FP FMA Operations.
739//
740
Evan Cheng529916c2010-11-12 20:32:20 +0000741def VMLAD : ADbI<0b11100, 0b00, 0, 0,
742 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
743 IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
744 [(set DPR:$Dd, (fadd (fmul DPR:$Dn, DPR:$Dm),
745 (f64 DPR:$Ddin)))]>,
746 RegConstraint<"$Ddin = $Dd">,
747 Requires<[HasVFP2,UseVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000748
Bill Wendling69661192010-11-01 06:00:39 +0000749def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
750 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
751 IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
752 [(set SPR:$Sd, (fadd (fmul SPR:$Sn, SPR:$Sm),
753 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000754 RegConstraint<"$Sdin = $Sd">,
755 Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000756
Bill Wendling88cf0382010-10-14 01:02:08 +0000757def : Pat<(fadd DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000758 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
759 Requires<[HasVFP2,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000760def : Pat<(fadd SPR:$dstin, (fmul SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000761 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
762 Requires<[HasVFP2,DontUseNEONForFP, UseVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000763
Evan Cheng529916c2010-11-12 20:32:20 +0000764def VMLSD : ADbI<0b11100, 0b00, 1, 0,
765 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
766 IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
767 [(set DPR:$Dd, (fadd (fneg (fmul DPR:$Dn,DPR:$Dm)),
768 (f64 DPR:$Ddin)))]>,
769 RegConstraint<"$Ddin = $Dd">,
770 Requires<[HasVFP2,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000771
Bill Wendling69661192010-11-01 06:00:39 +0000772def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
773 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
774 IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
775 [(set SPR:$Sd, (fadd (fneg (fmul SPR:$Sn, SPR:$Sm)),
776 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000777 RegConstraint<"$Sdin = $Sd">,
778 Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000779
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000780def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000781 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
782 Requires<[HasVFP2,UseVMLx]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000783def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000784 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
785 Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000786
Evan Cheng529916c2010-11-12 20:32:20 +0000787def VNMLAD : ADbI<0b11100, 0b01, 1, 0,
788 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
789 IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
790 [(set DPR:$Dd,(fsub (fneg (fmul DPR:$Dn,DPR:$Dm)),
791 (f64 DPR:$Ddin)))]>,
792 RegConstraint<"$Ddin = $Dd">,
793 Requires<[HasVFP2,UseVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000794
Bill Wendling69661192010-11-01 06:00:39 +0000795def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
796 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
797 IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
798 [(set SPR:$Sd, (fsub (fneg (fmul SPR:$Sn, SPR:$Sm)),
799 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000800 RegConstraint<"$Sdin = $Sd">,
801 Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000802
803def : Pat<(fsub (fneg (fmul DPR:$a, (f64 DPR:$b))), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000804 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
805 Requires<[HasVFP2,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000806def : Pat<(fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000807 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
808 Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000809
Evan Cheng529916c2010-11-12 20:32:20 +0000810def VNMLSD : ADbI<0b11100, 0b01, 0, 0,
811 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
812 IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
813 [(set DPR:$Dd, (fsub (fmul DPR:$Dn, DPR:$Dm),
814 (f64 DPR:$Ddin)))]>,
815 RegConstraint<"$Ddin = $Dd">,
816 Requires<[HasVFP2,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000817
Bill Wendling69661192010-11-01 06:00:39 +0000818def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
819 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
820 IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
821 [(set SPR:$Sd, (fsub (fmul SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000822 RegConstraint<"$Sdin = $Sd">,
823 Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000824
825def : Pat<(fsub (fmul DPR:$a, (f64 DPR:$b)), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000826 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
827 Requires<[HasVFP2,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000828def : Pat<(fsub (fmul SPR:$a, SPR:$b), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000829 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
830 Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000831
Evan Chenga8e29892007-01-19 07:51:42 +0000832
833//===----------------------------------------------------------------------===//
834// FP Conditional moves.
835//
836
Evan Cheng020cc1b2010-05-13 00:16:46 +0000837let neverHasSideEffects = 1 in {
Bill Wendling69661192010-11-01 06:00:39 +0000838def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
839 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
840 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm",
841 [/*(set DPR:$Dd, (ARMcmov DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
842 RegConstraint<"$Dn = $Dd">;
Evan Chenga8e29892007-01-19 07:51:42 +0000843
Bill Wendling69661192010-11-01 06:00:39 +0000844def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
845 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
846 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm",
847 [/*(set SPR:$Sd, (ARMcmov SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
848 RegConstraint<"$Sn = $Sd">;
Evan Chenga8e29892007-01-19 07:51:42 +0000849
Bill Wendling69661192010-11-01 06:00:39 +0000850def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
851 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
852 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
853 [/*(set DPR:$Dd, (ARMcneg DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
854 RegConstraint<"$Dn = $Dd">;
Evan Chenga8e29892007-01-19 07:51:42 +0000855
Bill Wendling69661192010-11-01 06:00:39 +0000856def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
857 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
858 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
859 [/*(set SPR:$Sd, (ARMcneg SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
860 RegConstraint<"$Sn = $Sd">;
Evan Cheng020cc1b2010-05-13 00:16:46 +0000861} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +0000862
863//===----------------------------------------------------------------------===//
864// Misc.
865//
866
Evan Cheng1e13c792009-11-10 19:44:56 +0000867// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
868// to APSR.
Evan Cheng91449a82009-07-20 02:12:31 +0000869let Defs = [CPSR], Uses = [FPSCR] in
Bill Wendling160acca2010-11-01 23:11:22 +0000870def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT,
871 "vmrs", "\tapsr_nzcv, fpscr",
Bill Wendlingbbbdcd42010-10-14 02:33:26 +0000872 [(arm_fmstat)]> {
Evan Chengcd8e66a2008-11-11 21:48:44 +0000873 let Inst{27-20} = 0b11101111;
874 let Inst{19-16} = 0b0001;
875 let Inst{15-12} = 0b1111;
876 let Inst{11-8} = 0b1010;
877 let Inst{7} = 0;
Bill Wendling946a2742010-10-14 01:19:34 +0000878 let Inst{6-5} = 0b00;
Evan Chengcd8e66a2008-11-11 21:48:44 +0000879 let Inst{4} = 1;
Bill Wendling946a2742010-10-14 01:19:34 +0000880 let Inst{3-0} = 0b0000;
Evan Chengcd8e66a2008-11-11 21:48:44 +0000881}
Evan Cheng39382422009-10-28 01:44:26 +0000882
Bill Wendlingbbbdcd42010-10-14 02:33:26 +0000883// FPSCR <-> GPR
Nate Begemand1fb5832010-08-03 21:31:55 +0000884let hasSideEffects = 1, Uses = [FPSCR] in
Bill Wendling88cf0382010-10-14 01:02:08 +0000885def VMRS : VFPAI<(outs GPR:$Rt), (ins), VFPMiscFrm, IIC_fpSTAT,
886 "vmrs", "\t$Rt, fpscr",
887 [(set GPR:$Rt, (int_arm_get_fpscr))]> {
888 // Instruction operand.
889 bits<4> Rt;
890
891 // Encode instruction operand.
892 let Inst{15-12} = Rt;
893
Johnny Chenc9745042010-02-09 22:35:38 +0000894 let Inst{27-20} = 0b11101111;
895 let Inst{19-16} = 0b0001;
896 let Inst{11-8} = 0b1010;
897 let Inst{7} = 0;
Bill Wendling88cf0382010-10-14 01:02:08 +0000898 let Inst{6-5} = 0b00;
Johnny Chenc9745042010-02-09 22:35:38 +0000899 let Inst{4} = 1;
Bill Wendling88cf0382010-10-14 01:02:08 +0000900 let Inst{3-0} = 0b0000;
Johnny Chenc9745042010-02-09 22:35:38 +0000901}
Johnny Chenc9745042010-02-09 22:35:38 +0000902
Nate Begemand1fb5832010-08-03 21:31:55 +0000903let Defs = [FPSCR] in
904def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT,
905 "vmsr", "\tfpscr, $src",
Bill Wendling88cf0382010-10-14 01:02:08 +0000906 [(int_arm_set_fpscr GPR:$src)]> {
907 // Instruction operand.
908 bits<4> src;
909
910 // Encode instruction operand.
911 let Inst{15-12} = src;
912
Johnny Chenc9745042010-02-09 22:35:38 +0000913 let Inst{27-20} = 0b11101110;
914 let Inst{19-16} = 0b0001;
915 let Inst{11-8} = 0b1010;
916 let Inst{7} = 0;
917 let Inst{4} = 1;
918}
Evan Cheng39382422009-10-28 01:44:26 +0000919
920// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +0000921let isReMaterializable = 1 in {
Bill Wendlingbbbdcd42010-10-14 02:33:26 +0000922def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +0000923 VFPMiscFrm, IIC_fpUNA64,
Bill Wendlingbbbdcd42010-10-14 02:33:26 +0000924 "vmov", ".f64\t$Dd, $imm",
925 [(set DPR:$Dd, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
926 // Instruction operands.
927 bits<5> Dd;
928 bits<32> imm;
929
930 // Encode instruction operands.
931 let Inst{15-12} = Dd{3-0};
932 let Inst{22} = Dd{4};
933 let Inst{19} = imm{31};
934 let Inst{18-16} = imm{22-20};
935 let Inst{3-0} = imm{19-16};
936
937 // Encode remaining instruction bits.
Jim Grosbache5165492009-11-09 00:11:35 +0000938 let Inst{27-23} = 0b11101;
939 let Inst{21-20} = 0b11;
940 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +0000941 let Inst{8} = 1; // Double precision.
Jim Grosbache5165492009-11-09 00:11:35 +0000942 let Inst{7-4} = 0b0000;
943}
944
Bill Wendlingbbbdcd42010-10-14 02:33:26 +0000945def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm),
946 VFPMiscFrm, IIC_fpUNA32,
947 "vmov", ".f32\t$Sd, $imm",
948 [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
949 // Instruction operands.
950 bits<5> Sd;
951 bits<32> imm;
952
953 // Encode instruction operands.
954 let Inst{15-12} = Sd{4-1};
955 let Inst{22} = Sd{0};
956 let Inst{19} = imm{31}; // The immediate is handled as a double.
957 let Inst{18-16} = imm{22-20};
958 let Inst{3-0} = imm{19-16};
959
960 // Encode remaining instruction bits.
Evan Cheng39382422009-10-28 01:44:26 +0000961 let Inst{27-23} = 0b11101;
962 let Inst{21-20} = 0b11;
963 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +0000964 let Inst{8} = 0; // Single precision.
Evan Cheng39382422009-10-28 01:44:26 +0000965 let Inst{7-4} = 0b0000;
966}
Evan Cheng39382422009-10-28 01:44:26 +0000967}