Skip to content

Commit 9aec799

Browse files
author
carll
committed
Forgot to add the new files in memcheck/tests/ppc32 and memcheck/tests/ppc32.
They should have been part of the previous commit 15106. -------------------------------------------------------------------- Add support for the lbarx, lharx, stbcx and sthcs instructions. The instructions are part of the ISA 2.06 but were not implemented in all versions of hardware. The four instructions are all supported in ISA 2.07. The instructions were put under the ISA 2.07 category of supported instructions in this patch. The VEX commit for this fix is r3137. The bugzilla for this issue is 346324. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15107 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent e3a6d6f commit 9aec799

10 files changed

+129
-0
lines changed

memcheck/tests/ppc32/power_ISA2_07.c

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <stdio.h>
2+
#include <config.h>
3+
4+
double foo = -1.0;
5+
double FRT1;
6+
double FRT2;
7+
8+
#ifdef HAS_ISA_2_07
9+
10+
/* b0 may be non-zero in lwarx/ldarx Power6 instrs */
11+
void test_reservation()
12+
{
13+
14+
unsigned RT;
15+
unsigned base;
16+
unsigned offset;
17+
unsigned arrB[] = { 0x00112233U, 0x44556677U, 0x8899aabbU, 0xccddeeffU };
18+
int arrH[] __attribute__ ((aligned (2))) = { 0xdeadbeef, 0xbad0beef, 0xbeefdead, 0xbeef0bad };
19+
20+
/* The lbarx and lharx instructions were "phased in" in ISA 2.06. That
21+
* means it they may show up in some implementations but not others. They
22+
* are in all ISA 2.08 implementations.
23+
*/
24+
base = (unsigned) &arrB;
25+
offset = ((unsigned ) &arrB[1]) - base;
26+
__asm__ volatile ("ori 20, %0, 0"::"r" (base));
27+
__asm__ volatile ("ori 21, %0, 0"::"r" (offset));
28+
__asm__ volatile ("lbarx %0, 20, 21, 1":"=r" (RT));
29+
printf("lbarx => 0x%x\n", RT);
30+
31+
base = (unsigned) &arrH;
32+
offset = ((unsigned) &arrH[1]) - base;
33+
__asm__ volatile ("ori 20, %0, 0"::"r" (base));
34+
__asm__ volatile ("ori 21, %0, 0"::"r" (offset));
35+
__asm__ volatile ("lharx %0, 20, 21, 1":"=r" (RT));
36+
printf("lharx => 0x%x\n", RT);
37+
38+
}
39+
#endif
40+
41+
int main(void)
42+
{
43+
#ifdef HAS_ISA_2_07
44+
(void) test_reservation();
45+
#endif
46+
47+
return 0;
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
3+
HEAP SUMMARY:
4+
in use at exit: 0 bytes in 0 blocks
5+
total heap usage: 0 allocs, 0 frees, 0 bytes allocated
6+
7+
For a detailed leak analysis, rerun with: --leak-check=full
8+
9+
For counts of detected and suppressed errors, rerun with: -v
10+
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lbarx => 0x44
2+
lharx => 0xbad0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lbarx => 0x77
2+
lharx => 0xbeef
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
prereq: ../../../tests/check_isa-2_07_cap
2+
prog: power_ISA2_07
3+
vgopts:

memcheck/tests/ppc64/power_ISA2_07.c

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <stdio.h>
2+
#include <config.h>
3+
4+
double foo = -1.0;
5+
double FRT1;
6+
double FRT2;
7+
8+
#ifdef HAS_ISA_2_07
9+
10+
/* b0 may be non-zero in lwarx/ldarx Power6 instrs */
11+
void test_reservation()
12+
{
13+
14+
unsigned long RT;
15+
unsigned long base;
16+
unsigned long offset;
17+
unsigned arrB[] = { 0x00112233U, 0x44556677U, 0x8899aabbU, 0xccddeeffU };
18+
int arrH[] __attribute__ ((aligned (2))) = { 0xdeadbeef, 0xbad0beef, 0xbeefdead, 0xbeef0bad };
19+
20+
/* The lbarx and lharx instructions were "phased in" in ISA 2.06. That
21+
* means it they may show up in some implementations but not others. They
22+
* are in all ISA 2.08 implementations.
23+
*/
24+
base = (unsigned long) &arrB;
25+
offset = ((unsigned long) &arrB[1]) - base;
26+
__asm__ volatile ("ori 20, %0, 0"::"r" (base));
27+
__asm__ volatile ("ori 21, %0, 0"::"r" (offset));
28+
__asm__ volatile ("lbarx %0, 20, 21, 1":"=r" (RT));
29+
printf("lbarx => 0x%lx\n", RT);
30+
31+
base = (unsigned long) &arrH;
32+
offset = ((unsigned long) &arrH[1]) - base;
33+
__asm__ volatile ("ori 20, %0, 0"::"r" (base));
34+
__asm__ volatile ("ori 21, %0, 0"::"r" (offset));
35+
__asm__ volatile ("lharx %0, 20, 21, 1":"=r" (RT));
36+
printf("lharx => 0x%lx\n", RT);
37+
}
38+
#endif
39+
40+
int main(void)
41+
{
42+
#ifdef HAS_ISA_2_07
43+
(void) test_reservation();
44+
#endif
45+
46+
return 0;
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
3+
HEAP SUMMARY:
4+
in use at exit: 0 bytes in 0 blocks
5+
total heap usage: 0 allocs, 0 frees, 0 bytes allocated
6+
7+
For a detailed leak analysis, rerun with: --leak-check=full
8+
9+
For counts of detected and suppressed errors, rerun with: -v
10+
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lbarx => 0x44
2+
lharx => 0xbad0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lbarx => 0x77
2+
lharx => 0xbeef
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
prereq: ../../../tests/check_isa-2_07_cap
2+
prog: power_ISA2_07
3+
vgopts:

0 commit comments

Comments
 (0)