neon: Fix bug in copy[bwl] rule
authorDavid Schleef <ds@schleef.org>
Tue, 16 Jun 2009 04:39:27 +0000 (21:39 -0700)
committerDavid Schleef <ds@schleef.org>
Tue, 16 Jun 2009 04:39:27 +0000 (21:39 -0700)
orc/orcrules-neon.c
testsuite/Makefile.am
testsuite/compile_parse_neon.c [new file with mode: 0644]

index db675f2..6f308ad 100644 (file)
@@ -713,12 +713,9 @@ orc_neon_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \
     ORC_ASM_CODE(p,"  " insn_name " %s, %s\n", \
         orc_neon_reg_name (p->vars[insn->dest_args[0]].alloc), \
         orc_neon_reg_name (p->vars[insn->src_args[0]].alloc)); \
-    x |= (p->vars[insn->dest_args[0]].alloc&0xf)<<16; \
-    x |= ((p->vars[insn->dest_args[0]].alloc>>4)&0x1)<<7; \
-    x |= (p->vars[insn->src_args[0]].alloc&0xf)<<12; \
-    x |= ((p->vars[insn->src_args[0]].alloc>>4)&0x1)<<22; \
-    x |= (p->vars[insn->src_args[0]].alloc&0xf)<<0; \
-    x |= ((p->vars[insn->src_args[0]].alloc>>4)&0x1)<<5; \
+    x = NEON_BINARY(code, p->vars[insn->dest_args[0]].alloc, \
+        p->vars[insn->src_args[0]].alloc, \
+        p->vars[insn->src_args[0]].alloc); \
     orc_arm_emit (p, x); \
   } \
 }
index 051ca05..686af20 100644 (file)
@@ -21,11 +21,13 @@ CLEANFILES = temp-orc-test-*
 TESTS += compile_opcodes_sys_neon \
        compile_opcodes_float_neon \
        compile_opcodes_pixel_neon \
-       compile_opcodes_sys_c64x
+       compile_opcodes_sys_c64x \
+       compile_parse_neon
 orcbin_PROGRAMS += compile_opcodes_sys_neon \
        compile_opcodes_float_neon \
        compile_opcodes_pixel_neon \
-       compile_opcodes_sys_c64x
+       compile_opcodes_sys_c64x \
+       compile_parse_neon
 
 AM_CFLAGS = $(ORC_CFLAGS)
 LIBS = $(ORC_LIBS) $(top_builddir)/orc-test/liborc-test-@ORC_MAJORMINOR@.la
diff --git a/testsuite/compile_parse_neon.c b/testsuite/compile_parse_neon.c
new file mode 100644 (file)
index 0000000..548d7ac
--- /dev/null
@@ -0,0 +1,90 @@
+
+#include <orc/orc.h>
+#include <orc-test/orctest.h>
+#include <orc/orcparse.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static char * read_file (const char *filename);
+void output_code (OrcProgram *p, FILE *output);
+void output_code_header (OrcProgram *p, FILE *output);
+void output_code_test (OrcProgram *p, FILE *output);
+
+int error = FALSE;
+
+int
+main (int argc, char *argv[])
+{
+  char *code;
+  int n;
+  int i;
+  OrcProgram **programs;
+  const char *filename = "test.orc";
+
+  orc_init ();
+  orc_test_init ();
+
+  if (argc >= 2) {
+    filename = argv[1];
+  }
+  code = read_file (filename);
+  if (!code) {
+    printf("compile_parse_test <file.orc>\n");
+    exit(1);
+  }
+
+  n = orc_parse (code, &programs);
+
+  for(i=0;i<n;i++){
+    OrcCompileResult ret;
+
+    ret = orc_test_gcc_compile_neon (programs[i]);
+    if (ret == ORC_TEST_FAILED) {
+      printf("%s", orc_program_get_asm_code (programs[i]));
+      error = TRUE;
+    }
+  }
+
+  if (error) return 1;
+  return 0;
+}
+
+
+static char *
+read_file (const char *filename)
+{
+  FILE *file = NULL;
+  char *contents = NULL;
+  long size;
+  int ret;
+
+  file = fopen (filename, "r");
+  if (file == NULL) return NULL;
+
+  ret = fseek (file, 0, SEEK_END);
+  if (ret < 0) goto bail;
+
+  size = ftell (file);
+  if (size < 0) goto bail;
+
+  ret = fseek (file, 0, SEEK_SET);
+  if (ret < 0) goto bail;
+
+  contents = malloc (size + 1);
+  if (contents == NULL) goto bail;
+
+  ret = fread (contents, size, 1, file);
+  if (ret < 0) goto bail;
+
+  contents[size] = 0;
+
+  return contents;
+bail:
+  /* something failed */
+  if (file) fclose (file);
+  if (contents) free (contents);
+
+  return NULL;
+}
+