Commit b842d131 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/32s: Allow constant folding in mtsr()/mfsr()



On the same way as we did in wrtee(), add an alternative
using mtsr/mfsr instructions instead of mtsrin/mfsrin
when the segment register can be determined at compile time.

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/9baed0ff9d76723ec90f1b567ddd4ac1ecc7a190.1612612022.git.christophe.leroy@csgroup.eu
parent 179ae57d
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1417,6 +1417,9 @@ static inline u32 mfsr(u32 idx)
{
	u32 val;

	if (__builtin_constant_p(idx))
		asm volatile("mfsr %0, %1" : "=r" (val): "i" (idx >> 28));
	else
		asm volatile("mfsrin %0, %1" : "=r" (val): "r" (idx));

	return val;
@@ -1424,6 +1427,9 @@ static inline u32 mfsr(u32 idx)

static inline void mtsr(u32 val, u32 idx)
{
	if (__builtin_constant_p(idx))
		asm volatile("mtsr %1, %0" : : "r" (val), "i" (idx >> 28));
	else
		asm volatile("mtsrin %0, %1" : : "r" (val), "r" (idx));
}
#endif