struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / sdbinutils / include / opcode / tilegx.h
blobdf0ed71d33ad5c83b28aeb8c29e751f37c9f1546
1 /* TILE-Gx opcode information.
3 * Copyright (C) 2011-2022 Free Software Foundation, Inc.
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.
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.
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.
21 #ifndef opcode_tile_h
22 #define opcode_tile_h
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 typedef unsigned long long tilegx_bundle_bits;
31 enum
33 TILEGX_MAX_OPERANDS = 4 /* bfexts */
36 typedef enum
38 TILEGX_OPC_BPT,
39 TILEGX_OPC_INFO,
40 TILEGX_OPC_INFOL,
41 TILEGX_OPC_LD4S_TLS,
42 TILEGX_OPC_LD_TLS,
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;
376 /* 64-bit pattern for a { bpt ; nop } bundle. */
377 #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
381 static __inline unsigned int
382 get_BFEnd_X0(tilegx_bundle_bits num)
384 const unsigned int n = (unsigned int)num;
385 return (((n >> 12)) & 0x3f);
388 static __inline unsigned int
389 get_BFOpcodeExtension_X0(tilegx_bundle_bits num)
391 const unsigned int n = (unsigned int)num;
392 return (((n >> 24)) & 0xf);
395 static __inline unsigned int
396 get_BFStart_X0(tilegx_bundle_bits num)
398 const unsigned int n = (unsigned int)num;
399 return (((n >> 18)) & 0x3f);
402 static __inline unsigned int
403 get_BrOff_X1(tilegx_bundle_bits n)
405 return (((unsigned int)(n >> 31)) & 0x0000003f) |
406 (((unsigned int)(n >> 37)) & 0x0001ffc0);
409 static __inline unsigned int
410 get_BrType_X1(tilegx_bundle_bits n)
412 return (((unsigned int)(n >> 54)) & 0x1f);
415 static __inline unsigned int
416 get_Dest_Imm8_X1(tilegx_bundle_bits n)
418 return (((unsigned int)(n >> 31)) & 0x0000003f) |
419 (((unsigned int)(n >> 43)) & 0x000000c0);
422 static __inline unsigned int
423 get_Dest_X0(tilegx_bundle_bits num)
425 const unsigned int n = (unsigned int)num;
426 return (((n >> 0)) & 0x3f);
429 static __inline unsigned int
430 get_Dest_X1(tilegx_bundle_bits n)
432 return (((unsigned int)(n >> 31)) & 0x3f);
435 static __inline unsigned int
436 get_Dest_Y0(tilegx_bundle_bits num)
438 const unsigned int n = (unsigned int)num;
439 return (((n >> 0)) & 0x3f);
442 static __inline unsigned int
443 get_Dest_Y1(tilegx_bundle_bits n)
445 return (((unsigned int)(n >> 31)) & 0x3f);
448 static __inline unsigned int
449 get_Imm16_X0(tilegx_bundle_bits num)
451 const unsigned int n = (unsigned int)num;
452 return (((n >> 12)) & 0xffff);
455 static __inline unsigned int
456 get_Imm16_X1(tilegx_bundle_bits n)
458 return (((unsigned int)(n >> 43)) & 0xffff);
461 static __inline unsigned int
462 get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num)
464 const unsigned int n = (unsigned int)num;
465 return (((n >> 20)) & 0xff);
468 static __inline unsigned int
469 get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n)
471 return (((unsigned int)(n >> 51)) & 0xff);
474 static __inline unsigned int
475 get_Imm8_X0(tilegx_bundle_bits num)
477 const unsigned int n = (unsigned int)num;
478 return (((n >> 12)) & 0xff);
481 static __inline unsigned int
482 get_Imm8_X1(tilegx_bundle_bits n)
484 return (((unsigned int)(n >> 43)) & 0xff);
487 static __inline unsigned int
488 get_Imm8_Y0(tilegx_bundle_bits num)
490 const unsigned int n = (unsigned int)num;
491 return (((n >> 12)) & 0xff);
494 static __inline unsigned int
495 get_Imm8_Y1(tilegx_bundle_bits n)
497 return (((unsigned int)(n >> 43)) & 0xff);
500 static __inline unsigned int
501 get_JumpOff_X1(tilegx_bundle_bits n)
503 return (((unsigned int)(n >> 31)) & 0x7ffffff);
506 static __inline unsigned int
507 get_JumpOpcodeExtension_X1(tilegx_bundle_bits n)
509 return (((unsigned int)(n >> 58)) & 0x1);
512 static __inline unsigned int
513 get_MF_Imm14_X1(tilegx_bundle_bits n)
515 return (((unsigned int)(n >> 37)) & 0x3fff);
518 static __inline unsigned int
519 get_MT_Imm14_X1(tilegx_bundle_bits n)
521 return (((unsigned int)(n >> 31)) & 0x0000003f) |
522 (((unsigned int)(n >> 37)) & 0x00003fc0);
525 static __inline unsigned int
526 get_Mode(tilegx_bundle_bits n)
528 return (((unsigned int)(n >> 62)) & 0x3);
531 static __inline unsigned int
532 get_Opcode_X0(tilegx_bundle_bits num)
534 const unsigned int n = (unsigned int)num;
535 return (((n >> 28)) & 0x7);
538 static __inline unsigned int
539 get_Opcode_X1(tilegx_bundle_bits n)
541 return (((unsigned int)(n >> 59)) & 0x7);
544 static __inline unsigned int
545 get_Opcode_Y0(tilegx_bundle_bits num)
547 const unsigned int n = (unsigned int)num;
548 return (((n >> 27)) & 0xf);
551 static __inline unsigned int
552 get_Opcode_Y1(tilegx_bundle_bits n)
554 return (((unsigned int)(n >> 58)) & 0xf);
557 static __inline unsigned int
558 get_Opcode_Y2(tilegx_bundle_bits n)
560 return (((n >> 26)) & 0x00000001) |
561 (((unsigned int)(n >> 56)) & 0x00000002);
564 static __inline unsigned int
565 get_RRROpcodeExtension_X0(tilegx_bundle_bits num)
567 const unsigned int n = (unsigned int)num;
568 return (((n >> 18)) & 0x3ff);
571 static __inline unsigned int
572 get_RRROpcodeExtension_X1(tilegx_bundle_bits n)
574 return (((unsigned int)(n >> 49)) & 0x3ff);
577 static __inline unsigned int
578 get_RRROpcodeExtension_Y0(tilegx_bundle_bits num)
580 const unsigned int n = (unsigned int)num;
581 return (((n >> 18)) & 0x3);
584 static __inline unsigned int
585 get_RRROpcodeExtension_Y1(tilegx_bundle_bits n)
587 return (((unsigned int)(n >> 49)) & 0x3);
590 static __inline unsigned int
591 get_ShAmt_X0(tilegx_bundle_bits num)
593 const unsigned int n = (unsigned int)num;
594 return (((n >> 12)) & 0x3f);
597 static __inline unsigned int
598 get_ShAmt_X1(tilegx_bundle_bits n)
600 return (((unsigned int)(n >> 43)) & 0x3f);
603 static __inline unsigned int
604 get_ShAmt_Y0(tilegx_bundle_bits num)
606 const unsigned int n = (unsigned int)num;
607 return (((n >> 12)) & 0x3f);
610 static __inline unsigned int
611 get_ShAmt_Y1(tilegx_bundle_bits n)
613 return (((unsigned int)(n >> 43)) & 0x3f);
616 static __inline unsigned int
617 get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num)
619 const unsigned int n = (unsigned int)num;
620 return (((n >> 18)) & 0x3ff);
623 static __inline unsigned int
624 get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n)
626 return (((unsigned int)(n >> 49)) & 0x3ff);
629 static __inline unsigned int
630 get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num)
632 const unsigned int n = (unsigned int)num;
633 return (((n >> 18)) & 0x3);
636 static __inline unsigned int
637 get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n)
639 return (((unsigned int)(n >> 49)) & 0x3);
642 static __inline unsigned int
643 get_SrcA_X0(tilegx_bundle_bits num)
645 const unsigned int n = (unsigned int)num;
646 return (((n >> 6)) & 0x3f);
649 static __inline unsigned int
650 get_SrcA_X1(tilegx_bundle_bits n)
652 return (((unsigned int)(n >> 37)) & 0x3f);
655 static __inline unsigned int
656 get_SrcA_Y0(tilegx_bundle_bits num)
658 const unsigned int n = (unsigned int)num;
659 return (((n >> 6)) & 0x3f);
662 static __inline unsigned int
663 get_SrcA_Y1(tilegx_bundle_bits n)
665 return (((unsigned int)(n >> 37)) & 0x3f);
668 static __inline unsigned int
669 get_SrcA_Y2(tilegx_bundle_bits num)
671 const unsigned int n = (unsigned int)num;
672 return (((n >> 20)) & 0x3f);
675 static __inline unsigned int
676 get_SrcBDest_Y2(tilegx_bundle_bits n)
678 return (((unsigned int)(n >> 51)) & 0x3f);
681 static __inline unsigned int
682 get_SrcB_X0(tilegx_bundle_bits num)
684 const unsigned int n = (unsigned int)num;
685 return (((n >> 12)) & 0x3f);
688 static __inline unsigned int
689 get_SrcB_X1(tilegx_bundle_bits n)
691 return (((unsigned int)(n >> 43)) & 0x3f);
694 static __inline unsigned int
695 get_SrcB_Y0(tilegx_bundle_bits num)
697 const unsigned int n = (unsigned int)num;
698 return (((n >> 12)) & 0x3f);
701 static __inline unsigned int
702 get_SrcB_Y1(tilegx_bundle_bits n)
704 return (((unsigned int)(n >> 43)) & 0x3f);
707 static __inline unsigned int
708 get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num)
710 const unsigned int n = (unsigned int)num;
711 return (((n >> 12)) & 0x3f);
714 static __inline unsigned int
715 get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n)
717 return (((unsigned int)(n >> 43)) & 0x3f);
720 static __inline unsigned int
721 get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num)
723 const unsigned int n = (unsigned int)num;
724 return (((n >> 12)) & 0x3f);
727 static __inline unsigned int
728 get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n)
730 return (((unsigned int)(n >> 43)) & 0x3f);
734 static __inline int
735 sign_extend(int n, int num_bits)
737 int shift = (int)(sizeof(int) * 8 - num_bits);
738 return (n << shift) >> shift;
743 static __inline tilegx_bundle_bits
744 create_BFEnd_X0(int num)
746 const unsigned int n = (unsigned int)num;
747 return ((n & 0x3f) << 12);
750 static __inline tilegx_bundle_bits
751 create_BFOpcodeExtension_X0(int num)
753 const unsigned int n = (unsigned int)num;
754 return ((n & 0xf) << 24);
757 static __inline tilegx_bundle_bits
758 create_BFStart_X0(int num)
760 const unsigned int n = (unsigned int)num;
761 return ((n & 0x3f) << 18);
764 static __inline tilegx_bundle_bits
765 create_BrOff_X1(int num)
767 const unsigned int n = (unsigned int)num;
768 return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
769 (((tilegx_bundle_bits)(n & 0x0001ffc0)) << 37);
772 static __inline tilegx_bundle_bits
773 create_BrType_X1(int num)
775 const unsigned int n = (unsigned int)num;
776 return (((tilegx_bundle_bits)(n & 0x1f)) << 54);
779 static __inline tilegx_bundle_bits
780 create_Dest_Imm8_X1(int num)
782 const unsigned int n = (unsigned int)num;
783 return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
784 (((tilegx_bundle_bits)(n & 0x000000c0)) << 43);
787 static __inline tilegx_bundle_bits
788 create_Dest_X0(int num)
790 const unsigned int n = (unsigned int)num;
791 return ((n & 0x3f) << 0);
794 static __inline tilegx_bundle_bits
795 create_Dest_X1(int num)
797 const unsigned int n = (unsigned int)num;
798 return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
801 static __inline tilegx_bundle_bits
802 create_Dest_Y0(int num)
804 const unsigned int n = (unsigned int)num;
805 return ((n & 0x3f) << 0);
808 static __inline tilegx_bundle_bits
809 create_Dest_Y1(int num)
811 const unsigned int n = (unsigned int)num;
812 return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
815 static __inline tilegx_bundle_bits
816 create_Imm16_X0(int num)
818 const unsigned int n = (unsigned int)num;
819 return ((n & 0xffff) << 12);
822 static __inline tilegx_bundle_bits
823 create_Imm16_X1(int num)
825 const unsigned int n = (unsigned int)num;
826 return (((tilegx_bundle_bits)(n & 0xffff)) << 43);
829 static __inline tilegx_bundle_bits
830 create_Imm8OpcodeExtension_X0(int num)
832 const unsigned int n = (unsigned int)num;
833 return ((n & 0xff) << 20);
836 static __inline tilegx_bundle_bits
837 create_Imm8OpcodeExtension_X1(int num)
839 const unsigned int n = (unsigned int)num;
840 return (((tilegx_bundle_bits)(n & 0xff)) << 51);
843 static __inline tilegx_bundle_bits
844 create_Imm8_X0(int num)
846 const unsigned int n = (unsigned int)num;
847 return ((n & 0xff) << 12);
850 static __inline tilegx_bundle_bits
851 create_Imm8_X1(int num)
853 const unsigned int n = (unsigned int)num;
854 return (((tilegx_bundle_bits)(n & 0xff)) << 43);
857 static __inline tilegx_bundle_bits
858 create_Imm8_Y0(int num)
860 const unsigned int n = (unsigned int)num;
861 return ((n & 0xff) << 12);
864 static __inline tilegx_bundle_bits
865 create_Imm8_Y1(int num)
867 const unsigned int n = (unsigned int)num;
868 return (((tilegx_bundle_bits)(n & 0xff)) << 43);
871 static __inline tilegx_bundle_bits
872 create_JumpOff_X1(int num)
874 const unsigned int n = (unsigned int)num;
875 return (((tilegx_bundle_bits)(n & 0x7ffffff)) << 31);
878 static __inline tilegx_bundle_bits
879 create_JumpOpcodeExtension_X1(int num)
881 const unsigned int n = (unsigned int)num;
882 return (((tilegx_bundle_bits)(n & 0x1)) << 58);
885 static __inline tilegx_bundle_bits
886 create_MF_Imm14_X1(int num)
888 const unsigned int n = (unsigned int)num;
889 return (((tilegx_bundle_bits)(n & 0x3fff)) << 37);
892 static __inline tilegx_bundle_bits
893 create_MT_Imm14_X1(int num)
895 const unsigned int n = (unsigned int)num;
896 return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
897 (((tilegx_bundle_bits)(n & 0x00003fc0)) << 37);
900 static __inline tilegx_bundle_bits
901 create_Mode(int num)
903 const unsigned int n = (unsigned int)num;
904 return (((tilegx_bundle_bits)(n & 0x3)) << 62);
907 static __inline tilegx_bundle_bits
908 create_Opcode_X0(int num)
910 const unsigned int n = (unsigned int)num;
911 return ((n & 0x7) << 28);
914 static __inline tilegx_bundle_bits
915 create_Opcode_X1(int num)
917 const unsigned int n = (unsigned int)num;
918 return (((tilegx_bundle_bits)(n & 0x7)) << 59);
921 static __inline tilegx_bundle_bits
922 create_Opcode_Y0(int num)
924 const unsigned int n = (unsigned int)num;
925 return ((n & 0xf) << 27);
928 static __inline tilegx_bundle_bits
929 create_Opcode_Y1(int num)
931 const unsigned int n = (unsigned int)num;
932 return (((tilegx_bundle_bits)(n & 0xf)) << 58);
935 static __inline tilegx_bundle_bits
936 create_Opcode_Y2(int num)
938 const unsigned int n = (unsigned int)num;
939 return ((n & 0x00000001) << 26) |
940 (((tilegx_bundle_bits)(n & 0x00000002)) << 56);
943 static __inline tilegx_bundle_bits
944 create_RRROpcodeExtension_X0(int num)
946 const unsigned int n = (unsigned int)num;
947 return ((n & 0x3ff) << 18);
950 static __inline tilegx_bundle_bits
951 create_RRROpcodeExtension_X1(int num)
953 const unsigned int n = (unsigned int)num;
954 return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
957 static __inline tilegx_bundle_bits
958 create_RRROpcodeExtension_Y0(int num)
960 const unsigned int n = (unsigned int)num;
961 return ((n & 0x3) << 18);
964 static __inline tilegx_bundle_bits
965 create_RRROpcodeExtension_Y1(int num)
967 const unsigned int n = (unsigned int)num;
968 return (((tilegx_bundle_bits)(n & 0x3)) << 49);
971 static __inline tilegx_bundle_bits
972 create_ShAmt_X0(int num)
974 const unsigned int n = (unsigned int)num;
975 return ((n & 0x3f) << 12);
978 static __inline tilegx_bundle_bits
979 create_ShAmt_X1(int num)
981 const unsigned int n = (unsigned int)num;
982 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
985 static __inline tilegx_bundle_bits
986 create_ShAmt_Y0(int num)
988 const unsigned int n = (unsigned int)num;
989 return ((n & 0x3f) << 12);
992 static __inline tilegx_bundle_bits
993 create_ShAmt_Y1(int num)
995 const unsigned int n = (unsigned int)num;
996 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
999 static __inline tilegx_bundle_bits
1000 create_ShiftOpcodeExtension_X0(int num)
1002 const unsigned int n = (unsigned int)num;
1003 return ((n & 0x3ff) << 18);
1006 static __inline tilegx_bundle_bits
1007 create_ShiftOpcodeExtension_X1(int num)
1009 const unsigned int n = (unsigned int)num;
1010 return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
1013 static __inline tilegx_bundle_bits
1014 create_ShiftOpcodeExtension_Y0(int num)
1016 const unsigned int n = (unsigned int)num;
1017 return ((n & 0x3) << 18);
1020 static __inline tilegx_bundle_bits
1021 create_ShiftOpcodeExtension_Y1(int num)
1023 const unsigned int n = (unsigned int)num;
1024 return (((tilegx_bundle_bits)(n & 0x3)) << 49);
1027 static __inline tilegx_bundle_bits
1028 create_SrcA_X0(int num)
1030 const unsigned int n = (unsigned int)num;
1031 return ((n & 0x3f) << 6);
1034 static __inline tilegx_bundle_bits
1035 create_SrcA_X1(int num)
1037 const unsigned int n = (unsigned int)num;
1038 return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
1041 static __inline tilegx_bundle_bits
1042 create_SrcA_Y0(int num)
1044 const unsigned int n = (unsigned int)num;
1045 return ((n & 0x3f) << 6);
1048 static __inline tilegx_bundle_bits
1049 create_SrcA_Y1(int num)
1051 const unsigned int n = (unsigned int)num;
1052 return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
1055 static __inline tilegx_bundle_bits
1056 create_SrcA_Y2(int num)
1058 const unsigned int n = (unsigned int)num;
1059 return ((n & 0x3f) << 20);
1062 static __inline tilegx_bundle_bits
1063 create_SrcBDest_Y2(int num)
1065 const unsigned int n = (unsigned int)num;
1066 return (((tilegx_bundle_bits)(n & 0x3f)) << 51);
1069 static __inline tilegx_bundle_bits
1070 create_SrcB_X0(int num)
1072 const unsigned int n = (unsigned int)num;
1073 return ((n & 0x3f) << 12);
1076 static __inline tilegx_bundle_bits
1077 create_SrcB_X1(int num)
1079 const unsigned int n = (unsigned int)num;
1080 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1083 static __inline tilegx_bundle_bits
1084 create_SrcB_Y0(int num)
1086 const unsigned int n = (unsigned int)num;
1087 return ((n & 0x3f) << 12);
1090 static __inline tilegx_bundle_bits
1091 create_SrcB_Y1(int num)
1093 const unsigned int n = (unsigned int)num;
1094 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1097 static __inline tilegx_bundle_bits
1098 create_UnaryOpcodeExtension_X0(int num)
1100 const unsigned int n = (unsigned int)num;
1101 return ((n & 0x3f) << 12);
1104 static __inline tilegx_bundle_bits
1105 create_UnaryOpcodeExtension_X1(int num)
1107 const unsigned int n = (unsigned int)num;
1108 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1111 static __inline tilegx_bundle_bits
1112 create_UnaryOpcodeExtension_Y0(int num)
1114 const unsigned int n = (unsigned int)num;
1115 return ((n & 0x3f) << 12);
1118 static __inline tilegx_bundle_bits
1119 create_UnaryOpcodeExtension_Y1(int num)
1121 const unsigned int n = (unsigned int)num;
1122 return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
1126 typedef enum
1128 TILEGX_PIPELINE_X0,
1129 TILEGX_PIPELINE_X1,
1130 TILEGX_PIPELINE_Y0,
1131 TILEGX_PIPELINE_Y1,
1132 TILEGX_PIPELINE_Y2,
1133 TILEGX_NUM_PIPELINE_ENCODINGS = 5,
1134 } tilegx_pipeline;
1136 #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
1138 typedef enum
1140 TILEGX_OP_TYPE_REGISTER,
1141 TILEGX_OP_TYPE_IMMEDIATE,
1142 TILEGX_OP_TYPE_ADDRESS,
1143 TILEGX_OP_TYPE_SPR
1144 } tilegx_operand_type;
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)
1149 enum
1151 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1152 TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE = 3,
1154 /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
1155 TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES = 3,
1157 /* Instructions take this many bytes. */
1158 TILEGX_BUNDLE_SIZE_IN_BYTES = 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES,
1160 /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
1161 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3,
1163 /* Bundles should be aligned modulo this number of bytes. */
1164 TILEGX_BUNDLE_ALIGNMENT_IN_BYTES =
1165 (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES),
1167 /* Number of registers (some are magic, such as network I/O). */
1168 TILEGX_NUM_REGISTERS = 64,
1172 struct tilegx_operand
1174 /* Is this operand a register, immediate or address? */
1175 tilegx_operand_type type;
1177 /* The default relocation type for this operand. */
1178 signed int default_reloc : 16;
1180 /* How many bits is this value? (used for range checking) */
1181 unsigned int num_bits : 5;
1183 /* Is the value signed? (used for range checking) */
1184 unsigned int is_signed : 1;
1186 /* Is this operand a source register? */
1187 unsigned int is_src_reg : 1;
1189 /* Is this operand written? (i.e. is it a destination register) */
1190 unsigned int is_dest_reg : 1;
1192 /* Is this operand PC-relative? */
1193 unsigned int is_pc_relative : 1;
1195 /* By how many bits do we right shift the value before inserting? */
1196 unsigned int rightshift : 2;
1198 /* Return the bits for this operand to be ORed into an existing bundle. */
1199 tilegx_bundle_bits (*insert) (int op);
1201 /* Extract this operand and return it. */
1202 unsigned int (*extract) (tilegx_bundle_bits bundle);
1206 extern const struct tilegx_operand tilegx_operands[];
1208 /* One finite-state machine per pipe for rapid instruction decoding. */
1209 extern const unsigned short * const
1210 tilegx_bundle_decoder_fsms[TILEGX_NUM_PIPELINE_ENCODINGS];
1213 struct tilegx_opcode
1215 /* The opcode mnemonic, e.g. "add" */
1216 const char *name;
1218 /* The enum value for this mnemonic. */
1219 tilegx_mnemonic mnemonic;
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;
1230 /* How many operands are there? */
1231 unsigned char num_operands;
1233 /* Which register does this write implicitly, or TREG_ZERO if none? */
1234 unsigned char implicitly_written_register;
1236 /* Can this be bundled with other instructions (almost always true). */
1237 unsigned char can_bundle;
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];
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];
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
1254 extern const struct tilegx_opcode tilegx_opcodes[];
1256 /* Used for non-textual disassembly into structs. */
1257 struct tilegx_decoded_instruction
1259 const struct tilegx_opcode *opcode;
1260 const struct tilegx_operand *operands[TILEGX_MAX_OPERANDS];
1261 long long operand_values[TILEGX_MAX_OPERANDS];
1265 /* Disassemble a bundle into a struct for machine processing. */
1266 extern 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]);
1272 #if !defined(__KERNEL__) && !defined(_LIBC)
1273 /* Canonical names of all the registers. */
1274 /* ISSUE: This table lives in "tile-dis.c" */
1275 extern const char * const tilegx_register_names[];
1277 /* Descriptor for a special-purpose register. */
1278 struct tilegx_spr
1280 /* The number */
1281 int number;
1283 /* The name */
1284 const char *name;
1287 /* List of all the SPRs; ordered by increasing number. */
1288 extern const struct tilegx_spr tilegx_sprs[];
1290 /* Number of special-purpose registers. */
1291 extern const int tilegx_num_sprs;
1293 extern const char *
1294 get_tilegx_spr_name (int num);
1295 #endif /* !__KERNEL__ && !_LIBC */
1297 /* Make a few "tile_" variables to simply common code between
1298 architectures. */
1300 typedef 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
1306 #ifdef __cplusplus
1308 #endif
1310 #endif /* opcode_tilegx_h */