4db4a6
commit 3950c5d661ee09526cddcf24daf5fc22bc83f70c
4db4a6
Author: Carl Love <cel@us.ibm.com>
4db4a6
Date:   Mon Nov 1 11:18:32 2021 -0500
4db4a6
4db4a6
    Valgrind Add powerpc R=1 tests
4db4a6
    
4db4a6
    Contributed by Will Schmidt <will_schmidt@vnet.ibm.com>
4db4a6
    
4db4a6
    This includes updates and adjustments as suggested by Carl.
4db4a6
    
4db4a6
    Add tests that exercise PCRelative instructions.
4db4a6
    These instructions are encoded with R==1, which indicate that
4db4a6
    the memory accessed by the instruction is at a location
4db4a6
    relative to the currently executing instruction.
4db4a6
    
4db4a6
    These tests are built using -Wl,-text and -Wl,-bss
4db4a6
    options to ensure the location of the target array is at a
4db4a6
    location with a specific offset from the currently
4db4a6
    executing instruction.
4db4a6
    
4db4a6
    The write instructions are aimed at a large buffer in
4db4a6
    the bss section; which is checked for updates at the
4db4a6
    completion of each test.
4db4a6
    
4db4a6
    In order to ensure consistent output across assorted
4db4a6
    systems, the tests have been padded with ori, nop instructions
4db4a6
    and align directives.
4db4a6
    
4db4a6
    Detailed changes:
4db4a6
     * Makefile.am: Add test_isa_3_1_R1_RT and test_isa_3_1_R1_XT tests.
4db4a6
     * isa_3_1_helpers.h: Add identify_instruction_by_func_name() helper function
4db4a6
       to indicate if the test is for R==1.
4db4a6
       Add helpers to initialize and print changes to the pcrelative_write_target
4db4a6
       array.
4db4a6
       Add #define to help pad code with a series of eyecatcher ORI instructions.
4db4a6
         * test_isa_3_1_R1_RT.c: New test.
4db4a6
         * test_isa_3_1_R1_XT.c: New test.
4db4a6
         * test_isa_3_1_R1_XT.stdout.exp: New expected output.
4db4a6
         * test_isa_3_1_R1_XT.stdout.exp: New expected output.
4db4a6
         * test_isa_3_1_R1_RT.stderr.exp: New expected output.
4db4a6
         * test_isa_3_1_R1_RT.stderr.exp: New expected output.
4db4a6
    
4db4a6
         * test_isa_3_1_R1_RT.vgtest: New test handler.
4db4a6
         * test_isa_3_1_R1_XT.vgtest: New test handler.
4db4a6
    
4db4a6
         * test_isa_3_1_common.c: Add indicators (updates_byte,updates_halfword,
4db4a6
           updates_word) indicators to control the output from the R==1 tests.
4db4a6
           Add helper check for "_R1" to indicate if instruction is coded with R==1.
4db4a6
           Add init and print helpers for the pcrelative_write_target array.
4db4a6
4db4a6
diff --git a/none/tests/ppc64/Makefile.am b/none/tests/ppc64/Makefile.am
4db4a6
index b709f3ef4..f8eab9fc0 100644
4db4a6
--- a/none/tests/ppc64/Makefile.am
4db4a6
+++ b/none/tests/ppc64/Makefile.am
4db4a6
@@ -61,6 +61,8 @@ EXTRA_DIST = \
4db4a6
 	test_isa_3_1_VRT.vgtest test_isa_3_1_VRT.stderr.exp test_isa_3_1_VRT.stdout.exp \
4db4a6
 	test_isa_3_1_Misc.vgtest test_isa_3_1_Misc.stderr.exp test_isa_3_1_Misc.stdout.exp \
4db4a6
 	test_isa_3_1_AT.vgtest test_isa_3_1_AT.stderr.exp test_isa_3_1_AT.stdout.exp \
4db4a6
+	test_isa_3_1_R1_RT.vgtest test_isa_3_1_R1_RT.stderr.exp test_isa_3_1_R1_RT.stdout.exp \
4db4a6
+	test_isa_3_1_R1_XT.vgtest test_isa_3_1_R1_XT.stderr.exp test_isa_3_1_R1_XT.stdout.exp \
4db4a6
 	subnormal_test.stderr.exp  subnormal_test.stdout.exp \
4db4a6
 	subnormal_test.vgtest test_darn_inst.stderr.exp \
4db4a6
 	test_darn_inst.stdout.exp test_darn_inst.vgtest \
4db4a6
@@ -68,8 +70,8 @@ EXTRA_DIST = \
4db4a6
 	test_copy_paste.stderr.exp test_copy_paste.stdout.exp \
4db4a6
 	test_copy_paste.vgtest \
4db4a6
 	test_mcrxrx.vgtest test_mcrxrx.stderr.exp test_mcrxrx.stdout.exp \
4db4a6
-	test_lxvx_stxvx.vgtest test_lxvx_stxvx.stderr.exp test_lxvx_stxvx.stdout.exp-p8  test_lxvx_stxvx.stdout.exp-p9
4db4a6
-
4db4a6
+	test_lxvx_stxvx.vgtest test_lxvx_stxvx.stderr.exp \
4db4a6
+	test_lxvx_stxvx.stdout.exp-p8  test_lxvx_stxvx.stdout.exp-p9
4db4a6
 
4db4a6
 check_PROGRAMS = \
4db4a6
 	allexec \
4db4a6
@@ -80,11 +82,12 @@ check_PROGRAMS = \
4db4a6
 	test_isa_3_0 test_mod_instructions \
4db4a6
 	test_isa_3_1_RT test_isa_3_1_XT test_isa_3_1_VRT \
4db4a6
 	test_isa_3_1_Misc test_isa_3_1_AT \
4db4a6
+	test_isa_3_1_R1_RT test_isa_3_1_R1_XT \
4db4a6
 	subnormal_test test_darn_inst test_copy_paste \
4db4a6
 	test_tm test_touch_tm data-cache-instructions \
4db4a6
 	std_reg_imm \
4db4a6
 	twi_tdi tw_td power6_bcmp scv_test \
4db4a6
-	test_mcrxrx  test_lxvx_stxvx
4db4a6
+	test_mcrxrx test_lxvx_stxvx
4db4a6
 
4db4a6
 # lmw, stmw, lswi, lswx, stswi, stswx compile (and run) only on big endian.
4db4a6
 if VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX
4db4a6
@@ -106,6 +109,8 @@ test_isa_3_1_RT_SOURCES = test_isa_3_1_RT.c test_isa_3_1_common.c
4db4a6
 test_isa_3_1_VRT_SOURCES = test_isa_3_1_VRT.c test_isa_3_1_common.c
4db4a6
 test_isa_3_1_Misc_SOURCES = test_isa_3_1_Misc.c test_isa_3_1_common.c
4db4a6
 test_isa_3_1_AT_SOURCES = test_isa_3_1_AT.c test_isa_3_1_common.c
4db4a6
+test_isa_3_1_R1_XT_SOURCES = test_isa_3_1_R1_XT.c test_isa_3_1_common.c
4db4a6
+test_isa_3_1_R1_RT_SOURCES = test_isa_3_1_R1_RT.c test_isa_3_1_common.c
4db4a6
 test_darn_inst_SOURCES = test_darn_inst.c
4db4a6
 
4db4a6
 if HAS_ALTIVEC
4db4a6
@@ -224,6 +229,11 @@ test_isa_3_1_VRT_CFLAGS = $(test_isa_3_1_CFLAGS)
4db4a6
 test_isa_3_1_Misc_CFLAGS = $(test_isa_3_1_CFLAGS)
4db4a6
 test_isa_3_1_AT_CFLAGS = $(test_isa_3_1_CFLAGS)
4db4a6
 
4db4a6
+# The _R1_foo tests exercise pc-relative instructions, so require the bss and text sections
4db4a6
+# exist at known offsets with respect to each other.
4db4a6
+test_isa_3_1_R1_RT_CFLAGS = $(test_isa_3_1_CFLAGS) -Wl,-Tbss,0x20000 -Wl,-Ttext,0x40000
4db4a6
+test_isa_3_1_R1_XT_CFLAGS = $(test_isa_3_1_CFLAGS) -Wl,-Tbss,0x20000 -Wl,-Ttext,0x40000
4db4a6
+
4db4a6
 subnormal_test_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(VSX_FLAG) $(ISA_2_06_FLAG) \
4db4a6
 			@FLAG_M64@ $(ALTIVEC_FLAG) $(BUILD_FLAG_VSX) $(BUILD_FLAGS_ISA_2_06)
4db4a6
 
4db4a6
diff --git a/none/tests/ppc64/isa_3_1_helpers.h b/none/tests/ppc64/isa_3_1_helpers.h
4db4a6
index 338f55526..716a6277b 100644
4db4a6
--- a/none/tests/ppc64/isa_3_1_helpers.h
4db4a6
+++ b/none/tests/ppc64/isa_3_1_helpers.h
4db4a6
@@ -43,6 +43,9 @@ extern void debug_show_current_iteration();
4db4a6
 extern void debug_dump_buffer();
4db4a6
 
4db4a6
 extern void identify_form_components(const char *, const char *);
4db4a6
+extern void identify_instruction_by_func_name(const char *);
4db4a6
+extern void init_pcrelative_write_target();
4db4a6
+extern void print_pcrelative_write_target();
4db4a6
 extern void dump_vsxargs();
4db4a6
 extern void generic_prologue();
4db4a6
 extern void build_args_table();
4db4a6
@@ -58,6 +61,21 @@ extern void initialize_source_registers();
4db4a6
 extern void set_up_iterators();
4db4a6
 extern void initialize_buffer(int);
4db4a6
 
4db4a6
+/* This (TEXT_BSS_DELTA) is the relative distance between those
4db4a6
+   sections as set by the linker options for the R==1 tests. */
4db4a6
+#define TEXT_BSS_DELTA 0x20000
4db4a6
+#define RELOC_BUFFER_SIZE 0x1000
4db4a6
+extern unsigned long long pcrelative_buff_addr(int);
4db4a6
+#define PAD_ORI	\
4db4a6
+	__asm__ __volatile__ ("ori 21,21,21"); \
4db4a6
+	__asm__ __volatile__ ("ori 22,22,22");\
4db4a6
+	__asm__ __volatile__ ("ori 23,23,23");\
4db4a6
+	__asm__ __volatile__ ("ori 24,24,24");\
4db4a6
+	__asm__ __volatile__ ("ori 25,25,25");\
4db4a6
+	__asm__ __volatile__ ("ori 26,26,26");\
4db4a6
+	__asm__ __volatile__ ("ori 27,27,27");\
4db4a6
+	__asm__ __volatile__ ("ori 28,28,28");
4db4a6
+
4db4a6
 extern int verbose;
4db4a6
 #define debug_printf(X) if (verbose>0) printf(X);
4db4a6
 #define debug_show_labels (verbose>0)
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_RT.c b/none/tests/ppc64/test_isa_3_1_R1_RT.c
4db4a6
new file mode 100644
4db4a6
index 000000000..d73b84b10
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_RT.c
4db4a6
@@ -0,0 +1,624 @@
4db4a6
+/*
4db4a6
+ * Valgrind testcase for PowerPC ISA 3.1
4db4a6
+ *
4db4a6
+ * Copyright (C) 2019-2020 Will Schmidt <will_schmidt@vnet.ibm.com>
4db4a6
+ *
4db4a6
+ * 64bit build:
4db4a6
+ *    gcc -Winline -Wall -g -O -mregnames -maltivec -m64
4db4a6
+ */
4db4a6
+
4db4a6
+/*
4db4a6
+ *   This program is free software; you can redistribute it and/or
4db4a6
+ *   modify it under the terms of the GNU General Public License as
4db4a6
+ *   published by the Free Software Foundation; either version 2 of the
4db4a6
+ *   License, or (at your option) any later version.
4db4a6
+ *
4db4a6
+ *   This program is distributed in the hope that it will be useful,
4db4a6
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
4db4a6
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4db4a6
+ *   GNU General Public License for more details.
4db4a6
+ *
4db4a6
+ *   You should have received a copy of the GNU General Public License
4db4a6
+ *   along with this program; if not, write to the Free Software
4db4a6
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4db4a6
+ */
4db4a6
+
4db4a6
+#include <stdio.h>
4db4a6
+#ifdef HAS_ISA_3_1
4db4a6
+#include <stdint.h>
4db4a6
+#include <assert.h>
4db4a6
+#include <stdlib.h>
4db4a6
+#include <string.h>
4db4a6
+#include <unistd.h>
4db4a6
+#include <altivec.h>
4db4a6
+#include <malloc.h>
4db4a6
+
4db4a6
+#include <string.h>
4db4a6
+#include <signal.h>
4db4a6
+#include <setjmp.h>
4db4a6
+
4db4a6
+/* Condition Register fields.
4db4a6
+   These are used to capture the condition register values immediately after
4db4a6
+   the instruction under test is executed. This is done to help prevent other
4db4a6
+   test overhead (switch statements, result compares, etc) from disturbing
4db4a6
+   the test case results.  */
4db4a6
+unsigned long current_cr;
4db4a6
+unsigned long current_fpscr;
4db4a6
+
4db4a6
+struct test_list_t current_test;
4db4a6
+
4db4a6
+#include "isa_3_1_helpers.h"
4db4a6
+
4db4a6
+static void test_plxvp_off0_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plxvp 20, +0(0),1"  );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxvp_off8_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plxvp 20, +8(0),1" );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxvp_off16_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plxvp 20, +16(0),1" );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxvp_off24_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plxvp 20, +24(0),1" );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxvp_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plxvp 20, +32(0),1" );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plbz_off0_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plbz %0, +0(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plbz_off8_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plbz %0, +8(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plbz_off16_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plbz %0, +16(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plbz_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plbz %0, +32(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plbz_off64_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plbz %0, +64(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plhz_off0_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plhz %0, +0(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plhz_off8_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plhz %0, +8(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plhz_off16_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plhz %0, +16(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plhz_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plhz %0, +32(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plhz_off64_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plhz %0, +64(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plha_off0_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plha %0, +0(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plha_off8_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plha %0, +8(0), 1" : "=r" (rt)  );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plha_off16_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plha %0, +16(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plha_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plha %0, +32(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plha_off64_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plha %0, +64(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plwz_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plwz %0, +0(0), 1" : "=r" (rt)  );
4db4a6
+}
4db4a6
+static void test_plwz_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plwz %0, +8(0), 1" : "=r" (rt) );
4db4a6
+}
4db4a6
+static void test_plwz_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plwz %0, +16(0), 1" : "=r" (rt) );
4db4a6
+}
4db4a6
+static void test_plwz_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plwz %0, +32(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plwz_off64_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plwz %0, +64(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plwa_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plwa %0, +0(0), 1" : "=r" (rt)  );
4db4a6
+}
4db4a6
+static void test_plwa_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plwa %0, +8(0), 1" : "=r" (rt)  );
4db4a6
+}
4db4a6
+static void test_plwa_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plwa %0, +16(0), 1" : "=r" (rt) );
4db4a6
+}
4db4a6
+static void test_plwa_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plwa %0, +32(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plwa_off64_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plwa %0, +64(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_pld_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pld %0, +0(0), 1" : "=r" (rt)  );
4db4a6
+}
4db4a6
+static void test_pld_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pld %0, +8(0), 1" : "=r" (rt)  );
4db4a6
+}
4db4a6
+static void test_pld_off16_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("pld %0, +16(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_pld_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("pld %0, +32(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_pld_off64_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("pld %0, +64(0), 1" : "=r" (rt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_pstb_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstb %0, -0x1f400+0(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstb_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstb %0, -0x1f400+8(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstb_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstb %0, -0x1f400+16(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstb_off32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstb %0, -0x1f400+32(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_psth_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("psth %0, -0x1f400+0(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_psth_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("psth %0, -0x1f400+8(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_psth_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("psth %0, -0x1f400+16(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_psth_off32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("psth %0, -0x1f400+32(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstw_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstw %0, -0x1f400+0(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstw_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstw %0, -0x1f400+8(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstw_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstw %0, -0x1f400+16(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstw_off32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstw %0, -0x1f400+32(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstd_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstd %0, -0x1f400+0(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstd_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstd %0, -0x1f400+8(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstd_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstd %0, -0x1f400+16(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+static void test_pstd_off32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstd %0, -0x1f400+32(0), 1" :: "r" (rs) );
4db4a6
+}
4db4a6
+  /* For the paddi tests; although we can get close to a read/write target
4db4a6
+     due to forcing where the .text and .bss sections are placed, there is
4db4a6
+     still enough codegen variability that having a raw value in the exp
4db4a6
+     file will not be determinative for these instructions.
4db4a6
+     Thus, compromise and just ensure that the generated value is an
4db4a6
+     address that lands within the reloc buffer, and use quasi magic
4db4a6
+     eyecatcher values in the return to indicate success.  */
4db4a6
+static void test_paddi_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("paddi %0, 0, 0+0, 1" : "=r" (rt)  );
4db4a6
+  rt = rt - TEXT_BSS_DELTA;
4db4a6
+  if (rt > pcrelative_buff_addr(0) &&
4db4a6
+		  rt < pcrelative_buff_addr(RELOC_BUFFER_SIZE))
4db4a6
+	  rt = 0xffff0000;
4db4a6
+}
4db4a6
+static void test_paddi_12_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("paddi %0, 0, 0+12, 1" : "=r" (rt)  );
4db4a6
+  rt = rt - TEXT_BSS_DELTA;
4db4a6
+  if (rt > pcrelative_buff_addr(0) &&
4db4a6
+		  rt < pcrelative_buff_addr(RELOC_BUFFER_SIZE))
4db4a6
+	  rt = 0xffff0012;
4db4a6
+}
4db4a6
+static void test_paddi_48_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("paddi %0, 0, 0+48, 1" : "=r" (rt)  );
4db4a6
+  rt = rt - TEXT_BSS_DELTA;
4db4a6
+  if (rt > pcrelative_buff_addr(0) &&
4db4a6
+		  rt < pcrelative_buff_addr(RELOC_BUFFER_SIZE))
4db4a6
+	  rt = 0xffff0048;
4db4a6
+}
4db4a6
+static void test_paddi_98_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("paddi %0, 0, 0+98, 1" : "=r" (rt) );
4db4a6
+  rt = rt - TEXT_BSS_DELTA;
4db4a6
+  if (rt > pcrelative_buff_addr(0) &&
4db4a6
+		  rt < pcrelative_buff_addr(RELOC_BUFFER_SIZE))
4db4a6
+	  rt = 0xffff0098;
4db4a6
+}
4db4a6
+static void test_plq_off0_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plq 26, +0(0), 1"  );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plq_off8_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plq 26, +8(0), 1"  );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plq_off16_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plq 26, +16(0), 1"  );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plq_off32_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plq 26, +32(0), 1"  );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plq_off48_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plq 26, +48(0), 1"  );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plq_off64_R1 (void) {
4db4a6
+	PAD_ORI
4db4a6
+  __asm__ __volatile__ ("plq 26, +64(0), 1"  );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_pstq_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstq 24, -0x1f400+0(0), 1"  );
4db4a6
+}
4db4a6
+static void test_pstq_off8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstq 24, -0x1f400+8(0), 1"  );
4db4a6
+}
4db4a6
+static void test_pstq_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstq 24, -0x1f400+16(0), 1"  );
4db4a6
+}
4db4a6
+static void test_pstq_off32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstq 24, -0x1f400+32(0), 1"  );
4db4a6
+}
4db4a6
+static void test_pstq_off64_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstq 24, -0x1f400+64(0), 1"  );
4db4a6
+}
4db4a6
+
4db4a6
+static test_list_t testgroup_generic[] = {
4db4a6
+  { &test_paddi_0_R1, "paddi 0_R1", "RT,RA,SI,R"}, /* bcwp */
4db4a6
+  { &test_paddi_12_R1, "paddi 12_R1", "RT,RA,SI,R"}, /* bcwp */
4db4a6
+  { &test_paddi_48_R1, "paddi 48_R1", "RT,RA,SI,R"}, /* bcwp */
4db4a6
+  { &test_paddi_98_R1, "paddi 98_R1", "RT,RA,SI,R"}, /* bcwp */
4db4a6
+  { &test_plbz_off0_R1, "plbz off0_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plbz_off8_R1, "plbz off8_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plbz_off16_R1, "plbz off16_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plbz_off32_R1, "plbz off32_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plbz_off64_R1, "plbz off64_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pld_off0_R1, "pld off0_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pld_off8_R1, "pld off8_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pld_off16_R1, "pld off16_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pld_off32_R1, "pld off32_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pld_off64_R1, "pld off64_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plha_off0_R1, "plha off0_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plha_off8_R1, "plha off8_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plha_off16_R1, "plha off16_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plha_off32_R1, "plha off32_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plha_off64_R1, "plha off64_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plhz_off0_R1, "plhz off0_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plhz_off8_R1, "plhz off8_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plhz_off16_R1, "plhz off16_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plhz_off32_R1, "plhz off32_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plhz_off64_R1, "plhz off64_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plq_off0_R1, "plq off0_R1", "RTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plq_off8_R1, "plq off8_R1", "RTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plq_off16_R1, "plq off16_R1", "RTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plq_off32_R1, "plq off32_R1", "RTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plq_off48_R1, "plq off48_R1", "RTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plq_off64_R1, "plq off64_R1", "RTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwa_off0_R1, "plwa off0_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwa_off8_R1, "plwa off8_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwa_off16_R1, "plwa off16_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwa_off32_R1, "plwa off32_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwa_off64_R1, "plwa off64_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwz_off0_R1, "plwz off0_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwz_off8_R1, "plwz off8_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwz_off16_R1, "plwz off16_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwz_off32_R1, "plwz off32_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plwz_off64_R1, "plwz off64_R1", "RT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxvp_off0_R1, "plxvp off0_R1", "XTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxvp_off8_R1, "plxvp off8_R1", "XTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxvp_off16_R1, "plxvp off16_R1", "XTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxvp_off24_R1, "plxvp off24_R1", "XTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxvp_off32_R1, "plxvp off32_R1", "XTp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstb_off0_R1, "pstb off0_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstb_off8_R1, "pstb off8_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstb_off16_R1, "pstb off16_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstb_off32_R1, "pstb off32_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstd_off0_R1, "pstd off0_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstd_off8_R1, "pstd off8_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstd_off16_R1, "pstd off16_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstd_off32_R1, "pstd off32_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_psth_off0_R1, "psth off0_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_psth_off8_R1, "psth off8_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_psth_off16_R1, "psth off16_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_psth_off32_R1, "psth off32_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstq_off0_R1, "pstq off0_R1", "RSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstq_off8_R1, "pstq off8_R1", "RSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstq_off16_R1, "pstq off16_R1", "RSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstq_off32_R1, "pstq off32_R1", "RSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstq_off64_R1, "pstq off64_R1", "RSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstw_off0_R1, "pstw off0_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstw_off8_R1, "pstw off8_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstw_off16_R1, "pstw off16_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstw_off32_R1, "pstw off32_R1", "RS,D(RA),R"}, /* bcwp */
4db4a6
+	{ NULL, 	    NULL },
4db4a6
+};
4db4a6
+
4db4a6
+/*  Allow skipping of tests. */
4db4a6
+unsigned long test_count=0xffff;
4db4a6
+unsigned long skip_count=0;
4db4a6
+unsigned long setup_only=0;
4db4a6
+
4db4a6
+/*  Set up a setjmp/longjmp to gently handle our SIGILLs and SIGSEGVs.  */
4db4a6
+static jmp_buf mybuf;
4db4a6
+
4db4a6
+/* This (testfunction_generic) is meant to handle all of the instruction
4db4a6
+   variations.  The helpers set up the register and iterator values
4db4a6
+   as is appropriate for the instruction being tested.  */
4db4a6
+static void testfunction_generic (const char* instruction_name,
4db4a6
+				  test_func_t test_function,
4db4a6
+				  unsigned int ignore_flags,
4db4a6
+				  char * cur_form) {
4db4a6
+
4db4a6
+   identify_form_components (instruction_name , cur_form);
4db4a6
+   debug_show_form (instruction_name, cur_form);
4db4a6
+   set_up_iterators ();
4db4a6
+   debug_show_iter_ranges ();
4db4a6
+   initialize_buffer (0);
4db4a6
+   init_pcrelative_write_target ();
4db4a6
+   debug_dump_buffer ();
4db4a6
+
4db4a6
+   for (vrai = a_start; vrai < a_iters ; vrai+=a_inc) {
4db4a6
+      for (vrbi = b_start; vrbi < b_iters ; vrbi+=b_inc) {
4db4a6
+	 for (vrci = c_start; vrci < c_iters ; vrci+=c_inc) {
4db4a6
+	    for (vrmi = m_start; (vrmi < m_iters) ; vrmi+=m_inc) {
4db4a6
+		CHECK_OVERRIDES
4db4a6
+		debug_show_current_iteration ();
4db4a6
+		// Be sure to initialize the target registers first.
4db4a6
+		initialize_target_registers ();
4db4a6
+		initialize_source_registers ();
4db4a6
+		printf ("%s", instruction_name);
4db4a6
+		print_register_header ();
4db4a6
+		printf( " =>"); fflush (stdout);
4db4a6
+		if (!setup_only) {
4db4a6
+		  if (enable_setjmp) {
4db4a6
+		   if ( setjmp ( mybuf ) ) {
4db4a6
+		     printf("signal tripped. (FIXME)\n");
4db4a6
+		     continue;
4db4a6
+		   }
4db4a6
+		  }
4db4a6
+		  (*test_function) ();
4db4a6
+		}
4db4a6
+		print_register_footer ();
4db4a6
+		print_result_buffer ();
4db4a6
+		print_pcrelative_write_target ();
4db4a6
+		printf ("\n");
4db4a6
+	    }
4db4a6
+	 }
4db4a6
+      }
4db4a6
+   }
4db4a6
+}
4db4a6
+
4db4a6
+void mykillhandler ( int x ) { longjmp (mybuf, 1); }
4db4a6
+void mysegvhandler ( int x ) { longjmp (mybuf, 1); }
4db4a6
+
4db4a6
+static void do_tests ( void )
4db4a6
+{
4db4a6
+   int groupcount;
4db4a6
+   char * cur_form;
4db4a6
+   test_group_t group_function = &testfunction_generic;
4db4a6
+   test_list_t *tests = testgroup_generic;
4db4a6
+
4db4a6
+   struct sigaction kill_action, segv_action;
4db4a6
+   struct sigaction old_kill_action, old_segv_action;
4db4a6
+   if (enable_setjmp) {
4db4a6
+      kill_action.sa_handler = mykillhandler;
4db4a6
+      segv_action.sa_handler = mysegvhandler;
4db4a6
+      sigemptyset ( &kill_action.sa_mask );
4db4a6
+      sigemptyset ( &segv_action.sa_mask );
4db4a6
+      kill_action.sa_flags = SA_NODEFER;
4db4a6
+      segv_action.sa_flags = SA_NODEFER;
4db4a6
+      sigaction ( SIGILL, &kill_action, &old_kill_action);
4db4a6
+      sigaction ( SIGSEGV, &segv_action, &old_segv_action);
4db4a6
+   }
4db4a6
+
4db4a6
+   for (groupcount = 0; tests[groupcount].name != NULL; groupcount++) {
4db4a6
+	cur_form = strdup(tests[groupcount].form);
4db4a6
+	current_test = tests[groupcount];
4db4a6
+	identify_instruction_by_func_name (current_test.name);
4db4a6
+	if (groupcount < skip_count) continue;
4db4a6
+	if (verbose) printf("Test #%d ,", groupcount);
4db4a6
+	if (verbose > 1) printf(" instruction %s (v=%d)", current_test.name, verbose);
4db4a6
+	(*group_function) (current_test.name, current_test.func, 0, cur_form );
4db4a6
+	printf ("\n");
4db4a6
+	if (groupcount >= (skip_count+test_count)) break;
4db4a6
+   }
4db4a6
+   if (debug_show_labels) printf("\n");
4db4a6
+   printf ("All done. Tested %d different instruction groups\n", groupcount);
4db4a6
+}
4db4a6
+
4db4a6
+static void usage (void)
4db4a6
+{
4db4a6
+   fprintf(stderr,
4db4a6
+      "Usage: test_isa_XXX [OPTIONS]\n"
4db4a6
+      "\t-h: display this help and exit\n"
4db4a6
+      "\t-v: increase verbosity\n"
4db4a6
+      "\t-a <foo> : limit number of a-iterations to <foo>\n"
4db4a6
+      "\t-b <foo> : limit number of b-iterations to <foo>\n"
4db4a6
+      "\t-c <foo> : limit number of c-iterations to <foo>\n"
4db4a6
+      "\t-n <foo> : limit to this number of tests.\n"
4db4a6
+      "\t-r <foo>: run only test # <foo> \n"
4db4a6
+      "\t\n"
4db4a6
+      "\t-j :enable setjmp to recover from illegal insns. \n"
4db4a6
+      "\t-m :(dev only?) lock VRM value to zero.\n"
4db4a6
+      "\t-z :(dev only?) lock MC value to zero.\n"
4db4a6
+      "\t-p :(dev only?) disable prefix instructions\n"
4db4a6
+      "\t-s <foo>: skip <foo> tests \n"
4db4a6
+      "\t-c <foo>: stop after running <foo> # of tests \n"
4db4a6
+      "\t-f : Do the test setup but do not actually execute the test instruction. \n"
4db4a6
+   );
4db4a6
+}
4db4a6
+
4db4a6
+int main (int argc, char **argv)
4db4a6
+{
4db4a6
+   int c;
4db4a6
+   while ((c = getopt(argc, argv, "dhjvmpfzs:a:b:c:n:r:")) != -1) {
4db4a6
+      switch (c) {
4db4a6
+	 case 'h':
4db4a6
+	    usage();
4db4a6
+	    return 0;
4db4a6
+
4db4a6
+	 case 'v':
4db4a6
+	    verbose++;
4db4a6
+	    break;
4db4a6
+
4db4a6
+	 /* Options related to limiting the test iterations.  */
4db4a6
+	 case 'a':
4db4a6
+	    a_limit=atoi (optarg);
4db4a6
+	    printf ("limiting a-iters to %ld.\n", a_limit);
4db4a6
+	    break;
4db4a6
+	 case 'b':
4db4a6
+	    b_limit=atoi (optarg);
4db4a6
+	    printf ("limiting b-iters to %ld.\n", b_limit);
4db4a6
+	    break;
4db4a6
+	 case 'c':
4db4a6
+	    c_limit=atoi (optarg);
4db4a6
+	    printf ("limiting c-iters to %ld.\n", c_limit);
4db4a6
+	    break;
4db4a6
+	 case 'n': // run this number of tests.
4db4a6
+	    test_count=atoi (optarg);
4db4a6
+	    printf ("limiting to %ld tests\n", test_count);
4db4a6
+	    break;
4db4a6
+	 case 'r': // run just test #<foo>.
4db4a6
+	    skip_count=atoi (optarg);
4db4a6
+	    test_count=0;
4db4a6
+	    if (verbose) printf("Running test number %ld\n", skip_count);
4db4a6
+	    break;
4db4a6
+	 case 's': // skip this number of tests.
4db4a6
+	    skip_count=atoi (optarg);
4db4a6
+	    printf ("skipping %ld tests\n", skip_count);
4db4a6
+	    break;
4db4a6
+
4db4a6
+	 /* debug options.  */
4db4a6
+	 case 'd':
4db4a6
+	    dump_tables=1;
4db4a6
+	    printf("DEBUG:dump_tables.\n");
4db4a6
+	    break;
4db4a6
+	 case 'f':
4db4a6
+	    setup_only=1;
4db4a6
+	    printf("DEBUG:setup_only.\n");
4db4a6
+	    break;
4db4a6
+	 case 'j':
4db4a6
+	    enable_setjmp=1;
4db4a6
+	    printf ("DEBUG:setjmp enabled.\n");
4db4a6
+	    break;
4db4a6
+	 case 'm':
4db4a6
+	    vrm_override=1;
4db4a6
+	    printf ("DEBUG:vrm override enabled.\n");
4db4a6
+	    break;
4db4a6
+	 case 'p':
4db4a6
+	    prefix_override=1;
4db4a6
+	    printf ("DEBUG:prefix override enabled.\n");
4db4a6
+	    break;
4db4a6
+	 case 'z':
4db4a6
+	    mc_override=1;
4db4a6
+	    printf ("DEBUG:MC override enabled.\n");
4db4a6
+	    break;
4db4a6
+	 default:
4db4a6
+	    usage();
4db4a6
+	    fprintf(stderr, "Unknown argument: '%c'\n", c);
4db4a6
+	   }
4db4a6
+	}
4db4a6
+
4db4a6
+	generic_prologue ();
4db4a6
+	build_vsx_table ();
4db4a6
+	build_args_table ();
4db4a6
+	build_float_vsx_tables ();
4db4a6
+
4db4a6
+	if (dump_tables) {
4db4a6
+	   dump_float_vsx_tables ();
4db4a6
+	   dump_vsxargs ();
4db4a6
+	}
4db4a6
+
4db4a6
+	do_tests ();
4db4a6
+
4db4a6
+	return 0;
4db4a6
+}
4db4a6
+
4db4a6
+#else	   // HAS_ISA_3_1
4db4a6
+int main (int argc, char **argv)
4db4a6
+{
4db4a6
+   printf("NO ISA 3.1 SUPPORT\n");
4db4a6
+   return 0;
4db4a6
+}
4db4a6
+#endif
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_RT.stderr.exp b/none/tests/ppc64/test_isa_3_1_R1_RT.stderr.exp
4db4a6
new file mode 100644
4db4a6
index 000000000..139597f9c
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_RT.stderr.exp
4db4a6
@@ -0,0 +1,2 @@
4db4a6
+
4db4a6
+
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_RT.stdout.exp b/none/tests/ppc64/test_isa_3_1_R1_RT.stdout.exp
4db4a6
new file mode 100644
4db4a6
index 000000000..87594748f
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_RT.stdout.exp
4db4a6
@@ -0,0 +1,138 @@
4db4a6
+paddi 0_R1 =>         ffff0000
4db4a6
+
4db4a6
+paddi 12_R1 =>         ffff0012
4db4a6
+
4db4a6
+paddi 48_R1 =>         ffff0048
4db4a6
+
4db4a6
+paddi 98_R1 =>         ffff0098
4db4a6
+
4db4a6
+plbz off0_R1 =>               1a
4db4a6
+
4db4a6
+plbz off8_R1 =>               1f
4db4a6
+
4db4a6
+plbz off16_R1 =>               1f
4db4a6
+
4db4a6
+plbz off32_R1 =>               1b
4db4a6
+
4db4a6
+plbz off64_R1 =>               1b
4db4a6
+
4db4a6
+pld off0_R1 => e740000004100000
4db4a6
+
4db4a6
+pld off8_R1 =>         4e800020
4db4a6
+
4db4a6
+pld off16_R1 => 6318001862f7001f
4db4a6
+
4db4a6
+pld off32_R1 => 639c001c637b001b
4db4a6
+
4db4a6
+pld off64_R1 => 639c001c637b001b
4db4a6
+
4db4a6
+plha off0_R1 =>               1a
4db4a6
+
4db4a6
+plha off8_R1 =>               1f
4db4a6
+
4db4a6
+plha off16_R1 =>               1f
4db4a6
+
4db4a6
+plha off32_R1 =>               1b
4db4a6
+
4db4a6
+plha off64_R1 =>               1b
4db4a6
+
4db4a6
+plhz off0_R1 =>               1a
4db4a6
+
4db4a6
+plhz off8_R1 =>               1f
4db4a6
+
4db4a6
+plhz off16_R1 =>               1f
4db4a6
+
4db4a6
+plhz off32_R1 =>               1b
4db4a6
+
4db4a6
+plhz off64_R1 =>               1b
4db4a6
+
4db4a6
+plq off0_R1 => e34000000410001a 62d6001662b5001f
4db4a6
+
4db4a6
+plq off8_R1 => 62d6001662b5001f 6318001862f7001f
4db4a6
+
4db4a6
+plq off16_R1 => 6318001862f7001f 635a001a6339001b
4db4a6
+
4db4a6
+plq off32_R1 => 639c001c637b001b         4e80003b
4db4a6
+
4db4a6
+plq off48_R1 =>               1a 62d6001662b5001f
4db4a6
+
4db4a6
+plq off64_R1 => 639c001c637b001b         4e80003b
4db4a6
+
4db4a6
+plwa off0_R1 =>          4100000
4db4a6
+
4db4a6
+plwa off8_R1 =>         4e800020
4db4a6
+
4db4a6
+plwa off16_R1 =>                0
4db4a6
+
4db4a6
+plwa off32_R1 =>         637b001b
4db4a6
+
4db4a6
+plwa off64_R1 =>         637b001b
4db4a6
+
4db4a6
+plwz off0_R1 =>          6100000
4db4a6
+
4db4a6
+plwz off8_R1 =>         4e800020
4db4a6
+
4db4a6
+plwz off16_R1 =>                0
4db4a6
+
4db4a6
+plwz off32_R1 =>         637b001b
4db4a6
+
4db4a6
+plwz off64_R1 =>         637b001b
4db4a6
+
4db4a6
+plxvp off0_R1 => 6318001862f70017 635a001a63390019 ea80000004100000 62d6001662b50015
4db4a6
+
4db4a6
+plxvp off8_R1 => 635a001a63390019 639c001c637b001b 62d6001662b50015 6318001862f70017
4db4a6
+
4db4a6
+plxvp off16_R1 => 639c001c637b001b 000000004e800020 6318001862f70017 635a001a63390019
4db4a6
+
4db4a6
+plxvp off24_R1 => 000000004e800020 0000000000000000 635a001a63390019 639c001c637b001b
4db4a6
+
4db4a6
+plxvp off32_R1 => 0000000000000000 62d6001662b50015 639c001c637b001b 000000004e800020
4db4a6
+
4db4a6
+pstb off0_R1 102030405060708 => 08              
4db4a6
+
4db4a6
+pstb off8_R1 102030405060708 => 08              
4db4a6
+
4db4a6
+pstb off16_R1 102030405060708 => 08              
4db4a6
+
4db4a6
+pstb off32_R1 102030405060708 => 08              
4db4a6
+
4db4a6
+pstd off0_R1 102030405060708 => 0102030405060708 
4db4a6
+
4db4a6
+pstd off8_R1 102030405060708 => 0102030405060708 
4db4a6
+
4db4a6
+pstd off16_R1 102030405060708 => 0102030405060708 
4db4a6
+
4db4a6
+pstd off32_R1 102030405060708 => 0102030405060708 
4db4a6
+
4db4a6
+psth off0_R1 102030405060708 => 0708      
4db4a6
+
4db4a6
+psth off8_R1 102030405060708 => 0708      
4db4a6
+
4db4a6
+psth off16_R1 102030405060708 => 0708      
4db4a6
+
4db4a6
+psth off32_R1 102030405060708 => 0708      
4db4a6
+
4db4a6
+pstq off0_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+pstq off0_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+
4db4a6
+pstq off8_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+pstq off8_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+
4db4a6
+pstq off16_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+pstq off16_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+
4db4a6
+pstq off32_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+pstq off32_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+
4db4a6
+pstq off64_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+pstq off64_R1 102030405060708 a5b4c3d2e1f00918 => 0102030405060708  a5b4c3d2e1f00918 
4db4a6
+
4db4a6
+pstw off0_R1 102030405060708 => 05060708  
4db4a6
+
4db4a6
+pstw off8_R1 102030405060708 => 05060708  
4db4a6
+
4db4a6
+pstw off16_R1 102030405060708 => 05060708  
4db4a6
+
4db4a6
+pstw off32_R1 102030405060708 => 05060708  
4db4a6
+
4db4a6
+All done. Tested 66 different instruction groups
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_RT.vgtest b/none/tests/ppc64/test_isa_3_1_R1_RT.vgtest
4db4a6
new file mode 100644
4db4a6
index 000000000..61d7f65a1
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_RT.vgtest
4db4a6
@@ -0,0 +1,2 @@
4db4a6
+prereq: ../../../tests/check_ppc64_auxv_cap arch_3_1
4db4a6
+prog: test_isa_3_1_R1_RT
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_XT.c b/none/tests/ppc64/test_isa_3_1_R1_XT.c
4db4a6
new file mode 100644
4db4a6
index 000000000..58885b8d3
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_XT.c
4db4a6
@@ -0,0 +1,534 @@
4db4a6
+/*
4db4a6
+ * Valgrind testcase for PowerPC ISA 3.1
4db4a6
+ *
4db4a6
+ * Copyright (C) 2019-2020 Will Schmidt <will_schmidt@vnet.ibm.com>
4db4a6
+ *
4db4a6
+ * 64bit build:
4db4a6
+ *    gcc -Winline -Wall -g -O -mregnames -maltivec -m64
4db4a6
+ */
4db4a6
+
4db4a6
+/*
4db4a6
+ *   This program is free software; you can redistribute it and/or
4db4a6
+ *   modify it under the terms of the GNU General Public License as
4db4a6
+ *   published by the Free Software Foundation; either version 2 of the
4db4a6
+ *   License, or (at your option) any later version.
4db4a6
+ *
4db4a6
+ *   This program is distributed in the hope that it will be useful,
4db4a6
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
4db4a6
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4db4a6
+ *   GNU General Public License for more details.
4db4a6
+ *
4db4a6
+ *   You should have received a copy of the GNU General Public License
4db4a6
+ *   along with this program; if not, write to the Free Software
4db4a6
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4db4a6
+ */
4db4a6
+
4db4a6
+#include <stdio.h>
4db4a6
+#ifdef HAS_ISA_3_1
4db4a6
+#include <stdint.h>
4db4a6
+#include <assert.h>
4db4a6
+#include <stdlib.h>
4db4a6
+#include <string.h>
4db4a6
+#include <unistd.h>
4db4a6
+#include <altivec.h>
4db4a6
+#include <malloc.h>
4db4a6
+
4db4a6
+#include <string.h>
4db4a6
+#include <signal.h>
4db4a6
+#include <setjmp.h>
4db4a6
+
4db4a6
+/* Condition Register fields.
4db4a6
+   These are used to capture the condition register values immediately after
4db4a6
+   the instruction under test is executed. This is done to help prevent other
4db4a6
+   test overhead (switch statements, result compares, etc) from disturbing
4db4a6
+   the test case results.  */
4db4a6
+unsigned long current_cr;
4db4a6
+unsigned long current_fpscr;
4db4a6
+
4db4a6
+struct test_list_t current_test;
4db4a6
+
4db4a6
+#include "isa_3_1_helpers.h"
4db4a6
+static void test_pstxvp_off0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxvp 20, -0x1f400+0(0),1");
4db4a6
+}
4db4a6
+static void test_pstxvp_off16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxvp 20, -0x1f400+16(0),1");
4db4a6
+}
4db4a6
+static void test_pstxvp_off32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxvp 20, -0x1f400+32(0),1");
4db4a6
+}
4db4a6
+static void test_pstxvp_off48_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxvp 20, -0x1f400+48(0),1");
4db4a6
+}
4db4a6
+static void test_plfd_64_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfd 28, +64(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfd_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfd 28, +32(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfd_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfd 28, +16(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfd_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfd 28, +8(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfd_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfd 28, +4(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfd_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfd 28, +0(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfs_64_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfs 28, +64(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfs_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfs 28, +32(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfs_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfs 28, +16(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfs_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfs 28, +8(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfs_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfs 28, +4(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plfs_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plfs 28, +0(0), 1");
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_pstfd_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfd 26, -0x1f400+32(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfd_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfd 26, -0x1f400+16(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfd_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfd 26, -0x1f400+8(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfd_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfd 26, -0x1f400+4(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfd_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfd 26, -0x1f400+0(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfs_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfs 26, -0x1f400+32(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfs_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfs 26, -0x1f400+16(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfs_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfs 26, -0x1f400+8(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfs_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfs 26, -0x1f400+4(0), 1");
4db4a6
+}
4db4a6
+static void test_pstfs_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstfs 26, -0x1f400+0(0), 1");
4db4a6
+}
4db4a6
+static void test_plxsd_64_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxsd %0, +64(0), 1" : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxsd_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ (".align 2 ; plxsd %0, +32(0), 1" : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxsd_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxsd %0, +16(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxsd_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxsd %0, +8(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxsd_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxsd %0, +4(0), 1; pnop;pnop;pnop; "  : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxsd_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxsd %0, +0(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxssp_64_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxssp %0, +64(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxssp_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxssp %0, +32(0), 1; pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxssp_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxssp %0, +16(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxssp_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxssp %0, +8(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxssp_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxssp %0, +4(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxssp_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxssp %0, +0(0), 1; pnop;pnop;pnop; " : "=v" (vrt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+/* Follow the short-range plxv instructions with nop in order to
4db4a6
+   pad out subsequent instructions.  When written there are found
4db4a6
+   to be fluctuations in the instructions to store the result back
4db4a6
+   into the target variable.  (pla,pstxv...).
4db4a6
+   */
4db4a6
+static void test_plxv_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxv %x0, +16(0), 1; pnop;pnop;pnop;" : "=wa" (vec_xt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxv_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxv %x0, +8(0), 1; pnop;pnop;pnop;" : "=wa" (vec_xt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxv_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxv %x0, +4(0), 1; pnop;pnop;pnop;" : "=wa" (vec_xt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_plxv_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("plxv %x0, +0(0), 1; pnop;pnop;pnop; " : "=wa" (vec_xt) );
4db4a6
+	PAD_ORI
4db4a6
+}
4db4a6
+static void test_pstxsd_64_R1 (void) {
4db4a6
+  __asm__ __volatile__ (".align 2 ; pstxsd 22, -0x1f400+64(0), 1" );
4db4a6
+}
4db4a6
+static void test_pstxsd_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ (".align 2 ; pstxsd 22, -0x1f400+32(0), 1" );
4db4a6
+}
4db4a6
+static void test_pstxsd_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ (".align 2 ; pstxsd 22, -0x1f400+16(0), 1" );
4db4a6
+}
4db4a6
+static void test_pstxsd_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ (".align 2 ; pstxsd 22, -0x1f400+8(0), 1" );
4db4a6
+}
4db4a6
+static void test_pstxsd_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ (".align 2 ; pstxsd 22, -0x1f400+4(0), 1"  );
4db4a6
+}
4db4a6
+static void test_pstxsd_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ (".align 2 ; pstxsd 22, -0x1f400+0(0), 1" );
4db4a6
+}
4db4a6
+static void test_pstxssp_64_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxssp 22, -0x1f400+64(0), 1" );
4db4a6
+}
4db4a6
+static void test_pstxssp_32_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxssp 22, -0x1f400+32(0), 1");
4db4a6
+}
4db4a6
+static void test_pstxssp_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxssp 22, -0x1f400+16(0), 1");
4db4a6
+}
4db4a6
+static void test_pstxssp_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxssp 22, -0x1f400+8(0), 1");
4db4a6
+}
4db4a6
+static void test_pstxssp_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxssp 22, -0x1f400+4(0), 1");
4db4a6
+}
4db4a6
+static void test_pstxssp_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxssp 22, -0x1f400+0(0), 1");
4db4a6
+}
4db4a6
+static void test_pstxv_16_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxv %x0, -0x1f400+16(0), 1" :: "wa" (vec_xs));
4db4a6
+}
4db4a6
+static void test_pstxv_8_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxv %x0, -0x1f400+8(0), 1" :: "wa" (vec_xs));
4db4a6
+}
4db4a6
+static void test_pstxv_4_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxv %x0, -0x1f400+4(0), 1" :: "wa" (vec_xs));
4db4a6
+}
4db4a6
+static void test_pstxv_0_R1 (void) {
4db4a6
+  __asm__ __volatile__ ("pstxv %x0, -0x1f400+0(0), 1" :: "wa" (vec_xs));
4db4a6
+}
4db4a6
+
4db4a6
+static test_list_t testgroup_generic[] = {
4db4a6
+  { &test_plfd_0_R1, "plfd 0_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfd_4_R1, "plfd 4_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfd_8_R1, "plfd 8_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfd_16_R1, "plfd 16_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfd_32_R1, "plfd 32_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfd_64_R1, "plfd 64_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfs_0_R1, "plfs 0_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfs_4_R1, "plfs 4_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfs_8_R1, "plfs 8_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfs_16_R1, "plfs 16_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfs_32_R1, "plfs 32_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plfs_64_R1, "plfs 64_R1", "FRT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxsd_0_R1, "plxsd 0_R1", "VRT,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_plxsd_4_R1, "plxsd 4_R1", "VRT,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_plxsd_8_R1, "plxsd 8_R1", "VRT,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_plxsd_16_R1, "plxsd 16_R1", "VRT,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_plxsd_32_R1, "plxsd 32_R1", "VRT,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_plxsd_64_R1, "plxsd 64_R1", "VRT,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_plxssp_0_R1, "plxssp 0_R1", "VRT,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_plxssp_4_R1, "plxssp 4_R1", "VRT,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_plxssp_8_R1, "plxssp 8_R1", "VRT,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_plxssp_16_R1, "plxssp 16_R1", "VRT,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_plxssp_32_R1, "plxssp 32_R1", "VRT,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_plxssp_64_R1, "plxssp 64_R1", "VRT,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_plxv_0_R1, "plxv 0_R1", "XT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxv_4_R1, "plxv 4_R1", "XT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxv_8_R1, "plxv 8_R1", "XT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_plxv_16_R1, "plxv 16_R1", "XT,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstfd_0_R1, "pstfd 0_R1", "FRS,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_pstfd_4_R1, "pstfd 4_R1", "FRS,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_pstfd_8_R1, "pstfd 8_R1", "FRS,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_pstfd_16_R1, "pstfd 16_R1", "FRS,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_pstfd_32_R1, "pstfd 32_R1", "FRS,D(RA),R", 0b00110000}, /* bcwp */
4db4a6
+  { &test_pstfs_0_R1, "pstfs 0_R1", "FRS,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_pstfs_4_R1, "pstfs 4_R1", "FRS,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_pstfs_8_R1, "pstfs 8_R1", "FRS,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_pstfs_16_R1, "pstfs 16_R1", "FRS,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_pstfs_32_R1, "pstfs 32_R1", "FRS,D(RA),R", 0b00001111}, /* bcwp */
4db4a6
+  { &test_pstxsd_0_R1, "pstxsd 0_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxsd_4_R1, "pstxsd 4_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxsd_8_R1, "pstxsd 8_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxsd_16_R1, "pstxsd 16_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxsd_32_R1, "pstxsd 32_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxsd_64_R1, "pstxsd 64_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxssp_0_R1, "pstxssp 0_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxssp_4_R1, "pstxssp 4_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxssp_8_R1, "pstxssp 8_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxssp_16_R1, "pstxssp 16_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxssp_32_R1, "pstxssp 32_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxssp_64_R1, "pstxssp 64_R1", "VRS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxvp_off0_R1, "pstxvp off0_R1", "XSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxvp_off16_R1, "pstxvp off16_R1", "XSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxvp_off32_R1, "pstxvp off32_R1", "XSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxvp_off48_R1, "pstxvp off48_R1", "XSp,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxv_0_R1, "pstxv 0_R1", "XS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxv_4_R1, "pstxv 4_R1", "XS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxv_8_R1, "pstxv 8_R1", "XS,D(RA),R"}, /* bcwp */
4db4a6
+  { &test_pstxv_16_R1, "pstxv 16_R1", "XS,D(RA),R"}, /* bcwp */
4db4a6
+	{ NULL, 	    NULL },
4db4a6
+};
4db4a6
+
4db4a6
+/*  Allow skipping of tests. */
4db4a6
+unsigned long test_count=0xffff;
4db4a6
+unsigned long skip_count=0;
4db4a6
+unsigned long setup_only=0;
4db4a6
+
4db4a6
+/*  Set up a setjmp/longjmp to gently handle our SIGILLs and SIGSEGVs.  */
4db4a6
+static jmp_buf mybuf;
4db4a6
+
4db4a6
+/* This (testfunction_generic) is meant to handle all of the instruction
4db4a6
+   variations.  The helpers set up the register and iterator values
4db4a6
+   as is appropriate for the instruction being tested.  */
4db4a6
+static void testfunction_generic (const char* instruction_name,
4db4a6
+				  test_func_t test_function,
4db4a6
+				  unsigned int ignore_flags,
4db4a6
+				  char * cur_form) {
4db4a6
+
4db4a6
+   identify_form_components (instruction_name , cur_form);
4db4a6
+   debug_show_form (instruction_name, cur_form);
4db4a6
+   set_up_iterators ();
4db4a6
+   debug_show_iter_ranges ();
4db4a6
+   initialize_buffer (0);
4db4a6
+   init_pcrelative_write_target ();
4db4a6
+   debug_dump_buffer ();
4db4a6
+
4db4a6
+   for (vrai = a_start; vrai < a_iters ; vrai+=a_inc) {
4db4a6
+      for (vrbi = b_start; vrbi < b_iters ; vrbi+=b_inc) {
4db4a6
+	 for (vrci = c_start; vrci < c_iters ; vrci+=c_inc) {
4db4a6
+	    for (vrmi = m_start; (vrmi < m_iters) ; vrmi+=m_inc) {
4db4a6
+		CHECK_OVERRIDES
4db4a6
+		debug_show_current_iteration ();
4db4a6
+		// Be sure to initialize the target registers first.
4db4a6
+		initialize_target_registers ();
4db4a6
+		initialize_source_registers ();
4db4a6
+		vec_xa[0]=0x1234;
4db4a6
+		vec_xa[1]=0x4567;
4db4a6
+		printf ("%s", instruction_name);
4db4a6
+		print_register_header ();
4db4a6
+		printf( " =>"); fflush (stdout);
4db4a6
+		if (!setup_only) {
4db4a6
+		  if (enable_setjmp) {
4db4a6
+		   if ( setjmp ( mybuf ) ) {
4db4a6
+		     printf("signal tripped. (FIXME)\n");
4db4a6
+		     continue;
4db4a6
+		   }
4db4a6
+		  }
4db4a6
+		  (*test_function) ();
4db4a6
+		}
4db4a6
+		print_register_footer ();
4db4a6
+		print_result_buffer ();
4db4a6
+		print_pcrelative_write_target ();
4db4a6
+		printf ("\n");
4db4a6
+	    }
4db4a6
+	 }
4db4a6
+      }
4db4a6
+   }
4db4a6
+}
4db4a6
+
4db4a6
+void mykillhandler ( int x ) { longjmp (mybuf, 1); }
4db4a6
+void mysegvhandler ( int x ) { longjmp (mybuf, 1); }
4db4a6
+
4db4a6
+static void do_tests ( void )
4db4a6
+{
4db4a6
+   int groupcount;
4db4a6
+   char * cur_form;
4db4a6
+   test_group_t group_function = &testfunction_generic;
4db4a6
+   test_list_t *tests = testgroup_generic;
4db4a6
+
4db4a6
+   struct sigaction kill_action, segv_action;
4db4a6
+   struct sigaction old_kill_action, old_segv_action;
4db4a6
+   if (enable_setjmp) {
4db4a6
+      kill_action.sa_handler = mykillhandler;
4db4a6
+      segv_action.sa_handler = mysegvhandler;
4db4a6
+      sigemptyset ( &kill_action.sa_mask );
4db4a6
+      sigemptyset ( &segv_action.sa_mask );
4db4a6
+      kill_action.sa_flags = SA_NODEFER;
4db4a6
+      segv_action.sa_flags = SA_NODEFER;
4db4a6
+      sigaction ( SIGILL, &kill_action, &old_kill_action);
4db4a6
+      sigaction ( SIGSEGV, &segv_action, &old_segv_action);
4db4a6
+   }
4db4a6
+
4db4a6
+   for (groupcount = 0; tests[groupcount].name != NULL; groupcount++) {
4db4a6
+	cur_form = strdup(tests[groupcount].form);
4db4a6
+	current_test = tests[groupcount];
4db4a6
+	identify_instruction_by_func_name (current_test.name);
4db4a6
+	if (groupcount < skip_count) continue;
4db4a6
+	if (verbose) printf("Test #%d ,", groupcount);
4db4a6
+	if (verbose > 1) printf(" instruction %s (v=%d)", current_test.name, verbose);
4db4a6
+	(*group_function) (current_test.name, current_test.func, 0, cur_form );
4db4a6
+	printf ("\n");
4db4a6
+	if (groupcount >= (skip_count+test_count)) break;
4db4a6
+   }
4db4a6
+   if (debug_show_labels) printf("\n");
4db4a6
+   printf ("All done. Tested %d different instruction groups\n", groupcount);
4db4a6
+}
4db4a6
+
4db4a6
+static void usage (void)
4db4a6
+{
4db4a6
+   fprintf(stderr,
4db4a6
+      "Usage: test_isa_XXX [OPTIONS]\n"
4db4a6
+      "\t-h: display this help and exit\n"
4db4a6
+      "\t-v: increase verbosity\n"
4db4a6
+      "\t-a <foo> : limit number of a-iterations to <foo>\n"
4db4a6
+      "\t-b <foo> : limit number of b-iterations to <foo>\n"
4db4a6
+      "\t-c <foo> : limit number of c-iterations to <foo>\n"
4db4a6
+      "\t-n <foo> : limit to this number of tests.\n"
4db4a6
+      "\t-r <foo>: run only test # <foo> \n"
4db4a6
+      "\t\n"
4db4a6
+      "\t-j :enable setjmp to recover from illegal insns. \n"
4db4a6
+      "\t-m :(dev only?) lock VRM value to zero.\n"
4db4a6
+      "\t-z :(dev only?) lock MC value to zero.\n"
4db4a6
+      "\t-p :(dev only?) disable prefix instructions\n"
4db4a6
+      "\t-s <foo>: skip <foo> tests \n"
4db4a6
+      "\t-c <foo>: stop after running <foo> # of tests \n"
4db4a6
+      "\t-f : Do the test setup but do not actually execute the test instruction. \n"
4db4a6
+   );
4db4a6
+}
4db4a6
+
4db4a6
+int main (int argc, char **argv)
4db4a6
+{
4db4a6
+   int c;
4db4a6
+   while ((c = getopt(argc, argv, "dhjvmpfzs:a:b:c:n:r:")) != -1) {
4db4a6
+      switch (c) {
4db4a6
+	 case 'h':
4db4a6
+	    usage();
4db4a6
+	    return 0;
4db4a6
+
4db4a6
+	 case 'v':
4db4a6
+	    verbose++;
4db4a6
+	    break;
4db4a6
+
4db4a6
+	 /* Options related to limiting the test iterations.  */
4db4a6
+	 case 'a':
4db4a6
+	    a_limit=atoi (optarg);
4db4a6
+	    printf ("limiting a-iters to %ld.\n", a_limit);
4db4a6
+	    break;
4db4a6
+	 case 'b':
4db4a6
+	    b_limit=atoi (optarg);
4db4a6
+	    printf ("limiting b-iters to %ld.\n", b_limit);
4db4a6
+	    break;
4db4a6
+	 case 'c':
4db4a6
+	    c_limit=atoi (optarg);
4db4a6
+	    printf ("limiting c-iters to %ld.\n", c_limit);
4db4a6
+	    break;
4db4a6
+	 case 'n': // run this number of tests.
4db4a6
+	    test_count=atoi (optarg);
4db4a6
+	    printf ("limiting to %ld tests\n", test_count);
4db4a6
+	    break;
4db4a6
+	 case 'r': // run just test #<foo>.
4db4a6
+	    skip_count=atoi (optarg);
4db4a6
+	    test_count=0;
4db4a6
+	    if (verbose) printf("Running test number %ld\n", skip_count);
4db4a6
+	    break;
4db4a6
+	 case 's': // skip this number of tests.
4db4a6
+	    skip_count=atoi (optarg);
4db4a6
+	    printf ("skipping %ld tests\n", skip_count);
4db4a6
+	    break;
4db4a6
+
4db4a6
+	 /* debug options.  */
4db4a6
+	 case 'd':
4db4a6
+	    dump_tables=1;
4db4a6
+	    printf("DEBUG:dump_tables.\n");
4db4a6
+	    break;
4db4a6
+	 case 'f':
4db4a6
+	    setup_only=1;
4db4a6
+	    printf("DEBUG:setup_only.\n");
4db4a6
+	    break;
4db4a6
+	 case 'j':
4db4a6
+	    enable_setjmp=1;
4db4a6
+	    printf ("DEBUG:setjmp enabled.\n");
4db4a6
+	    break;
4db4a6
+	 case 'm':
4db4a6
+	    vrm_override=1;
4db4a6
+	    printf ("DEBUG:vrm override enabled.\n");
4db4a6
+	    break;
4db4a6
+	 case 'p':
4db4a6
+	    prefix_override=1;
4db4a6
+	    printf ("DEBUG:prefix override enabled.\n");
4db4a6
+	    break;
4db4a6
+	 case 'z':
4db4a6
+	    mc_override=1;
4db4a6
+	    printf ("DEBUG:MC override enabled.\n");
4db4a6
+	    break;
4db4a6
+	 default:
4db4a6
+	    usage();
4db4a6
+	    fprintf(stderr, "Unknown argument: '%c'\n", c);
4db4a6
+	   }
4db4a6
+	}
4db4a6
+
4db4a6
+	generic_prologue ();
4db4a6
+	build_vsx_table ();
4db4a6
+	build_args_table ();
4db4a6
+	build_float_vsx_tables ();
4db4a6
+
4db4a6
+	if (dump_tables) {
4db4a6
+	   dump_float_vsx_tables ();
4db4a6
+	   dump_vsxargs ();
4db4a6
+	}
4db4a6
+
4db4a6
+	do_tests ();
4db4a6
+
4db4a6
+	return 0;
4db4a6
+}
4db4a6
+
4db4a6
+#else	   // HAS_ISA_3_1
4db4a6
+int main (int argc, char **argv)
4db4a6
+{
4db4a6
+   printf("NO ISA 3.1 SUPPORT\n");
4db4a6
+   return 0;
4db4a6
+}
4db4a6
+#endif
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_XT.stderr.exp b/none/tests/ppc64/test_isa_3_1_R1_XT.stderr.exp
4db4a6
new file mode 100644
4db4a6
index 000000000..139597f9c
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_XT.stderr.exp
4db4a6
@@ -0,0 +1,2 @@
4db4a6
+
4db4a6
+
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_XT.stdout.exp b/none/tests/ppc64/test_isa_3_1_R1_XT.stdout.exp
4db4a6
new file mode 100644
4db4a6
index 000000000..48d591f4d
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_XT.stdout.exp
4db4a6
@@ -0,0 +1,127 @@
4db4a6
+plfd 0_R1 =>_ -4.903986e+55 _  cb80000006100000, 0 
4db4a6
+
4db4a6
+plfd 4_R1 =>_ 3.095878e+167 _  62b50015cb800004, 0 
4db4a6
+
4db4a6
+plfd 8_R1 =>_ 1.297320e+168 _  62d6001662b50015, 0 
4db4a6
+
4db4a6
+plfd 16_R1 =>_ 2.264413e+169 _  6318001862f70017, 0 
4db4a6
+
4db4a6
+plfd 32_R1 =>_ 6.763045e+171 _  639c001c637b001b, 0 
4db4a6
+
4db4a6
+plfd 64_R1 =>_ 6.763045e+171 _  639c001c637b001b, 0 
4db4a6
+
4db4a6
+plfs 0_R1 =>_ 2.708339e-35 _  38c2000000000000, 0 
4db4a6
+
4db4a6
+plfs 4_R1 =>_ -2.560001e+02 _  c070000080000000, 0 
4db4a6
+
4db4a6
+plfs 8_R1 =>_ 1.669433e+21 _  4456a002a0000000, 0 
4db4a6
+
4db4a6
+plfs 16_R1 =>_ 2.278176e+21 _  445ee002e0000000, 0 
4db4a6
+
4db4a6
+plfs 32_R1 =>_ 4.630140e+21 _  446f600360000000, 0 
4db4a6
+
4db4a6
+plfs 64_R1 =>_ 4.630140e+21 _  446f600360000000, 0 
4db4a6
+
4db4a6
+plxsd 0_R1 => a800000004100000,0000000000000000 -5.07588375e-116            +Zero
4db4a6
+
4db4a6
+plxsd 4_R1 =>  7000000a8000004,0000000000000000  5.77662562e-275            +Zero
4db4a6
+
4db4a6
+plxsd 8_R1 =>  700000060000000,0000000000000000  5.77662407e-275            +Zero
4db4a6
+
4db4a6
+plxsd 16_R1 =>          7000000,0000000000000000             +Den            +Zero
4db4a6
+
4db4a6
+plxsd 32_R1 => 6339001963180018,0000000000000000  9.43505226e+169            +Zero
4db4a6
+
4db4a6
+plxsd 64_R1 => 6339001963180018,0000000000000000  9.43505226e+169            +Zero
4db4a6
+
4db4a6
+plxssp 0_R1 => 3882000000000000,0000000000000000     6.19888e-05           +Zero           +Zero           +Zero
4db4a6
+
4db4a6
+plxssp 4_R1 => bd80000080000000,0000000000000000    -6.25000e-02           -Zero           +Zero           +Zero
4db4a6
+
4db4a6
+plxssp 8_R1 => 38e0000000000000,0000000000000000     1.06812e-04           +Zero           +Zero           +Zero
4db4a6
+
4db4a6
+plxssp 16_R1 => 38e0000000000000,0000000000000000     1.06812e-04           +Zero           +Zero           +Zero
4db4a6
+
4db4a6
+plxssp 32_R1 => 445ac002c0000000,0000000000000000     8.75000e+02    -2.00000e+00           +Zero           +Zero
4db4a6
+
4db4a6
+plxssp 64_R1 => 446b400340000000,0000000000000000     9.41000e+02     2.00000e+00           +Zero           +Zero
4db4a6
+
4db4a6
+plxv 0_R1 => c800000004100000          7000000
4db4a6
+
4db4a6
+plxv 4_R1 =>  7000000c8000004  700000000000000
4db4a6
+
4db4a6
+plxv 8_R1 =>          7000000          7000000
4db4a6
+
4db4a6
+plxv 16_R1 =>          7000000          7000000
4db4a6
+
4db4a6
+pstfd 0_R1 43dfe000003fe000 43eff000000ff000 => e000003fe00043df
4db4a6
+pstfd 0_R1 43eff000000ff000 43efefffffcff000 => f000000ff00043ef
4db4a6
+
4db4a6
+pstfd 4_R1 43dfe000003fe000 43eff000000ff000 =>     e000003f e00043df    
4db4a6
+pstfd 4_R1 43eff000000ff000 43efefffffcff000 =>     f000000f f00043ef    
4db4a6
+
4db4a6
+pstfd 8_R1 43dfe000003fe000 43eff000000ff000 => e000003fe00043df
4db4a6
+pstfd 8_R1 43eff000000ff000 43efefffffcff000 => f000000ff00043ef
4db4a6
+
4db4a6
+pstfd 16_R1 43dfe000003fe000 43eff000000ff000 => e000003fe00043df
4db4a6
+pstfd 16_R1 43eff000000ff000 43efefffffcff000 => f000000ff00043ef
4db4a6
+
4db4a6
+pstfd 32_R1 43dfe000003fe000 43eff000000ff000 => e000003fe00043df
4db4a6
+pstfd 32_R1 43eff000000ff000 43efefffffcff000 => f000000ff00043ef
4db4a6
+
4db4a6
+pstfs 0_R1 000000005eff0000 000000005f7f8000 => 00005eff    
4db4a6
+pstfs 0_R1 000000005f7f8000 000000005f7f8000 => 80005f7f    
4db4a6
+
4db4a6
+pstfs 4_R1 000000005eff0000 000000005f7f8000 =>     00005eff
4db4a6
+pstfs 4_R1 000000005f7f8000 000000005f7f8000 =>     80005f7f
4db4a6
+
4db4a6
+pstfs 8_R1 000000005eff0000 000000005f7f8000 => 00005eff    
4db4a6
+pstfs 8_R1 000000005f7f8000 000000005f7f8000 => 80005f7f    
4db4a6
+
4db4a6
+pstfs 16_R1 000000005eff0000 000000005f7f8000 => 00005eff    
4db4a6
+pstfs 16_R1 000000005f7f8000 000000005f7f8000 => 80005f7f    
4db4a6
+
4db4a6
+pstfs 32_R1 000000005eff0000 000000005f7f8000 => 00005eff    
4db4a6
+pstfs 32_R1 000000005f7f8000 000000005f7f8000 => 80005f7f    
4db4a6
+
4db4a6
+pstxsd 0_R1 => 0000000000000000
4db4a6
+
4db4a6
+pstxsd 4_R1 =>     00000000 00000000    
4db4a6
+
4db4a6
+pstxsd 8_R1 => 0000000000000000
4db4a6
+
4db4a6
+pstxsd 16_R1 => 0000000000000000
4db4a6
+
4db4a6
+pstxsd 32_R1 => 0000000000000000
4db4a6
+
4db4a6
+pstxsd 64_R1 => 0000000000000000
4db4a6
+
4db4a6
+pstxssp 0_R1 => 00000000    
4db4a6
+
4db4a6
+pstxssp 4_R1 =>     00000000
4db4a6
+
4db4a6
+pstxssp 8_R1 => 00000000    
4db4a6
+
4db4a6
+pstxssp 16_R1 => 00000000    
4db4a6
+
4db4a6
+pstxssp 32_R1 => 00000000    
4db4a6
+
4db4a6
+pstxssp 64_R1 => 00000000    
4db4a6
+
4db4a6
+pstxvp off0_R1 0180055e0180077e 0080000e8080000e ff7ffffe7f7ffffe ff8000007f800000 => fffe7f7ffffeff7f 00007f800000ff80 077e0180055e0180 000e8080000e0080
4db4a6
+
4db4a6
+pstxvp off16_R1 0180055e0180077e 0080000e8080000e ff7ffffe7f7ffffe ff8000007f800000 => fffe7f7ffffeff7f 00007f800000ff80 077e0180055e0180 000e8080000e0080
4db4a6
+
4db4a6
+pstxvp off32_R1 0180055e0180077e 0080000e8080000e ff7ffffe7f7ffffe ff8000007f800000 => fffe7f7ffffeff7f 00007f800000ff80 077e0180055e0180 000e8080000e0080
4db4a6
+
4db4a6
+pstxvp off48_R1 0180055e0180077e 0080000e8080000e ff7ffffe7f7ffffe ff8000007f800000 => fffe7f7ffffeff7f 00007f800000ff80 077e0180055e0180 000e8080000e0080
4db4a6
+
4db4a6
+pstxv 0_R1 ff7ffffe7f7ffffe,ff8000007f800000 => fffe7f7ffffeff7f 00007f800000ff80
4db4a6
+
4db4a6
+pstxv 4_R1 ff7ffffe7f7ffffe,ff8000007f800000 => fffe7f7ffffeff7f 00007f800000ff80
4db4a6
+
4db4a6
+pstxv 8_R1 ff7ffffe7f7ffffe,ff8000007f800000 => fffe7f7ffffeff7f 00007f800000ff80
4db4a6
+
4db4a6
+pstxv 16_R1 ff7ffffe7f7ffffe,ff8000007f800000 =>     fffe7f7f fffeff7f00007f80 0000ff80    
4db4a6
+
4db4a6
+All done. Tested 58 different instruction groups
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_R1_XT.vgtest b/none/tests/ppc64/test_isa_3_1_R1_XT.vgtest
4db4a6
new file mode 100644
4db4a6
index 000000000..7331aafad
4db4a6
--- /dev/null
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_R1_XT.vgtest
4db4a6
@@ -0,0 +1,2 @@
4db4a6
+prereq: ../../../tests/check_ppc64_auxv_cap arch_3_1
4db4a6
+prog: test_isa_3_1_R1_XT
4db4a6
diff --git a/none/tests/ppc64/test_isa_3_1_common.c b/none/tests/ppc64/test_isa_3_1_common.c
4db4a6
index 7c3dc6f00..b3320277b 100644
4db4a6
--- a/none/tests/ppc64/test_isa_3_1_common.c
4db4a6
+++ b/none/tests/ppc64/test_isa_3_1_common.c
4db4a6
@@ -134,11 +134,13 @@ bool uses_acc_vsrs;
4db4a6
 bool uses_pmsk;
4db4a6
 bool uses_buffer;  // Buffer related.
4db4a6
 bool uses_load_buffer, uses_store_buffer, uses_any_buffer;
4db4a6
+bool updates_byte, updates_halfword, updates_word; // output helpers.
4db4a6
 bool uses_quad;
4db4a6
 unsigned long output_mask;  // Output field special handling.
4db4a6
 bool instruction_is_sp, instruction_is_sp_estimate;
4db4a6
 bool instruction_is_dp, instruction_is_dp_estimate;
4db4a6
 bool instruction_is_b16;
4db4a6
+bool instruction_is_relative;
4db4a6
 
4db4a6
 unsigned long long min (unsigned long long a, unsigned long long b) {
4db4a6
    if ( a < b )
4db4a6
@@ -236,6 +238,18 @@ void identify_form_components (const char *instruction_name,
4db4a6
       (strncmp (instruction_name, "pmst", 4) == 0) ||
4db4a6
       (strncmp (instruction_name, "pst", 3) == 0) ||
4db4a6
       (strncmp (instruction_name, "st", 2) == 0));
4db4a6
+   updates_byte = (
4db4a6
+      (strncmp (instruction_name, "pstb", 4) == 0) );
4db4a6
+   updates_halfword = (
4db4a6
+      (strncmp (instruction_name, "psth", 4) == 0) ||
4db4a6
+       (strncmp (instruction_name, "pstfs", 4) == 0) ||
4db4a6
+       (strncmp (instruction_name, "pstxsd", 4) == 0) ||
4db4a6
+       (strncmp (instruction_name, "pstxssp", 4) == 0) ||
4db4a6
+       (strncmp (instruction_name, "pstxv", 4) == 0) ||
4db4a6
+       (strncmp (instruction_name, "psfs", 4) == 0) );
4db4a6
+   updates_word = (
4db4a6
+      (strncmp (instruction_name, "pstw", 4) == 0) );
4db4a6
+
4db4a6
    uses_any_buffer = (strstr (cur_form, "(RA)") != NULL);
4db4a6
    uses_buffer = uses_any_buffer||uses_load_buffer||uses_store_buffer;
4db4a6
 
4db4a6
@@ -268,6 +282,15 @@ void identify_form_components (const char *instruction_name,
4db4a6
    instruction_is_b16 =         ( current_test.mask & B16_MASK        );
4db4a6
 }
4db4a6
 
4db4a6
+/* Parse the provided function name to set assorted values.
4db4a6
+   In particular, set an indicator when the instruction test has
4db4a6
+   indicated it will run with R==1 that indicates it is a PC-relative
4db4a6
+   instruction.  Those tests should all have "_R1" as part of
4db4a6
+   the function name.  */
4db4a6
+void identify_instruction_by_func_name(const char * function_name) {
4db4a6
+   instruction_is_relative = ( (strstr (function_name, "R1") != NULL));
4db4a6
+}
4db4a6
+
4db4a6
 void display_form_components (char * cur_form) {
4db4a6
    printf (" %s\n", cur_form);
4db4a6
    printf ("Instruction form elements: ");
4db4a6
@@ -288,7 +311,7 @@ void display_form_components (char * cur_form) {
4db4a6
    if (has_frbp) printf ("frbp ");
4db4a6
    if (has_frs)  printf ("frs ");
4db4a6
    if (has_frsp) printf ("frsp ");
4db4a6
-   if (has_frt)  printf ("frt ");
4db4a6
+   if (has_frt)  printf ("frt%s ",(instruction_is_relative)?"-raw":"");
4db4a6
    if (has_frtp) printf ("frtp ");
4db4a6
    if (has_xa)   printf ("xa ");
4db4a6
    if (has_xap)  printf ("xap ");
4db4a6
@@ -298,6 +321,7 @@ void display_form_components (char * cur_form) {
4db4a6
    if (has_xsp)  printf ("xsp ");
4db4a6
    if (has_xt)   printf ("xt ");
4db4a6
    if (has_xtp)  printf ("xtp ");
4db4a6
+   if (instruction_is_relative)  printf ("R==1 ");
4db4a6
    if (uses_acc_src) printf ("AS ");
4db4a6
    if (uses_acc_dest) printf ("AT ");
4db4a6
    printf ("\n");
4db4a6
@@ -991,6 +1015,107 @@ if (debug_show_values) printf (" buffer:");
4db4a6
   }
4db4a6
 }
4db4a6
 
4db4a6
+/* **** Reloc Buffer **************************************** */
4db4a6
+/* Create a large buffer to be the destination for pc-relative
4db4a6
+ * writes.  This test is built with linker hints in order
4db4a6
+ * to ensure our buffer, stored in the .bss section, is at a
4db4a6
+ * mostly known offset from the instructions being exercised,
4db4a6
+ * so a hardcoded offset from the PC (pc-relative) will be
4db4a6
+ * on-target.
4db4a6
+ * If there are significant reworks to the code, the bss or
4db4a6
+ * text sections, or the offsets used may need to change.
4db4a6
+ *
4db4a6
+ * The linker hints are specifically -Tbss and -Ttext.
4db4a6
+ * gcc foo.c test_isa_3_1_common.c -I../../../   -Wl,-Tbss 0x20000 -Wl,-Ttext 0x40000
4db4a6
+ */
4db4a6
+ /* RELOC_BUFFER_SIZE is defined to 0x1000 in isa_3_1_helpers.h  */
4db4a6
+#define RELOC_BUFFER_PATTERN 0x0001000100010001
4db4a6
+volatile unsigned long long pcrelative_write_target[RELOC_BUFFER_SIZE];
4db4a6
+
4db4a6
+/* Initialize the buffer to known values. */
4db4a6
+void init_pcrelative_write_target() {
4db4a6
+       int i;
4db4a6
+       for (i=0;i
4db4a6
+               pcrelative_write_target[i]=i*RELOC_BUFFER_PATTERN;
4db4a6
+}
4db4a6
+
4db4a6
+/* Review the pcrelative_write_target buffer; and print any
4db4a6
+   elements that vary from the initialized value.
4db4a6
+   Exclude portions of the output as appropriate if the current test
4db4a6
+   is marked for byte,halfword,word.  */
4db4a6
+void print_pcrelative_write_target() {
4db4a6
+  int i,z,rshift;
4db4a6
+  unsigned long long curr_value;
4db4a6
+  unsigned long long ref_value;
4db4a6
+  unsigned long long curr_token,init_token;
4db4a6
+  for (i=0;i
4db4a6
+    ref_value=i*RELOC_BUFFER_PATTERN;
4db4a6
+    curr_value = pcrelative_write_target[i];
4db4a6
+    if (ref_value != curr_value) {
4db4a6
+      printf(" ");
4db4a6
+      if (verbose)
4db4a6
+	printf("delta found: %d %llx -> %llx\n",i,ref_value,curr_value);
4db4a6
+      if (updates_byte) {
4db4a6
+	for (z=0;z<8;z++) {
4db4a6
+	  rshift=z*8;
4db4a6
+	  if (verbose) printf("z:%d ",z);
4db4a6
+	  init_token = (ref_value>>rshift) & 0xff;
4db4a6
+	  curr_token = (curr_value>>rshift) & 0xff;
4db4a6
+	  if (verbose)
4db4a6
+	    printf("wms byte:: %llx -> %llx \n",init_token,curr_token);
4db4a6
+	  if (init_token == curr_token && (updates_byte||updates_halfword||updates_word) ) {
4db4a6
+	     printf("%2s","  ");
4db4a6
+	  } else {
4db4a6
+	    printf("%02llx",curr_token);
4db4a6
+	  }
4db4a6
+        }
4db4a6
+      }
4db4a6
+      else if (updates_halfword) {
4db4a6
+	for (z=0;z<4;z++) {
4db4a6
+	  rshift=z*16;
4db4a6
+	  if (verbose) printf("z:%d ",z);
4db4a6
+	  init_token = (ref_value>>rshift) & 0xffff;
4db4a6
+	  curr_token = (curr_value>>rshift) & 0xffff;
4db4a6
+	  if (verbose)
4db4a6
+	    printf("wms half:: %llx -> %llx \n",init_token,curr_token);
4db4a6
+	  if (init_token == curr_token) {
4db4a6
+	     printf("%2s","  ");
4db4a6
+	  } else {
4db4a6
+	    printf("%04llx",curr_token);
4db4a6
+	  }
4db4a6
+        }
4db4a6
+      }
4db4a6
+      else if (updates_word) {
4db4a6
+	for (z=0;z<2;z++) {
4db4a6
+	  rshift=z*32;
4db4a6
+	  if (verbose) printf("z:%d ",z);
4db4a6
+	  init_token = (ref_value>>rshift) & 0xffffffff;
4db4a6
+	  curr_token = (curr_value>>rshift) & 0xffffffff;
4db4a6
+	  if (verbose)
4db4a6
+	    printf("wms word:: %llx -> %llx \n",init_token,curr_token);
4db4a6
+	  if (init_token == curr_token ) {
4db4a6
+	     printf("%2s","  ");
4db4a6
+	  } else {
4db4a6
+	    printf("%08llx",curr_token);
4db4a6
+	  }
4db4a6
+        }
4db4a6
+      }
4db4a6
+      else {
4db4a6
+	printf("%016llx ",curr_value);
4db4a6
+      }
4db4a6
+    }
4db4a6
+  }
4db4a6
+}
4db4a6
+
4db4a6
+/* Helper that returns the address of the pcrelative_write_target buffer.
4db4a6
+   Due to variances in where the sections land in memory, this value is
4db4a6
+   used to normalize the results.  (see paddi tests for usage).   */
4db4a6
+unsigned long long pcrelative_buff_addr(int x) {
4db4a6
+   /* Return the base address of the array.  The base address will be
4db4a6
+      a function of the code load address.  */
4db4a6
+   return (unsigned long long) &pcrelative_write_target[x];
4db4a6
+}
4db4a6
+
4db4a6
 void print_undefined () {
4db4a6
    if (debug_show_values)
4db4a6
       printf (" [Undef]");
4db4a6
@@ -1339,7 +1464,7 @@ void print_frt () {
4db4a6
       /* If the result is a dfp128 value, the dfp128 value is
4db4a6
          contained in the frt, frtp values which are split across
4db4a6
          a pair of VSRs.  */
4db4a6
-      if (uses_dfp128_output) {
4db4a6
+      if (!instruction_is_relative && uses_dfp128_output) {
4db4a6
 	 if (verbose) print_vsr (28);
4db4a6
 	 if (verbose) print_vsr (29);
4db4a6
 	 value1 = get_vsrhd_vs28 ();
4db4a6
@@ -1347,7 +1472,12 @@ void print_frt () {
4db4a6
 	 dissect_dfp128_float (value1, value3);
4db4a6
       } else {
4db4a6
 	 if (debug_show_raw_values) generic_print_float_as_hex (frt);
4db4a6
-	 printf (" %e", frt);
4db4a6
+	 if (instruction_is_relative) {
4db4a6
+	    printf ("_ %e _ ", frt);
4db4a6
+	    print_vsr (28);
4db4a6
+	 } else {
4db4a6
+		printf (" %e", frt);
4db4a6
+	  }
4db4a6
 	 if (has_frtp) {
4db4a6
 	    if (debug_show_raw_values) generic_print_float_as_hex (frtp);
4db4a6
 	    printf (" %e", frtp);
4db4a6
@@ -1652,7 +1782,15 @@ void print_all() {
4db4a6
 void print_register_header () {
4db4a6
   post_test = 0;
4db4a6
   if (debug_show_all_regs) print_all();
4db4a6
-  if (has_ra) print_ra ();
4db4a6
+
4db4a6
+  if (has_ra) {
4db4a6
+	  /* Suppress the print of RA if the instruction has
4db4a6
+	     R==1, since the ra value must be zero for the
4db4a6
+	     instruction to be valid.  */
4db4a6
+	  if (!instruction_is_relative)
4db4a6
+		 print_ra();
4db4a6
+  }
4db4a6
+
4db4a6
   if (has_rb) print_rb ();
4db4a6
   if (has_rc) print_rc ();
4db4a6
   if (has_rs) print_rs();
4db4a6
@@ -1894,6 +2032,11 @@ void set_up_iterators () {
4db4a6
    } else {
4db4a6
 	   a_start=0; b_start=0; c_start=0; m_start=0;
4db4a6
    }
4db4a6
+   /* Special casing for R==1 tests. */
4db4a6
+   if (instruction_is_relative) {
4db4a6
+	  a_iters = 1;
4db4a6
+	  m_start=3; m_iters=4;
4db4a6
+   }
4db4a6
    if ((has_vra+has_vrb+has_vrc+has_vrm+has_xa+has_xb+uses_MC > 2) &&
4db4a6
        (!debug_enable_all_iters)) {
4db4a6
       /* Instruction tests using multiple fields will generate a lot of
4db4a6
@@ -2196,15 +2339,12 @@ void initialize_source_registers () {
4db4a6
 	  vrb[0] = vsxargs[ (vrbi  ) % isr_modulo];
4db4a6
 	  vrb[1] = vsxargs[ (vrbi+1) % isr_modulo];
4db4a6
    }
4db4a6
- 
4db4a6
-  if (has_xa) { 
4db4a6
-    vec_xa[0] = vsxargs[ (vrai  ) % isr_modulo];
4db4a6
-    vec_xa[1] = vsxargs[ (vrai+1) % isr_modulo];
4db4a6
-  }
4db4a6
-  if (has_xb) {
4db4a6
-    vec_xb[0] = vsxargs[ (vrbi  ) % isr_modulo];
4db4a6
-    vec_xb[1] = vsxargs[ (vrbi+1) % isr_modulo];
4db4a6
-  }
4db4a6
+
4db4a6
+   if (instruction_is_relative) {
4db4a6
+     /* for pstxsd and friends using R=1 */
4db4a6
+     vec_xa[0] = vsxargs[ (vrai+2  ) % isr_modulo];
4db4a6
+     vec_xa[1] = vsxargs[ (vrai+3  ) % isr_modulo];
4db4a6
+   }
4db4a6
 
4db4a6
    // xap 'shares' with the second half of an xa-pair.
4db4a6
   if (has_xap ) {