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

Generated by: LCOV version 1.13