ReXGlue SDK
Loading...
Searching...
No Matches
rex::ppc::ArgTranslator Struct Reference

#include <rex/ppc/call.h>

Static Public Member Functions

static constexpr PPCRegister & GetIntegerRegister (PPCContext &ctx, size_t slot) noexcept
static constexpr PPCRegister & GetFloatRegister (PPCContext &ctx, size_t ordinal) noexcept
static constexpr PPCVRegister & GetVectorRegister (PPCContext &ctx, size_t ordinal) noexcept
static constexpr u32 GetStackSlotAddress (const PPCContext &ctx, size_t slot) noexcept
template<size_t Bytes = sizeof(u32)>
static constexpr u64 GetIntegerArgumentValue (const PPCContext &ctx, u8 *base, size_t slot) noexcept
static f64 GetFloatArgumentValue (const PPCContext &ctx, u8 *base, const ArgPlace &arg, bool single) noexcept
template<size_t Bytes = sizeof(u32)>
static constexpr void SetIntegerArgumentValue (PPCContext &ctx, u8 *base, size_t slot, u64 value) noexcept
static void SetFloatArgumentValue (PPCContext &ctx, u8 *base, const ArgPlace &arg, f64 value, bool single) noexcept
static PPCVRegister GetVectorArgumentValue (const PPCContext &ctx, u8 *base, const ArgPlace &arg) noexcept
static void SetVectorArgumentValue (PPCContext &ctx, u8 *base, const ArgPlace &arg, const PPCVRegister &value) noexcept
template<ByValueType T>
static T GetValue (PPCContext &ctx, u8 *base, const ArgPlace &arg) noexcept
template<ByValueType T>
static void SetByValueArgumentValue (PPCContext &ctx, u8 *base, const ArgPlace &arg, const T &value) noexcept
template<BigEndianType T>
static constexpr T GetValue (PPCContext &ctx, u8 *base, const ArgPlace &arg) noexcept
template<MappedPtrType T>
static T GetValue (PPCContext &ctx, u8 *base, const ArgPlace &arg) noexcept
template<MappedPtrType T>
static T GetMappedPointerValue (u64 value, u8 *base) noexcept
template<VectorType T>
static T GetValue (PPCContext &ctx, u8 *base, const ArgPlace &arg) noexcept
template<PlainType T>
static constexpr T GetValue (PPCContext &ctx, u8 *base, const ArgPlace &arg) noexcept
template<typename T>
requires std::is_pointer_v<T>
static constexpr T GetValue (PPCContext &ctx, u8 *base, const ArgPlace &arg) noexcept
template<typename T>
requires std::is_pointer_v<T>
static constexpr T GetPointerValue (u64 value, u8 *base) noexcept
template<typename T>
static constexpr void SetValue (PPCContext &ctx, u8 *base, const ArgPlace &arg, T value) noexcept

Static Public Attributes

static constexpr size_t kIntegerRegisters = 8
static constexpr size_t kFloatRegisters = 13
static constexpr size_t kVectorRegisters = 13

Detailed Description

Reads and writes function arguments in the guest calling convention.

Member Function Documentation

◆ GetFloatArgumentValue()

f64 rex::ppc::ArgTranslator::GetFloatArgumentValue ( const PPCContext & ctx,
u8 * base,
const ArgPlace & arg,
bool single )
inlinestaticnoexcept

Reads a float argument from its register or its stack slot.

Parameters
singleTrue when the argument is a 4 byte float.
Returns
The argument widened to a double.

◆ GetFloatRegister()

constexpr PPCRegister & rex::ppc::ArgTranslator::GetFloatRegister ( PPCContext & ctx,
size_t ordinal )
inlinestaticconstexprnoexcept
Parameters
ordinalThe float argument index, under kFloatRegisters.
Returns
f1 for index 0 through f13 for index 12.

◆ GetIntegerArgumentValue()

template<size_t Bytes = sizeof(u32)>
constexpr u64 rex::ppc::ArgTranslator::GetIntegerArgumentValue ( const PPCContext & ctx,
u8 * base,
size_t slot )
inlinestaticconstexprnoexcept

Reads an integer argument from its register or its stack slot.

Template Parameters
BytesThe argument width in bytes, 4 or 8.
Returns
The argument, zero extended.

◆ GetIntegerRegister()

constexpr PPCRegister & rex::ppc::ArgTranslator::GetIntegerRegister ( PPCContext & ctx,
size_t slot )
inlinestaticconstexprnoexcept

Returns the integer argument register for an argument image slot. The register is r3 for slot 0 through r10 for slot 7.

Parameters
slotThe slot, under kIntegerRegisters.

◆ GetMappedPointerValue()

template<MappedPtrType T>
T rex::ppc::ArgTranslator::GetMappedPointerValue ( u64 value,
u8 * base )
inlinestaticnoexcept

Converts the value of an integer register to a mapped pointer.

Parameters
valueRegister value whose low 32 bits are the guest address.
Returns
The mapped pointer, null when the address is 0.

◆ GetPointerValue()

template<typename T>
requires std::is_pointer_v<T>
constexpr T rex::ppc::ArgTranslator::GetPointerValue ( u64 value,
u8 * base )
inlinestaticconstexprnoexcept

Converts the value of an integer register to a host pointer.

Parameters
valueRegister value whose low 32 bits are the guest address.
Returns
The host pointer, null when the address is 0.

◆ GetStackSlotAddress()

constexpr u32 rex::ppc::ArgTranslator::GetStackSlotAddress ( const PPCContext & ctx,
size_t slot )
inlinestaticconstexprnoexcept

Returns the guest address of an argument image slot past the integer registers.

Parameters
ctxThe register file at the callee's entry.
slotThe slot, at least kIntegerRegisters.

◆ GetValue() [1/5]

template<typename T>
requires std::is_pointer_v<T>
constexpr T rex::ppc::ArgTranslator::GetValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg )
inlinestaticconstexprnoexcept

Reads a pointer argument.

Returns
The host pointer, null when the argument is 0.

◆ GetValue() [2/5]

template<PlainType T>
constexpr T rex::ppc::ArgTranslator::GetValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg )
inlinestaticconstexprnoexcept

Reads an integer or float argument.

◆ GetValue() [3/5]

template<MappedPtrType T>
T rex::ppc::ArgTranslator::GetValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg )
inlinestaticnoexcept

Reads a mapped pointer argument.

Returns
The mapped pointer, null when the argument is 0.

◆ GetValue() [4/5]

template<BigEndianType T>
constexpr T rex::ppc::ArgTranslator::GetValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg )
inlinestaticconstexprnoexcept

Reads a big endian argument.

◆ GetValue() [5/5]

template<ByValueType T>
T rex::ppc::ArgTranslator::GetValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg )
inlinestaticnoexcept

Reads a structure argument from its registers and stack slots.

◆ GetVectorArgumentValue()

PPCVRegister rex::ppc::ArgTranslator::GetVectorArgumentValue ( const PPCContext & ctx,
u8 * base,
const ArgPlace & arg )
inlinestaticnoexcept

Reads a vector argument from its register or its 16 byte stack slot pair.

Returns
The vector. Its stack image is the byte reversed register.

◆ GetVectorRegister()

constexpr PPCVRegister & rex::ppc::ArgTranslator::GetVectorRegister ( PPCContext & ctx,
size_t ordinal )
inlinestaticconstexprnoexcept
Parameters
ordinalThe vector argument index, under kVectorRegisters.
Returns
v1 for index 0 through v13 for index 12.

◆ SetByValueArgumentValue()

template<ByValueType T>
void rex::ppc::ArgTranslator::SetByValueArgumentValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg,
const T & value )
inlinestaticnoexcept

Writes a structure argument to its registers and stack slots.

◆ SetFloatArgumentValue()

void rex::ppc::ArgTranslator::SetFloatArgumentValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg,
f64 value,
bool single )
inlinestaticnoexcept

Writes a float argument to its register, and to its stack slot when its slot is past r10.

Parameters
singleTrue when the argument is a 4 byte float.

◆ SetIntegerArgumentValue()

template<size_t Bytes = sizeof(u32)>
constexpr void rex::ppc::ArgTranslator::SetIntegerArgumentValue ( PPCContext & ctx,
u8 * base,
size_t slot,
u64 value )
inlinestaticconstexprnoexcept

Writes an integer argument to its register or its stack slot.

Template Parameters
BytesThe argument width in bytes, 4 or 8.
Parameters
valueValue to write. A 4 byte value goes to the low word of a stack slot.

◆ SetValue()

template<typename T>
constexpr void rex::ppc::ArgTranslator::SetValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg,
T value )
inlinestaticconstexprnoexcept

Writes an argument of any supported type.

◆ SetVectorArgumentValue()

void rex::ppc::ArgTranslator::SetVectorArgumentValue ( PPCContext & ctx,
u8 * base,
const ArgPlace & arg,
const PPCVRegister & value )
inlinestaticnoexcept

Writes a vector argument to its register or its 16 byte stack slot pair.

Parameters
valueThe vector, stored byte reversed in the stack image.

Member Data Documentation

◆ kFloatRegisters

size_t rex::ppc::ArgTranslator::kFloatRegisters = 13
staticconstexpr

Number of float argument registers, f1 to f13.

◆ kIntegerRegisters

size_t rex::ppc::ArgTranslator::kIntegerRegisters = 8
staticconstexpr

Number of integer argument registers, r3 to r10.

◆ kVectorRegisters

size_t rex::ppc::ArgTranslator::kVectorRegisters = 13
staticconstexpr

Number of vector argument registers, v1 to v13.


The documentation for this struct was generated from the following file: