Subversion Repositories Kolibri OS

Rev

Rev 5191 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5191 serge 1
/* TILEPro opcode information.
2
 *
6324 serge 3
 *    Copyright (C) 2011-2015 Free Software Foundation, Inc.
5191 serge 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
 
24
typedef unsigned long long tilepro_bundle_bits;
25
 
26
 
27
enum
28
{
29
  TILEPRO_MAX_OPERANDS = 5 /* mm */
30
};
31
 
32
typedef 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
 
438
enum
439
{
440
  TILEPRO_SN_MAX_OPERANDS = 6 /* route */
441
};
442
 
443
typedef 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
 
470
extern const unsigned char tilepro_sn_route_encode[6 * 6 * 6];
471
extern const signed char tilepro_sn_route_decode[256][3];
472
extern const char tilepro_sn_direction_names[6][5];
473
extern const signed char tilepro_sn_dest_map[6][6];
474
#endif /* DISASM_ONLY */
475
 
476
 
477
static __inline unsigned int
478
get_BrOff_SN(tilepro_bundle_bits num)
479
{
480
  const unsigned int n = (unsigned int)num;
481
  return (((n >> 0)) & 0x3ff);
482
}
483
 
484
static __inline unsigned int
485
get_BrOff_X1(tilepro_bundle_bits n)
486
{
487
  return (((unsigned int)(n >> 43)) & 0x00007fff) |
488
         (((unsigned int)(n >> 20)) & 0x00018000);
489
}
490
 
491
static __inline unsigned int
492
get_BrType_X1(tilepro_bundle_bits n)
493
{
494
  return (((unsigned int)(n >> 31)) & 0xf);
495
}
496
 
497
static __inline unsigned int
498
get_Dest_Imm8_X1(tilepro_bundle_bits n)
499
{
500
  return (((unsigned int)(n >> 31)) & 0x0000003f) |
501
         (((unsigned int)(n >> 43)) & 0x000000c0);
502
}
503
 
504
static __inline unsigned int
505
get_Dest_SN(tilepro_bundle_bits num)
506
{
507
  const unsigned int n = (unsigned int)num;
508
  return (((n >> 2)) & 0x3);
509
}
510
 
511
static __inline unsigned int
512
get_Dest_X0(tilepro_bundle_bits num)
513
{
514
  const unsigned int n = (unsigned int)num;
515
  return (((n >> 0)) & 0x3f);
516
}
517
 
518
static __inline unsigned int
519
get_Dest_X1(tilepro_bundle_bits n)
520
{
521
  return (((unsigned int)(n >> 31)) & 0x3f);
522
}
523
 
524
static __inline unsigned int
525
get_Dest_Y0(tilepro_bundle_bits num)
526
{
527
  const unsigned int n = (unsigned int)num;
528
  return (((n >> 0)) & 0x3f);
529
}
530
 
531
static __inline unsigned int
532
get_Dest_Y1(tilepro_bundle_bits n)
533
{
534
  return (((unsigned int)(n >> 31)) & 0x3f);
535
}
536
 
537
static __inline unsigned int
538
get_Imm16_X0(tilepro_bundle_bits num)
539
{
540
  const unsigned int n = (unsigned int)num;
541
  return (((n >> 12)) & 0xffff);
542
}
543
 
544
static __inline unsigned int
545
get_Imm16_X1(tilepro_bundle_bits n)
546
{
547
  return (((unsigned int)(n >> 43)) & 0xffff);
548
}
549
 
550
static __inline unsigned int
551
get_Imm8_SN(tilepro_bundle_bits num)
552
{
553
  const unsigned int n = (unsigned int)num;
554
  return (((n >> 0)) & 0xff);
555
}
556
 
557
static __inline unsigned int
558
get_Imm8_X0(tilepro_bundle_bits num)
559
{
560
  const unsigned int n = (unsigned int)num;
561
  return (((n >> 12)) & 0xff);
562
}
563
 
564
static __inline unsigned int
565
get_Imm8_X1(tilepro_bundle_bits n)
566
{
567
  return (((unsigned int)(n >> 43)) & 0xff);
568
}
569
 
570
static __inline unsigned int
571
get_Imm8_Y0(tilepro_bundle_bits num)
572
{
573
  const unsigned int n = (unsigned int)num;
574
  return (((n >> 12)) & 0xff);
575
}
576
 
577
static __inline unsigned int
578
get_Imm8_Y1(tilepro_bundle_bits n)
579
{
580
  return (((unsigned int)(n >> 43)) & 0xff);
581
}
582
 
583
static __inline unsigned int
584
get_ImmOpcodeExtension_X0(tilepro_bundle_bits num)
585
{
586
  const unsigned int n = (unsigned int)num;
587
  return (((n >> 20)) & 0x7f);
588
}
589
 
590
static __inline unsigned int
591
get_ImmOpcodeExtension_X1(tilepro_bundle_bits n)
592
{
593
  return (((unsigned int)(n >> 51)) & 0x7f);
594
}
595
 
596
static __inline unsigned int
597
get_ImmRROpcodeExtension_SN(tilepro_bundle_bits num)
598
{
599
  const unsigned int n = (unsigned int)num;
600
  return (((n >> 8)) & 0x3);
601
}
602
 
603
static __inline unsigned int
604
get_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
 
613
static __inline unsigned int
614
get_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
 
623
static __inline unsigned int
624
get_MF_Imm15_X1(tilepro_bundle_bits n)
625
{
626
  return (((unsigned int)(n >> 37)) & 0x00003fff) |
627
         (((unsigned int)(n >> 44)) & 0x00004000);
628
}
629
 
630
static __inline unsigned int
631
get_MMEnd_X0(tilepro_bundle_bits num)
632
{
633
  const unsigned int n = (unsigned int)num;
634
  return (((n >> 18)) & 0x1f);
635
}
636
 
637
static __inline unsigned int
638
get_MMEnd_X1(tilepro_bundle_bits n)
639
{
640
  return (((unsigned int)(n >> 49)) & 0x1f);
641
}
642
 
643
static __inline unsigned int
644
get_MMStart_X0(tilepro_bundle_bits num)
645
{
646
  const unsigned int n = (unsigned int)num;
647
  return (((n >> 23)) & 0x1f);
648
}
649
 
650
static __inline unsigned int
651
get_MMStart_X1(tilepro_bundle_bits n)
652
{
653
  return (((unsigned int)(n >> 54)) & 0x1f);
654
}
655
 
656
static __inline unsigned int
657
get_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
 
664
static __inline unsigned int
665
get_Mode(tilepro_bundle_bits n)
666
{
667
  return (((unsigned int)(n >> 63)) & 0x1);
668
}
669
 
670
static __inline unsigned int
671
get_NoRegOpcodeExtension_SN(tilepro_bundle_bits num)
672
{
673
  const unsigned int n = (unsigned int)num;
674
  return (((n >> 0)) & 0xf);
675
}
676
 
677
static __inline unsigned int
678
get_Opcode_SN(tilepro_bundle_bits num)
679
{
680
  const unsigned int n = (unsigned int)num;
681
  return (((n >> 10)) & 0x3f);
682
}
683
 
684
static __inline unsigned int
685
get_Opcode_X0(tilepro_bundle_bits num)
686
{
687
  const unsigned int n = (unsigned int)num;
688
  return (((n >> 28)) & 0x7);
689
}
690
 
691
static __inline unsigned int
692
get_Opcode_X1(tilepro_bundle_bits n)
693
{
694
  return (((unsigned int)(n >> 59)) & 0xf);
695
}
696
 
697
static __inline unsigned int
698
get_Opcode_Y0(tilepro_bundle_bits num)
699
{
700
  const unsigned int n = (unsigned int)num;
701
  return (((n >> 27)) & 0xf);
702
}
703
 
704
static __inline unsigned int
705
get_Opcode_Y1(tilepro_bundle_bits n)
706
{
707
  return (((unsigned int)(n >> 59)) & 0xf);
708
}
709
 
710
static __inline unsigned int
711
get_Opcode_Y2(tilepro_bundle_bits n)
712
{
713
  return (((unsigned int)(n >> 56)) & 0x7);
714
}
715
 
716
static __inline unsigned int
717
get_RROpcodeExtension_SN(tilepro_bundle_bits num)
718
{
719
  const unsigned int n = (unsigned int)num;
720
  return (((n >> 4)) & 0xf);
721
}
722
 
723
static __inline unsigned int
724
get_RRROpcodeExtension_X0(tilepro_bundle_bits num)
725
{
726
  const unsigned int n = (unsigned int)num;
727
  return (((n >> 18)) & 0x1ff);
728
}
729
 
730
static __inline unsigned int
731
get_RRROpcodeExtension_X1(tilepro_bundle_bits n)
732
{
733
  return (((unsigned int)(n >> 49)) & 0x1ff);
734
}
735
 
736
static __inline unsigned int
737
get_RRROpcodeExtension_Y0(tilepro_bundle_bits num)
738
{
739
  const unsigned int n = (unsigned int)num;
740
  return (((n >> 18)) & 0x3);
741
}
742
 
743
static __inline unsigned int
744
get_RRROpcodeExtension_Y1(tilepro_bundle_bits n)
745
{
746
  return (((unsigned int)(n >> 49)) & 0x3);
747
}
748
 
749
static __inline unsigned int
750
get_RouteOpcodeExtension_SN(tilepro_bundle_bits num)
751
{
752
  const unsigned int n = (unsigned int)num;
753
  return (((n >> 0)) & 0x3ff);
754
}
755
 
756
static __inline unsigned int
757
get_S_X0(tilepro_bundle_bits num)
758
{
759
  const unsigned int n = (unsigned int)num;
760
  return (((n >> 27)) & 0x1);
761
}
762
 
763
static __inline unsigned int
764
get_S_X1(tilepro_bundle_bits n)
765
{
766
  return (((unsigned int)(n >> 58)) & 0x1);
767
}
768
 
769
static __inline unsigned int
770
get_ShAmt_X0(tilepro_bundle_bits num)
771
{
772
  const unsigned int n = (unsigned int)num;
773
  return (((n >> 12)) & 0x1f);
774
}
775
 
776
static __inline unsigned int
777
get_ShAmt_X1(tilepro_bundle_bits n)
778
{
779
  return (((unsigned int)(n >> 43)) & 0x1f);
780
}
781
 
782
static __inline unsigned int
783
get_ShAmt_Y0(tilepro_bundle_bits num)
784
{
785
  const unsigned int n = (unsigned int)num;
786
  return (((n >> 12)) & 0x1f);
787
}
788
 
789
static __inline unsigned int
790
get_ShAmt_Y1(tilepro_bundle_bits n)
791
{
792
  return (((unsigned int)(n >> 43)) & 0x1f);
793
}
794
 
795
static __inline unsigned int
796
get_SrcA_X0(tilepro_bundle_bits num)
797
{
798
  const unsigned int n = (unsigned int)num;
799
  return (((n >> 6)) & 0x3f);
800
}
801
 
802
static __inline unsigned int
803
get_SrcA_X1(tilepro_bundle_bits n)
804
{
805
  return (((unsigned int)(n >> 37)) & 0x3f);
806
}
807
 
808
static __inline unsigned int
809
get_SrcA_Y0(tilepro_bundle_bits num)
810
{
811
  const unsigned int n = (unsigned int)num;
812
  return (((n >> 6)) & 0x3f);
813
}
814
 
815
static __inline unsigned int
816
get_SrcA_Y1(tilepro_bundle_bits n)
817
{
818
  return (((unsigned int)(n >> 37)) & 0x3f);
819
}
820
 
821
static __inline unsigned int
822
get_SrcA_Y2(tilepro_bundle_bits n)
823
{
824
  return (((n >> 26)) & 0x00000001) |
825
         (((unsigned int)(n >> 50)) & 0x0000003e);
826
}
827
 
828
static __inline unsigned int
829
get_SrcBDest_Y2(tilepro_bundle_bits num)
830
{
831
  const unsigned int n = (unsigned int)num;
832
  return (((n >> 20)) & 0x3f);
833
}
834
 
835
static __inline unsigned int
836
get_SrcB_X0(tilepro_bundle_bits num)
837
{
838
  const unsigned int n = (unsigned int)num;
839
  return (((n >> 12)) & 0x3f);
840
}
841
 
842
static __inline unsigned int
843
get_SrcB_X1(tilepro_bundle_bits n)
844
{
845
  return (((unsigned int)(n >> 43)) & 0x3f);
846
}
847
 
848
static __inline unsigned int
849
get_SrcB_Y0(tilepro_bundle_bits num)
850
{
851
  const unsigned int n = (unsigned int)num;
852
  return (((n >> 12)) & 0x3f);
853
}
854
 
855
static __inline unsigned int
856
get_SrcB_Y1(tilepro_bundle_bits n)
857
{
858
  return (((unsigned int)(n >> 43)) & 0x3f);
859
}
860
 
861
static __inline unsigned int
862
get_Src_SN(tilepro_bundle_bits num)
863
{
864
  const unsigned int n = (unsigned int)num;
865
  return (((n >> 0)) & 0x3);
866
}
867
 
868
static __inline unsigned int
869
get_UnOpcodeExtension_X0(tilepro_bundle_bits num)
870
{
871
  const unsigned int n = (unsigned int)num;
872
  return (((n >> 12)) & 0x1f);
873
}
874
 
875
static __inline unsigned int
876
get_UnOpcodeExtension_X1(tilepro_bundle_bits n)
877
{
878
  return (((unsigned int)(n >> 43)) & 0x1f);
879
}
880
 
881
static __inline unsigned int
882
get_UnOpcodeExtension_Y0(tilepro_bundle_bits num)
883
{
884
  const unsigned int n = (unsigned int)num;
885
  return (((n >> 12)) & 0x1f);
886
}
887
 
888
static __inline unsigned int
889
get_UnOpcodeExtension_Y1(tilepro_bundle_bits n)
890
{
891
  return (((unsigned int)(n >> 43)) & 0x1f);
892
}
893
 
894
static __inline unsigned int
895
get_UnShOpcodeExtension_X0(tilepro_bundle_bits num)
896
{
897
  const unsigned int n = (unsigned int)num;
898
  return (((n >> 17)) & 0x3ff);
899
}
900
 
901
static __inline unsigned int
902
get_UnShOpcodeExtension_X1(tilepro_bundle_bits n)
903
{
904
  return (((unsigned int)(n >> 48)) & 0x3ff);
905
}
906
 
907
static __inline unsigned int
908
get_UnShOpcodeExtension_Y0(tilepro_bundle_bits num)
909
{
910
  const unsigned int n = (unsigned int)num;
911
  return (((n >> 17)) & 0x7);
912
}
913
 
914
static __inline unsigned int
915
get_UnShOpcodeExtension_Y1(tilepro_bundle_bits n)
916
{
917
  return (((unsigned int)(n >> 48)) & 0x7);
918
}
919
 
920
 
921
static __inline int
922
sign_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
 
930
static __inline tilepro_bundle_bits
931
create_BrOff_SN(int num)
932
{
933
  const unsigned int n = (unsigned int)num;
934
  return ((n & 0x3ff) << 0);
935
}
936
 
937
static __inline tilepro_bundle_bits
938
create_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
 
945
static __inline tilepro_bundle_bits
946
create_BrType_X1(int num)
947
{
948
  const unsigned int n = (unsigned int)num;
949
  return (((tilepro_bundle_bits)(n & 0xf)) << 31);
950
}
951
 
952
static __inline tilepro_bundle_bits
953
create_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
 
960
static __inline tilepro_bundle_bits
961
create_Dest_SN(int num)
962
{
963
  const unsigned int n = (unsigned int)num;
964
  return ((n & 0x3) << 2);
965
}
966
 
967
static __inline tilepro_bundle_bits
968
create_Dest_X0(int num)
969
{
970
  const unsigned int n = (unsigned int)num;
971
  return ((n & 0x3f) << 0);
972
}
973
 
974
static __inline tilepro_bundle_bits
975
create_Dest_X1(int num)
976
{
977
  const unsigned int n = (unsigned int)num;
978
  return (((tilepro_bundle_bits)(n & 0x3f)) << 31);
979
}
980
 
981
static __inline tilepro_bundle_bits
982
create_Dest_Y0(int num)
983
{
984
  const unsigned int n = (unsigned int)num;
985
  return ((n & 0x3f) << 0);
986
}
987
 
988
static __inline tilepro_bundle_bits
989
create_Dest_Y1(int num)
990
{
991
  const unsigned int n = (unsigned int)num;
992
  return (((tilepro_bundle_bits)(n & 0x3f)) << 31);
993
}
994
 
995
static __inline tilepro_bundle_bits
996
create_Imm16_X0(int num)
997
{
998
  const unsigned int n = (unsigned int)num;
999
  return ((n & 0xffff) << 12);
1000
}
1001
 
1002
static __inline tilepro_bundle_bits
1003
create_Imm16_X1(int num)
1004
{
1005
  const unsigned int n = (unsigned int)num;
1006
  return (((tilepro_bundle_bits)(n & 0xffff)) << 43);
1007
}
1008
 
1009
static __inline tilepro_bundle_bits
1010
create_Imm8_SN(int num)
1011
{
1012
  const unsigned int n = (unsigned int)num;
1013
  return ((n & 0xff) << 0);
1014
}
1015
 
1016
static __inline tilepro_bundle_bits
1017
create_Imm8_X0(int num)
1018
{
1019
  const unsigned int n = (unsigned int)num;
1020
  return ((n & 0xff) << 12);
1021
}
1022
 
1023
static __inline tilepro_bundle_bits
1024
create_Imm8_X1(int num)
1025
{
1026
  const unsigned int n = (unsigned int)num;
1027
  return (((tilepro_bundle_bits)(n & 0xff)) << 43);
1028
}
1029
 
1030
static __inline tilepro_bundle_bits
1031
create_Imm8_Y0(int num)
1032
{
1033
  const unsigned int n = (unsigned int)num;
1034
  return ((n & 0xff) << 12);
1035
}
1036
 
1037
static __inline tilepro_bundle_bits
1038
create_Imm8_Y1(int num)
1039
{
1040
  const unsigned int n = (unsigned int)num;
1041
  return (((tilepro_bundle_bits)(n & 0xff)) << 43);
1042
}
1043
 
1044
static __inline tilepro_bundle_bits
1045
create_ImmOpcodeExtension_X0(int num)
1046
{
1047
  const unsigned int n = (unsigned int)num;
1048
  return ((n & 0x7f) << 20);
1049
}
1050
 
1051
static __inline tilepro_bundle_bits
1052
create_ImmOpcodeExtension_X1(int num)
1053
{
1054
  const unsigned int n = (unsigned int)num;
1055
  return (((tilepro_bundle_bits)(n & 0x7f)) << 51);
1056
}
1057
 
1058
static __inline tilepro_bundle_bits
1059
create_ImmRROpcodeExtension_SN(int num)
1060
{
1061
  const unsigned int n = (unsigned int)num;
1062
  return ((n & 0x3) << 8);
1063
}
1064
 
1065
static __inline tilepro_bundle_bits
1066
create_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
 
1076
static __inline tilepro_bundle_bits
1077
create_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
 
1087
static __inline tilepro_bundle_bits
1088
create_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
 
1095
static __inline tilepro_bundle_bits
1096
create_MMEnd_X0(int num)
1097
{
1098
  const unsigned int n = (unsigned int)num;
1099
  return ((n & 0x1f) << 18);
1100
}
1101
 
1102
static __inline tilepro_bundle_bits
1103
create_MMEnd_X1(int num)
1104
{
1105
  const unsigned int n = (unsigned int)num;
1106
  return (((tilepro_bundle_bits)(n & 0x1f)) << 49);
1107
}
1108
 
1109
static __inline tilepro_bundle_bits
1110
create_MMStart_X0(int num)
1111
{
1112
  const unsigned int n = (unsigned int)num;
1113
  return ((n & 0x1f) << 23);
1114
}
1115
 
1116
static __inline tilepro_bundle_bits
1117
create_MMStart_X1(int num)
1118
{
1119
  const unsigned int n = (unsigned int)num;
1120
  return (((tilepro_bundle_bits)(n & 0x1f)) << 54);
1121
}
1122
 
1123
static __inline tilepro_bundle_bits
1124
create_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
 
1132
static __inline tilepro_bundle_bits
1133
create_Mode(int num)
1134
{
1135
  const unsigned int n = (unsigned int)num;
1136
  return (((tilepro_bundle_bits)(n & 0x1)) << 63);
1137
}
1138
 
1139
static __inline tilepro_bundle_bits
1140
create_NoRegOpcodeExtension_SN(int num)
1141
{
1142
  const unsigned int n = (unsigned int)num;
1143
  return ((n & 0xf) << 0);
1144
}
1145
 
1146
static __inline tilepro_bundle_bits
1147
create_Opcode_SN(int num)
1148
{
1149
  const unsigned int n = (unsigned int)num;
1150
  return ((n & 0x3f) << 10);
1151
}
1152
 
1153
static __inline tilepro_bundle_bits
1154
create_Opcode_X0(int num)
1155
{
1156
  const unsigned int n = (unsigned int)num;
1157
  return ((n & 0x7) << 28);
1158
}
1159
 
1160
static __inline tilepro_bundle_bits
1161
create_Opcode_X1(int num)
1162
{
1163
  const unsigned int n = (unsigned int)num;
1164
  return (((tilepro_bundle_bits)(n & 0xf)) << 59);
1165
}
1166
 
1167
static __inline tilepro_bundle_bits
1168
create_Opcode_Y0(int num)
1169
{
1170
  const unsigned int n = (unsigned int)num;
1171
  return ((n & 0xf) << 27);
1172
}
1173
 
1174
static __inline tilepro_bundle_bits
1175
create_Opcode_Y1(int num)
1176
{
1177
  const unsigned int n = (unsigned int)num;
1178
  return (((tilepro_bundle_bits)(n & 0xf)) << 59);
1179
}
1180
 
1181
static __inline tilepro_bundle_bits
1182
create_Opcode_Y2(int num)
1183
{
1184
  const unsigned int n = (unsigned int)num;
1185
  return (((tilepro_bundle_bits)(n & 0x7)) << 56);
1186
}
1187
 
1188
static __inline tilepro_bundle_bits
1189
create_RROpcodeExtension_SN(int num)
1190
{
1191
  const unsigned int n = (unsigned int)num;
1192
  return ((n & 0xf) << 4);
1193
}
1194
 
1195
static __inline tilepro_bundle_bits
1196
create_RRROpcodeExtension_X0(int num)
1197
{
1198
  const unsigned int n = (unsigned int)num;
1199
  return ((n & 0x1ff) << 18);
1200
}
1201
 
1202
static __inline tilepro_bundle_bits
1203
create_RRROpcodeExtension_X1(int num)
1204
{
1205
  const unsigned int n = (unsigned int)num;
1206
  return (((tilepro_bundle_bits)(n & 0x1ff)) << 49);
1207
}
1208
 
1209
static __inline tilepro_bundle_bits
1210
create_RRROpcodeExtension_Y0(int num)
1211
{
1212
  const unsigned int n = (unsigned int)num;
1213
  return ((n & 0x3) << 18);
1214
}
1215
 
1216
static __inline tilepro_bundle_bits
1217
create_RRROpcodeExtension_Y1(int num)
1218
{
1219
  const unsigned int n = (unsigned int)num;
1220
  return (((tilepro_bundle_bits)(n & 0x3)) << 49);
1221
}
1222
 
1223
static __inline tilepro_bundle_bits
1224
create_RouteOpcodeExtension_SN(int num)
1225
{
1226
  const unsigned int n = (unsigned int)num;
1227
  return ((n & 0x3ff) << 0);
1228
}
1229
 
1230
static __inline tilepro_bundle_bits
1231
create_S_X0(int num)
1232
{
1233
  const unsigned int n = (unsigned int)num;
1234
  return ((n & 0x1) << 27);
1235
}
1236
 
1237
static __inline tilepro_bundle_bits
1238
create_S_X1(int num)
1239
{
1240
  const unsigned int n = (unsigned int)num;
1241
  return (((tilepro_bundle_bits)(n & 0x1)) << 58);
1242
}
1243
 
1244
static __inline tilepro_bundle_bits
1245
create_ShAmt_X0(int num)
1246
{
1247
  const unsigned int n = (unsigned int)num;
1248
  return ((n & 0x1f) << 12);
1249
}
1250
 
1251
static __inline tilepro_bundle_bits
1252
create_ShAmt_X1(int num)
1253
{
1254
  const unsigned int n = (unsigned int)num;
1255
  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1256
}
1257
 
1258
static __inline tilepro_bundle_bits
1259
create_ShAmt_Y0(int num)
1260
{
1261
  const unsigned int n = (unsigned int)num;
1262
  return ((n & 0x1f) << 12);
1263
}
1264
 
1265
static __inline tilepro_bundle_bits
1266
create_ShAmt_Y1(int num)
1267
{
1268
  const unsigned int n = (unsigned int)num;
1269
  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1270
}
1271
 
1272
static __inline tilepro_bundle_bits
1273
create_SrcA_X0(int num)
1274
{
1275
  const unsigned int n = (unsigned int)num;
1276
  return ((n & 0x3f) << 6);
1277
}
1278
 
1279
static __inline tilepro_bundle_bits
1280
create_SrcA_X1(int num)
1281
{
1282
  const unsigned int n = (unsigned int)num;
1283
  return (((tilepro_bundle_bits)(n & 0x3f)) << 37);
1284
}
1285
 
1286
static __inline tilepro_bundle_bits
1287
create_SrcA_Y0(int num)
1288
{
1289
  const unsigned int n = (unsigned int)num;
1290
  return ((n & 0x3f) << 6);
1291
}
1292
 
1293
static __inline tilepro_bundle_bits
1294
create_SrcA_Y1(int num)
1295
{
1296
  const unsigned int n = (unsigned int)num;
1297
  return (((tilepro_bundle_bits)(n & 0x3f)) << 37);
1298
}
1299
 
1300
static __inline tilepro_bundle_bits
1301
create_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
 
1308
static __inline tilepro_bundle_bits
1309
create_SrcBDest_Y2(int num)
1310
{
1311
  const unsigned int n = (unsigned int)num;
1312
  return ((n & 0x3f) << 20);
1313
}
1314
 
1315
static __inline tilepro_bundle_bits
1316
create_SrcB_X0(int num)
1317
{
1318
  const unsigned int n = (unsigned int)num;
1319
  return ((n & 0x3f) << 12);
1320
}
1321
 
1322
static __inline tilepro_bundle_bits
1323
create_SrcB_X1(int num)
1324
{
1325
  const unsigned int n = (unsigned int)num;
1326
  return (((tilepro_bundle_bits)(n & 0x3f)) << 43);
1327
}
1328
 
1329
static __inline tilepro_bundle_bits
1330
create_SrcB_Y0(int num)
1331
{
1332
  const unsigned int n = (unsigned int)num;
1333
  return ((n & 0x3f) << 12);
1334
}
1335
 
1336
static __inline tilepro_bundle_bits
1337
create_SrcB_Y1(int num)
1338
{
1339
  const unsigned int n = (unsigned int)num;
1340
  return (((tilepro_bundle_bits)(n & 0x3f)) << 43);
1341
}
1342
 
1343
static __inline tilepro_bundle_bits
1344
create_Src_SN(int num)
1345
{
1346
  const unsigned int n = (unsigned int)num;
1347
  return ((n & 0x3) << 0);
1348
}
1349
 
1350
static __inline tilepro_bundle_bits
1351
create_UnOpcodeExtension_X0(int num)
1352
{
1353
  const unsigned int n = (unsigned int)num;
1354
  return ((n & 0x1f) << 12);
1355
}
1356
 
1357
static __inline tilepro_bundle_bits
1358
create_UnOpcodeExtension_X1(int num)
1359
{
1360
  const unsigned int n = (unsigned int)num;
1361
  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1362
}
1363
 
1364
static __inline tilepro_bundle_bits
1365
create_UnOpcodeExtension_Y0(int num)
1366
{
1367
  const unsigned int n = (unsigned int)num;
1368
  return ((n & 0x1f) << 12);
1369
}
1370
 
1371
static __inline tilepro_bundle_bits
1372
create_UnOpcodeExtension_Y1(int num)
1373
{
1374
  const unsigned int n = (unsigned int)num;
1375
  return (((tilepro_bundle_bits)(n & 0x1f)) << 43);
1376
}
1377
 
1378
static __inline tilepro_bundle_bits
1379
create_UnShOpcodeExtension_X0(int num)
1380
{
1381
  const unsigned int n = (unsigned int)num;
1382
  return ((n & 0x3ff) << 17);
1383
}
1384
 
1385
static __inline tilepro_bundle_bits
1386
create_UnShOpcodeExtension_X1(int num)
1387
{
1388
  const unsigned int n = (unsigned int)num;
1389
  return (((tilepro_bundle_bits)(n & 0x3ff)) << 48);
1390
}
1391
 
1392
static __inline tilepro_bundle_bits
1393
create_UnShOpcodeExtension_Y0(int num)
1394
{
1395
  const unsigned int n = (unsigned int)num;
1396
  return ((n & 0x7) << 17);
1397
}
1398
 
1399
static __inline tilepro_bundle_bits
1400
create_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
 
1408
typedef 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
 
1419
typedef 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
 
1430
enum
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
 
1466
struct 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
 
1500
extern const struct tilepro_operand tilepro_operands[];
1501
 
1502
/* One finite-state machine per pipe for rapid instruction decoding. */
1503
extern const unsigned short * const
1504
tilepro_bundle_decoder_fsms[TILEPRO_NUM_PIPELINE_ENCODINGS];
1505
 
1506
 
1507
struct 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
 
1548
extern const struct tilepro_opcode tilepro_opcodes[];
1549
 
1550
#if !defined(__KERNEL__) && !defined(_LIBC)
1551
 
1552
typedef unsigned short tilepro_sn_instruction_bits;
1553
 
1554
struct 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
 
1577
extern const struct tilepro_sn_opcode tilepro_sn_opcodes[];
1578
 
1579
#endif /* !__KERNEL__ && !_LIBC */
1580
 
1581
/* Used for non-textual disassembly into structs. */
1582
struct 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. */
1591
extern 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
 */
1600
extern const struct tilepro_opcode *
1601
find_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" */
1607
extern const char * const tilepro_register_names[];
1608
 
1609
/* Descriptor for a special-purpose register. */
1610
struct 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. */
1620
extern const struct tilepro_spr tilepro_sprs[];
1621
 
1622
/* Number of special-purpose registers. */
1623
extern const int tilepro_num_sprs;
1624
 
1625
extern const char *
1626
get_tilepro_spr_name (int num);
1627
#endif /* !__KERNEL__ && !_LIBC */
1628
 
1629
/* Make a few "tile_" variables to simply common code between
1630
   architectures.  */
1631
 
1632
typedef 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 */