Skip to content

Memory API

Markdown

This API provides special instruction intrinsics, cache operations and memcpy()-type routines. shz_memcpy() is a generic drop-in memcpy() replacement; when you know and control the alignment and batch sizes, you can micro-optimize by calling the most specific specialization instead. sq_ routines write through the SH4 store queues, and _xmtrx routines use the XMTRX register bank as a scratch buffer, clobbering it. memcpy()-like routines will typically always check for proper alignment and size increments of parameters using assert(), so make sure to build a release build (-DNDEBUG) for maximal gainz when not debugging. There is no shz_memset() yet; it is listed as a TODO in the header.

  • C header: #include <sh4zam/shz_mem.h>
  • C++ header: #include <sh4zam/shz_mem.hpp>
  • Symbols: 24

Suffixes used in this module. The full list is in Naming and Suffixes.

  • sq_: Writes through the SH4 store queues (burst writes to memory or the PVR).
  • _xmtrx: Uses the XMTRX register bank as a 64-byte scratch buffer. Clobbers XMTRX.
  • memcpyN: A numeric suffix on memcpy/memset names the element granularity or count, e.g. shz_memcpy32_1 copies exactly one 32-byte line.

Specialized routines for specific sizes + alignments.

SymbolDescription
shz_memcpy1Undocumented upstream.
shz_memcpy2Undocumented upstream.
shz_memcpy4Undocumented upstream.
shz_memcpy8Undocumented upstream.
shz_memcpy32Undocumented upstream.
shz_sq_memcpy32Undocumented upstream.
shz_sq_memcpy32_xmtrxUndocumented upstream.
shz_memcpy64Undocumented upstream.
shz_memcpy128Undocumented upstream.

Routine replacing the C standard library copy/set API.

SymbolDescription
SHZ_ACCESSGeneric drop-in fast memcpy() replacement.
shz_memcpyUndocumented upstream.
shz_memmoveUndocumented upstream.

Specialized routines for operating on statically sized buffers.

SymbolDescription
shz_memcpy2_8Undocumented upstream.
shz_memcpy2_16Undocumented upstream.
shz_memcpy4_16Undocumented upstream.
shz_memcpy32_1Undocumented upstream.
shz_memswap32_1Undocumented upstream.
shz_memswap32_1_xmtrxUndocumented upstream.
shz_sq_memcpy32_1Undocumented upstream.
shz_sq_memcpy32_1_xmtrxUndocumented upstream.
SymbolDescription
SHZ_PREFETCHUsed to prepopulate the cache line mapping to the given address, before it is used.

Public declarations that upstream keeps out of its Doxygen reference. Listed for completeness; prefer the documented API.

SymbolDescription
shz_memset8Undocumented upstream.
shz_memset2_16Undocumented upstream.
shz_dcache_alloc_lineUndocumented upstream.