|
ReXGlue SDK
|
Namespaces | |
| namespace | simd |
Classes | |
| struct | ArgCountT |
| struct | ArgPlace |
| struct | ArgPlaceT |
| struct | ArgTranslator |
| struct | BoundThread |
| struct | ByValue |
| struct | CRRegister |
| struct | DetourOriginal |
| struct | DetourOriginal< R(Args...)> |
| struct | DetourOriginal< R(PPCContext &, Args...)> |
| struct | EmbeddedMetadataAsset |
| struct | FPSCRRegister |
| struct | ImportFunction |
| struct | ImportFunction< R(Args...)> |
| struct | IsByValue |
| struct | IsByValue< ByValue< T > > |
| struct | KernelHooks |
| struct | MMIORecipient |
| struct | PPCCallUsage |
| struct | PPCCodegenFlags |
| struct | PPCImage |
| union | Register |
| struct | RuntimeFunction |
| class | StackFrame |
| struct | Vec128S |
| union | VRegister |
| struct | VSCRRegister |
| struct | XERRegister |
Concepts | |
| concept | BigEndianType |
| concept | MappedPtrType |
| concept | FloatType |
| concept | VectorType |
| concept | ByValueType |
| concept | HiddenReturnType |
| concept | PlainType |
Typedefs | |
| using | RegisterModulesFunc = void (*)(kernel::IModuleRegistry& modules) |
| using | RecompiledCodeFunc = std::span<const u8> (*)() |
| using | Vec128 = Vec128S |
Enumerations | |
| enum class | RuntimeFunctionType : u8 { kSaveMillicode , kNoHandler , kRestoreMillicode , kHandler } |
| enum class | MMIOBlock : u8 { kGPU , kAPU } |
Functions | |
| template<typename R, typename... T> | |
| constexpr std::tuple< T... > | FunctionArgs (R(*)(T...)) noexcept |
| constexpr u32 | ByValueSlots (size_t size) |
| constexpr bool | IsRightJustified (size_t size) |
| template<typename T> | |
| constexpr bool | IsFloatType () |
| template<typename... Args> | |
| constexpr std::array< ArgPlace, sizeof...(Args)> | PlaceArgs () |
| template<typename R, typename... Args> | |
| constexpr auto | PlaceSignatureArgs (R(*)(Args...)) |
| template<auto Func> | |
| constexpr auto | PlaceFunctionArgs () |
| template<auto Func, int I = 0, typename... TArgs> requires (I >= sizeof...(TArgs)) | |
| void | TranslateArgsToHost (PPCContext &ctx, u8 *base, std::tuple< TArgs... > &) noexcept |
| template<auto Func, int I = 0, typename... TArgs> requires (I < sizeof...(TArgs)) | |
| void | TranslateArgsToHost (PPCContext &ctx, u8 *base, std::tuple< TArgs... > &tpl) noexcept |
| template<int I = 0, typename... TArgs> requires (I >= sizeof...(TArgs)) | |
| void | TranslateArgsToGuest (PPCContext &ctx, u8 *base, std::tuple< TArgs... > &) noexcept |
| template<int I = 0, typename... TArgs> requires (I < sizeof...(TArgs)) | |
| void | TranslateArgsToGuest (PPCContext &ctx, u8 *base, std::tuple< TArgs... > &tpl) noexcept |
| template<ByValueType T> | |
| void | StoreByValue (u8 *base, u32 address, const T &value) |
| template<ByValueType T> | |
| u64 | ByValueToWord (const T &value) |
| template<ByValueType T> | |
| T | ByValueFromWord (u64 word) |
| template<ByValueType T> | |
| T | LoadByValue (u8 *base, u32 address) |
| template<typename RetT> | |
| void | StoreHostResult (PPCContext &ctx, u8 *base, u32 hidden_pointer, const RetT &value) |
| template<auto Func, bool StopAtEntry = true> | |
| void | GuestToHostThunk (PPCContext &ctx, u8 *base) |
| u32 | GetStackLimit (PPCContext &ctx, u8 *base) |
| void | stack_bounds_check (PPCContext &ctx, u8 *base, u32 new_r1) |
| u32 | FrameBelow (PPCContext &ctx, u8 *base, u32 size) |
| u32 | OpenCallFrame (PPCContext &ctx, u8 *base, u32 stack_bytes) |
| template<typename... Args> | |
| constexpr u32 | GetStackArgumentBytes () |
| template<typename R> | |
| constexpr u32 | HiddenReturnBytes () |
| template<typename R> | |
| R | LoadGuestResult (u8 *base, const PPCRegister &r3, const PPCRegister &f1, const PPCVRegister &v1, u32 result_storage) |
| template<typename R, typename... Args> | |
| R | Call (PPCContext &ctx, u8 *base, PPCFunc &fn, Args... args) |
| template<typename T, typename... TArgs> | |
| T | HostToGuestCall (PPCFunc *func, TArgs &&... argv) |
| REX_PPC_API BoundThread | GetBoundThread () |
| f64 | ReciprocalEstimate (f64 x) noexcept |
| f64 | ReciprocalSqrtEstimate (f64 x) noexcept |
| template<auto Body> | |
| void | RunDetour (PPCContext &ctx, u8 *base, const char *name, PPCFunc *host) |
| REX_PPC_API bool | RegisterEmbeddedMetadataAsset (std::string_view relative_path, const u8 *data, std::size_t size) |
| REX_PPC_API std::optional< EmbeddedMetadataAsset > | FindEmbeddedMetadataAsset (const std::filesystem::path &relative_path) |
| constexpr RuntimeFunction | DecodeRuntimeFunction (u32 begin, u32 word) |
| REX_PPC_API void | SetKernelHooks (const KernelHooks *hooks) |
| constexpr u32 | MMIOBlockBase (MMIOBlock block) |
| constexpr std::optional< MMIOBlock > | MMIOBlockOf (u32 address) |
| constexpr bool | IsMMIOBlockAddress (u32 address) |
| REX_PPC_API void | AttachMMIO (MMIOBlock block, const MMIORecipient &recipient) |
| REX_PPC_API void | DetachMMIO (MMIOBlock block, const void *context) |
| REX_PPC_API u32 | MMIOLoad32 (u32 address) |
| REX_PPC_API void | MMIOStore32 (u32 address, u32 value) |
| REX_PPC_API u8 | MMIOLoad8 (u32 address) |
| REX_PPC_API u16 | MMIOLoad16 (u32 address) |
| REX_PPC_API void | MMIONarrowStore (u32 address, u32 size) |
| REX_PPC_API PPCFunc * | ResolveFunction (u32 guest_address) |
| REX_PPC_API void | Trap (PPCContext &ctx, u8 *base, u16 trap_type) |
| REX_PPC_API std::jmp_buf & | GetJumpBuffer (u32 address) |
| REX_PPC_API void | LongJump (u32 address, int value) |
| REX_PPC_API void | UnimplementedInstruction (const char *opcode) |
| REX_PPC_API bool | AddRecompiledCode (std::span< const u8 > code) |
| REX_PPC_API void | RemoveRecompiledCode (std::span< const u8 > code) |
| REX_PPC_API bool | IsRecompiledCode (u64 address) |
| std::string | to_string (const Vec128 &value) |
| std::ostream & | operator<< (std::ostream &os, const Vec128 &value) |
| std::string | to_hex_string (const Vec128 &value) |
| template<int N> | |
| f32 | m128_f32 (const simde__m128 &v) |
| template<int N> | |
| i32 | m128_i32 (const simde__m128 &v) |
| template<int N> | |
| f64 | m128_f64 (const simde__m128d &v) |
| template<int N> | |
| f64 | m128_f64 (const simde__m128 &v) |
| template<int N> | |
| i64 | m128_i64 (const simde__m128d &v) |
| template<int N> | |
| i64 | m128_i64 (const simde__m128 &v) |
Variables | |
| template<ByValueType T> | |
| constexpr size_t | kByValueSize = sizeof(std::declval<std::remove_cvref_t<T>>().value) |
| constexpr u32 | kRedZone = 1344 |
| constexpr u32 | kLinkageSize = 0x50 |
| constexpr u32 | kHostReturnAddress = 0xBCBCBCBC |
| constexpr u32 | kRoundNearest = 0x00 |
| constexpr u32 | kRoundTowardZero = 0x01 |
| constexpr u32 | kRoundUp = 0x02 |
| constexpr u32 | kRoundDown = 0x03 |
| constexpr u32 | kRoundMask = 0x03 |
| constexpr u64 | kScalarReciprocalTable [128] |
| constexpr u64 | kScalarReciprocalSqrtTable [16] |
| constexpr u32 | kSign32 = 0x80000000u |
| constexpr u32 | kQuiet32 = 0x00400000u |
| constexpr u32 | kInfinity32 = 0x7F800000u |
| constexpr u32 | kQNaN32 = 0x7FC00000u |
| constexpr u64 | kSign64 = 0x8000000000000000ull |
| constexpr u64 | kQuiet64 = 0x0008000000000000ull |
| constexpr u64 | kMantissa64 = 0x000FFFFFFFFFFFFFull |
| constexpr u64 | kInfinity64 = 0x7FF0000000000000ull |
| constexpr u64 | kQNaN64 = 0x7FF8000000000000ull |
| constexpr u32 | kMMIOBlockSize = 0x10000 |
The PowerPC context, intrinsics and hook support that generated code uses.
| using rex::ppc::RecompiledCodeFunc = std::span<const u8> (*)() |
Returns the recompiled code that codegen generated for an image.
| using rex::ppc::RegisterModulesFunc = void (*)(kernel::IModuleRegistry& modules) |
Registers the recompiled libraries of a project with several binaries.
| modules | The module registry of the runtime being launched. |
|
strong |
|
strong |
| REX_PPC_API bool rex::ppc::AddRecompiledCode | ( | std::span< const u8 > | code | ) |
Registers a range of recompiled code. Each registration needs its own RemoveRecompiledCode.
| REX_PPC_API void rex::ppc::AttachMMIO | ( | MMIOBlock | block, |
| const MMIORecipient & | recipient ) |
Routes the loads and stores of a block to a recipient. A recipient with no read or write handler is refused. Call it only while no guest thread runs.
| block | Block whose accesses are routed. |
| recipient | The handler and its context. |
| T rex::ppc::ByValueFromWord | ( | u64 | word | ) |
Unpacks a structure of at most 8 bytes from the register image a function returns in r3.
|
constexpr |
Returns the number of 8 byte image slots a structure takes.
| u64 rex::ppc::ByValueToWord | ( | const T & | value | ) |
Packs a structure of at most 8 bytes into the register image a function returns in r3.
| R rex::ppc::Call | ( | PPCContext & | ctx, |
| u8 * | base, | ||
| PPCFunc & | fn, | ||
| Args... | args ) |
Calls recompiled code on the thread's register file by the guest calling convention.
| R | The return type, read from r3 or f1. |
| ctx | The register file of the calling thread. |
|
constexpr |
Decodes a pdata entry.
| begin | The begin address word. |
| word | The type, length and prologue word. |
| REX_PPC_API void rex::ppc::DetachMMIO | ( | MMIOBlock | block, |
| const void * | context ) |
Restores the null recipient when the block routes to the context.
| block | Block to restore. |
| context | The context the owner attached. |
| REX_PPC_API std::optional< EmbeddedMetadataAsset > rex::ppc::FindEmbeddedMetadataAsset | ( | const std::filesystem::path & | relative_path | ) |
Looks up an embedded metadata asset by normalized path.
|
inline |
Returns a 16 byte aligned r1 under the current one, aborting on a wrap or a stack limit crossing.
| base | The guest memory base, null when no thread state is bound. |
| size | The bytes the frame needs. |
|
constexprnoexcept |
Returns a tuple of the argument types of a function pointer.
| REX_PPC_API BoundThread rex::ppc::GetBoundThread | ( | ) |
Returns the register file and memory base of the calling thread, null when no thread state is bound to the calling thread.
| REX_PPC_API std::jmp_buf & rex::ppc::GetJumpBuffer | ( | u32 | address | ) |
Returns the host jump buffer of the calling thread for a guest jump buffer address, created on first use.
| address | The guest address of the jump buffer. |
|
constexpr |
Returns the stack argument bytes a call with these argument types needs. The count is 8 bytes per argument slot past slot 8.
|
inline |
Returns the stack limit of the running thread, 0 when r13 is unset.
| void rex::ppc::GuestToHostThunk | ( | PPCContext & | ctx, |
| u8 * | base ) |
Calls a native function with arguments read from the register file.
| StopAtEntry | False to skip the stop check before the call, for a release that must finish. |
|
constexpr |
Returns the call frame bytes the result of a hidden return call needs, 0 when R is not returned through a pointer.
| T rex::ppc::HostToGuestCall | ( | PPCFunc * | func, |
| TArgs &&... | argv ) |
Calls recompiled code on the calling thread's register file.
| TArgs | The argument types, deduced from argv. |
|
constexpr |
Reports whether a type is float or double.
|
constexpr |
Reports whether an address is in a register block.
| REX_PPC_API bool rex::ppc::IsRecompiledCode | ( | u64 | address | ) |
Reports whether an address is in registered recompiled code. Safe in a signal handler.
|
constexpr |
Reports whether a structure sits at the low end of its slot instead of the start.
| T rex::ppc::LoadByValue | ( | u8 * | base, |
| u32 | address ) |
Reads a structure from guest memory in guest layout, a vector byte reversed.
| R rex::ppc::LoadGuestResult | ( | u8 * | base, |
| const PPCRegister & | r3, | ||
| const PPCRegister & | f1, | ||
| const PPCVRegister & | v1, | ||
| u32 | result_storage ) |
Reads the result a guest function left in its result registers.
| result_storage | The guest address of the hidden return storage, used by a hidden return. |
| REX_PPC_API void rex::ppc::LongJump | ( | u32 | address, |
| int | value ) |
Jumps to the host jump buffer of the calling thread for a guest jump buffer address.
| address | The guest address of the jump buffer. |
| value | The value setjmp returns. |
| f32 rex::ppc::m128_f32 | ( | const simde__m128 & | v | ) |
Returns a lane of an SSE register as f32.
| N | Lane index, 0 to 3. |
| f64 rex::ppc::m128_f64 | ( | const simde__m128 & | v | ) |
Returns a lane of an SSE register as f64.
| N | Lane index, 0 or 1. |
| v | The SSE register, read as two f64 lanes. |
| f64 rex::ppc::m128_f64 | ( | const simde__m128d & | v | ) |
Returns a lane of an SSE register as f64.
| N | Lane index, 0 or 1. |
| i32 rex::ppc::m128_i32 | ( | const simde__m128 & | v | ) |
Returns the bits of a lane of an SSE register as i32.
| N | Lane index, 0 to 3. |
| i64 rex::ppc::m128_i64 | ( | const simde__m128 & | v | ) |
Returns the bits of a lane of an SSE register as i64.
| N | Lane index, 0 or 1. |
| v | The SSE register, read as two 64 bit lanes. |
| i64 rex::ppc::m128_i64 | ( | const simde__m128d & | v | ) |
Returns the bits of a lane of an SSE register as i64.
| N | Lane index, 0 or 1. |
|
constexpr |
Finds the register block that holds an address.
| REX_PPC_API u16 rex::ppc::MMIOLoad16 | ( | u32 | address | ) |
Loads two bytes of a register, addressed as in big endian order.
| REX_PPC_API u32 rex::ppc::MMIOLoad32 | ( | u32 | address | ) |
Loads a register value.
| REX_PPC_API u8 rex::ppc::MMIOLoad8 | ( | u32 | address | ) |
Loads one byte of a register, addressed as in big endian order.
| address | The guest address of the byte. |
| REX_PPC_API void rex::ppc::MMIONarrowStore | ( | u32 | address, |
| u32 | size ) |
Ends the process with an error naming a store narrower than a register.
| REX_PPC_API void rex::ppc::MMIOStore32 | ( | u32 | address, |
| u32 | value ) |
Stores a register value. A store outside both blocks is ignored.
|
inline |
Opens a call frame under r1 for a call from host code into recompiled code.
| stack_bytes | The stack argument bytes the call needs. |
| std::ostream & rex::ppc::operator<< | ( | std::ostream & | os, |
| const Vec128 & | value ) |
Writes the four u32 lanes as 8 digit uppercase hex, "[X X X X]".
|
constexpr |
Places an argument list by the guest calling convention, where a float takes the slot of an integer register and a vector in a register takes no slot.
| Args | The argument types in order. |
|
constexpr |
Places each argument of a function by the guest calling convention.
|
constexpr |
Places each argument of a function signature by the guest calling convention.
|
inlinenodiscardnoexcept |
Computes the scalar reciprocal estimate of fres.
Operands with a biased exponent below 895 give a signed infinity, above 1172 a signed zero. A NaN comes back quiet.
|
inlinenodiscardnoexcept |
Computes the scalar reciprocal square root estimate of frsqrte.
Zero gives a signed infinity. A negative operand or negative infinity gives the default quiet NaN.
| REX_PPC_API bool rex::ppc::RegisterEmbeddedMetadataAsset | ( | std::string_view | relative_path, |
| const u8 * | data, | ||
| std::size_t | size ) |
Registers a metadata asset embedded into the host executable.
An empty path, null data, 0 size or a path that normalizes to nothing is rejected.
| relative_path | Path relative to the metadata root, such as "icons/custom/67.png". |
| data | Asset bytes, which must stay valid for the whole process. |
| size | Byte count of data. |
| REX_PPC_API void rex::ppc::RemoveRecompiledCode | ( | std::span< const u8 > | code | ) |
Removes a registration of a range of recompiled code.
| code | The range passed to AddRecompiledCode. |
| REX_PPC_API PPCFunc * rex::ppc::ResolveFunction | ( | u32 | guest_address | ) |
Resolves a guest address to the recompiled function that implements it.
| void rex::ppc::RunDetour | ( | PPCContext & | ctx, |
| u8 * | base, | ||
| const char * | name, | ||
| PPCFunc * | host ) |
Runs a detour body for a recompiled function.
| Body | The detour body, optionally taking the context first. |
| host | The hook, as the image maps it. |
| REX_PPC_API void rex::ppc::SetKernelHooks | ( | const KernelHooks * | hooks | ) |
Sets the kernel calls of the PPC runtime. With none set, no thread is bound, no address resolves and the detour checks do nothing.
| hooks | The calls, which must stay valid until they are replaced. Null clears them. |
|
inline |
Aborts when a new r1 would fall below the stack limit of the thread.
| ctx | The register file, r1 still at its current value. |
| new_r1 | The r1 the caller is about to set. |
| void rex::ppc::StoreByValue | ( | u8 * | base, |
| u32 | address, | ||
| const T & | value ) |
Writes a structure to guest memory in guest layout, a vector byte reversed.
| void rex::ppc::StoreHostResult | ( | PPCContext & | ctx, |
| u8 * | base, | ||
| u32 | hidden_pointer, | ||
| const RetT & | value ) |
Writes the result of a native C++ function to the registers a guest caller reads.
| hidden_pointer | The result pointer the caller passed in r3, used by a hidden return. |
|
inline |
Formats the four u32 lanes of a vector as hex.
| std::string rex::ppc::to_string | ( | const Vec128 & | value | ) |
Returns the four f32 lanes as "(x, y, z, w)".
|
noexcept |
Ends the recursion over the arguments written as guest values.
|
noexcept |
Writes argument I and every later one from a tuple into the register file and stack image.
|
noexcept |
Ends the recursion over the arguments read into host values.
|
noexcept |
Reads argument I and every later one from the register file into a tuple.
| REX_PPC_API void rex::ppc::Trap | ( | PPCContext & | ctx, |
| u8 * | base, | ||
| u16 | trap_type ) |
Logs a trap instruction of generated code. Execution continues.
| REX_PPC_API void rex::ppc::UnimplementedInstruction | ( | const char * | opcode | ) |
Throws for an instruction that codegen does not translate.
|
inlineconstexpr |
Size in bytes of the structure a ByValue holds.
|
inlineconstexpr |
Return address a call from host code leaves in lr.
|
inlineconstexpr |
Minimum frame of a guest function that calls others, 10 double words.
|
inlineconstexpr |
Bytes under r1 a leaf guest function may use without moving r1.
|
constexpr |
Rounding mode, toward negative infinity.
|
constexpr |
Rounding mode, toward positive infinity.
|
inlineconstexpr |
Scalar reciprocal square root estimate indexed by parity and the top 3 mantissa bits.
|
inlineconstexpr |
Result of the scalar reciprocal estimate indexed by the top 7 mantissa bits of the operand.