Initial commit to Gerrit
[profile/ivi/orc.git] / testsuite / compile_opcodes_sys_c.c
1
2 #include "config.h"
3
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 #include <orc/orc.h>
8 #include <orc-test/orctest.h>
9
10
11 int error = FALSE;
12 int verbose = FALSE;
13
14 void test_opcode (OrcStaticOpcode *opcode);
15 void test_opcode_const (OrcStaticOpcode *opcode);
16 void test_opcode_param (OrcStaticOpcode *opcode);
17
18 int
19 main (int argc, char *argv[])
20 {
21   int i;
22   OrcOpcodeSet *opcode_set;
23
24   orc_init();
25   orc_test_init();
26
27   opcode_set = orc_opcode_set_get ("sys");
28
29   for(i=0;i<opcode_set->n_opcodes;i++){
30     if (verbose) printf("/* %s %d,%d,%d */\n",
31         opcode_set->opcodes[i].name,
32         opcode_set->opcodes[i].dest_size[0],
33         opcode_set->opcodes[i].src_size[0],
34         opcode_set->opcodes[i].src_size[1]);
35     test_opcode (opcode_set->opcodes + i);
36   }
37
38   if (error) {
39     printf("test failed\n");
40     return 1;
41   } else {
42     printf("test passed\n");
43     return 0;
44   }
45 }
46
47 void
48 test_opcode (OrcStaticOpcode *opcode)
49 {
50   OrcProgram *p;
51   OrcCompileResult result;
52   const char *s;
53
54   p = orc_test_get_program_for_opcode (opcode);
55   if (!p) return;
56
57   result = orc_program_compile_for_target (p, orc_target_get_by_name("c"));
58   if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
59     s = orc_program_get_asm_code (p);
60     if (s != NULL) {
61       printf("%s\n", s);
62     } else {
63       printf("no code\n");
64     }
65     error = TRUE;
66     return;
67   }
68
69   orc_program_free (p);
70 }
71
72 void
73 test_opcode_const (OrcStaticOpcode *opcode)
74 {
75   OrcProgram *p;
76   OrcCompileResult result;
77   const char *s;
78
79   p = orc_test_get_program_for_opcode_const (opcode);
80   if (!p) return;
81
82   result = orc_program_compile_for_target (p, orc_target_get_by_name("c"));
83   if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
84     s = orc_program_get_asm_code (p);
85     if (s != NULL) {
86       printf("%s\n", s);
87     } else {
88       printf("no code\n");
89     }
90     error = TRUE;
91     return;
92   }
93
94   orc_program_free (p);
95 }
96
97 void
98 test_opcode_param (OrcStaticOpcode *opcode)
99 {
100   OrcProgram *p;
101   OrcCompileResult result;
102   const char *s;
103
104   p = orc_test_get_program_for_opcode_param (opcode);
105   if (!p) return;
106
107   result = orc_program_compile_for_target (p, orc_target_get_by_name("c"));
108   if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) {
109     s = orc_program_get_asm_code (p);
110     if (s != NULL) {
111       printf("%s\n", s);
112     } else {
113       printf("no code\n");
114     }
115     error = TRUE;
116     return;
117   }
118
119   orc_program_free (p);
120 }
121
122
123
124