summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortstellar <tstellar@91177308-0d34-0410-b5e6-96231b3b80d8>2012-10-15 20:53:41 +0000
committertstellar <tstellar@91177308-0d34-0410-b5e6-96231b3b80d8>2012-10-15 20:53:41 +0000
commit6441cb10ad207c66e2d6069e159fd0150deb8a54 (patch)
tree29c220310dcb65025b8cb7720dd841ae76589afe
parentc451e5482c2331c820a1dc89bd125eef51872dd2 (diff)
R600: add support for cos/sin intrinsic
Patch by: Vincent Lejeune Reviewed-by: Tom Stellard <thomas.stellard@amd.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/R600/@165967 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/AMDGPU/AMDGPUIntrinsics.td2
-rw-r--r--lib/Target/AMDGPU/R600Instructions.td17
-rw-r--r--test/CodeGen/R600/llvm.cos.ll (renamed from test/CodeGen/R600/llvm.AMDGPU.cos.ll)6
-rw-r--r--test/CodeGen/R600/llvm.sin.ll (renamed from test/CodeGen/R600/llvm.AMDGPU.sin.ll)6
4 files changed, 17 insertions, 14 deletions
diff --git a/lib/Target/AMDGPU/AMDGPUIntrinsics.td b/lib/Target/AMDGPU/AMDGPUIntrinsics.td
index feca038b221..c5a7bebb745 100644
--- a/lib/Target/AMDGPU/AMDGPUIntrinsics.td
+++ b/lib/Target/AMDGPU/AMDGPUIntrinsics.td
@@ -21,7 +21,6 @@ let TargetPrefix = "AMDGPU", isTarget = 1 in {
def int_AMDGPU_arl : Intrinsic<[llvm_i32_ty], [llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_cndlt : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
- def int_AMDGPU_cos : Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_div : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_dp4 : Intrinsic<[llvm_float_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>;
def int_AMDGPU_floor : Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
@@ -35,7 +34,6 @@ let TargetPrefix = "AMDGPU", isTarget = 1 in {
def int_AMDGPU_seq : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_sgt : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_sge : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
- def int_AMDGPU_sin : Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_sle : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_sne : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_ssg : Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
diff --git a/lib/Target/AMDGPU/R600Instructions.td b/lib/Target/AMDGPU/R600Instructions.td
index db6139fa61f..9c0b6f7edb2 100644
--- a/lib/Target/AMDGPU/R600Instructions.td
+++ b/lib/Target/AMDGPU/R600Instructions.td
@@ -915,8 +915,13 @@ let Predicates = [isR600] in {
// Helper pattern for normalizing inputs to triginomic instructions for R700+
// cards.
-class TRIG_eg <InstR600 trig, Intrinsic intr> : Pat<
- (intr R600_Reg32:$src),
+class COS_PAT <InstR600 trig> : Pat<
+ (fcos R600_Reg32:$src),
+ (trig (MUL (MOV_IMM_I32 (i32 ALU_LITERAL_X), CONST.TWO_PI_INV), R600_Reg32:$src))
+>;
+
+class SIN_PAT <InstR600 trig> : Pat<
+ (fsin R600_Reg32:$src),
(trig (MUL (MOV_IMM_I32 (i32 ALU_LITERAL_X), CONST.TWO_PI_INV), R600_Reg32:$src))
>;
@@ -929,8 +934,8 @@ let Predicates = [isR700] in {
def COS_r700 : COS_Common<0x6F>;
// R700 normalizes inputs to SIN/COS the same as EG
- def : TRIG_eg <SIN_r700, int_AMDGPU_sin>;
- def : TRIG_eg <COS_r700, int_AMDGPU_cos>;
+ def : SIN_PAT <SIN_r700>;
+ def : COS_PAT <COS_r700>;
}
//===----------------------------------------------------------------------===//
@@ -1007,8 +1012,8 @@ let Predicates = [isEGorCayman] in {
def SSG_eg : SSG_Common<CNDGT_eg, CNDGE_eg>;
def TGSI_LIT_Z_eg : TGSI_LIT_Z_Common<MUL_LIT_eg, LOG_CLAMPED_eg, EXP_IEEE_eg>;
- def : TRIG_eg <SIN_eg, int_AMDGPU_sin>;
- def : TRIG_eg <COS_eg, int_AMDGPU_cos>;
+ def : SIN_PAT <SIN_eg>;
+ def : COS_PAT <COS_eg>;
def FLT_TO_INT_eg : FLT_TO_INT_Common<0x50> {
let Pattern = [];
diff --git a/test/CodeGen/R600/llvm.AMDGPU.cos.ll b/test/CodeGen/R600/llvm.cos.ll
index 5b41a408a9b..dc120bfb00c 100644
--- a/test/CodeGen/R600/llvm.AMDGPU.cos.ll
+++ b/test/CodeGen/R600/llvm.cos.ll
@@ -4,13 +4,13 @@
define void @test() {
%r0 = call float @llvm.R600.load.input(i32 0)
- %r1 = call float @llvm.AMDGPU.cos( float %r0)
+ %r1 = call float @llvm.cos.f32(float %r0)
call void @llvm.AMDGPU.store.output(float %r1, i32 0)
ret void
}
+declare float @llvm.cos.f32(float) readnone
+
declare float @llvm.R600.load.input(i32) readnone
declare void @llvm.AMDGPU.store.output(float, i32)
-
-declare float @llvm.AMDGPU.cos(float ) readnone
diff --git a/test/CodeGen/R600/llvm.AMDGPU.sin.ll b/test/CodeGen/R600/llvm.sin.ll
index d0e0df839da..5cd6998c937 100644
--- a/test/CodeGen/R600/llvm.AMDGPU.sin.ll
+++ b/test/CodeGen/R600/llvm.sin.ll
@@ -4,13 +4,13 @@
define void @test() {
%r0 = call float @llvm.R600.load.input(i32 0)
- %r1 = call float @llvm.AMDGPU.sin( float %r0)
+ %r1 = call float @llvm.sin.f32( float %r0)
call void @llvm.AMDGPU.store.output(float %r1, i32 0)
ret void
}
+declare float @llvm.sin.f32(float) readnone
+
declare float @llvm.R600.load.input(i32) readnone
declare void @llvm.AMDGPU.store.output(float, i32)
-
-declare float @llvm.AMDGPU.sin(float ) readnone