diff options
author | Wim Taymans <wtaymans@redhat.com> | 2016-04-25 12:45:25 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2016-04-25 12:45:25 +0200 |
commit | bacfc94cfffe1a19426513c929f6c5130dfb9f52 (patch) | |
tree | bd19cf477690b05ada0d577ef33b94bba979d259 | |
parent | 507654a3e0b050b98ee8a7088348fece83ada533 (diff) |
x86: fix some crashesorc-0.5
-rw-r--r-- | orc-test/orctest.c | 12 | ||||
-rw-r--r-- | orc/x86/orc-x86-compiler.c | 58 | ||||
-rw-r--r-- | orc/x86/orc-x86-label.h | 2 |
3 files changed, 40 insertions, 32 deletions
diff --git a/orc-test/orctest.c b/orc-test/orctest.c index 5d38400..2d66710 100644 --- a/orc-test/orctest.c +++ b/orc-test/orctest.c @@ -675,9 +675,7 @@ orc_test_compare_output_full (OrcProgram *program, int flags) } } #endif - } - for (i = 0; i < program->n_arrays; i++) { ex->arrays[i].value = a_exec[i]->data; ex->arrays[i].stride = a_exec[i]->stride; } @@ -700,6 +698,11 @@ orc_test_compare_output_full (OrcProgram *program, int flags) #endif for (i = 0; i < program->n_arrays; i++) { + OrcArray *arr = &program->arrays[i]; + + if (ORC_ARRAY_IS_CONST (arr)) + continue; + ex->arrays[i].value = a_emul[i]->data; ex->arrays[i].stride = a_emul[i]->stride; } @@ -714,6 +717,11 @@ orc_test_compare_output_full (OrcProgram *program, int flags) #endif for (i = 0; i < program->n_arrays; i++) { + OrcArray *arr = &program->arrays[i]; + + if (ORC_ARRAY_IS_CONST (arr)) + continue; + if (!orc_test_array_compare (a_exec[i], a_emul[i], flags)) { printf("dest array %d bad\n", i); bad = TRUE; diff --git a/orc/x86/orc-x86-compiler.c b/orc/x86/orc-x86-compiler.c index ad23395..b2e9aeb 100644 --- a/orc/x86/orc-x86-compiler.c +++ b/orc/x86/orc-x86-compiler.c @@ -1253,9 +1253,9 @@ label_x86_convff (OrcX86Compiler *c, OrcInstruction *insn, int cost) { OrcLabeler *l = GET_LABELER (c); - switch (INSN_BITS (insn)) { + switch (INSN_ARGBITS (insn)) { case 64: - switch (INSN_ARGBITS (insn)) { + switch (INSN_BITS (insn)) { case 32: orc_labeler_label (l, insn, ORC_X86_label_sse2_cvtpd2ps, cost + 1); break; @@ -1264,7 +1264,7 @@ label_x86_convff (OrcX86Compiler *c, OrcInstruction *insn, int cost) } break; case 32: - switch (INSN_ARGBITS (insn)) { + switch (INSN_BITS (insn)) { case 64: orc_labeler_label (l, insn, ORC_X86_label_sse2_cvtps2pd, cost + 1); break; @@ -1282,9 +1282,9 @@ label_x86_convfi (OrcX86Compiler *c, OrcInstruction *insn, int cost) { OrcLabeler *l = GET_LABELER (c); - switch (INSN_BITS (insn)) { + switch (INSN_ARGBITS (insn)) { case 32: - switch (INSN_ARGBITS (insn)) { + switch (INSN_BITS (insn)) { case 32: orc_labeler_label (l, insn, ORC_X86_label_sse2_cvttps2dq, cost + 1); break; @@ -1293,7 +1293,7 @@ label_x86_convfi (OrcX86Compiler *c, OrcInstruction *insn, int cost) } break; case 64: - switch (INSN_ARGBITS (insn)) { + switch (INSN_BITS (insn)) { case 32: orc_labeler_label (l, insn, ORC_X86_label_sse2_cvttpd2dq, cost + 1); break; @@ -1310,9 +1310,9 @@ label_x86_convif (OrcX86Compiler *c, OrcInstruction *insn, int cost) { OrcLabeler *l = GET_LABELER (c); - switch (INSN_BITS (insn)) { + switch (INSN_ARGBITS (insn)) { case 32: - switch (INSN_ARGBITS (insn)) { + switch (INSN_BITS (insn)) { case 32: orc_labeler_label (l, insn, ORC_X86_label_sse2_cvtdq2ps, cost + 1); break; @@ -1333,21 +1333,21 @@ record_label_x86 (OrcX86Compiler *c, OrcInstruction *insn) { OrcProgram *p = GET_PROGRAM (c); OrcLabeler *l = GET_LABELER (c); - OrcInstruction *arg[2]; - int cost; + const OrcInstructionInfo *info; + int i, cost; + + info = orc_instruction_get_info (insn->opcode); cost = 0; - if ((arg[0] = INSN_ARG (p, insn, 0))) { - if (!L_INSN_LABEL (l, arg[0])) - record_label_x86 (c, arg[0]); - cost += L_INSN_COST (l, arg[0]); - ORC_LOG ("arg0 %d cost %d", arg[0]->id, cost); - } - if ((arg[1] = INSN_ARG (p, insn, 1))) { - if (!L_INSN_LABEL (l, arg[1])) - record_label_x86 (c, arg[1]); - cost += L_INSN_COST (l, arg[1]); - ORC_LOG ("arg1 %d cost %d", arg[1]->id, cost); + for (i = 0; i < info->n_args; i++) { + if (ORC_INSTRUCTION_INFO_ARG_IS_INSN (info, i)) { + OrcInstruction *ai = INSN_ARG (p, insn, i); + if (!L_INSN_LABEL (l, ai)) { + record_label_x86 (c, ai); + cost += L_INSN_COST (l, ai); + ORC_LOG ("arg%d %d cost %d", i, ai->id, cost); + } + } } switch (insn->opcode) { @@ -2015,7 +2015,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) break; case ORC_X86_label_mmx_psllw: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) @@ -2028,7 +2028,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) } case ORC_X86_label_mmx_pslld: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) @@ -2040,7 +2040,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) } case ORC_X86_label_mmx_psllq: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) @@ -2052,7 +2052,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) } case ORC_X86_label_mmx_psraw: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) @@ -2064,7 +2064,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) } case ORC_X86_label_mmx_psrad: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) @@ -2076,7 +2076,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) } case ORC_X86_label_mmx_psrlw: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) @@ -2088,7 +2088,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) } case ORC_X86_label_mmx_psrld: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) @@ -2100,7 +2100,7 @@ reduce_x86 (OrcX86Compiler *c, OrcInstruction *insn) } case ORC_X86_label_mmx_psrlq: { - OrcArray *arr = GET_ARRAY (p, insn->arg[2]); + OrcArray *arr = GET_ARRAY (p, insn->arg[1]); if (ORC_ARRAY_IS_CONST (arr)) { orc_uint64 val = orc_load_vector_u (arr->bits, arr->value, 0); for (i = 0; i < arg[0]->n_lanes; i++) diff --git a/orc/x86/orc-x86-label.h b/orc/x86/orc-x86-label.h index 09e59e4..0e1f102 100644 --- a/orc/x86/orc-x86-label.h +++ b/orc/x86/orc-x86-label.h @@ -3,7 +3,7 @@ #define _ORC_X86_LABEL_H_ typedef enum { - ORC_X86_label_load, + ORC_X86_label_load = 1, ORC_X86_label_store, /* other labels */ |