Skip to content

Commit e3a6d6f

Browse files
author
carll
committed
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@15106 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent 4cd1d21 commit e3a6d6f

File tree

7 files changed

+95
-9
lines changed

7 files changed

+95
-9
lines changed

memcheck/tests/ppc32/Makefile.am

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@ dist_noinst_SCRIPTS = filter_stderr
55

66
EXTRA_DIST = $(noinst_SCRIPTS) \
77
power_ISA2_05.stderr.exp power_ISA2_05.stdout.exp power_ISA2_05.vgtest \
8-
power_ISA2_05.stdout.exp_Without_FPPO
8+
power_ISA2_05.stdout.exp_Without_FPPO \
9+
power_ISA2_07.stdout.exp power_ISA2_07.stdout.exp-LE \
10+
power_ISA2_07.stderr.exp power_ISA2_07.vgtest
911

1012
check_PROGRAMS = \
11-
power_ISA2_05
13+
power_ISA2_05 power_ISA2_07
1214

1315
power_ISA2_05_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
1416
-I$(top_srcdir)/include @FLAG_M32@
17+
18+
if HAS_ISA_2_07
19+
BUILD_FLAGS_ISA_2_07 = -mhtm -mcpu=power8
20+
ISA_2_07_FLAG = -DHAS_ISA_2_07
21+
else
22+
BUILD_FLAGS_ISA_2_07 =
23+
ISA_2_07_FLAG =
24+
endif
25+
26+
power_ISA2_07_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
27+
$(ISA_2_07_FLAG) -I$(top_srcdir)/include @FLAG_M32@

memcheck/tests/ppc64/Makefile.am

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@ dist_noinst_SCRIPTS = filter_stderr
55

66
EXTRA_DIST = $(noinst_SCRIPTS) \
77
power_ISA2_05.stderr.exp power_ISA2_05.stdout.exp power_ISA2_05.vgtest \
8-
power_ISA2_05.stdout.exp_Without_FPPO
8+
power_ISA2_05.stdout.exp_Without_FPPO \
9+
power_ISA2_07.stdout.exp power_ISA2_07.stdout.exp-LE \
10+
power_ISA2_07.stderr.exp power_ISA2_07.vgtest
11+
912

1013
check_PROGRAMS = \
11-
power_ISA2_05
14+
power_ISA2_05 power_ISA2_07
1215

1316
power_ISA2_05_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
1417
-I$(top_srcdir)/include @FLAG_M64@
18+
19+
if HAS_ISA_2_07
20+
BUILD_FLAGS_ISA_2_07 = -mhtm -mcpu=power8
21+
ISA_2_07_FLAG = -DHAS_ISA_2_07
22+
else
23+
BUILD_FLAGS_ISA_2_07 =
24+
ISA_2_07_FLAG =
25+
endif
26+
27+
power_ISA2_07_CFLAGS = $(AM_CFLAGS) $(WERROR) -Winline -Wall -Wshadow -g \
28+
$(ISA_2_07_FLAG) -I$(top_srcdir)/include @FLAG_M64@

none/tests/ppc32/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ EXTRA_DIST = \
4040
test_dfp5.stderr.exp test_dfp5.stdout.exp test_dfp5.vgtest \
4141
jm_vec_isa_2_07.stderr.exp jm_vec_isa_2_07.stdout.exp jm_vec_isa_2_07.vgtest \
4242
jm_fp_isa_2_07.stderr.exp jm_fp_isa_2_07.stdout.exp jm_fp_isa_2_07.vgtest \
43-
jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.vgtest \
43+
jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.stdout.exp-LE \
44+
jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.vgtest \
4445
test_isa_2_07_part2.stderr.exp test_isa_2_07_part2.stdout.exp test_isa_2_07_part2.vgtest \
4546
test_tm.stderr.exp test_tm.stdout.exp test_tm.vgtest \
4647
test_touch_tm.stderr.exp test_touch_tm.stdout.exp test_touch_tm.vgtest \

none/tests/ppc32/jm_int_isa_2_07.stdout.exp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ stq 23456789,22446688, 0 => 0000000023456789,0000000022446688)
22

33
lq (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 11335577,23456789)
44

5+
lbarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x000000aa, 0x00000000)
6+
7+
lharx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x0000aacc, 0x00000000)
8+
59
lqarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x11335577, 0x23456789)
610

11+
stbcx. 45236789,44226688, => 8900000000000000,0000000000000001; CR=20000000
12+
13+
sthcx. 45236789,44226688, => 6789000000000000,0000000000000001; CR=20000000
14+
715
stqcx. 45236789,44226688, => 0000000045236789,0000000044226688; CR=20000000
816

9-
All done. Tested 4 different instructions
17+
All done. Tested 8 different instructions

none/tests/ppc64/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ EXTRA_DIST = \
2828
test_dfp5.stderr.exp test_dfp5.stdout.exp test_dfp5.vgtest \
2929
jm_vec_isa_2_07.stderr.exp jm_vec_isa_2_07.stdout.exp jm_vec_isa_2_07.vgtest \
3030
jm_fp_isa_2_07.stderr.exp jm_fp_isa_2_07.stdout.exp jm_fp_isa_2_07.vgtest \
31-
jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.vgtest \
31+
jm_int_isa_2_07.stderr.exp jm_int_isa_2_07.vgtest \
32+
jm_int_isa_2_07.stdout.exp jm_int_isa_2_07.stdout.exp-LE \
3233
test_isa_2_07_part2.stderr.exp test_isa_2_07_part2.stdout.exp test_isa_2_07_part2.vgtest \
3334
test_tm.stderr.exp test_tm.stdout.exp test_tm.vgtest \
3435
test_touch_tm.stderr.exp test_touch_tm.stdout.exp test_touch_tm.vgtest \

none/tests/ppc64/jm_int_isa_2_07.stdout.exp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ stq abcdef0123456789,1133557722446688, 0 => abcdef0123456789,1133557722446688)
22

33
lq (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0xaaccee0011335577, 0xabcdef0123456789)
44

5+
lbarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x00000000000000aa, 0x0000000000000000)
6+
7+
lharx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0x000000000000aacc, 0x0000000000000000)
8+
59
lqarx (0xaaccee0011335577, 0xabcdef0123456789) => (reg_pair = 0xaaccee0011335577, 0xabcdef0123456789)
610

11+
stbcx. abefcd0145236789,1155337744226688 => 8900000000000000,0000000000000001; CR=20000000
12+
13+
sthcx. abefcd0145236789,1155337744226688 => 6789000000000000,0000000000000001; CR=20000000
14+
715
stqcx. abefcd0145236789,1155337744226688 => abefcd0145236789,1155337744226688; CR=20000000
816

9-
All done. Tested 4 different instructions
17+
All done. Tested 8 different instructions

none/tests/ppc64/test_isa_2_07_part1.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,31 @@ static test_t tests_ildq_ops_two_i16[] = {
301301
{ NULL, NULL, },
302302
};
303303

304-
304+
#ifdef HAS_ISA_2_07
305305
Word_t * mem_resv;
306+
static void test_stbcx(void)
307+
{
308+
/* Have to do the lbarx to the memory address to create the reservation
309+
* or the store will not occur.
310+
*/
311+
__asm__ __volatile__ ("lbarx %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
312+
r14 = (HWord_t) 0xABEFCD0145236789ULL;
313+
r15 = (HWord_t) 0x1155337744226688ULL;
314+
__asm__ __volatile__ ("stbcx. %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
315+
}
316+
317+
static void test_sthcx(void)
318+
{
319+
/* Have to do the lharx to the memory address to create the reservation
320+
* or the store will not occur.
321+
*/
322+
__asm__ __volatile__ ("lharx %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
323+
r14 = (HWord_t) 0xABEFCD0145236789ULL;
324+
r15 = (HWord_t) 0x1155337744226688ULL;
325+
__asm__ __volatile__ ("sthcx. %0, %1, %2" : :"r" (r14), "r" (r16),"r" (r17));
326+
}
327+
#endif
328+
306329
static void test_stqcx(void)
307330
{
308331
/* Have to do the lqarx to the memory address to create the reservation
@@ -315,16 +338,34 @@ static void test_stqcx(void)
315338
}
316339

317340
static test_t tests_stq_ops_three[] = {
341+
#ifdef HAS_ISA_2_07
342+
{ &test_stbcx , "stbcx.", },
343+
{ &test_sthcx , "sthcx.", },
344+
#endif
318345
{ &test_stqcx , "stqcx.", },
319346
{ NULL, NULL, },
320347
};
321348

349+
#ifdef HAS_ISA_2_07
350+
static void test_lbarx(void)
351+
{
352+
__asm__ __volatile__ ("lbarx %0, %1, %2, 0" : :"r" (r14), "r" (r16),"r" (r17));
353+
}
354+
static void test_lharx(void)
355+
{
356+
__asm__ __volatile__ ("lharx %0, %1, %2, 0" : :"r" (r14), "r" (r16),"r" (r17));
357+
}
358+
#endif
322359
static void test_lqarx(void)
323360
{
324361
__asm__ __volatile__ ("lqarx %0, %1, %2, 0" : :"r" (r14), "r" (r16),"r" (r17));
325362
}
326363

327364
static test_t tests_ldq_ops_three[] = {
365+
#ifdef HAS_ISA_2_07
366+
{ &test_lbarx , "lbarx", },
367+
{ &test_lharx , "lharx", },
368+
#endif
328369
{ &test_lqarx , "lqarx", },
329370
{ NULL, NULL, },
330371
};

0 commit comments

Comments
 (0)