|
From: <sv...@va...> - 2012-07-16 08:23:35
|
sewardj 2012-07-16 09:23:26 +0100 (Mon, 16 Jul 2012)
New Revision: 12750
Log:
Add tests for MOVBE -- an Intel-Atom-only instruction
Added files:
trunk/none/tests/amd64/movbe.c
trunk/none/tests/amd64/movbe.stderr.exp
trunk/none/tests/amd64/movbe.stdout.exp
trunk/none/tests/amd64/movbe.vgtest
Modified files:
trunk/configure.in
trunk/none/tests/amd64/Makefile.am
Added: trunk/none/tests/amd64/movbe.vgtest (+2 -0)
===================================================================
--- trunk/none/tests/amd64/movbe.vgtest 2012-07-15 02:31:45 +01:00 (rev 12749)
+++ trunk/none/tests/amd64/movbe.vgtest 2012-07-16 09:23:26 +01:00 (rev 12750)
@@ -0,0 +1,2 @@
+prog: movbe
+vgopts: -q
Added: trunk/none/tests/amd64/movbe.stdout.exp (+24 -0)
===================================================================
--- trunk/none/tests/amd64/movbe.stdout.exp 2012-07-15 02:31:45 +01:00 (rev 12749)
+++ trunk/none/tests/amd64/movbe.stdout.exp 2012-07-16 09:23:26 +01:00 (rev 12750)
@@ -0,0 +1,24 @@
+MOVBE_RtoM_64
+ before 00571784494af2981ecac9199de375513bd127afa6e9c3690d6a95fac528657d501eefeec0d8b847
+ after 00571784494af2981ecac9199de375513b7d6528c5fa956a0d6a95fac528657d0d6a95fac528657d
+
+MOVBE_RtoM_32
+ before 84c4457d8560b160b244a056e51599fe2751bca75afbd2b6382dccdbc2829139fd673a5c2148a319
+ after 84c4457d8560b160b244a056e51599fe27dbcc2d38fbd2b6382dccdbc2829139382dccdbc2829139
+
+MOVBE_RtoM_16
+ before 179e655064dc2a846b3e625d19775d06e540bc6839c44b4a36ed3550df9899d8979b83b70eb840d7
+ after 179e655064dc2a846b3e625d19775d06e5ed366839c44b4a36ed3550df9899d836ed3550df9899d8
+
+MOVBE_MtoR_64
+ before 856c13b8709950cb8315cab0121ab056db93c0f8294addf95df605a7d127a7d31f195c53c95bf85f
+ after 856c13b8709950cb8315cab0121ab056db93c0f8294addf95df605a7d127a7d35df9dd4a29f8c093
+
+MOVBE_MtoR_32
+ before 3d6603cf39008e39979569ee6d5cbcd8966cf73d98a42d54e87fc9cb92bba12040ef72e29bf3afcf
+ after 3d6603cf39008e39979569ee6d5cbcd8966cf73d98a42d54e87fc9cb92bba120983df76c00000000
+
+MOVBE_MtoR_16
+ before 172ebcce16c982d16eb865944fab9d368adae4bb36b59768b76e2305226ee0f4069b4435908d7b40
+ after 172ebcce16c982d16eb865944fab9d368adae4bb36b59768b76e2305226ee0f4e4da2305226ee0f4
+
Added: trunk/none/tests/amd64/movbe.c (+81 -0)
===================================================================
--- trunk/none/tests/amd64/movbe.c 2012-07-15 02:31:45 +01:00 (rev 12749)
+++ trunk/none/tests/amd64/movbe.c 2012-07-16 09:23:26 +01:00 (rev 12750)
@@ -0,0 +1,81 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <malloc.h>
+
+typedef unsigned char UChar;
+typedef unsigned int UInt;
+typedef unsigned long int UWord;
+typedef unsigned long long int ULong;
+
+
+typedef struct { UChar cs[40]; } Block;
+
+void showBlock ( char* msg, Block* b )
+{
+ int i;
+ printf(" %s ", msg);
+ for (i = 0; i < 40; i++)
+ printf("%02x", (UInt)b->cs[i]);
+ printf("\n");
+}
+
+UChar randUChar ( void )
+{
+ static UInt seed = 80021;
+ seed = 1103515245 * seed + 12345;
+ return (seed >> 17) & 0xFF;
+}
+
+void randBlock ( Block* b )
+{
+ int i;
+ UChar* p = (UChar*)b;
+ for (i = 0; i < sizeof(Block); i++)
+ p[i] = randUChar();
+}
+
+/* Generate a function test_NAME, that tests the given insn.
+ The insn may only mention (%rax) and r9. */
+
+#define GEN_test_Monly(_name, _mem_form) \
+ \
+ __attribute__ ((noinline)) static void test_##_name ( void ) \
+ { \
+ Block* b = memalign(32, sizeof(Block)); \
+ randBlock(b); \
+ printf("%s\n", #_name); \
+ showBlock("before", b); \
+ __asm__ __volatile__( \
+ "leaq 16(%0),%%rax" "\n\t" \
+ "movq 24(%0),%%r9" "\n\t" \
+ _mem_form "\n\t" \
+ "movq %%r9, 32(%0)" "\n\t" \
+ : /*OUT*/ \
+ : /*IN*/"r"(b) \
+ : /*TRASH*/"r9","rax","memory","cc" \
+ ); \
+ showBlock("after ", b); \
+ printf("\n"); \
+ free(b); \
+ }
+
+GEN_test_Monly( MOVBE_RtoM_64, "movbe %%r9, 1(%%rax)")
+GEN_test_Monly( MOVBE_RtoM_32, "movbe %%r9d,1(%%rax)")
+GEN_test_Monly( MOVBE_RtoM_16, "movbe %%r9w,1(%%rax)")
+
+GEN_test_Monly( MOVBE_MtoR_64, "movbe 1(%%rax), %%r9")
+GEN_test_Monly( MOVBE_MtoR_32, "movbe 1(%%rax), %%r9d")
+GEN_test_Monly( MOVBE_MtoR_16, "movbe 1(%%rax), %%r9w")
+
+int main ( void )
+{
+ test_MOVBE_RtoM_64();
+ test_MOVBE_RtoM_32();
+ test_MOVBE_RtoM_16();
+ test_MOVBE_MtoR_64();
+ test_MOVBE_MtoR_32();
+ test_MOVBE_MtoR_16();
+ return 0;
+}
Added: trunk/none/tests/amd64/movbe.stderr.exp (+0 -0)
===================================================================
Modified: trunk/none/tests/amd64/Makefile.am (+4 -0)
===================================================================
--- trunk/none/tests/amd64/Makefile.am 2012-07-15 02:31:45 +01:00 (rev 12749)
+++ trunk/none/tests/amd64/Makefile.am 2012-07-16 09:23:26 +01:00 (rev 12750)
@@ -52,6 +52,7 @@
looper.stderr.exp looper.stdout.exp looper.vgtest \
loopnel.stderr.exp loopnel.stdout.exp loopnel.vgtest \
lzcnt64.stderr.exp lzcnt64.stdout.exp lzcnt64.vgtest \
+ movbe.stderr.exp movbe.stdout.exp movbe.vgtest \
nan80and64.stderr.exp nan80and64.stdout.exp nan80and64.vgtest \
nibz_bennee_mmap.stderr.exp nibz_bennee_mmap.stdout.exp \
nibz_bennee_mmap.vgtest \
@@ -106,6 +107,9 @@
if BUILD_AVX_TESTS
check_PROGRAMS += avx-1
endif
+if BUILD_MOVBE_TESTS
+ check_PROGRAMS += movbe
+endif
# DDD: these need to be made to work on Darwin like the x86/ ones were.
if ! VGCONF_OS_IS_DARWIN
Modified: trunk/configure.in (+21 -0)
===================================================================
--- trunk/configure.in 2012-07-15 02:31:45 +01:00 (rev 12749)
+++ trunk/configure.in 2012-07-16 09:23:26 +01:00 (rev 12750)
@@ -1754,6 +1754,27 @@
AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
+# does the x86/amd64 assembler understand MOVBE?
+# Note, this doesn't generate a C-level symbol. It generates a
+# automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
+AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+ do { long long int x;
+ __asm__ __volatile__(
+ "movbe (%%rsp), %%r15" : : : "r15" ); }
+ while (0)
+]])], [
+ac_have_as_movbe=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_as_movbe=no
+AC_MSG_RESULT([no])
+])
+
+AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
+
+
# Does the C compiler support the "ifunc" attribute
# Note, this doesn't generate a C-level symbol. It generates a
# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
|