From 659f2e0fcb14be56ffd2cccba3e25439e1501e40 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 14 Aug 2018 01:49:49 -0400 Subject: [PATCH] ac: add imad & fmad helpers Reviewed-by: Samuel Pitoiset --- src/amd/common/ac_llvm_build.c | 14 ++++++++++++++ src/amd/common/ac_llvm_build.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index c89bdf49faf..6d5bfb1a1be 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1969,6 +1969,20 @@ LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input, AC_FUNC_ATTR_READNONE); } +LLVMValueRef ac_build_imad(struct ac_llvm_context *ctx, LLVMValueRef s0, + LLVMValueRef s1, LLVMValueRef s2) +{ + return LLVMBuildAdd(ctx->builder, + LLVMBuildMul(ctx->builder, s0, s1, ""), s2, ""); +} + +LLVMValueRef ac_build_fmad(struct ac_llvm_context *ctx, LLVMValueRef s0, + LLVMValueRef s1, LLVMValueRef s2) +{ + return LLVMBuildFAdd(ctx->builder, + LLVMBuildFMul(ctx->builder, s0, s1, ""), s2, ""); +} + void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned simm16) { LLVMValueRef args[1] = { diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 84212f0d459..d11a6ebb1be 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -398,6 +398,10 @@ void ac_build_kill_if_false(struct ac_llvm_context *ctx, LLVMValueRef i1); LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input, LLVMValueRef offset, LLVMValueRef width, bool is_signed); +LLVMValueRef ac_build_imad(struct ac_llvm_context *ctx, LLVMValueRef s0, + LLVMValueRef s1, LLVMValueRef s2); +LLVMValueRef ac_build_fmad(struct ac_llvm_context *ctx, LLVMValueRef s0, + LLVMValueRef s1, LLVMValueRef s2); void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned simm16); -- 2.30.2