From: David Schleef Date: Wed, 28 Jul 2010 00:08:02 +0000 (-0700) Subject: Reimplement emulation X-Git-Tag: orc-0.4.7~113 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9f5602ad073b62d269c034fb78fe08abb52def16;p=platform%2Fupstream%2Forc.git Reimplement emulation --- diff --git a/orc/Makefile.am b/orc/Makefile.am index 1ad75bc..6d9178a 100644 --- a/orc/Makefile.am +++ b/orc/Makefile.am @@ -11,6 +11,7 @@ liborc_@ORC_MAJORMINOR@_la_CFLAGS = $(ORC_CFLAGS) \ liborc_@ORC_MAJORMINOR@_la_SOURCES = \ orc.c \ + orcemulateopcodes.c \ orcexecutor.c \ orcfunctions.c \ orcutils.c \ @@ -88,8 +89,13 @@ nodist_pkginclude_HEADERS = orc-stdint.h DISTCLEANFILES = orc-stdint.h +noinst_PROGRAMS = generate-emulation -orcfunctions: +generate_emulation_LDADD = $(ORC_LIBS) +generate_emulation_CFLAGS = $(ORC_CFLAGS) + +update: $(top_builddir)/tools/orcc$(EXEEXT) --implementation -o orcfunctions.c orcfunctions.orc $(top_builddir)/tools/orcc$(EXEEXT) --header -o orcfunctions.h orcfunctions.orc - + ./generate-emulation$(EXEEXT) -o orcemulateopcodes.c + diff --git a/orc/generate-emulation.c b/orc/generate-emulation.c new file mode 100644 index 0000000..b26e2aa --- /dev/null +++ b/orc/generate-emulation.c @@ -0,0 +1,302 @@ + +#include "config.h" + +#include +#include + +#include +#include +#include +#include + +void output_code_emulate (OrcProgram *p, FILE *output); + +int verbose = 0; +int error = 0; +int compat; + +char *target = "sse"; + +#define ORC_VERSION(a,b,c,d) ((a)*1000000 + (b)*10000 + (c)*100 + (d)) +#define REQUIRE(a,b,c,d) do { \ + if (ORC_VERSION((a),(b),(c),(d)) > compat) { \ + fprintf(stderr, "Feature used that is incompatible with --compat\n"); \ + exit (1); \ + } \ +} while (0) + +void help (void) +{ + printf("Usage:\n"); + printf(" generate-emulation [OPTION...]\n"); + printf("\n"); + printf("Help Options:\n"); + printf(" -h, --help Show help options\n"); + printf("\n"); + printf("Application Options:\n"); + printf(" -o, --output FILE Write output to FILE\n"); + printf("\n"); + + exit (0); +} + +int +main (int argc, char *argv[]) +{ + char *output_file = NULL; + char *input_file = NULL; + char *include_file = NULL; + FILE *output; + int i; + OrcOpcodeSet *opcode_set; + + orc_init (); + + for(i=1;i\n"); + fprintf(output, "#include \n"); + if (include_file) { + fprintf(output, "#include <%s>\n", include_file); + } + fprintf(output, "\n"); + fprintf(output, "%s", orc_target_get_asm_preamble ("c")); + fprintf(output, "\n"); + + opcode_set = orc_opcode_set_get ("sys"); + + for(i=0;in_opcodes;i++){ + char s[40]; + OrcProgram *program; + OrcStaticOpcode *opcode = opcode_set->opcodes + i; + + program = orc_program_new (); + + sprintf(s, "emulate_%s", opcode->name); + orc_program_set_name (program, s); + + if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + orc_program_add_accumulator (program, opcode->dest_size[0], "d1"); + } else { + orc_program_add_destination (program, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1]) { + orc_program_add_destination (program, opcode->dest_size[1], "d2"); + } + orc_program_add_source (program, opcode->src_size[0], "s1"); + if (opcode->src_size[1]) { + if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) { + orc_program_add_parameter (program, opcode->src_size[1], "s2"); + } else { + orc_program_add_source (program, opcode->src_size[1], "s2"); + } + } + if (opcode->src_size[1]) { + orc_program_append_str (program, opcode->name, "d1", "s1", "s2"); + } else { + if (opcode->dest_size[1]) { + orc_program_append_dds_str (program, opcode->name, "d1", "d2", "s1"); + } else { + orc_program_append_ds_str (program, opcode->name, "d1", "s1"); + } + } + + output_code_emulate (program, output); + } + + fclose (output); + + if (error) exit(1); + + return 0; +} + + +const char *varnames[] = { + "d1", "d2", "d3", "d4", + "s1", "s2", "s3", "s4", + "s5", "s6", "s7", "s8", + "a1", "a2", "a3", "d4", + "c1", "c2", "c3", "c4", + "c5", "c6", "c7", "c8", + "p1", "p2", "p3", "p4", + "p5", "p6", "p7", "p8", + "t1", "t2", "t3", "t4", + "t5", "t6", "t7", "t8", + "t9", "t10", "t11", "t12", + "t13", "t14", "t15", "t16" +}; + +const char *enumnames[] = { + "ORC_VAR_D1", "ORC_VAR_D2", "ORC_VAR_D3", "ORC_VAR_D4", + "ORC_VAR_S1", "ORC_VAR_S2", "ORC_VAR_S3", "ORC_VAR_S4", + "ORC_VAR_S5", "ORC_VAR_S6", "ORC_VAR_S7", "ORC_VAR_S8", + "ORC_VAR_A1", "ORC_VAR_A2", "ORC_VAR_A3", "ORC_VAR_A4", + "ORC_VAR_C1", "ORC_VAR_C2", "ORC_VAR_C3", "ORC_VAR_C4", + "ORC_VAR_C5", "ORC_VAR_C6", "ORC_VAR_C7", "ORC_VAR_C8", + "ORC_VAR_P1", "ORC_VAR_P2", "ORC_VAR_P3", "ORC_VAR_P4", + "ORC_VAR_P5", "ORC_VAR_P6", "ORC_VAR_P7", "ORC_VAR_P8", + "ORC_VAR_T1", "ORC_VAR_T2", "ORC_VAR_T3", "ORC_VAR_T4", + "ORC_VAR_T5", "ORC_VAR_T6", "ORC_VAR_T7", "ORC_VAR_T8", + "ORC_VAR_T9", "ORC_VAR_T10", "ORC_VAR_T11", "ORC_VAR_T12", + "ORC_VAR_T13", "ORC_VAR_T14", "ORC_VAR_T15", "ORC_VAR_T16" +}; + +#if 0 +void +output_prototype (OrcProgram *p, FILE *output) +{ + OrcVariable *var; + int i; + int need_comma; + + fprintf(output, "%s (", p->name); + need_comma = FALSE; + for(i=0;i<4;i++){ + var = &p->vars[ORC_VAR_D1 + i]; + if (var->size) { + if (need_comma) fprintf(output, ", "); + if (var->type_name) { + fprintf(output, "%s * %s", var->type_name, + varnames[ORC_VAR_D1 + i]); + } else { + fprintf(output, "orc_uint%d * %s", var->size*8, + varnames[ORC_VAR_D1 + i]); + } + if (p->is_2d) { + fprintf(output, ", int %s_stride", varnames[ORC_VAR_D1 + i]); + } + need_comma = TRUE; + } + } + for(i=0;i<4;i++){ + var = &p->vars[ORC_VAR_A1 + i]; + if (var->size) { + if (need_comma) fprintf(output, ", "); + if (var->type_name) { + fprintf(output, "%s * %s", var->type_name, + varnames[ORC_VAR_A1 + i]); + } else { + fprintf(output, "orc_uint%d * %s", var->size*8, + varnames[ORC_VAR_A1 + i]); + } + need_comma = TRUE; + } + } + for(i=0;i<8;i++){ + var = &p->vars[ORC_VAR_S1 + i]; + if (var->size) { + if (need_comma) fprintf(output, ", "); + if (var->type_name) { + fprintf(output, "const %s * %s", var->type_name, + varnames[ORC_VAR_S1 + i]); + } else { + fprintf(output, "const orc_uint%d * %s", var->size*8, + varnames[ORC_VAR_S1 + i]); + } + if (p->is_2d) { + fprintf(output, ", int %s_stride", varnames[ORC_VAR_S1 + i]); + } + need_comma = TRUE; + } + } + for(i=0;i<8;i++){ + var = &p->vars[ORC_VAR_P1 + i]; + if (var->size) { + if (need_comma) fprintf(output, ", "); + if (var->is_float_param) { + REQUIRE(0,4,5,1); + } + fprintf(output, "%s %s", + var->is_float_param ? "float" : "int", + varnames[ORC_VAR_P1 + i]); + need_comma = TRUE; + } + } + if (p->constant_n == 0) { + if (need_comma) fprintf(output, ", "); + fprintf(output, "int n"); + need_comma = TRUE; + } + if (p->is_2d && p->constant_m == 0) { + if (need_comma) fprintf(output, ", "); + fprintf(output, "int m"); + } + fprintf(output, ")"); +} + +void +output_code_header (OrcProgram *p, FILE *output) +{ + fprintf(output, "void "); + output_prototype (p, output); + fprintf(output, ";\n"); +} +#endif + +void +output_code_emulate (OrcProgram *p, FILE *output) +{ + + fprintf(output, "void\n"); + if (p->constant_n) { + fprintf(output, "%s (OrcOpcodeExecutor *ex)\n", p->name); + } else { + fprintf(output, "%s (OrcOpcodeExecutor *ex, int n)\n", p->name); + } + fprintf(output, "{\n"); + { + OrcCompileResult result; + + result = orc_program_compile_full (p, orc_target_get_by_name("c"), + ORC_TARGET_C_BARE | ORC_TARGET_C_OPCODE); + if (ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { + fprintf(output, "%s\n", orc_program_get_asm_code (p)); + } else { + printf("Failed to compile %s\n", p->name); + error = TRUE; + } + } + fprintf(output, "}\n"); + fprintf(output, "\n"); + +} + + diff --git a/orc/opcodes.h b/orc/opcodes.h index 3b13344..15883ef 100644 --- a/orc/opcodes.h +++ b/orc/opcodes.h @@ -111,16 +111,16 @@ UNARY_LW(select1lw, "((orc_uint32)%s >> 16)&0xffff") UNARY_UW(swapw, "ORC_SWAP_W(%s)") UNARY_UL(swapl, "ORC_SWAP_L(%s)") -BINARY_F(addf, "%s + %s") -BINARY_F(subf, "%s - %s") -BINARY_F(mulf, "%s * %s") -BINARY_F(divf, "%s / %s") -UNARY_F(sqrtf, "sqrt(%s)") -BINARY_F(maxf, "ORC_MAX(%s,%s)") -BINARY_F(minf, "ORC_MIN(%s,%s)") -BINARY_FL(cmpeqf, "(%s == %s) ? (~0) : 0") -BINARY_FL(cmpltf, "(%s < %s) ? (~0) : 0") -BINARY_FL(cmplef, "(%s <= %s) ? (~0) : 0") +BINARY_F(addf, "ORC_DENORMAL(ORC_DENORMAL(%s) + ORC_DENORMAL(%s))") +BINARY_F(subf, "ORC_DENORMAL(ORC_DENORMAL(%s) - ORC_DENORMAL(%s))") +BINARY_F(mulf, "ORC_DENORMAL(ORC_DENORMAL(%s) * ORC_DENORMAL(%s))") +BINARY_F(divf, "ORC_DENORMAL(ORC_DENORMAL(%s) / ORC_DENORMAL(%s))") +UNARY_F(sqrtf, "sqrt(ORC_DENORMAL(%s))") +BINARY_F(maxf, "ORC_MAXF(ORC_DENORMAL(%s),ORC_DENORMAL(%s))") +BINARY_F(minf, "ORC_MINF(ORC_DENORMAL(%s),ORC_DENORMAL(%s))") +BINARY_FL(cmpeqf, "(ORC_DENORMAL(%s) == ORC_DENORMAL(%s)) ? (~0) : 0") +BINARY_FL(cmpltf, "(ORC_DENORMAL(%s) < ORC_DENORMAL(%s)) ? (~0) : 0") +BINARY_FL(cmplef, "(ORC_DENORMAL(%s) <= ORC_DENORMAL(%s)) ? (~0) : 0") UNARY_FL(convfl, "(int)%s") UNARY_LF(convlf, "%s") diff --git a/orc/orcemulateopcodes.c b/orc/orcemulateopcodes.c new file mode 100644 index 0000000..7f4d9da --- /dev/null +++ b/orc/orcemulateopcodes.c @@ -0,0 +1,3302 @@ + +/* autogenerated by generate-emulation */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include +#include + + +/* begin Orc C target preamble */ +#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))) +#define ORC_MIN_NORMAL (1.1754944909521339405e-38) +#define ORC_DENORMAL(x) (((x) > -ORC_MIN_NORMAL && (x) < ORC_MIN_NORMAL) ? ((x)<0 ? (-0.0f) : (0.0f)) : (x)) +#define ORC_MINF(a,b) (isnan(a) ? a : isnan(b) ? b : ((a)<(b)) ? (a) : (b)) +#define ORC_MAXF(a,b) (isnan(a) ? a : isnan(b) ? b : ((a)>(b)) ? (a) : (b)) +/* end Orc C target preamble */ + + +void +emulate_absb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: absb */ + var0 = ORC_ABS(var4); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addb */ + var0 = var4 + var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addssb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addssb */ + var0 = ORC_CLAMP_SB(var4 + var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addusb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addusb */ + var0 = ORC_CLAMP_UB((orc_uint8)var4 + (orc_uint8)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_andb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: andb */ + var0 = var4 & var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_andnb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: andnb */ + var0 = (~var4) & var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_avgsb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: avgsb */ + var0 = (var4 + var5 + 1)>>1; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_avgub (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: avgub */ + var0 = ((orc_uint8)var4 + (orc_uint8)var5 + 1)>>1; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpeqb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpeqb */ + var0 = (var4 == var5) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpgtsb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpgtsb */ + var0 = (var4 > var5) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_copyb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: copyb */ + var0 = var4; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_maxsb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: maxsb */ + var0 = ORC_MAX(var4, var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_maxub (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: maxub */ + var0 = ORC_MAX((orc_uint8)var4, (orc_uint8)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_minsb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: minsb */ + var0 = ORC_MIN(var4, var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_minub (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: minub */ + var0 = ORC_MIN((orc_uint8)var4, (orc_uint8)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mullb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mullb */ + var0 = (var4 * var5) & 0xff; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulhsb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulhsb */ + var0 = (var4 * var5) >> 8; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulhub (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulhub */ + var0 = ((orc_uint32)(orc_uint8)var4 * (orc_uint32)(orc_uint8)var5) >> 8; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_orb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: orb */ + var0 = var4 | var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shlb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shlb */ + var0 = var4 << var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shrsb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shrsb */ + var0 = var4 >> var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shrub (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shrub */ + var0 = ((orc_uint8)var4) >> var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_signb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: signb */ + var0 = ORC_CLAMP(var4,-1,1); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subb */ + var0 = var4 - var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subssb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subssb */ + var0 = ORC_CLAMP_SB(var4 - var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subusb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subusb */ + var0 = ORC_CLAMP_UB((orc_uint8)var4 - (orc_uint8)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_xorb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: xorb */ + var0 = var4 ^ var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_absw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: absw */ + var0 = ORC_ABS(var4); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addw */ + var0 = var4 + var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addssw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addssw */ + var0 = ORC_CLAMP_SW(var4 + var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addusw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addusw */ + var0 = ORC_CLAMP_UW((orc_uint16)var4 + (orc_uint16)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_andw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: andw */ + var0 = var4 & var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_andnw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: andnw */ + var0 = (~var4) & var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_avgsw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: avgsw */ + var0 = (var4 + var5 + 1)>>1; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_avguw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: avguw */ + var0 = ((orc_uint16)var4 + (orc_uint16)var5 + 1)>>1; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpeqw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpeqw */ + var0 = (var4 == var5) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpgtsw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpgtsw */ + var0 = (var4 > var5) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_copyw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: copyw */ + var0 = var4; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_maxsw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: maxsw */ + var0 = ORC_MAX(var4, var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_maxuw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: maxuw */ + var0 = ORC_MAX((orc_uint16)var4, (orc_uint16)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_minsw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: minsw */ + var0 = ORC_MIN(var4, var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_minuw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: minuw */ + var0 = ORC_MIN((orc_uint16)var4, (orc_uint16)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mullw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mullw */ + var0 = (var4 * var5) & 0xffff; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulhsw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulhsw */ + var0 = (var4 * var5) >> 16; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulhuw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulhuw */ + var0 = ((orc_uint32)((orc_uint16)var4) * (orc_uint32)((orc_uint16)var5)) >> 16; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_orw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: orw */ + var0 = var4 | var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shlw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shlw */ + var0 = var4 << var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shrsw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shrsw */ + var0 = var4 >> var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shruw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shruw */ + var0 = ((orc_uint16)var4) >> var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_signw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: signw */ + var0 = ORC_CLAMP(var4,-1,1); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subw */ + var0 = var4 - var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subssw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subssw */ + var0 = ORC_CLAMP_SW(var4 - var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subusw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subusw */ + var0 = ORC_CLAMP_UW((orc_uint16)var4 - (orc_uint16)var5); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_xorw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: xorw */ + var0 = var4 ^ var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_absl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: absl */ + var0.i = ORC_ABS(var4.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addl */ + var0.i = var4.i + var5.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addssl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addssl */ + var0.i = ORC_CLAMP_SL((orc_int64)var4.i + (orc_int64)var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_addusl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addusl */ + var0.i = ORC_CLAMP_UL((orc_int64)(orc_uint32)var4.i + (orc_int64)(orc_uint32)var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_andl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: andl */ + var0.i = var4.i & var5.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_andnl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: andnl */ + var0.i = (~var4.i) & var5.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_avgsl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: avgsl */ + var0.i = ((orc_int64)var4.i + (orc_int64)var5.i + 1)>>1; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_avgul (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: avgul */ + var0.i = ((orc_uint64)(orc_uint32)var4.i + (orc_uint64)(orc_uint32)var5.i + 1)>>1; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpeql (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpeql */ + var0.i = (var4.i == var5.i) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpgtsl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpgtsl */ + var0.i = (var4.i > var5.i) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_copyl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: copyl */ + var0.i = var4.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_maxsl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: maxsl */ + var0.i = ORC_MAX(var4.i, var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_maxul (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: maxul */ + var0.i = ORC_MAX((orc_uint32)var4.i, (orc_uint32)var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_minsl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: minsl */ + var0.i = ORC_MIN(var4.i, var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_minul (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: minul */ + var0.i = ORC_MIN((orc_uint32)var4.i, (orc_uint32)var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulll (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulll */ + var0.i = (var4.i * var5.i) & 0xffffffff; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulhsl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulhsl */ + var0.i = ((orc_int64)var4.i * (orc_int64)var5.i) >> 32; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulhul (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulhul */ + var0.i = ((orc_uint64)var4.i * (orc_uint64)var5.i) >> 32; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_orl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: orl */ + var0.i = var4.i | var5.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shll (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shll */ + var0.i = var4.i << var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shrsl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shrsl */ + var0.i = var4.i >> var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_shrul (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + const int var24 = ((orc_union32 *)(ex->src_ptrs[1]))->i; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: shrul */ + var0.i = ((orc_uint32)var4.i) >> var24; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_signl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: signl */ + var0.i = ORC_CLAMP(var4.i,-1,1); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subl */ + var0.i = var4.i - var5.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subssl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subssl */ + var0.i = ORC_CLAMP_SL((orc_int64)var4.i - (orc_int64)var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subusl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subusl */ + var0.i = ORC_CLAMP_UL((orc_int64)(orc_uint32)var4.i - (orc_int64)(orc_uint32)var5.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_xorl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: xorl */ + var0.i = var4.i ^ var5.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convsbw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convsbw */ + var0 = var4; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convubw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convubw */ + var0 = (orc_uint8)var4; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convswl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convswl */ + var0.i = var4; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convuwl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convuwl */ + var0.i = (orc_uint16)var4; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convwb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convwb */ + var0 = var4; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convssswb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convssswb */ + var0 = ORC_CLAMP_SB(var4); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convsuswb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convsuswb */ + var0 = ORC_CLAMP_UB(var4); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convusswb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convusswb */ + var0 = ORC_CLAMP_SB((orc_uint16)var4); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convuuswb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convuuswb */ + var0 = ORC_CLAMP_UB((orc_uint16)var4); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convlw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convlw */ + var0 = var4.i; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convssslw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convssslw */ + var0 = ORC_CLAMP_SW(var4.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convsuslw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convsuslw */ + var0 = ORC_CLAMP_UW(var4.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convusslw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convusslw */ + var0 = ORC_CLAMP_SW((orc_uint32)var4.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convuuslw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convuuslw */ + var0 = ORC_CLAMP_UW((orc_uint32)var4.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulsbw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulsbw */ + var0 = var4 * var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulubw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulubw */ + var0 = (orc_uint8)var4 * (orc_uint8)var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulswl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulswl */ + var0.i = var4 * var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_muluwl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: muluwl */ + var0.i = (orc_uint16)var4 * (orc_uint16)var5; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_accw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var12 = 0; + + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: accw */ + var12 = var12 + var4; + } + ((orc_union32 *)ex->dest_ptrs[0])->i = (var12 + ((orc_union32 *)ex->dest_ptrs[0])->i) & 0xffff; + +} + +void +emulate_accl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var12 = { 0 }; + + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: accl */ + var12.i = var12.i + var4.i; + } + ((orc_union32 *)ex->dest_ptrs[0])->i += var12.i; + +} + +void +emulate_accsadubl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + orc_union32 var12 = { 0 }; + + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: accsadubl */ + var12.i = var12.i + ORC_ABS((orc_int32)(orc_uint8)var4 - (orc_int32)(orc_uint8)var5); + } + ((orc_union32 *)ex->dest_ptrs[0])->i += var12.i; + +} + +void +emulate_swapw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: swapw */ + var0 = ORC_SWAP_W(var4); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_swapl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: swapl */ + var0.i = ORC_SWAP_L(var4.i); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_select0wb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: select0wb */ + var0 = (orc_uint16)var4 & 0xff; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_select1wb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: select1wb */ + var0 = ((orc_uint16)var4 >> 8)&0xff; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_select0lw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: select0lw */ + var0 = (orc_uint32)var4.i & 0xffff; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_select1lw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: select1lw */ + var0 = ((orc_uint32)var4.i >> 16)&0xffff; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mergewl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_int16 var4; + const orc_int16 * ptr4; + orc_int16 var5; + const orc_int16 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + ptr5 = (orc_int16 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mergewl */ + var0.i = ((orc_uint16)var4) | ((orc_uint16)var5 << 16); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mergebw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int8 var4; + const orc_int8 * ptr4; + orc_int8 var5; + const orc_int8 * ptr5; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr4 = (orc_int8 *)ex->src_ptrs[0]; + ptr5 = (orc_int8 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mergebw */ + var0 = ((orc_uint8)var4) | ((orc_uint8)var5 << 8); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_splitlw (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int16 var0; + orc_int16 * ptr0; + orc_int16 var1; + orc_int16 * ptr1; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_int16 *)ex->dest_ptrs[0]; + ptr1 = (orc_int16 *)ex->dest_ptrs[1]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: splitlw */ + var0 = (var4.i >> 16) & 0xffff; + var1 = var4.i & 0xffff; + *ptr0 = var0; + ptr0++; + *ptr1 = var1; + ptr1++; + } + +} + +void +emulate_splitwb (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_int8 var0; + orc_int8 * ptr0; + orc_int8 var1; + orc_int8 * ptr1; + orc_int16 var4; + const orc_int16 * ptr4; + + ptr0 = (orc_int8 *)ex->dest_ptrs[0]; + ptr1 = (orc_int8 *)ex->dest_ptrs[1]; + ptr4 = (orc_int16 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: splitwb */ + var0 = (var4 >> 8) & 0xff; + var1 = var4 & 0xff; + *ptr0 = var0; + ptr0++; + *ptr1 = var1; + ptr1++; + } + +} + +void +emulate_addf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: addf */ + var0.f = ORC_DENORMAL(ORC_DENORMAL(var4.f) + ORC_DENORMAL(var5.f)); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_subf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: subf */ + var0.f = ORC_DENORMAL(ORC_DENORMAL(var4.f) - ORC_DENORMAL(var5.f)); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_mulf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: mulf */ + var0.f = ORC_DENORMAL(ORC_DENORMAL(var4.f) * ORC_DENORMAL(var5.f)); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_divf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: divf */ + var0.f = ORC_DENORMAL(ORC_DENORMAL(var4.f) / ORC_DENORMAL(var5.f)); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_sqrtf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: sqrtf */ + var0.f = sqrt(ORC_DENORMAL(var4.f)); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_maxf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: maxf */ + var0.f = ORC_MAXF(ORC_DENORMAL(var4.f),ORC_DENORMAL(var5.f)); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_minf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: minf */ + var0.f = ORC_MINF(ORC_DENORMAL(var4.f),ORC_DENORMAL(var5.f)); + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpeqf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpeqf */ + var0.i = (ORC_DENORMAL(var4.f) == ORC_DENORMAL(var5.f)) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmpltf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmpltf */ + var0.i = (ORC_DENORMAL(var4.f) < ORC_DENORMAL(var5.f)) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_cmplef (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + orc_union32 var5; + const orc_union32 * ptr5; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + ptr5 = (orc_union32 *)ex->src_ptrs[1]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + var5 = *ptr5; + ptr5++; + /* 0: cmplef */ + var0.i = (ORC_DENORMAL(var4.f) <= ORC_DENORMAL(var5.f)) ? (~0) : 0; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convfl (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convfl */ + var0.i = (int)var4.f; + *ptr0 = var0; + ptr0++; + } + +} + +void +emulate_convlf (OrcOpcodeExecutor *ex, int n) +{ + int i; + orc_union32 var0; + orc_union32 * ptr0; + orc_union32 var4; + const orc_union32 * ptr4; + + ptr0 = (orc_union32 *)ex->dest_ptrs[0]; + ptr4 = (orc_union32 *)ex->src_ptrs[0]; + + for (i = 0; i < n; i++) { + var4 = *ptr4; + ptr4++; + /* 0: convlf */ + var0.f = var4.i; + *ptr0 = var0; + ptr0++; + } + +} + diff --git a/orc/orcemulateopcodes.h b/orc/orcemulateopcodes.h new file mode 100644 index 0000000..4d4a827 --- /dev/null +++ b/orc/orcemulateopcodes.h @@ -0,0 +1,248 @@ +void emulate_absb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_absb (OrcOpcodeExecutor *ex); +void emulate_addb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addb (OrcOpcodeExecutor *ex); +void emulate_addssb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addssb (OrcOpcodeExecutor *ex); +void emulate_addusb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addusb (OrcOpcodeExecutor *ex); +void emulate_andb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_andb (OrcOpcodeExecutor *ex); +void emulate_andnb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_andnb (OrcOpcodeExecutor *ex); +void emulate_avgsb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_avgsb (OrcOpcodeExecutor *ex); +void emulate_avgub (OrcOpcodeExecutor *ex, int n); +void emulate_n16_avgub (OrcOpcodeExecutor *ex); +void emulate_cmpeqb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpeqb (OrcOpcodeExecutor *ex); +void emulate_cmpgtsb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpgtsb (OrcOpcodeExecutor *ex); +void emulate_copyb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_copyb (OrcOpcodeExecutor *ex); +void emulate_maxsb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_maxsb (OrcOpcodeExecutor *ex); +void emulate_maxub (OrcOpcodeExecutor *ex, int n); +void emulate_n16_maxub (OrcOpcodeExecutor *ex); +void emulate_minsb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_minsb (OrcOpcodeExecutor *ex); +void emulate_minub (OrcOpcodeExecutor *ex, int n); +void emulate_n16_minub (OrcOpcodeExecutor *ex); +void emulate_mullb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mullb (OrcOpcodeExecutor *ex); +void emulate_mulhsb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulhsb (OrcOpcodeExecutor *ex); +void emulate_mulhub (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulhub (OrcOpcodeExecutor *ex); +void emulate_orb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_orb (OrcOpcodeExecutor *ex); +void emulate_shlb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shlb (OrcOpcodeExecutor *ex); +void emulate_shrsb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shrsb (OrcOpcodeExecutor *ex); +void emulate_shrub (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shrub (OrcOpcodeExecutor *ex); +void emulate_signb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_signb (OrcOpcodeExecutor *ex); +void emulate_subb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subb (OrcOpcodeExecutor *ex); +void emulate_subssb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subssb (OrcOpcodeExecutor *ex); +void emulate_subusb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subusb (OrcOpcodeExecutor *ex); +void emulate_xorb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_xorb (OrcOpcodeExecutor *ex); +void emulate_absw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_absw (OrcOpcodeExecutor *ex); +void emulate_addw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addw (OrcOpcodeExecutor *ex); +void emulate_addssw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addssw (OrcOpcodeExecutor *ex); +void emulate_addusw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addusw (OrcOpcodeExecutor *ex); +void emulate_andw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_andw (OrcOpcodeExecutor *ex); +void emulate_andnw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_andnw (OrcOpcodeExecutor *ex); +void emulate_avgsw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_avgsw (OrcOpcodeExecutor *ex); +void emulate_avguw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_avguw (OrcOpcodeExecutor *ex); +void emulate_cmpeqw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpeqw (OrcOpcodeExecutor *ex); +void emulate_cmpgtsw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpgtsw (OrcOpcodeExecutor *ex); +void emulate_copyw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_copyw (OrcOpcodeExecutor *ex); +void emulate_maxsw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_maxsw (OrcOpcodeExecutor *ex); +void emulate_maxuw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_maxuw (OrcOpcodeExecutor *ex); +void emulate_minsw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_minsw (OrcOpcodeExecutor *ex); +void emulate_minuw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_minuw (OrcOpcodeExecutor *ex); +void emulate_mullw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mullw (OrcOpcodeExecutor *ex); +void emulate_mulhsw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulhsw (OrcOpcodeExecutor *ex); +void emulate_mulhuw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulhuw (OrcOpcodeExecutor *ex); +void emulate_orw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_orw (OrcOpcodeExecutor *ex); +void emulate_shlw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shlw (OrcOpcodeExecutor *ex); +void emulate_shrsw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shrsw (OrcOpcodeExecutor *ex); +void emulate_shruw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shruw (OrcOpcodeExecutor *ex); +void emulate_signw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_signw (OrcOpcodeExecutor *ex); +void emulate_subw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subw (OrcOpcodeExecutor *ex); +void emulate_subssw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subssw (OrcOpcodeExecutor *ex); +void emulate_subusw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subusw (OrcOpcodeExecutor *ex); +void emulate_xorw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_xorw (OrcOpcodeExecutor *ex); +void emulate_absl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_absl (OrcOpcodeExecutor *ex); +void emulate_addl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addl (OrcOpcodeExecutor *ex); +void emulate_addssl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addssl (OrcOpcodeExecutor *ex); +void emulate_addusl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addusl (OrcOpcodeExecutor *ex); +void emulate_andl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_andl (OrcOpcodeExecutor *ex); +void emulate_andnl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_andnl (OrcOpcodeExecutor *ex); +void emulate_avgsl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_avgsl (OrcOpcodeExecutor *ex); +void emulate_avgul (OrcOpcodeExecutor *ex, int n); +void emulate_n16_avgul (OrcOpcodeExecutor *ex); +void emulate_cmpeql (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpeql (OrcOpcodeExecutor *ex); +void emulate_cmpgtsl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpgtsl (OrcOpcodeExecutor *ex); +void emulate_copyl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_copyl (OrcOpcodeExecutor *ex); +void emulate_maxsl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_maxsl (OrcOpcodeExecutor *ex); +void emulate_maxul (OrcOpcodeExecutor *ex, int n); +void emulate_n16_maxul (OrcOpcodeExecutor *ex); +void emulate_minsl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_minsl (OrcOpcodeExecutor *ex); +void emulate_minul (OrcOpcodeExecutor *ex, int n); +void emulate_n16_minul (OrcOpcodeExecutor *ex); +void emulate_mulll (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulll (OrcOpcodeExecutor *ex); +void emulate_mulhsl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulhsl (OrcOpcodeExecutor *ex); +void emulate_mulhul (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulhul (OrcOpcodeExecutor *ex); +void emulate_orl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_orl (OrcOpcodeExecutor *ex); +void emulate_shll (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shll (OrcOpcodeExecutor *ex); +void emulate_shrsl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shrsl (OrcOpcodeExecutor *ex); +void emulate_shrul (OrcOpcodeExecutor *ex, int n); +void emulate_n16_shrul (OrcOpcodeExecutor *ex); +void emulate_signl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_signl (OrcOpcodeExecutor *ex); +void emulate_subl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subl (OrcOpcodeExecutor *ex); +void emulate_subssl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subssl (OrcOpcodeExecutor *ex); +void emulate_subusl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subusl (OrcOpcodeExecutor *ex); +void emulate_xorl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_xorl (OrcOpcodeExecutor *ex); +void emulate_convsbw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convsbw (OrcOpcodeExecutor *ex); +void emulate_convubw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convubw (OrcOpcodeExecutor *ex); +void emulate_convswl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convswl (OrcOpcodeExecutor *ex); +void emulate_convuwl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convuwl (OrcOpcodeExecutor *ex); +void emulate_convwb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convwb (OrcOpcodeExecutor *ex); +void emulate_convssswb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convssswb (OrcOpcodeExecutor *ex); +void emulate_convsuswb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convsuswb (OrcOpcodeExecutor *ex); +void emulate_convusswb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convusswb (OrcOpcodeExecutor *ex); +void emulate_convuuswb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convuuswb (OrcOpcodeExecutor *ex); +void emulate_convlw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convlw (OrcOpcodeExecutor *ex); +void emulate_convssslw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convssslw (OrcOpcodeExecutor *ex); +void emulate_convsuslw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convsuslw (OrcOpcodeExecutor *ex); +void emulate_convusslw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convusslw (OrcOpcodeExecutor *ex); +void emulate_convuuslw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convuuslw (OrcOpcodeExecutor *ex); +void emulate_mulsbw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulsbw (OrcOpcodeExecutor *ex); +void emulate_mulubw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulubw (OrcOpcodeExecutor *ex); +void emulate_mulswl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulswl (OrcOpcodeExecutor *ex); +void emulate_muluwl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_muluwl (OrcOpcodeExecutor *ex); +void emulate_accw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_accw (OrcOpcodeExecutor *ex); +void emulate_accl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_accl (OrcOpcodeExecutor *ex); +void emulate_accsadubl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_accsadubl (OrcOpcodeExecutor *ex); +void emulate_swapw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_swapw (OrcOpcodeExecutor *ex); +void emulate_swapl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_swapl (OrcOpcodeExecutor *ex); +void emulate_select0wb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_select0wb (OrcOpcodeExecutor *ex); +void emulate_select1wb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_select1wb (OrcOpcodeExecutor *ex); +void emulate_select0lw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_select0lw (OrcOpcodeExecutor *ex); +void emulate_select1lw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_select1lw (OrcOpcodeExecutor *ex); +void emulate_mergewl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mergewl (OrcOpcodeExecutor *ex); +void emulate_mergebw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mergebw (OrcOpcodeExecutor *ex); +void emulate_splitlw (OrcOpcodeExecutor *ex, int n); +void emulate_n16_splitlw (OrcOpcodeExecutor *ex); +void emulate_splitwb (OrcOpcodeExecutor *ex, int n); +void emulate_n16_splitwb (OrcOpcodeExecutor *ex); +void emulate_addf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_addf (OrcOpcodeExecutor *ex); +void emulate_subf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_subf (OrcOpcodeExecutor *ex); +void emulate_mulf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_mulf (OrcOpcodeExecutor *ex); +void emulate_divf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_divf (OrcOpcodeExecutor *ex); +void emulate_sqrtf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_sqrtf (OrcOpcodeExecutor *ex); +void emulate_maxf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_maxf (OrcOpcodeExecutor *ex); +void emulate_minf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_minf (OrcOpcodeExecutor *ex); +void emulate_cmpeqf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpeqf (OrcOpcodeExecutor *ex); +void emulate_cmpltf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmpltf (OrcOpcodeExecutor *ex); +void emulate_cmplef (OrcOpcodeExecutor *ex, int n); +void emulate_n16_cmplef (OrcOpcodeExecutor *ex); +void emulate_convfl (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convfl (OrcOpcodeExecutor *ex); +void emulate_convlf (OrcOpcodeExecutor *ex, int n); +void emulate_n16_convlf (OrcOpcodeExecutor *ex); diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c index d37c76c..98c1e14 100644 --- a/orc/orcexecutor.c +++ b/orc/orcexecutor.c @@ -119,6 +119,43 @@ orc_executor_set_m (OrcExecutor *ex, int m) ORC_EXECUTOR_M(ex) = m; } +static void +load_constant (void *data, int size, int value) +{ + switch (size) { + case 1: + { + int l; + orc_int8 *d = data; + for(l=0;l<16;l++) { + d[l] = value; + } + } + break; + case 2: + { + int l; + orc_int16 *d = data; + for(l=0;l<16;l++) { + d[l] = value; + } + } + break; + case 4: + { + int l; + orc_int32 *d = data; + for(l=0;l<16;l++) { + d[l] = value; + } + } + break; + default: + ORC_ASSERT(0); + } + +} + void orc_executor_emulate (OrcExecutor *ex) { @@ -129,7 +166,8 @@ orc_executor_emulate (OrcExecutor *ex) OrcProgram *program = ex->program; OrcInstruction *insn; OrcStaticOpcode *opcode; - OrcOpcodeExecutor opcode_ex; + OrcOpcodeExecutor *opcode_ex; + void *tmpspace[ORC_VAR_T15+1] = { 0 }; ex->accumulators[0] = 0; ex->accumulators[1] = 0; @@ -145,104 +183,105 @@ orc_executor_emulate (OrcExecutor *ex) } else { m = 1; } + + for(i=0;ivars + i; + + if (var->size) { + tmpspace[i] = malloc(4 * 16); + } + } + + opcode_ex = malloc(sizeof(OrcOpcodeExecutor)*program->n_insns); + + for(j=0;jn_insns;j++){ + insn = program->insns + j; + opcode = insn->opcode; + + opcode_ex[j].emulateN = opcode->emulateN; + for(k=0;kvars + insn->src_args[k]; + + if (var->vartype == ORC_VAR_TYPE_CONST) { + opcode_ex[j].src_ptrs[k] = tmpspace[insn->src_args[k]]; + load_constant (tmpspace[insn->src_args[k]], opcode->src_size[k], + var->value); + } else if (var->vartype == ORC_VAR_TYPE_PARAM) { + opcode_ex[j].src_ptrs[k] = tmpspace[insn->src_args[k]]; + load_constant (tmpspace[insn->src_args[k]], opcode->src_size[k], + ex->params[insn->src_args[k]]); + } else if (var->vartype == ORC_VAR_TYPE_TEMP) { + opcode_ex[j].src_ptrs[k] = tmpspace[insn->src_args[k]]; + } else if (var->vartype == ORC_VAR_TYPE_SRC) { + opcode_ex[j].src_ptrs[k] = ex->arrays[insn->src_args[k]]; + } else if (var->vartype == ORC_VAR_TYPE_DEST) { + opcode_ex[j].src_ptrs[k] = ex->arrays[insn->src_args[k]]; + } + } + for(k=0;kvars + insn->dest_args[k]; + + if (var->vartype == ORC_VAR_TYPE_TEMP) { + opcode_ex[j].dest_ptrs[k] = tmpspace[insn->dest_args[k]]; + } else if (var->vartype == ORC_VAR_TYPE_ACCUMULATOR) { + opcode_ex[j].dest_ptrs[k] = + &ex->accumulators[insn->dest_args[k] - ORC_VAR_A1]; + } else if (var->vartype == ORC_VAR_TYPE_DEST) { + opcode_ex[j].dest_ptrs[k] = ex->arrays[insn->dest_args[k]]; + } + } + } + ORC_DEBUG("src ptr %p stride %d", ex->arrays[ORC_VAR_S1], ex->params[ORC_VAR_S1]); for(m_index=0;m_indexn;i++){ + + for(i=0;in;i+=16){ for(j=0;jn_insns;j++){ insn = program->insns + j; opcode = insn->opcode; - /* set up args */ for(k=0;kvars + insn->src_args[k]; - if (opcode->src_size[k] == 0) continue; - - if (var->vartype == ORC_VAR_TYPE_CONST) { - opcode_ex.src_values[k] = var->value; - } else if (var->vartype == ORC_VAR_TYPE_PARAM) { - opcode_ex.src_values[k] = ex->params[insn->src_args[k]]; - } else if (var->vartype == ORC_VAR_TYPE_TEMP) { - /* FIXME shouldn't store executor stuff in program */ - opcode_ex.src_values[k] = var->value; - } else if (var->vartype == ORC_VAR_TYPE_SRC || - var->vartype == ORC_VAR_TYPE_DEST) { - void *ptr = ORC_PTR_OFFSET(ex->arrays[insn->src_args[k]], - var->size*i + ex->params[insn->src_args[k]]*m_index); - - switch (var->size) { - case 1: - opcode_ex.src_values[k] = *(orc_int8 *)ptr; - break; - case 2: - opcode_ex.src_values[k] = *(orc_int16 *)ptr; - break; - case 4: - opcode_ex.src_values[k] = *(orc_int32 *)ptr; - break; - case 8: - opcode_ex.src_values[k] = *(orc_int64 *)ptr; - break; - default: - ORC_ERROR("unhandled size %d", program->vars[insn->src_args[k]].size); - } - } else { - ORC_ERROR("shouldn't be reached (%d)", var->vartype); + if (var->vartype == ORC_VAR_TYPE_SRC) { + opcode_ex[j].src_ptrs[k] = + ORC_PTR_OFFSET(ex->arrays[insn->src_args[k]], + var->size*i + ex->params[insn->src_args[k]]*m_index); + } else if (var->vartype == ORC_VAR_TYPE_DEST) { + opcode_ex[j].src_ptrs[k] = + ORC_PTR_OFFSET(ex->arrays[insn->src_args[k]], + var->size*i + ex->params[insn->src_args[k]]*m_index); } } - - opcode->emulate (&opcode_ex, opcode->emulate_user); - - for(k=0;kvars + insn->dest_args[k]; - if (opcode->dest_size[k] == 0) continue; - - if (var->vartype == ORC_VAR_TYPE_TEMP) { - /* FIXME shouldn't store executor stuff in program */ - var->value = opcode_ex.dest_values[k]; - } else if (var->vartype == ORC_VAR_TYPE_DEST) { - void *ptr = ORC_PTR_OFFSET(ex->arrays[insn->dest_args[k]], - var->size*i + ex->params[insn->dest_args[k]]*m_index); - - switch (var->size) { - case 1: - *(orc_int8 *)ptr = opcode_ex.dest_values[k]; - break; - case 2: - *(orc_int16 *)ptr = opcode_ex.dest_values[k]; - break; - case 4: - *(orc_int32 *)ptr = opcode_ex.dest_values[k]; - break; - case 8: - *(orc_int64 *)ptr = opcode_ex.dest_values[k]; - break; - default: - ORC_ERROR("unhandled size %d", program->vars[insn->dest_args[k]].size); - } - } else if (var->vartype == ORC_VAR_TYPE_ACCUMULATOR) { - switch (var->size) { - case 2: - ex->accumulators[insn->dest_args[k] - ORC_VAR_A1] += - opcode_ex.dest_values[k]; - ex->accumulators[insn->dest_args[k] - ORC_VAR_A1] &= 0xffff; - break; - case 4: - ex->accumulators[insn->dest_args[k] - ORC_VAR_A1] += - opcode_ex.dest_values[k]; - break; - default: - ORC_ERROR("unhandled size %d", program->vars[insn->dest_args[k]].size); - } - } else { - ORC_ERROR("shouldn't be reached (%d)", var->vartype); + if (var->vartype == ORC_VAR_TYPE_DEST) { + opcode_ex[j].dest_ptrs[k] = + ORC_PTR_OFFSET(ex->arrays[insn->dest_args[k]], + var->size*i + ex->params[insn->dest_args[k]]*m_index); } } } + + for(j=0;jn_insns;j++){ + insn = program->insns + j; + opcode = insn->opcode; + + if (ex->n - i >= 16) { + opcode_ex[j].emulateN (opcode_ex + j, 16); + } else { + opcode_ex[j].emulateN (opcode_ex + j, ex->n - i); + } + } } } + + free (opcode_ex); + for(i=0;idest_values[0], ex->src_values[0]); } +#include "orc/orcemulateopcodes.h" static OrcStaticOpcode opcodes[] = { /* byte ops */ - { "absb", absb, NULL, 0, { 1 }, { 1 } }, - { "addb", addb, NULL, 0, { 1 }, { 1, 1 } }, - { "addssb", addssb, NULL, 0, { 1 }, { 1, 1 } }, - { "addusb", addusb, NULL, 0, { 1 }, { 1, 1 } }, - { "andb", andb, NULL, 0, { 1 }, { 1, 1 } }, - { "andnb", andnb, NULL, 0, { 1 }, { 1, 1 } }, - { "avgsb", avgsb, NULL, 0, { 1 }, { 1, 1 } }, - { "avgub", avgub, NULL, 0, { 1 }, { 1, 1 } }, - { "cmpeqb", cmpeqb, NULL, 0, { 1 }, { 1, 1 } }, - { "cmpgtsb", cmpgtsb, NULL, 0, { 1 }, { 1, 1 } }, - { "copyb", copyb, NULL, 0, { 1 }, { 1 } }, - { "maxsb", maxsb, NULL, 0, { 1 }, { 1, 1 } }, - { "maxub", maxub, NULL, 0, { 1 }, { 1, 1 } }, - { "minsb", minsb, NULL, 0, { 1 }, { 1, 1 } }, - { "minub", minub, NULL, 0, { 1 }, { 1, 1 } }, - { "mullb", mullb, NULL, 0, { 1 }, { 1, 1 } }, - { "mulhsb", mulhsb, NULL, 0, { 1 }, { 1, 1 } }, - { "mulhub", mulhub, NULL, 0, { 1 }, { 1, 1 } }, - { "orb", orb, NULL, 0, { 1 }, { 1, 1 } }, - { "shlb", shlb, NULL, ORC_STATIC_OPCODE_SCALAR, { 1 }, { 1, 1 } }, - { "shrsb", shrsb, NULL, ORC_STATIC_OPCODE_SCALAR, { 1 }, { 1, 1 } }, - { "shrub", shrub, NULL, ORC_STATIC_OPCODE_SCALAR, { 1 }, { 1, 1 } }, - { "signb", signb, NULL, 0, { 1 }, { 1 } }, - { "subb", subb, NULL, 0, { 1 }, { 1, 1 } }, - { "subssb", subssb, NULL, 0, { 1 }, { 1, 1 } }, - { "subusb", subusb, NULL, 0, { 1 }, { 1, 1 } }, - { "xorb", xorb, NULL, 0, { 1 }, { 1, 1 } }, + { "absb", absb, NULL, 0, { 1 }, { 1 }, emulate_absb }, + { "addb", addb, NULL, 0, { 1 }, { 1, 1 }, emulate_addb }, + { "addssb", addssb, NULL, 0, { 1 }, { 1, 1 }, emulate_addssb }, + { "addusb", addusb, NULL, 0, { 1 }, { 1, 1 }, emulate_addusb }, + { "andb", andb, NULL, 0, { 1 }, { 1, 1 }, emulate_andb }, + { "andnb", andnb, NULL, 0, { 1 }, { 1, 1 }, emulate_andnb }, + { "avgsb", avgsb, NULL, 0, { 1 }, { 1, 1 }, emulate_avgsb }, + { "avgub", avgub, NULL, 0, { 1 }, { 1, 1 }, emulate_avgub }, + { "cmpeqb", cmpeqb, NULL, 0, { 1 }, { 1, 1 }, emulate_cmpeqb }, + { "cmpgtsb", cmpgtsb, NULL, 0, { 1 }, { 1, 1 }, emulate_cmpgtsb }, + { "copyb", copyb, NULL, 0, { 1 }, { 1 }, emulate_copyb }, + { "maxsb", maxsb, NULL, 0, { 1 }, { 1, 1 }, emulate_maxsb }, + { "maxub", maxub, NULL, 0, { 1 }, { 1, 1 }, emulate_maxub }, + { "minsb", minsb, NULL, 0, { 1 }, { 1, 1 }, emulate_minsb }, + { "minub", minub, NULL, 0, { 1 }, { 1, 1 }, emulate_minub }, + { "mullb", mullb, NULL, 0, { 1 }, { 1, 1 }, emulate_mullb }, + { "mulhsb", mulhsb, NULL, 0, { 1 }, { 1, 1 }, emulate_mulhsb }, + { "mulhub", mulhub, NULL, 0, { 1 }, { 1, 1 }, emulate_mulhub }, + { "orb", orb, NULL, 0, { 1 }, { 1, 1 }, emulate_orb }, + { "shlb", shlb, NULL, ORC_STATIC_OPCODE_SCALAR, { 1 }, { 1, 1 }, emulate_shlb }, + { "shrsb", shrsb, NULL, ORC_STATIC_OPCODE_SCALAR, { 1 }, { 1, 1 }, emulate_shrsb }, + { "shrub", shrub, NULL, ORC_STATIC_OPCODE_SCALAR, { 1 }, { 1, 1 }, emulate_shrub }, + { "signb", signb, NULL, 0, { 1 }, { 1 }, emulate_signb }, + { "subb", subb, NULL, 0, { 1 }, { 1, 1 }, emulate_subb }, + { "subssb", subssb, NULL, 0, { 1 }, { 1, 1 }, emulate_subssb }, + { "subusb", subusb, NULL, 0, { 1 }, { 1, 1 }, emulate_subusb }, + { "xorb", xorb, NULL, 0, { 1 }, { 1, 1 }, emulate_xorb }, /* word ops */ - { "absw", absw, NULL, 0, { 2 }, { 2 } }, - { "addw", addw, NULL, 0, { 2 }, { 2, 2 } }, - { "addssw", addssw, NULL, 0, { 2 }, { 2, 2 } }, - { "addusw", addusw, NULL, 0, { 2 }, { 2, 2 } }, - { "andw", andw, NULL, 0, { 2 }, { 2, 2 } }, - { "andnw", andnw, NULL, 0, { 2 }, { 2, 2 } }, - { "avgsw", avgsw, NULL, 0, { 2 }, { 2, 2 } }, - { "avguw", avguw, NULL, 0, { 2 }, { 2, 2 } }, - { "cmpeqw", cmpeqw, NULL, 0, { 2 }, { 2, 2 } }, - { "cmpgtsw", cmpgtsw, NULL, 0, { 2 }, { 2, 2 } }, - { "copyw", copyw, NULL, 0, { 2 }, { 2 } }, - { "maxsw", maxsw, NULL, 0, { 2 }, { 2, 2 } }, - { "maxuw", maxuw, NULL, 0, { 2 }, { 2, 2 } }, - { "minsw", minsw, NULL, 0, { 2 }, { 2, 2 } }, - { "minuw", minuw, NULL, 0, { 2 }, { 2, 2 } }, - { "mullw", mullw, NULL, 0, { 2 }, { 2, 2 } }, - { "mulhsw", mulhsw, NULL, 0, { 2 }, { 2, 2 } }, - { "mulhuw", mulhuw, NULL, 0, { 2 }, { 2, 2 } }, - { "orw", orw, NULL, 0, { 2 }, { 2, 2 } }, - { "shlw", shlw, NULL, ORC_STATIC_OPCODE_SCALAR, { 2 }, { 2, 2 } }, - { "shrsw", shrsw, NULL, ORC_STATIC_OPCODE_SCALAR, { 2 }, { 2, 2 } }, - { "shruw", shruw, NULL, ORC_STATIC_OPCODE_SCALAR, { 2 }, { 2, 2 } }, - { "signw", signw, NULL, 0, { 2 }, { 2 } }, - { "subw", subw, NULL, 0, { 2 }, { 2, 2 } }, - { "subssw", subssw, NULL, 0, { 2 }, { 2, 2 } }, - { "subusw", subusw, NULL, 0, { 2 }, { 2, 2 } }, - { "xorw", xorw, NULL, 0, { 2 }, { 2, 2 } }, + { "absw", absw, NULL, 0, { 2 }, { 2 }, emulate_absw }, + { "addw", addw, NULL, 0, { 2 }, { 2, 2 }, emulate_addw }, + { "addssw", addssw, NULL, 0, { 2 }, { 2, 2 }, emulate_addssw }, + { "addusw", addusw, NULL, 0, { 2 }, { 2, 2 }, emulate_addusw }, + { "andw", andw, NULL, 0, { 2 }, { 2, 2 }, emulate_andw }, + { "andnw", andnw, NULL, 0, { 2 }, { 2, 2 }, emulate_andnw }, + { "avgsw", avgsw, NULL, 0, { 2 }, { 2, 2 }, emulate_avgsw }, + { "avguw", avguw, NULL, 0, { 2 }, { 2, 2 }, emulate_avguw }, + { "cmpeqw", cmpeqw, NULL, 0, { 2 }, { 2, 2 }, emulate_cmpeqw }, + { "cmpgtsw", cmpgtsw, NULL, 0, { 2 }, { 2, 2 }, emulate_cmpgtsw }, + { "copyw", copyw, NULL, 0, { 2 }, { 2 }, emulate_copyw }, + { "maxsw", maxsw, NULL, 0, { 2 }, { 2, 2 }, emulate_maxsw }, + { "maxuw", maxuw, NULL, 0, { 2 }, { 2, 2 }, emulate_maxuw }, + { "minsw", minsw, NULL, 0, { 2 }, { 2, 2 }, emulate_minsw }, + { "minuw", minuw, NULL, 0, { 2 }, { 2, 2 }, emulate_minuw }, + { "mullw", mullw, NULL, 0, { 2 }, { 2, 2 }, emulate_mullw }, + { "mulhsw", mulhsw, NULL, 0, { 2 }, { 2, 2 }, emulate_mulhsw }, + { "mulhuw", mulhuw, NULL, 0, { 2 }, { 2, 2 }, emulate_mulhuw }, + { "orw", orw, NULL, 0, { 2 }, { 2, 2 }, emulate_orw }, + { "shlw", shlw, NULL, ORC_STATIC_OPCODE_SCALAR, { 2 }, { 2, 2 }, emulate_shlw }, + { "shrsw", shrsw, NULL, ORC_STATIC_OPCODE_SCALAR, { 2 }, { 2, 2 }, emulate_shrsw }, + { "shruw", shruw, NULL, ORC_STATIC_OPCODE_SCALAR, { 2 }, { 2, 2 }, emulate_shruw }, + { "signw", signw, NULL, 0, { 2 }, { 2 }, emulate_signw }, + { "subw", subw, NULL, 0, { 2 }, { 2, 2 }, emulate_subw }, + { "subssw", subssw, NULL, 0, { 2 }, { 2, 2 }, emulate_subssw }, + { "subusw", subusw, NULL, 0, { 2 }, { 2, 2 }, emulate_subusw }, + { "xorw", xorw, NULL, 0, { 2 }, { 2, 2 }, emulate_xorw }, /* long ops */ - { "absl", absl, NULL, 0, { 4 }, { 4 } }, - { "addl", addl, NULL, 0, { 4 }, { 4, 4 } }, - { "addssl", addssl, NULL, 0, { 4 }, { 4, 4 } }, - { "addusl", addusl, NULL, 0, { 4 }, { 4, 4 } }, - { "andl", andl, NULL, 0, { 4 }, { 4, 4 } }, - { "andnl", andnl, NULL, 0, { 4 }, { 4, 4 } }, - { "avgsl", avgsl, NULL, 0, { 4 }, { 4, 4 } }, - { "avgul", avgul, NULL, 0, { 4 }, { 4, 4 } }, - { "cmpeql", cmpeql, NULL, 0, { 4 }, { 4, 4 } }, - { "cmpgtsl", cmpgtsl, NULL, 0, { 4 }, { 4, 4 } }, - { "copyl", copyl, NULL, 0, { 4 }, { 4 } }, - { "maxsl", maxsl, NULL, 0, { 4 }, { 4, 4 } }, - { "maxul", maxul, NULL, 0, { 4 }, { 4, 4 } }, - { "minsl", minsl, NULL, 0, { 4 }, { 4, 4 } }, - { "minul", minul, NULL, 0, { 4 }, { 4, 4 } }, - { "mulll", mulll, NULL, 0, { 4 }, { 4, 4 } }, - { "mulhsl", mulhsl, NULL, 0, { 4 }, { 4, 4 } }, - { "mulhul", mulhul, NULL, 0, { 4 }, { 4, 4 } }, - { "orl", orl, NULL, 0, { 4 }, { 4, 4 } }, - { "shll", shll, NULL, ORC_STATIC_OPCODE_SCALAR, { 4 }, { 4, 4 } }, - { "shrsl", shrsl, NULL, ORC_STATIC_OPCODE_SCALAR, { 4 }, { 4, 4 } }, - { "shrul", shrul, NULL, ORC_STATIC_OPCODE_SCALAR, { 4 }, { 4, 4 } }, - { "signl", signl, NULL, 0, { 4 }, { 4 } }, - { "subl", subl, NULL, 0, { 4 }, { 4, 4 } }, - { "subssl", subssl, NULL, 0, { 4 }, { 4, 4 } }, - { "subusl", subusl, NULL, 0, { 4 }, { 4, 4 } }, - { "xorl", xorl, NULL, 0, { 4 }, { 4, 4 } }, - - { "convsbw", convsbw, NULL, 0, { 2 }, { 1 } }, - { "convubw", convubw, NULL, 0, { 2 }, { 1 } }, - { "convswl", convswl, NULL, 0, { 4 }, { 2 } }, - { "convuwl", convuwl, NULL, 0, { 4 }, { 2 } }, + { "absl", absl, NULL, 0, { 4 }, { 4 }, emulate_absl }, + { "addl", addl, NULL, 0, { 4 }, { 4, 4 }, emulate_addl }, + { "addssl", addssl, NULL, 0, { 4 }, { 4, 4 }, emulate_addssl }, + { "addusl", addusl, NULL, 0, { 4 }, { 4, 4 }, emulate_addusl }, + { "andl", andl, NULL, 0, { 4 }, { 4, 4 }, emulate_andl }, + { "andnl", andnl, NULL, 0, { 4 }, { 4, 4 }, emulate_andnl }, + { "avgsl", avgsl, NULL, 0, { 4 }, { 4, 4 }, emulate_avgsl }, + { "avgul", avgul, NULL, 0, { 4 }, { 4, 4 }, emulate_avgul }, + { "cmpeql", cmpeql, NULL, 0, { 4 }, { 4, 4 }, emulate_cmpeql }, + { "cmpgtsl", cmpgtsl, NULL, 0, { 4 }, { 4, 4 }, emulate_cmpgtsl }, + { "copyl", copyl, NULL, 0, { 4 }, { 4 }, emulate_copyl }, + { "maxsl", maxsl, NULL, 0, { 4 }, { 4, 4 }, emulate_maxsl }, + { "maxul", maxul, NULL, 0, { 4 }, { 4, 4 }, emulate_maxul }, + { "minsl", minsl, NULL, 0, { 4 }, { 4, 4 }, emulate_minsl }, + { "minul", minul, NULL, 0, { 4 }, { 4, 4 }, emulate_minul }, + { "mulll", mulll, NULL, 0, { 4 }, { 4, 4 }, emulate_mulll }, + { "mulhsl", mulhsl, NULL, 0, { 4 }, { 4, 4 }, emulate_mulhsl }, + { "mulhul", mulhul, NULL, 0, { 4 }, { 4, 4 }, emulate_mulhul }, + { "orl", orl, NULL, 0, { 4 }, { 4, 4 }, emulate_orl }, + { "shll", shll, NULL, ORC_STATIC_OPCODE_SCALAR, { 4 }, { 4, 4 }, emulate_shll }, + { "shrsl", shrsl, NULL, ORC_STATIC_OPCODE_SCALAR, { 4 }, { 4, 4 }, emulate_shrsl }, + { "shrul", shrul, NULL, ORC_STATIC_OPCODE_SCALAR, { 4 }, { 4, 4 }, emulate_shrul }, + { "signl", signl, NULL, 0, { 4 }, { 4 }, emulate_signl }, + { "subl", subl, NULL, 0, { 4 }, { 4, 4 }, emulate_subl }, + { "subssl", subssl, NULL, 0, { 4 }, { 4, 4 }, emulate_subssl }, + { "subusl", subusl, NULL, 0, { 4 }, { 4, 4 }, emulate_subusl }, + { "xorl", xorl, NULL, 0, { 4 }, { 4, 4 }, emulate_xorl }, + + { "convsbw", convsbw, NULL, 0, { 2 }, { 1 }, emulate_convsbw }, + { "convubw", convubw, NULL, 0, { 2 }, { 1 }, emulate_convubw }, + { "convswl", convswl, NULL, 0, { 4 }, { 2 }, emulate_convswl }, + { "convuwl", convuwl, NULL, 0, { 4 }, { 2 }, emulate_convuwl }, #ifdef ENABLE_64BIT - { "convslq", convslq, NULL, 0, { 8 }, { 4 } }, - { "convulq", convulq, NULL, 0, { 8 }, { 4 } }, + { "convslq", convslq, NULL, 0, { 8 }, { 4 }, emulate_convslq }, + { "convulq", convulq, NULL, 0, { 8 }, { 4 }, emulate_convulq }, #endif - { "convwb", convwb, NULL, 0, { 1 }, { 2 } }, - { "convssswb", convssswb, NULL, 0, { 1 }, { 2 } }, - { "convsuswb", convsuswb, NULL, 0, { 1 }, { 2 } }, - { "convusswb", convusswb, NULL, 0, { 1 }, { 2 } }, - { "convuuswb", convuuswb, NULL, 0, { 1 }, { 2 } }, + { "convwb", convwb, NULL, 0, { 1 }, { 2 }, emulate_convwb }, + { "convssswb", convssswb, NULL, 0, { 1 }, { 2 }, emulate_convssswb }, + { "convsuswb", convsuswb, NULL, 0, { 1 }, { 2 }, emulate_convsuswb }, + { "convusswb", convusswb, NULL, 0, { 1 }, { 2 }, emulate_convusswb }, + { "convuuswb", convuuswb, NULL, 0, { 1 }, { 2 }, emulate_convuuswb }, - { "convlw", convlw, NULL, 0, { 2 }, { 4 } }, - { "convssslw", convssslw, NULL, 0, { 2 }, { 4 } }, - { "convsuslw", convsuslw, NULL, 0, { 2 }, { 4 } }, - { "convusslw", convusslw, NULL, 0, { 2 }, { 4 } }, - { "convuuslw", convuuslw, NULL, 0, { 2 }, { 4 } }, + { "convlw", convlw, NULL, 0, { 2 }, { 4 }, emulate_convlw }, + { "convssslw", convssslw, NULL, 0, { 2 }, { 4 }, emulate_convssslw }, + { "convsuslw", convsuslw, NULL, 0, { 2 }, { 4 }, emulate_convsuslw }, + { "convusslw", convusslw, NULL, 0, { 2 }, { 4 }, emulate_convusslw }, + { "convuuslw", convuuslw, NULL, 0, { 2 }, { 4 }, emulate_convuuslw }, #ifdef ENABLE_64BIT - { "convql", convql, NULL, 0, { 4 }, { 8 } }, - { "convssql", convssql, NULL, 0, { 4 }, { 8 } }, - { "convusql", convusql, NULL, 0, { 4 }, { 8 } }, + { "convql", convql, NULL, 0, { 4 }, { 8 }, emulate_convql }, + { "convssql", convssql, NULL, 0, { 4 }, { 8 }, emulate_convssql }, + { "convusql", convusql, NULL, 0, { 4 }, { 8 }, emulate_convusql }, #endif - { "mulsbw", mulsbw, NULL, 0, { 2 }, { 1, 1 } }, - { "mulubw", mulubw, NULL, 0, { 2 }, { 1, 1 } }, - { "mulswl", mulswl, NULL, 0, { 4 }, { 2, 2 } }, - { "muluwl", muluwl, NULL, 0, { 4 }, { 2, 2 } }, + { "mulsbw", mulsbw, NULL, 0, { 2 }, { 1, 1 }, emulate_mulsbw }, + { "mulubw", mulubw, NULL, 0, { 2 }, { 1, 1 }, emulate_mulubw }, + { "mulswl", mulswl, NULL, 0, { 4 }, { 2, 2 }, emulate_mulswl }, + { "muluwl", muluwl, NULL, 0, { 4 }, { 2, 2 }, emulate_muluwl }, #ifdef ENABLE_64BIT - { "mulslq", mulslq, NULL, 0, { 8 }, { 4, 4 } }, - { "mululq", mululq, NULL, 0, { 8 }, { 4, 4 } }, + { "mulslq", mulslq, NULL, 0, { 8 }, { 4, 4 }, emulate_mulslq }, + { "mululq", mululq, NULL, 0, { 8 }, { 4, 4 }, emulate_mululq }, #endif /* accumulators */ - { "accw", accw, NULL, ORC_STATIC_OPCODE_ACCUMULATOR, { 2 }, { 2 } }, - { "accl", accl, NULL, ORC_STATIC_OPCODE_ACCUMULATOR, { 4 }, { 4 } }, - { "accsadubl", accsadubl, NULL, ORC_STATIC_OPCODE_ACCUMULATOR, { 4 }, { 1, 1 } }, - - { "swapw", swapw, NULL, 0, { 2 }, { 2 } }, - { "swapl", swapl, NULL, 0, { 4 }, { 4 } }, - { "select0wb", select0wb, NULL, 0, { 1 }, { 2 } }, - { "select1wb", select1wb, NULL, 0, { 1 }, { 2 } }, - { "select0lw", select0lw, NULL, 0, { 2 }, { 4 } }, - { "select1lw", select1lw, NULL, 0, { 2 }, { 4 } }, - { "mergewl", mergewl, NULL, 0, { 4 }, { 2, 2 } }, - { "mergebw", mergebw, NULL, 0, { 2 }, { 1, 1 } }, - { "splitlw", splitlw, NULL, 0, { 2, 2 }, { 4 } }, - { "splitwb", splitwb, NULL, 0, { 1, 1 }, { 2 } }, + { "accw", accw, NULL, ORC_STATIC_OPCODE_ACCUMULATOR, { 2 }, { 2 }, emulate_accw }, + { "accl", accl, NULL, ORC_STATIC_OPCODE_ACCUMULATOR, { 4 }, { 4 }, emulate_accl }, + { "accsadubl", accsadubl, NULL, ORC_STATIC_OPCODE_ACCUMULATOR, { 4 }, { 1, 1 }, emulate_accsadubl }, + + { "swapw", swapw, NULL, 0, { 2 }, { 2 }, emulate_swapw }, + { "swapl", swapl, NULL, 0, { 4 }, { 4 }, emulate_swapl }, + { "select0wb", select0wb, NULL, 0, { 1 }, { 2 }, emulate_select0wb }, + { "select1wb", select1wb, NULL, 0, { 1 }, { 2 }, emulate_select1wb }, + { "select0lw", select0lw, NULL, 0, { 2 }, { 4 }, emulate_select0lw }, + { "select1lw", select1lw, NULL, 0, { 2 }, { 4 }, emulate_select1lw }, + { "mergewl", mergewl, NULL, 0, { 4 }, { 2, 2 }, emulate_mergewl }, + { "mergebw", mergebw, NULL, 0, { 2 }, { 1, 1 }, emulate_mergebw }, + { "splitlw", splitlw, NULL, 0, { 2, 2 }, { 4 }, emulate_splitlw }, + { "splitwb", splitwb, NULL, 0, { 1, 1 }, { 2 }, emulate_splitwb }, /* float ops */ - { "addf", addf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 } }, - { "subf", subf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 } }, - { "mulf", mulf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 } }, - { "divf", divf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 } }, - { "sqrtf", orc_sqrtf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4 } }, - { "maxf", maxf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 } }, - { "minf", minf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 } }, - { "cmpeqf", cmpeqf, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4, 4 } }, - { "cmpltf", cmpltf, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4, 4 } }, - { "cmplef", cmplef, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4, 4 } }, - { "convfl", convfl, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4 } }, - { "convlf", convlf, NULL, ORC_STATIC_OPCODE_FLOAT_DEST, { 4 }, { 4 } }, + { "addf", addf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 }, emulate_addf }, + { "subf", subf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 }, emulate_subf }, + { "mulf", mulf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 }, emulate_mulf }, + { "divf", divf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 }, emulate_divf }, + { "sqrtf", orc_sqrtf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4 }, emulate_sqrtf }, + { "maxf", maxf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 }, emulate_maxf }, + { "minf", minf, NULL, ORC_STATIC_OPCODE_FLOAT, { 4 }, { 4, 4 }, emulate_minf }, + { "cmpeqf", cmpeqf, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4, 4 }, emulate_cmpeqf }, + { "cmpltf", cmpltf, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4, 4 }, emulate_cmpltf }, + { "cmplef", cmplef, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4, 4 }, emulate_cmplef }, + { "convfl", convfl, NULL, ORC_STATIC_OPCODE_FLOAT_SRC, { 4 }, { 4 }, emulate_convfl }, + { "convlf", convlf, NULL, ORC_STATIC_OPCODE_FLOAT_DEST, { 4 }, { 4 }, emulate_convlf }, { "" } }; diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c index 844a8b5..d085f7b 100644 --- a/orc/orcprogram-c.c +++ b/orc/orcprogram-c.c @@ -102,6 +102,10 @@ orc_target_c_get_asm_preamble (void) "#define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))\n" "#define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))\n" "#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))\n" + "#define ORC_MIN_NORMAL (1.1754944909521339405e-38)\n" + "#define ORC_DENORMAL(x) (((x) > -ORC_MIN_NORMAL && (x) < ORC_MIN_NORMAL) ? ((x)<0 ? (-0.0f) : (0.0f)) : (x))\n" + "#define ORC_MINF(a,b) (isnan(a) ? a : isnan(b) ? b : ((a)<(b)) ? (a) : (b))\n" + "#define ORC_MAXF(a,b) (isnan(a) ? a : isnan(b) ? b : ((a)>(b)) ? (a) : (b))\n" "/* end Orc C target preamble */\n\n"; } @@ -129,24 +133,30 @@ static const char *varnames[] = { static void get_varname (char *s, OrcCompiler *compiler, int var) { - if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) { - sprintf(s, "ex->arrays[%d]", var); - } else { + if (compiler->target_flags & ORC_TARGET_C_NOEXEC) { if (var < 48) { strcpy (s, varnames[var]); } else { sprintf(s, "t%d", var-32); } + } else if (compiler->target_flags & ORC_TARGET_C_OPCODE) { + if (var < ORC_VAR_S1) { + sprintf(s, "ex->dest_ptrs[%d]", var-ORC_VAR_D1); + } else { + sprintf(s, "ex->src_ptrs[%d]", var-ORC_VAR_S1); + } + } else { + sprintf(s, "ex->arrays[%d]", var); } } static void get_varname_stride (char *s, OrcCompiler *compiler, int var) { - if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) { - sprintf(s, "ex->params[%d]", var); - } else { + if (compiler->target_flags & ORC_TARGET_C_NOEXEC) { sprintf(s, "%s_stride", varnames[var]); + } else { + sprintf(s, "ex->params[%d]", var); } } @@ -171,7 +181,8 @@ orc_compiler_c_assemble (OrcCompiler *compiler) ORC_ASM_CODE(compiler," int j;\n"); } if (compiler->program->constant_n == 0) { - if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) { + if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC) && + !(compiler->target_flags & ORC_TARGET_C_OPCODE)) { ORC_ASM_CODE(compiler," int n = ex->n;\n"); } } else { @@ -241,7 +252,19 @@ orc_compiler_c_assemble (OrcCompiler *compiler) break; case ORC_VAR_TYPE_PARAM: c_get_name (varname, compiler, i); - if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) { + if (compiler->target_flags & ORC_TARGET_C_NOEXEC) { + ORC_ASM_CODE(compiler," const %s %s = %s;\n", + var->is_float_param ? "float" : "int", + varname, varnames[i]); + } else if (compiler->target_flags & ORC_TARGET_C_OPCODE) { + if (var->is_float_param) { + ORC_ASM_CODE(compiler," const float %s = ((orc_union32 *)(ex->src_ptrs[%d]))->f;\n", + varname, i - ORC_VAR_P1 + compiler->program->n_src_vars); + } else { + ORC_ASM_CODE(compiler," const int %s = ((orc_union32 *)(ex->src_ptrs[%d]))->i;\n", + varname, i - ORC_VAR_P1 + compiler->program->n_src_vars); + } + } else { if (var->is_float_param) { ORC_ASM_CODE(compiler," const float %s = ((orc_union32 *)(ex->params+%d))->f;\n", varname, i); @@ -249,10 +272,6 @@ orc_compiler_c_assemble (OrcCompiler *compiler) ORC_ASM_CODE(compiler," const int %s = ex->params[%d];\n", varname, i); } - } else { - ORC_ASM_CODE(compiler," const %s %s = %s;\n", - var->is_float_param ? "float" : "int", - varname, varnames[i]); } break; default: @@ -374,20 +393,27 @@ orc_compiler_c_assemble (OrcCompiler *compiler) switch (var->vartype) { case ORC_VAR_TYPE_ACCUMULATOR: if (var->size == 2) { - if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) { - ORC_ASM_CODE(compiler," ex->accumulators[%d] = (%s & 0xffff);\n", - i - ORC_VAR_A1, varname); - } else { + if (compiler->target_flags & ORC_TARGET_C_NOEXEC) { ORC_ASM_CODE(compiler," *%s = (%s & 0xffff);\n", varnames[i], varname); + } else if (compiler->target_flags & ORC_TARGET_C_OPCODE) { + ORC_ASM_CODE(compiler," ((orc_union32 *)ex->dest_ptrs[%d])->i = " + "(%s + ((orc_union32 *)ex->dest_ptrs[%d])->i) & 0xffff;\n", + i - ORC_VAR_A1, varname, i - ORC_VAR_A1); + } else { + ORC_ASM_CODE(compiler," ex->accumulators[%d] = (%s & 0xffff);\n", + i - ORC_VAR_A1, varname); } } else { - if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) { - ORC_ASM_CODE(compiler," ex->accumulators[%d] = %s;\n", - i - ORC_VAR_A1, varname); - } else { + if (compiler->target_flags & ORC_TARGET_C_NOEXEC) { ORC_ASM_CODE(compiler," *%s = %s;\n", varnames[i], varname); + } else if (compiler->target_flags & ORC_TARGET_C_OPCODE) { + ORC_ASM_CODE(compiler," ((orc_union32 *)ex->dest_ptrs[%d])->i += %s;\n", + i - ORC_VAR_A1, varname); + } else { + ORC_ASM_CODE(compiler," ex->accumulators[%d] = %s;\n", + i - ORC_VAR_A1, varname); } } break; diff --git a/orc/orcprogram.h b/orc/orcprogram.h index daa03ed..a4b1a66 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -20,6 +20,8 @@ typedef struct _OrcFixup OrcFixup; typedef struct _OrcTarget OrcTarget; typedef void (*OrcOpcodeEmulateFunc)(OrcOpcodeExecutor *ex, void *user); +typedef void (*OrcOpcodeEmulateNFunc)(OrcOpcodeExecutor *ex, int n); +typedef void (*OrcOpcodeEmulate16Func)(OrcOpcodeExecutor *ex); typedef void (*OrcRuleEmitFunc)(OrcCompiler *p, void *user, OrcInstruction *insn); typedef void (*OrcExecutorFunc)(OrcExecutor *ex); @@ -75,6 +77,7 @@ enum { ORC_TARGET_C_C99 = (1<<0), ORC_TARGET_C_BARE = (1<<1), ORC_TARGET_C_NOEXEC = (1<<2), + ORC_TARGET_C_OPCODE = (1<<3), ORC_TARGET_FAST_NAN = (1<<30), ORC_TARGET_FAST_DENORMAL = (1<<31) }; @@ -269,6 +272,7 @@ struct _OrcStaticOpcode { unsigned int flags; int dest_size[ORC_STATIC_OPCODE_N_DEST]; int src_size[ORC_STATIC_OPCODE_N_SRC]; + OrcOpcodeEmulateNFunc emulateN; }; /** @@ -416,6 +420,11 @@ struct _OrcOpcodeExecutor { /*< private >*/ int src_values[ORC_STATIC_OPCODE_N_SRC]; int dest_values[ORC_STATIC_OPCODE_N_DEST]; + + OrcOpcodeEmulateNFunc emulateN; + + void *src_ptrs[ORC_STATIC_OPCODE_N_SRC]; + void *dest_ptrs[ORC_STATIC_OPCODE_N_DEST]; }; /**