Ticket #473: remove_memcpy_aligned.patch
File remove_memcpy_aligned.patch, 15.5 KB (added by doughera, 13 years ago) |
---|
-
MANIFEST
diff -r -u -N parrot-current/MANIFEST parrot-andy/MANIFEST
old new 211 211 config/auto/cgoto.pm [] 212 212 config/auto/cgoto/test_c.in [] 213 213 config/auto/cpu.pm [] 214 config/auto/cpu/i386/Makefile []215 214 config/auto/cpu/i386/auto.pm [] 216 config/auto/cpu/i386/memcpy_mmx.c []217 config/auto/cpu/i386/memcpy_mmx_in.c []218 config/auto/cpu/i386/memcpy_sse.c []219 config/auto/cpu/i386/memcpy_sse_in.c []220 215 config/auto/cpu/i386/test_gcc_cmpxchg_c.in [] 221 216 config/auto/cpu/ppc/auto.pm [] 222 217 config/auto/cpu/ppc/test_gcc_cmpset_c.in [] -
config/auto/cpu/i386/Makefile
diff -r -u -N parrot-current/config/auto/cpu/i386/Makefile parrot-andy/config/auto/cpu/i386/Makefile
old new 1 # use gcc/as to generate some files2 # this file is not intended to be run during normal config3 # but only by developers that change the source4 5 6 all: memcpy_files7 8 memcpy_files: memcpy_mmx.c memcpy_sse.c9 10 memcpy_mmx.c: memcpy_mmx_in.c ../../../../tools/dev/as2c.pl11 perl ../../../../tools/dev/as2c.pl memcpy_mmx_in > $@12 rm -f memcpy_mmx_in.s memcpy_mmx_in.o13 14 memcpy_sse.c: memcpy_sse_in.c ../../../../tools/dev/as2c.pl15 perl ../../../../tools/dev/as2c.pl memcpy_sse_in > $@16 rm -f memcpy_sse_in.s memcpy_sse_in.o17 -
config/auto/cpu/i386/auto.pm
diff -r -u -N parrot-current/config/auto/cpu/i386/auto.pm parrot-andy/config/auto/cpu/i386/auto.pm
old new 7 7 8 8 =head1 DESCRIPTION 9 9 10 Test for MMX/SSEfunctionality. Creates these Config entries10 Test for cmpxchg ASM functionality. Creates these Config entries 11 11 12 12 TEMP_generated => 'files ...' for inclusion in platform.c or platform.h 13 i386_has_ mmx=> 113 i386_has_gcc_cmpxchg_c => 1 14 14 15 15 =cut 16 16 … … 24 24 25 25 my $verbose = $conf->options->get('verbose'); 26 26 27 my @files = qw( memcpy_mmx.c memcpy_sse.c ); 28 for my $f (@files) { 29 print " $f " if $verbose; 30 my ($suffix) = $f =~ /memcpy_(\w+)/; 31 my $path_f = "config/auto/cpu/i386/$f"; 32 $conf->cc_gen($path_f); 33 eval( $conf->cc_build("-DPARROT_CONFIG_TEST") ); 34 if ($@) { 35 print " $@ " if $verbose; 36 } 37 else { 38 if ( $conf->cc_run() =~ /ok/ ) { 39 _handle_cc_run_ok($conf, $suffix, $path_f, $verbose); 40 } 41 } 42 $conf->cc_clean(); 43 } 44 45 @files = qw( test_gcc_cmpxchg_c.in ); 27 my @files = qw( test_gcc_cmpxchg_c.in ); 46 28 for my $f (@files) { 47 29 print " $f " if $verbose; 48 30 my ($suffix) = $f =~ /test_(\w+)/; -
config/auto/cpu/i386/memcpy_mmx.c
diff -r -u -N parrot-current/config/auto/cpu/i386/memcpy_mmx.c parrot-andy/config/auto/cpu/i386/memcpy_mmx.c
old new 1 /*2 * DO NOT EDIT THIS FILE3 *4 * Generated from memcpy_mmx_in.c via memcpy_mmx_in.s5 * by '../../../../tools/dev/as2c.pl memcpy_mmx_in'6 */7 8 /*9 * GAS LISTING /home/chip/tmp/cci2hVe3.s page 110 *11 *12 * 1 .file "memcpy_mmx_in.c"13 * 2 .text14 * 3 .p2align 4,,1515 * 4 .globl Parrot_memcpy_aligned_mmx16 *17 */18 static const char Parrot_memcpy_aligned_mmx_code[] = {19 /* Parrot_memcpy_aligned_mmx: */20 0x57, /* pushl %edi */21 0x56, /* pushl %esi */22 0x53, /* pushl %ebx */23 0x83, 0xEC, 0x10, /* subl $16, %esp */24 0x8B, 0x44, 0x24, 0x20, /* movl 32(%esp), %eax */25 0x8B, 0x5C, 0x24, 0x24, /* movl 36(%esp), %ebx */26 0x8B, 0x54, 0x24, 0x28, /* movl 40(%esp), %edx */27 0xDD, 0x5C, 0x24, 0x08, /* fstpl 8(%esp) */28 0x89, 0xC7, /* mov %eax, %edi */29 0x89, 0xDE, /* mov %ebx, %esi */30 0x89, 0xD1, /* mov %edx, %ecx */31 0xC1, 0xE9, 0x04, /* shr $4, %ecx */32 /* 1: */33 0x0F, 0x6F, 0x06, /* movq 0(%esi), %mm0 */34 0x0F, 0x6F, 0x4E, 0x08, /* movq 8(%esi), %mm1 */35 0x83, 0xC6, 0x10, /* add $16, %esi */36 0x0F, 0x7F, 0x07, /* movq %mm0, 0(%edi) */37 0x0F, 0x7F, 0x4F, 0x08, /* movq %mm1, 8(%edi) */38 0x83, 0xC7, 0x10, /* add $16, %edi */39 0x49, /* dec %ecx */40 0x75, 0xE9, /* jnz 1b */41 0x0F, 0x77, /* emms */42 0xDD, 0x44, 0x24, 0x08, /* fldl 8(%esp) */43 0x83, 0xC4, 0x10, /* addl $16, %esp */44 0x5B, /* popl %ebx */45 0x5E, /* popl %esi */46 0x5F, /* popl %edi */47 0xC3, /* ret */48 0x0049 };50 51 #include <stdlib.h>52 typedef void* (*Parrot_memcpy_aligned_mmx_t)(void *dest, const void *src, size_t);53 54 #ifndef NDEBUG55 #include <assert.h>56 static void*57 Parrot_memcpy_aligned_mmx_debug(void* d, const void* s, size_t n)58 {59 assert( (n & 0xf) == 0);60 assert( ((unsigned long) d & 7) == 0);61 assert( ((unsigned long) s & 7) == 0);62 return ((Parrot_memcpy_aligned_mmx_t)Parrot_memcpy_aligned_mmx_code)(d, s, n);63 }64 65 Parrot_memcpy_aligned_mmx_t Parrot_memcpy_aligned_mmx = Parrot_memcpy_aligned_mmx_debug;66 67 #else68 Parrot_memcpy_aligned_mmx_t Parrot_memcpy_aligned_mmx =69 (Parrot_memcpy_aligned_mmx_t) Parrot_memcpy_aligned_mmx_code;70 #endif71 72 #ifdef PARROT_CONFIG_TEST73 #include <string.h>74 #include <stdio.h>75 int main(int argc, char *argv[]) {76 unsigned char *s, *d;77 size_t i, n;78 79 n = 640; /* sizeof(reg_store) */80 81 s = (unsigned char *)malloc(n);82 for (i = 0; i < n; ++i)83 s[i] = i & 0xff;84 d = (unsigned char *)malloc(n);85 for (i = 0; i < n; ++i)86 d[i] = 0xff;87 Parrot_memcpy_aligned_mmx(d, s, n);88 for (i = 0; i < n; ++i)89 if (d[i] != (i & 0xff)) {90 printf("error s[%d] = %d d = %d\n", i, s[i], d[i]);91 exit(EXIT_FAILURE);92 }93 puts("ok");94 return 0;95 }96 #endif /* PARROT_CONFIG_TEST */97 98 /*99 * Local variables:100 * c-file-style: "parrot"101 * End:102 * vim: expandtab shiftwidth=4:103 */ -
config/auto/cpu/i386/memcpy_mmx_in.c
diff -r -u -N parrot-current/config/auto/cpu/i386/memcpy_mmx_in.c parrot-andy/config/auto/cpu/i386/memcpy_mmx_in.c
old new 1 /*2 * $Id: memcpy_mmx_in.c 36833 2009-02-17 20:09:26Z allison $3 * Copyright (C) 2004-2006, Parrot Foundation.4 */5 6 #include <stdlib.h>7 void*8 Parrot_memcpy_aligned_mmx(void *dest, const void *src, size_t n)9 {10 double tos;11 /*12 * must preserve tos - need also a version with fstpt/fldt13 */14 asm(15 "fstpl %3\n\t"16 "mov %0, %%edi\n\t"17 "mov %1, %%esi\n\t"18 "mov %2, %%ecx\n\t"19 "shr $4, %%ecx\n\t"20 "# .p2align 3\n\t"21 "1:\n\t"22 "movq 0(%%esi), %%mm0\n\t"23 "movq 8(%%esi), %%mm1\n\t"24 "add $16, %%esi\n\t"25 "movq %%mm0, 0(%%edi)\n\t"26 "movq %%mm1, 8(%%edi)\n\t"27 "add $16, %%edi\n\t"28 "dec %%ecx\n\t"29 "jnz 1b\n\t"30 "emms\n\t"31 "fldl %3\n\t"32 : /* no out */33 : "g"(dest), "g"(src), "g"(n), "m"(tos)34 : "%esi", "%edi", "%ecx", "memory");35 36 return dest;37 }38 39 /*INTERFACE40 41 #include <stdlib.h>42 typedef void* (*@FUNC@_t)(void *dest, const void *src, size_t);43 44 #ifndef NDEBUG45 # include <assert.h>46 static void*47 @FUNC@_debug(void* d, const void* s, size_t n)48 {49 assert( (n & 0xf) == 0);50 assert( ((unsigned long) d & 7) == 0);51 assert( ((unsigned long) s & 7) == 0);52 return ((@FUNC@_t)@FUNC@_code)(d, s, n);53 }54 55 @FUNC@_t @FUNC@ = @FUNC@_debug;56 57 #else58 @FUNC@_t @FUNC@ =59 (@FUNC@_t) @FUNC@_code;60 #endif61 62 #ifdef PARROT_CONFIG_TEST63 # include <string.h>64 # include <stdio.h>65 int main(int argc, char *argv[]) {66 unsigned char *s, *d;67 size_t i, n;68 69 n = 640; @* sizeof(reg_store) *@70 71 s = malloc(n);72 for (i = 0; i < n; ++i)73 s[i] = i & 0xff;74 d = malloc(n);75 for (i = 0; i < n; ++i)76 d[i] = 0xff;77 @FUNC@(d, s, n);78 for (i = 0; i < n; ++i) {79 if (d[i] != (i & 0xff)) {80 printf("error s[%d] = %d d = %d\n", i, s[i], d[i]);81 exit(EXIT_FAILURE);82 }83 }84 puts("ok");85 return 0;86 }87 #endif @* PARROT_CONFIG_TEST *@88 INTERFACE*/89 90 /*91 * Local variables:92 * c-file-style: "parrot"93 * End:94 * vim: expandtab shiftwidth=4:95 */ -
config/auto/cpu/i386/memcpy_sse.c
diff -r -u -N parrot-current/config/auto/cpu/i386/memcpy_sse.c parrot-andy/config/auto/cpu/i386/memcpy_sse.c
old new 1 /*2 * DO NOT EDIT THIS FILE3 *4 * Generated from memcpy_sse_in.c via memcpy_sse_in.s5 * by '../../../../tools/dev/as2c.pl memcpy_sse_in'6 */7 8 /*9 * GAS LISTING /home/chip/tmp/ccvNpFsi.s page 110 *11 *12 * 1 .file "memcpy_sse_in.c"13 * 2 .text14 * 3 .p2align 4,,1515 * 4 .globl Parrot_memcpy_aligned_sse16 *17 */18 static const char Parrot_memcpy_aligned_sse_code[] = {19 /* Parrot_memcpy_aligned_sse: */20 0x57, /* pushl %edi */21 0x56, /* pushl %esi */22 0x8B, 0x44, 0x24, 0x0C, /* movl 12(%esp), %eax */23 0x8B, 0x4C, 0x24, 0x14, /* mov 20(%esp), %ecx */24 0x8B, 0x74, 0x24, 0x10, /* mov 16(%esp), %esi */25 0x89, 0xC7, /* mov %eax, %edi */26 0xC1, 0xE9, 0x05, /* shr $5, %ecx */27 /* 1: */28 0x0F, 0x10, 0x06, /* movups 0(%esi), %xmm0 */29 0x0F, 0x10, 0x4E, 0x10, /* movups 16(%esi), %xmm1 */30 0x83, 0xC6, 0x20, /* add $32, %esi */31 0x0F, 0x11, 0x07, /* movups %xmm0, 0(%edi) */32 0x0F, 0x11, 0x4F, 0x10, /* movups %xmm1, 16(%edi) */33 0x83, 0xC7, 0x20, /* add $32, %edi */34 0x49, /* dec %ecx */35 0x75, 0xE9, /* jnz 1b */36 0x5E, /* popl %esi */37 0x5F, /* popl %edi */38 0xC3, /* ret */39 0x0040 };41 42 #include <stdlib.h>43 typedef void* (*Parrot_memcpy_aligned_sse_t)(void *dest, const void *src, size_t);44 45 #ifndef NDEBUG46 #include <assert.h>47 static void*48 Parrot_memcpy_aligned_sse_debug(void* d, const void* s, size_t n)49 {50 assert( (n & 0x1f) == 0);51 assert( ((unsigned long) d & 7) == 0);52 assert( ((unsigned long) s & 7) == 0);53 return ((Parrot_memcpy_aligned_sse_t)Parrot_memcpy_aligned_sse_code)(d, s, n);54 }55 56 Parrot_memcpy_aligned_sse_t Parrot_memcpy_aligned_sse = Parrot_memcpy_aligned_sse_debug;57 58 #else59 Parrot_memcpy_aligned_sse_t Parrot_memcpy_aligned_sse =60 (Parrot_memcpy_aligned_sse_t) Parrot_memcpy_aligned_sse_code;61 #endif62 63 #ifdef PARROT_CONFIG_TEST64 #include <string.h>65 #include <stdio.h>66 int main(int argc, char *argv[]) {67 unsigned char *s, *d;68 size_t i, n;69 70 n = 640; /* sizeof(reg_store) */71 72 s = (unsigned char *)malloc(n);73 for (i = 0; i < n; ++i)74 s[i] = i & 0xff;75 d = (unsigned char *)malloc(n);76 for (i = 0; i < n; ++i)77 d[i] = 0xff;78 Parrot_memcpy_aligned_sse(d, s, n);79 for (i = 0; i < n; ++i)80 if (d[i] != (i & 0xff)) {81 printf("error s[%d] = %d d = %d\n", i, s[i], d[i]);82 exit(EXIT_FAILURE);83 }84 puts("ok");85 return 0;86 }87 #endif /* PARROT_CONFIG_TEST */88 89 /*90 * Local variables:91 * c-file-style: "parrot"92 * End:93 * vim: expandtab shiftwidth=4:94 */ -
config/auto/cpu/i386/memcpy_sse_in.c
diff -r -u -N parrot-current/config/auto/cpu/i386/memcpy_sse_in.c parrot-andy/config/auto/cpu/i386/memcpy_sse_in.c
old new 1 /*2 * $Id: memcpy_sse_in.c 36833 2009-02-17 20:09:26Z allison $3 * Copyright (C) 2004-2006, Parrot Foundation.4 */5 6 #include <stdlib.h>7 void*8 Parrot_memcpy_aligned_sse(void *dest, const void *src, size_t n)9 {10 asm(11 "mov %0, %%ecx\n\t"12 "mov %1, %%esi\n\t"13 "mov %2, %%edi\n\t"14 "shr $5, %%ecx\n\t"15 "#.p2align 4\n\t"16 "1:\n\t"17 "movups 0(%%esi), %%xmm0\n\t"18 "movups 16(%%esi), %%xmm1\n\t"19 "add $32, %%esi\n\t"20 "movups %%xmm0, 0(%%edi)\n\t"21 "movups %%xmm1, 16(%%edi)\n\t"22 "add $32, %%edi\n\t"23 "dec %%ecx\n\t"24 "jnz 1b\n\t"25 26 : : "g"(n), "g"(src), "g"(dest) : "%esi", "%edi", "%ecx");27 return dest;28 }29 30 /*INTERFACE31 32 #include <stdlib.h>33 typedef void* (*@FUNC@_t)(void *dest, const void *src, size_t);34 35 #ifndef NDEBUG36 # include <assert.h>37 static void*38 @FUNC@_debug(void* d, const void* s, size_t n)39 {40 assert( (n & 0x1f) == 0);41 assert( ((unsigned long) d & 7) == 0);42 assert( ((unsigned long) s & 7) == 0);43 return ((@FUNC@_t)@FUNC@_code)(d, s, n);44 }45 46 @FUNC@_t @FUNC@ = @FUNC@_debug;47 48 #else49 @FUNC@_t @FUNC@ =50 (@FUNC@_t) @FUNC@_code;51 #endif52 53 #ifdef PARROT_CONFIG_TEST54 # include <string.h>55 # include <stdio.h>56 int main(int argc, char *argv[]) {57 unsigned char *s, *d;58 size_t i, n;59 60 n = 640; @* sizeof(reg_store) *@61 62 s = malloc(n);63 for (i = 0; i < n; ++i)64 s[i] = i & 0xff;65 d = malloc(n);66 for (i = 0; i < n; ++i)67 d[i] = 0xff;68 @FUNC@(d, s, n);69 for (i = 0; i < n; ++i)70 if (d[i] != (i & 0xff)) {71 printf("error s[%d] = %d d = %d\n", i, s[i], d[i]);72 exit(EXIT_FAILURE);73 }74 puts("ok");75 return 0;76 }77 #endif @* PARROT_CONFIG_TEST *@78 INTERFACE*/79 80 /*81 * Local variables:82 * c-file-style: "parrot"83 * End:84 * vim: expandtab shiftwidth=4:85 */ -
config/gen/platform/platform_interface.h
diff -r -u -N parrot-current/config/gen/platform/platform_interface.h parrot-andy/config/gen/platform/platform_interface.h
old new 48 48 # define mem_realloc_executable mem_sys_realloc 49 49 #endif 50 50 51 void* Parrot_memcpy_aligned(void*, void*, size_t);52 53 #if defined(PARROT_HAS_I386_SSE)54 55 typedef void* (*Parrot_memcpy_func_t)(void *dest, const void *src, size_t);56 extern Parrot_memcpy_func_t Parrot_memcpy_aligned_sse;57 58 # define Parrot_memcpy_aligned(d, s, l) Parrot_memcpy_aligned_sse((d), (s), (l))59 60 #elif defined(PARROT_HAS_I386_MMX)61 62 typedef void* (*Parrot_memcpy_func_t)(void *dest, const void *src, size_t);63 extern Parrot_memcpy_func_t Parrot_memcpy_aligned_mmx;64 65 # define Parrot_memcpy_aligned(d, s, l) Parrot_memcpy_aligned_mmx((d), (s), (l))66 67 #else68 # define Parrot_memcpy_aligned(d, s, l) mem_sys_memcopy((d), (s), (l))69 #endif70 71 51 /* 72 52 ** Time 73 53 */