summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir/value.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/frontend/ir/value.h')
-rw-r--r--src/shader_recompiler/frontend/ir/value.h104
1 files changed, 102 insertions, 2 deletions
diff --git a/src/shader_recompiler/frontend/ir/value.h b/src/shader_recompiler/frontend/ir/value.h
index 7b20824ed..bb7d19001 100644
--- a/src/shader_recompiler/frontend/ir/value.h
+++ b/src/shader_recompiler/frontend/ir/value.h
@@ -14,6 +14,7 @@
14#include <boost/container/small_vector.hpp> 14#include <boost/container/small_vector.hpp>
15#include <boost/intrusive/list.hpp> 15#include <boost/intrusive/list.hpp>
16 16
17#include "common/assert.h"
17#include "common/bit_cast.h" 18#include "common/bit_cast.h"
18#include "common/common_types.h" 19#include "common/common_types.h"
19#include "shader_recompiler/exception.h" 20#include "shader_recompiler/exception.h"
@@ -76,8 +77,6 @@ public:
76 [[nodiscard]] bool operator!=(const Value& other) const; 77 [[nodiscard]] bool operator!=(const Value& other) const;
77 78
78private: 79private:
79 void ValidateAccess(IR::Type expected) const;
80
81 IR::Type type{}; 80 IR::Type type{};
82 union { 81 union {
83 IR::Inst* inst{}; 82 IR::Inst* inst{};
@@ -288,4 +287,105 @@ inline bool Value::IsImmediate() const noexcept {
288 return current_type != Type::Opaque; 287 return current_type != Type::Opaque;
289} 288}
290 289
290inline IR::Inst* Value::Inst() const {
291 DEBUG_ASSERT(type == Type::Opaque);
292 return inst;
293}
294
295inline IR::Block* Value::Label() const {
296 DEBUG_ASSERT(type == Type::Label);
297 return label;
298}
299
300inline IR::Inst* Value::InstRecursive() const {
301 DEBUG_ASSERT(type == Type::Opaque);
302 if (IsIdentity()) {
303 return inst->Arg(0).InstRecursive();
304 }
305 return inst;
306}
307
308inline IR::Value Value::Resolve() const {
309 if (IsIdentity()) {
310 return inst->Arg(0).Resolve();
311 }
312 return *this;
313}
314
315inline IR::Reg Value::Reg() const {
316 DEBUG_ASSERT(type == Type::Reg);
317 return reg;
318}
319
320inline IR::Pred Value::Pred() const {
321 DEBUG_ASSERT(type == Type::Pred);
322 return pred;
323}
324
325inline IR::Attribute Value::Attribute() const {
326 DEBUG_ASSERT(type == Type::Attribute);
327 return attribute;
328}
329
330inline IR::Patch Value::Patch() const {
331 DEBUG_ASSERT(type == Type::Patch);
332 return patch;
333}
334
335inline bool Value::U1() const {
336 if (IsIdentity()) {
337 return inst->Arg(0).U1();
338 }
339 DEBUG_ASSERT(type == Type::U1);
340 return imm_u1;
341}
342
343inline u8 Value::U8() const {
344 if (IsIdentity()) {
345 return inst->Arg(0).U8();
346 }
347 DEBUG_ASSERT(type == Type::U8);
348 return imm_u8;
349}
350
351inline u16 Value::U16() const {
352 if (IsIdentity()) {
353 return inst->Arg(0).U16();
354 }
355 DEBUG_ASSERT(type == Type::U16);
356 return imm_u16;
357}
358
359inline u32 Value::U32() const {
360 if (IsIdentity()) {
361 return inst->Arg(0).U32();
362 }
363 DEBUG_ASSERT(type == Type::U32);
364 return imm_u32;
365}
366
367inline f32 Value::F32() const {
368 if (IsIdentity()) {
369 return inst->Arg(0).F32();
370 }
371 DEBUG_ASSERT(type == Type::F32);
372 return imm_f32;
373}
374
375inline u64 Value::U64() const {
376 if (IsIdentity()) {
377 return inst->Arg(0).U64();
378 }
379 DEBUG_ASSERT(type == Type::U64);
380 return imm_u64;
381}
382
383inline f64 Value::F64() const {
384 if (IsIdentity()) {
385 return inst->Arg(0).F64();
386 }
387 DEBUG_ASSERT(type == Type::F64);
388 return imm_f64;
389}
390
291} // namespace Shader::IR 391} // namespace Shader::IR