diff options
author | David Schleef <ds@schleef.org> | 2005-01-10 02:38:32 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2005-01-10 02:38:32 +0000 |
commit | f43c4e35ee4f2008b28811ca25af9c09ee44ec6e (patch) | |
tree | d7ef09a68deed5a9bd5bf499ed6f15bcee1e543a | |
parent | 8e5ae77db51d5d3ab2f9f90d87294d2a6f5d6dbb (diff) | |
download | liboil-f43c4e35ee4f2008b28811ca25af9c09ee44ec6e.tar.gz |
* examples/oil-inspect.c: (oil_print_impl): use "std." as abbr for
standard
* examples/uberopt/uberopt.c: (main): fix compile problem on ia64
* examples/work/Makefile.am: glib fixes
* liboil/Makefile.am: autobuild a marshalling function
* liboil/build_marshal.c: (main), (add_pointer_mask),
(print_header), (print_footer): same
* liboil/liboilmarshal.c: (_oil_test_marshal_function): the
autobuilt source
* liboil/liboiltest.c: (oil_test_check_function): use the autobuilt
marshalling function
* liboil/liboiltest.h: same
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | examples/oil-inspect.c | 2 | ||||
-rw-r--r-- | examples/uberopt/uberopt.c | 4 | ||||
-rw-r--r-- | examples/work/Makefile.am | 4 | ||||
-rw-r--r-- | liboil/Makefile.am | 14 | ||||
-rw-r--r-- | liboil/build_marshal.c | 199 | ||||
-rw-r--r-- | liboil/liboilmarshal.c | 137 | ||||
-rw-r--r-- | liboil/liboiltest.c | 13 | ||||
-rw-r--r-- | liboil/liboiltest.h | 3 |
9 files changed, 374 insertions, 17 deletions
@@ -1,5 +1,20 @@ 2005-01-09 David Schleef <ds@schleef.org> + * examples/oil-inspect.c: (oil_print_impl): use "std." as abbr for + standard + * examples/uberopt/uberopt.c: (main): fix compile problem on ia64 + * examples/work/Makefile.am: glib fixes + * liboil/Makefile.am: autobuild a marshalling function + * liboil/build_marshal.c: (main), (add_pointer_mask), + (print_header), (print_footer): same + * liboil/liboilmarshal.c: (_oil_test_marshal_function): the + autobuilt source + * liboil/liboiltest.c: (oil_test_check_function): use the autobuilt + marshalling function + * liboil/liboiltest.h: same + +2005-01-09 David Schleef <ds@schleef.org> + * examples/work/work.c: (test), (main): misc changes * liboil/conv/conv_3dnow.c: (conv_f32_s16_3dnow), (conv_s32_f32_3dnow): fix asm diff --git a/examples/oil-inspect.c b/examples/oil-inspect.c index 4432e7d..95e8e21 100644 --- a/examples/oil-inspect.c +++ b/examples/oil-inspect.c @@ -114,7 +114,7 @@ oil_print_impl (OilFunctionImpl *impl, OilTest *test, char* prefix) free (c); } if (impl->profile_ave) { - printf ("%s profile: %g ticks (st.dev. %g)\n", prefix, impl->profile_ave, + printf ("%s profile: %g ticks (std.dev. %g)\n", prefix, impl->profile_ave, impl->profile_std); } if (test && !(impl->flags & OIL_IMPL_FLAG_REF)) { diff --git a/examples/uberopt/uberopt.c b/examples/uberopt/uberopt.c index d609d6d..9fcbd46 100644 --- a/examples/uberopt/uberopt.c +++ b/examples/uberopt/uberopt.c @@ -162,7 +162,7 @@ main (int argc, char *argv[]) s = strstr(lines[i],"UBER_INDEX"); if (s) { - g_print("%.*s%d%s\n", (s-lines[i]), lines[i], n_impls, s+10); + g_print("%.*s%d%s\n", (int)(s-lines[i]), lines[i], n_impls, s+10); } else { g_print("%s\n",lines[i]); } @@ -180,7 +180,7 @@ main (int argc, char *argv[]) s = strstr(lines[i],"UBER_INDEX"); if (s) { - g_print("%.*s%d%s\n", (s-lines[i]), lines[i], n_impls, s+10); + g_print("%.*s%d%s\n", (int)(s-lines[i]), lines[i], n_impls, s+10); } else { g_print("%s\n",lines[i]); } diff --git a/examples/work/Makefile.am b/examples/work/Makefile.am index f141e6a..4ff1f58 100644 --- a/examples/work/Makefile.am +++ b/examples/work/Makefile.am @@ -1,5 +1,9 @@ +if HAVE_GLIB noinst_PROGRAMS = work +else +noinst_PROGRAMS = +endif work_SOURCES = work.c diff --git a/liboil/Makefile.am b/liboil/Makefile.am index 5089284..85e6803 100644 --- a/liboil/Makefile.am +++ b/liboil/Makefile.am @@ -7,7 +7,7 @@ lib_LTLIBRARIES = liboiltmp1.la liboil-@LIBOIL_MAJORMINOR@.la noinst_LTLIBRARIES = liboilfunctions.la -noinst_PROGRAMS = build_prototypes +noinst_PROGRAMS = build_prototypes build_marshal pkginclude_HEADERS = liboil.h liboilfunction.h liboildebug.h liboilfuncs.h \ liboiltypes.h liboilcpu.h liboilprototype.h liboilparameter.h \ @@ -48,7 +48,8 @@ liboil_@LIBOIL_MAJORMINOR@_la_SOURCES = \ liboilprototype.c \ liboilarray.c \ liboiltest.h \ - liboiltest.c + liboiltest.c \ + liboilmarshal.c liboil_@LIBOIL_MAJORMINOR@_la_LIBADD = \ liboilfunctions.la liboil_@LIBOIL_MAJORMINOR@_la_CFLAGS = $(LIBOIL_CFLAGS) @@ -63,6 +64,12 @@ build_prototypes_SOURCES = build_prototypes.c build_prototypes_CFLAGS = $(LIBOIL_CFLAGS) build_prototypes_LDFLAGS = $(LIBOIL_LIBS) +build_marshal_DEPENDENCIES = liboil-$(LIBOIL_MAJORMINOR).la + +build_marshal_SOURCES = build_marshal.c +build_marshal_CFLAGS = $(LIBOIL_CFLAGS) +build_marshal_LDFLAGS = $(LIBOIL_LIBS) + liboilarray.c: liboiltmp1.la Makefile echo '/* This file is autogenerated. Do not edit */' >liboilarray.c echo >>liboilarray.c @@ -90,3 +97,6 @@ liboilarray.c: liboiltmp1.la Makefile liboilfuncs.h: ./build_prototypes >liboilfuncs.h +liboilmarshal.c: + ./build_marshal >liboilmarshal.c + diff --git a/liboil/build_marshal.c b/liboil/build_marshal.c new file mode 100644 index 0000000..7405b8d --- /dev/null +++ b/liboil/build_marshal.c @@ -0,0 +1,199 @@ +/* + * LIBOIL - Library of Optimized Inner Loops + * Copyright (c) 2004 David A. Schleef <ds@schleef.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +#include <stdio.h> +#include <liboil/liboil.h> +#include <ctype.h> +#include <stdlib.h> +#include <string.h> + +#include <liboil/liboilprototype.h> + +void print_header (void); +void print_footer (void); +void add_pointer_mask (unsigned int mask); + +unsigned int proto_masks[1000]; +int n_for_mask[1000]; +int n_proto_masks; + +int main (int argc, char *argv[]) +{ + OilFunctionClass *klass; + OilPrototype *proto; + int i; + int j; + int n; + unsigned int pointer_mask; + + oil_init (); + + print_header (); + + n = oil_class_get_n_classes (); + for (i=0;i<n; i++ ){ + klass = oil_class_get_by_index (i); + + if(klass->prototype) { + proto = oil_prototype_from_string (klass->prototype); + if (proto) { + pointer_mask = 1; + + for (j=0;j<proto->n_params;j++){ + pointer_mask <<= 1; + if (proto->params[j].is_pointer) pointer_mask |= 1; + } + + add_pointer_mask (pointer_mask); + + oil_prototype_free (proto); + } else { + printf("/* ERROR: could not parse %s(%s) */\n", klass->name, klass->prototype); + } + } + } + + for(i=0;i<n_proto_masks;i++){ + unsigned int bit; + unsigned int hibit; + + pointer_mask = proto_masks[i]; + for(hibit=1;hibit<=pointer_mask;hibit<<=1); + hibit>>=2; + + printf(" case 0x%04x:\n", pointer_mask); + printf(" oil_profile_start (prof);\n"); + printf(" ((void (*)("); + if(hibit == 0) { + printf("void"); + } else { + for(bit=hibit;bit;bit >>= 1) { + if (pointer_mask & bit) { + printf("void *"); + } else { + printf("int"); + } + if (bit > 1) { + printf(","); + } + } + } + printf("))func)\n"); + printf(" ("); + j=0; + for(bit=hibit;bit;bit >>= 1) { + if (pointer_mask & bit) { + printf("(void *)args[%d]", j); + } else { + printf("(int)args[%d]", j); + } + if (bit > 1) { + printf(","); + } + j++; + } + printf(");\n"); + printf(" oil_profile_stop (prof);\n"); + printf(" break;\n"); + } + + print_footer (); + + return 0; +} + +void +add_pointer_mask (unsigned int mask) +{ + int i; + for(i=0;i<n_proto_masks;i++){ + if (proto_masks[i] == mask) { + n_for_mask[i]++; + return; + } + } + proto_masks[n_proto_masks] = mask; + n_for_mask[n_proto_masks]++; + n_proto_masks++; +} + +void print_header (void) +{ + printf ("/*\n"); + printf (" * LIBOIL - Library of Optimized Inner Loops\n"); + printf (" * Copyright (c) 2004 David A. Schleef <ds@schleef.org>\n"); + printf (" * All rights reserved.\n"); + printf (" *\n"); + printf (" * Redistribution and use in source and binary forms, with or without\n"); + printf (" * modification, are permitted provided that the following conditions\n"); + printf (" * are met:\n"); + printf (" * 1. Redistributions of source code must retain the above copyright\n"); + printf (" * notice, this list of conditions and the following disclaimer.\n"); + printf (" * 2. Redistributions in binary form must reproduce the above copyright\n"); + printf (" * notice, this list of conditions and the following disclaimer in the\n"); + printf (" * documentation and/or other materials provided with the distribution.\n"); + printf (" * \n"); + printf (" * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n"); + printf (" * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"); + printf (" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n"); + printf (" * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,\n"); + printf (" * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n"); + printf (" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n"); + printf (" * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n"); + printf (" * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n"); + printf (" * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n"); + printf (" * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n"); + printf (" * POSSIBILITY OF SUCH DAMAGE.\n"); + printf (" */\n"); + printf ("\n"); + printf ("/* This file is automatically generated. Do not edit. */\n"); + printf ("\n"); + printf ("#ifdef HAVE_CONFIG_H\n"); + printf ("#include <config.h>\n"); + printf ("#endif\n"); + printf ("\n"); + printf ("#include <liboil/liboiltest.h>\n"); + printf ("#include <liboil/liboildebug.h>\n"); + printf ("#include <liboil/liboilprofile.h>\n"); + printf ("\n"); + printf ("void\n"); + printf ("_oil_test_marshal_function (void *func, unsigned long *args, int n_args,\n"); + printf (" unsigned int pointer_mask, OilProfile *prof)\n"); + printf ("{\n"); + printf (" switch (pointer_mask) {\n"); +} + +void print_footer (void) +{ + printf (" default:\n"); + printf (" OIL_ERROR (\"unhandled marshal case\");\n"); + printf (" }\n"); + printf ("}\n"); + printf ("\n"); +} + diff --git a/liboil/liboilmarshal.c b/liboil/liboilmarshal.c new file mode 100644 index 0000000..00956ad --- /dev/null +++ b/liboil/liboilmarshal.c @@ -0,0 +1,137 @@ +/* + * LIBOIL - Library of Optimized Inner Loops + * Copyright (c) 2004 David A. Schleef <ds@schleef.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* This file is automatically generated. Do not edit. */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <liboil/liboiltest.h> +#include <liboil/liboildebug.h> +#include <liboil/liboilprofile.h> + +void +_oil_test_marshal_function (void *func, unsigned long *args, int n_args, + unsigned int pointer_mask, OilProfile *prof) +{ + switch (pointer_mask) { + case 0x0034: + oil_profile_start (prof); + ((void (*)(void *,int,void *,int,int))func) + ((void *)args[0],(int)args[1],(void *)args[2],(int)args[3],(int)args[4]); + oil_profile_stop (prof); + break; + case 0x001e: + oil_profile_start (prof); + ((void (*)(void *,void *,void *,int))func) + ((void *)args[0],(void *)args[1],(void *)args[2],(int)args[3]); + oil_profile_stop (prof); + break; + case 0x00d4: + oil_profile_start (prof); + ((void (*)(void *,int,void *,int,void *,int,int))func) + ((void *)args[0],(int)args[1],(void *)args[2],(int)args[3],(void *)args[4],(int)args[5],(int)args[6]); + oil_profile_stop (prof); + break; + case 0x000e: + oil_profile_start (prof); + ((void (*)(void *,void *,int))func) + ((void *)args[0],(void *)args[1],(int)args[2]); + oil_profile_stop (prof); + break; + case 0x00d3: + oil_profile_start (prof); + ((void (*)(void *,int,void *,int,int,void *,void *))func) + ((void *)args[0],(int)args[1],(void *)args[2],(int)args[3],(int)args[4],(void *)args[5],(void *)args[6]); + oil_profile_stop (prof); + break; + case 0x001a: + oil_profile_start (prof); + ((void (*)(void *,int,void *,int))func) + ((void *)args[0],(int)args[1],(void *)args[2],(int)args[3]); + oil_profile_stop (prof); + break; + case 0x006a: + oil_profile_start (prof); + ((void (*)(void *,int,void *,int,void *,int))func) + ((void *)args[0],(int)args[1],(void *)args[2],(int)args[3],(void *)args[4],(int)args[5]); + oil_profile_stop (prof); + break; + case 0x0074: + oil_profile_start (prof); + ((void (*)(void *,void *,int,void *,int,int))func) + ((void *)args[0],(void *)args[1],(int)args[2],(void *)args[3],(int)args[4],(int)args[5]); + oil_profile_stop (prof); + break; + case 0x001c: + oil_profile_start (prof); + ((void (*)(void *,void *,int,int))func) + ((void *)args[0],(void *)args[1],(int)args[2],(int)args[3]); + oil_profile_stop (prof); + break; + case 0x0007: + oil_profile_start (prof); + ((void (*)(void *,void *))func) + ((void *)args[0],(void *)args[1]); + oil_profile_stop (prof); + break; + case 0x003e: + oil_profile_start (prof); + ((void (*)(void *,void *,void *,void *,int))func) + ((void *)args[0],(void *)args[1],(void *)args[2],(void *)args[3],(int)args[4]); + oil_profile_stop (prof); + break; + case 0x0078: + oil_profile_start (prof); + ((void (*)(void *,void *,void *,int,int,int))func) + ((void *)args[0],(void *)args[1],(void *)args[2],(int)args[3],(int)args[4],(int)args[5]); + oil_profile_stop (prof); + break; + case 0x0001: + oil_profile_start (prof); + ((void (*)(void))func) + (); + oil_profile_stop (prof); + break; + case 0x003b: + oil_profile_start (prof); + ((void (*)(void *,void *,int,void *,void *))func) + ((void *)args[0],(void *)args[1],(int)args[2],(void *)args[3],(void *)args[4]); + oil_profile_stop (prof); + break; + case 0x0353: + oil_profile_start (prof); + ((void (*)(void *,int,void *,int,void *,int,int,void *,void *))func) + ((void *)args[0],(int)args[1],(void *)args[2],(int)args[3],(void *)args[4],(int)args[5],(int)args[6],(void *)args[7],(void *)args[8]); + oil_profile_stop (prof); + break; + default: + OIL_ERROR ("unhandled marshal case"); + } +} + diff --git a/liboil/liboiltest.c b/liboil/liboiltest.c index c77f743..a862d1b 100644 --- a/liboil/liboiltest.c +++ b/liboil/liboiltest.c @@ -119,17 +119,6 @@ oil_test_set_iterations (OilTest *test, int iterations) } static void -_oil_test_marshal_function (void *func, unsigned long *args, int n_args, - unsigned int pointer_mask, OilProfile *prof) -{ - oil_profile_start (prof); - ((void (*)(int,int,int,int,int,int,int,int,int,int))func) - (args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7], - args[8],args[9]); - oil_profile_stop (prof); -} - -static void oil_test_check_function (OilTest *test) { int i; @@ -151,7 +140,7 @@ oil_test_check_function (OilTest *test) OIL_LOG("calling reference function %s", test->impl->name); - pointer_mask = 0; + pointer_mask = 1; for(i=0;i<test->proto->n_params;i++){ OilParameter *p; j = test->proto->params[i].parameter_type; diff --git a/liboil/liboiltest.h b/liboil/liboiltest.h index dd97e7a..4b28723 100644 --- a/liboil/liboiltest.h +++ b/liboil/liboiltest.h @@ -67,5 +67,8 @@ void oil_test_init_src_arrays (OilTest *test); void oil_test_init_dest_arrays (OilTest *test); void oil_test_init_params (OilTest *test); +void _oil_test_marshal_function (void *func, unsigned long *args, int n_args, + unsigned int pointer_mask, OilProfile *prof); + #endif |