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