tests: add orcc test
authorDavid Schleef <ds@schleef.org>
Thu, 9 Jul 2009 19:12:39 +0000 (12:12 -0700)
committerDavid Schleef <ds@schleef.org>
Thu, 9 Jul 2009 19:12:39 +0000 (12:12 -0700)
configure.ac
testsuite/Makefile.am
testsuite/generate_opcodes_sys.c [new file with mode: 0644]
testsuite/orcc/Makefile.am [new file with mode: 0644]

index a071866..cbfaa0a 100644 (file)
@@ -123,6 +123,7 @@ orc-float/Makefile
 orc-pixel/Makefile
 orc-test/Makefile
 testsuite/Makefile
+testsuite/orcc/Makefile
 examples/Makefile
 tools/Makefile
 orc-uninstalled.pc
index 686af20..c01e7f8 100644 (file)
@@ -1,4 +1,6 @@
 
+SUBDIRS = orcc
+
 TESTS = \
        compile_opcodes_sys_c \
        compile_opcodes_float_c \
@@ -14,7 +16,8 @@ XFAIL_TESTS = \
        exec_opcodes_float \
        exec_opcodes_pixel
 
-orcbin_PROGRAMS = $(TESTS) generate_xml_table generate_xml_table2
+orcbin_PROGRAMS = $(TESTS) generate_xml_table generate_xml_table2 \
+       generate_opcodes_sys
 
 CLEANFILES = temp-orc-test-*
 
diff --git a/testsuite/generate_opcodes_sys.c b/testsuite/generate_opcodes_sys.c
new file mode 100644 (file)
index 0000000..a1ebd0f
--- /dev/null
@@ -0,0 +1,64 @@
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <orc/orc.h>
+#include <orc-test/orctest.h>
+
+
+int error = FALSE;
+
+void test_opcode (OrcStaticOpcode *opcode);
+void test_opcode_const (OrcStaticOpcode *opcode);
+void test_opcode_param (OrcStaticOpcode *opcode);
+
+int
+main (int argc, char *argv[])
+{
+  int i;
+  OrcOpcodeSet *opcode_set;
+  OrcStaticOpcode *opcode;
+  const char *d1;
+
+  orc_init();
+  orc_test_init();
+
+  opcode_set = orc_opcode_set_get ("sys");
+
+  for(i=0;i<opcode_set->n_opcodes;i++){
+    opcode = opcode_set->opcodes + i;
+
+    if (opcode->dest_size[0] == 0 ||
+        opcode->src_size[0] == 0) {
+      printf("# skipping %s\n\n", opcode->name);
+      continue;
+    }
+
+    printf(".function orc_%s\n", opcode->name);
+    if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) {
+      printf(".accumulator %d a1\n", opcode->dest_size[0]);
+      d1 = "a1";
+    } else {
+      printf(".dest %d d1\n", opcode->dest_size[0]);
+      d1 = "d1";
+    }
+    printf(".source %d s1\n", opcode->src_size[0]);
+    if (opcode->src_size[1]) {
+      printf(".source %d s2\n", opcode->src_size[1]);
+    }
+    printf("\n");
+    if (opcode->src_size[1]) {
+      printf("%s %s, s1, s2\n", opcode->name, d1);
+    } else {
+      printf("%s %s, s1\n", opcode->name, d1);
+    }
+    printf("\n");
+    printf("\n");
+  }
+
+  if (error) return 1;
+  return 0;
+}
+
diff --git a/testsuite/orcc/Makefile.am b/testsuite/orcc/Makefile.am
new file mode 100644 (file)
index 0000000..5e96c82
--- /dev/null
@@ -0,0 +1,19 @@
+
+
+TESTS = orc_test
+
+noinst_PROGRAMS = orc_test
+
+
+AM_CFLAGS = $(ORC_CFLAGS)
+LIBS = $(ORC_LIBS) $(top_builddir)/orc-test/liborc-test-@ORC_MAJORMINOR@.la
+
+CLEANFILES = testorc.c testorc.h orc_test.c
+
+orc:
+       ../../tools/orcc test.orc
+       cp out.c testorc.c
+       cp out.h testorc.h
+       cp test_out.c orc_test.c
+
+