blob: d6628bb6952b27d45956a49c17007acae892edc5 [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>;
Chris Lattner036609b2010-12-23 18:28:41 +000024def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInGlue, SDNPOutGlue]>;
25def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutGlue]>;
26def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutGlue]>;
Bill Wendling2695d8e2010-10-15 21:50:45 +000027def 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";
Owen Anderson96279d02011-08-02 18:30:00 +000039 let DecoderMethod = "DecodeVFPfpImm";
Evan Cheng39382422009-10-28 01:44:26 +000040}
41
42def vfp_f64imm : Operand<f64>,
43 PatLeaf<(f64 fpimm), [{
44 return ARM::getVFPf64Imm(N->getValueAPF()) != -1;
45 }]> {
46 let PrintMethod = "printVFPf64ImmOperand";
Owen Anderson96279d02011-08-02 18:30:00 +000047 let DecoderMethod = "DecodeVFPfpImm";
Evan Cheng39382422009-10-28 01:44:26 +000048}
49
50
51//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +000052// Load / store Instructions.
53//
54
Dan Gohmanbc9d98b2010-02-27 23:47:46 +000055let canFoldAsLoad = 1, isReMaterializable = 1 in {
Bill Wendling92b5a2e2010-11-03 01:49:29 +000056
Bill Wendling7d31a162010-10-20 22:44:54 +000057def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr),
58 IIC_fpLoad64, "vldr", ".64\t$Dd, $addr",
Bill Wendling2f46f1f2010-11-04 00:59:42 +000059 [(set DPR:$Dd, (f64 (load addrmode5:$addr)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +000060
Bill Wendling92b5a2e2010-11-03 01:49:29 +000061def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr),
62 IIC_fpLoad32, "vldr", ".32\t$Sd, $addr",
Evan Cheng5eda2822011-02-16 00:35:02 +000063 [(set SPR:$Sd, (load addrmode5:$addr))]> {
64 // Some single precision VFP instructions may be executed on both NEON and VFP
65 // pipelines.
66 let D = VFPNeonDomain;
67}
Bill Wendling92b5a2e2010-11-03 01:49:29 +000068
69} // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in'
Evan Chenga8e29892007-01-19 07:51:42 +000070
Bill Wendling2f46f1f2010-11-04 00:59:42 +000071def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr),
72 IIC_fpStore64, "vstr", ".64\t$Dd, $addr",
73 [(store (f64 DPR:$Dd), addrmode5:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +000074
Bill Wendling2f46f1f2010-11-04 00:59:42 +000075def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr),
76 IIC_fpStore32, "vstr", ".32\t$Sd, $addr",
Evan Cheng5eda2822011-02-16 00:35:02 +000077 [(store SPR:$Sd, addrmode5:$addr)]> {
78 // Some single precision VFP instructions may be executed on both NEON and VFP
79 // pipelines.
80 let D = VFPNeonDomain;
81}
Evan Chenga8e29892007-01-19 07:51:42 +000082
83//===----------------------------------------------------------------------===//
84// Load / store multiple Instructions.
85//
86
Bill Wendling73fe34a2010-11-16 01:16:36 +000087multiclass vfp_ldst_mult<string asm, bit L_bit,
88 InstrItinClass itin, InstrItinClass itin_upd> {
89 // Double Precision
90 def DIA :
Bill Wendling0f630752010-11-17 04:32:08 +000091 AXDI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +000092 IndexModeNone, itin,
Bill Wendling73fe34a2010-11-16 01:16:36 +000093 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +000094 let Inst{24-23} = 0b01; // Increment After
95 let Inst{21} = 0; // No writeback
96 let Inst{20} = L_bit;
97 }
Bill Wendling73fe34a2010-11-16 01:16:36 +000098 def DIA_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +000099 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
100 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000101 IndexModeUpd, itin_upd,
Bill Wendling73fe34a2010-11-16 01:16:36 +0000102 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000103 let Inst{24-23} = 0b01; // Increment After
104 let Inst{21} = 1; // Writeback
105 let Inst{20} = L_bit;
106 }
Bill Wendling73fe34a2010-11-16 01:16:36 +0000107 def DDB_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +0000108 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
109 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000110 IndexModeUpd, itin_upd,
111 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
112 let Inst{24-23} = 0b10; // Decrement Before
113 let Inst{21} = 1; // Writeback
114 let Inst{20} = L_bit;
115 }
Bill Wendling6c470b82010-11-13 09:09:38 +0000116
Bill Wendling73fe34a2010-11-16 01:16:36 +0000117 // Single Precision
118 def SIA :
Bill Wendling0f630752010-11-17 04:32:08 +0000119 AXSI4<(outs), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000120 IndexModeNone, itin,
Bill Wendling73fe34a2010-11-16 01:16:36 +0000121 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000122 let Inst{24-23} = 0b01; // Increment After
123 let Inst{21} = 0; // No writeback
124 let Inst{20} = L_bit;
Evan Cheng5eda2822011-02-16 00:35:02 +0000125
126 // Some single precision VFP instructions may be executed on both NEON and
127 // VFP pipelines.
128 let D = VFPNeonDomain;
Bill Wendling6c470b82010-11-13 09:09:38 +0000129 }
Bill Wendling73fe34a2010-11-16 01:16:36 +0000130 def SIA_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +0000131 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
132 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000133 IndexModeUpd, itin_upd,
Bill Wendling73fe34a2010-11-16 01:16:36 +0000134 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000135 let Inst{24-23} = 0b01; // Increment After
136 let Inst{21} = 1; // Writeback
137 let Inst{20} = L_bit;
Evan Cheng5eda2822011-02-16 00:35:02 +0000138
139 // Some single precision VFP instructions may be executed on both NEON and
140 // VFP pipelines.
141 let D = VFPNeonDomain;
Bill Wendling6c470b82010-11-13 09:09:38 +0000142 }
Bill Wendling73fe34a2010-11-16 01:16:36 +0000143 def SDB_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +0000144 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
145 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000146 IndexModeUpd, itin_upd,
147 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
148 let Inst{24-23} = 0b10; // Decrement Before
149 let Inst{21} = 1; // Writeback
150 let Inst{20} = L_bit;
Evan Cheng5eda2822011-02-16 00:35:02 +0000151
152 // Some single precision VFP instructions may be executed on both NEON and
153 // VFP pipelines.
154 let D = VFPNeonDomain;
Bill Wendling6c470b82010-11-13 09:09:38 +0000155 }
156}
157
Bill Wendlingddc918b2010-11-13 10:57:02 +0000158let neverHasSideEffects = 1 in {
159
Bill Wendling73fe34a2010-11-16 01:16:36 +0000160let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
161defm VLDM : vfp_ldst_mult<"vldm", 1, IIC_fpLoad_m, IIC_fpLoad_mu>;
Bill Wendlingddc918b2010-11-13 10:57:02 +0000162
Bill Wendling73fe34a2010-11-16 01:16:36 +0000163let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
164defm VSTM : vfp_ldst_mult<"vstm", 0, IIC_fpLoad_m, IIC_fpLoad_mu>;
Bill Wendlingddc918b2010-11-13 10:57:02 +0000165
166} // neverHasSideEffects
167
Bill Wendling73c57e12010-11-16 02:00:24 +0000168def : MnemonicAlias<"vldm", "vldmia">;
169def : MnemonicAlias<"vstm", "vstmia">;
170
Jim Grosbach0d06bb92011-06-27 20:00:07 +0000171def : InstAlias<"vpush${p} $r", (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r)>,
172 Requires<[HasVFP2]>;
173def : InstAlias<"vpush${p} $r", (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r)>,
174 Requires<[HasVFP2]>;
175def : InstAlias<"vpop${p} $r", (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r)>,
176 Requires<[HasVFP2]>;
177def : InstAlias<"vpop${p} $r", (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r)>,
178 Requires<[HasVFP2]>;
179
Evan Chenga8e29892007-01-19 07:51:42 +0000180// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
181
182//===----------------------------------------------------------------------===//
183// FP Binary Operations.
184//
185
Bill Wendling69661192010-11-01 06:00:39 +0000186def VADDD : ADbI<0b11100, 0b11, 0, 0,
187 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
188 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
189 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
Bill Wendling174777b2010-10-12 22:08:41 +0000190
Bill Wendling69661192010-11-01 06:00:39 +0000191def VADDS : ASbIn<0b11100, 0b11, 0, 0,
192 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
193 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000194 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000195 // Some single precision VFP instructions may be executed on both NEON and
196 // VFP pipelines on A8.
197 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000198}
Evan Chenga8e29892007-01-19 07:51:42 +0000199
Bill Wendling69661192010-11-01 06:00:39 +0000200def VSUBD : ADbI<0b11100, 0b11, 1, 0,
201 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
202 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
203 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
Jim Grosbach499e8862010-10-12 21:22:40 +0000204
Bill Wendling69661192010-11-01 06:00:39 +0000205def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
206 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
207 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000208 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000209 // Some single precision VFP instructions may be executed on both NEON and
210 // VFP pipelines on A8.
211 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000212}
Evan Chenga8e29892007-01-19 07:51:42 +0000213
Bill Wendling69661192010-11-01 06:00:39 +0000214def VDIVD : ADbI<0b11101, 0b00, 0, 0,
215 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
216 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
217 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000218
Bill Wendling69661192010-11-01 06:00:39 +0000219def VDIVS : ASbI<0b11101, 0b00, 0, 0,
220 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
221 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
222 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000223
Bill Wendling69661192010-11-01 06:00:39 +0000224def VMULD : ADbI<0b11100, 0b10, 0, 0,
225 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
226 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
227 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000228
Bill Wendling69661192010-11-01 06:00:39 +0000229def VMULS : ASbIn<0b11100, 0b10, 0, 0,
230 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
231 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000232 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000233 // Some single precision VFP instructions may be executed on both NEON and
234 // VFP pipelines on A8.
235 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000236}
Jim Grosbache5165492009-11-09 00:11:35 +0000237
Bill Wendling69661192010-11-01 06:00:39 +0000238def VNMULD : ADbI<0b11100, 0b10, 1, 0,
239 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
240 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
241 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000242
Bill Wendling69661192010-11-01 06:00:39 +0000243def VNMULS : ASbI<0b11100, 0b10, 1, 0,
244 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
245 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000246 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000247 // Some single precision VFP instructions may be executed on both NEON and
248 // VFP pipelines on A8.
249 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000250}
Evan Chenga8e29892007-01-19 07:51:42 +0000251
Chris Lattner72939122007-05-03 00:32:00 +0000252// Match reassociated forms only if not sign dependent rounding.
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000253def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000254 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000255def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000256 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000257
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000258// These are encoded as unary instructions.
259let Defs = [FPSCR] in {
Bill Wendling69661192010-11-01 06:00:39 +0000260def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
261 (outs), (ins DPR:$Dd, DPR:$Dm),
262 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
263 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000264
Bill Wendling69661192010-11-01 06:00:39 +0000265def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
266 (outs), (ins SPR:$Sd, SPR:$Sm),
267 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000268 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000269 // Some single precision VFP instructions may be executed on both NEON and
270 // VFP pipelines on A8.
271 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000272}
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000273
Bill Wendling67a704d2010-10-13 20:58:46 +0000274// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000275def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0,
276 (outs), (ins DPR:$Dd, DPR:$Dm),
277 IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
278 [/* For disassembly only; pattern left blank */]>;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000279
Bill Wendling69661192010-11-01 06:00:39 +0000280def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
281 (outs), (ins SPR:$Sd, SPR:$Sm),
282 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000283 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000284 // Some single precision VFP instructions may be executed on both NEON and
285 // VFP pipelines on A8.
286 let D = VFPNeonA8Domain;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000287}
Evan Cheng5eda2822011-02-16 00:35:02 +0000288} // Defs = [FPSCR]
Evan Chenga8e29892007-01-19 07:51:42 +0000289
290//===----------------------------------------------------------------------===//
291// FP Unary Operations.
292//
293
Bill Wendling69661192010-11-01 06:00:39 +0000294def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0,
295 (outs DPR:$Dd), (ins DPR:$Dm),
296 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
297 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000298
Bill Wendling69661192010-11-01 06:00:39 +0000299def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
300 (outs SPR:$Sd), (ins SPR:$Sm),
301 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000302 [(set SPR:$Sd, (fabs SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000303 // Some single precision VFP instructions may be executed on both NEON and
304 // VFP pipelines on A8.
305 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000306}
Evan Chenga8e29892007-01-19 07:51:42 +0000307
Evan Cheng91449a82009-07-20 02:12:31 +0000308let Defs = [FPSCR] in {
Bill Wendling69661192010-11-01 06:00:39 +0000309def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
310 (outs), (ins DPR:$Dd),
311 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
312 [(arm_cmpfp0 (f64 DPR:$Dd))]> {
313 let Inst{3-0} = 0b0000;
314 let Inst{5} = 0;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000315}
316
Bill Wendling69661192010-11-01 06:00:39 +0000317def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0,
318 (outs), (ins SPR:$Sd),
319 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
320 [(arm_cmpfp0 SPR:$Sd)]> {
321 let Inst{3-0} = 0b0000;
322 let Inst{5} = 0;
Evan Cheng5eda2822011-02-16 00:35:02 +0000323
Evan Cheng6557bce2011-02-22 19:53:14 +0000324 // Some single precision VFP instructions may be executed on both NEON and
325 // VFP pipelines on A8.
326 let D = VFPNeonA8Domain;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000327}
Evan Chenga8e29892007-01-19 07:51:42 +0000328
Bill Wendling67a704d2010-10-13 20:58:46 +0000329// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000330def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0,
331 (outs), (ins DPR:$Dd),
332 IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
333 [/* For disassembly only; pattern left blank */]> {
334 let Inst{3-0} = 0b0000;
335 let Inst{5} = 0;
Bill Wendling67a704d2010-10-13 20:58:46 +0000336}
Johnny Chen7edd8e32010-02-08 19:41:48 +0000337
Bill Wendling69661192010-11-01 06:00:39 +0000338def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
339 (outs), (ins SPR:$Sd),
340 IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
341 [/* For disassembly only; pattern left blank */]> {
342 let Inst{3-0} = 0b0000;
343 let Inst{5} = 0;
Evan Cheng5eda2822011-02-16 00:35:02 +0000344
Evan Cheng6557bce2011-02-22 19:53:14 +0000345 // Some single precision VFP instructions may be executed on both NEON and
346 // VFP pipelines on A8.
347 let D = VFPNeonA8Domain;
Bill Wendling67a704d2010-10-13 20:58:46 +0000348}
Evan Cheng5eda2822011-02-16 00:35:02 +0000349} // Defs = [FPSCR]
Evan Chenga8e29892007-01-19 07:51:42 +0000350
Bill Wendling54908dd2010-10-13 00:56:35 +0000351def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
352 (outs DPR:$Dd), (ins SPR:$Sm),
353 IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
354 [(set DPR:$Dd, (fextend SPR:$Sm))]> {
355 // Instruction operands.
356 bits<5> Dd;
357 bits<5> Sm;
358
359 // Encode instruction operands.
360 let Inst{3-0} = Sm{4-1};
361 let Inst{5} = Sm{0};
362 let Inst{15-12} = Dd{3-0};
363 let Inst{22} = Dd{4};
364}
Evan Chenga8e29892007-01-19 07:51:42 +0000365
Evan Cheng96581d32008-11-11 02:11:05 +0000366// Special case encoding: bits 11-8 is 0b1011.
Bill Wendling54908dd2010-10-13 00:56:35 +0000367def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
368 IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
369 [(set SPR:$Sd, (fround DPR:$Dm))]> {
370 // Instruction operands.
371 bits<5> Sd;
372 bits<5> Dm;
373
374 // Encode instruction operands.
375 let Inst{3-0} = Dm{3-0};
376 let Inst{5} = Dm{4};
377 let Inst{15-12} = Sd{4-1};
378 let Inst{22} = Sd{0};
379
Evan Cheng96581d32008-11-11 02:11:05 +0000380 let Inst{27-23} = 0b11101;
381 let Inst{21-16} = 0b110111;
382 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000383 let Inst{7-6} = 0b11;
384 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000385}
Evan Chenga8e29892007-01-19 07:51:42 +0000386
Johnny Chen2d658df2010-02-09 17:21:56 +0000387// Between half-precision and single-precision. For disassembly only.
388
Bill Wendling67a704d2010-10-13 20:58:46 +0000389// FIXME: Verify encoding after integrated assembler is working.
Owen Anderson838130e2011-08-22 21:34:00 +0000390def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
391 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$Sd, $Sm",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000392 [/* For disassembly only; pattern left blank */]>;
393
Bob Wilson76a312b2010-03-19 22:51:32 +0000394def : ARMPat<(f32_to_f16 SPR:$a),
395 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000396
Owen Anderson838130e2011-08-22 21:34:00 +0000397def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
398 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$Sd, $Sm",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000399 [/* For disassembly only; pattern left blank */]>;
400
Bob Wilson76a312b2010-03-19 22:51:32 +0000401def : ARMPat<(f16_to_f32 GPR:$a),
402 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000403
Owen Anderson838130e2011-08-22 21:34:00 +0000404def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
405 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$Sd, $Sm",
Johnny Chen2d658df2010-02-09 17:21:56 +0000406 [/* For disassembly only; pattern left blank */]>;
407
Owen Anderson838130e2011-08-22 21:34:00 +0000408def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
409 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$Sd, $Sm",
Johnny Chen2d658df2010-02-09 17:21:56 +0000410 [/* For disassembly only; pattern left blank */]>;
411
Bill Wendling69661192010-11-01 06:00:39 +0000412def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
413 (outs DPR:$Dd), (ins DPR:$Dm),
414 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
415 [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000416
Bill Wendling69661192010-11-01 06:00:39 +0000417def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
418 (outs SPR:$Sd), (ins SPR:$Sm),
419 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000420 [(set SPR:$Sd, (fneg SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000421 // Some single precision VFP instructions may be executed on both NEON and
422 // VFP pipelines on A8.
423 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000424}
Evan Chenga8e29892007-01-19 07:51:42 +0000425
Bill Wendling69661192010-11-01 06:00:39 +0000426def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0,
427 (outs DPR:$Dd), (ins DPR:$Dm),
428 IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
429 [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000430
Bill Wendling69661192010-11-01 06:00:39 +0000431def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0,
432 (outs SPR:$Sd), (ins SPR:$Sm),
433 IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
434 [(set SPR:$Sd, (fsqrt SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000435
Bill Wendling67a704d2010-10-13 20:58:46 +0000436let neverHasSideEffects = 1 in {
Bill Wendling69661192010-11-01 06:00:39 +0000437def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
438 (outs DPR:$Dd), (ins DPR:$Dm),
439 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000440
Bill Wendling69661192010-11-01 06:00:39 +0000441def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
442 (outs SPR:$Sd), (ins SPR:$Sm),
443 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000444} // neverHasSideEffects
445
Evan Chenga8e29892007-01-19 07:51:42 +0000446//===----------------------------------------------------------------------===//
447// FP <-> GPR Copies. Int <-> FP Conversions.
448//
449
Bill Wendling7d31a162010-10-20 22:44:54 +0000450def VMOVRS : AVConv2I<0b11100001, 0b1010,
451 (outs GPR:$Rt), (ins SPR:$Sn),
452 IIC_fpMOVSI, "vmov", "\t$Rt, $Sn",
453 [(set GPR:$Rt, (bitconvert SPR:$Sn))]> {
454 // Instruction operands.
455 bits<4> Rt;
456 bits<5> Sn;
Evan Chenga8e29892007-01-19 07:51:42 +0000457
Bill Wendling7d31a162010-10-20 22:44:54 +0000458 // Encode instruction operands.
459 let Inst{19-16} = Sn{4-1};
460 let Inst{7} = Sn{0};
461 let Inst{15-12} = Rt;
462
463 let Inst{6-5} = 0b00;
464 let Inst{3-0} = 0b0000;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000465
466 // Some single precision VFP instructions may be executed on both NEON and VFP
467 // pipelines.
468 let D = VFPNeonDomain;
Bill Wendling7d31a162010-10-20 22:44:54 +0000469}
470
471def VMOVSR : AVConv4I<0b11100000, 0b1010,
472 (outs SPR:$Sn), (ins GPR:$Rt),
473 IIC_fpMOVIS, "vmov", "\t$Sn, $Rt",
474 [(set SPR:$Sn, (bitconvert GPR:$Rt))]> {
475 // Instruction operands.
476 bits<5> Sn;
477 bits<4> Rt;
478
479 // Encode instruction operands.
480 let Inst{19-16} = Sn{4-1};
481 let Inst{7} = Sn{0};
482 let Inst{15-12} = Rt;
483
484 let Inst{6-5} = 0b00;
485 let Inst{3-0} = 0b0000;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000486
487 // Some single precision VFP instructions may be executed on both NEON and VFP
488 // pipelines.
489 let D = VFPNeonDomain;
Bill Wendling7d31a162010-10-20 22:44:54 +0000490}
Evan Chenga8e29892007-01-19 07:51:42 +0000491
Evan Cheng020cc1b2010-05-13 00:16:46 +0000492let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000493def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000494 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
495 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
Johnny Chen7acca672010-02-05 18:04:58 +0000496 [/* FIXME: Can't write pattern for multiple result instr*/]> {
Bill Wendling01aabda2010-10-20 23:37:40 +0000497 // Instruction operands.
498 bits<5> Dm;
499 bits<4> Rt;
500 bits<4> Rt2;
501
502 // Encode instruction operands.
503 let Inst{3-0} = Dm{3-0};
504 let Inst{5} = Dm{4};
505 let Inst{15-12} = Rt;
506 let Inst{19-16} = Rt2;
507
Johnny Chen7acca672010-02-05 18:04:58 +0000508 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000509
510 // Some single precision VFP instructions may be executed on both NEON and VFP
511 // pipelines.
512 let D = VFPNeonDomain;
Johnny Chen7acca672010-02-05 18:04:58 +0000513}
Evan Chenga8e29892007-01-19 07:51:42 +0000514
Johnny Chen23401d62010-02-08 17:26:09 +0000515def VMOVRRS : AVConv3I<0b11000101, 0b1010,
Owen Anderson694e0ff2011-08-29 23:15:25 +0000516 (outs GPR:$Rt, GPR:$Rt2), (ins SPR:$src1, SPR:$src2),
517 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000518 [/* For disassembly only; pattern left blank */]> {
Owen Anderson694e0ff2011-08-29 23:15:25 +0000519 bits<5> src1;
520 bits<4> Rt;
521 bits<4> Rt2;
522
523 // Encode instruction operands.
524 let Inst{3-0} = src1{3-0};
525 let Inst{5} = src1{4};
526 let Inst{15-12} = Rt;
527 let Inst{19-16} = Rt2;
528
Johnny Chen23401d62010-02-08 17:26:09 +0000529 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000530
531 // Some single precision VFP instructions may be executed on both NEON and VFP
532 // pipelines.
533 let D = VFPNeonDomain;
Owen Anderson357ec682011-08-22 20:27:12 +0000534 let DecoderMethod = "DecodeVMOVRRS";
Johnny Chen23401d62010-02-08 17:26:09 +0000535}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000536} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000537
Evan Chenga8e29892007-01-19 07:51:42 +0000538// FMDHR: GPR -> SPR
539// FMDLR: GPR -> SPR
540
Jim Grosbache5165492009-11-09 00:11:35 +0000541def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000542 (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2),
543 IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2",
544 [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]> {
545 // Instruction operands.
546 bits<5> Dm;
547 bits<4> Rt;
548 bits<4> Rt2;
549
550 // Encode instruction operands.
551 let Inst{3-0} = Dm{3-0};
552 let Inst{5} = Dm{4};
553 let Inst{15-12} = Rt;
554 let Inst{19-16} = Rt2;
555
556 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000557
558 // Some single precision VFP instructions may be executed on both NEON and VFP
559 // pipelines.
560 let D = VFPNeonDomain;
Johnny Chen7acca672010-02-05 18:04:58 +0000561}
Evan Chenga8e29892007-01-19 07:51:42 +0000562
Evan Cheng020cc1b2010-05-13 00:16:46 +0000563let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000564def VMOVSRR : AVConv5I<0b11000100, 0b1010,
565 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000566 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000567 [/* For disassembly only; pattern left blank */]> {
Owen Anderson694e0ff2011-08-29 23:15:25 +0000568 // Instruction operands.
569 bits<5> dst1;
570 bits<4> src1;
571 bits<4> src2;
572
573 // Encode instruction operands.
574 let Inst{3-0} = dst1{3-0};
575 let Inst{5} = dst1{4};
576 let Inst{15-12} = src1;
577 let Inst{19-16} = src2;
578
Johnny Chen23401d62010-02-08 17:26:09 +0000579 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000580
581 // Some single precision VFP instructions may be executed on both NEON and VFP
582 // pipelines.
583 let D = VFPNeonDomain;
Owen Anderson357ec682011-08-22 20:27:12 +0000584
585 let DecoderMethod = "DecodeVMOVSRR";
Johnny Chen23401d62010-02-08 17:26:09 +0000586}
587
Evan Chenga8e29892007-01-19 07:51:42 +0000588// FMRDH: SPR -> GPR
589// FMRDL: SPR -> GPR
590// FMRRS: SPR -> GPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000591// FMRX: SPR system reg -> GPR
Evan Chenga8e29892007-01-19 07:51:42 +0000592// FMSRR: GPR -> SPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000593// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000594
595
Bill Wendling67a704d2010-10-13 20:58:46 +0000596// Int -> FP:
Evan Chenga8e29892007-01-19 07:51:42 +0000597
Bill Wendling67a704d2010-10-13 20:58:46 +0000598class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
599 bits<4> opcod4, dag oops, dag iops,
600 InstrItinClass itin, string opc, string asm,
601 list<dag> pattern>
602 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
603 pattern> {
604 // Instruction operands.
605 bits<5> Dd;
606 bits<5> Sm;
607
608 // Encode instruction operands.
609 let Inst{3-0} = Sm{4-1};
610 let Inst{5} = Sm{0};
611 let Inst{15-12} = Dd{3-0};
612 let Inst{22} = Dd{4};
613}
614
615class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
616 bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
617 string opc, string asm, list<dag> pattern>
618 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
619 pattern> {
620 // Instruction operands.
621 bits<5> Sd;
622 bits<5> Sm;
623
624 // Encode instruction operands.
625 let Inst{3-0} = Sm{4-1};
626 let Inst{5} = Sm{0};
627 let Inst{15-12} = Sd{4-1};
628 let Inst{22} = Sd{0};
629}
630
631def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
632 (outs DPR:$Dd), (ins SPR:$Sm),
633 IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
634 [(set DPR:$Dd, (f64 (arm_sitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000635 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000636}
Evan Chenga8e29892007-01-19 07:51:42 +0000637
Bill Wendling67a704d2010-10-13 20:58:46 +0000638def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
639 (outs SPR:$Sd),(ins SPR:$Sm),
640 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
641 [(set SPR:$Sd, (arm_sitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000642 let Inst{7} = 1; // s32
Evan Cheng5eda2822011-02-16 00:35:02 +0000643
Evan Cheng6557bce2011-02-22 19:53:14 +0000644 // Some single precision VFP instructions may be executed on both NEON and
645 // VFP pipelines on A8.
646 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000647}
Evan Chenga8e29892007-01-19 07:51:42 +0000648
Bill Wendling67a704d2010-10-13 20:58:46 +0000649def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
650 (outs DPR:$Dd), (ins SPR:$Sm),
651 IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
652 [(set DPR:$Dd, (f64 (arm_uitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000653 let Inst{7} = 0; // u32
654}
Evan Chenga8e29892007-01-19 07:51:42 +0000655
Bill Wendling67a704d2010-10-13 20:58:46 +0000656def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
657 (outs SPR:$Sd), (ins SPR:$Sm),
658 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
659 [(set SPR:$Sd, (arm_uitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000660 let Inst{7} = 0; // u32
Evan Cheng5eda2822011-02-16 00:35:02 +0000661
Evan Cheng6557bce2011-02-22 19:53:14 +0000662 // Some single precision VFP instructions may be executed on both NEON and
663 // VFP pipelines on A8.
664 let D = VFPNeonA8Domain;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000665}
Evan Chenga8e29892007-01-19 07:51:42 +0000666
Bill Wendling67a704d2010-10-13 20:58:46 +0000667// FP -> Int:
668
669class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
670 bits<4> opcod4, dag oops, dag iops,
671 InstrItinClass itin, string opc, string asm,
672 list<dag> pattern>
673 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
674 pattern> {
675 // Instruction operands.
676 bits<5> Sd;
677 bits<5> Dm;
678
679 // Encode instruction operands.
680 let Inst{3-0} = Dm{3-0};
681 let Inst{5} = Dm{4};
682 let Inst{15-12} = Sd{4-1};
683 let Inst{22} = Sd{0};
684}
685
686class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
687 bits<4> opcod4, dag oops, dag iops,
688 InstrItinClass itin, string opc, string asm,
689 list<dag> pattern>
690 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
691 pattern> {
692 // Instruction operands.
693 bits<5> Sd;
694 bits<5> Sm;
695
696 // Encode instruction operands.
697 let Inst{3-0} = Sm{4-1};
698 let Inst{5} = Sm{0};
699 let Inst{15-12} = Sd{4-1};
700 let Inst{22} = Sd{0};
701}
702
Evan Chenga8e29892007-01-19 07:51:42 +0000703// Always set Z bit in the instruction, i.e. "round towards zero" variants.
Bill Wendling67a704d2010-10-13 20:58:46 +0000704def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
705 (outs SPR:$Sd), (ins DPR:$Dm),
706 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
707 [(set SPR:$Sd, (arm_ftosi (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000708 let Inst{7} = 1; // Z bit
709}
Evan Chenga8e29892007-01-19 07:51:42 +0000710
Bill Wendling67a704d2010-10-13 20:58:46 +0000711def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
712 (outs SPR:$Sd), (ins SPR:$Sm),
713 IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
714 [(set SPR:$Sd, (arm_ftosi SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000715 let Inst{7} = 1; // Z bit
Evan Cheng5eda2822011-02-16 00:35:02 +0000716
Evan Cheng6557bce2011-02-22 19:53:14 +0000717 // Some single precision VFP instructions may be executed on both NEON and
718 // VFP pipelines on A8.
719 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000720}
Evan Chenga8e29892007-01-19 07:51:42 +0000721
Bill Wendling67a704d2010-10-13 20:58:46 +0000722def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
723 (outs SPR:$Sd), (ins DPR:$Dm),
724 IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
725 [(set SPR:$Sd, (arm_ftoui (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000726 let Inst{7} = 1; // Z bit
727}
Evan Chenga8e29892007-01-19 07:51:42 +0000728
Bill Wendling67a704d2010-10-13 20:58:46 +0000729def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
730 (outs SPR:$Sd), (ins SPR:$Sm),
731 IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
732 [(set SPR:$Sd, (arm_ftoui SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000733 let Inst{7} = 1; // Z bit
Evan Cheng5eda2822011-02-16 00:35:02 +0000734
Evan Cheng6557bce2011-02-22 19:53:14 +0000735 // Some single precision VFP instructions may be executed on both NEON and
736 // VFP pipelines on A8.
737 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000738}
Evan Chenga8e29892007-01-19 07:51:42 +0000739
Johnny Chen15b423f2010-02-08 22:02:41 +0000740// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
Nate Begemand1fb5832010-08-03 21:31:55 +0000741let Uses = [FPSCR] in {
Bill Wendling67a704d2010-10-13 20:58:46 +0000742// FIXME: Verify encoding after integrated assembler is working.
743def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
744 (outs SPR:$Sd), (ins DPR:$Dm),
745 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
746 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000747 let Inst{7} = 0; // Z bit
748}
749
Bill Wendling67a704d2010-10-13 20:58:46 +0000750def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
751 (outs SPR:$Sd), (ins SPR:$Sm),
752 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
753 [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000754 let Inst{7} = 0; // Z bit
755}
756
Bill Wendling67a704d2010-10-13 20:58:46 +0000757def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
758 (outs SPR:$Sd), (ins DPR:$Dm),
759 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
Bill Wendling88cf0382010-10-14 01:02:08 +0000760 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000761 let Inst{7} = 0; // Z bit
762}
763
Bill Wendling67a704d2010-10-13 20:58:46 +0000764def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
765 (outs SPR:$Sd), (ins SPR:$Sm),
766 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
767 [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000768 let Inst{7} = 0; // Z bit
769}
Nate Begemand1fb5832010-08-03 21:31:55 +0000770}
Johnny Chen15b423f2010-02-08 22:02:41 +0000771
Johnny Chen27bb8d02010-02-11 18:17:16 +0000772// Convert between floating-point and fixed-point
773// Data type for fixed-point naming convention:
774// S16 (U=0, sx=0) -> SH
775// U16 (U=1, sx=0) -> UH
776// S32 (U=0, sx=1) -> SL
777// U32 (U=1, sx=1) -> UL
778
Bill Wendling160acca2010-11-01 23:11:22 +0000779// FIXME: Marking these as codegen only seems wrong. They are real
780// instructions(?)
781let Constraints = "$a = $dst", isCodeGenOnly = 1 in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000782
783// FP to Fixed-Point:
784
785def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
Bill Wendlingcd944a42010-11-01 23:17:54 +0000786 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
Johnny Chen27bb8d02010-02-11 18:17:16 +0000787 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000788 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000789 // Some single precision VFP instructions may be executed on both NEON and
790 // VFP pipelines on A8.
791 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000792}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000793
794def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
795 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
796 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000797 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000798 // Some single precision VFP instructions may be executed on both NEON and
799 // VFP pipelines on A8.
800 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000801}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000802
803def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
804 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
805 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000806 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000807 // Some single precision VFP instructions may be executed on both NEON and
808 // VFP pipelines on A8.
809 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000810}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000811
812def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
813 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
814 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000815 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000816 // Some single precision VFP instructions may be executed on both NEON and
817 // VFP pipelines on A8.
818 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000819}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000820
821def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
822 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
823 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
824 [/* For disassembly only; pattern left blank */]>;
825
826def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
827 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
828 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
829 [/* For disassembly only; pattern left blank */]>;
830
831def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
832 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
833 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
834 [/* For disassembly only; pattern left blank */]>;
835
836def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
837 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
838 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
839 [/* For disassembly only; pattern left blank */]>;
840
841// Fixed-Point to FP:
842
843def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
844 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
845 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000846 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000847 // Some single precision VFP instructions may be executed on both NEON and
848 // VFP pipelines on A8.
849 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000850}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000851
852def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
853 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
854 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000855 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000856 // Some single precision VFP instructions may be executed on both NEON and
857 // VFP pipelines on A8.
858 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000859}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000860
861def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
862 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
863 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000864 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000865 // Some single precision VFP instructions may be executed on both NEON and
866 // VFP pipelines on A8.
867 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000868}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000869
870def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
871 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
872 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
Evan Cheng5eda2822011-02-16 00:35:02 +0000873 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000874 // Some single precision VFP instructions may be executed on both NEON and
875 // VFP pipelines on A8.
876 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000877}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000878
879def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
880 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
881 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
882 [/* For disassembly only; pattern left blank */]>;
883
884def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
885 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
886 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
887 [/* For disassembly only; pattern left blank */]>;
888
889def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
890 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
891 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
892 [/* For disassembly only; pattern left blank */]>;
893
894def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
895 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
896 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
897 [/* For disassembly only; pattern left blank */]>;
898
Bill Wendling160acca2010-11-01 23:11:22 +0000899} // End of 'let Constraints = "$a = $dst", isCodeGenOnly = 1 in'
Johnny Chen27bb8d02010-02-11 18:17:16 +0000900
Evan Chenga8e29892007-01-19 07:51:42 +0000901//===----------------------------------------------------------------------===//
Cameron Zwarich375db7f2011-07-07 08:28:52 +0000902// FP Multiply-Accumulate Operations.
Evan Chenga8e29892007-01-19 07:51:42 +0000903//
904
Evan Cheng529916c2010-11-12 20:32:20 +0000905def VMLAD : ADbI<0b11100, 0b00, 0, 0,
906 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
907 IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000908 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
909 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000910 RegConstraint<"$Ddin = $Dd">,
Evan Cheng48575f62010-12-05 22:04:16 +0000911 Requires<[HasVFP2,UseFPVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000912
Bill Wendling69661192010-11-01 06:00:39 +0000913def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
914 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
915 IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000916 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
917 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000918 RegConstraint<"$Sdin = $Sd">,
Evan Cheng5eda2822011-02-16 00:35:02 +0000919 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000920 // Some single precision VFP instructions may be executed on both NEON and
921 // VFP pipelines on A8.
922 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000923}
Evan Chenga8e29892007-01-19 07:51:42 +0000924
Evan Cheng48575f62010-12-05 22:04:16 +0000925def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000926 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +0000927 Requires<[HasVFP2,UseFPVMLx]>;
928def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000929 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +0000930 Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000931
Evan Cheng529916c2010-11-12 20:32:20 +0000932def VMLSD : ADbI<0b11100, 0b00, 1, 0,
933 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
934 IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000935 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
936 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000937 RegConstraint<"$Ddin = $Dd">,
Evan Cheng48575f62010-12-05 22:04:16 +0000938 Requires<[HasVFP2,UseFPVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000939
Bill Wendling69661192010-11-01 06:00:39 +0000940def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
941 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
942 IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000943 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
944 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000945 RegConstraint<"$Sdin = $Sd">,
Evan Cheng5eda2822011-02-16 00:35:02 +0000946 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000947 // Some single precision VFP instructions may be executed on both NEON and
948 // VFP pipelines on A8.
949 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000950}
Evan Chenga8e29892007-01-19 07:51:42 +0000951
Evan Cheng48575f62010-12-05 22:04:16 +0000952def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000953 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +0000954 Requires<[HasVFP2,UseFPVMLx]>;
955def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000956 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +0000957 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000958
Evan Cheng529916c2010-11-12 20:32:20 +0000959def VNMLAD : ADbI<0b11100, 0b01, 1, 0,
960 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
961 IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000962 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
963 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000964 RegConstraint<"$Ddin = $Dd">,
Evan Cheng48575f62010-12-05 22:04:16 +0000965 Requires<[HasVFP2,UseFPVMLx]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000966
Bill Wendling69661192010-11-01 06:00:39 +0000967def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
968 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
969 IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000970 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
971 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000972 RegConstraint<"$Sdin = $Sd">,
Evan Cheng5eda2822011-02-16 00:35:02 +0000973 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000974 // Some single precision VFP instructions may be executed on both NEON and
975 // VFP pipelines on A8.
976 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000977}
Bill Wendling88cf0382010-10-14 01:02:08 +0000978
Evan Cheng48575f62010-12-05 22:04:16 +0000979def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000980 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +0000981 Requires<[HasVFP2,UseFPVMLx]>;
982def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000983 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +0000984 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000985
Evan Cheng529916c2010-11-12 20:32:20 +0000986def VNMLSD : ADbI<0b11100, 0b01, 0, 0,
987 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
988 IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000989 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
990 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000991 RegConstraint<"$Ddin = $Dd">,
Evan Cheng48575f62010-12-05 22:04:16 +0000992 Requires<[HasVFP2,UseFPVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000993
Bill Wendling69661192010-11-01 06:00:39 +0000994def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
995 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
996 IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000997 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000998 RegConstraint<"$Sdin = $Sd">,
Evan Cheng5eda2822011-02-16 00:35:02 +0000999 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]> {
Evan Cheng6557bce2011-02-22 19:53:14 +00001000 // Some single precision VFP instructions may be executed on both NEON and
1001 // VFP pipelines on A8.
1002 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +00001003}
Bill Wendling88cf0382010-10-14 01:02:08 +00001004
Evan Cheng48575f62010-12-05 22:04:16 +00001005def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001006 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +00001007 Requires<[HasVFP2,UseFPVMLx]>;
1008def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001009 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
Evan Cheng48575f62010-12-05 22:04:16 +00001010 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
Bill Wendling88cf0382010-10-14 01:02:08 +00001011
Evan Chenga8e29892007-01-19 07:51:42 +00001012
1013//===----------------------------------------------------------------------===//
1014// FP Conditional moves.
1015//
1016
Evan Cheng020cc1b2010-05-13 00:16:46 +00001017let neverHasSideEffects = 1 in {
Jim Grosbachf219f312011-03-11 23:09:50 +00001018def VMOVDcc : ARMPseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001019 4, IIC_fpUNA64,
Bill Wendling69661192010-11-01 06:00:39 +00001020 [/*(set DPR:$Dd, (ARMcmov DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
1021 RegConstraint<"$Dn = $Dd">;
Evan Chenga8e29892007-01-19 07:51:42 +00001022
Jim Grosbachf219f312011-03-11 23:09:50 +00001023def VMOVScc : ARMPseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001024 4, IIC_fpUNA32,
Bill Wendling69661192010-11-01 06:00:39 +00001025 [/*(set SPR:$Sd, (ARMcmov SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
1026 RegConstraint<"$Sn = $Sd">;
Evan Cheng020cc1b2010-05-13 00:16:46 +00001027} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +00001028
1029//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001030// Move from VFP System Register to ARM core register.
Evan Cheng78be83d2008-11-11 19:40:26 +00001031//
1032
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001033class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1034 list<dag> pattern>:
1035 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
Evan Cheng39382422009-10-28 01:44:26 +00001036
Bill Wendling88cf0382010-10-14 01:02:08 +00001037 // Instruction operand.
1038 bits<4> Rt;
1039
Johnny Chenc9745042010-02-09 22:35:38 +00001040 let Inst{27-20} = 0b11101111;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001041 let Inst{19-16} = opc19_16;
1042 let Inst{15-12} = Rt;
Johnny Chenc9745042010-02-09 22:35:38 +00001043 let Inst{11-8} = 0b1010;
1044 let Inst{7} = 0;
Bill Wendling88cf0382010-10-14 01:02:08 +00001045 let Inst{6-5} = 0b00;
Johnny Chenc9745042010-02-09 22:35:38 +00001046 let Inst{4} = 1;
Bill Wendling88cf0382010-10-14 01:02:08 +00001047 let Inst{3-0} = 0b0000;
Johnny Chenc9745042010-02-09 22:35:38 +00001048}
Johnny Chenc9745042010-02-09 22:35:38 +00001049
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001050// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
1051// to APSR.
1052let Defs = [CPSR], Uses = [FPSCR], Rt = 0b1111 /* apsr_nzcv */ in
1053def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins),
1054 "vmrs", "\tapsr_nzcv, fpscr", [(arm_fmstat)]>;
1055
1056// Application level FPSCR -> GPR
1057let hasSideEffects = 1, Uses = [FPSCR] in
1058def VMRS : MovFromVFP<0b0001 /* fpscr */, (outs GPR:$Rt), (ins),
1059 "vmrs", "\t$Rt, fpscr",
1060 [(set GPR:$Rt, (int_arm_get_fpscr))]>;
1061
1062// System level FPEXC, FPSID -> GPR
1063let Uses = [FPSCR] in {
1064 def VMRS_FPEXC : MovFromVFP<0b1000 /* fpexc */, (outs GPR:$Rt), (ins),
1065 "vmrs", "\t$Rt, fpexc", []>;
1066 def VMRS_FPSID : MovFromVFP<0b0000 /* fpsid */, (outs GPR:$Rt), (ins),
1067 "vmrs", "\t$Rt, fpsid", []>;
1068}
1069
1070//===----------------------------------------------------------------------===//
1071// Move from ARM core register to VFP System Register.
1072//
1073
1074class MovToVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1075 list<dag> pattern>:
1076 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
1077
Bill Wendling88cf0382010-10-14 01:02:08 +00001078 // Instruction operand.
1079 bits<4> src;
1080
1081 // Encode instruction operand.
1082 let Inst{15-12} = src;
1083
Johnny Chenc9745042010-02-09 22:35:38 +00001084 let Inst{27-20} = 0b11101110;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001085 let Inst{19-16} = opc19_16;
Johnny Chenc9745042010-02-09 22:35:38 +00001086 let Inst{11-8} = 0b1010;
1087 let Inst{7} = 0;
1088 let Inst{4} = 1;
1089}
Evan Cheng39382422009-10-28 01:44:26 +00001090
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001091let Defs = [FPSCR] in {
1092 // Application level GPR -> FPSCR
1093 def VMSR : MovToVFP<0b0001 /* fpscr */, (outs), (ins GPR:$src),
1094 "vmsr", "\tfpscr, $src", [(int_arm_set_fpscr GPR:$src)]>;
1095 // System level GPR -> FPEXC
1096 def VMSR_FPEXC : MovToVFP<0b1000 /* fpexc */, (outs), (ins GPR:$src),
1097 "vmsr", "\tfpexc, $src", []>;
1098 // System level GPR -> FPSID
1099 def VMSR_FPSID : MovToVFP<0b0000 /* fpsid */, (outs), (ins GPR:$src),
1100 "vmsr", "\tfpsid, $src", []>;
1101}
1102
1103//===----------------------------------------------------------------------===//
1104// Misc.
1105//
1106
Evan Cheng39382422009-10-28 01:44:26 +00001107// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +00001108let isReMaterializable = 1 in {
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001109def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +00001110 VFPMiscFrm, IIC_fpUNA64,
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001111 "vmov", ".f64\t$Dd, $imm",
1112 [(set DPR:$Dd, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
1113 // Instruction operands.
1114 bits<5> Dd;
1115 bits<32> imm;
1116
1117 // Encode instruction operands.
1118 let Inst{15-12} = Dd{3-0};
1119 let Inst{22} = Dd{4};
Owen Anderson96279d02011-08-02 18:30:00 +00001120 let Inst{19} = imm{31}; // The immediate is handled as a float.
1121 let Inst{18-16} = imm{25-23};
1122 let Inst{3-0} = imm{22-19};
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001123
1124 // Encode remaining instruction bits.
Jim Grosbache5165492009-11-09 00:11:35 +00001125 let Inst{27-23} = 0b11101;
1126 let Inst{21-20} = 0b11;
1127 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001128 let Inst{8} = 1; // Double precision.
Jim Grosbache5165492009-11-09 00:11:35 +00001129 let Inst{7-4} = 0b0000;
1130}
1131
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001132def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm),
1133 VFPMiscFrm, IIC_fpUNA32,
1134 "vmov", ".f32\t$Sd, $imm",
1135 [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
1136 // Instruction operands.
1137 bits<5> Sd;
1138 bits<32> imm;
1139
1140 // Encode instruction operands.
1141 let Inst{15-12} = Sd{4-1};
1142 let Inst{22} = Sd{0};
Owen Anderson96279d02011-08-02 18:30:00 +00001143 let Inst{19} = imm{31}; // The immediate is handled as a float.
1144 let Inst{18-16} = imm{25-23};
1145 let Inst{3-0} = imm{22-19};
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001146
1147 // Encode remaining instruction bits.
Evan Cheng39382422009-10-28 01:44:26 +00001148 let Inst{27-23} = 0b11101;
1149 let Inst{21-20} = 0b11;
1150 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001151 let Inst{8} = 0; // Single precision.
Evan Cheng39382422009-10-28 01:44:26 +00001152 let Inst{7-4} = 0b0000;
1153}
Evan Cheng39382422009-10-28 01:44:26 +00001154}