5 typedef uint32_t HWord_t
;
7 typedef uint64_t HWord_t
;
10 typedef void (*test_func_t
)();
12 typedef struct test_table
{
17 static uint32_t values
[] = {
27 register HWord_t r27
asm("r27");
28 register HWord_t r28
asm("r28");
29 register HWord_t r29
asm("r29");
30 register HWord_t r30
asm("r30");
31 register HWord_t r31
asm("r31");
33 register HWord_t r14
asm("r14");
39 #define SAVE_REGS(addr) \
43 " std 29, 16(%0) \n" \
44 " std 30, 24(%0) \n" \
45 " std 31, 32(%0) \n" \
48 #define RESTORE_REGS(addr) \
57 #else /* !__powerpc64__ */
59 #define SAVE_REGS(addr) \
64 " stw 30, 12(%0) \n" \
65 " stw 31, 16(%0) \n" \
68 #define RESTORE_REGS(addr) \
73 " lwz 30, 12(%0) \n" \
74 " lwz 31, 16(%0) \n" \
77 #endif /* __powerpc64__ */
80 * gcc is not happy if we modify r31 (the frame pointer) behind its back
83 static void __attribute__((optimize("-fomit-frame-pointer"))) test_lmw(void)
85 r14
= (HWord_t
)values
;
92 " lmw %r27, 0(%r14) \n");
95 printf("lmw => %016lx %016lx %016lx %016lx %016lx\n",
97 printf("lmw => %08x %08x %08x %08x %08x\n",
99 r27
, r28
, r29
, r30
, r31
);
102 * test load multiple with nonzero immediate offset
103 * load the last two values into r30 - r31.
104 * r27 - r29 should remain the same
107 " lmw %r30, 20(%r14) \n");
110 printf("lmw => %016lx %016lx %016lx %016lx %016lx\n",
112 printf("lmw => %08x %08x %08x %08x %08x\n",
114 r27
, r28
, r29
, r30
, r31
);
116 /* restore r27 - r31 */
121 * gcc is not happy if we modify r31 (the frame pointer) behind its back
124 static void __attribute__((optimize("-fomit-frame-pointer"))) test_stmw(void)
126 uint32_t result
[7] = { 0 };
133 " lwz 27, 0(%0) \n" \
134 " lwz 28, 4(%0) \n" \
135 " lwz 29, 8(%0) \n" \
136 " lwz 30, 12(%0) \n" \
137 " lwz 31, 16(%0) \n" \
140 RESTORE_REGS(values
);
143 r14
= (HWord_t
)&result
;
145 /* store r27 - r31 */
147 " stmw %r27, 0(%r14) \n");
150 for (i
= 0; i
< sizeof(result
) / sizeof(result
[0]); i
++)
151 printf("%08x ", result
[i
]);
156 * test store multiple with nonzero immediate offset
157 * store r30 - r31 into the last two places in the array
158 * the rest of the array should remain the same
161 " stmw %r30, 20(%r14) \n");
164 for (i
= 0; i
< sizeof(result
) / sizeof(result
[0]); i
++)
165 printf("%08x ", result
[i
]);
172 static test_table_t all_tests
[] = {
174 "Test Load Multiple instruction" },
176 "Test Store Multiple instruction" },
181 * gcc is not happy if we modify r31 (the frame pointer) behind its back
184 int __attribute__((optimize("-fomit-frame-pointer"))) main(void)
189 while ((func
= all_tests
[i
].func
)) {