9 #include <orc-test/orctest.h>
14 char * get_desc (OrcStaticOpcode *opcode);
15 char * get_code (OrcStaticOpcode *opcode);
18 main (int argc, char *argv[])
21 OrcOpcodeSet *opcode_set;
22 OrcTarget *targets[10];
23 unsigned int target_flags[10];
29 targets[0] = orc_target_get_by_name("sse");
30 target_flags[0] = orc_target_get_default_flags(targets[0]);
32 targets[1] = orc_target_get_by_name("mmx");
33 target_flags[1] = orc_target_get_default_flags(targets[1]);
35 targets[2] = orc_target_get_by_name("altivec");
36 target_flags[2] = orc_target_get_default_flags(targets[2]);
38 targets[3] = orc_target_get_by_name("arm");
39 target_flags[3] = orc_target_get_default_flags(targets[3]);
41 targets[4] = orc_target_get_by_name("c64x-c");
42 target_flags[4] = orc_target_get_default_flags(targets[4]);
47 "<table frame=\"all\" id=\"table-basictypes\" xreflabel=\"Table of Opcodes\">\n"
48 "<title>Table of Opcodes</title>\n"
49 "<tgroup cols=\"3\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n"
52 "<entry>opcode</entry>\n"
53 "<entry>destination size</entry>\n"
54 "<entry>source 1 size</entry>\n"
55 "<entry>source 2 size</entry>\n"
56 "<entry>description</entry>\n"
57 "<entry>pseudo code</entry>\n"
60 "<tbody valign=\"top\">\n");
62 opcode_set = orc_opcode_set_get ("sys");
64 for(i=0;i<opcode_set->n_opcodes;i++){
66 printf("<entry>%s</entry>\n", opcode_set->opcodes[i].name);
67 printf("<entry>%d</entry>\n", opcode_set->opcodes[i].dest_size[0]);
68 printf("<entry>%d</entry>\n", opcode_set->opcodes[i].src_size[0]);
69 if (opcode_set->opcodes[i].src_size[1]) {
70 printf("<entry>%d%s</entry>\n", opcode_set->opcodes[i].src_size[1],
71 (opcode_set->opcodes[i].flags & ORC_STATIC_OPCODE_SCALAR) ? "S" : "");
73 printf("<entry></entry>\n");
75 printf("<entry>%s</entry>\n", get_desc(&opcode_set->opcodes[i]));
76 printf("<entry>%s</entry>\n", get_code(&opcode_set->opcodes[i]));
94 { "absb", "(a < 0) ? -a : a", "absolute value" },
95 { "addb", "a + b", "add" },
96 { "addssb", "clamp(a + b)", "add with signed saturate" },
97 { "addusb", "clamp(a + b)", "add with unsigned saturate" },
98 { "andb", "a & b", "bitwise AND" },
99 { "andnb", "a & (~b)", "bitwise AND NOT" },
100 { "avgsb", "(a + b + 1)>>1", "signed average" },
101 { "avgub", "(a + b + 1)>>1", "unsigned average" },
102 { "cmpeqb", "(a == b) ? (~0) : 0", "compare equal" },
103 { "cmpgtsb", "(a > b) ? (~0) : 0", "compare greater than" },
104 { "copyb", "a", "copy" },
105 { "maxsb", "(a > b) ? a : b", "signed maximum" },
106 { "maxub", "(a > b) ? a : b", "unsigned maximum" },
107 { "minsb", "(a < b) ? a : b", "signed minimum" },
108 { "minub", "(a < b) ? a : b", "unsigned minimum" },
109 { "mullb", "a * b", "low bits of multiply" },
110 { "mulhsb", "(a * b) >> 8", "high bits of signed multiply" },
111 { "mulhub", "(a * b) >> 8", "high bits of unsigned multiply" },
112 { "orb", "a | b", "bitwise or" },
113 { "shlb", "a << b", "shift left" },
114 { "shrsb", "a >> b", "signed shift right" },
115 { "shrub", "a >> b", "unsigned shift right" },
116 { "signb", "sign(a)", "sign" },
117 { "subb", "a - b", "subtract" },
118 { "subssb", "clamp(a - b)", "subtract with signed saturate" },
119 { "subusb", "clamp(a - b)", "subtract with unsigned saturate" },
120 { "xorb", "a ^ b", "bitwise XOR" },
122 { "absw", "(a < 0) ? -a : a", "absolute value" },
123 { "addw", "a + b", "add" },
124 { "addssw", "clamp(a + b)", "add with signed saturate" },
125 { "addusw", "clamp(a + b)", "add with unsigned saturate" },
126 { "andw", "a & b", "bitwise AND" },
127 { "andnw", "a & (~b)", "bitwise AND NOT" },
128 { "avgsw", "(a + b + 1)>>1", "signed average" },
129 { "avguw", "(a + b + 1)>>1", "unsigned average" },
130 { "cmpeqw", "(a == b) ? (~0) : 0", "compare equal" },
131 { "cmpgtsw", "(a > b) ? (~0) : 0", "compare greater than" },
132 { "copyw", "a", "copy" },
133 { "maxsw", "(a > b) ? a : b", "signed maximum" },
134 { "maxuw", "(a > b) ? a : b", "unsigned maximum" },
135 { "minsw", "(a < b) ? a : b", "signed minimum" },
136 { "minuw", "(a < b) ? a : b", "unsigned minimum" },
137 { "mullw", "a * b", "low bits of multiply" },
138 { "mulhsw", "(a * b) >> 8", "high bits of signed multiply" },
139 { "mulhuw", "(a * b) >> 8", "high bits of unsigned multiply" },
140 { "orw", "a | b", "bitwise or" },
141 { "shlw", "a << b", "shift left" },
142 { "shrsw", "a >> b", "signed shift right" },
143 { "shruw", "a >> b", "unsigned shift right" },
144 { "signw", "sign(a)", "sign" },
145 { "subw", "a - b", "subtract" },
146 { "subssw", "clamp(a - b)", "subtract with signed saturate" },
147 { "subusw", "clamp(a - b)", "subtract with unsigned saturate" },
148 { "xorw", "a ^ b", "bitwise XOR" },
150 { "absl", "(a < 0) ? -a : a", "absolute value" },
151 { "addl", "a + b", "add" },
152 { "addssl", "clamp(a + b)", "add with signed saturate" },
153 { "addusl", "clamp(a + b)", "add with unsigned saturate" },
154 { "andl", "a & b", "bitwise AND" },
155 { "andnl", "a & (~b)", "bitwise AND NOT" },
156 { "avgsl", "(a + b + 1)>>1", "signed average" },
157 { "avgul", "(a + b + 1)>>1", "unsigned average" },
158 { "cmpeql", "(a == b) ? (~0) : 0", "compare equal" },
159 { "cmpgtsl", "(a > b) ? (~0) : 0", "compare greater than" },
160 { "copyl", "a", "copy" },
161 { "maxsl", "(a > b) ? a : b", "signed maximum" },
162 { "maxul", "(a > b) ? a : b", "unsigned maximum" },
163 { "minsl", "(a < b) ? a : b", "signed minimum" },
164 { "minul", "(a < b) ? a : b", "unsigned minimum" },
165 { "mulll", "a * b", "low bits of multiply" },
166 { "mulhsl", "(a * b) >> 16", "high bits of signed multiply" },
167 { "mulhul", "(a * b) >> 16", "high bits of unsigned multiply" },
168 { "orl", "a | b", "bitwise or" },
169 { "shll", "a << b", "shift left" },
170 { "shrsl", "a >> b", "signed shift right" },
171 { "shrul", "a >> b", "unsigned shift right" },
172 { "signl", "sign(a)", "sign" },
173 { "subl", "a - b", "subtract" },
174 { "subssl", "clamp(a - b)", "subtract with signed saturate" },
175 { "subusl", "clamp(a - b)", "subtract with unsigned saturate" },
176 { "xorl", "a ^ b", "bitwise XOR" },
178 { "convsbw", "a", "convert signed" },
179 { "convubw", "a", "convert unsigned" },
180 { "convswl", "a", "convert signed" },
181 { "convuwl", "a", "convert unsigned" },
182 { "convwb", "a", "convert" },
183 { "convssswb", "clamp(a)", "convert signed to signed with saturation" },
184 { "convsuswb", "clamp(a)", "convert signed to unsigned with saturation" },
185 { "convusswb", "clamp(a)", "convert unsigned to signed with saturation" },
186 { "convuuswb", "clamp(a)", "convert unsigned to unsigned with saturation" },
187 { "convlw", "a", "convert" },
188 { "convssslw", "clamp(a)", "convert signed to signed with saturation" },
189 { "convsuslw", "clamp(a)", "convert signed to unsigned with saturation" },
190 { "convusslw", "clamp(a)", "convert unsigned to signed with saturation" },
191 { "convuuslw", "clamp(a)", "convert unsigned to unsigned with saturation" },
192 { "mulsbw", "a * b", "multiply signed" },
193 { "mulubw", "a * b", "multiply unsigned" },
194 { "mulswl", "a * b", "multiply signed" },
195 { "muluwl", "a * b", "multiply unsigned" },
196 { "mergewl", "special", "merge halves" },
197 { "mergebw", "special", "merge halves" },
198 { "select0wb", "special", "select first half" },
199 { "select1wb", "special", "select second half" },
200 { "select0lw", "special", "select first half" },
201 { "select1lw", "special", "select second half" },
202 { "swapw", "special", "endianness swap" },
203 { "swapl", "special", "endianness swap" },
205 { "accw", "+= a", "accumulate" },
206 { "accl", "+= a", "accumulate" },
207 { "accsadubl", "+= abs(a - b)", "accumulate absolute difference" },
209 { "splitlw" , "special", "split first/second words" },
210 { "splitwb" , "special", "split first/second bytes" },
211 { "addf", "a + b", "add" },
212 { "subf", "a - b", "subtract" },
213 { "mulf", "a * b", "multiply" },
214 { "divf", "a / b", "divide" },
215 { "sqrtf", "sqrt(a)", "square root" },
216 { "maxf", "max(a,b)", "maximum" },
217 { "minf", "min(a,b)", "minimum" },
218 { "cmpeqf", "(a == b) ? (~0) : 0", "compare equal" },
219 { "cmpltf", "(a == b) ? (~0) : 0", "compare less than" },
220 { "cmplef", "(a == b) ? (~0) : 0", "compare less than or equal" },
221 { "convfl", "a", "convert float point to integer" },
222 { "convlf", "a", "convert integer to floating point" },
224 { "loadb", "array[i]", "load from memory" },
225 { "loadw", "array[i]", "load from memory" },
226 { "loadl", "array[i]", "load from memory" },
227 { "loadq", "array[i]", "load from memory" },
228 { "storeb", "special", "store to memory" },
229 { "storew", "special", "store to memory" },
230 { "storel", "special", "store to memory" },
231 { "storeq", "special", "store to memory" },
232 { "loadoffb", "array[i+offset]", "load from memory with offset" },
233 { "loadoffw", "array[i+offset]", "load from memory with offset" },
234 { "loadoffl", "array[i+offset]", "load from memory with offset" },
235 { "loadoffq", "array[i+offset]", "load from memory with offset" },
236 { "loadpb", "scalar", "load parameter or constant" },
237 { "loadpw", "scalar", "load parameter or constant" },
238 { "loadpl", "scalar", "load parameter or constant" },
239 { "loadpq", "scalar", "load parameter or constant" },
240 { "loadupdb", "array[i>>1]", "load upsampled duplicate" },
241 { "loadupib", "(array[i>>1] + array[(i+1)>>1] + 1)>>1",
242 "load upsampled interpolate" },
243 { "ldresnearb", "array[(b+c*i)>>8]", "load, nearest neighbor resampled" },
244 { "ldreslinb", "special", "load, bilinear resampled" },
245 { "ldresnearl", "array[(b+c*i)>>8]", "load, nearest neighbor resampled" },
246 { "ldreslinl", "special", "load, bilinear resampled" },
247 { "div255w", "a/255", "divide by 255" },
248 { "divluw", "clamp(a/(b & 255),0,255)", "saturated unsigned divide 16-bit by 8-bit" },
249 { "splatw3q", "special", "duplicates high 16-bits to lower 48 bits" },
250 { "splatbw", "special", "duplicates 8 bits to both halfs of 16 bits" },
251 { "splatbl", "special", "duplicates 8 bits to all parts of 32 bits" },
252 { "convql", "a", "convert" },
253 { "convslq", "a", "signed convert" },
254 { "convulq", "a", "unsigned convert" },
255 { "convhwb", "a>>8", "shift and convert" },
256 { "convhlw", "a>>16", "shift and convert" },
257 { "convsssql", "clamp(a)", "convert signed to signed with saturation" },
258 { "convsusql", "clamp(a)", "convert signed to unsigned with saturation" },
259 { "convussql", "clamp(a)", "convert unsigned to signed with saturation" },
260 { "convuusql", "clamp(a)", "convert unsigned to unsigned with saturation" },
266 get_desc (OrcStaticOpcode *opcode)
269 for(i=0;i<sizeof(ops)/sizeof(ops[0]);i++){
270 if (strcmp (opcode->name, ops[i].name) == 0) {
278 get_code (OrcStaticOpcode *opcode)
281 for(i=0;i<sizeof(ops)/sizeof(ops[0]);i++){
282 if (strcmp (opcode->name, ops[i].name) == 0) {