Test sahf/lahf on amd64.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6695 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am
index 7a165b8..0491e9f 100644
--- a/none/tests/amd64/Makefile.am
+++ b/none/tests/amd64/Makefile.am
@@ -30,7 +30,9 @@
 	nibz_bennee_mmap.vgtest \
 	rcl-amd64.vgtest rcl-amd64.stdout.exp rcl-amd64.stderr.exp \
 	smc1.stderr.exp smc1.stdout.exp smc1.vgtest \
-	shrld.stderr.exp shrld.stdout.exp shrld.vgtest
+	shrld.stderr.exp shrld.stdout.exp shrld.vgtest \
+	slahf-amd64.stderr.exp slahf-amd64.stdout.exp \
+	slahf-amd64.stderr.vgtest
 
 
 check_PROGRAMS = \
@@ -38,7 +40,8 @@
 	clc \
 	faultstatus fcmovnu fxtract $(INSN_TESTS) looper jrcxz \
 	rcl-amd64 smc1 shrld \
-	nibz_bennee_mmap
+	nibz_bennee_mmap \
+	slahf-amd64
 
 AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include
 		@FLAG_M64@
diff --git a/none/tests/amd64/slahf-amd64.c b/none/tests/amd64/slahf-amd64.c
new file mode 100644
index 0000000..06a91ae
--- /dev/null
+++ b/none/tests/amd64/slahf-amd64.c
@@ -0,0 +1,50 @@
+
+#include <stdio.h>
+
+typedef unsigned long long int ULong;
+
+extern ULong lahf_1 ( void );
+asm("\n"
+"lahf_1:\n"
+"\tpushq $0\n"
+"\tpopfq\n"
+"\tmovabsq $0xFFFFFFFFFFFFFFFF, %rax\n"
+"\tmovabsq $0x8765432112345678, %rdx\n"
+"\tsubq %rax, %rdx\n"
+"\tlahf\n"
+"\tret\n"
+);
+
+extern ULong lahf_0 ( void );
+asm("\n"
+"lahf_0:\n"
+"\tpushq $0\n"
+"\tpopfq\n"
+"\tmovabsq $0x0, %rax\n"
+"\tmovabsq $0x8765432112345678, %rdx\n"
+"\tsubq %rax, %rdx\n"
+"\tlahf\n"
+"\tret\n"
+);
+
+extern ULong sahf_then_lahf ( ULong );
+asm("\n"
+"sahf_then_lahf:\n"
+"\tmovq %rdi, %rax\n"
+"\tsahf\n"
+"\tmovabsq $0, %rax\n"
+"\tlahf\n"
+"\tret\n"
+);
+
+int main ( void )
+{
+   ULong i;
+   printf("0x%llx\n", lahf_0());
+   printf("0x%llx\n", lahf_1());
+   for (i = 0; i < 255; i++) {
+      ULong x = sahf_then_lahf(i << 8);
+      printf("%llx -> %llx\n", i, x);
+   }
+   return 0;
+}
diff --git a/none/tests/amd64/slahf-amd64.stderr.exp b/none/tests/amd64/slahf-amd64.stderr.exp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/none/tests/amd64/slahf-amd64.stderr.exp
diff --git a/none/tests/amd64/slahf-amd64.stdout.exp b/none/tests/amd64/slahf-amd64.stdout.exp
new file mode 100644
index 0000000..71657da
--- /dev/null
+++ b/none/tests/amd64/slahf-amd64.stdout.exp
@@ -0,0 +1,257 @@
+0x8600
+0xffffffffffff93ff
+0 -> 200
+1 -> 300
+2 -> 200
+3 -> 300
+4 -> 600
+5 -> 700
+6 -> 600
+7 -> 700
+8 -> 200
+9 -> 300
+a -> 200
+b -> 300
+c -> 600
+d -> 700
+e -> 600
+f -> 700
+10 -> 1200
+11 -> 1300
+12 -> 1200
+13 -> 1300
+14 -> 1600
+15 -> 1700
+16 -> 1600
+17 -> 1700
+18 -> 1200
+19 -> 1300
+1a -> 1200
+1b -> 1300
+1c -> 1600
+1d -> 1700
+1e -> 1600
+1f -> 1700
+20 -> 200
+21 -> 300
+22 -> 200
+23 -> 300
+24 -> 600
+25 -> 700
+26 -> 600
+27 -> 700
+28 -> 200
+29 -> 300
+2a -> 200
+2b -> 300
+2c -> 600
+2d -> 700
+2e -> 600
+2f -> 700
+30 -> 1200
+31 -> 1300
+32 -> 1200
+33 -> 1300
+34 -> 1600
+35 -> 1700
+36 -> 1600
+37 -> 1700
+38 -> 1200
+39 -> 1300
+3a -> 1200
+3b -> 1300
+3c -> 1600
+3d -> 1700
+3e -> 1600
+3f -> 1700
+40 -> 4200
+41 -> 4300
+42 -> 4200
+43 -> 4300
+44 -> 4600
+45 -> 4700
+46 -> 4600
+47 -> 4700
+48 -> 4200
+49 -> 4300
+4a -> 4200
+4b -> 4300
+4c -> 4600
+4d -> 4700
+4e -> 4600
+4f -> 4700
+50 -> 5200
+51 -> 5300
+52 -> 5200
+53 -> 5300
+54 -> 5600
+55 -> 5700
+56 -> 5600
+57 -> 5700
+58 -> 5200
+59 -> 5300
+5a -> 5200
+5b -> 5300
+5c -> 5600
+5d -> 5700
+5e -> 5600
+5f -> 5700
+60 -> 4200
+61 -> 4300
+62 -> 4200
+63 -> 4300
+64 -> 4600
+65 -> 4700
+66 -> 4600
+67 -> 4700
+68 -> 4200
+69 -> 4300
+6a -> 4200
+6b -> 4300
+6c -> 4600
+6d -> 4700
+6e -> 4600
+6f -> 4700
+70 -> 5200
+71 -> 5300
+72 -> 5200
+73 -> 5300
+74 -> 5600
+75 -> 5700
+76 -> 5600
+77 -> 5700
+78 -> 5200
+79 -> 5300
+7a -> 5200
+7b -> 5300
+7c -> 5600
+7d -> 5700
+7e -> 5600
+7f -> 5700
+80 -> 8200
+81 -> 8300
+82 -> 8200
+83 -> 8300
+84 -> 8600
+85 -> 8700
+86 -> 8600
+87 -> 8700
+88 -> 8200
+89 -> 8300
+8a -> 8200
+8b -> 8300
+8c -> 8600
+8d -> 8700
+8e -> 8600
+8f -> 8700
+90 -> 9200
+91 -> 9300
+92 -> 9200
+93 -> 9300
+94 -> 9600
+95 -> 9700
+96 -> 9600
+97 -> 9700
+98 -> 9200
+99 -> 9300
+9a -> 9200
+9b -> 9300
+9c -> 9600
+9d -> 9700
+9e -> 9600
+9f -> 9700
+a0 -> 8200
+a1 -> 8300
+a2 -> 8200
+a3 -> 8300
+a4 -> 8600
+a5 -> 8700
+a6 -> 8600
+a7 -> 8700
+a8 -> 8200
+a9 -> 8300
+aa -> 8200
+ab -> 8300
+ac -> 8600
+ad -> 8700
+ae -> 8600
+af -> 8700
+b0 -> 9200
+b1 -> 9300
+b2 -> 9200
+b3 -> 9300
+b4 -> 9600
+b5 -> 9700
+b6 -> 9600
+b7 -> 9700
+b8 -> 9200
+b9 -> 9300
+ba -> 9200
+bb -> 9300
+bc -> 9600
+bd -> 9700
+be -> 9600
+bf -> 9700
+c0 -> c200
+c1 -> c300
+c2 -> c200
+c3 -> c300
+c4 -> c600
+c5 -> c700
+c6 -> c600
+c7 -> c700
+c8 -> c200
+c9 -> c300
+ca -> c200
+cb -> c300
+cc -> c600
+cd -> c700
+ce -> c600
+cf -> c700
+d0 -> d200
+d1 -> d300
+d2 -> d200
+d3 -> d300
+d4 -> d600
+d5 -> d700
+d6 -> d600
+d7 -> d700
+d8 -> d200
+d9 -> d300
+da -> d200
+db -> d300
+dc -> d600
+dd -> d700
+de -> d600
+df -> d700
+e0 -> c200
+e1 -> c300
+e2 -> c200
+e3 -> c300
+e4 -> c600
+e5 -> c700
+e6 -> c600
+e7 -> c700
+e8 -> c200
+e9 -> c300
+ea -> c200
+eb -> c300
+ec -> c600
+ed -> c700
+ee -> c600
+ef -> c700
+f0 -> d200
+f1 -> d300
+f2 -> d200
+f3 -> d300
+f4 -> d600
+f5 -> d700
+f6 -> d600
+f7 -> d700
+f8 -> d200
+f9 -> d300
+fa -> d200
+fb -> d300
+fc -> d600
+fd -> d700
+fe -> d600
diff --git a/none/tests/amd64/slahf-amd64.vgtest b/none/tests/amd64/slahf-amd64.vgtest
new file mode 100644
index 0000000..759afd0
--- /dev/null
+++ b/none/tests/amd64/slahf-amd64.vgtest
@@ -0,0 +1,2 @@
+prog: slahf-amd64
+vgopts: -q