Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
opcode_tilegx.h
Go to the documentation of this file.
1 /* TILE-Gx opcode information.
2  *
3  * Copyright 2011 Tilera Corporation. All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation, version 2.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12  * NON INFRINGEMENT. See the GNU General Public License for
13  * more details.
14  *
15  *
16  *
17  *
18  *
19  */
20 
21 #ifndef __ARCH_OPCODE_H__
22 #define __ARCH_OPCODE_H__
23 
24 #ifndef __ASSEMBLER__
25 
26 typedef unsigned long long tilegx_bundle_bits;
27 
28 /* These are the bits that determine if a bundle is in the X encoding. */
29 #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
30 
31 enum
32 {
33  /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
35 
36  /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
38 
39  /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
41 
42  /* Instructions take this many bytes. */
44 
45  /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
47 
48  /* Bundles should be aligned modulo this number of bytes. */
51 
52  /* Number of registers (some are magic, such as network I/O). */
54 };
55 
56 /* Make a few "tile_" variables to simplify common code between
57  architectures. */
58 
60 #define TILE_BUNDLE_SIZE_IN_BYTES TILEGX_BUNDLE_SIZE_IN_BYTES
61 #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
62 #define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
63  TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
64 
65 /* 64-bit pattern for a { bpt ; nop } bundle. */
66 #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
67 
68 static __inline unsigned int
69 get_BFEnd_X0(tilegx_bundle_bits num)
70 {
71  const unsigned int n = (unsigned int)num;
72  return (((n >> 12)) & 0x3f);
73 }
74 
75 static __inline unsigned int
76 get_BFOpcodeExtension_X0(tilegx_bundle_bits num)
77 {
78  const unsigned int n = (unsigned int)num;
79  return (((n >> 24)) & 0xf);
80 }
81 
82 static __inline unsigned int
83 get_BFStart_X0(tilegx_bundle_bits num)
84 {
85  const unsigned int n = (unsigned int)num;
86  return (((n >> 18)) & 0x3f);
87 }
88 
89 static __inline unsigned int
90 get_BrOff_X1(tilegx_bundle_bits n)
91 {
92  return (((unsigned int)(n >> 31)) & 0x0000003f) |
93  (((unsigned int)(n >> 37)) & 0x0001ffc0);
94 }
95 
96 static __inline unsigned int
97 get_BrType_X1(tilegx_bundle_bits n)
98 {
99  return (((unsigned int)(n >> 54)) & 0x1f);
100 }
101 
102 static __inline unsigned int
103 get_Dest_Imm8_X1(tilegx_bundle_bits n)
104 {
105  return (((unsigned int)(n >> 31)) & 0x0000003f) |
106  (((unsigned int)(n >> 43)) & 0x000000c0);
107 }
108 
109 static __inline unsigned int
110 get_Dest_X0(tilegx_bundle_bits num)
111 {
112  const unsigned int n = (unsigned int)num;
113  return (((n >> 0)) & 0x3f);
114 }
115 
116 static __inline unsigned int
117 get_Dest_X1(tilegx_bundle_bits n)
118 {
119  return (((unsigned int)(n >> 31)) & 0x3f);
120 }
121 
122 static __inline unsigned int
123 get_Dest_Y0(tilegx_bundle_bits num)
124 {
125  const unsigned int n = (unsigned int)num;
126  return (((n >> 0)) & 0x3f);
127 }
128 
129 static __inline unsigned int
130 get_Dest_Y1(tilegx_bundle_bits n)
131 {
132  return (((unsigned int)(n >> 31)) & 0x3f);
133 }
134 
135 static __inline unsigned int
136 get_Imm16_X0(tilegx_bundle_bits num)
137 {
138  const unsigned int n = (unsigned int)num;
139  return (((n >> 12)) & 0xffff);
140 }
141 
142 static __inline unsigned int
143 get_Imm16_X1(tilegx_bundle_bits n)
144 {
145  return (((unsigned int)(n >> 43)) & 0xffff);
146 }
147 
148 static __inline unsigned int
149 get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num)
150 {
151  const unsigned int n = (unsigned int)num;
152  return (((n >> 20)) & 0xff);
153 }
154 
155 static __inline unsigned int
156 get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n)
157 {
158  return (((unsigned int)(n >> 51)) & 0xff);
159 }
160 
161 static __inline unsigned int
162 get_Imm8_X0(tilegx_bundle_bits num)
163 {
164  const unsigned int n = (unsigned int)num;
165  return (((n >> 12)) & 0xff);
166 }
167 
168 static __inline unsigned int
169 get_Imm8_X1(tilegx_bundle_bits n)
170 {
171  return (((unsigned int)(n >> 43)) & 0xff);
172 }
173 
174 static __inline unsigned int
175 get_Imm8_Y0(tilegx_bundle_bits num)
176 {
177  const unsigned int n = (unsigned int)num;
178  return (((n >> 12)) & 0xff);
179 }
180 
181 static __inline unsigned int
182 get_Imm8_Y1(tilegx_bundle_bits n)
183 {
184  return (((unsigned int)(n >> 43)) & 0xff);
185 }
186 
187 static __inline unsigned int
188 get_JumpOff_X1(tilegx_bundle_bits n)
189 {
190  return (((unsigned int)(n >> 31)) & 0x7ffffff);
191 }
192 
193 static __inline unsigned int
194 get_JumpOpcodeExtension_X1(tilegx_bundle_bits n)
195 {
196  return (((unsigned int)(n >> 58)) & 0x1);
197 }
198 
199 static __inline unsigned int
200 get_MF_Imm14_X1(tilegx_bundle_bits n)
201 {
202  return (((unsigned int)(n >> 37)) & 0x3fff);
203 }
204 
205 static __inline unsigned int
206 get_MT_Imm14_X1(tilegx_bundle_bits n)
207 {
208  return (((unsigned int)(n >> 31)) & 0x0000003f) |
209  (((unsigned int)(n >> 37)) & 0x00003fc0);
210 }
211 
212 static __inline unsigned int
213 get_Mode(tilegx_bundle_bits n)
214 {
215  return (((unsigned int)(n >> 62)) & 0x3);
216 }
217 
218 static __inline unsigned int
219 get_Opcode_X0(tilegx_bundle_bits num)
220 {
221  const unsigned int n = (unsigned int)num;
222  return (((n >> 28)) & 0x7);
223 }
224 
225 static __inline unsigned int
226 get_Opcode_X1(tilegx_bundle_bits n)
227 {
228  return (((unsigned int)(n >> 59)) & 0x7);
229 }
230 
231 static __inline unsigned int
232 get_Opcode_Y0(tilegx_bundle_bits num)
233 {
234  const unsigned int n = (unsigned int)num;
235  return (((n >> 27)) & 0xf);
236 }
237 
238 static __inline unsigned int
239 get_Opcode_Y1(tilegx_bundle_bits n)
240 {
241  return (((unsigned int)(n >> 58)) & 0xf);
242 }
243 
244 static __inline unsigned int
245 get_Opcode_Y2(tilegx_bundle_bits n)
246 {
247  return (((n >> 26)) & 0x00000001) |
248  (((unsigned int)(n >> 56)) & 0x00000002);
249 }
250 
251 static __inline unsigned int
252 get_RRROpcodeExtension_X0(tilegx_bundle_bits num)
253 {
254  const unsigned int n = (unsigned int)num;
255  return (((n >> 18)) & 0x3ff);
256 }
257 
258 static __inline unsigned int
259 get_RRROpcodeExtension_X1(tilegx_bundle_bits n)
260 {
261  return (((unsigned int)(n >> 49)) & 0x3ff);
262 }
263 
264 static __inline unsigned int
265 get_RRROpcodeExtension_Y0(tilegx_bundle_bits num)
266 {
267  const unsigned int n = (unsigned int)num;
268  return (((n >> 18)) & 0x3);
269 }
270 
271 static __inline unsigned int
272 get_RRROpcodeExtension_Y1(tilegx_bundle_bits n)
273 {
274  return (((unsigned int)(n >> 49)) & 0x3);
275 }
276 
277 static __inline unsigned int
278 get_ShAmt_X0(tilegx_bundle_bits num)
279 {
280  const unsigned int n = (unsigned int)num;
281  return (((n >> 12)) & 0x3f);
282 }
283 
284 static __inline unsigned int
285 get_ShAmt_X1(tilegx_bundle_bits n)
286 {
287  return (((unsigned int)(n >> 43)) & 0x3f);
288 }
289 
290 static __inline unsigned int
291 get_ShAmt_Y0(tilegx_bundle_bits num)
292 {
293  const unsigned int n = (unsigned int)num;
294  return (((n >> 12)) & 0x3f);
295 }
296 
297 static __inline unsigned int
298 get_ShAmt_Y1(tilegx_bundle_bits n)
299 {
300  return (((unsigned int)(n >> 43)) & 0x3f);
301 }
302 
303 static __inline unsigned int
304 get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num)
305 {
306  const unsigned int n = (unsigned int)num;
307  return (((n >> 18)) & 0x3ff);
308 }
309 
310 static __inline unsigned int
311 get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n)
312 {
313  return (((unsigned int)(n >> 49)) & 0x3ff);
314 }
315 
316 static __inline unsigned int
317 get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num)
318 {
319  const unsigned int n = (unsigned int)num;
320  return (((n >> 18)) & 0x3);
321 }
322 
323 static __inline unsigned int
324 get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n)
325 {
326  return (((unsigned int)(n >> 49)) & 0x3);
327 }
328 
329 static __inline unsigned int
330 get_SrcA_X0(tilegx_bundle_bits num)
331 {
332  const unsigned int n = (unsigned int)num;
333  return (((n >> 6)) & 0x3f);
334 }
335 
336 static __inline unsigned int
337 get_SrcA_X1(tilegx_bundle_bits n)
338 {
339  return (((unsigned int)(n >> 37)) & 0x3f);
340 }
341 
342 static __inline unsigned int
343 get_SrcA_Y0(tilegx_bundle_bits num)
344 {
345  const unsigned int n = (unsigned int)num;
346  return (((n >> 6)) & 0x3f);
347 }
348 
349 static __inline unsigned int
350 get_SrcA_Y1(tilegx_bundle_bits n)
351 {
352  return (((unsigned int)(n >> 37)) & 0x3f);
353 }
354 
355 static __inline unsigned int
356 get_SrcA_Y2(tilegx_bundle_bits num)
357 {
358  const unsigned int n = (unsigned int)num;
359  return (((n >> 20)) & 0x3f);
360 }
361 
362 static __inline unsigned int
363 get_SrcBDest_Y2(tilegx_bundle_bits n)
364 {
365  return (((unsigned int)(n >> 51)) & 0x3f);
366 }
367 
368 static __inline unsigned int
369 get_SrcB_X0(tilegx_bundle_bits num)
370 {
371  const unsigned int n = (unsigned int)num;
372  return (((n >> 12)) & 0x3f);
373 }
374 
375 static __inline unsigned int
376 get_SrcB_X1(tilegx_bundle_bits n)
377 {
378  return (((unsigned int)(n >> 43)) & 0x3f);
379 }
380 
381 static __inline unsigned int
382 get_SrcB_Y0(tilegx_bundle_bits num)
383 {
384  const unsigned int n = (unsigned int)num;
385  return (((n >> 12)) & 0x3f);
386 }
387 
388 static __inline unsigned int
389 get_SrcB_Y1(tilegx_bundle_bits n)
390 {
391  return (((unsigned int)(n >> 43)) & 0x3f);
392 }
393 
394 static __inline unsigned int
395 get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num)
396 {
397  const unsigned int n = (unsigned int)num;
398  return (((n >> 12)) & 0x3f);
399 }
400 
401 static __inline unsigned int
402 get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n)
403 {
404  return (((unsigned int)(n >> 43)) & 0x3f);
405 }
406 
407 static __inline unsigned int
408 get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num)
409 {
410  const unsigned int n = (unsigned int)num;
411  return (((n >> 12)) & 0x3f);
412 }
413 
414 static __inline unsigned int
415 get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n)
416 {
417  return (((unsigned int)(n >> 43)) & 0x3f);
418 }
419 
420 
421 static __inline int
422 sign_extend(int n, int num_bits)
423 {
424  int shift = (int)(sizeof(int) * 8 - num_bits);
425  return (n << shift) >> shift;
426 }
427 
428 
429 
431 create_BFEnd_X0(int num)
432 {
433  const unsigned int n = (unsigned int)num;
434  return ((n & 0x3f) << 12);
435 }
436 
438 create_BFOpcodeExtension_X0(int num)
439 {
440  const unsigned int n = (unsigned int)num;
441  return ((n & 0xf) << 24);
442 }
443 
445 create_BFStart_X0(int num)
446 {
447  const unsigned int n = (unsigned int)num;
448  return ((n & 0x3f) << 18);
449 }
450 
452 create_BrOff_X1(int num)
453 {
454  const unsigned int n = (unsigned int)num;
455  return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
456  (((tilegx_bundle_bits)(n & 0x0001ffc0)) << 37);
457 }
458 
460 create_BrType_X1(int num)
461 {
462  const unsigned int n = (unsigned int)num;
463  return (((tilegx_bundle_bits)(n & 0x1f)) << 54);
464 }
465 
467 create_Dest_Imm8_X1(int num)
468 {
469  const unsigned int n = (unsigned int)num;
470  return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
471  (((tilegx_bundle_bits)(n & 0x000000c0)) << 43);
472 }
473 
475 create_Dest_X0(int num)
476 {
477  const unsigned int n = (unsigned int)num;
478  return ((n & 0x3f) << 0);
479 }
480 
482 create_Dest_X1(int num)
483 {
484  const unsigned int n = (unsigned int)num;
485  return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
486 }
487 
489 create_Dest_Y0(int num)
490 {
491  const unsigned int n = (unsigned int)num;
492  return ((n & 0x3f) << 0);
493 }
494 
496 create_Dest_Y1(int num)
497 {
498  const unsigned int n = (unsigned int)num;
499  return (((tilegx_bundle_bits)(n & 0x3f)) << 31);
500 }
501 
503 create_Imm16_X0(int num)
504 {
505  const unsigned int n = (unsigned int)num;
506  return ((n & 0xffff) << 12);
507 }
508 
510 create_Imm16_X1(int num)
511 {
512  const unsigned int n = (unsigned int)num;
513  return (((tilegx_bundle_bits)(n & 0xffff)) << 43);
514 }
515 
517 create_Imm8OpcodeExtension_X0(int num)
518 {
519  const unsigned int n = (unsigned int)num;
520  return ((n & 0xff) << 20);
521 }
522 
524 create_Imm8OpcodeExtension_X1(int num)
525 {
526  const unsigned int n = (unsigned int)num;
527  return (((tilegx_bundle_bits)(n & 0xff)) << 51);
528 }
529 
531 create_Imm8_X0(int num)
532 {
533  const unsigned int n = (unsigned int)num;
534  return ((n & 0xff) << 12);
535 }
536 
538 create_Imm8_X1(int num)
539 {
540  const unsigned int n = (unsigned int)num;
541  return (((tilegx_bundle_bits)(n & 0xff)) << 43);
542 }
543 
545 create_Imm8_Y0(int num)
546 {
547  const unsigned int n = (unsigned int)num;
548  return ((n & 0xff) << 12);
549 }
550 
552 create_Imm8_Y1(int num)
553 {
554  const unsigned int n = (unsigned int)num;
555  return (((tilegx_bundle_bits)(n & 0xff)) << 43);
556 }
557 
559 create_JumpOff_X1(int num)
560 {
561  const unsigned int n = (unsigned int)num;
562  return (((tilegx_bundle_bits)(n & 0x7ffffff)) << 31);
563 }
564 
566 create_JumpOpcodeExtension_X1(int num)
567 {
568  const unsigned int n = (unsigned int)num;
569  return (((tilegx_bundle_bits)(n & 0x1)) << 58);
570 }
571 
573 create_MF_Imm14_X1(int num)
574 {
575  const unsigned int n = (unsigned int)num;
576  return (((tilegx_bundle_bits)(n & 0x3fff)) << 37);
577 }
578 
580 create_MT_Imm14_X1(int num)
581 {
582  const unsigned int n = (unsigned int)num;
583  return (((tilegx_bundle_bits)(n & 0x0000003f)) << 31) |
584  (((tilegx_bundle_bits)(n & 0x00003fc0)) << 37);
585 }
586 
588 create_Mode(int num)
589 {
590  const unsigned int n = (unsigned int)num;
591  return (((tilegx_bundle_bits)(n & 0x3)) << 62);
592 }
593 
595 create_Opcode_X0(int num)
596 {
597  const unsigned int n = (unsigned int)num;
598  return ((n & 0x7) << 28);
599 }
600 
602 create_Opcode_X1(int num)
603 {
604  const unsigned int n = (unsigned int)num;
605  return (((tilegx_bundle_bits)(n & 0x7)) << 59);
606 }
607 
609 create_Opcode_Y0(int num)
610 {
611  const unsigned int n = (unsigned int)num;
612  return ((n & 0xf) << 27);
613 }
614 
616 create_Opcode_Y1(int num)
617 {
618  const unsigned int n = (unsigned int)num;
619  return (((tilegx_bundle_bits)(n & 0xf)) << 58);
620 }
621 
623 create_Opcode_Y2(int num)
624 {
625  const unsigned int n = (unsigned int)num;
626  return ((n & 0x00000001) << 26) |
627  (((tilegx_bundle_bits)(n & 0x00000002)) << 56);
628 }
629 
631 create_RRROpcodeExtension_X0(int num)
632 {
633  const unsigned int n = (unsigned int)num;
634  return ((n & 0x3ff) << 18);
635 }
636 
638 create_RRROpcodeExtension_X1(int num)
639 {
640  const unsigned int n = (unsigned int)num;
641  return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
642 }
643 
645 create_RRROpcodeExtension_Y0(int num)
646 {
647  const unsigned int n = (unsigned int)num;
648  return ((n & 0x3) << 18);
649 }
650 
652 create_RRROpcodeExtension_Y1(int num)
653 {
654  const unsigned int n = (unsigned int)num;
655  return (((tilegx_bundle_bits)(n & 0x3)) << 49);
656 }
657 
659 create_ShAmt_X0(int num)
660 {
661  const unsigned int n = (unsigned int)num;
662  return ((n & 0x3f) << 12);
663 }
664 
666 create_ShAmt_X1(int num)
667 {
668  const unsigned int n = (unsigned int)num;
669  return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
670 }
671 
673 create_ShAmt_Y0(int num)
674 {
675  const unsigned int n = (unsigned int)num;
676  return ((n & 0x3f) << 12);
677 }
678 
680 create_ShAmt_Y1(int num)
681 {
682  const unsigned int n = (unsigned int)num;
683  return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
684 }
685 
687 create_ShiftOpcodeExtension_X0(int num)
688 {
689  const unsigned int n = (unsigned int)num;
690  return ((n & 0x3ff) << 18);
691 }
692 
694 create_ShiftOpcodeExtension_X1(int num)
695 {
696  const unsigned int n = (unsigned int)num;
697  return (((tilegx_bundle_bits)(n & 0x3ff)) << 49);
698 }
699 
701 create_ShiftOpcodeExtension_Y0(int num)
702 {
703  const unsigned int n = (unsigned int)num;
704  return ((n & 0x3) << 18);
705 }
706 
708 create_ShiftOpcodeExtension_Y1(int num)
709 {
710  const unsigned int n = (unsigned int)num;
711  return (((tilegx_bundle_bits)(n & 0x3)) << 49);
712 }
713 
715 create_SrcA_X0(int num)
716 {
717  const unsigned int n = (unsigned int)num;
718  return ((n & 0x3f) << 6);
719 }
720 
722 create_SrcA_X1(int num)
723 {
724  const unsigned int n = (unsigned int)num;
725  return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
726 }
727 
729 create_SrcA_Y0(int num)
730 {
731  const unsigned int n = (unsigned int)num;
732  return ((n & 0x3f) << 6);
733 }
734 
736 create_SrcA_Y1(int num)
737 {
738  const unsigned int n = (unsigned int)num;
739  return (((tilegx_bundle_bits)(n & 0x3f)) << 37);
740 }
741 
743 create_SrcA_Y2(int num)
744 {
745  const unsigned int n = (unsigned int)num;
746  return ((n & 0x3f) << 20);
747 }
748 
750 create_SrcBDest_Y2(int num)
751 {
752  const unsigned int n = (unsigned int)num;
753  return (((tilegx_bundle_bits)(n & 0x3f)) << 51);
754 }
755 
757 create_SrcB_X0(int num)
758 {
759  const unsigned int n = (unsigned int)num;
760  return ((n & 0x3f) << 12);
761 }
762 
764 create_SrcB_X1(int num)
765 {
766  const unsigned int n = (unsigned int)num;
767  return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
768 }
769 
771 create_SrcB_Y0(int num)
772 {
773  const unsigned int n = (unsigned int)num;
774  return ((n & 0x3f) << 12);
775 }
776 
778 create_SrcB_Y1(int num)
779 {
780  const unsigned int n = (unsigned int)num;
781  return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
782 }
783 
785 create_UnaryOpcodeExtension_X0(int num)
786 {
787  const unsigned int n = (unsigned int)num;
788  return ((n & 0x3f) << 12);
789 }
790 
792 create_UnaryOpcodeExtension_X1(int num)
793 {
794  const unsigned int n = (unsigned int)num;
795  return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
796 }
797 
799 create_UnaryOpcodeExtension_Y0(int num)
800 {
801  const unsigned int n = (unsigned int)num;
802  return ((n & 0x3f) << 12);
803 }
804 
806 create_UnaryOpcodeExtension_Y1(int num)
807 {
808  const unsigned int n = (unsigned int)num;
809  return (((tilegx_bundle_bits)(n & 0x3f)) << 43);
810 }
811 
812 
813 enum
814 {
1400 };
1401 
1402 
1403 #endif /* __ASSEMBLER__ */
1404 
1405 #endif /* __ARCH_OPCODE_H__ */