From: David Schleef Date: Mon, 2 Aug 2010 01:34:41 +0000 (-0700) Subject: mmx: Fix problems in recent commit X-Git-Tag: orc-0.4.7~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77bed0558d6b83db229f3c305beb6348ad870b6b;p=platform%2Fupstream%2Forc.git mmx: Fix problems in recent commit --- diff --git a/orc/orcprogram-mmx.c b/orc/orcprogram-mmx.c index 5de2fe1..40a9d64 100644 --- a/orc/orcprogram-mmx.c +++ b/orc/orcprogram-mmx.c @@ -199,10 +199,26 @@ orc_compiler_mmx_init (OrcCompiler *compiler) } compiler->valid_regs[compiler->exec_reg] = 0; -#ifndef MMX - compiler->loop_shift = 5 - orc_program_get_max_var_size (compiler->program); -#else - compiler->loop_shift = 4 - orc_program_get_max_var_size (compiler->program); + switch (orc_program_get_max_var_size (compiler->program)) { + case 1: + compiler->loop_shift = 4; + break; + case 2: + compiler->loop_shift = 3; + break; + case 4: + compiler->loop_shift = 2; + break; + case 8: + compiler->loop_shift = 1; + break; + default: + ORC_ERROR("unhandled max var size %d", + orc_program_get_max_var_size (compiler->program)); + break; + } +#ifdef MMX + compiler->loop_shift--; #endif compiler->unroll_shift = 1; @@ -239,7 +255,7 @@ mmx_save_accumulators (OrcCompiler *compiler) #ifndef MMX orc_mmx_emit_pshufd (compiler, ORC_MMX_SHUF(1,1,1,1), src, compiler->tmpreg); - if (compiler->vars[i].size == 2) { /* moo */ + if (compiler->vars[i].size == 2) { orc_mmx_emit_660f (compiler, "paddw", 0xfd, compiler->tmpreg, src); } else { orc_mmx_emit_660f (compiler, "paddd", 0xfe, compiler->tmpreg, src); @@ -295,9 +311,9 @@ mmx_load_constant (OrcCompiler *compiler, int reg, int size, int value) orc_x86_emit_mov_imm_reg (compiler, 4, value, compiler->gp_tmpreg); orc_x86_emit_mov_reg_mmx (compiler, compiler->gp_tmpreg, reg); #ifndef MMX - orc_mmx_emit_pshufd (compiler, 0, reg, reg); + orc_mmx_emit_pshufd (compiler, ORC_MMX_SHUF(0,0,0,0), reg, reg); #else - orc_mmx_emit_pshufw (compiler, 0, reg, reg); + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(1,0,1,0), reg, reg); #endif } @@ -702,6 +718,8 @@ orc_compiler_mmx_assemble (OrcCompiler *compiler) if (set_mxcsr) { orc_mmx_restore_mxcsr (compiler); } +#else + orc_x86_emit_emms (compiler); #endif orc_x86_emit_epilogue (compiler); diff --git a/orc/orcprogram-sse.c b/orc/orcprogram-sse.c index 8252c69..4ff17d2 100644 --- a/orc/orcprogram-sse.c +++ b/orc/orcprogram-sse.c @@ -199,10 +199,26 @@ orc_compiler_sse_init (OrcCompiler *compiler) } compiler->valid_regs[compiler->exec_reg] = 0; -#ifndef MMX - compiler->loop_shift = 5 - orc_program_get_max_var_size (compiler->program); -#else - compiler->loop_shift = 4 - orc_program_get_max_var_size (compiler->program); + switch (orc_program_get_max_var_size (compiler->program)) { + case 1: + compiler->loop_shift = 4; + break; + case 2: + compiler->loop_shift = 3; + break; + case 4: + compiler->loop_shift = 2; + break; + case 8: + compiler->loop_shift = 1; + break; + default: + ORC_ERROR("unhandled max var size %d", + orc_program_get_max_var_size (compiler->program)); + break; + } +#ifdef MMX + compiler->loop_shift--; #endif compiler->unroll_shift = 1; @@ -295,9 +311,9 @@ sse_load_constant (OrcCompiler *compiler, int reg, int size, int value) orc_x86_emit_mov_imm_reg (compiler, 4, value, compiler->gp_tmpreg); orc_x86_emit_mov_reg_sse (compiler, compiler->gp_tmpreg, reg); #ifndef MMX - orc_sse_emit_pshufd (compiler, 0, reg, reg); + orc_sse_emit_pshufd (compiler, ORC_SSE_SHUF(0,0,0,0), reg, reg); #else - orc_mmx_emit_pshufw (compiler, 0, reg, reg); + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(1,0,1,0), reg, reg); #endif } @@ -702,6 +718,8 @@ orc_compiler_sse_assemble (OrcCompiler *compiler) if (set_mxcsr) { orc_sse_restore_mxcsr (compiler); } +#else + orc_x86_emit_emms (compiler); #endif orc_x86_emit_epilogue (compiler); diff --git a/orc/orcrules-mmx.c b/orc/orcrules-mmx.c index e7f9fe9..9f5fbd7 100644 --- a/orc/orcrules-mmx.c +++ b/orc/orcrules-mmx.c @@ -32,15 +32,17 @@ mmx_rule_loadpX (OrcCompiler *compiler, void *user, OrcInstruction *insn) if (src->size == 1) { orc_mmx_emit_punpcklbw (compiler, reg, reg); } +#ifndef MMX if (src->size <= 2) { -#ifdef MMX - orc_mmx_emit_pshufw (compiler, 0, reg, reg); -#else orc_mmx_emit_pshuflw (compiler, 0, reg, reg); -#endif } -#ifndef MMX orc_mmx_emit_pshufd (compiler, 0, reg, reg); +#else + if (src->size <= 2) { + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(0,0,0,0), reg, reg); + } else { + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(1,0,1,0), reg, reg); + } #endif } else if (src->vartype == ORC_VAR_TYPE_CONST) { int value = src->value; @@ -64,6 +66,8 @@ mmx_rule_loadpX (OrcCompiler *compiler, void *user, OrcInstruction *insn) orc_x86_emit_mov_reg_mmx (compiler, compiler->gp_tmpreg, reg); #ifndef MMX orc_mmx_emit_pshufd (compiler, 0, reg, reg); +#else + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(1,0,1,0), reg, reg); #endif } } @@ -1263,8 +1267,13 @@ orc_compiler_mmx_register_rules (OrcTarget *target) orc_rule_register (rule_set, #x , mmx_rule_ ## x, NULL) /* SSE 2 */ +#ifndef MMX rule_set = orc_rule_set_new (orc_opcode_set_get("sys"), target, ORC_TARGET_MMX_MMXEXT); +#else + rule_set = orc_rule_set_new (orc_opcode_set_get("sys"), target, + ORC_TARGET_MMX_MMX); +#endif orc_rule_register (rule_set, "loadb", mmx_rule_loadX, NULL); orc_rule_register (rule_set, "loadw", mmx_rule_loadX, NULL); diff --git a/orc/orcrules-sse.c b/orc/orcrules-sse.c index ad049cb..556f3f6 100644 --- a/orc/orcrules-sse.c +++ b/orc/orcrules-sse.c @@ -32,15 +32,17 @@ sse_rule_loadpX (OrcCompiler *compiler, void *user, OrcInstruction *insn) if (src->size == 1) { orc_sse_emit_punpcklbw (compiler, reg, reg); } +#ifndef MMX if (src->size <= 2) { -#ifdef MMX - orc_mmx_emit_pshufw (compiler, 0, reg, reg); -#else orc_sse_emit_pshuflw (compiler, 0, reg, reg); -#endif } -#ifndef MMX orc_sse_emit_pshufd (compiler, 0, reg, reg); +#else + if (src->size <= 2) { + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(0,0,0,0), reg, reg); + } else { + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(1,0,1,0), reg, reg); + } #endif } else if (src->vartype == ORC_VAR_TYPE_CONST) { int value = src->value; @@ -64,6 +66,8 @@ sse_rule_loadpX (OrcCompiler *compiler, void *user, OrcInstruction *insn) orc_x86_emit_mov_reg_sse (compiler, compiler->gp_tmpreg, reg); #ifndef MMX orc_sse_emit_pshufd (compiler, 0, reg, reg); +#else + orc_mmx_emit_pshufw (compiler, ORC_MMX_SHUF(1,0,1,0), reg, reg); #endif } } @@ -1263,8 +1267,13 @@ orc_compiler_sse_register_rules (OrcTarget *target) orc_rule_register (rule_set, #x , sse_rule_ ## x, NULL) /* SSE 2 */ +#ifndef MMX rule_set = orc_rule_set_new (orc_opcode_set_get("sys"), target, ORC_TARGET_SSE_SSE2); +#else + rule_set = orc_rule_set_new (orc_opcode_set_get("sys"), target, + ORC_TARGET_MMX_MMX); +#endif orc_rule_register (rule_set, "loadb", sse_rule_loadX, NULL); orc_rule_register (rule_set, "loadw", sse_rule_loadX, NULL);