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