ac: add imad & fmad helpers
authorMarek Olšák <marek.olsak@amd.com>
Tue, 14 Aug 2018 05:49:49 +0000 (01:49 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 22 Aug 2018 00:50:37 +0000 (20:50 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h

index c89bdf49faf5ea6b5d982f7df0286af3b44c4147..6d5bfb1a1be9ec02bae223aff35e09e073d038ea 100644 (file)
@@ -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] = {
index 84212f0d459eb9db3614da87597734dedb0da8c2..d11a6ebb1be6d89f69b92efa03f2d6fc3e1ad31e 100644 (file)
@@ -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);