From 7114e2e7cff35364230795123d9049b96098725e Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Thu, 8 Aug 2013 16:06:08 +0000 Subject: [PATCH] R600/SI: Implement sint<->fp64 conversions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187987 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/R600/SIInstrInfo.td | 6 ++++++ lib/Target/R600/SIInstructions.td | 8 ++++++-- test/CodeGen/R600/fp64_to_sint.ll | 9 +++++++++ test/CodeGen/R600/sint_to_fp64.ll | 9 +++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/CodeGen/R600/fp64_to_sint.ll create mode 100644 test/CodeGen/R600/sint_to_fp64.ll diff --git a/lib/Target/R600/SIInstrInfo.td b/lib/Target/R600/SIInstrInfo.td index 52af79ccc25..302fa2475cf 100644 --- a/lib/Target/R600/SIInstrInfo.td +++ b/lib/Target/R600/SIInstrInfo.td @@ -184,6 +184,12 @@ multiclass VOP1_32 op, string opName, list pattern> multiclass VOP1_64 op, string opName, list pattern> : VOP1_Helper ; +multiclass VOP1_32_64 op, string opName, list pattern> + : VOP1_Helper ; + +multiclass VOP1_64_32 op, string opName, list pattern> + : VOP1_Helper ; + multiclass VOP2_Helper op, RegisterClass vrc, RegisterClass arc, string opName, list pattern, string revOp> { def _e32 : VOP2 < diff --git a/lib/Target/R600/SIInstructions.td b/lib/Target/R600/SIInstructions.td index 500d15e8f43..efe7a3ea680 100644 --- a/lib/Target/R600/SIInstructions.td +++ b/lib/Target/R600/SIInstructions.td @@ -603,8 +603,12 @@ defm V_MOV_B32 : VOP1_32 <0x00000001, "V_MOV_B32", []>; } // End neverHasSideEffects = 1, isMoveImm = 1 defm V_READFIRSTLANE_B32 : VOP1_32 <0x00000002, "V_READFIRSTLANE_B32", []>; -//defm V_CVT_I32_F64 : VOP1_32 <0x00000003, "V_CVT_I32_F64", []>; -//defm V_CVT_F64_I32 : VOP1_64 <0x00000004, "V_CVT_F64_I32", []>; +defm V_CVT_I32_F64 : VOP1_32_64 <0x00000003, "V_CVT_I32_F64", + [(set i32:$dst, (fp_to_sint f64:$src0))] +>; +defm V_CVT_F64_I32 : VOP1_64_32 <0x00000004, "V_CVT_F64_I32", + [(set f64:$dst, (sint_to_fp i32:$src0))] +>; defm V_CVT_F32_I32 : VOP1_32 <0x00000005, "V_CVT_F32_I32", [(set f32:$dst, (sint_to_fp i32:$src0))] >; diff --git a/test/CodeGen/R600/fp64_to_sint.ll b/test/CodeGen/R600/fp64_to_sint.ll new file mode 100644 index 00000000000..42f9f3403a3 --- /dev/null +++ b/test/CodeGen/R600/fp64_to_sint.ll @@ -0,0 +1,9 @@ +; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s --check-prefix=CHECK + +; CHECK: @fp64_to_sint +; CHECK: V_CVT_I32_F64_e32 +define void @fp64_to_sint(i32 addrspace(1)* %out, double %in) { + %result = fptosi double %in to i32 + store i32 %result, i32 addrspace(1)* %out + ret void +} diff --git a/test/CodeGen/R600/sint_to_fp64.ll b/test/CodeGen/R600/sint_to_fp64.ll new file mode 100644 index 00000000000..37f67c94d2d --- /dev/null +++ b/test/CodeGen/R600/sint_to_fp64.ll @@ -0,0 +1,9 @@ +; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s --check-prefix=CHECK + +; CHECK: @sint_to_fp64 +; CHECK: V_CVT_F64_I32_e32 +define void @sint_to_fp64(double addrspace(1)* %out, i32 %in) { + %result = sitofp i32 %in to double + store double %result, double addrspace(1)* %out + ret void +} -- 2.34.1