@@ -1802,46 +1802,84 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
1802
1802
}
1803
1803
1804
1804
Opcode :: Fadd | Opcode :: Fsub | Opcode :: Fmul | Opcode :: Fdiv | Opcode :: Fmin | Opcode :: Fmax => {
1805
- let bits = ty_bits ( ctx. output_ty ( insn, 0 ) ) ;
1806
- let fpu_op = match ( op, bits) {
1807
- ( Opcode :: Fadd , 32 ) => FPUOp2 :: Add32 ,
1808
- ( Opcode :: Fadd , 64 ) => FPUOp2 :: Add64 ,
1809
- ( Opcode :: Fsub , 32 ) => FPUOp2 :: Sub32 ,
1810
- ( Opcode :: Fsub , 64 ) => FPUOp2 :: Sub64 ,
1811
- ( Opcode :: Fmul , 32 ) => FPUOp2 :: Mul32 ,
1812
- ( Opcode :: Fmul , 64 ) => FPUOp2 :: Mul64 ,
1813
- ( Opcode :: Fdiv , 32 ) => FPUOp2 :: Div32 ,
1814
- ( Opcode :: Fdiv , 64 ) => FPUOp2 :: Div64 ,
1815
- ( Opcode :: Fmin , 32 ) => FPUOp2 :: Min32 ,
1816
- ( Opcode :: Fmin , 64 ) => FPUOp2 :: Min64 ,
1817
- ( Opcode :: Fmax , 32 ) => FPUOp2 :: Max32 ,
1818
- ( Opcode :: Fmax , 64 ) => FPUOp2 :: Max64 ,
1819
- _ => panic ! ( "Unknown op/bits combination" ) ,
1820
- } ;
1805
+ let ty = ty. unwrap ( ) ;
1806
+ let bits = ty_bits ( ty) ;
1821
1807
let rn = put_input_in_reg ( ctx, inputs[ 0 ] , NarrowValueMode :: None ) ;
1822
1808
let rm = put_input_in_reg ( ctx, inputs[ 1 ] , NarrowValueMode :: None ) ;
1823
1809
let rd = get_output_reg ( ctx, outputs[ 0 ] ) ;
1824
- ctx. emit ( Inst :: FpuRRR { fpu_op, rd, rn, rm } ) ;
1810
+ if bits < 128 {
1811
+ let fpu_op = match ( op, bits) {
1812
+ ( Opcode :: Fadd , 32 ) => FPUOp2 :: Add32 ,
1813
+ ( Opcode :: Fadd , 64 ) => FPUOp2 :: Add64 ,
1814
+ ( Opcode :: Fsub , 32 ) => FPUOp2 :: Sub32 ,
1815
+ ( Opcode :: Fsub , 64 ) => FPUOp2 :: Sub64 ,
1816
+ ( Opcode :: Fmul , 32 ) => FPUOp2 :: Mul32 ,
1817
+ ( Opcode :: Fmul , 64 ) => FPUOp2 :: Mul64 ,
1818
+ ( Opcode :: Fdiv , 32 ) => FPUOp2 :: Div32 ,
1819
+ ( Opcode :: Fdiv , 64 ) => FPUOp2 :: Div64 ,
1820
+ ( Opcode :: Fmin , 32 ) => FPUOp2 :: Min32 ,
1821
+ ( Opcode :: Fmin , 64 ) => FPUOp2 :: Min64 ,
1822
+ ( Opcode :: Fmax , 32 ) => FPUOp2 :: Max32 ,
1823
+ ( Opcode :: Fmax , 64 ) => FPUOp2 :: Max64 ,
1824
+ _ => panic ! ( "Unknown op/bits combination" ) ,
1825
+ } ;
1826
+ ctx. emit ( Inst :: FpuRRR { fpu_op, rd, rn, rm } ) ;
1827
+ } else {
1828
+ let alu_op = match op {
1829
+ Opcode :: Fadd => VecALUOp :: Fadd ,
1830
+ Opcode :: Fsub => VecALUOp :: Fsub ,
1831
+ Opcode :: Fdiv => VecALUOp :: Fdiv ,
1832
+ Opcode :: Fmax => VecALUOp :: Fmax ,
1833
+ Opcode :: Fmin => VecALUOp :: Fmin ,
1834
+ Opcode :: Fmul => VecALUOp :: Fmul ,
1835
+ _ => unreachable ! ( ) ,
1836
+ } ;
1837
+
1838
+ ctx. emit ( Inst :: VecRRR {
1839
+ rd,
1840
+ rn,
1841
+ rm,
1842
+ alu_op,
1843
+ size : VectorSize :: from_ty ( ty) ,
1844
+ } ) ;
1845
+ }
1825
1846
}
1826
1847
1827
1848
Opcode :: Sqrt | Opcode :: Fneg | Opcode :: Fabs | Opcode :: Fpromote | Opcode :: Fdemote => {
1828
- let bits = ty_bits ( ctx. output_ty ( insn, 0 ) ) ;
1829
- let fpu_op = match ( op, bits) {
1830
- ( Opcode :: Sqrt , 32 ) => FPUOp1 :: Sqrt32 ,
1831
- ( Opcode :: Sqrt , 64 ) => FPUOp1 :: Sqrt64 ,
1832
- ( Opcode :: Fneg , 32 ) => FPUOp1 :: Neg32 ,
1833
- ( Opcode :: Fneg , 64 ) => FPUOp1 :: Neg64 ,
1834
- ( Opcode :: Fabs , 32 ) => FPUOp1 :: Abs32 ,
1835
- ( Opcode :: Fabs , 64 ) => FPUOp1 :: Abs64 ,
1836
- ( Opcode :: Fpromote , 32 ) => panic ! ( "Cannot promote to 32 bits" ) ,
1837
- ( Opcode :: Fpromote , 64 ) => FPUOp1 :: Cvt32To64 ,
1838
- ( Opcode :: Fdemote , 32 ) => FPUOp1 :: Cvt64To32 ,
1839
- ( Opcode :: Fdemote , 64 ) => panic ! ( "Cannot demote to 64 bits" ) ,
1840
- _ => panic ! ( "Unknown op/bits combination" ) ,
1841
- } ;
1849
+ let ty = ty. unwrap ( ) ;
1850
+ let bits = ty_bits ( ty) ;
1842
1851
let rn = put_input_in_reg ( ctx, inputs[ 0 ] , NarrowValueMode :: None ) ;
1843
1852
let rd = get_output_reg ( ctx, outputs[ 0 ] ) ;
1844
- ctx. emit ( Inst :: FpuRR { fpu_op, rd, rn } ) ;
1853
+ if bits < 128 {
1854
+ let fpu_op = match ( op, bits) {
1855
+ ( Opcode :: Sqrt , 32 ) => FPUOp1 :: Sqrt32 ,
1856
+ ( Opcode :: Sqrt , 64 ) => FPUOp1 :: Sqrt64 ,
1857
+ ( Opcode :: Fneg , 32 ) => FPUOp1 :: Neg32 ,
1858
+ ( Opcode :: Fneg , 64 ) => FPUOp1 :: Neg64 ,
1859
+ ( Opcode :: Fabs , 32 ) => FPUOp1 :: Abs32 ,
1860
+ ( Opcode :: Fabs , 64 ) => FPUOp1 :: Abs64 ,
1861
+ ( Opcode :: Fpromote , 32 ) => panic ! ( "Cannot promote to 32 bits" ) ,
1862
+ ( Opcode :: Fpromote , 64 ) => FPUOp1 :: Cvt32To64 ,
1863
+ ( Opcode :: Fdemote , 32 ) => FPUOp1 :: Cvt64To32 ,
1864
+ ( Opcode :: Fdemote , 64 ) => panic ! ( "Cannot demote to 64 bits" ) ,
1865
+ _ => panic ! ( "Unknown op/bits combination" ) ,
1866
+ } ;
1867
+ ctx. emit ( Inst :: FpuRR { fpu_op, rd, rn } ) ;
1868
+ } else {
1869
+ let op = match op {
1870
+ Opcode :: Fabs => VecMisc2 :: Fabs ,
1871
+ Opcode :: Fneg => VecMisc2 :: Fneg ,
1872
+ Opcode :: Sqrt => VecMisc2 :: Fsqrt ,
1873
+ _ => unimplemented ! ( ) ,
1874
+ } ;
1875
+
1876
+ ctx. emit ( Inst :: VecMisc {
1877
+ op,
1878
+ rd,
1879
+ rn,
1880
+ size : VectorSize :: from_ty ( ty) ,
1881
+ } ) ;
1882
+ }
1845
1883
}
1846
1884
1847
1885
Opcode :: Ceil | Opcode :: Floor | Opcode :: Trunc | Opcode :: Nearest => {
0 commit comments