mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-06 06:28:13 +01:00
value: Move ImmediateToU64() to be a part of Value's interface
This'll make it slightly nicer to do basic constant folding for 32-bit and 64-bit variants of the same IR opcode type. By that, I mean it's possible to inspect immediate values without a bunch of conditional checks beforehand to verify that it's possible to call GetU32() or GetU64, etc.
This commit is contained in:
parent
ca603c1215
commit
d69fceec55
3 changed files with 38 additions and 29 deletions
|
|
@ -155,4 +155,23 @@ Cond Value::GetCond() const {
|
|||
return inner.imm_cond;
|
||||
}
|
||||
|
||||
u64 Value::GetImmediateAsU64() const {
|
||||
ASSERT(IsImmediate());
|
||||
|
||||
switch (GetType()) {
|
||||
case IR::Type::U1:
|
||||
return u64(GetU1());
|
||||
case IR::Type::U8:
|
||||
return u64(GetU8());
|
||||
case IR::Type::U16:
|
||||
return u64(GetU16());
|
||||
case IR::Type::U32:
|
||||
return u64(GetU32());
|
||||
case IR::Type::U64:
|
||||
return u64(GetU64());
|
||||
default:
|
||||
ASSERT_MSG(false, "GetImmediateAsU64 called on an incompatible Value type.");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::IR
|
||||
|
|
|
|||
|
|
@ -66,6 +66,14 @@ public:
|
|||
CoprocessorInfo GetCoprocInfo() const;
|
||||
Cond GetCond() const;
|
||||
|
||||
/**
|
||||
* Retrieves the immediate of a Value instance.
|
||||
*
|
||||
* @pre The value contains either a U1, U8, U16, U32, or U64 value.
|
||||
* Breaking this precondition will cause an assertion to be invoked.
|
||||
*/
|
||||
u64 GetImmediateAsU64() const;
|
||||
|
||||
private:
|
||||
Type type;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue