Skip to content

Commit e2379a6

Browse files
committed
matrix.h: Fix const-correctness for some *_fast function parameters.
- In practice, this only affected compiling for NEON on certain compilers. Other SIMD ISAs should remain unaffected.
1 parent 5cd9d36 commit e2379a6

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

desmume/src/matrix.h

+20-20
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ static void memset_u32_fast(void *dst, const u32 val)
185185
}
186186

187187
template <size_t LENGTH>
188-
static void stream_copy_fast(void *__restrict dst, void *__restrict src)
188+
static void stream_copy_fast(void *__restrict dst, const void *__restrict src)
189189
{
190190
MACRODO_N( LENGTH / sizeof(v512s8), _mm512_stream_si512((v512s8 *)dst + (X), _mm512_stream_load_si512((v512s8 *)src + (X))) );
191191
}
192192

193193
template <size_t LENGTH>
194-
static void buffer_copy_fast(void *__restrict dst, void *__restrict src)
194+
static void buffer_copy_fast(void *__restrict dst, const void *__restrict src)
195195
{
196196
MACRODO_N( LENGTH / sizeof(v512s8), _mm512_store_si512((v512s8 *)dst + (X), _mm512_load_si512((v512s8 *)src + (X))) );
197197
}
@@ -479,7 +479,7 @@ static void memset_u32_fast(void *dst, const u32 val)
479479
}
480480

481481
template <size_t VECLENGTH>
482-
static void stream_copy_fast(void *__restrict dst, void *__restrict src)
482+
static void stream_copy_fast(void *__restrict dst, const void *__restrict src)
483483
{
484484
#ifdef ENABLE_SSE4_1
485485
MACRODO_N( VECLENGTH / sizeof(v128s8), _mm_stream_si128((v128s8 *)dst + (X), _mm_stream_load_si128((v128s8 *)src + (X))) );
@@ -489,7 +489,7 @@ static void stream_copy_fast(void *__restrict dst, void *__restrict src)
489489
}
490490

491491
template <size_t VECLENGTH>
492-
static void buffer_copy_fast(void *__restrict dst, void *__restrict src)
492+
static void buffer_copy_fast(void *__restrict dst, const void *__restrict src)
493493
{
494494
MACRODO_N( VECLENGTH / sizeof(v128s8), _mm_store_si128((v128s8 *)dst + (X), _mm_load_si128((v128s8 *)src + (X))) );
495495
}
@@ -606,13 +606,13 @@ static void memset_u32_fast(void *dst, const u32 val)
606606
}
607607

608608
template <size_t VECLENGTH>
609-
static void buffer_copy_fast(void *__restrict dst, void *__restrict src)
609+
static void buffer_copy_fast(void *__restrict dst, const void *__restrict src)
610610
{
611611
MACRODO_N( VECLENGTH / sizeof(uint8x16x4_t), vst1q_u8_x4((u8 *)dst + ((X) * sizeof(uint8x16x4_t)), vld1q_u8_x4((u8 *)src + ((X) * sizeof(uint8x16x4_t)))) );
612612
}
613613

614614
template <size_t VECLENGTH>
615-
static void stream_copy_fast(void *__restrict dst, void *__restrict src)
615+
static void stream_copy_fast(void *__restrict dst, const void *__restrict src)
616616
{
617617
// NEON doesn't have the same temporal/caching distinctions that SSE and AVX do,
618618
// so just use buffer_copy_fast() for this function too.
@@ -656,10 +656,10 @@ static void buffer_copy_or_constant_s8(void *__restrict dst, const void *__restr
656656
}
657657

658658
template <size_t VECLENGTH>
659-
static void buffer_copy_or_constant_s8_fast(void *__restrict dst, void *__restrict src, const s8 c)
659+
static void buffer_copy_or_constant_s8_fast(void *__restrict dst, const void *__restrict src, const s8 c)
660660
{
661661
const v128u8 c_vec = vreinterpretq_u8_s8( vdupq_n_s8(c) );
662-
__buffer_copy_or_constant_fast<VECLENGTH, false>(dst, src, c_vec);
662+
__buffer_copy_or_constant_fast<VECLENGTH>(dst, src, c_vec);
663663
}
664664

665665
template <bool NEEDENDIANSWAP>
@@ -670,7 +670,7 @@ static void buffer_copy_or_constant_s16(void *__restrict dst, const void *__rest
670670
}
671671

672672
template <size_t VECLENGTH, bool NEEDENDIANSWAP>
673-
static void buffer_copy_or_constant_s16_fast(void *__restrict dst, void *__restrict src, const s16 c)
673+
static void buffer_copy_or_constant_s16_fast(void *__restrict dst, const void *__restrict src, const s16 c)
674674
{
675675
const v128u8 c_vec = vreinterpretq_u8_s16( vdupq_n_s16(c) );
676676
__buffer_copy_or_constant_fast<VECLENGTH>(dst, src, c_vec);
@@ -684,7 +684,7 @@ static void buffer_copy_or_constant_s32(void *__restrict dst, const void *__rest
684684
}
685685

686686
template <size_t VECLENGTH, bool NEEDENDIANSWAP>
687-
static void buffer_copy_or_constant_s32_fast(void *__restrict dst, void *__restrict src, const s32 c)
687+
static void buffer_copy_or_constant_s32_fast(void *__restrict dst, const void *__restrict src, const s32 c)
688688
{
689689
const v128u8 c_vec = vreinterpretq_u8_s32( vdupq_n_s32(c) );
690690
__buffer_copy_or_constant_fast<VECLENGTH>(dst, src, c_vec);
@@ -731,13 +731,13 @@ static void memset_u32_fast(void *dst, const u32 val)
731731
}
732732

733733
template <size_t VECLENGTH>
734-
static void buffer_copy_fast(void *__restrict dst, void *__restrict src)
734+
static void buffer_copy_fast(void *__restrict dst, const void *__restrict src)
735735
{
736736
MACRODO_N( VECLENGTH / sizeof(v128s8), vec_st(vec_ld((X)*sizeof(v128s8),(u8 *__restrict)src), (X)*sizeof(v128s8), (u8 *__restrict)dst) );
737737
}
738738

739739
template <size_t VECLENGTH>
740-
static void stream_copy_fast(void *__restrict dst, void *__restrict src)
740+
static void stream_copy_fast(void *__restrict dst, const void *__restrict src)
741741
{
742742
// AltiVec doesn't have the same temporal/caching distinctions that SSE and AVX do,
743743
// so just use buffer_copy_fast() for this function too.
@@ -782,7 +782,7 @@ static void buffer_copy_or_constant_s8(void *__restrict dst, const void *__restr
782782
}
783783

784784
template <size_t VECLENGTH>
785-
static void buffer_copy_or_constant_s8_fast(void *__restrict dst, void *__restrict src, const s8 c)
785+
static void buffer_copy_or_constant_s8_fast(void *__restrict dst, const void *__restrict src, const s8 c)
786786
{
787787
const v128s8 c_vec = {c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c};
788788
__buffer_copy_or_constant_fast<v128s8, VECLENGTH>(dst, src, c_vec);
@@ -797,7 +797,7 @@ static void buffer_copy_or_constant_s16(void *__restrict dst, const void *__rest
797797
}
798798

799799
template <size_t VECLENGTH, bool NEEDENDIANSWAP>
800-
static void buffer_copy_or_constant_s16_fast(void *__restrict dst, void *__restrict src, const s16 c)
800+
static void buffer_copy_or_constant_s16_fast(void *__restrict dst, const void *__restrict src, const s16 c)
801801
{
802802
const s16 c_16 = (NEEDENDIANSWAP) ? LE_TO_LOCAL_16(c) : c;
803803
const v128s16 c_vec = {c_16, c_16, c_16, c_16, c_16, c_16, c_16, c_16};
@@ -813,7 +813,7 @@ static void buffer_copy_or_constant_s32(void *__restrict dst, const void *__rest
813813
}
814814

815815
template <size_t VECLENGTH, bool NEEDENDIANSWAP>
816-
static void buffer_copy_or_constant_s32_fast(void *__restrict dst, void *__restrict src, const s32 c)
816+
static void buffer_copy_or_constant_s32_fast(void *__restrict dst, const void *__restrict src, const s32 c)
817817
{
818818
const s32 c_32 = (NEEDENDIANSWAP) ? LE_TO_LOCAL_32(c) : c;
819819
const v128s32 c_vec = {c_32, c_32, c_32, c_32};
@@ -889,13 +889,13 @@ static void memset_u32_fast(void *dst, const u32 val)
889889
// vector intrinsics to control the temporal/caching behavior.
890890

891891
template <size_t VECLENGTH>
892-
static void stream_copy_fast(void *__restrict dst, void *__restrict src)
892+
static void stream_copy_fast(void *__restrict dst, const void *__restrict src)
893893
{
894894
memcpy(dst, src, VECLENGTH);
895895
}
896896

897897
template <size_t VECLENGTH>
898-
static void buffer_copy_fast(void *__restrict dst, void *__restrict src)
898+
static void buffer_copy_fast(void *__restrict dst, const void *__restrict src)
899899
{
900900
memcpy(dst, src, VECLENGTH);
901901
}
@@ -920,7 +920,7 @@ static void buffer_copy_or_constant_s8(void *__restrict dst, const void *__restr
920920
}
921921

922922
template <size_t VECLENGTH>
923-
static void buffer_copy_or_constant_s8_fast(void *__restrict dst, void *__restrict src, const s8 c)
923+
static void buffer_copy_or_constant_s8_fast(void *__restrict dst, const void *__restrict src, const s8 c)
924924
{
925925
#ifdef HOST_64
926926
s64 *src_64 = (s64 *)src;
@@ -980,7 +980,7 @@ static void buffer_copy_or_constant_s16(void *__restrict dst, const void *__rest
980980
}
981981

982982
template <size_t VECLENGTH, bool NEEDENDIANSWAP>
983-
static void buffer_copy_or_constant_s16_fast(void *__restrict dst, void *__restrict src, const s16 c)
983+
static void buffer_copy_or_constant_s16_fast(void *__restrict dst, const void *__restrict src, const s16 c)
984984
{
985985
#ifdef HOST_64
986986
s64 *src_64 = (s64 *)src;
@@ -1049,7 +1049,7 @@ static void buffer_copy_or_constant_s32(void *__restrict dst, const void *__rest
10491049
}
10501050

10511051
template <size_t VECLENGTH, bool NEEDENDIANSWAP>
1052-
static void buffer_copy_or_constant_s32_fast(void *__restrict dst, void *__restrict src, const s32 c)
1052+
static void buffer_copy_or_constant_s32_fast(void *__restrict dst, const void *__restrict src, const s32 c)
10531053
{
10541054
#ifdef HOST_64
10551055
s64 *src_64 = (s64 *)src;

0 commit comments

Comments
 (0)