From: David Schleef Date: Sun, 20 Sep 2009 00:46:06 +0000 (-0700) Subject: Add orc_memset() and orc_memcpy() X-Git-Tag: merge-base~76 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=52b21cbefed2e4f2af461aaaddeec393aab26ad7;p=platform%2Fupstream%2Forc.git Add orc_memset() and orc_memcpy() --- diff --git a/orc/Makefile.am b/orc/Makefile.am index d1b64ed..7985e70 100644 --- a/orc/Makefile.am +++ b/orc/Makefile.am @@ -12,6 +12,7 @@ liborc_@ORC_MAJORMINOR@_la_CFLAGS = $(ORC_CFLAGS) \ liborc_@ORC_MAJORMINOR@_la_SOURCES = \ orc.c \ orcexecutor.c \ + orcfunctions.c \ orcrule.c \ orccodemem.c \ orcprogram.c \ @@ -54,6 +55,7 @@ pkginclude_HEADERS = \ orc.h \ orcdebug.h \ orcprogram.h \ + orcfunctions.h \ orcutils.h \ orcparse.h \ opcodes.h \ @@ -68,3 +70,9 @@ nodist_pkginclude_HEADERS = orc-stdint.h DISTCLEANFILES = orc-stdint.h + + +orcfunctions: + $(top_builddir)/tools/orcc$(EXEEXT) --implementation -o orcfunctions.c orcfunctions.orc + $(top_builddir)/tools/orcc$(EXEEXT) --header -o orcfunctions.h orcfunctions.orc + diff --git a/orc/orc.h b/orc/orc.h index e7407d3..3f711be 100644 --- a/orc/orc.h +++ b/orc/orc.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/orc/orcfunctions.c b/orc/orcfunctions.c new file mode 100644 index 0000000..98c2f20 --- /dev/null +++ b/orc/orcfunctions.c @@ -0,0 +1,177 @@ + +/* autogenerated from orcfunctions.orc */ + +#ifndef DISABLE_ORC +#include +#else +#include +#endif + +#define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x))) +#define ORC_ABS(a) ((a)<0 ? -(a) : (a)) +#define ORC_MIN(a,b) ((a)<(b) ? (a) : (b)) +#define ORC_MAX(a,b) ((a)>(b) ? (a) : (b)) +#define ORC_SB_MAX 127 +#define ORC_SB_MIN (-1-ORC_SB_MAX) +#define ORC_UB_MAX 255 +#define ORC_UB_MIN 0 +#define ORC_SW_MAX 32767 +#define ORC_SW_MIN (-1-ORC_SW_MAX) +#define ORC_UW_MAX 65535 +#define ORC_UW_MIN 0 +#define ORC_SL_MAX 2147483647 +#define ORC_SL_MIN (-1-ORC_SL_MAX) +#define ORC_UL_MAX 4294967295U +#define ORC_UL_MIN 0 +#define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX) +#define ORC_CLAMP_UB(x) ORC_CLAMP(x,ORC_UB_MIN,ORC_UB_MAX) +#define ORC_CLAMP_SW(x) ORC_CLAMP(x,ORC_SW_MIN,ORC_SW_MAX) +#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX) +#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX) +#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX) +#define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8)) +#define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24)) +#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) + + +/* orc_memcpy */ +#ifdef DISABLE_ORC +void +orc_memcpy (void * d1, void * s1, int n){ + int i; + int8_t * var0; + const int8_t * var4; + + var0 = (void *)d1; + var4 = (void *)s1; + + for (i = 0; i < n; i++) { + /* 0: copyb */ + var0[i] = var4[i]; + } + +} + +#else +static void +_backup_orc_memcpy (OrcExecutor *ex) +{ + int i; + int8_t * var0; + const int8_t * var4; + + var0 = ex->arrays[0]; + var4 = ex->arrays[4]; + + for (i = 0; i < ex->n; i++) { + /* 0: copyb */ + var0[i] = var4[i]; + } + +} + +void +orc_memcpy (void * d1, void * s1, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static int p_inited = 0; + static OrcProgram *p = 0; + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcCompileResult result; + + p = orc_program_new (); + orc_program_set_name (p, "orc_memcpy"); + orc_program_set_backup_function (p, _backup_orc_memcpy); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_source (p, 1, "s1"); + + orc_program_append (p, "copyb", ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1); + + result = orc_program_compile (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->program = p; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_S1] = s1; + + orc_executor_run (ex); +} +#endif + + +/* orc_memset */ +#ifdef DISABLE_ORC +void +orc_memset (void * d1, int p1, int n){ + int i; + int8_t * var0; + const int8_t var24 = p1; + + var0 = (void *)d1; + + for (i = 0; i < n; i++) { + /* 0: copyb */ + var0[i] = var24; + } + +} + +#else +static void +_backup_orc_memset (OrcExecutor *ex) +{ + int i; + int8_t * var0; + const int8_t var24 = ex->params[24]; + + var0 = ex->arrays[0]; + + for (i = 0; i < ex->n; i++) { + /* 0: copyb */ + var0[i] = var24; + } + +} + +void +orc_memset (void * d1, int p1, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static int p_inited = 0; + static OrcProgram *p = 0; + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcCompileResult result; + + p = orc_program_new (); + orc_program_set_name (p, "orc_memset"); + orc_program_set_backup_function (p, _backup_orc_memset); + orc_program_add_destination (p, 1, "d1"); + orc_program_add_parameter (p, 1, "p1"); + + orc_program_append (p, "copyb", ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1); + + result = orc_program_compile (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->program = p; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->params[ORC_VAR_P1] = p1; + + orc_executor_run (ex); +} +#endif + diff --git a/orc/orcfunctions.h b/orc/orcfunctions.h new file mode 100644 index 0000000..4f0173c --- /dev/null +++ b/orc/orcfunctions.h @@ -0,0 +1,20 @@ + +/* autogenerated from orcfunctions.orc */ + +#ifndef _ORCFUNCTIONS_H_ +#define _ORCFUNCTIONS_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +void orc_memcpy (void * d1, void * s1, int n); +void orc_memset (void * d1, int p1, int n); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/orc/orcfunctions.orc b/orc/orcfunctions.orc new file mode 100644 index 0000000..51d89e5 --- /dev/null +++ b/orc/orcfunctions.orc @@ -0,0 +1,15 @@ + +.function orc_memcpy +.dest 1 d1 void +.source 1 s1 void + +copyb d1, s1 + + +.function orc_memset +.dest 1 d1 void +.param 1 p1 + +copyb d1, p1 + +