source: trunk/libs/newlib/src/include/opcode/tilepro.h @ 544

Last change on this file since 544 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 37.5 KB
Line 
1/* TILEPro opcode information.
2 *
3 *    Copyright 2011 Free Software Foundation, Inc.
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_tilepro_h
22#define opcode_tilepro_h
23
24typedef unsigned long long tilepro_bundle_bits;
25
26
27enum
28{
29  TILEPRO_MAX_OPERANDS = 5 /* mm */
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_LW_TLS,
40  TILEPRO_OPC_LW_TLS_SN,
41  TILEPRO_OPC_MOVE,
42  TILEPRO_OPC_MOVE_SN,
43  TILEPRO_OPC_MOVEI,
44  TILEPRO_OPC_MOVEI_SN,
45  TILEPRO_OPC_MOVELI,
46  TILEPRO_OPC_MOVELI_SN,
47  TILEPRO_OPC_MOVELIS,
48  TILEPRO_OPC_PREFETCH,
49  TILEPRO_OPC_RAISE,
50  TILEPRO_OPC_ADD,
51  TILEPRO_OPC_ADD_SN,
52  TILEPRO_OPC_ADDB,
53  TILEPRO_OPC_ADDB_SN,
54  TILEPRO_OPC_ADDBS_U,
55  TILEPRO_OPC_ADDBS_U_SN,
56  TILEPRO_OPC_ADDH,
57  TILEPRO_OPC_ADDH_SN,
58  TILEPRO_OPC_ADDHS,
59  TILEPRO_OPC_ADDHS_SN,
60  TILEPRO_OPC_ADDI,
61  TILEPRO_OPC_ADDI_SN,
62  TILEPRO_OPC_ADDIB,
63  TILEPRO_OPC_ADDIB_SN,
64  TILEPRO_OPC_ADDIH,
65  TILEPRO_OPC_ADDIH_SN,
66  TILEPRO_OPC_ADDLI,
67  TILEPRO_OPC_ADDLI_SN,
68  TILEPRO_OPC_ADDLIS,
69  TILEPRO_OPC_ADDS,
70  TILEPRO_OPC_ADDS_SN,
71  TILEPRO_OPC_ADIFFB_U,
72  TILEPRO_OPC_ADIFFB_U_SN,
73  TILEPRO_OPC_ADIFFH,
74  TILEPRO_OPC_ADIFFH_SN,
75  TILEPRO_OPC_AND,
76  TILEPRO_OPC_AND_SN,
77  TILEPRO_OPC_ANDI,
78  TILEPRO_OPC_ANDI_SN,
79  TILEPRO_OPC_AULI,
80  TILEPRO_OPC_AVGB_U,
81  TILEPRO_OPC_AVGB_U_SN,
82  TILEPRO_OPC_AVGH,
83  TILEPRO_OPC_AVGH_SN,
84  TILEPRO_OPC_BBNS,
85  TILEPRO_OPC_BBNS_SN,
86  TILEPRO_OPC_BBNST,
87  TILEPRO_OPC_BBNST_SN,
88  TILEPRO_OPC_BBS,
89  TILEPRO_OPC_BBS_SN,
90  TILEPRO_OPC_BBST,
91  TILEPRO_OPC_BBST_SN,
92  TILEPRO_OPC_BGEZ,
93  TILEPRO_OPC_BGEZ_SN,
94  TILEPRO_OPC_BGEZT,
95  TILEPRO_OPC_BGEZT_SN,
96  TILEPRO_OPC_BGZ,
97  TILEPRO_OPC_BGZ_SN,
98  TILEPRO_OPC_BGZT,
99  TILEPRO_OPC_BGZT_SN,
100  TILEPRO_OPC_BITX,
101  TILEPRO_OPC_BITX_SN,
102  TILEPRO_OPC_BLEZ,
103  TILEPRO_OPC_BLEZ_SN,
104  TILEPRO_OPC_BLEZT,
105  TILEPRO_OPC_BLEZT_SN,
106  TILEPRO_OPC_BLZ,
107  TILEPRO_OPC_BLZ_SN,
108  TILEPRO_OPC_BLZT,
109  TILEPRO_OPC_BLZT_SN,
110  TILEPRO_OPC_BNZ,
111  TILEPRO_OPC_BNZ_SN,
112  TILEPRO_OPC_BNZT,
113  TILEPRO_OPC_BNZT_SN,
114  TILEPRO_OPC_BYTEX,
115  TILEPRO_OPC_BYTEX_SN,
116  TILEPRO_OPC_BZ,
117  TILEPRO_OPC_BZ_SN,
118  TILEPRO_OPC_BZT,
119  TILEPRO_OPC_BZT_SN,
120  TILEPRO_OPC_CLZ,
121  TILEPRO_OPC_CLZ_SN,
122  TILEPRO_OPC_CRC32_32,
123  TILEPRO_OPC_CRC32_32_SN,
124  TILEPRO_OPC_CRC32_8,
125  TILEPRO_OPC_CRC32_8_SN,
126  TILEPRO_OPC_CTZ,
127  TILEPRO_OPC_CTZ_SN,
128  TILEPRO_OPC_DRAIN,
129  TILEPRO_OPC_DTLBPR,
130  TILEPRO_OPC_DWORD_ALIGN,
131  TILEPRO_OPC_DWORD_ALIGN_SN,
132  TILEPRO_OPC_FINV,
133  TILEPRO_OPC_FLUSH,
134  TILEPRO_OPC_FNOP,
135  TILEPRO_OPC_ICOH,
136  TILEPRO_OPC_ILL,
137  TILEPRO_OPC_INTHB,
138  TILEPRO_OPC_INTHB_SN,
139  TILEPRO_OPC_INTHH,
140  TILEPRO_OPC_INTHH_SN,
141  TILEPRO_OPC_INTLB,
142  TILEPRO_OPC_INTLB_SN,
143  TILEPRO_OPC_INTLH,
144  TILEPRO_OPC_INTLH_SN,
145  TILEPRO_OPC_INV,
146  TILEPRO_OPC_IRET,
147  TILEPRO_OPC_JALB,
148  TILEPRO_OPC_JALF,
149  TILEPRO_OPC_JALR,
150  TILEPRO_OPC_JALRP,
151  TILEPRO_OPC_JB,
152  TILEPRO_OPC_JF,
153  TILEPRO_OPC_JR,
154  TILEPRO_OPC_JRP,
155  TILEPRO_OPC_LB,
156  TILEPRO_OPC_LB_SN,
157  TILEPRO_OPC_LB_U,
158  TILEPRO_OPC_LB_U_SN,
159  TILEPRO_OPC_LBADD,
160  TILEPRO_OPC_LBADD_SN,
161  TILEPRO_OPC_LBADD_U,
162  TILEPRO_OPC_LBADD_U_SN,
163  TILEPRO_OPC_LH,
164  TILEPRO_OPC_LH_SN,
165  TILEPRO_OPC_LH_U,
166  TILEPRO_OPC_LH_U_SN,
167  TILEPRO_OPC_LHADD,
168  TILEPRO_OPC_LHADD_SN,
169  TILEPRO_OPC_LHADD_U,
170  TILEPRO_OPC_LHADD_U_SN,
171  TILEPRO_OPC_LNK,
172  TILEPRO_OPC_LNK_SN,
173  TILEPRO_OPC_LW,
174  TILEPRO_OPC_LW_SN,
175  TILEPRO_OPC_LW_NA,
176  TILEPRO_OPC_LW_NA_SN,
177  TILEPRO_OPC_LWADD,
178  TILEPRO_OPC_LWADD_SN,
179  TILEPRO_OPC_LWADD_NA,
180  TILEPRO_OPC_LWADD_NA_SN,
181  TILEPRO_OPC_MAXB_U,
182  TILEPRO_OPC_MAXB_U_SN,
183  TILEPRO_OPC_MAXH,
184  TILEPRO_OPC_MAXH_SN,
185  TILEPRO_OPC_MAXIB_U,
186  TILEPRO_OPC_MAXIB_U_SN,
187  TILEPRO_OPC_MAXIH,
188  TILEPRO_OPC_MAXIH_SN,
189  TILEPRO_OPC_MF,
190  TILEPRO_OPC_MFSPR,
191  TILEPRO_OPC_MINB_U,
192  TILEPRO_OPC_MINB_U_SN,
193  TILEPRO_OPC_MINH,
194  TILEPRO_OPC_MINH_SN,
195  TILEPRO_OPC_MINIB_U,
196  TILEPRO_OPC_MINIB_U_SN,
197  TILEPRO_OPC_MINIH,
198  TILEPRO_OPC_MINIH_SN,
199  TILEPRO_OPC_MM,
200  TILEPRO_OPC_MNZ,
201  TILEPRO_OPC_MNZ_SN,
202  TILEPRO_OPC_MNZB,
203  TILEPRO_OPC_MNZB_SN,
204  TILEPRO_OPC_MNZH,
205  TILEPRO_OPC_MNZH_SN,
206  TILEPRO_OPC_MTSPR,
207  TILEPRO_OPC_MULHH_SS,
208  TILEPRO_OPC_MULHH_SS_SN,
209  TILEPRO_OPC_MULHH_SU,
210  TILEPRO_OPC_MULHH_SU_SN,
211  TILEPRO_OPC_MULHH_UU,
212  TILEPRO_OPC_MULHH_UU_SN,
213  TILEPRO_OPC_MULHHA_SS,
214  TILEPRO_OPC_MULHHA_SS_SN,
215  TILEPRO_OPC_MULHHA_SU,
216  TILEPRO_OPC_MULHHA_SU_SN,
217  TILEPRO_OPC_MULHHA_UU,
218  TILEPRO_OPC_MULHHA_UU_SN,
219  TILEPRO_OPC_MULHHSA_UU,
220  TILEPRO_OPC_MULHHSA_UU_SN,
221  TILEPRO_OPC_MULHL_SS,
222  TILEPRO_OPC_MULHL_SS_SN,
223  TILEPRO_OPC_MULHL_SU,
224  TILEPRO_OPC_MULHL_SU_SN,
225  TILEPRO_OPC_MULHL_US,
226  TILEPRO_OPC_MULHL_US_SN,
227  TILEPRO_OPC_MULHL_UU,
228  TILEPRO_OPC_MULHL_UU_SN,
229  TILEPRO_OPC_MULHLA_SS,
230  TILEPRO_OPC_MULHLA_SS_SN,
231  TILEPRO_OPC_MULHLA_SU,
232  TILEPRO_OPC_MULHLA_SU_SN,
233  TILEPRO_OPC_MULHLA_US,
234  TILEPRO_OPC_MULHLA_US_SN,
235  TILEPRO_OPC_MULHLA_UU,
236  TILEPRO_OPC_MULHLA_UU_SN,
237  TILEPRO_OPC_MULHLSA_UU,
238  TILEPRO_OPC_MULHLSA_UU_SN,
239  TILEPRO_OPC_MULLL_SS,
240  TILEPRO_OPC_MULLL_SS_SN,
241  TILEPRO_OPC_MULLL_SU,
242  TILEPRO_OPC_MULLL_SU_SN,
243  TILEPRO_OPC_MULLL_UU,
244  TILEPRO_OPC_MULLL_UU_SN,
245  TILEPRO_OPC_MULLLA_SS,
246  TILEPRO_OPC_MULLLA_SS_SN,
247  TILEPRO_OPC_MULLLA_SU,
248  TILEPRO_OPC_MULLLA_SU_SN,
249  TILEPRO_OPC_MULLLA_UU,
250  TILEPRO_OPC_MULLLA_UU_SN,
251  TILEPRO_OPC_MULLLSA_UU,
252  TILEPRO_OPC_MULLLSA_UU_SN,
253  TILEPRO_OPC_MVNZ,
254  TILEPRO_OPC_MVNZ_SN,
255  TILEPRO_OPC_MVZ,
256  TILEPRO_OPC_MVZ_SN,
257  TILEPRO_OPC_MZ,
258  TILEPRO_OPC_MZ_SN,
259  TILEPRO_OPC_MZB,
260  TILEPRO_OPC_MZB_SN,
261  TILEPRO_OPC_MZH,
262  TILEPRO_OPC_MZH_SN,
263  TILEPRO_OPC_NAP,
264  TILEPRO_OPC_NOP,
265  TILEPRO_OPC_NOR,
266  TILEPRO_OPC_NOR_SN,
267  TILEPRO_OPC_OR,
268  TILEPRO_OPC_OR_SN,
269  TILEPRO_OPC_ORI,
270  TILEPRO_OPC_ORI_SN,
271  TILEPRO_OPC_PACKBS_U,
272  TILEPRO_OPC_PACKBS_U_SN,
273  TILEPRO_OPC_PACKHB,
274  TILEPRO_OPC_PACKHB_SN,
275  TILEPRO_OPC_PACKHS,
276  TILEPRO_OPC_PACKHS_SN,
277  TILEPRO_OPC_PACKLB,
278  TILEPRO_OPC_PACKLB_SN,
279  TILEPRO_OPC_PCNT,
280  TILEPRO_OPC_PCNT_SN,
281  TILEPRO_OPC_RL,
282  TILEPRO_OPC_RL_SN,
283  TILEPRO_OPC_RLI,
284  TILEPRO_OPC_RLI_SN,
285  TILEPRO_OPC_S1A,
286  TILEPRO_OPC_S1A_SN,
287  TILEPRO_OPC_S2A,
288  TILEPRO_OPC_S2A_SN,
289  TILEPRO_OPC_S3A,
290  TILEPRO_OPC_S3A_SN,
291  TILEPRO_OPC_SADAB_U,
292  TILEPRO_OPC_SADAB_U_SN,
293  TILEPRO_OPC_SADAH,
294  TILEPRO_OPC_SADAH_SN,
295  TILEPRO_OPC_SADAH_U,
296  TILEPRO_OPC_SADAH_U_SN,
297  TILEPRO_OPC_SADB_U,
298  TILEPRO_OPC_SADB_U_SN,
299  TILEPRO_OPC_SADH,
300  TILEPRO_OPC_SADH_SN,
301  TILEPRO_OPC_SADH_U,
302  TILEPRO_OPC_SADH_U_SN,
303  TILEPRO_OPC_SB,
304  TILEPRO_OPC_SBADD,
305  TILEPRO_OPC_SEQ,
306  TILEPRO_OPC_SEQ_SN,
307  TILEPRO_OPC_SEQB,
308  TILEPRO_OPC_SEQB_SN,
309  TILEPRO_OPC_SEQH,
310  TILEPRO_OPC_SEQH_SN,
311  TILEPRO_OPC_SEQI,
312  TILEPRO_OPC_SEQI_SN,
313  TILEPRO_OPC_SEQIB,
314  TILEPRO_OPC_SEQIB_SN,
315  TILEPRO_OPC_SEQIH,
316  TILEPRO_OPC_SEQIH_SN,
317  TILEPRO_OPC_SH,
318  TILEPRO_OPC_SHADD,
319  TILEPRO_OPC_SHL,
320  TILEPRO_OPC_SHL_SN,
321  TILEPRO_OPC_SHLB,
322  TILEPRO_OPC_SHLB_SN,
323  TILEPRO_OPC_SHLH,
324  TILEPRO_OPC_SHLH_SN,
325  TILEPRO_OPC_SHLI,
326  TILEPRO_OPC_SHLI_SN,
327  TILEPRO_OPC_SHLIB,
328  TILEPRO_OPC_SHLIB_SN,
329  TILEPRO_OPC_SHLIH,
330  TILEPRO_OPC_SHLIH_SN,
331  TILEPRO_OPC_SHR,
332  TILEPRO_OPC_SHR_SN,
333  TILEPRO_OPC_SHRB,
334  TILEPRO_OPC_SHRB_SN,
335  TILEPRO_OPC_SHRH,
336  TILEPRO_OPC_SHRH_SN,
337  TILEPRO_OPC_SHRI,
338  TILEPRO_OPC_SHRI_SN,
339  TILEPRO_OPC_SHRIB,
340  TILEPRO_OPC_SHRIB_SN,
341  TILEPRO_OPC_SHRIH,
342  TILEPRO_OPC_SHRIH_SN,
343  TILEPRO_OPC_SLT,
344  TILEPRO_OPC_SLT_SN,
345  TILEPRO_OPC_SLT_U,
346  TILEPRO_OPC_SLT_U_SN,
347  TILEPRO_OPC_SLTB,
348  TILEPRO_OPC_SLTB_SN,
349  TILEPRO_OPC_SLTB_U,
350  TILEPRO_OPC_SLTB_U_SN,
351  TILEPRO_OPC_SLTE,
352  TILEPRO_OPC_SLTE_SN,
353  TILEPRO_OPC_SLTE_U,
354  TILEPRO_OPC_SLTE_U_SN,
355  TILEPRO_OPC_SLTEB,
356  TILEPRO_OPC_SLTEB_SN,
357  TILEPRO_OPC_SLTEB_U,
358  TILEPRO_OPC_SLTEB_U_SN,
359  TILEPRO_OPC_SLTEH,
360  TILEPRO_OPC_SLTEH_SN,
361  TILEPRO_OPC_SLTEH_U,
362  TILEPRO_OPC_SLTEH_U_SN,
363  TILEPRO_OPC_SLTH,
364  TILEPRO_OPC_SLTH_SN,
365  TILEPRO_OPC_SLTH_U,
366  TILEPRO_OPC_SLTH_U_SN,
367  TILEPRO_OPC_SLTI,
368  TILEPRO_OPC_SLTI_SN,
369  TILEPRO_OPC_SLTI_U,
370  TILEPRO_OPC_SLTI_U_SN,
371  TILEPRO_OPC_SLTIB,
372  TILEPRO_OPC_SLTIB_SN,
373  TILEPRO_OPC_SLTIB_U,
374  TILEPRO_OPC_SLTIB_U_SN,
375  TILEPRO_OPC_SLTIH,
376  TILEPRO_OPC_SLTIH_SN,
377  TILEPRO_OPC_SLTIH_U,
378  TILEPRO_OPC_SLTIH_U_SN,
379  TILEPRO_OPC_SNE,
380  TILEPRO_OPC_SNE_SN,
381  TILEPRO_OPC_SNEB,
382  TILEPRO_OPC_SNEB_SN,
383  TILEPRO_OPC_SNEH,
384  TILEPRO_OPC_SNEH_SN,
385  TILEPRO_OPC_SRA,
386  TILEPRO_OPC_SRA_SN,
387  TILEPRO_OPC_SRAB,
388  TILEPRO_OPC_SRAB_SN,
389  TILEPRO_OPC_SRAH,
390  TILEPRO_OPC_SRAH_SN,
391  TILEPRO_OPC_SRAI,
392  TILEPRO_OPC_SRAI_SN,
393  TILEPRO_OPC_SRAIB,
394  TILEPRO_OPC_SRAIB_SN,
395  TILEPRO_OPC_SRAIH,
396  TILEPRO_OPC_SRAIH_SN,
397  TILEPRO_OPC_SUB,
398  TILEPRO_OPC_SUB_SN,
399  TILEPRO_OPC_SUBB,
400  TILEPRO_OPC_SUBB_SN,
401  TILEPRO_OPC_SUBBS_U,
402  TILEPRO_OPC_SUBBS_U_SN,
403  TILEPRO_OPC_SUBH,
404  TILEPRO_OPC_SUBH_SN,
405  TILEPRO_OPC_SUBHS,
406  TILEPRO_OPC_SUBHS_SN,
407  TILEPRO_OPC_SUBS,
408  TILEPRO_OPC_SUBS_SN,
409  TILEPRO_OPC_SW,
410  TILEPRO_OPC_SWADD,
411  TILEPRO_OPC_SWINT0,
412  TILEPRO_OPC_SWINT1,
413  TILEPRO_OPC_SWINT2,
414  TILEPRO_OPC_SWINT3,
415  TILEPRO_OPC_TBLIDXB0,
416  TILEPRO_OPC_TBLIDXB0_SN,
417  TILEPRO_OPC_TBLIDXB1,
418  TILEPRO_OPC_TBLIDXB1_SN,
419  TILEPRO_OPC_TBLIDXB2,
420  TILEPRO_OPC_TBLIDXB2_SN,
421  TILEPRO_OPC_TBLIDXB3,
422  TILEPRO_OPC_TBLIDXB3_SN,
423  TILEPRO_OPC_TNS,
424  TILEPRO_OPC_TNS_SN,
425  TILEPRO_OPC_WH64,
426  TILEPRO_OPC_XOR,
427  TILEPRO_OPC_XOR_SN,
428  TILEPRO_OPC_XORI,
429  TILEPRO_OPC_XORI_SN,
430  TILEPRO_OPC_NONE
431} tilepro_mnemonic;
432
433/* 64-bit pattern for a { bpt ; nop } bundle. */
434#define TILEPRO_BPT_BUNDLE 0x400b3cae70166000ULL
435
436#ifndef DISASM_ONLY
437
438enum
439{
440  TILEPRO_SN_MAX_OPERANDS = 6 /* route */
441};
442
443typedef enum
444{
445  TILEPRO_SN_OPC_BZ,
446  TILEPRO_SN_OPC_BNZ,
447  TILEPRO_SN_OPC_JRR,
448  TILEPRO_SN_OPC_FNOP,
449  TILEPRO_SN_OPC_BLZ,
450  TILEPRO_SN_OPC_NOP,
451  TILEPRO_SN_OPC_MOVEI,
452  TILEPRO_SN_OPC_MOVE,
453  TILEPRO_SN_OPC_BGEZ,
454  TILEPRO_SN_OPC_JR,
455  TILEPRO_SN_OPC_BLEZ,
456  TILEPRO_SN_OPC_BBNS,
457  TILEPRO_SN_OPC_JALRR,
458  TILEPRO_SN_OPC_BPT,
459  TILEPRO_SN_OPC_JALR,
460  TILEPRO_SN_OPC_SHR1,
461  TILEPRO_SN_OPC_BGZ,
462  TILEPRO_SN_OPC_BBS,
463  TILEPRO_SN_OPC_SHL8II,
464  TILEPRO_SN_OPC_ADDI,
465  TILEPRO_SN_OPC_HALT,
466  TILEPRO_SN_OPC_ROUTE,
467  TILEPRO_SN_OPC_NONE
468} tilepro_sn_mnemonic;
469
470extern const unsigned char tilepro_sn_route_encode[6 * 6 * 6];
471extern const signed char tilepro_sn_route_decode[256][3];
472extern const char tilepro_sn_direction_names[6][5];
473extern const signed char tilepro_sn_dest_map[6][6];
474#endif /* DISASM_ONLY */
475
476
477static __inline unsigned int
478get_BrOff_SN(tilepro_bundle_bits num)
479{
480  const unsigned int n = (unsigned int)num;
481  return (((n >> 0)) & 0x3ff);
482}
483
484static __inline unsigned int
485get_BrOff_X1(tilepro_bundle_bits n)
486{
487  return (((unsigned int)(n >> 43)) & 0x00007fff) |
488         (((unsigned int)(n >> 20)) & 0x00018000);
489}
490
491static __inline unsigned int
492get_BrType_X1(tilepro_bundle_bits n)
493{
494  return (((unsigned int)(n >> 31)) & 0xf);
495}
496
497static __inline unsigned int
498get_Dest_Imm8_X1(tilepro_bundle_bits n)
499{
500  return (((unsigned int)(n >> 31)) & 0x0000003f) |
501         (((unsigned int)(n >> 43)) & 0x000000c0);
502}
503
504static __inline unsigned int
505get_Dest_SN(tilepro_bundle_bits num)
506{
507  const unsigned int n = (unsigned int)num;
508  return (((n >> 2)) & 0x3);
509}
510
511static __inline unsigned int
512get_Dest_X0(tilepro_bundle_bits num)
513{
514  const unsigned int n = (unsigned int)num;
515  return (((n >> 0)) & 0x3f);
516}
517
518static __inline unsigned int
519get_Dest_X1(tilepro_bundle_bits n)
520{
521  return (((unsigned int)(n >> 31)) & 0x3f);
522}
523
524static __inline unsigned int
525get_Dest_Y0(tilepro_bundle_bits num)
526{
527  const unsigned int n = (unsigned int)num;
528  return (((n >> 0)) & 0x3f);
529}
530
531static __inline unsigned int
532get_Dest_Y1(tilepro_bundle_bits n)
533{
534  return (((unsigned int)(n >> 31)) & 0x3f);
535}
536
537static __inline unsigned int
538get_Imm16_X0(tilepro_bundle_bits num)
539{
540  const unsigned int n = (unsigned int)num;
541  return (((n >> 12)) & 0xffff);
542}
543
544static __inline unsigned int
545get_Imm16_X1(tilepro_bundle_bits n)
546{
547  return (((unsigned int)(n >> 43)) & 0xffff);
548}
549
550static __inline unsigned int
551get_Imm8_SN(tilepro_bundle_bits num)
552{
553  const unsigned int n = (unsigned int)num;
554  return (((n >> 0)) & 0xff);
555}
556
557static __inline unsigned int
558get_Imm8_X0(tilepro_bundle_bits num)
559{
560  const unsigned int n = (unsigned int)num;
561  return (((n >> 12)) & 0xff);
562}
563
564static __inline unsigned int
565get_Imm8_X1(tilepro_bundle_bits n)
566{
567  return (((unsigned int)(n >> 43)) & 0xff);
568}
569
570static __inline unsigned int
571get_Imm8_Y0(tilepro_bundle_bits num)
572{
573  const unsigned int n = (unsigned int)num;
574  return (((n >> 12)) & 0xff);
575}
576
577static __inline unsigned int
578get_Imm8_Y1(tilepro_bundle_bits n)
579{
580  return (((unsigned int)(n >> 43)) & 0xff);
581}
582
583static __inline unsigned int
584get_ImmOpcodeExtension_X0(tilepro_bundle_bits num)
585{
586  const unsigned int n = (unsigned int)num;
587  return (((n >> 20)) & 0x7f);
588}
589
590static __inline unsigned int
591get_ImmOpcodeExtension_X1(tilepro_bundle_bits n)
592{
593  return (((unsigned int)(n >> 51)) & 0x7f);
594}
595
596static __inline unsigned int
597get_ImmRROpcodeExtension_SN(tilepro_bundle_bits num)
598{
599  const unsigned int n = (unsigned int)num;
600  return (((n >> 8)) & 0x3);
601}
602
603static __inline unsigned int
604get_JOffLong_X1(tilepro_bundle_bits n)
605{
606  return (((unsigned int)(n >> 43)) & 0x00007fff) |
607         (((unsigned int)(n >> 20)) & 0x00018000) |
608         (((unsigned int)(n >> 14)) & 0x001e0000) |
609         (((unsigned int)(n >> 16)) & 0x07e00000) |
610         (((unsigned int)(n >> 31)) & 0x18000000);
611}
612
613static __inline unsigned int
614get_JOff_X1(tilepro_bundle_bits n)
615{
616  return (((unsigned int)(n >> 43)) & 0x00007fff) |
617         (((unsigned int)(n >> 20)) & 0x00018000) |
618         (((unsigned int)(n >> 14)) & 0x001e0000) |
619         (((unsigned int)(n >> 16)) & 0x07e00000) |
620         (((unsigned int)(n >> 31)) & 0x08000000);
621}
622
623static __inline unsigned int
624get_MF_Imm15_X1(tilepro_bundle_bits n)
625{
626  return (((unsigned int)(n >> 37)) & 0x00003fff) |
627         (((unsigned int)(n >> 44)) & 0x00004000);
628}
629
630static __inline unsigned int
631get_MMEnd_X0(tilepro_bundle_bits num)
632{
633  const unsigned int n = (unsigned int)num;
634  return (((n >> 18)) & 0x1f);
635}
636
637static __inline unsigned int
638get_MMEnd_X1(tilepro_bundle_bits n)
639{
640  return (((unsigned int)(n >> 49)) & 0x1f);
641}
642
643static __inline unsigned int
644get_MMStart_X0(tilepro_bundle_bits num)
645{
646  const unsigned int n = (unsigned int)num;
647  return (((n >> 23)) & 0x1f);
648}
649
650static __inline unsigned int
651get_MMStart_X1(tilepro_bundle_bits n)
652{
653  return (((unsigned int)(n >> 54)) & 0x1f);
654}
655
656static __inline unsigned int
657get_MT_Imm15_X1(tilepro_bundle_bits n)
658{
659  return (((unsigned int)(n >> 31)) & 0x0000003f) |
660         (((unsigned int)(n >> 37)) & 0x00003fc0) |
661         (((unsigned int)(n >> 44)) & 0x00004000);
662}
663
664static __inline unsigned int
665get_Mode(tilepro_bundle_bits n)
666{
667  return (((unsigned int)(n >> 63)) & 0x1);
668}
669
670static __inline unsigned int
671get_NoRegOpcodeExtension_SN(tilepro_bundle_bits num)
672{
673  const unsigned int n = (unsigned int)num;
674  return (((n >> 0)) & 0xf);
675}
676
677static __inline unsigned int
678get_Opcode_SN(tilepro_bundle_bits num)
679{
680  const unsigned int n = (unsigned int)num;
681  return (((n >> 10)) & 0x3f);
682}
683
684static __inline unsigned int
685get_Opcode_X0(tilepro_bundle_bits num)
686{
687  const unsigned int n = (unsigned int)num;
688  return (((n >> 28)) & 0x7);
689}
690
691static __inline unsigned int
692get_Opcode_X1(tilepro_bundle_bits n)
693{
694  return (((unsigned int)(n >> 59)) & 0xf);
695}
696
697static __inline unsigned int
698get_Opcode_Y0(tilepro_bundle_bits num)
699{
700  const unsigned int n = (unsigned int)num;
701  return (((n >> 27)) & 0xf);
702}
703
704static __inline unsigned int
705get_Opcode_Y1(tilepro_bundle_bits n)
706{
707  return (((unsigned int)(n >> 59)) & 0xf);
708}
709
710static __inline unsigned int
711get_Opcode_Y2(tilepro_bundle_bits n)
712{
713  return (((unsigned int)(n >> 56)) & 0x7);
714}
715
716static __inline unsigned int
717get_RROpcodeExtension_SN(tilepro_bundle_bits num)
718{
719  const unsigned int n = (unsigned int)num;
720  return (((n >> 4)) & 0xf);
721}
722
723static __inline unsigned int
724get_RRROpcodeExtension_X0(tilepro_bundle_bits num)
725{
726  const unsigned int n = (unsigned int)num;
727  return (((n >> 18)) & 0x1ff);
728}
729
730static __inline unsigned int
731get_RRROpcodeExtension_X1(tilepro_bundle_bits n)
732{
733  return (((unsigned int)(n >> 49)) & 0x1ff);
734}
735
736static __inline unsigned int
737get_RRROpcodeExtension_Y0(tilepro_bundle_bits num)
738{
739  const unsigned int n = (unsigned int)num;
740  return (((n >> 18)) & 0x3);
741}
742
743static __inline unsigned int
744get_RRROpcodeExtension_Y1(tilepro_bundle_bits n)
745{
746  return (((unsigned int)(n >> 49)) & 0x3);
747}
748
749static __inline unsigned int
750get_RouteOpcodeExtension_SN(tilepro_bundle_bits num)
751{
752  const unsigned int n = (unsigned int)num;
753  return (((n >> 0)) & 0x3ff);
754}
755
756static __inline unsigned int
757get_S_X0(tilepro_bundle_bits num)
758{
759  const unsigned int n = (unsigned int)num;
760  return (((n >> 27)) & 0x1);
761}
762
763static __inline unsigned int
764get_S_X1(tilepro_bundle_bits n)
765{
766  return (((unsigned int)(n >> 58)) & 0x1);
767}
768
769static __inline unsigned int
770get_ShAmt_X0(tilepro_bundle_bits num)
771{
772  const unsigned int n = (unsigned int)num;
773  return (((n >> 12)) & 0x1f);
774}
775
776static __inline unsigned int
777get_ShAmt_X1(tilepro_bundle_bits n)
778{
779  return (((unsigned int)(n >> 43)) & 0x1f);
780}
781
782static __inline unsigned int
783get_ShAmt_Y0(tilepro_bundle_bits num)
784{
785  const unsigned int n = (unsigned int)num;
786  return (((n >> 12)) & 0x1f);
787}
788
789static __inline unsigned int
790get_ShAmt_Y1(tilepro_bundle_bits n)
791{
792  return (((unsigned int)(n >> 43)) & 0x1f);
793}
794
795static __inline unsigned int
796get_SrcA_X0(tilepro_bundle_bits num)
797{
798  const unsigned int n = (unsigned int)num;
799  return (((n >> 6)) & 0x3f);
800}
801
802static __inline unsigned int
803get_SrcA_X1(tilepro_bundle_bits n)
804{
805  return (((unsigned int)(n >> 37)) & 0x3f);
806}
807
808static __inline unsigned int
809get_SrcA_Y0(tilepro_bundle_bits num)
810{
811  const unsigned int n = (unsigned int)num;
812  return (((n >> 6)) & 0x3f);
813}
814
815static __inline unsigned int
816get_SrcA_Y1(tilepro_bundle_bits n)
817{
818  return (((unsigned int)(n >> 37)) & 0x3f);
819}
820
821static __inline unsigned int
822get_SrcA_Y2(tilepro_bundle_bits n)
823{
824  return (((n >> 26)) & 0x00000001) |
825         (((unsigned int)(n >> 50)) & 0x0000003e);
826}
827
828static __inline unsigned int
829get_SrcBDest_Y2(tilepro_bundle_bits num)
830{
831  const unsigned int n = (unsigned int)num;
832  return (((n >> 20)) & 0x3f);
833}
834
835static __inline unsigned int
836get_SrcB_X0(tilepro_bundle_bits num)
837{
838  const unsigned int n = (unsigned int)num;
839  return (((n >> 12)) & 0x3f);
840}
841
842static __inline unsigned int
843get_SrcB_X1(tilepro_bundle_bits n)
844{
845  return (((unsigned int)(n >> 43)) & 0x3f);
846}
847
848static __inline unsigned int
849get_SrcB_Y0(tilepro_bundle_bits num)
850{
851  const unsigned int n = (unsigned int)num;
852  return (((n >> 12)) & 0x3f);
853}
854
855static __inline unsigned int
856get_SrcB_Y1(tilepro_bundle_bits n)
857{
858  return (((unsigned int)(n >> 43)) & 0x3f);
859}
860
861static __inline unsigned int
862get_Src_SN(tilepro_bundle_bits num)
863{
864  const unsigned int n = (unsigned int)num;
865  return (((n >> 0)) & 0x3);
866}
867
868static __inline unsigned int
869get_UnOpcodeExtension_X0(tilepro_bundle_bits num)
870{
871  const unsigned int n = (unsigned int)num;
872  return (((n >> 12)) & 0x1f);
873}
874
875static __inline unsigned int
876get_UnOpcodeExtension_X1(tilepro_bundle_bits n)
877{
878  return (((unsigned int)(n >> 43)) & 0x1f);
879}
880
881static __inline unsigned int
882get_UnOpcodeExtension_Y0(tilepro_bundle_bits num)
883{
884  const unsigned int n = (unsigned int)num;
885  return (((n >> 12)) & 0x1f);
886}
887
888static __inline unsigned int
889get_UnOpcodeExtension_Y1(tilepro_bundle_bits n)
890{
891  return (((unsigned int)(n >> 43)) & 0x1f);
892}
893
894static __inline unsigned int
895get_UnShOpcodeExtension_X0(tilepro_bundle_bits num)
896{
897  const unsigned int n = (unsigned int)num;
898  return (((n >> 17)) & 0x3ff);
899}
900
901static __inline unsigned int
902get_UnShOpcodeExtension_X1(tilepro_bundle_bits n)
903{
904  return (((unsigned int)(n >> 48)) & 0x3ff);
905}
906
907static __inline unsigned int
908get_UnShOpcodeExtension_Y0(tilepro_bundle_bits num)
909{
910  const unsigned int n = (unsigned int)num;
911  return (((n >> 17)) & 0x7);
912}
913
914static __inline unsigned int
915get_UnShOpcodeExtension_Y1(tilepro_bundle_bits n)
916{
917  return (((unsigned int)(n >> 48)) & 0x7);
918}
919
920
921static __inline int
922sign_extend(int n, int num_bits)
923{
924  int shift = (int)(sizeof(int) * 8 - num_bits);
925  return (n << shift) >> shift;
926}
927
928
929
930static __inline tilepro_bundle_bits
931create_BrOff_SN(int num)
932{
933  const unsigned int n = (unsigned int)num;
934  return ((n & 0x3ff) << 0);
935}
936
937static __inline tilepro_bundle_bits
938create_BrOff_X1(int num)
939{
940  const unsigned int n = (unsigned int)num;
941  return (((tilepro_bundle_bits)(n & 0x00007fff)) << 43) |
942         (((tilepro_bundle_bits)(n & 0x00018000)) << 20);
943}
944
945static __inline tilepro_bundle_bits
946create_BrType_X1(int num)
947{
948  const unsigned int n = (unsigned int)num;
949  return (((tilepro_bundle_bits)(n & 0xf)) << 31);
950}
951
952static __inline tilepro_bundle_bits
953create_Dest_Imm8_X1(int num)
954{
955  const unsigned int n = (unsigned int)num;
956  return (((tilepro_bundle_bits)(n & 0x0000003f)) << 31) |
957         (((tilepro_bundle_bits)(n & 0x000000c0)) << 43);
958}
959
960static __inline tilepro_bundle_bits
961create_Dest_SN(int num)
962{
963  const unsigned int n = (unsigned int)num;
964  return ((n & 0x3) << 2);
965}
966
967static __inline tilepro_bundle_bits
968create_Dest_X0(int num)
969{
970  const unsigned int n = (unsigned int)num;
971  return ((n & 0x3f) << 0);
972}
973
974static __inline tilepro_bundle_bits
975create_Dest_X1(int num)
976{
977  const unsigned int n = (unsigned int)num;
978  return (((tilepro_bundle_bits)(n & 0x3f)) << 31);
979}
980
981static __inline tilepro_bundle_bits
982create_Dest_Y0(int num)
983{
984  const unsigned int n = (unsigned int)num;
985  return ((n & 0x3f) << 0);
986}
987
988static __inline tilepro_bundle_bits
989create_Dest_Y1(int num)
990{
991  const unsigned int n = (unsigned int)num;
992  return (((tilepro_bundle_bits)(n & 0x3f)) << 31);
993}
994
995static __inline tilepro_bundle_bits
996create_Imm16_X0(int num)
997{
998  const unsigned int n = (unsigned int)num;
999  return ((n & 0xffff) << 12);
1000}
1001
1002static __inline tilepro_bundle_bits
1003create_Imm16_X1(int num)
1004{
1005  const unsigned int n = (unsigned int)num;
1006  return (((tilepro_bundle_bits)(n & 0xffff)) << 43);
1007}
1008
1009static __inline tilepro_bundle_bits
1010create_Imm8_SN(int num)
1011{
1012  const unsigned int n = (unsigned int)num;
1013  return ((n & 0xff) << 0);
1014}
1015
1016static __inline tilepro_bundle_bits
1017create_Imm8_X0(int num)
1018{
1019  const unsigned int n = (unsigned int)num;
1020  return ((n & 0xff) << 12);
1021}
1022
1023static __inline tilepro_bundle_bits
1024create_Imm8_X1(int num)
1025{
1026  const unsigned int n = (unsigned int)num;
1027  return (((tilepro_bundle_bits)(n & 0xff)) << 43);
1028}
1029
1030static __inline tilepro_bundle_bits
1031create_Imm8_Y0(int num)
1032{
1033  const unsigned int n = (unsigned int)num;
1034  return ((n & 0xff) << 12);
1035}
1036
1037static __inline tilepro_bundle_bits
1038create_Imm8_Y1(int num)
1039{
1040  const unsigned int n = (unsigned int)num;
1041  return (((tilepro_bundle_bits)(n & 0xff)) << 43);
1042}
1043
1044static __inline tilepro_bundle_bits
1045create_ImmOpcodeExtension_X0(int num)
1046{
1047  const unsigned int n = (unsigned int)num;
1048  return ((n & 0x7f) << 20);
1049}
1050
1051static __inline tilepro_bundle_bits
1052create_ImmOpcodeExtension_X1(int num)
1053{
1054  const unsigned int n = (unsigned int)num;
1055  return (((tilepro_bundle_bits)(n & 0x7f)) << 51);
1056}
1057
1058static __inline tilepro_bundle_bits
1059create_ImmRROpcodeExtension_SN(int num)
1060{
1061  const unsigned int n = (unsigned int)num;
1062  return ((n & 0x3) << 8);
1063}
1064
1065static __inline tilepro_bundle_bits
1066create_JOffLong_X1(int num)
1067{
1068  const unsigned int n = (unsigned int)num;
1069  return (((tilepro_bundle_bits)(n & 0x00007fff)) << 43) |
1070         (((tilepro_bundle_bits)(n & 0x00018000)) << 20) |
1071         (((tilepro_bundle_bits)(n & 0x001e0000)) << 14) |
1072         (((tilepro_bundle_bits)(n & 0x07e00000)) << 16) |
1073         (((tilepro_bundle_bits)(n & 0x18000000)) << 31);
1074}
1075
1076static __inline tilepro_bundle_bits
1077create_JOff_X1(int num)
1078{
1079  const unsigned int n = (unsigned int)num;
1080  return (((tilepro_bundle_bits)(n & 0x00007fff)) << 43) |
1081         (((tilepro_bundle_bits)(n & 0x00018000)) << 20) |
1082         (((tilepro_bundle_bits)(n & 0x001e0000)) << 14) |
1083         (((tilepro_bundle_bits)(n & 0x07e00000)) << 16) |
1084         (((tilepro_bundle_bits)(n & 0x08000000)) << 31);
1085}
1086
1087static __inline tilepro_bundle_bits
1088create_MF_Imm15_X1(int num)
1089{
1090  const unsigned int n = (unsigned int)num;
1091  return (((tilepro_bundle_bits)(n & 0x00003fff)) << 37) |
1092         (((tilepro_bundle_bits)(n & 0x00004000)) << 44);
1093}
1094
1095static __inline tilepro_bundle_bits
1096create_MMEnd_X0(int num)
1097{
1098  const unsigned int n = (unsigned int)num;
1099  return ((n & 0x1f) << 18);
1100}
1101
1102static __inline tilepro_bundle_bits
1103create_MMEnd_X1(int num)
1104{
1105  const unsigned int n = (unsigned int)num;
1106  return (((tilepro_bundle_bits)(n & 0x1f)) << 49);
1107}
1108
1109static __inline tilepro_bundle_bits
1110create_MMStart_X0(int num)
1111{
1112  const unsigned int n = (unsigned int)num;
1113  return ((n & 0x1f) << 23);
1114}
1115
1116static __inline tilepro_bundle_bits
1117create_MMStart_X1(int num)
1118{
1119  const unsigned int n = (unsigned int)num;
1120  return (((tilepro_bundle_bits)(n & 0x1f)) << 54);
1121}
1122
1123static __inline tilepro_bundle_bits
1124create_MT_Imm15_X1(int num)
1125{
1126  const unsigned int n = (unsigned int)num;
1127  return (((tilepro_bundle_bits)(n & 0x0000003f)) << 31) |
1128         (((tilepro_bundle_bits)(n & 0x00003fc0)) << 37) |
1129         (((tilepro_bundle_bits)(n & 0x00004000)) << 44);
1130}
1131
1132static __inline tilepro_bundle_bits
1133create_Mode(int num)
1134{
1135  const unsigned int n = (unsigned int)num;
1136  return (((tilepro_bundle_bits)(n & 0x1)) << 63);
1137}
1138
1139static __inline tilepro_bundle_bits
1140create_NoRegOpcodeExtension_SN(int num)
1141{
1142  const unsigned int n = (unsigned int)num;
1143  return ((n & 0xf) << 0);
1144}
1145
1146static __inline tilepro_bundle_bits
1147create_Opcode_SN(int num)
1148{
1149  const unsigned int n = (unsigned int)num;
1150  return ((n & 0x3f) << 10);
1151}
1152
1153static __inline tilepro_bundle_bits
1154create_Opcode_X0(int num)
1155{
1156  const unsigned int n = (unsigned int)num;
1157  return ((n & 0x7) << 28);
1158}
1159
1160static __inline tilepro_bundle_bits
1161create_Opcode_X1(int num)
1162{
1163  const unsigned int n = (unsigned int)num;
1164  return (((tilepro_bundle_bits)(n & 0xf)) << 59);
1165}
1166
1167static __inline tilepro_bundle_bits
1168create_Opcode_Y0(int num)
1169{
1170  const unsigned int n = (unsigned int)num;
1171  return ((n & 0xf) << 27);
1172}
1173
1174static __inline tilepro_bundle_bits
1175create_Opcode_Y1(int num)
1176{
1177  const unsigned int n = (unsigned int)num;
1178  return (((tilepro_bundle_bits)(n & 0xf)) << 59);
1179}
1180
1181static __inline tilepro_bundle_bits
1182create_Opcode_Y2(int num)
1183{
1184  const unsigned int n = (unsigned int)num;
1185  return (((tilepro_bundle_bits)(n & 0x7)) << 56);
1186}
1187
1188static __inline tilepro_bundle_bits
1189create_RROpcodeExtension_SN(int num)
1190{
1191  const unsigned int n = (unsigned int)num;
1192  return ((n & 0xf) << 4);
1193}
1194
1195static __inline tilepro_bundle_bits
1196create_RRROpcodeExtension_X0(int num)
1197{
1198  const unsigned int n = (unsigned int)num;
1199  return ((n & 0x1ff) << 18);
1200}
1201
1202static __inline tilepro_bundle_bits
1203create_RRROpcodeExtension_X1(int num)
1204{
1205  const unsigned int n = (unsigned int)num;
1206  return (((tilepro_bundle_bits)(n & 0x1ff)) << 49);
1207}
1208
1209static __inline tilepro_bundle_bits
1210create_RRROpcodeExtension_Y0(int num)
1211{
1212  const unsigned int n = (unsigned int)num;
1213  return ((n & 0x3) << 18);
1214}
1215
1216static __inline tilepro_bundle_bits
1217create_RRROpcodeExtension_Y1(int num)
1218{
1219  const unsigned int n = (unsigned int)num;
1220  return (((tilepro_bundle_bits)(n & 0x3)) << 49);
1221}
1222
1223static __inline tilepro_bundle_bits
1224create_RouteOpcodeExtension_SN(int num)
1225{
1226  const unsigned int n = (unsigned int)num;
1227  return ((n & 0x3ff) << 0);
1228}
1229
1230static __inline tilepro_bundle_bits
1231create_S_X0(int num)
1232{
1233  const unsigned int n = (unsigned int)num;
1234  return ((n & 0x1) << 27);
1235}
1236
1237static __inline tilepro_bundle_bits
1238create_S_X1(int num)
1239{
1240  const unsigned int n = (unsigned int)num;
1241  return (((tilepro_bundle_bits)(n & 0x1)) << 58);
1242}
1243
1244static __inline tilepro_bundle_bits
1245create_ShAmt_X0(int num)
1246{
1247  const unsigned int n = (unsigned int)num;
1248  return ((n & 0x1f) << 12);
1249}
1250
1251static __inline tilepro_bundle_bits
1252create_ShAmt_X1(int num)
1253{
1254  const unsigned int n = (unsigned int)num;
1255  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1256}
1257
1258static __inline tilepro_bundle_bits
1259create_ShAmt_Y0(int num)
1260{
1261  const unsigned int n = (unsigned int)num;
1262  return ((n & 0x1f) << 12);
1263}
1264
1265static __inline tilepro_bundle_bits
1266create_ShAmt_Y1(int num)
1267{
1268  const unsigned int n = (unsigned int)num;
1269  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1270}
1271
1272static __inline tilepro_bundle_bits
1273create_SrcA_X0(int num)
1274{
1275  const unsigned int n = (unsigned int)num;
1276  return ((n & 0x3f) << 6);
1277}
1278
1279static __inline tilepro_bundle_bits
1280create_SrcA_X1(int num)
1281{
1282  const unsigned int n = (unsigned int)num;
1283  return (((tilepro_bundle_bits)(n & 0x3f)) << 37);
1284}
1285
1286static __inline tilepro_bundle_bits
1287create_SrcA_Y0(int num)
1288{
1289  const unsigned int n = (unsigned int)num;
1290  return ((n & 0x3f) << 6);
1291}
1292
1293static __inline tilepro_bundle_bits
1294create_SrcA_Y1(int num)
1295{
1296  const unsigned int n = (unsigned int)num;
1297  return (((tilepro_bundle_bits)(n & 0x3f)) << 37);
1298}
1299
1300static __inline tilepro_bundle_bits
1301create_SrcA_Y2(int num)
1302{
1303  const unsigned int n = (unsigned int)num;
1304  return ((n & 0x00000001) << 26) |
1305         (((tilepro_bundle_bits)(n & 0x0000003e)) << 50);
1306}
1307
1308static __inline tilepro_bundle_bits
1309create_SrcBDest_Y2(int num)
1310{
1311  const unsigned int n = (unsigned int)num;
1312  return ((n & 0x3f) << 20);
1313}
1314
1315static __inline tilepro_bundle_bits
1316create_SrcB_X0(int num)
1317{
1318  const unsigned int n = (unsigned int)num;
1319  return ((n & 0x3f) << 12);
1320}
1321
1322static __inline tilepro_bundle_bits
1323create_SrcB_X1(int num)
1324{
1325  const unsigned int n = (unsigned int)num;
1326  return (((tilepro_bundle_bits)(n & 0x3f)) << 43);
1327}
1328
1329static __inline tilepro_bundle_bits
1330create_SrcB_Y0(int num)
1331{
1332  const unsigned int n = (unsigned int)num;
1333  return ((n & 0x3f) << 12);
1334}
1335
1336static __inline tilepro_bundle_bits
1337create_SrcB_Y1(int num)
1338{
1339  const unsigned int n = (unsigned int)num;
1340  return (((tilepro_bundle_bits)(n & 0x3f)) << 43);
1341}
1342
1343static __inline tilepro_bundle_bits
1344create_Src_SN(int num)
1345{
1346  const unsigned int n = (unsigned int)num;
1347  return ((n & 0x3) << 0);
1348}
1349
1350static __inline tilepro_bundle_bits
1351create_UnOpcodeExtension_X0(int num)
1352{
1353  const unsigned int n = (unsigned int)num;
1354  return ((n & 0x1f) << 12);
1355}
1356
1357static __inline tilepro_bundle_bits
1358create_UnOpcodeExtension_X1(int num)
1359{
1360  const unsigned int n = (unsigned int)num;
1361  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1362}
1363
1364static __inline tilepro_bundle_bits
1365create_UnOpcodeExtension_Y0(int num)
1366{
1367  const unsigned int n = (unsigned int)num;
1368  return ((n & 0x1f) << 12);
1369}
1370
1371static __inline tilepro_bundle_bits
1372create_UnOpcodeExtension_Y1(int num)
1373{
1374  const unsigned int n = (unsigned int)num;
1375  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1376}
1377
1378static __inline tilepro_bundle_bits
1379create_UnShOpcodeExtension_X0(int num)
1380{
1381  const unsigned int n = (unsigned int)num;
1382  return ((n & 0x3ff) << 17);
1383}
1384
1385static __inline tilepro_bundle_bits
1386create_UnShOpcodeExtension_X1(int num)
1387{
1388  const unsigned int n = (unsigned int)num;
1389  return (((tilepro_bundle_bits)(n & 0x3ff)) << 48);
1390}
1391
1392static __inline tilepro_bundle_bits
1393create_UnShOpcodeExtension_Y0(int num)
1394{
1395  const unsigned int n = (unsigned int)num;
1396  return ((n & 0x7) << 17);
1397}
1398
1399static __inline tilepro_bundle_bits
1400create_UnShOpcodeExtension_Y1(int num)
1401{
1402  const unsigned int n = (unsigned int)num;
1403  return (((tilepro_bundle_bits)(n & 0x7)) << 48);
1404}
1405
1406
1407
1408typedef enum
1409{
1410  TILEPRO_PIPELINE_X0,
1411  TILEPRO_PIPELINE_X1,
1412  TILEPRO_PIPELINE_Y0,
1413  TILEPRO_PIPELINE_Y1,
1414  TILEPRO_PIPELINE_Y2,
1415} tilepro_pipeline;
1416
1417#define tilepro_is_x_pipeline(p) ((int)(p) <= (int)TILEPRO_PIPELINE_X1)
1418
1419typedef enum
1420{
1421  TILEPRO_OP_TYPE_REGISTER,
1422  TILEPRO_OP_TYPE_IMMEDIATE,
1423  TILEPRO_OP_TYPE_ADDRESS,
1424  TILEPRO_OP_TYPE_SPR
1425} tilepro_operand_type;
1426
1427/* This is the bit that determines if a bundle is in the Y encoding. */
1428#define TILEPRO_BUNDLE_Y_ENCODING_MASK ((tilepro_bundle_bits)1 << 63)
1429
1430enum
1431{
1432  /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1433  TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE = 3,
1434
1435  /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
1436  TILEPRO_NUM_PIPELINE_ENCODINGS = 5,
1437
1438  /* Log base 2 of TILEPRO_BUNDLE_SIZE_IN_BYTES. */
1439  TILEPRO_LOG2_BUNDLE_SIZE_IN_BYTES = 3,
1440
1441  /* Instructions take this many bytes. */
1442  TILEPRO_BUNDLE_SIZE_IN_BYTES = 1 << TILEPRO_LOG2_BUNDLE_SIZE_IN_BYTES,
1443
1444  /* Log base 2 of TILEPRO_BUNDLE_ALIGNMENT_IN_BYTES. */
1445  TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3,
1446
1447  /* Bundles should be aligned modulo this number of bytes. */
1448  TILEPRO_BUNDLE_ALIGNMENT_IN_BYTES =
1449    (1 << TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES),
1450
1451  /* Log base 2 of TILEPRO_SN_INSTRUCTION_SIZE_IN_BYTES. */
1452  TILEPRO_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES = 1,
1453
1454  /* Static network instructions take this many bytes. */
1455  TILEPRO_SN_INSTRUCTION_SIZE_IN_BYTES =
1456    (1 << TILEPRO_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES),
1457
1458  /* Number of registers (some are magic, such as network I/O). */
1459  TILEPRO_NUM_REGISTERS = 64,
1460
1461  /* Number of static network registers. */
1462  TILEPRO_NUM_SN_REGISTERS = 4
1463};
1464
1465
1466struct tilepro_operand
1467{
1468  /* Is this operand a register, immediate or address? */
1469  tilepro_operand_type type;
1470
1471  /* The default relocation type for this operand.  */
1472  signed int default_reloc : 16;
1473
1474  /* How many bits is this value? (used for range checking) */
1475  unsigned int num_bits : 5;
1476
1477  /* Is the value signed? (used for range checking) */
1478  unsigned int is_signed : 1;
1479
1480  /* Is this operand a source register? */
1481  unsigned int is_src_reg : 1;
1482
1483  /* Is this operand written? (i.e. is it a destination register) */
1484  unsigned int is_dest_reg : 1;
1485
1486  /* Is this operand PC-relative? */
1487  unsigned int is_pc_relative : 1;
1488
1489  /* By how many bits do we right shift the value before inserting? */
1490  unsigned int rightshift : 2;
1491
1492  /* Return the bits for this operand to be ORed into an existing bundle. */
1493  tilepro_bundle_bits (*insert) (int op);
1494
1495  /* Extract this operand and return it. */
1496  unsigned int (*extract) (tilepro_bundle_bits bundle);
1497};
1498
1499
1500extern const struct tilepro_operand tilepro_operands[];
1501
1502/* One finite-state machine per pipe for rapid instruction decoding. */
1503extern const unsigned short * const
1504tilepro_bundle_decoder_fsms[TILEPRO_NUM_PIPELINE_ENCODINGS];
1505
1506
1507struct tilepro_opcode
1508{
1509  /* The opcode mnemonic, e.g. "add" */
1510  const char *name;
1511
1512  /* The enum value for this mnemonic. */
1513  tilepro_mnemonic mnemonic;
1514
1515  /* A bit mask of which of the five pipes this instruction
1516     is compatible with:
1517     X0  0x01
1518     X1  0x02
1519     Y0  0x04
1520     Y1  0x08
1521     Y2  0x10 */
1522  unsigned char pipes;
1523
1524  /* How many operands are there? */
1525  unsigned char num_operands;
1526
1527  /* Which register does this write implicitly, or TREG_ZERO if none? */
1528  unsigned char implicitly_written_register;
1529
1530  /* Can this be bundled with other instructions (almost always true). */
1531  unsigned char can_bundle;
1532
1533  /* The description of the operands. Each of these is an
1534   * index into the tilepro_operands[] table. */
1535  unsigned char operands[TILEPRO_NUM_PIPELINE_ENCODINGS][TILEPRO_MAX_OPERANDS];
1536
1537#if !defined(__KERNEL__) && !defined(_LIBC)
1538  /* A mask of which bits have predefined values for each pipeline.
1539   * This is useful for disassembly. */
1540  tilepro_bundle_bits fixed_bit_masks[TILEPRO_NUM_PIPELINE_ENCODINGS];
1541
1542  /* For each bit set in fixed_bit_masks, what the value is for this
1543   * instruction. */
1544  tilepro_bundle_bits fixed_bit_values[TILEPRO_NUM_PIPELINE_ENCODINGS];
1545#endif
1546};
1547
1548extern const struct tilepro_opcode tilepro_opcodes[];
1549
1550#if !defined(__KERNEL__) && !defined(_LIBC)
1551
1552typedef unsigned short tilepro_sn_instruction_bits;
1553
1554struct tilepro_sn_opcode
1555{
1556  /* The opcode mnemonic, e.g. "add" */
1557  const char *name;
1558
1559  /* The enum value for this mnemonic. */
1560  tilepro_sn_mnemonic mnemonic;
1561
1562  /* How many operands are there? */
1563  unsigned char num_operands;
1564
1565  /* The description of the operands. Each of these is an
1566   * index into the tilepro_operands[] table. */
1567  unsigned char operands[TILEPRO_SN_MAX_OPERANDS];
1568
1569  /* A mask of which bits have predefined values.
1570   * This is useful for disassembly. */
1571  tilepro_sn_instruction_bits fixed_bit_mask;
1572
1573  /* For each bit set in fixed_bit_masks, what its value is. */
1574  tilepro_sn_instruction_bits fixed_bit_values;
1575};
1576
1577extern const struct tilepro_sn_opcode tilepro_sn_opcodes[];
1578
1579#endif /* !__KERNEL__ && !_LIBC */
1580
1581/* Used for non-textual disassembly into structs. */
1582struct tilepro_decoded_instruction
1583{
1584  const struct tilepro_opcode *opcode;
1585  const struct tilepro_operand *operands[TILEPRO_MAX_OPERANDS];
1586  int operand_values[TILEPRO_MAX_OPERANDS];
1587};
1588
1589
1590/* Disassemble a bundle into a struct for machine processing. */
1591extern int parse_insn_tilepro(tilepro_bundle_bits bits,
1592                              unsigned int pc,
1593                              struct tilepro_decoded_instruction
1594                              decoded[TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE]);
1595
1596
1597/* Given a set of bundle bits and a specific pipe, returns which
1598 * instruction the bundle contains in that pipe.
1599 */
1600extern const struct tilepro_opcode *
1601find_opcode(tilepro_bundle_bits bits, tilepro_pipeline pipe);
1602
1603
1604#if !defined(__KERNEL__) && !defined(_LIBC)
1605/* Canonical names of all the registers. */
1606/* ISSUE: This table lives in "tilepro-dis.c" */
1607extern const char * const tilepro_register_names[];
1608
1609/* Descriptor for a special-purpose register. */
1610struct tilepro_spr
1611{
1612  /* The number */
1613  int number;
1614
1615  /* The name */
1616  const char *name;
1617};
1618
1619/* List of all the SPRs; ordered by increasing number. */
1620extern const struct tilepro_spr tilepro_sprs[];
1621
1622/* Number of special-purpose registers. */
1623extern const int tilepro_num_sprs;
1624
1625extern const char *
1626get_tilepro_spr_name (int num);
1627#endif /* !__KERNEL__ && !_LIBC */
1628
1629/* Make a few "tile_" variables to simply common code between
1630   architectures.  */
1631
1632typedef tilepro_bundle_bits tile_bundle_bits;
1633#define TILE_BUNDLE_SIZE_IN_BYTES TILEPRO_BUNDLE_SIZE_IN_BYTES
1634#define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEPRO_BUNDLE_ALIGNMENT_IN_BYTES
1635#define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
1636  TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
1637
1638#endif /* opcode_tilepro_h */
Note: See TracBrowser for help on using the repository browser.