From f19794a459b561fcca996cab9d747a595b1aee09 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sat, 26 Jun 2010 14:34:17 -0700 Subject: [PATCH] tools: add orc-bugreport --- tools/Makefile.am | 2 +- tools/orc-bugreport.c | 515 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 516 insertions(+), 1 deletion(-) create mode 100644 tools/orc-bugreport.c diff --git a/tools/Makefile.am b/tools/Makefile.am index ba302dd..64bd805 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,5 +1,5 @@ -bin_PROGRAMS = orcc +bin_PROGRAMS = orcc orc-bugreport AM_CFLAGS = $(ORC_CFLAGS) LDADD = $(ORC_LIBS) ../orc-test/liborc-test-@ORC_MAJORMINOR@.la diff --git a/tools/orc-bugreport.c b/tools/orc-bugreport.c new file mode 100644 index 0000000..dddbd87 --- /dev/null +++ b/tools/orc-bugreport.c @@ -0,0 +1,515 @@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include +#include +#include + +static char * read_file (const char *filename); + +void test_opcodes (void); + +int error = FALSE; + +int +main (int argc, char *argv[]) +{ + int i; + OrcProgram **programs; + const char *filename = NULL; + + orc_init (); + orc_test_init (); + + for(i=1;i Set debugging level\n"); + printf(" ORC_CODE=[KEYWORDS,...] Modify code generation\n"); + printf(" General keywords:\n"); + printf(" backup Always use backup function\n"); + printf(" debug Generate debuggable code (useful for backtraces on i386)\n"); + printf(" SSE keywords:\n"); + printf(" -sse2 Disable SSE2\n"); + printf(" -sse3 Disable SSE3\n"); + printf(" -ssse3 Disable SSEE3\n"); + printf(" -sse41 Disable SSE4.1\n"); + printf(" -sse42 Disable SSE4.2\n"); + printf(" -sse4a Disable SSE4a\n"); + printf(" -sse5 Disable SSE5\n"); + printf("\n"); + exit (0); + } + + filename = argv[i]; + } + + printf("Orc " VERSION " - integrated testing tool\n"); + + if (filename) { + int n; + int ret; + char *code; + + code = read_file (filename); + if (!code) { + printf("orc-bugreport: could not read file %s\n", filename); + exit(1); + } + + printf("Parsing %s\n", filename); + n = orc_parse (code, &programs); + + for(i=0;iname); + error = TRUE; + } + } + } else { + printf("Opcode test\n"); + test_opcodes(); + } + + { + int i; + int flags = orc_target_get_default_flags (orc_target_get_default()); + + printf("Compiler options: "); + for(i=0;i<32;i++){ + if (flags & (1<n_opcodes;i++){ + test_opcode_src (opcode_set->opcodes + i); + } + for(i=0;in_opcodes;i++){ + test_opcode_const (opcode_set->opcodes + i); + } + for(i=0;in_opcodes;i++){ + test_opcode_param (opcode_set->opcodes + i); + } + for(i=0;in_opcodes;i++){ + test_opcode_inplace (opcode_set->opcodes + i); + } + for(i=0;in_opcodes;i++){ + test_opcode_src_2d (opcode_set->opcodes + i); + } + for(i=0;in_opcodes;i++){ + test_opcode_src_const_n (opcode_set->opcodes + i); + } + for(i=0;in_opcodes;i++){ + test_opcode_src_const_n_2d (opcode_set->opcodes + i); + } +} + +void +test_opcode_src (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + int flags = 0; + + if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) { + return; + } + + p = orc_program_new (); + if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); + } else { + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + orc_program_add_source (p, opcode->src_size[0], "s1"); + if (opcode->src_size[1] != 0) { + orc_program_add_source (p, opcode->src_size[1], "s2"); + } + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_s_%s", opcode->name); + orc_program_set_name (p, s); + + if (opcode->dest_size[1] != 0) { + orc_program_append_dds_str (p, opcode->name, "d1", "d2", "s1"); + } else { + orc_program_append_str (p, opcode->name, "d1", "s1", "s2"); + } + + ret = orc_test_compare_output_full (p, flags); + if (!ret) { + printf("FAIL: %s src\n", opcode->name); + error = TRUE; + } + + orc_program_free (p); +} + +void +test_opcode_const (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + int flags = 0; + + if (opcode->src_size[1] == 0) { + return; + } + + p = orc_program_new (); + if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); + } else { + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + orc_program_add_source (p, opcode->src_size[0], "s1"); + orc_program_add_constant (p, opcode->src_size[1], 1, "c1"); + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_c_%s", opcode->name); + orc_program_set_name (p, s); + + orc_program_append_str (p, opcode->name, "d1", "s1", "c1"); + + ret = orc_test_compare_output_full (p, flags); + if (!ret) { + printf("FAIL: %s const\n", opcode->name); + error = TRUE; + } + + orc_program_free (p); +} + +void +test_opcode_param (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + int flags = 0; + + if (opcode->src_size[1] == 0) { + return; + } + p = orc_program_new (); + if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); + } else { + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + orc_program_add_source (p, opcode->src_size[0], "s1"); + orc_program_add_parameter (p, opcode->src_size[1], "p1"); + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_c_%s", opcode->name); + orc_program_set_name (p, s); + + orc_program_append_str (p, opcode->name, "d1", "s1", "p1"); + + ret = orc_test_compare_output_full (p, flags); + if (!ret) { + printf("FAIL: %s param\n", opcode->name); + error = TRUE; + } + + orc_program_free (p); +} + +void +test_opcode_inplace (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + int flags = 0; + + if (opcode->dest_size[0] != opcode->src_size[0]) return; + + if (opcode->flags & ORC_STATIC_OPCODE_SCALAR || + opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + return; + } + + p = orc_program_new (); + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + if (opcode->src_size[1] != 0) { + orc_program_add_source (p, opcode->src_size[0], "s2"); + } + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_inplace_%s", opcode->name); + orc_program_set_name (p, s); + + orc_program_append_str (p, opcode->name, "d1", "d1", "s2"); + + ret = orc_test_compare_output_full (p, flags); + if (!ret) { + printf("FAIL: %s inplace\n", opcode->name); + error = TRUE; + } + + orc_program_free (p); +} + +void +test_opcode_src_2d (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + int flags = 0; + + if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) { + return; + } + + p = orc_program_new (); + if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); + } else { + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + orc_program_add_source (p, opcode->src_size[0], "s1"); + if (opcode->src_size[1] != 0) { + orc_program_add_source (p, opcode->src_size[1], "s2"); + } + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_s_%s", opcode->name); + orc_program_set_name (p, s); + orc_program_set_2d (p); + + if (opcode->dest_size[1] != 0) { + orc_program_append_dds_str (p, opcode->name, "d1", "d2", "s1"); + } else { + orc_program_append_str (p, opcode->name, "d1", "s1", "s2"); + } + + ret = orc_test_compare_output_full (p, flags); + if (!ret) { + printf("FAIL: %s src_2d\n", opcode->name); + error = TRUE; + } + + orc_program_free (p); +} + +void +test_opcode_src_const_n (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + int flags = 0; + + if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) { + return; + } + + p = orc_program_new (); + if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); + } else { + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + orc_program_add_source (p, opcode->src_size[0], "s1"); + if (opcode->src_size[1] != 0) { + orc_program_add_source (p, opcode->src_size[1], "s2"); + } + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_s_%s", opcode->name); + orc_program_set_name (p, s); + orc_program_set_constant_n (p, 8); + + if (opcode->dest_size[1] != 0) { + orc_program_append_dds_str (p, opcode->name, "d1", "d2", "s1"); + } else { + orc_program_append_str (p, opcode->name, "d1", "s1", "s2"); + } + + ret = orc_test_compare_output_full (p, flags); + if (!ret) { + printf("FAIL: %s src_const_n\n", opcode->name); + error = TRUE; + } + + orc_program_free (p); +} + +void +test_opcode_src_const_n_2d (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + int flags = 0; + + if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) { + return; + } + + p = orc_program_new (); + if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); + } else { + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + orc_program_add_source (p, opcode->src_size[0], "s1"); + if (opcode->src_size[1] != 0) { + orc_program_add_source (p, opcode->src_size[1], "s2"); + } + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_s_%s", opcode->name); + orc_program_set_name (p, s); + orc_program_set_2d (p); + orc_program_set_constant_n (p, 8); + + if (opcode->dest_size[1] != 0) { + orc_program_append_dds_str (p, opcode->name, "d1", "d2", "s1"); + } else { + orc_program_append_str (p, opcode->name, "d1", "s1", "s2"); + } + + ret = orc_test_compare_output_full (p, flags); + if (!ret) { + printf("FAIL: %s src_const_n_2d\n", opcode->name); + error = TRUE; + } + + orc_program_free (p); +} + -- 2.7.4