LCOV - code coverage report
Current view: top level - build-llvm/lib/Target/BPF - BPFGenDisassemblerTables.inc (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 84 106 79.2 %
Date: 2018-05-20 00:06:23 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
       2             : |*                                                                            *|
       3             : |*  * BPF Disassembler                                                        *|
       4             : |*                                                                            *|
       5             : |* Automatically generated file, do not edit!                                 *|
       6             : |*                                                                            *|
       7             : \*===----------------------------------------------------------------------===*/
       8             : 
       9             : #include "llvm/MC/MCInst.h"
      10             : #include "llvm/Support/Debug.h"
      11             : #include "llvm/Support/DataTypes.h"
      12             : #include "llvm/Support/LEB128.h"
      13             : #include "llvm/Support/raw_ostream.h"
      14             : #include <assert.h>
      15             : 
      16             : namespace llvm {
      17             : 
      18             : // Helper function for extracting fields from encoded instructions.
      19             : template<typename InsnType>
      20             : static InsnType fieldFromInstruction(InsnType insn, unsigned startBit,
      21             :                                      unsigned numBits) {
      22             :     assert(startBit + numBits <= (sizeof(InsnType)*8) &&
      23             :            "Instruction field out of bounds!");
      24             :     InsnType fieldMask;
      25         532 :     if (numBits == sizeof(InsnType)*8)
      26             :       fieldMask = (InsnType)(-1LL);
      27             :     else
      28         532 :       fieldMask = (((InsnType)1 << numBits) - 1) << startBit;
      29        1270 :     return (insn & fieldMask) >> startBit;
      30             : }
      31             : 
      32             : static const uint8_t DecoderTableBPF64[] = {
      33             : /* 0 */       MCD::OPC_ExtractField, 56, 8,  // Inst{63-56} ...
      34             : /* 3 */       MCD::OPC_FilterValue, 4, 3, 0, // Skip to: 10
      35             : /* 7 */       MCD::OPC_Decode, 125, 0, // Opcode: ADD_ri_32
      36             : /* 10 */      MCD::OPC_FilterValue, 5, 4, 0, // Skip to: 18
      37             : /* 14 */      MCD::OPC_Decode, 146, 1, 1, // Opcode: JMP
      38             : /* 18 */      MCD::OPC_FilterValue, 7, 3, 0, // Skip to: 25
      39             : /* 22 */      MCD::OPC_Decode, 124, 2, // Opcode: ADD_ri
      40             : /* 25 */      MCD::OPC_FilterValue, 12, 3, 0, // Skip to: 32
      41             : /* 29 */      MCD::OPC_Decode, 127, 3, // Opcode: ADD_rr_32
      42             : /* 32 */      MCD::OPC_FilterValue, 15, 3, 0, // Skip to: 39
      43             : /* 36 */      MCD::OPC_Decode, 126, 4, // Opcode: ADD_rr
      44             : /* 39 */      MCD::OPC_FilterValue, 20, 4, 0, // Skip to: 47
      45             : /* 43 */      MCD::OPC_Decode, 220, 1, 0, // Opcode: SUB_ri_32
      46             : /* 47 */      MCD::OPC_FilterValue, 21, 4, 0, // Skip to: 55
      47             : /* 51 */      MCD::OPC_Decode, 144, 1, 5, // Opcode: JEQ_ri
      48             : /* 55 */      MCD::OPC_FilterValue, 23, 4, 0, // Skip to: 63
      49             : /* 59 */      MCD::OPC_Decode, 219, 1, 2, // Opcode: SUB_ri
      50             : /* 63 */      MCD::OPC_FilterValue, 24, 37, 0, // Skip to: 104
      51             : /* 67 */      MCD::OPC_ExtractField, 32, 16,  // Inst{47-32} ...
      52             : /* 70 */      MCD::OPC_FilterValue, 0, 249, 2, // Skip to: 835
      53             : /* 74 */      MCD::OPC_CheckField, 48, 8, 32, 10, 0, // Skip to: 90
      54             : /* 80 */      MCD::OPC_CheckField, 0, 32, 0, 4, 0, // Skip to: 90
      55             : /* 86 */      MCD::OPC_Decode, 141, 1, 6, // Opcode: FI_ri
      56             : /* 90 */      MCD::OPC_CheckField, 52, 4, 0, 4, 0, // Skip to: 100
      57             : /* 96 */      MCD::OPC_Decode, 178, 1, 7, // Opcode: LD_imm64
      58             : /* 100 */     MCD::OPC_Decode, 179, 1, 8, // Opcode: LD_pseudo
      59             : /* 104 */     MCD::OPC_FilterValue, 28, 4, 0, // Skip to: 112
      60             : /* 108 */     MCD::OPC_Decode, 222, 1, 3, // Opcode: SUB_rr_32
      61             : /* 112 */     MCD::OPC_FilterValue, 29, 4, 0, // Skip to: 120
      62             : /* 116 */     MCD::OPC_Decode, 145, 1, 9, // Opcode: JEQ_rr
      63             : /* 120 */     MCD::OPC_FilterValue, 31, 4, 0, // Skip to: 128
      64             : /* 124 */     MCD::OPC_Decode, 221, 1, 4, // Opcode: SUB_rr
      65             : /* 128 */     MCD::OPC_FilterValue, 32, 4, 0, // Skip to: 136
      66             : /* 132 */     MCD::OPC_Decode, 174, 1, 10, // Opcode: LD_ABS_W
      67             : /* 136 */     MCD::OPC_FilterValue, 36, 4, 0, // Skip to: 144
      68             : /* 140 */     MCD::OPC_Decode, 189, 1, 0, // Opcode: MUL_ri_32
      69             : /* 144 */     MCD::OPC_FilterValue, 37, 4, 0, // Skip to: 152
      70             : /* 148 */     MCD::OPC_Decode, 159, 1, 5, // Opcode: JUGT_ri
      71             : /* 152 */     MCD::OPC_FilterValue, 39, 4, 0, // Skip to: 160
      72             : /* 156 */     MCD::OPC_Decode, 188, 1, 2, // Opcode: MUL_ri
      73             : /* 160 */     MCD::OPC_FilterValue, 40, 4, 0, // Skip to: 168
      74             : /* 164 */     MCD::OPC_Decode, 173, 1, 10, // Opcode: LD_ABS_H
      75             : /* 168 */     MCD::OPC_FilterValue, 44, 4, 0, // Skip to: 176
      76             : /* 172 */     MCD::OPC_Decode, 191, 1, 3, // Opcode: MUL_rr_32
      77             : /* 176 */     MCD::OPC_FilterValue, 45, 4, 0, // Skip to: 184
      78             : /* 180 */     MCD::OPC_Decode, 160, 1, 9, // Opcode: JUGT_rr
      79             : /* 184 */     MCD::OPC_FilterValue, 47, 4, 0, // Skip to: 192
      80             : /* 188 */     MCD::OPC_Decode, 190, 1, 4, // Opcode: MUL_rr
      81             : /* 192 */     MCD::OPC_FilterValue, 48, 4, 0, // Skip to: 200
      82             : /* 196 */     MCD::OPC_Decode, 172, 1, 10, // Opcode: LD_ABS_B
      83             : /* 200 */     MCD::OPC_FilterValue, 52, 4, 0, // Skip to: 208
      84             : /* 204 */     MCD::OPC_Decode, 138, 1, 0, // Opcode: DIV_ri_32
      85             : /* 208 */     MCD::OPC_FilterValue, 53, 4, 0, // Skip to: 216
      86             : /* 212 */     MCD::OPC_Decode, 157, 1, 5, // Opcode: JUGE_ri
      87             : /* 216 */     MCD::OPC_FilterValue, 55, 4, 0, // Skip to: 224
      88             : /* 220 */     MCD::OPC_Decode, 137, 1, 2, // Opcode: DIV_ri
      89             : /* 224 */     MCD::OPC_FilterValue, 60, 4, 0, // Skip to: 232
      90             : /* 228 */     MCD::OPC_Decode, 140, 1, 3, // Opcode: DIV_rr_32
      91             : /* 232 */     MCD::OPC_FilterValue, 61, 4, 0, // Skip to: 240
      92             : /* 236 */     MCD::OPC_Decode, 158, 1, 9, // Opcode: JUGE_rr
      93             : /* 240 */     MCD::OPC_FilterValue, 63, 4, 0, // Skip to: 248
      94             : /* 244 */     MCD::OPC_Decode, 139, 1, 4, // Opcode: DIV_rr
      95             : /* 248 */     MCD::OPC_FilterValue, 64, 4, 0, // Skip to: 256
      96             : /* 252 */     MCD::OPC_Decode, 177, 1, 11, // Opcode: LD_IND_W
      97             : /* 256 */     MCD::OPC_FilterValue, 68, 4, 0, // Skip to: 264
      98             : /* 260 */     MCD::OPC_Decode, 196, 1, 0, // Opcode: OR_ri_32
      99             : /* 264 */     MCD::OPC_FilterValue, 71, 4, 0, // Skip to: 272
     100             : /* 268 */     MCD::OPC_Decode, 195, 1, 2, // Opcode: OR_ri
     101             : /* 272 */     MCD::OPC_FilterValue, 72, 4, 0, // Skip to: 280
     102             : /* 276 */     MCD::OPC_Decode, 176, 1, 11, // Opcode: LD_IND_H
     103             : /* 280 */     MCD::OPC_FilterValue, 76, 4, 0, // Skip to: 288
     104             : /* 284 */     MCD::OPC_Decode, 198, 1, 3, // Opcode: OR_rr_32
     105             : /* 288 */     MCD::OPC_FilterValue, 79, 4, 0, // Skip to: 296
     106             : /* 292 */     MCD::OPC_Decode, 197, 1, 4, // Opcode: OR_rr
     107             : /* 296 */     MCD::OPC_FilterValue, 80, 4, 0, // Skip to: 304
     108             : /* 300 */     MCD::OPC_Decode, 175, 1, 11, // Opcode: LD_IND_B
     109             : /* 304 */     MCD::OPC_FilterValue, 84, 4, 0, // Skip to: 312
     110             : /* 308 */     MCD::OPC_Decode, 131, 1, 0, // Opcode: AND_ri_32
     111             : /* 312 */     MCD::OPC_FilterValue, 85, 4, 0, // Skip to: 320
     112             : /* 316 */     MCD::OPC_Decode, 147, 1, 5, // Opcode: JNE_ri
     113             : /* 320 */     MCD::OPC_FilterValue, 87, 4, 0, // Skip to: 328
     114             : /* 324 */     MCD::OPC_Decode, 130, 1, 2, // Opcode: AND_ri
     115             : /* 328 */     MCD::OPC_FilterValue, 92, 4, 0, // Skip to: 336
     116             : /* 332 */     MCD::OPC_Decode, 133, 1, 3, // Opcode: AND_rr_32
     117             : /* 336 */     MCD::OPC_FilterValue, 93, 4, 0, // Skip to: 344
     118             : /* 340 */     MCD::OPC_Decode, 148, 1, 9, // Opcode: JNE_rr
     119             : /* 344 */     MCD::OPC_FilterValue, 95, 4, 0, // Skip to: 352
     120             : /* 348 */     MCD::OPC_Decode, 132, 1, 4, // Opcode: AND_rr
     121             : /* 352 */     MCD::OPC_FilterValue, 97, 4, 0, // Skip to: 360
     122             : /* 356 */     MCD::OPC_Decode, 170, 1, 12, // Opcode: LDW
     123             : /* 360 */     MCD::OPC_FilterValue, 99, 4, 0, // Skip to: 368
     124             : /* 364 */     MCD::OPC_Decode, 217, 1, 13, // Opcode: STW
     125             : /* 368 */     MCD::OPC_FilterValue, 100, 4, 0, // Skip to: 376
     126             : /* 372 */     MCD::OPC_Decode, 201, 1, 0, // Opcode: SLL_ri_32
     127             : /* 376 */     MCD::OPC_FilterValue, 101, 4, 0, // Skip to: 384
     128             : /* 380 */     MCD::OPC_Decode, 151, 1, 5, // Opcode: JSGT_ri
     129             : /* 384 */     MCD::OPC_FilterValue, 103, 4, 0, // Skip to: 392
     130             : /* 388 */     MCD::OPC_Decode, 200, 1, 2, // Opcode: SLL_ri
     131             : /* 392 */     MCD::OPC_FilterValue, 105, 4, 0, // Skip to: 400
     132             : /* 396 */     MCD::OPC_Decode, 168, 1, 12, // Opcode: LDH
     133             : /* 400 */     MCD::OPC_FilterValue, 107, 4, 0, // Skip to: 408
     134             : /* 404 */     MCD::OPC_Decode, 215, 1, 13, // Opcode: STH
     135             : /* 408 */     MCD::OPC_FilterValue, 108, 4, 0, // Skip to: 416
     136             : /* 412 */     MCD::OPC_Decode, 203, 1, 3, // Opcode: SLL_rr_32
     137             : /* 416 */     MCD::OPC_FilterValue, 109, 4, 0, // Skip to: 424
     138             : /* 420 */     MCD::OPC_Decode, 152, 1, 9, // Opcode: JSGT_rr
     139             : /* 424 */     MCD::OPC_FilterValue, 111, 4, 0, // Skip to: 432
     140             : /* 428 */     MCD::OPC_Decode, 202, 1, 4, // Opcode: SLL_rr
     141             : /* 432 */     MCD::OPC_FilterValue, 113, 4, 0, // Skip to: 440
     142             : /* 436 */     MCD::OPC_Decode, 165, 1, 12, // Opcode: LDB
     143             : /* 440 */     MCD::OPC_FilterValue, 115, 4, 0, // Skip to: 448
     144             : /* 444 */     MCD::OPC_Decode, 212, 1, 13, // Opcode: STB
     145             : /* 448 */     MCD::OPC_FilterValue, 116, 4, 0, // Skip to: 456
     146             : /* 452 */     MCD::OPC_Decode, 209, 1, 0, // Opcode: SRL_ri_32
     147             : /* 456 */     MCD::OPC_FilterValue, 117, 4, 0, // Skip to: 464
     148             : /* 460 */     MCD::OPC_Decode, 149, 1, 5, // Opcode: JSGE_ri
     149             : /* 464 */     MCD::OPC_FilterValue, 119, 4, 0, // Skip to: 472
     150             : /* 468 */     MCD::OPC_Decode, 208, 1, 2, // Opcode: SRL_ri
     151             : /* 472 */     MCD::OPC_FilterValue, 121, 4, 0, // Skip to: 480
     152             : /* 476 */     MCD::OPC_Decode, 167, 1, 12, // Opcode: LDD
     153             : /* 480 */     MCD::OPC_FilterValue, 123, 4, 0, // Skip to: 488
     154             : /* 484 */     MCD::OPC_Decode, 214, 1, 13, // Opcode: STD
     155             : /* 488 */     MCD::OPC_FilterValue, 124, 4, 0, // Skip to: 496
     156             : /* 492 */     MCD::OPC_Decode, 211, 1, 3, // Opcode: SRL_rr_32
     157             : /* 496 */     MCD::OPC_FilterValue, 125, 4, 0, // Skip to: 504
     158             : /* 500 */     MCD::OPC_Decode, 150, 1, 9, // Opcode: JSGE_rr
     159             : /* 504 */     MCD::OPC_FilterValue, 127, 4, 0, // Skip to: 512
     160             : /* 508 */     MCD::OPC_Decode, 210, 1, 4, // Opcode: SRL_rr
     161             : /* 512 */     MCD::OPC_FilterValue, 132, 1, 4, 0, // Skip to: 521
     162             : /* 517 */     MCD::OPC_Decode, 192, 1, 14, // Opcode: NEG_32
     163             : /* 521 */     MCD::OPC_FilterValue, 133, 1, 4, 0, // Skip to: 530
     164             : /* 526 */     MCD::OPC_Decode, 142, 1, 10, // Opcode: JAL
     165             : /* 530 */     MCD::OPC_FilterValue, 135, 1, 4, 0, // Skip to: 539
     166             : /* 535 */     MCD::OPC_Decode, 193, 1, 15, // Opcode: NEG_64
     167             : /* 539 */     MCD::OPC_FilterValue, 141, 1, 4, 0, // Skip to: 548
     168             : /* 544 */     MCD::OPC_Decode, 143, 1, 10, // Opcode: JALX
     169             : /* 548 */     MCD::OPC_FilterValue, 149, 1, 10, 0, // Skip to: 563
     170             : /* 553 */     MCD::OPC_CheckField, 0, 32, 0, 20, 1, // Skip to: 835
     171             : /* 559 */     MCD::OPC_Decode, 199, 1, 6, // Opcode: RET
     172             : /* 563 */     MCD::OPC_FilterValue, 164, 1, 4, 0, // Skip to: 572
     173             : /* 568 */     MCD::OPC_Decode, 234, 1, 0, // Opcode: XOR_ri_32
     174             : /* 572 */     MCD::OPC_FilterValue, 165, 1, 4, 0, // Skip to: 581
     175             : /* 577 */     MCD::OPC_Decode, 163, 1, 5, // Opcode: JULT_ri
     176             : /* 581 */     MCD::OPC_FilterValue, 167, 1, 4, 0, // Skip to: 590
     177             : /* 586 */     MCD::OPC_Decode, 233, 1, 2, // Opcode: XOR_ri
     178             : /* 590 */     MCD::OPC_FilterValue, 172, 1, 4, 0, // Skip to: 599
     179             : /* 595 */     MCD::OPC_Decode, 236, 1, 3, // Opcode: XOR_rr_32
     180             : /* 599 */     MCD::OPC_FilterValue, 173, 1, 4, 0, // Skip to: 608
     181             : /* 604 */     MCD::OPC_Decode, 164, 1, 9, // Opcode: JULT_rr
     182             : /* 608 */     MCD::OPC_FilterValue, 175, 1, 4, 0, // Skip to: 617
     183             : /* 613 */     MCD::OPC_Decode, 235, 1, 4, // Opcode: XOR_rr
     184             : /* 617 */     MCD::OPC_FilterValue, 180, 1, 4, 0, // Skip to: 626
     185             : /* 622 */     MCD::OPC_Decode, 185, 1, 16, // Opcode: MOV_ri_32
     186             : /* 626 */     MCD::OPC_FilterValue, 181, 1, 4, 0, // Skip to: 635
     187             : /* 631 */     MCD::OPC_Decode, 161, 1, 5, // Opcode: JULE_ri
     188             : /* 635 */     MCD::OPC_FilterValue, 183, 1, 4, 0, // Skip to: 644
     189             : /* 640 */     MCD::OPC_Decode, 184, 1, 7, // Opcode: MOV_ri
     190             : /* 644 */     MCD::OPC_FilterValue, 188, 1, 4, 0, // Skip to: 653
     191             : /* 649 */     MCD::OPC_Decode, 187, 1, 17, // Opcode: MOV_rr_32
     192             : /* 653 */     MCD::OPC_FilterValue, 189, 1, 4, 0, // Skip to: 662
     193             : /* 658 */     MCD::OPC_Decode, 162, 1, 9, // Opcode: JULE_rr
     194             : /* 662 */     MCD::OPC_FilterValue, 191, 1, 14, 0, // Skip to: 681
     195             : /* 667 */     MCD::OPC_CheckField, 48, 8, 0, 4, 0, // Skip to: 677
     196             : /* 673 */     MCD::OPC_Decode, 194, 1, 6, // Opcode: NOP
     197             : /* 677 */     MCD::OPC_Decode, 186, 1, 18, // Opcode: MOV_rr
     198             : /* 681 */     MCD::OPC_FilterValue, 195, 1, 4, 0, // Skip to: 690
     199             : /* 686 */     MCD::OPC_Decode, 231, 1, 19, // Opcode: XADD32
     200             : /* 690 */     MCD::OPC_FilterValue, 196, 1, 4, 0, // Skip to: 699
     201             : /* 695 */     MCD::OPC_Decode, 205, 1, 0, // Opcode: SRA_ri_32
     202             : /* 699 */     MCD::OPC_FilterValue, 197, 1, 4, 0, // Skip to: 708
     203             : /* 704 */     MCD::OPC_Decode, 155, 1, 5, // Opcode: JSLT_ri
     204             : /* 708 */     MCD::OPC_FilterValue, 199, 1, 4, 0, // Skip to: 717
     205             : /* 713 */     MCD::OPC_Decode, 204, 1, 2, // Opcode: SRA_ri
     206             : /* 717 */     MCD::OPC_FilterValue, 204, 1, 4, 0, // Skip to: 726
     207             : /* 722 */     MCD::OPC_Decode, 207, 1, 3, // Opcode: SRA_rr_32
     208             : /* 726 */     MCD::OPC_FilterValue, 205, 1, 4, 0, // Skip to: 735
     209             : /* 731 */     MCD::OPC_Decode, 156, 1, 9, // Opcode: JSLT_rr
     210             : /* 735 */     MCD::OPC_FilterValue, 207, 1, 4, 0, // Skip to: 744
     211             : /* 740 */     MCD::OPC_Decode, 206, 1, 4, // Opcode: SRA_rr
     212             : /* 744 */     MCD::OPC_FilterValue, 212, 1, 27, 0, // Skip to: 776
     213             : /* 749 */     MCD::OPC_ExtractField, 0, 32,  // Inst{31-0} ...
     214             : /* 752 */     MCD::OPC_FilterValue, 16, 4, 0, // Skip to: 760
     215             : /* 756 */     MCD::OPC_Decode, 180, 1, 15, // Opcode: LE16
     216             : /* 760 */     MCD::OPC_FilterValue, 32, 4, 0, // Skip to: 768
     217             : /* 764 */     MCD::OPC_Decode, 181, 1, 15, // Opcode: LE32
     218             : /* 768 */     MCD::OPC_FilterValue, 64, 63, 0, // Skip to: 835
     219             : /* 772 */     MCD::OPC_Decode, 182, 1, 15, // Opcode: LE64
     220             : /* 776 */     MCD::OPC_FilterValue, 213, 1, 4, 0, // Skip to: 785
     221             : /* 781 */     MCD::OPC_Decode, 153, 1, 5, // Opcode: JSLE_ri
     222             : /* 785 */     MCD::OPC_FilterValue, 219, 1, 4, 0, // Skip to: 794
     223             : /* 790 */     MCD::OPC_Decode, 232, 1, 19, // Opcode: XADD64
     224             : /* 794 */     MCD::OPC_FilterValue, 220, 1, 27, 0, // Skip to: 826
     225             : /* 799 */     MCD::OPC_ExtractField, 0, 32,  // Inst{31-0} ...
     226             : /* 802 */     MCD::OPC_FilterValue, 16, 4, 0, // Skip to: 810
     227             : /* 806 */     MCD::OPC_Decode, 134, 1, 15, // Opcode: BE16
     228             : /* 810 */     MCD::OPC_FilterValue, 32, 4, 0, // Skip to: 818
     229             : /* 814 */     MCD::OPC_Decode, 135, 1, 15, // Opcode: BE32
     230             : /* 818 */     MCD::OPC_FilterValue, 64, 13, 0, // Skip to: 835
     231             : /* 822 */     MCD::OPC_Decode, 136, 1, 15, // Opcode: BE64
     232             : /* 826 */     MCD::OPC_FilterValue, 221, 1, 4, 0, // Skip to: 835
     233             : /* 831 */     MCD::OPC_Decode, 154, 1, 9, // Opcode: JSLE_rr
     234             : /* 835 */     MCD::OPC_Fail,
     235             :   0
     236             : };
     237             : 
     238             : static const uint8_t DecoderTableBPFALU3264[] = {
     239             : /* 0 */       MCD::OPC_ExtractField, 56, 8,  // Inst{63-56} ...
     240             : /* 3 */       MCD::OPC_FilterValue, 97, 4, 0, // Skip to: 11
     241             : /* 7 */       MCD::OPC_Decode, 171, 1, 20, // Opcode: LDW32
     242             : /* 11 */      MCD::OPC_FilterValue, 99, 4, 0, // Skip to: 19
     243             : /* 15 */      MCD::OPC_Decode, 218, 1, 21, // Opcode: STW32
     244             : /* 19 */      MCD::OPC_FilterValue, 105, 4, 0, // Skip to: 27
     245             : /* 23 */      MCD::OPC_Decode, 169, 1, 20, // Opcode: LDH32
     246             : /* 27 */      MCD::OPC_FilterValue, 107, 4, 0, // Skip to: 35
     247             : /* 31 */      MCD::OPC_Decode, 216, 1, 21, // Opcode: STH32
     248             : /* 35 */      MCD::OPC_FilterValue, 113, 4, 0, // Skip to: 43
     249             : /* 39 */      MCD::OPC_Decode, 166, 1, 20, // Opcode: LDB32
     250             : /* 43 */      MCD::OPC_FilterValue, 115, 4, 0, // Skip to: 51
     251             : /* 47 */      MCD::OPC_Decode, 213, 1, 21, // Opcode: STB32
     252             : /* 51 */      MCD::OPC_Fail,
     253             :   0
     254             : };
     255             : 
     256             : static bool checkDecoderPredicate(unsigned Idx, const FeatureBitset& Bits) {
     257           0 :   llvm_unreachable("Invalid index!");
     258             : }
     259             : 
     260             : template<typename InsnType>
     261         389 : static DecodeStatus decodeToMCInst(DecodeStatus S, unsigned Idx, InsnType insn, MCInst &MI,
     262             :                                    uint64_t Address, const void *Decoder, bool &DecodeComplete) {
     263         389 :   DecodeComplete = true;
     264             :   InsnType tmp;
     265         389 :   switch (Idx) {
     266           0 :   default: llvm_unreachable("Invalid index!");
     267             :   case 0:
     268             :     tmp = fieldFromInstruction(insn, 48, 4);
     269          20 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     270             :     tmp = fieldFromInstruction(insn, 48, 4);
     271          20 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     272             :     tmp = fieldFromInstruction(insn, 0, 32);
     273          40 :     MI.addOperand(MCOperand::createImm(tmp));
     274             :     return S;
     275             :   case 1:
     276             :     tmp = fieldFromInstruction(insn, 32, 16);
     277          10 :     MI.addOperand(MCOperand::createImm(tmp));
     278             :     return S;
     279             :   case 2:
     280             :     tmp = fieldFromInstruction(insn, 48, 4);
     281          49 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     282             :     tmp = fieldFromInstruction(insn, 48, 4);
     283          49 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     284             :     tmp = fieldFromInstruction(insn, 0, 32);
     285          98 :     MI.addOperand(MCOperand::createImm(tmp));
     286             :     return S;
     287             :   case 3:
     288             :     tmp = fieldFromInstruction(insn, 48, 4);
     289          20 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     290             :     tmp = fieldFromInstruction(insn, 48, 4);
     291          20 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     292             :     tmp = fieldFromInstruction(insn, 52, 4);
     293          20 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     294             :     return S;
     295             :   case 4:
     296             :     tmp = fieldFromInstruction(insn, 48, 4);
     297          41 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     298             :     tmp = fieldFromInstruction(insn, 48, 4);
     299          41 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     300             :     tmp = fieldFromInstruction(insn, 52, 4);
     301          41 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     302             :     return S;
     303             :   case 5:
     304             :     tmp = fieldFromInstruction(insn, 48, 4);
     305          21 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     306             :     tmp = fieldFromInstruction(insn, 0, 32);
     307          42 :     MI.addOperand(MCOperand::createImm(tmp));
     308             :     tmp = fieldFromInstruction(insn, 32, 16);
     309          42 :     MI.addOperand(MCOperand::createImm(tmp));
     310             :     return S;
     311             :   case 6:
     312             :     return S;
     313             :   case 7:
     314             :     tmp = fieldFromInstruction(insn, 48, 4);
     315          38 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     316             :     tmp = fieldFromInstruction(insn, 0, 32);
     317          76 :     MI.addOperand(MCOperand::createImm(tmp));
     318             :     return S;
     319             :   case 8:
     320             :     tmp = fieldFromInstruction(insn, 48, 4);
     321           2 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     322             :     tmp = fieldFromInstruction(insn, 52, 4);
     323           4 :     MI.addOperand(MCOperand::createImm(tmp));
     324             :     tmp = fieldFromInstruction(insn, 0, 32);
     325           4 :     MI.addOperand(MCOperand::createImm(tmp));
     326             :     return S;
     327             :   case 9:
     328             :     tmp = fieldFromInstruction(insn, 48, 4);
     329          28 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     330             :     tmp = fieldFromInstruction(insn, 52, 4);
     331          28 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     332             :     tmp = fieldFromInstruction(insn, 32, 16);
     333          56 :     MI.addOperand(MCOperand::createImm(tmp));
     334             :     return S;
     335             :   case 10:
     336             :     tmp = fieldFromInstruction(insn, 0, 32);
     337          36 :     MI.addOperand(MCOperand::createImm(tmp));
     338             :     return S;
     339             :   case 11:
     340             :     tmp = fieldFromInstruction(insn, 52, 4);
     341          12 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     342             :     return S;
     343             :   case 12:
     344             :     tmp = fieldFromInstruction(insn, 48, 4);
     345          20 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     346             :     tmp = 0;
     347             :     tmp |= fieldFromInstruction(insn, 32, 16) << 0;
     348          20 :     tmp |= fieldFromInstruction(insn, 52, 4) << 16;
     349          20 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     350             :     return S;
     351             :   case 13:
     352             :     tmp = fieldFromInstruction(insn, 52, 4);
     353          13 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     354             :     tmp = fieldFromInstruction(insn, 32, 20);
     355          13 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     356             :     return S;
     357             :   case 14:
     358             :     tmp = fieldFromInstruction(insn, 48, 4);
     359           2 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     360             :     tmp = fieldFromInstruction(insn, 48, 4);
     361           2 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     362             :     return S;
     363             :   case 15:
     364             :     tmp = fieldFromInstruction(insn, 48, 4);
     365          14 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     366             :     tmp = fieldFromInstruction(insn, 48, 4);
     367          14 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     368             :     return S;
     369             :   case 16:
     370             :     tmp = fieldFromInstruction(insn, 48, 4);
     371           4 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     372             :     tmp = fieldFromInstruction(insn, 0, 32);
     373           8 :     MI.addOperand(MCOperand::createImm(tmp));
     374             :     return S;
     375             :   case 17:
     376             :     tmp = fieldFromInstruction(insn, 48, 4);
     377           2 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     378             :     tmp = fieldFromInstruction(insn, 52, 4);
     379           2 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     380             :     return S;
     381             :   case 18:
     382             :     tmp = fieldFromInstruction(insn, 48, 4);
     383          42 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     384             :     tmp = fieldFromInstruction(insn, 52, 4);
     385          42 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     386             :     return S;
     387             :   case 19:
     388             :     tmp = fieldFromInstruction(insn, 52, 4);
     389           6 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     390             :     tmp = fieldFromInstruction(insn, 32, 20);
     391           6 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     392             :     tmp = fieldFromInstruction(insn, 52, 4);
     393           6 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     394             :     return S;
     395             :   case 20:
     396             :     tmp = fieldFromInstruction(insn, 48, 4);
     397           6 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     398             :     tmp = 0;
     399             :     tmp |= fieldFromInstruction(insn, 32, 16) << 0;
     400           6 :     tmp |= fieldFromInstruction(insn, 52, 4) << 16;
     401           6 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     402             :     return S;
     403             :   case 21:
     404             :     tmp = fieldFromInstruction(insn, 52, 4);
     405           6 :     if (DecodeGPR32RegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     406             :     tmp = fieldFromInstruction(insn, 32, 20);
     407           6 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     408             :     return S;
     409             :   }
     410             : }
     411             : 
     412             : template<typename InsnType>
     413         389 : static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
     414             :                                       InsnType insn, uint64_t Address,
     415             :                                       const void *DisAsm,
     416             :                                       const MCSubtargetInfo &STI) {
     417             :   const FeatureBitset& Bits = STI.getFeatureBits();
     418             : 
     419             :   const uint8_t *Ptr = DecodeTable;
     420             :   uint32_t CurFieldValue = 0;
     421             :   DecodeStatus S = MCDisassembler::Success;
     422             :   while (true) {
     423       18939 :     ptrdiff_t Loc = Ptr - DecodeTable;
     424       18939 :     switch (*Ptr) {
     425           0 :     default:
     426           0 :       errs() << Loc << ": Unexpected decode table opcode!\n";
     427             :       return MCDisassembler::Fail;
     428         424 :     case MCD::OPC_ExtractField: {
     429         424 :       unsigned Start = *++Ptr;
     430         424 :       unsigned Len = *++Ptr;
     431         424 :       ++Ptr;
     432         424 :       CurFieldValue = fieldFromInstruction(insn, Start, Len);
     433             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_ExtractField(" << Start << ", "
     434             :                    << Len << "): " << CurFieldValue << "\n");
     435             :       break;
     436             :     }
     437       18018 :     case MCD::OPC_FilterValue: {
     438             :       // Decode the field value.
     439             :       unsigned Len;
     440       18018 :       InsnType Val = decodeULEB128(++Ptr, &Len);
     441       18018 :       Ptr += Len;
     442             :       // NumToSkip is a plain 16-bit integer.
     443       18018 :       unsigned NumToSkip = *Ptr++;
     444       18018 :       NumToSkip |= (*Ptr++) << 8;
     445             : 
     446             :       // Perform the filter operation.
     447       18018 :       if (Val != CurFieldValue)
     448       17594 :         Ptr += NumToSkip;
     449             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_FilterValue(" << Val << ", " << NumToSkip
     450             :                    << "): " << ((Val != CurFieldValue) ? "FAIL:" : "PASS:")
     451             :                    << " continuing at " << (Ptr - DecodeTable) << "\n");
     452             : 
     453             :       break;
     454             :     }
     455         108 :     case MCD::OPC_CheckField: {
     456         108 :       unsigned Start = *++Ptr;
     457         108 :       unsigned Len = *++Ptr;
     458             :       InsnType FieldValue = fieldFromInstruction(insn, Start, Len);
     459             :       // Decode the field value.
     460         108 :       uint32_t ExpectedValue = decodeULEB128(++Ptr, &Len);
     461         108 :       Ptr += Len;
     462             :       // NumToSkip is a plain 16-bit integer.
     463         108 :       unsigned NumToSkip = *Ptr++;
     464         108 :       NumToSkip |= (*Ptr++) << 8;
     465             : 
     466             :       // If the actual and expected values don't match, skip.
     467         108 :       if (ExpectedValue != FieldValue)
     468          67 :         Ptr += NumToSkip;
     469             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckField(" << Start << ", "
     470             :                    << Len << ", " << ExpectedValue << ", " << NumToSkip
     471             :                    << "): FieldValue = " << FieldValue << ", ExpectedValue = "
     472             :                    << ExpectedValue << ": "
     473             :                    << ((ExpectedValue == FieldValue) ? "PASS\n" : "FAIL\n"));
     474             :       break;
     475             :     }
     476           0 :     case MCD::OPC_CheckPredicate: {
     477             :       unsigned Len;
     478             :       // Decode the Predicate Index value.
     479           0 :       unsigned PIdx = decodeULEB128(++Ptr, &Len);
     480             :       Ptr += Len;
     481             :       // NumToSkip is a plain 16-bit integer.
     482             :       unsigned NumToSkip = *Ptr++;
     483             :       NumToSkip |= (*Ptr++) << 8;
     484             :       // Check the predicate.
     485             :       bool Pred;
     486             :       if (!(Pred = checkDecoderPredicate(PIdx, Bits)))
     487             :         Ptr += NumToSkip;
     488             :       (void)Pred;
     489             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckPredicate(" << PIdx << "): "
     490             :             << (Pred ? "PASS\n" : "FAIL\n"));
     491             : 
     492             :       break;
     493             :     }
     494         389 :     case MCD::OPC_Decode: {
     495             :       unsigned Len;
     496             :       // Decode the Opcode value.
     497         389 :       unsigned Opc = decodeULEB128(++Ptr, &Len);
     498         389 :       Ptr += Len;
     499         389 :       unsigned DecodeIdx = decodeULEB128(Ptr, &Len);
     500             :       Ptr += Len;
     501             : 
     502             :       MI.clear();
     503             :       MI.setOpcode(Opc);
     504             :       bool DecodeComplete;
     505         389 :       S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete);
     506             :       assert(DecodeComplete);
     507             : 
     508             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_Decode: opcode " << Opc
     509             :                    << ", using decoder " << DecodeIdx << ": "
     510             :                    << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
     511             :       return S;
     512             :     }
     513           0 :     case MCD::OPC_TryDecode: {
     514             :       unsigned Len;
     515             :       // Decode the Opcode value.
     516           0 :       unsigned Opc = decodeULEB128(++Ptr, &Len);
     517           0 :       Ptr += Len;
     518           0 :       unsigned DecodeIdx = decodeULEB128(Ptr, &Len);
     519           0 :       Ptr += Len;
     520             :       // NumToSkip is a plain 16-bit integer.
     521           0 :       unsigned NumToSkip = *Ptr++;
     522           0 :       NumToSkip |= (*Ptr++) << 8;
     523             : 
     524             :       // Perform the decode operation.
     525             :       MCInst TmpMI;
     526             :       TmpMI.setOpcode(Opc);
     527             :       bool DecodeComplete;
     528           0 :       S = decodeToMCInst(S, DecodeIdx, insn, TmpMI, Address, DisAsm, DecodeComplete);
     529             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_TryDecode: opcode " << Opc
     530             :                    << ", using decoder " << DecodeIdx << ": ");
     531             : 
     532           0 :       if (DecodeComplete) {
     533             :         // Decoding complete.
     534             :         LLVM_DEBUG(dbgs() << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
     535             :         MI = TmpMI;
     536             :         return S;
     537             :       } else {
     538             :         assert(S == MCDisassembler::Fail);
     539             :         // If the decoding was incomplete, skip.
     540           0 :         Ptr += NumToSkip;
     541             :         LLVM_DEBUG(dbgs() << "FAIL: continuing at " << (Ptr - DecodeTable) << "\n");
     542             :         // Reset decode status. This also drops a SoftFail status that could be
     543             :         // set before the decode attempt.
     544             :         S = MCDisassembler::Success;
     545             :       }
     546             :       break;
     547             :     }
     548           0 :     case MCD::OPC_SoftFail: {
     549             :       // Decode the mask values.
     550             :       unsigned Len;
     551           0 :       InsnType PositiveMask = decodeULEB128(++Ptr, &Len);
     552           0 :       Ptr += Len;
     553           0 :       InsnType NegativeMask = decodeULEB128(Ptr, &Len);
     554           0 :       Ptr += Len;
     555           0 :       bool Fail = (insn & PositiveMask) || (~insn & NegativeMask);
     556             :       if (Fail)
     557             :         S = MCDisassembler::SoftFail;
     558             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_SoftFail: " << (Fail ? "FAIL\n":"PASS\n"));
     559             :       break;
     560             :     }
     561             :     case MCD::OPC_Fail: {
     562             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_Fail\n");
     563             :       return MCDisassembler::Fail;
     564             :     }
     565             :     }
     566             :   }
     567             :   llvm_unreachable("bogosity detected in disassembler state machine!");
     568             : }
     569             : 
     570             : 
     571             : } // End llvm namespace

Generated by: LCOV version 1.13