]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - include/opcode/tilegx.h
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / include / opcode / tilegx.h
CommitLineData
aa137e4d
NC
1/* TILE-Gx opcode information.
2 *
250d07de 3 * Copyright (C) 2011-2021 Free Software Foundation, Inc.
aa137e4d
NC
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21#ifndef opcode_tile_h
22#define opcode_tile_h
23
f63c1776
PA
24#ifdef __cplusplus
25extern "C" {
26#endif
27
aa137e4d
NC
28typedef unsigned long long tilegx_bundle_bits;
29
30
31enum
32{
33 TILEGX_MAX_OPERANDS = 4 /* bfexts */
34};
35
36typedef enum
37{
38 TILEGX_OPC_BPT,
39 TILEGX_OPC_INFO,
40 TILEGX_OPC_INFOL,
6f7be959
WL
41 TILEGX_OPC_LD4S_TLS,
42 TILEGX_OPC_LD_TLS,
aa137e4d
NC
43 TILEGX_OPC_MOVE,
44 TILEGX_OPC_MOVEI,
45 TILEGX_OPC_MOVELI,
46 TILEGX_OPC_PREFETCH,
47 TILEGX_OPC_PREFETCH_ADD_L1,
48 TILEGX_OPC_PREFETCH_ADD_L1_FAULT,
49 TILEGX_OPC_PREFETCH_ADD_L2,
50 TILEGX_OPC_PREFETCH_ADD_L2_FAULT,
51 TILEGX_OPC_PREFETCH_ADD_L3,
52 TILEGX_OPC_PREFETCH_ADD_L3_FAULT,
53 TILEGX_OPC_PREFETCH_L1,
54 TILEGX_OPC_PREFETCH_L1_FAULT,
55 TILEGX_OPC_PREFETCH_L2,
56 TILEGX_OPC_PREFETCH_L2_FAULT,
57 TILEGX_OPC_PREFETCH_L3,
58 TILEGX_OPC_PREFETCH_L3_FAULT,
59 TILEGX_OPC_RAISE,
60 TILEGX_OPC_ADD,
61 TILEGX_OPC_ADDI,
62 TILEGX_OPC_ADDLI,
63 TILEGX_OPC_ADDX,
64 TILEGX_OPC_ADDXI,
65 TILEGX_OPC_ADDXLI,
66 TILEGX_OPC_ADDXSC,
67 TILEGX_OPC_AND,
68 TILEGX_OPC_ANDI,
69 TILEGX_OPC_BEQZ,
70 TILEGX_OPC_BEQZT,
71 TILEGX_OPC_BFEXTS,
72 TILEGX_OPC_BFEXTU,
73 TILEGX_OPC_BFINS,
74 TILEGX_OPC_BGEZ,
75 TILEGX_OPC_BGEZT,
76 TILEGX_OPC_BGTZ,
77 TILEGX_OPC_BGTZT,
78 TILEGX_OPC_BLBC,
79 TILEGX_OPC_BLBCT,
80 TILEGX_OPC_BLBS,
81 TILEGX_OPC_BLBST,
82 TILEGX_OPC_BLEZ,
83 TILEGX_OPC_BLEZT,
84 TILEGX_OPC_BLTZ,
85 TILEGX_OPC_BLTZT,
86 TILEGX_OPC_BNEZ,
87 TILEGX_OPC_BNEZT,
88 TILEGX_OPC_CLZ,
89 TILEGX_OPC_CMOVEQZ,
90 TILEGX_OPC_CMOVNEZ,
91 TILEGX_OPC_CMPEQ,
92 TILEGX_OPC_CMPEQI,
93 TILEGX_OPC_CMPEXCH,
94 TILEGX_OPC_CMPEXCH4,
95 TILEGX_OPC_CMPLES,
96 TILEGX_OPC_CMPLEU,
97 TILEGX_OPC_CMPLTS,
98 TILEGX_OPC_CMPLTSI,
99 TILEGX_OPC_CMPLTU,
100 TILEGX_OPC_CMPLTUI,
101 TILEGX_OPC_CMPNE,
102 TILEGX_OPC_CMUL,
103 TILEGX_OPC_CMULA,
104 TILEGX_OPC_CMULAF,
105 TILEGX_OPC_CMULF,
106 TILEGX_OPC_CMULFR,
107 TILEGX_OPC_CMULH,
108 TILEGX_OPC_CMULHR,
109 TILEGX_OPC_CRC32_32,
110 TILEGX_OPC_CRC32_8,
111 TILEGX_OPC_CTZ,
112 TILEGX_OPC_DBLALIGN,
113 TILEGX_OPC_DBLALIGN2,
114 TILEGX_OPC_DBLALIGN4,
115 TILEGX_OPC_DBLALIGN6,
116 TILEGX_OPC_DRAIN,
117 TILEGX_OPC_DTLBPR,
118 TILEGX_OPC_EXCH,
119 TILEGX_OPC_EXCH4,
120 TILEGX_OPC_FDOUBLE_ADD_FLAGS,
121 TILEGX_OPC_FDOUBLE_ADDSUB,
122 TILEGX_OPC_FDOUBLE_MUL_FLAGS,
123 TILEGX_OPC_FDOUBLE_PACK1,
124 TILEGX_OPC_FDOUBLE_PACK2,
125 TILEGX_OPC_FDOUBLE_SUB_FLAGS,
126 TILEGX_OPC_FDOUBLE_UNPACK_MAX,
127 TILEGX_OPC_FDOUBLE_UNPACK_MIN,
128 TILEGX_OPC_FETCHADD,
129 TILEGX_OPC_FETCHADD4,
130 TILEGX_OPC_FETCHADDGEZ,
131 TILEGX_OPC_FETCHADDGEZ4,
132 TILEGX_OPC_FETCHAND,
133 TILEGX_OPC_FETCHAND4,
134 TILEGX_OPC_FETCHOR,
135 TILEGX_OPC_FETCHOR4,
136 TILEGX_OPC_FINV,
137 TILEGX_OPC_FLUSH,
138 TILEGX_OPC_FLUSHWB,
139 TILEGX_OPC_FNOP,
140 TILEGX_OPC_FSINGLE_ADD1,
141 TILEGX_OPC_FSINGLE_ADDSUB2,
142 TILEGX_OPC_FSINGLE_MUL1,
143 TILEGX_OPC_FSINGLE_MUL2,
144 TILEGX_OPC_FSINGLE_PACK1,
145 TILEGX_OPC_FSINGLE_PACK2,
146 TILEGX_OPC_FSINGLE_SUB1,
147 TILEGX_OPC_ICOH,
148 TILEGX_OPC_ILL,
149 TILEGX_OPC_INV,
150 TILEGX_OPC_IRET,
151 TILEGX_OPC_J,
152 TILEGX_OPC_JAL,
153 TILEGX_OPC_JALR,
154 TILEGX_OPC_JALRP,
155 TILEGX_OPC_JR,
156 TILEGX_OPC_JRP,
157 TILEGX_OPC_LD,
158 TILEGX_OPC_LD1S,
159 TILEGX_OPC_LD1S_ADD,
160 TILEGX_OPC_LD1U,
161 TILEGX_OPC_LD1U_ADD,
162 TILEGX_OPC_LD2S,
163 TILEGX_OPC_LD2S_ADD,
164 TILEGX_OPC_LD2U,
165 TILEGX_OPC_LD2U_ADD,
166 TILEGX_OPC_LD4S,
167 TILEGX_OPC_LD4S_ADD,
168 TILEGX_OPC_LD4U,
169 TILEGX_OPC_LD4U_ADD,
170 TILEGX_OPC_LD_ADD,
171 TILEGX_OPC_LDNA,
172 TILEGX_OPC_LDNA_ADD,
173 TILEGX_OPC_LDNT,
174 TILEGX_OPC_LDNT1S,
175 TILEGX_OPC_LDNT1S_ADD,
176 TILEGX_OPC_LDNT1U,
177 TILEGX_OPC_LDNT1U_ADD,
178 TILEGX_OPC_LDNT2S,
179 TILEGX_OPC_LDNT2S_ADD,
180 TILEGX_OPC_LDNT2U,
181 TILEGX_OPC_LDNT2U_ADD,
182 TILEGX_OPC_LDNT4S,
183 TILEGX_OPC_LDNT4S_ADD,
184 TILEGX_OPC_LDNT4U,
185 TILEGX_OPC_LDNT4U_ADD,
186 TILEGX_OPC_LDNT_ADD,
187 TILEGX_OPC_LNK,
188 TILEGX_OPC_MF,
189 TILEGX_OPC_MFSPR,
190 TILEGX_OPC_MM,
191 TILEGX_OPC_MNZ,
192 TILEGX_OPC_MTSPR,
193 TILEGX_OPC_MUL_HS_HS,
194 TILEGX_OPC_MUL_HS_HU,
195 TILEGX_OPC_MUL_HS_LS,
196 TILEGX_OPC_MUL_HS_LU,
197 TILEGX_OPC_MUL_HU_HU,
198 TILEGX_OPC_MUL_HU_LS,
199 TILEGX_OPC_MUL_HU_LU,
200 TILEGX_OPC_MUL_LS_LS,
201 TILEGX_OPC_MUL_LS_LU,
202 TILEGX_OPC_MUL_LU_LU,
203 TILEGX_OPC_MULA_HS_HS,
204 TILEGX_OPC_MULA_HS_HU,
205 TILEGX_OPC_MULA_HS_LS,
206 TILEGX_OPC_MULA_HS_LU,
207 TILEGX_OPC_MULA_HU_HU,
208 TILEGX_OPC_MULA_HU_LS,
209 TILEGX_OPC_MULA_HU_LU,
210 TILEGX_OPC_MULA_LS_LS,
211 TILEGX_OPC_MULA_LS_LU,
212 TILEGX_OPC_MULA_LU_LU,
213 TILEGX_OPC_MULAX,
214 TILEGX_OPC_MULX,
215 TILEGX_OPC_MZ,
216 TILEGX_OPC_NAP,
217 TILEGX_OPC_NOP,
218 TILEGX_OPC_NOR,
219 TILEGX_OPC_OR,
220 TILEGX_OPC_ORI,
221 TILEGX_OPC_PCNT,
222 TILEGX_OPC_REVBITS,
223 TILEGX_OPC_REVBYTES,
224 TILEGX_OPC_ROTL,
225 TILEGX_OPC_ROTLI,
226 TILEGX_OPC_SHL,
227 TILEGX_OPC_SHL16INSLI,
228 TILEGX_OPC_SHL1ADD,
229 TILEGX_OPC_SHL1ADDX,
230 TILEGX_OPC_SHL2ADD,
231 TILEGX_OPC_SHL2ADDX,
232 TILEGX_OPC_SHL3ADD,
233 TILEGX_OPC_SHL3ADDX,
234 TILEGX_OPC_SHLI,
235 TILEGX_OPC_SHLX,
236 TILEGX_OPC_SHLXI,
237 TILEGX_OPC_SHRS,
238 TILEGX_OPC_SHRSI,
239 TILEGX_OPC_SHRU,
240 TILEGX_OPC_SHRUI,
241 TILEGX_OPC_SHRUX,
242 TILEGX_OPC_SHRUXI,
243 TILEGX_OPC_SHUFFLEBYTES,
244 TILEGX_OPC_ST,
245 TILEGX_OPC_ST1,
246 TILEGX_OPC_ST1_ADD,
247 TILEGX_OPC_ST2,
248 TILEGX_OPC_ST2_ADD,
249 TILEGX_OPC_ST4,
250 TILEGX_OPC_ST4_ADD,
251 TILEGX_OPC_ST_ADD,
252 TILEGX_OPC_STNT,
253 TILEGX_OPC_STNT1,
254 TILEGX_OPC_STNT1_ADD,
255 TILEGX_OPC_STNT2,
256 TILEGX_OPC_STNT2_ADD,
257 TILEGX_OPC_STNT4,
258 TILEGX_OPC_STNT4_ADD,
259 TILEGX_OPC_STNT_ADD,
260 TILEGX_OPC_SUB,
261 TILEGX_OPC_SUBX,
262 TILEGX_OPC_SUBXSC,
263 TILEGX_OPC_SWINT0,
264 TILEGX_OPC_SWINT1,
265 TILEGX_OPC_SWINT2,
266 TILEGX_OPC_SWINT3,
267 TILEGX_OPC_TBLIDXB0,
268 TILEGX_OPC_TBLIDXB1,
269 TILEGX_OPC_TBLIDXB2,
270 TILEGX_OPC_TBLIDXB3,
271 TILEGX_OPC_V1ADD,
272 TILEGX_OPC_V1ADDI,
273 TILEGX_OPC_V1ADDUC,
274 TILEGX_OPC_V1ADIFFU,
275 TILEGX_OPC_V1AVGU,
276 TILEGX_OPC_V1CMPEQ,
277 TILEGX_OPC_V1CMPEQI,
278 TILEGX_OPC_V1CMPLES,
279 TILEGX_OPC_V1CMPLEU,
280 TILEGX_OPC_V1CMPLTS,
281 TILEGX_OPC_V1CMPLTSI,
282 TILEGX_OPC_V1CMPLTU,
283 TILEGX_OPC_V1CMPLTUI,
284 TILEGX_OPC_V1CMPNE,
285 TILEGX_OPC_V1DDOTPU,
286 TILEGX_OPC_V1DDOTPUA,
287 TILEGX_OPC_V1DDOTPUS,
288 TILEGX_OPC_V1DDOTPUSA,
289 TILEGX_OPC_V1DOTP,
290 TILEGX_OPC_V1DOTPA,
291 TILEGX_OPC_V1DOTPU,
292 TILEGX_OPC_V1DOTPUA,
293 TILEGX_OPC_V1DOTPUS,
294 TILEGX_OPC_V1DOTPUSA,
295 TILEGX_OPC_V1INT_H,
296 TILEGX_OPC_V1INT_L,
297 TILEGX_OPC_V1MAXU,
298 TILEGX_OPC_V1MAXUI,
299 TILEGX_OPC_V1MINU,
300 TILEGX_OPC_V1MINUI,
301 TILEGX_OPC_V1MNZ,
302 TILEGX_OPC_V1MULTU,
303 TILEGX_OPC_V1MULU,
304 TILEGX_OPC_V1MULUS,
305 TILEGX_OPC_V1MZ,
306 TILEGX_OPC_V1SADAU,
307 TILEGX_OPC_V1SADU,
308 TILEGX_OPC_V1SHL,
309 TILEGX_OPC_V1SHLI,
310 TILEGX_OPC_V1SHRS,
311 TILEGX_OPC_V1SHRSI,
312 TILEGX_OPC_V1SHRU,
313 TILEGX_OPC_V1SHRUI,
314 TILEGX_OPC_V1SUB,
315 TILEGX_OPC_V1SUBUC,
316 TILEGX_OPC_V2ADD,
317 TILEGX_OPC_V2ADDI,
318 TILEGX_OPC_V2ADDSC,
319 TILEGX_OPC_V2ADIFFS,
320 TILEGX_OPC_V2AVGS,
321 TILEGX_OPC_V2CMPEQ,
322 TILEGX_OPC_V2CMPEQI,
323 TILEGX_OPC_V2CMPLES,
324 TILEGX_OPC_V2CMPLEU,
325 TILEGX_OPC_V2CMPLTS,
326 TILEGX_OPC_V2CMPLTSI,
327 TILEGX_OPC_V2CMPLTU,
328 TILEGX_OPC_V2CMPLTUI,
329 TILEGX_OPC_V2CMPNE,
330 TILEGX_OPC_V2DOTP,
331 TILEGX_OPC_V2DOTPA,
332 TILEGX_OPC_V2INT_H,
333 TILEGX_OPC_V2INT_L,
334 TILEGX_OPC_V2MAXS,
335 TILEGX_OPC_V2MAXSI,
336 TILEGX_OPC_V2MINS,
337 TILEGX_OPC_V2MINSI,
338 TILEGX_OPC_V2MNZ,
339 TILEGX_OPC_V2MULFSC,
340 TILEGX_OPC_V2MULS,
341 TILEGX_OPC_V2MULTS,
342 TILEGX_OPC_V2MZ,
343 TILEGX_OPC_V2PACKH,
344 TILEGX_OPC_V2PACKL,
345 TILEGX_OPC_V2PACKUC,
346 TILEGX_OPC_V2SADAS,
347 TILEGX_OPC_V2SADAU,
348 TILEGX_OPC_V2SADS,
349 TILEGX_OPC_V2SADU,
350 TILEGX_OPC_V2SHL,
351 TILEGX_OPC_V2SHLI,
352 TILEGX_OPC_V2SHLSC,
353 TILEGX_OPC_V2SHRS,
354 TILEGX_OPC_V2SHRSI,
355 TILEGX_OPC_V2SHRU,
356 TILEGX_OPC_V2SHRUI,
357 TILEGX_OPC_V2SUB,
358 TILEGX_OPC_V2SUBSC,
359 TILEGX_OPC_V4ADD,
360 TILEGX_OPC_V4ADDSC,
361 TILEGX_OPC_V4INT_H,
362 TILEGX_OPC_V4INT_L,
363 TILEGX_OPC_V4PACKSC,
364 TILEGX_OPC_V4SHL,
365 TILEGX_OPC_V4SHLSC,
366 TILEGX_OPC_V4SHRS,
367 TILEGX_OPC_V4SHRU,
368 TILEGX_OPC_V4SUB,
369 TILEGX_OPC_V4SUBSC,
370 TILEGX_OPC_WH64,
371 TILEGX_OPC_XOR,
372 TILEGX_OPC_XORI,
373 TILEGX_OPC_NONE
374} tilegx_mnemonic;
375
376/* 64-bit pattern for a { bpt ; nop } bundle. */
377#define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
378
379
380
381static __inline unsigned int
382get_BFEnd_X0(tilegx_bundle_bits num)
383{
384 const unsigned int n = (unsigned int)num;
385 return (((n >> 12)) & 0x3f);
386}
387
388static __inline unsigned int
389get_BFOpcodeExtension_X0(tilegx_bundle_bits num)
390{
391 const unsigned int n = (unsigned int)num;
392 return (((n >> 24)) & 0xf);
393}
394
395static __inline unsigned int
396get_BFStart_X0(tilegx_bundle_bits num)
397{
398 const unsigned int n = (unsigned int)num;
399 return (((n >> 18)) & 0x3f);
400}
401
402static __inline unsigned int
403get_BrOff_X1(tilegx_bundle_bits n)
404{
405 return (((unsigned int)(n >> 31)) & 0x0000003f) |
406 (((unsigned int)(n >> 37)) & 0x0001ffc0);
407}
408
409static __inline unsigned int
410get_BrType_X1(tilegx_bundle_bits n)
411{
412 return (((unsigned int)(n >> 54)) & 0x1f);
413}
414
415static __inline unsigned int
416get_Dest_Imm8_X1(tilegx_bundle_bits n)
417{
418 return (((unsigned int)(n >> 31)) & 0x0000003f) |
419 (((unsigned int)(n >> 43)) & 0x000000c0);
420}
421
422static __inline unsigned int
423get_Dest_X0(tilegx_bundle_bits num)
424{
425 const unsigned int n = (unsigned int)num;
426 return (((n >> 0)) & 0x3f);
427}
428
429static __inline unsigned int
430get_Dest_X1(tilegx_bundle_bits n)
431{
432 return (((unsigned int)(n >> 31)) & 0x3f);
433}
434
435static __inline unsigned int
436get_Dest_Y0(tilegx_bundle_bits num)
437{
438 const unsigned int n = (unsigned int)num;
439 return (((n >> 0)) & 0x3f);
440}
441
442static __inline unsigned int
443get_Dest_Y1(tilegx_bundle_bits n)
444{
445 return (((unsigned int)(n >> 31)) & 0x3f);
446}
447
448static __inline unsigned int
449get_Imm16_X0(tilegx_bundle_bits num)
450{
451 const unsigned int n = (unsigned int)num;
452 return (((n >> 12)) & 0xffff);
453}
454
455static __inline unsigned int
456get_Imm16_X1(tilegx_bundle_bits n)
457{
458 return (((unsigned int)(n >> 43)) & 0xffff);
459}
460
461static __inline unsigned int
462get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num)
463{
464 const unsigned int n = (unsigned int)num;
465 return (((n >> 20)) & 0xff);
466}
467
468static __inline unsigned int
469get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n)
470{
471 return (((unsigned int)(n >> 51)) & 0xff);
472}
473
474static __inline unsigned int
475get_Imm8_X0(tilegx_bundle_bits num)
476{
477 const unsigned int n = (unsigned int)num;
478 return (((n >> 12)) & 0xff);
479}
480
481static __inline unsigned int
482get_Imm8_X1(tilegx_bundle_bits n)
483{
484 return (((unsigned int)(n >> 43)) & 0xff);
485}
486
487static __inline unsigned int
488get_Imm8_Y0(tilegx_bundle_bits num)
489{
490 const unsigned int n = (unsigned int)num;
491 return (((n >> 12)) & 0xff);
492}
493
494static __inline unsigned int
495get_Imm8_Y1(tilegx_bundle_bits n)
496{
497 return (((unsigned int)(n >> 43)) & 0xff);
498}
499
500static __inline unsigned int
501get_JumpOff_X1(tilegx_bundle_bits n)
502{
503 return (((unsigned int)(n >> 31)) & 0x7ffffff);
504}
505
506static __inline unsigned int
507get_JumpOpcodeExtension_X1(tilegx_bundle_bits n)
508{
509 return (((unsigned int)(n >> 58)) & 0x1);
510}
511
512static __inline unsigned int
513get_MF_Imm14_X1(tilegx_bundle_bits n)
514{
515 return (((unsigned int)(n >> 37)) & 0x3fff);
516}
517
518static __inline unsigned int
519get_MT_Imm14_X1(tilegx_bundle_bits n)
520{
521 return (((unsigned int)(n >> 31)) & 0x0000003f) |
522 (((unsigned int)(n >> 37)) & 0x00003fc0);
523}
524
525static __inline unsigned int
526get_Mode(tilegx_bundle_bits n)
527{
528 return (((unsigned int)(n >> 62)) & 0x3);
529}
530
531static __inline unsigned int
532get_Opcode_X0(tilegx_bundle_bits num)
533{
534 const unsigned int n = (unsigned int)num;
535 return (((n >> 28)) & 0x7);
536}
537
538static __inline unsigned int
539get_Opcode_X1(tilegx_bundle_bits n)
540{
541 return (((unsigned int)(n >> 59)) & 0x7);
542}
543
544static __inline unsigned int
545get_Opcode_Y0(tilegx_bundle_bits num)
546{
547 const unsigned int n = (unsigned int)num;
548 return (((n >> 27)) & 0xf);
549}
550
551static __inline unsigned int
552get_Opcode_Y1(tilegx_bundle_bits n)
553{
554 return (((unsigned int)(n >> 58)) & 0xf);
555}
556
557static __inline unsigned int
558get_Opcode_Y2(tilegx_bundle_bits n)
559{
560 return (((n >> 26)) & 0x00000001) |
561 (((unsigned int)(n >> 56)) & 0x00000002);
562}
563
564static __inline unsigned int
565get_RRROpcodeExtension_X0(tilegx_bundle_bits num)
566{
567 const unsigned int n = (unsigned int)num;
568 return (((n >> 18)) & 0x3ff);
569}
570
571static __inline unsigned int
572get_RRROpcodeExtension_X1(tilegx_bundle_bits n)
573{
574 return (((unsigned int)(n >> 49)) & 0x3ff);
575}
576
577static __inline unsigned int
578get_RRROpcodeExtension_Y0(tilegx_bundle_bits num)
579{
580 const unsigned int n = (unsigned int)num;
581 return (((n >> 18)) & 0x3);
582}
583
584static __inline unsigned int
585get_RRROpcodeExtension_Y1(tilegx_bundle_bits n)
586{
587 return (((unsigned int)(n >> 49)) & 0x3);
588}
589
590static __inline unsigned int
591get_ShAmt_X0(tilegx_bundle_bits num)
592{
593 const unsigned int n = (unsigned int)num;
594 return (((n >> 12)) & 0x3f);
595}
596
597static __inline unsigned int
598get_ShAmt_X1(tilegx_bundle_bits n)
599{
600 return (((unsigned int)(n >> 43)) & 0x3f);
601}
602
603static __inline unsigned int
604get_ShAmt_Y0(tilegx_bundle_bits num)
605{
606 const unsigned int n = (unsigned int)num;
607 return (((n >> 12)) & 0x3f);
608}
609
610static __inline unsigned int
611get_ShAmt_Y1(tilegx_bundle_bits n)
612{
613 return (((unsigned int)(n >> 43)) & 0x3f);
614}
615
616static __inline unsigned int
617get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num)
618{
619 const unsigned int n = (unsigned int)num;
620 return (((n >> 18)) & 0x3ff);
621}
622
623static __inline unsigned int
624get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n)
625{
626 return (((unsigned int)(n >> 49)) & 0x3ff);
627}
628
629static __inline unsigned int
630get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num)
631{
632 const unsigned int n = (unsigned int)num;
633 return (((n >> 18)) & 0x3);
634}
635
636static __inline unsigned int
637get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n)
638{
639 return (((unsigned int)(n >> 49)) & 0x3);
640}
641
642static __inline unsigned int
643get_SrcA_X0(tilegx_bundle_bits num)
644{
645 const unsigned int n = (unsigned int)num;
646 return (((n >> 6)) & 0x3f);
647}
648
649static __inline unsigned int
650get_SrcA_X1(tilegx_bundle_bits n)
651{
652 return (((unsigned int)(n >> 37)) & 0x3f);
653}
654
655static __inline unsigned int
656get_SrcA_Y0(tilegx_bundle_bits num)
657{
658 const unsigned int n = (unsigned int)num;
659 return (((n >> 6)) & 0x3f);
660}
661
662static __inline unsigned int
663get_SrcA_Y1(tilegx_bundle_bits n)
664{
665 return (((unsigned int)(n >> 37)) & 0x3f);
666}
667
668static __inline unsigned int
669get_SrcA_Y2(tilegx_bundle_bits num)
670{
671 const unsigned int n = (unsigned int)num;
672 return (((n >> 20)) & 0x3f);
673}
674
675static __inline unsigned int
676get_SrcBDest_Y2(tilegx_bundle_bits n)
677{
678 return (((unsigned int)(n >> 51)) & 0x3f);
679}
680
681static __inline unsigned int
682get_SrcB_X0(tilegx_bundle_bits num)
683{
684 const unsigned int n = (unsigned int)num;
685 return (((n >> 12)) & 0x3f);
686}
687
688static __inline unsigned int
689get_SrcB_X1(tilegx_bundle_bits n)
690{
691 return (((unsigned int)(n >> 43)) & 0x3f);
692}
693
694static __inline unsigned int
695get_SrcB_Y0(tilegx_bundle_bits num)
696{
697 const unsigned int n = (unsigned int)num;
698 return (((n >> 12)) & 0x3f);
699}
700
701static __inline unsigned int
702get_SrcB_Y1(tilegx_bundle_bits n)
703{
704 return (((unsigned int)(n >> 43)) & 0x3f);
705}
706
707static __inline unsigned int
708get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num)
709{
710 const unsigned int n = (unsigned int)num;
711 return (((n >> 12)) & 0x3f);
712}
713
714static __inline unsigned int
715get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n)
716{
717 return (((unsigned int)(n >> 43)) & 0x3f);
718}
719
720static __inline unsigned int
721get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num)
722{
723 const unsigned int n = (unsigned int)num;
724 return (((n >> 12)) & 0x3f);
725}
726
727static __inline unsigned int
728get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n)
729{
730 return (((unsigned int)(n >> 43)) & 0x3f);
731}
732
733
734static __inline int
735sign_extend(int n, int num_bits)
736{
737 int shift = (int)(sizeof(int) * 8 - num_bits);
738 return (n << shift) >> shift;
739}
740
741
742
743static __inline tilegx_bundle_bits
744create_BFEnd_X0(int num)
745{
746 const unsigned int n = (unsigned int)num;
747 return ((n & 0x3f) << 12);
748}
749
750static __inline tilegx_bundle_bits
751create_BFOpcodeExtension_X0(int num)
752{
753 const unsigned int n = (unsigned int)num;
754 return ((n & 0xf) << 24);
755}
756
757static __inline tilegx_bundle_bits
758create_BFStart_X0(int num)
759{
760 const unsigned int n = (unsigned int)num;
761 return ((n & 0x3f) << 18);
762}
763
764static __inline tilegx_bundle_bits
765create_BrOff_X1(int num)
766{
767 const unsigned int n = (unsigned int)num;
768 return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
769 (((tilegx_bundle_bits)(n & 0x0001ffc0)) << 37);
770}
771
772static __inline tilegx_bundle_bits
773create_BrType_X1(int num)
774{
775 const unsigned int n = (unsigned int)num;
776 return (((tilegx_bundle_bits)(n & 0x1f)) << 54);
777}
778
779static __inline tilegx_bundle_bits
780create_Dest_Imm8_X1(int num)
781{
782 const unsigned int n = (unsigned int)num;
783 return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
784 (((tilegx_bundle_bits)(n & 0x000000c0)) << 43);
785}
786
787static __inline tilegx_bundle_bits
788create_Dest_X0(int num)
789{
790 const unsigned int n = (unsigned int)num;
791 return ((n & 0x3f) << 0);
792}
793
794static __inline tilegx_bundle_bits
795create_Dest_X1(int num)
796{
797 const unsigned int n = (unsigned int)num;
798 return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
799}
800
801static __inline tilegx_bundle_bits
802create_Dest_Y0(int num)
803{
804 const unsigned int n = (unsigned int)num;
805 return ((n & 0x3f) << 0);
806}
807
808static __inline tilegx_bundle_bits
809create_Dest_Y1(int num)
810{
811 const unsigned int n = (unsigned int)num;
812 return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
813}
814
815static __inline tilegx_bundle_bits
816create_Imm16_X0(int num)
817{
818 const unsigned int n = (unsigned int)num;
819 return ((n & 0xffff) << 12);
820}
821
822static __inline tilegx_bundle_bits
823create_Imm16_X1(int num)
824{
825 const unsigned int n = (unsigned int)num;
826 return (((tilegx_bundle_bits)(n & 0xffff)) << 43);
827}
828
829static __inline tilegx_bundle_bits
830create_Imm8OpcodeExtension_X0(int num)
831{
832 const unsigned int n = (unsigned int)num;
833 return ((n & 0xff) << 20);
834}
835
836static __inline tilegx_bundle_bits
837create_Imm8OpcodeExtension_X1(int num)
838{
839 const unsigned int n = (unsigned int)num;
840 return (((tilegx_bundle_bits)(n & 0xff)) << 51);
841}
842
843static __inline tilegx_bundle_bits
844create_Imm8_X0(int num)
845{
846 const unsigned int n = (unsigned int)num;
847 return ((n & 0xff) << 12);
848}
849
850static __inline tilegx_bundle_bits
851create_Imm8_X1(int num)
852{
853 const unsigned int n = (unsigned int)num;
854 return (((tilegx_bundle_bits)(n & 0xff)) << 43);
855}
856
857static __inline tilegx_bundle_bits
858create_Imm8_Y0(int num)
859{
860 const unsigned int n = (unsigned int)num;
861 return ((n & 0xff) << 12);
862}
863
864static __inline tilegx_bundle_bits
865create_Imm8_Y1(int num)
866{
867 const unsigned int n = (unsigned int)num;
868 return (((tilegx_bundle_bits)(n & 0xff)) << 43);
869}
870
871static __inline tilegx_bundle_bits
872create_JumpOff_X1(int num)
873{
874 const unsigned int n = (unsigned int)num;
875 return (((tilegx_bundle_bits)(n & 0x7ffffff)) << 31);
876}
877
878static __inline tilegx_bundle_bits
879create_JumpOpcodeExtension_X1(int num)
880{
881 const unsigned int n = (unsigned int)num;
882 return (((tilegx_bundle_bits)(n & 0x1)) << 58);
883}
884
885static __inline tilegx_bundle_bits
886create_MF_Imm14_X1(int num)
887{
888 const unsigned int n = (unsigned int)num;
889 return (((tilegx_bundle_bits)(n & 0x3fff)) << 37);
890}
891
892static __inline tilegx_bundle_bits
893create_MT_Imm14_X1(int num)
894{
895 const unsigned int n = (unsigned int)num;
896 return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
897 (((tilegx_bundle_bits)(n & 0x00003fc0)) << 37);
898}
899
900static __inline tilegx_bundle_bits
901create_Mode(int num)
902{
903 const unsigned int n = (unsigned int)num;
904 return (((tilegx_bundle_bits)(n & 0x3)) << 62);
905}
906
907static __inline tilegx_bundle_bits
908create_Opcode_X0(int num)
909{
910 const unsigned int n = (unsigned int)num;
911 return ((n & 0x7) << 28);
912}
913
914static __inline tilegx_bundle_bits
915create_Opcode_X1(int num)
916{
917 const unsigned int n = (unsigned int)num;
918 return (((tilegx_bundle_bits)(n & 0x7)) << 59);
919}
920
921static __inline tilegx_bundle_bits
922create_Opcode_Y0(int num)
923{
924 const unsigned int n = (unsigned int)num;
925 return ((n & 0xf) << 27);
926}
927
928static __inline tilegx_bundle_bits
929create_Opcode_Y1(int num)
930{
931 const unsigned int n = (unsigned int)num;
932 return (((tilegx_bundle_bits)(n & 0xf)) << 58);
933}
934
935static __inline tilegx_bundle_bits
936create_Opcode_Y2(int num)
937{
938 const unsigned int n = (unsigned int)num;
939 return ((n & 0x00000001) << 26) |
940 (((tilegx_bundle_bits)(n & 0x00000002)) << 56);
941}
942
943static __inline tilegx_bundle_bits
944create_RRROpcodeExtension_X0(int num)
945{
946 const unsigned int n = (unsigned int)num;
947 return ((n & 0x3ff) << 18);
948}
949
950static __inline tilegx_bundle_bits
951create_RRROpcodeExtension_X1(int num)
952{
953 const unsigned int n = (unsigned int)num;
954 return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
955}
956
957static __inline tilegx_bundle_bits
958create_RRROpcodeExtension_Y0(int num)
959{
960 const unsigned int n = (unsigned int)num;
961 return ((n & 0x3) << 18);
962}
963
964static __inline tilegx_bundle_bits
965create_RRROpcodeExtension_Y1(int num)
966{
967 const unsigned int n = (unsigned int)num;
968 return (((tilegx_bundle_bits)(n & 0x3)) << 49);
969}
970
971static __inline tilegx_bundle_bits
972create_ShAmt_X0(int num)
973{
974 const unsigned int n = (unsigned int)num;
975 return ((n & 0x3f) << 12);
976}
977
978static __inline tilegx_bundle_bits
979create_ShAmt_X1(int num)
980{
981 const unsigned int n = (unsigned int)num;
982 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
983}
984
985static __inline tilegx_bundle_bits
986create_ShAmt_Y0(int num)
987{
988 const unsigned int n = (unsigned int)num;
989 return ((n & 0x3f) << 12);
990}
991
992static __inline tilegx_bundle_bits
993create_ShAmt_Y1(int num)
994{
995 const unsigned int n = (unsigned int)num;
996 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
997}
998
999static __inline tilegx_bundle_bits
1000create_ShiftOpcodeExtension_X0(int num)
1001{
1002 const unsigned int n = (unsigned int)num;
1003 return ((n & 0x3ff) << 18);
1004}
1005
1006static __inline tilegx_bundle_bits
1007create_ShiftOpcodeExtension_X1(int num)
1008{
1009 const unsigned int n = (unsigned int)num;
1010 return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
1011}
1012
1013static __inline tilegx_bundle_bits
1014create_ShiftOpcodeExtension_Y0(int num)
1015{
1016 const unsigned int n = (unsigned int)num;
1017 return ((n & 0x3) << 18);
1018}
1019
1020static __inline tilegx_bundle_bits
1021create_ShiftOpcodeExtension_Y1(int num)
1022{
1023 const unsigned int n = (unsigned int)num;
1024 return (((tilegx_bundle_bits)(n & 0x3)) << 49);
1025}
1026
1027static __inline tilegx_bundle_bits
1028create_SrcA_X0(int num)
1029{
1030 const unsigned int n = (unsigned int)num;
1031 return ((n & 0x3f) << 6);
1032}
1033
1034static __inline tilegx_bundle_bits
1035create_SrcA_X1(int num)
1036{
1037 const unsigned int n = (unsigned int)num;
1038 return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
1039}
1040
1041static __inline tilegx_bundle_bits
1042create_SrcA_Y0(int num)
1043{
1044 const unsigned int n = (unsigned int)num;
1045 return ((n & 0x3f) << 6);
1046}
1047
1048static __inline tilegx_bundle_bits
1049create_SrcA_Y1(int num)
1050{
1051 const unsigned int n = (unsigned int)num;
1052 return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
1053}
1054
1055static __inline tilegx_bundle_bits
1056create_SrcA_Y2(int num)
1057{
1058 const unsigned int n = (unsigned int)num;
1059 return ((n & 0x3f) << 20);
1060}
1061
1062static __inline tilegx_bundle_bits
1063create_SrcBDest_Y2(int num)
1064{
1065 const unsigned int n = (unsigned int)num;
1066 return (((tilegx_bundle_bits)(n & 0x3f)) << 51);
1067}
1068
1069static __inline tilegx_bundle_bits
1070create_SrcB_X0(int num)
1071{
1072 const unsigned int n = (unsigned int)num;
1073 return ((n & 0x3f) << 12);
1074}
1075
1076static __inline tilegx_bundle_bits
1077create_SrcB_X1(int num)
1078{
1079 const unsigned int n = (unsigned int)num;
1080 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1081}
1082
1083static __inline tilegx_bundle_bits
1084create_SrcB_Y0(int num)
1085{
1086 const unsigned int n = (unsigned int)num;
1087 return ((n & 0x3f) << 12);
1088}
1089
1090static __inline tilegx_bundle_bits
1091create_SrcB_Y1(int num)
1092{
1093 const unsigned int n = (unsigned int)num;
1094 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1095}
1096
1097static __inline tilegx_bundle_bits
1098create_UnaryOpcodeExtension_X0(int num)
1099{
1100 const unsigned int n = (unsigned int)num;
1101 return ((n & 0x3f) << 12);
1102}
1103
1104static __inline tilegx_bundle_bits
1105create_UnaryOpcodeExtension_X1(int num)
1106{
1107 const unsigned int n = (unsigned int)num;
1108 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1109}
1110
1111static __inline tilegx_bundle_bits
1112create_UnaryOpcodeExtension_Y0(int num)
1113{
1114 const unsigned int n = (unsigned int)num;
1115 return ((n & 0x3f) << 12);
1116}
1117
1118static __inline tilegx_bundle_bits
1119create_UnaryOpcodeExtension_Y1(int num)
1120{
1121 const unsigned int n = (unsigned int)num;
1122 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1123}
1124
1125
1126typedef enum
1127{
1128 TILEGX_PIPELINE_X0,
1129 TILEGX_PIPELINE_X1,
1130 TILEGX_PIPELINE_Y0,
1131 TILEGX_PIPELINE_Y1,
1132 TILEGX_PIPELINE_Y2,
6edaf4d7 1133 TILEGX_NUM_PIPELINE_ENCODINGS = 5,
aa137e4d
NC
1134} tilegx_pipeline;
1135
1136#define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
1137
1138typedef enum
1139{
1140 TILEGX_OP_TYPE_REGISTER,
1141 TILEGX_OP_TYPE_IMMEDIATE,
1142 TILEGX_OP_TYPE_ADDRESS,
1143 TILEGX_OP_TYPE_SPR
1144} tilegx_operand_type;
1145
1146/* These are the bits that determine if a bundle is in the X encoding. */
1147#define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
1148
1149enum
1150{
1151 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1152 TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE = 3,
1153
aa137e4d
NC
1154 /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
1155 TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES = 3,
1156
1157 /* Instructions take this many bytes. */
1158 TILEGX_BUNDLE_SIZE_IN_BYTES = 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES,
1159
1160 /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
1161 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3,
1162
1163 /* Bundles should be aligned modulo this number of bytes. */
1164 TILEGX_BUNDLE_ALIGNMENT_IN_BYTES =
1165 (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES),
1166
1167 /* Number of registers (some are magic, such as network I/O). */
1168 TILEGX_NUM_REGISTERS = 64,
1169};
1170
1171
1172struct tilegx_operand
1173{
1174 /* Is this operand a register, immediate or address? */
1175 tilegx_operand_type type;
1176
1177 /* The default relocation type for this operand. */
1178 signed int default_reloc : 16;
1179
1180 /* How many bits is this value? (used for range checking) */
1181 unsigned int num_bits : 5;
1182
1183 /* Is the value signed? (used for range checking) */
1184 unsigned int is_signed : 1;
1185
1186 /* Is this operand a source register? */
1187 unsigned int is_src_reg : 1;
1188
1189 /* Is this operand written? (i.e. is it a destination register) */
1190 unsigned int is_dest_reg : 1;
1191
1192 /* Is this operand PC-relative? */
1193 unsigned int is_pc_relative : 1;
1194
1195 /* By how many bits do we right shift the value before inserting? */
1196 unsigned int rightshift : 2;
1197
1198 /* Return the bits for this operand to be ORed into an existing bundle. */
1199 tilegx_bundle_bits (*insert) (int op);
1200
1201 /* Extract this operand and return it. */
1202 unsigned int (*extract) (tilegx_bundle_bits bundle);
1203};
1204
1205
1206extern const struct tilegx_operand tilegx_operands[];
1207
1208/* One finite-state machine per pipe for rapid instruction decoding. */
1209extern const unsigned short * const
1210tilegx_bundle_decoder_fsms[TILEGX_NUM_PIPELINE_ENCODINGS];
1211
1212
1213struct tilegx_opcode
1214{
1215 /* The opcode mnemonic, e.g. "add" */
1216 const char *name;
1217
1218 /* The enum value for this mnemonic. */
1219 tilegx_mnemonic mnemonic;
1220
1221 /* A bit mask of which of the five pipes this instruction
1222 is compatible with:
1223 X0 0x01
1224 X1 0x02
1225 Y0 0x04
1226 Y1 0x08
1227 Y2 0x10 */
1228 unsigned char pipes;
1229
1230 /* How many operands are there? */
1231 unsigned char num_operands;
1232
1233 /* Which register does this write implicitly, or TREG_ZERO if none? */
1234 unsigned char implicitly_written_register;
1235
1236 /* Can this be bundled with other instructions (almost always true). */
1237 unsigned char can_bundle;
1238
1239 /* The description of the operands. Each of these is an
1240 * index into the tilegx_operands[] table. */
1241 unsigned char operands[TILEGX_NUM_PIPELINE_ENCODINGS][TILEGX_MAX_OPERANDS];
1242
1243#if !defined(__KERNEL__) && !defined(_LIBC)
1244 /* A mask of which bits have predefined values for each pipeline.
1245 * This is useful for disassembly. */
1246 tilegx_bundle_bits fixed_bit_masks[TILEGX_NUM_PIPELINE_ENCODINGS];
1247
1248 /* For each bit set in fixed_bit_masks, what the value is for this
1249 * instruction. */
1250 tilegx_bundle_bits fixed_bit_values[TILEGX_NUM_PIPELINE_ENCODINGS];
1251#endif
1252};
1253
1254extern const struct tilegx_opcode tilegx_opcodes[];
1255
1256/* Used for non-textual disassembly into structs. */
1257struct tilegx_decoded_instruction
1258{
1259 const struct tilegx_opcode *opcode;
1260 const struct tilegx_operand *operands[TILEGX_MAX_OPERANDS];
1261 long long operand_values[TILEGX_MAX_OPERANDS];
1262};
1263
1264
1265/* Disassemble a bundle into a struct for machine processing. */
1266extern int parse_insn_tilegx(tilegx_bundle_bits bits,
1267 unsigned long long pc,
1268 struct tilegx_decoded_instruction
1269 decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]);
1270
1271
1272#if !defined(__KERNEL__) && !defined(_LIBC)
1273/* Canonical names of all the registers. */
1274/* ISSUE: This table lives in "tile-dis.c" */
1275extern const char * const tilegx_register_names[];
1276
1277/* Descriptor for a special-purpose register. */
1278struct tilegx_spr
1279{
1280 /* The number */
1281 int number;
1282
1283 /* The name */
1284 const char *name;
1285};
1286
1287/* List of all the SPRs; ordered by increasing number. */
1288extern const struct tilegx_spr tilegx_sprs[];
1289
1290/* Number of special-purpose registers. */
1291extern const int tilegx_num_sprs;
1292
1293extern const char *
1294get_tilegx_spr_name (int num);
1295#endif /* !__KERNEL__ && !_LIBC */
1296
1297/* Make a few "tile_" variables to simply common code between
1298 architectures. */
1299
1300typedef tilegx_bundle_bits tile_bundle_bits;
1301#define TILE_BUNDLE_SIZE_IN_BYTES TILEGX_BUNDLE_SIZE_IN_BYTES
1302#define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
1303#define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
1304 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
1305
f63c1776
PA
1306#ifdef __cplusplus
1307}
1308#endif
1309
aa137e4d 1310#endif /* opcode_tilegx_h */