From 813e1ef1a3a76e704006e7cbeb348e9fb9881877 Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Sat, 3 Aug 2024 22:29:44 -0300 Subject: [PATCH] shader_recompiler: renamed SrcValue to SrcValue & added simple docs --- .../frontend/translate/translate.cpp | 21 +++++++-------- .../frontend/translate/translate.h | 26 +++++++++++-------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/shader_recompiler/frontend/translate/translate.cpp b/src/shader_recompiler/frontend/translate/translate.cpp index 42fc511cb..fd1555396 100644 --- a/src/shader_recompiler/frontend/translate/translate.cpp +++ b/src/shader_recompiler/frontend/translate/translate.cpp @@ -309,11 +309,8 @@ IR::U64F64 Translator::GetSrcRaw64(const InstOperand& operand, bool integer) { } template <> -Translator::SrcAuto Translator::GetSrc(const InstOperand& operand) { - return SrcAuto{ - *this, - operand, - }; +Translator::SrcValue Translator::GetSrc(const InstOperand& operand) { + return SrcValue{*this, operand}; } template <> @@ -346,31 +343,31 @@ IR::F64 Translator::GetSrc(const InstOperand& operand) { return GetSrcRaw64(operand, false); } -Translator::SrcAuto::operator IR::U32F32() const { +Translator::SrcValue::operator IR::U32F32() const { return translator.GetSrc(operand); } -Translator::SrcAuto::operator IR::Value() const { +Translator::SrcValue::operator IR::Value() const { return IR::Value{translator.GetSrc(operand)}; } -Translator::SrcAuto::operator IR::U32() const { +Translator::SrcValue::operator IR::U32() const { return translator.GetSrc(operand); } -Translator::SrcAuto::operator IR::F32() const { +Translator::SrcValue::operator IR::F32() const { return translator.GetSrc(operand); } -Translator::SrcAuto::operator IR::U64F64() const { +Translator::SrcValue::operator IR::U64F64() const { return translator.GetSrc(operand); } -Translator::SrcAuto::operator IR::U64() const { +Translator::SrcValue::operator IR::U64() const { return translator.GetSrc(operand); } -Translator::SrcAuto::operator IR::F64() const { +Translator::SrcValue::operator IR::F64() const { return translator.GetSrc(operand); } diff --git a/src/shader_recompiler/frontend/translate/translate.h b/src/shader_recompiler/frontend/translate/translate.h index e0acf6b54..bc0a55051 100644 --- a/src/shader_recompiler/frontend/translate/translate.h +++ b/src/shader_recompiler/frontend/translate/translate.h @@ -209,11 +209,11 @@ public: void IMAGE_ATOMIC(AtomicOp op, const GcnInst& inst); private: - struct SrcAuto; + struct SrcValue; [[nodiscard]] IR::U32F32 GetSrcRaw(const InstOperand& operand, bool integer); [[nodiscard]] IR::U64F64 GetSrcRaw64(const InstOperand& operand, bool integer); - template + template [[nodiscard]] T GetSrc(const InstOperand& operand); void SetDst(const InstOperand& operand, const IR::U32F32& value); @@ -228,23 +228,27 @@ private: IR::U32 m0_value; bool opcode_missing = false; - class SrcAuto { + /** + * This is a wrapper for IR::Value returned by GetSrc to lazy + * evaluate the correct type and auto-cast to integer if needed. + */ + class SrcValue { Translator& translator; const InstOperand& operand; public: - SrcAuto(Translator& translator, const InstOperand& operand) + SrcValue(Translator& translator, const InstOperand& operand) : translator(translator), operand(operand) {} - operator IR::Value() const; + explicit(false) operator IR::Value() const; - operator IR::U32F32() const; - operator IR::U32() const; - operator IR::F32() const; + explicit(false) operator IR::U32F32() const; + explicit(false) operator IR::U32() const; + explicit(false) operator IR::F32() const; - operator IR::U64F64() const; - operator IR::U64() const; - operator IR::F64() const; + explicit(false) operator IR::U64F64() const; + explicit(false) operator IR::U64() const; + explicit(false) operator IR::F64() const; }; };