summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/frontend/maxwell/translate/impl/double_fused_multiply_add.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-03-21 07:09:14 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:24 +0200
commitc858b8ba97d3ff79dcff0795c1184ee356f2cd1a (patch)
treea6b0c12aebb276c8a475b206941779d8d1af371d /src/shader_recompiler/frontend/maxwell/translate/impl/double_fused_multiply_add.cpp
parentshader: Add FP64 register load/store helpers (diff)
downloadyuzu-c858b8ba97d3ff79dcff0795c1184ee356f2cd1a.tar
yuzu-c858b8ba97d3ff79dcff0795c1184ee356f2cd1a.tar.gz
yuzu-c858b8ba97d3ff79dcff0795c1184ee356f2cd1a.tar.bz2
yuzu-c858b8ba97d3ff79dcff0795c1184ee356f2cd1a.tar.lz
yuzu-c858b8ba97d3ff79dcff0795c1184ee356f2cd1a.tar.xz
yuzu-c858b8ba97d3ff79dcff0795c1184ee356f2cd1a.tar.zst
yuzu-c858b8ba97d3ff79dcff0795c1184ee356f2cd1a.zip
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/translate/impl/double_fused_multiply_add.cpp')
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/double_fused_multiply_add.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/double_fused_multiply_add.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/double_fused_multiply_add.cpp
new file mode 100644
index 000000000..ff7321862
--- /dev/null
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/double_fused_multiply_add.cpp
@@ -0,0 +1,53 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "common/common_types.h"
+#include "shader_recompiler/exception.h"
+#include "shader_recompiler/frontend/maxwell/translate/impl/common_encoding.h"
+#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
+
+namespace Shader::Maxwell {
+namespace {
+
+void DFMA(TranslatorVisitor& v, u64 insn, const IR::F64& src_b, const IR::F64& src_c) {
+ union {
+ u64 raw;
+ BitField<0, 8, IR::Reg> dest_reg;
+ BitField<8, 8, IR::Reg> src_a_reg;
+ BitField<50, 2, FpRounding> fp_rounding;
+ BitField<48, 1, u64> neg_b;
+ BitField<49, 1, u64> neg_c;
+ } const dfma{insn};
+
+ const IR::F64 src_a{v.D(dfma.src_a_reg)};
+ const IR::F64 op_b{v.ir.FPAbsNeg(src_b, false, dfma.neg_b != 0)};
+ const IR::F64 op_c{v.ir.FPAbsNeg(src_c, false, dfma.neg_c != 0)};
+
+ const IR::FpControl control{
+ .no_contraction{true},
+ .rounding{CastFpRounding(dfma.fp_rounding)},
+ .fmz_mode{IR::FmzMode::None},
+ };
+
+ v.D(dfma.dest_reg, v.ir.FPFma(src_a, op_b, op_c, control));
+}
+} // Anonymous namespace
+
+void TranslatorVisitor::DFMA_reg(u64 insn) {
+ DFMA(*this, insn, GetDoubleReg20(insn), GetDoubleReg39(insn));
+}
+
+void TranslatorVisitor::DFMA_cr(u64 insn) {
+ DFMA(*this, insn, GetDoubleCbuf(insn), GetDoubleReg39(insn));
+}
+
+void TranslatorVisitor::DFMA_rc(u64 insn) {
+ DFMA(*this, insn, GetDoubleReg39(insn), GetDoubleCbuf(insn));
+}
+
+void TranslatorVisitor::DFMA_imm(u64 insn) {
+ DFMA(*this, insn, GetDoubleImm20(insn), GetDoubleReg39(insn));
+}
+
+} // namespace Shader::Maxwell