1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _SELFTESTS_POWERPC_INSTRUCTIONS_H
3 #define _SELFTESTS_POWERPC_INSTRUCTIONS_H
8 /* This defines the "copy" instruction from Power ISA 3.0 Book II, section 4.4. */
9 #define __COPY(RA, RB, L) \
10 (0x7c00060c | (RA) << (31-15) | (RB) << (31-20) | (L) << (31-10))
11 #define COPY(RA, RB, L) \
12 .long __COPY((RA), (RB), (L))
14 static inline void copy(void *i)
16 asm volatile(str(COPY(0, %0, 0))";"
23 static inline void copy_first(void *i)
25 asm volatile(str(COPY(0, %0, 1))";"
32 /* This defines the "paste" instruction from Power ISA 3.0 Book II, section 4.4. */
33 #define __PASTE(RA, RB, L, RC) \
34 (0x7c00070c | (RA) << (31-15) | (RB) << (31-20) | (L) << (31-10) | (RC) << (31-31))
35 #define PASTE(RA, RB, L, RC) \
36 .long __PASTE((RA), (RB), (L), (RC))
38 static inline int paste(void *i)
42 asm volatile(str(PASTE(0, %1, 0, 0))";"
51 static inline int paste_last(void *i)
55 asm volatile(str(PASTE(0, %1, 1, 1))";"
64 #define PPC_INST_COPY __COPY(0, 0, 0)
65 #define PPC_INST_COPY_FIRST __COPY(0, 0, 1)
66 #define PPC_INST_PASTE __PASTE(0, 0, 0, 0)
67 #define PPC_INST_PASTE_LAST __PASTE(0, 0, 1, 1)
69 #endif /* _SELFTESTS_POWERPC_INSTRUCTIONS_H */