SHZ_ACCESS
SHZ_ACCESS(write_only, 1, 3) SHZ_ACCESS(read_only, 2, 3) SHZ_INLINE void* shz_memcpy( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT;Generic drop-in fast memcpy() replacement.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| `` | write_only | |
| `` | 1 | |
| `` | 3 |
Returns
Section titled “Returns”dst buffer pointer.
Details
Section titled “Details”Specialized memcpy() variant for copying multiples of 128 bytes.
Specialized memcpy() variant for copying multiples of 64-bytes.
Copies bytes from src to dst in 32-byte chunks, using the Store Queues and XMTRX.
Copies bytes from src to dst in 32-byte chunks, using the Store Queues.
Copies bytes from the src to the dst buffer in 32-byte chunks.
Assigns the given 8-byte value to the bytes in dst.
Copies a from one 8-byte aligned buffer to another 8 bytes at a time.
Copies a from one 4-byte aligned buffer to another 4 bytes at a time.
Copies from one 2-byte aligned buffer to another two bytes at a time.
Copies an unaligned buffer to another one byte at a time.
Generic drop-in fast memmove() replacement.
Copies bytes from src to dst, determining the most efficient specialization to call into at run-time, returning dst.
There are no alignment or size requirements for this routine, but it is specifically optimized for 2-, 4-, 8-, and 32-byte alignments, with bigger alignments bringing bigger gainz.
Copies bytes from src to dst, determining the most efficient specialization to call into at run-time, return dst. The source and destination buffers are allowed to overlap, making this routine slightly less efficient, but more versatile than shz_memcpy().
There is no alignment or size requirement for this routine.
The dst pointer is returned.
The dst pointer is returned.
The dst buffer is returned.
The dst buffer is returned.
Transfers from 8-byte aligned buffer, src to 32-byte aligned buffer, dst, 32 bytes at a time. Returns the dst address.
Transfers from 8-byte aligned buffer, src to 4-byte aligned address, dst, 32 bytes at a time, writing through the cache, using the SH4's Store Queues. Returns the dst address.
Equiavalent to shz_sq_memcpy32(), except copying is done through XMTRX.
Copies a from an 8-byte aligned buffer to a 32-byte aligned buffer, 64 bytes at a time. Returns the dst address.
Copies a from an 8-byte aligned buffer to a 32-byte aligned buffer, 128 bytes at a time. Returns the dst address.
- When you know of and can control the
srcanddstalignments and batch sizes, you can micro-optimize by calling into the most specific memcpy() specialization for your given scenario, over just using this generic implementation, which must choose which one to use at run-time. - Typically, unless you know you are copying a tiny number of definitely unaligned bytes, you want to use
shz_memcpy(), which automatically handles arbitrary alignment for you, potentially more efficiently than copying byte-by-byte. - This is the quickest way to move 32-byte chunks of data around within memory, but the
shz_sq_memcpy32()will be faster when writing through the cache to external memory. - This is the quickest way to move 32-byte chunks of data to external memory. When copying to cached memory, you must invalidate the cache lines containing
dstbefore initiating the copy... Which means this routine becomes slower than doing memory-to-memory copies withshz_memcpy32().
Warnings
Section titled “Warnings”dstandsrcbuffers should not be overlapping.dstandsrcbuffers should not be overlapping.dstandsrcmust both be aligned by at least 2 bytes, andbytesmust be a multiple of 2.dstandsrcbuffers should not be overlapping.dstandsrcmust both be aligned by at least 4 bytes, andbytesmust be a multiple of 4.dstandsrcbuffers should not be overlapping.dstandsrcmust both be aligned by at least 8 bytes, andbytesmust be a multiple of 8.srcanddstshould not overlap.dstshould be at least 8-byte aligned, andbytesshould be a multiple of 8!dstmust be 32-byte aligned, whilesrccan be only 8-byte aligned.bytesmust be a multiple of 32.srcanddstbuffers must not overlap.srcmust be at least 8-byte aligned, whiledstcan be only 4-byte aligned.bytesmust be a multiple of 32.- This routine clobbers XMTRX.
srcanddstbuffers must not overlap.dstmust be 32-byte aligned, whilesrccan be only 8-byte aligned.bytesmust be a multiple of 64.srcanddstbuffers must not overlap.dstmust be 32-byte aligned, whilesrccan be only 8-byte aligned.bytesmust be a multiple of 128.
Availability
Section titled “Availability”- C++ equivalent: none (call the C function from C++)
- Type-generic form: none
- Back-ends: SH4: shared C implementation · SW: portable C · SPU: shared C implementation
- Defined in:
sh4zam/shz_mem.h:84 - Module: Memory, section "C stdlib Replacements"
See also
Section titled “See also”shz_memcpy1, shz_memcpy2, shz_memcpy4, shz_memcpy8, shz_memcpy32, shz_memcpy64, shz_memcpy128, shz_memcpy, shz_sq_memcpy32, shz_sq_memcpy32_1