1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef opcode_tilepro_h
22#define opcode_tilepro_h
23
24#include <arch/opcode.h>
25
26
27enum
28{
29 TILEPRO_MAX_OPERANDS = 5
30};
31
32typedef enum
33{
34 TILEPRO_OPC_BPT,
35 TILEPRO_OPC_INFO,
36 TILEPRO_OPC_INFOL,
37 TILEPRO_OPC_J,
38 TILEPRO_OPC_JAL,
39 TILEPRO_OPC_MOVE,
40 TILEPRO_OPC_MOVE_SN,
41 TILEPRO_OPC_MOVEI,
42 TILEPRO_OPC_MOVEI_SN,
43 TILEPRO_OPC_MOVELI,
44 TILEPRO_OPC_MOVELI_SN,
45 TILEPRO_OPC_MOVELIS,
46 TILEPRO_OPC_PREFETCH,
47 TILEPRO_OPC_RAISE,
48 TILEPRO_OPC_ADD,
49 TILEPRO_OPC_ADD_SN,
50 TILEPRO_OPC_ADDB,
51 TILEPRO_OPC_ADDB_SN,
52 TILEPRO_OPC_ADDBS_U,
53 TILEPRO_OPC_ADDBS_U_SN,
54 TILEPRO_OPC_ADDH,
55 TILEPRO_OPC_ADDH_SN,
56 TILEPRO_OPC_ADDHS,
57 TILEPRO_OPC_ADDHS_SN,
58 TILEPRO_OPC_ADDI,
59 TILEPRO_OPC_ADDI_SN,
60 TILEPRO_OPC_ADDIB,
61 TILEPRO_OPC_ADDIB_SN,
62 TILEPRO_OPC_ADDIH,
63 TILEPRO_OPC_ADDIH_SN,
64 TILEPRO_OPC_ADDLI,
65 TILEPRO_OPC_ADDLI_SN,
66 TILEPRO_OPC_ADDLIS,
67 TILEPRO_OPC_ADDS,
68 TILEPRO_OPC_ADDS_SN,
69 TILEPRO_OPC_ADIFFB_U,
70 TILEPRO_OPC_ADIFFB_U_SN,
71 TILEPRO_OPC_ADIFFH,
72 TILEPRO_OPC_ADIFFH_SN,
73 TILEPRO_OPC_AND,
74 TILEPRO_OPC_AND_SN,
75 TILEPRO_OPC_ANDI,
76 TILEPRO_OPC_ANDI_SN,
77 TILEPRO_OPC_AULI,
78 TILEPRO_OPC_AVGB_U,
79 TILEPRO_OPC_AVGB_U_SN,
80 TILEPRO_OPC_AVGH,
81 TILEPRO_OPC_AVGH_SN,
82 TILEPRO_OPC_BBNS,
83 TILEPRO_OPC_BBNS_SN,
84 TILEPRO_OPC_BBNST,
85 TILEPRO_OPC_BBNST_SN,
86 TILEPRO_OPC_BBS,
87 TILEPRO_OPC_BBS_SN,
88 TILEPRO_OPC_BBST,
89 TILEPRO_OPC_BBST_SN,
90 TILEPRO_OPC_BGEZ,
91 TILEPRO_OPC_BGEZ_SN,
92 TILEPRO_OPC_BGEZT,
93 TILEPRO_OPC_BGEZT_SN,
94 TILEPRO_OPC_BGZ,
95 TILEPRO_OPC_BGZ_SN,
96 TILEPRO_OPC_BGZT,
97 TILEPRO_OPC_BGZT_SN,
98 TILEPRO_OPC_BITX,
99 TILEPRO_OPC_BITX_SN,
100 TILEPRO_OPC_BLEZ,
101 TILEPRO_OPC_BLEZ_SN,
102 TILEPRO_OPC_BLEZT,
103 TILEPRO_OPC_BLEZT_SN,
104 TILEPRO_OPC_BLZ,
105 TILEPRO_OPC_BLZ_SN,
106 TILEPRO_OPC_BLZT,
107 TILEPRO_OPC_BLZT_SN,
108 TILEPRO_OPC_BNZ,
109 TILEPRO_OPC_BNZ_SN,
110 TILEPRO_OPC_BNZT,
111 TILEPRO_OPC_BNZT_SN,
112 TILEPRO_OPC_BYTEX,
113 TILEPRO_OPC_BYTEX_SN,
114 TILEPRO_OPC_BZ,
115 TILEPRO_OPC_BZ_SN,
116 TILEPRO_OPC_BZT,
117 TILEPRO_OPC_BZT_SN,
118 TILEPRO_OPC_CLZ,
119 TILEPRO_OPC_CLZ_SN,
120 TILEPRO_OPC_CRC32_32,
121 TILEPRO_OPC_CRC32_32_SN,
122 TILEPRO_OPC_CRC32_8,
123 TILEPRO_OPC_CRC32_8_SN,
124 TILEPRO_OPC_CTZ,
125 TILEPRO_OPC_CTZ_SN,
126 TILEPRO_OPC_DRAIN,
127 TILEPRO_OPC_DTLBPR,
128 TILEPRO_OPC_DWORD_ALIGN,
129 TILEPRO_OPC_DWORD_ALIGN_SN,
130 TILEPRO_OPC_FINV,
131 TILEPRO_OPC_FLUSH,
132 TILEPRO_OPC_FNOP,
133 TILEPRO_OPC_ICOH,
134 TILEPRO_OPC_ILL,
135 TILEPRO_OPC_INTHB,
136 TILEPRO_OPC_INTHB_SN,
137 TILEPRO_OPC_INTHH,
138 TILEPRO_OPC_INTHH_SN,
139 TILEPRO_OPC_INTLB,
140 TILEPRO_OPC_INTLB_SN,
141 TILEPRO_OPC_INTLH,
142 TILEPRO_OPC_INTLH_SN,
143 TILEPRO_OPC_INV,
144 TILEPRO_OPC_IRET,
145 TILEPRO_OPC_JALB,
146 TILEPRO_OPC_JALF,
147 TILEPRO_OPC_JALR,
148 TILEPRO_OPC_JALRP,
149 TILEPRO_OPC_JB,
150 TILEPRO_OPC_JF,
151 TILEPRO_OPC_JR,
152 TILEPRO_OPC_JRP,
153 TILEPRO_OPC_LB,
154 TILEPRO_OPC_LB_SN,
155 TILEPRO_OPC_LB_U,
156 TILEPRO_OPC_LB_U_SN,
157 TILEPRO_OPC_LBADD,
158 TILEPRO_OPC_LBADD_SN,
159 TILEPRO_OPC_LBADD_U,
160 TILEPRO_OPC_LBADD_U_SN,
161 TILEPRO_OPC_LH,
162 TILEPRO_OPC_LH_SN,
163 TILEPRO_OPC_LH_U,
164 TILEPRO_OPC_LH_U_SN,
165 TILEPRO_OPC_LHADD,
166 TILEPRO_OPC_LHADD_SN,
167 TILEPRO_OPC_LHADD_U,
168 TILEPRO_OPC_LHADD_U_SN,
169 TILEPRO_OPC_LNK,
170 TILEPRO_OPC_LNK_SN,
171 TILEPRO_OPC_LW,
172 TILEPRO_OPC_LW_SN,
173 TILEPRO_OPC_LW_NA,
174 TILEPRO_OPC_LW_NA_SN,
175 TILEPRO_OPC_LWADD,
176 TILEPRO_OPC_LWADD_SN,
177 TILEPRO_OPC_LWADD_NA,
178 TILEPRO_OPC_LWADD_NA_SN,
179 TILEPRO_OPC_MAXB_U,
180 TILEPRO_OPC_MAXB_U_SN,
181 TILEPRO_OPC_MAXH,
182 TILEPRO_OPC_MAXH_SN,
183 TILEPRO_OPC_MAXIB_U,
184 TILEPRO_OPC_MAXIB_U_SN,
185 TILEPRO_OPC_MAXIH,
186 TILEPRO_OPC_MAXIH_SN,
187 TILEPRO_OPC_MF,
188 TILEPRO_OPC_MFSPR,
189 TILEPRO_OPC_MINB_U,
190 TILEPRO_OPC_MINB_U_SN,
191 TILEPRO_OPC_MINH,
192 TILEPRO_OPC_MINH_SN,
193 TILEPRO_OPC_MINIB_U,
194 TILEPRO_OPC_MINIB_U_SN,
195 TILEPRO_OPC_MINIH,
196 TILEPRO_OPC_MINIH_SN,
197 TILEPRO_OPC_MM,
198 TILEPRO_OPC_MNZ,
199 TILEPRO_OPC_MNZ_SN,
200 TILEPRO_OPC_MNZB,
201 TILEPRO_OPC_MNZB_SN,
202 TILEPRO_OPC_MNZH,
203 TILEPRO_OPC_MNZH_SN,
204 TILEPRO_OPC_MTSPR,
205 TILEPRO_OPC_MULHH_SS,
206 TILEPRO_OPC_MULHH_SS_SN,
207 TILEPRO_OPC_MULHH_SU,
208 TILEPRO_OPC_MULHH_SU_SN,
209 TILEPRO_OPC_MULHH_UU,
210 TILEPRO_OPC_MULHH_UU_SN,
211 TILEPRO_OPC_MULHHA_SS,
212 TILEPRO_OPC_MULHHA_SS_SN,
213 TILEPRO_OPC_MULHHA_SU,
214 TILEPRO_OPC_MULHHA_SU_SN,
215 TILEPRO_OPC_MULHHA_UU,
216 TILEPRO_OPC_MULHHA_UU_SN,
217 TILEPRO_OPC_MULHHSA_UU,
218 TILEPRO_OPC_MULHHSA_UU_SN,
219 TILEPRO_OPC_MULHL_SS,
220 TILEPRO_OPC_MULHL_SS_SN,
221 TILEPRO_OPC_MULHL_SU,
222 TILEPRO_OPC_MULHL_SU_SN,
223 TILEPRO_OPC_MULHL_US,
224 TILEPRO_OPC_MULHL_US_SN,
225 TILEPRO_OPC_MULHL_UU,
226 TILEPRO_OPC_MULHL_UU_SN,
227 TILEPRO_OPC_MULHLA_SS,
228 TILEPRO_OPC_MULHLA_SS_SN,
229 TILEPRO_OPC_MULHLA_SU,
230 TILEPRO_OPC_MULHLA_SU_SN,
231 TILEPRO_OPC_MULHLA_US,
232 TILEPRO_OPC_MULHLA_US_SN,
233 TILEPRO_OPC_MULHLA_UU,
234 TILEPRO_OPC_MULHLA_UU_SN,
235 TILEPRO_OPC_MULHLSA_UU,
236 TILEPRO_OPC_MULHLSA_UU_SN,
237 TILEPRO_OPC_MULLL_SS,
238 TILEPRO_OPC_MULLL_SS_SN,
239 TILEPRO_OPC_MULLL_SU,
240 TILEPRO_OPC_MULLL_SU_SN,
241 TILEPRO_OPC_MULLL_UU,
242 TILEPRO_OPC_MULLL_UU_SN,
243 TILEPRO_OPC_MULLLA_SS,
244 TILEPRO_OPC_MULLLA_SS_SN,
245 TILEPRO_OPC_MULLLA_SU,
246 TILEPRO_OPC_MULLLA_SU_SN,
247 TILEPRO_OPC_MULLLA_UU,
248 TILEPRO_OPC_MULLLA_UU_SN,
249 TILEPRO_OPC_MULLLSA_UU,
250 TILEPRO_OPC_MULLLSA_UU_SN,
251 TILEPRO_OPC_MVNZ,
252 TILEPRO_OPC_MVNZ_SN,
253 TILEPRO_OPC_MVZ,
254 TILEPRO_OPC_MVZ_SN,
255 TILEPRO_OPC_MZ,
256 TILEPRO_OPC_MZ_SN,
257 TILEPRO_OPC_MZB,
258 TILEPRO_OPC_MZB_SN,
259 TILEPRO_OPC_MZH,
260 TILEPRO_OPC_MZH_SN,
261 TILEPRO_OPC_NAP,
262 TILEPRO_OPC_NOP,
263 TILEPRO_OPC_NOR,
264 TILEPRO_OPC_NOR_SN,
265 TILEPRO_OPC_OR,
266 TILEPRO_OPC_OR_SN,
267 TILEPRO_OPC_ORI,
268 TILEPRO_OPC_ORI_SN,
269 TILEPRO_OPC_PACKBS_U,
270 TILEPRO_OPC_PACKBS_U_SN,
271 TILEPRO_OPC_PACKHB,
272 TILEPRO_OPC_PACKHB_SN,
273 TILEPRO_OPC_PACKHS,
274 TILEPRO_OPC_PACKHS_SN,
275 TILEPRO_OPC_PACKLB,
276 TILEPRO_OPC_PACKLB_SN,
277 TILEPRO_OPC_PCNT,
278 TILEPRO_OPC_PCNT_SN,
279 TILEPRO_OPC_RL,
280 TILEPRO_OPC_RL_SN,
281 TILEPRO_OPC_RLI,
282 TILEPRO_OPC_RLI_SN,
283 TILEPRO_OPC_S1A,
284 TILEPRO_OPC_S1A_SN,
285 TILEPRO_OPC_S2A,
286 TILEPRO_OPC_S2A_SN,
287 TILEPRO_OPC_S3A,
288 TILEPRO_OPC_S3A_SN,
289 TILEPRO_OPC_SADAB_U,
290 TILEPRO_OPC_SADAB_U_SN,
291 TILEPRO_OPC_SADAH,
292 TILEPRO_OPC_SADAH_SN,
293 TILEPRO_OPC_SADAH_U,
294 TILEPRO_OPC_SADAH_U_SN,
295 TILEPRO_OPC_SADB_U,
296 TILEPRO_OPC_SADB_U_SN,
297 TILEPRO_OPC_SADH,
298 TILEPRO_OPC_SADH_SN,
299 TILEPRO_OPC_SADH_U,
300 TILEPRO_OPC_SADH_U_SN,
301 TILEPRO_OPC_SB,
302 TILEPRO_OPC_SBADD,
303 TILEPRO_OPC_SEQ,
304 TILEPRO_OPC_SEQ_SN,
305 TILEPRO_OPC_SEQB,
306 TILEPRO_OPC_SEQB_SN,
307 TILEPRO_OPC_SEQH,
308 TILEPRO_OPC_SEQH_SN,
309 TILEPRO_OPC_SEQI,
310 TILEPRO_OPC_SEQI_SN,
311 TILEPRO_OPC_SEQIB,
312 TILEPRO_OPC_SEQIB_SN,
313 TILEPRO_OPC_SEQIH,
314 TILEPRO_OPC_SEQIH_SN,
315 TILEPRO_OPC_SH,
316 TILEPRO_OPC_SHADD,
317 TILEPRO_OPC_SHL,
318 TILEPRO_OPC_SHL_SN,
319 TILEPRO_OPC_SHLB,
320 TILEPRO_OPC_SHLB_SN,
321 TILEPRO_OPC_SHLH,
322 TILEPRO_OPC_SHLH_SN,
323 TILEPRO_OPC_SHLI,
324 TILEPRO_OPC_SHLI_SN,
325 TILEPRO_OPC_SHLIB,
326 TILEPRO_OPC_SHLIB_SN,
327 TILEPRO_OPC_SHLIH,
328 TILEPRO_OPC_SHLIH_SN,
329 TILEPRO_OPC_SHR,
330 TILEPRO_OPC_SHR_SN,
331 TILEPRO_OPC_SHRB,
332 TILEPRO_OPC_SHRB_SN,
333 TILEPRO_OPC_SHRH,
334 TILEPRO_OPC_SHRH_SN,
335 TILEPRO_OPC_SHRI,
336 TILEPRO_OPC_SHRI_SN,
337 TILEPRO_OPC_SHRIB,
338 TILEPRO_OPC_SHRIB_SN,
339 TILEPRO_OPC_SHRIH,
340 TILEPRO_OPC_SHRIH_SN,
341 TILEPRO_OPC_SLT,
342 TILEPRO_OPC_SLT_SN,
343 TILEPRO_OPC_SLT_U,
344 TILEPRO_OPC_SLT_U_SN,
345 TILEPRO_OPC_SLTB,
346 TILEPRO_OPC_SLTB_SN,
347 TILEPRO_OPC_SLTB_U,
348 TILEPRO_OPC_SLTB_U_SN,
349 TILEPRO_OPC_SLTE,
350 TILEPRO_OPC_SLTE_SN,
351 TILEPRO_OPC_SLTE_U,
352 TILEPRO_OPC_SLTE_U_SN,
353 TILEPRO_OPC_SLTEB,
354 TILEPRO_OPC_SLTEB_SN,
355 TILEPRO_OPC_SLTEB_U,
356 TILEPRO_OPC_SLTEB_U_SN,
357 TILEPRO_OPC_SLTEH,
358 TILEPRO_OPC_SLTEH_SN,
359 TILEPRO_OPC_SLTEH_U,
360 TILEPRO_OPC_SLTEH_U_SN,
361 TILEPRO_OPC_SLTH,
362 TILEPRO_OPC_SLTH_SN,
363 TILEPRO_OPC_SLTH_U,
364 TILEPRO_OPC_SLTH_U_SN,
365 TILEPRO_OPC_SLTI,
366 TILEPRO_OPC_SLTI_SN,
367 TILEPRO_OPC_SLTI_U,
368 TILEPRO_OPC_SLTI_U_SN,
369 TILEPRO_OPC_SLTIB,
370 TILEPRO_OPC_SLTIB_SN,
371 TILEPRO_OPC_SLTIB_U,
372 TILEPRO_OPC_SLTIB_U_SN,
373 TILEPRO_OPC_SLTIH,
374 TILEPRO_OPC_SLTIH_SN,
375 TILEPRO_OPC_SLTIH_U,
376 TILEPRO_OPC_SLTIH_U_SN,
377 TILEPRO_OPC_SNE,
378 TILEPRO_OPC_SNE_SN,
379 TILEPRO_OPC_SNEB,
380 TILEPRO_OPC_SNEB_SN,
381 TILEPRO_OPC_SNEH,
382 TILEPRO_OPC_SNEH_SN,
383 TILEPRO_OPC_SRA,
384 TILEPRO_OPC_SRA_SN,
385 TILEPRO_OPC_SRAB,
386 TILEPRO_OPC_SRAB_SN,
387 TILEPRO_OPC_SRAH,
388 TILEPRO_OPC_SRAH_SN,
389 TILEPRO_OPC_SRAI,
390 TILEPRO_OPC_SRAI_SN,
391 TILEPRO_OPC_SRAIB,
392 TILEPRO_OPC_SRAIB_SN,
393 TILEPRO_OPC_SRAIH,
394 TILEPRO_OPC_SRAIH_SN,
395 TILEPRO_OPC_SUB,
396 TILEPRO_OPC_SUB_SN,
397 TILEPRO_OPC_SUBB,
398 TILEPRO_OPC_SUBB_SN,
399 TILEPRO_OPC_SUBBS_U,
400 TILEPRO_OPC_SUBBS_U_SN,
401 TILEPRO_OPC_SUBH,
402 TILEPRO_OPC_SUBH_SN,
403 TILEPRO_OPC_SUBHS,
404 TILEPRO_OPC_SUBHS_SN,
405 TILEPRO_OPC_SUBS,
406 TILEPRO_OPC_SUBS_SN,
407 TILEPRO_OPC_SW,
408 TILEPRO_OPC_SWADD,
409 TILEPRO_OPC_SWINT0,
410 TILEPRO_OPC_SWINT1,
411 TILEPRO_OPC_SWINT2,
412 TILEPRO_OPC_SWINT3,
413 TILEPRO_OPC_TBLIDXB0,
414 TILEPRO_OPC_TBLIDXB0_SN,
415 TILEPRO_OPC_TBLIDXB1,
416 TILEPRO_OPC_TBLIDXB1_SN,
417 TILEPRO_OPC_TBLIDXB2,
418 TILEPRO_OPC_TBLIDXB2_SN,
419 TILEPRO_OPC_TBLIDXB3,
420 TILEPRO_OPC_TBLIDXB3_SN,
421 TILEPRO_OPC_TNS,
422 TILEPRO_OPC_TNS_SN,
423 TILEPRO_OPC_WH64,
424 TILEPRO_OPC_XOR,
425 TILEPRO_OPC_XOR_SN,
426 TILEPRO_OPC_XORI,
427 TILEPRO_OPC_XORI_SN,
428 TILEPRO_OPC_NONE
429} tilepro_mnemonic;
430
431
432
433
434typedef enum
435{
436 TILEPRO_PIPELINE_X0,
437 TILEPRO_PIPELINE_X1,
438 TILEPRO_PIPELINE_Y0,
439 TILEPRO_PIPELINE_Y1,
440 TILEPRO_PIPELINE_Y2,
441} tilepro_pipeline;
442
443#define tilepro_is_x_pipeline(p) ((int)(p) <= (int)TILEPRO_PIPELINE_X1)
444
445typedef enum
446{
447 TILEPRO_OP_TYPE_REGISTER,
448 TILEPRO_OP_TYPE_IMMEDIATE,
449 TILEPRO_OP_TYPE_ADDRESS,
450 TILEPRO_OP_TYPE_SPR
451} tilepro_operand_type;
452
453struct tilepro_operand
454{
455
456 tilepro_operand_type type;
457
458
459 signed int default_reloc : 16;
460
461
462 unsigned int num_bits : 5;
463
464
465 unsigned int is_signed : 1;
466
467
468 unsigned int is_src_reg : 1;
469
470
471 unsigned int is_dest_reg : 1;
472
473
474 unsigned int is_pc_relative : 1;
475
476
477 unsigned int rightshift : 2;
478
479
480 tilepro_bundle_bits (*insert) (int op);
481
482
483 unsigned int (*extract) (tilepro_bundle_bits bundle);
484};
485
486
487extern const struct tilepro_operand tilepro_operands[];
488
489
490extern const unsigned short * const
491tilepro_bundle_decoder_fsms[TILEPRO_NUM_PIPELINE_ENCODINGS];
492
493
494struct tilepro_opcode
495{
496
497 const char *name;
498
499
500 tilepro_mnemonic mnemonic;
501
502
503
504
505
506
507
508
509 unsigned char pipes;
510
511
512 unsigned char num_operands;
513
514
515 unsigned char implicitly_written_register;
516
517
518 unsigned char can_bundle;
519
520
521
522 unsigned char operands[TILEPRO_NUM_PIPELINE_ENCODINGS][TILEPRO_MAX_OPERANDS];
523
524};
525
526extern const struct tilepro_opcode tilepro_opcodes[];
527
528
529
530struct tilepro_decoded_instruction
531{
532 const struct tilepro_opcode *opcode;
533 const struct tilepro_operand *operands[TILEPRO_MAX_OPERANDS];
534 int operand_values[TILEPRO_MAX_OPERANDS];
535};
536
537
538
539extern int parse_insn_tilepro(tilepro_bundle_bits bits,
540 unsigned int pc,
541 struct tilepro_decoded_instruction
542 decoded[TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE]);
543
544
545
546
547
548extern const struct tilepro_opcode *
549find_opcode(tilepro_bundle_bits bits, tilepro_pipeline pipe);
550
551
552
553#endif
554