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: 86 109 78.9 %
Date: 2018-07-13 00:08:38 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, 4, 0, 0, // Skip to: 12
      35             : /* 8 */       MCD::OPC_Decode, 136, 1, 0, // Opcode: ADD_ri_32
      36             : /* 12 */      MCD::OPC_FilterValue, 5, 4, 0, 0, // Skip to: 21
      37             : /* 17 */      MCD::OPC_Decode, 155, 1, 1, // Opcode: JMP
      38             : /* 21 */      MCD::OPC_FilterValue, 7, 4, 0, 0, // Skip to: 30
      39             : /* 26 */      MCD::OPC_Decode, 135, 1, 2, // Opcode: ADD_ri
      40             : /* 30 */      MCD::OPC_FilterValue, 12, 4, 0, 0, // Skip to: 39
      41             : /* 35 */      MCD::OPC_Decode, 138, 1, 3, // Opcode: ADD_rr_32
      42             : /* 39 */      MCD::OPC_FilterValue, 15, 4, 0, 0, // Skip to: 48
      43             : /* 44 */      MCD::OPC_Decode, 137, 1, 4, // Opcode: ADD_rr
      44             : /* 48 */      MCD::OPC_FilterValue, 20, 4, 0, 0, // Skip to: 57
      45             : /* 53 */      MCD::OPC_Decode, 229, 1, 0, // Opcode: SUB_ri_32
      46             : /* 57 */      MCD::OPC_FilterValue, 21, 4, 0, 0, // Skip to: 66
      47             : /* 62 */      MCD::OPC_Decode, 153, 1, 5, // Opcode: JEQ_ri
      48             : /* 66 */      MCD::OPC_FilterValue, 23, 4, 0, 0, // Skip to: 75
      49             : /* 71 */      MCD::OPC_Decode, 228, 1, 2, // Opcode: SUB_ri
      50             : /* 75 */      MCD::OPC_FilterValue, 24, 41, 0, 0, // Skip to: 121
      51             : /* 80 */      MCD::OPC_ExtractField, 32, 16,  // Inst{47-32} ...
      52             : /* 83 */      MCD::OPC_FilterValue, 0, 84, 3, 0, // Skip to: 940
      53             : /* 88 */      MCD::OPC_CheckField, 48, 8, 32, 11, 0, 0, // Skip to: 106
      54             : /* 95 */      MCD::OPC_CheckField, 0, 32, 0, 4, 0, 0, // Skip to: 106
      55             : /* 102 */     MCD::OPC_Decode, 150, 1, 6, // Opcode: FI_ri
      56             : /* 106 */     MCD::OPC_CheckField, 52, 4, 0, 4, 0, 0, // Skip to: 117
      57             : /* 113 */     MCD::OPC_Decode, 187, 1, 7, // Opcode: LD_imm64
      58             : /* 117 */     MCD::OPC_Decode, 188, 1, 8, // Opcode: LD_pseudo
      59             : /* 121 */     MCD::OPC_FilterValue, 28, 4, 0, 0, // Skip to: 130
      60             : /* 126 */     MCD::OPC_Decode, 231, 1, 3, // Opcode: SUB_rr_32
      61             : /* 130 */     MCD::OPC_FilterValue, 29, 4, 0, 0, // Skip to: 139
      62             : /* 135 */     MCD::OPC_Decode, 154, 1, 9, // Opcode: JEQ_rr
      63             : /* 139 */     MCD::OPC_FilterValue, 31, 4, 0, 0, // Skip to: 148
      64             : /* 144 */     MCD::OPC_Decode, 230, 1, 4, // Opcode: SUB_rr
      65             : /* 148 */     MCD::OPC_FilterValue, 32, 4, 0, 0, // Skip to: 157
      66             : /* 153 */     MCD::OPC_Decode, 183, 1, 10, // Opcode: LD_ABS_W
      67             : /* 157 */     MCD::OPC_FilterValue, 36, 4, 0, 0, // Skip to: 166
      68             : /* 162 */     MCD::OPC_Decode, 198, 1, 0, // Opcode: MUL_ri_32
      69             : /* 166 */     MCD::OPC_FilterValue, 37, 4, 0, 0, // Skip to: 175
      70             : /* 171 */     MCD::OPC_Decode, 168, 1, 5, // Opcode: JUGT_ri
      71             : /* 175 */     MCD::OPC_FilterValue, 39, 4, 0, 0, // Skip to: 184
      72             : /* 180 */     MCD::OPC_Decode, 197, 1, 2, // Opcode: MUL_ri
      73             : /* 184 */     MCD::OPC_FilterValue, 40, 4, 0, 0, // Skip to: 193
      74             : /* 189 */     MCD::OPC_Decode, 182, 1, 10, // Opcode: LD_ABS_H
      75             : /* 193 */     MCD::OPC_FilterValue, 44, 4, 0, 0, // Skip to: 202
      76             : /* 198 */     MCD::OPC_Decode, 200, 1, 3, // Opcode: MUL_rr_32
      77             : /* 202 */     MCD::OPC_FilterValue, 45, 4, 0, 0, // Skip to: 211
      78             : /* 207 */     MCD::OPC_Decode, 169, 1, 9, // Opcode: JUGT_rr
      79             : /* 211 */     MCD::OPC_FilterValue, 47, 4, 0, 0, // Skip to: 220
      80             : /* 216 */     MCD::OPC_Decode, 199, 1, 4, // Opcode: MUL_rr
      81             : /* 220 */     MCD::OPC_FilterValue, 48, 4, 0, 0, // Skip to: 229
      82             : /* 225 */     MCD::OPC_Decode, 181, 1, 10, // Opcode: LD_ABS_B
      83             : /* 229 */     MCD::OPC_FilterValue, 52, 4, 0, 0, // Skip to: 238
      84             : /* 234 */     MCD::OPC_Decode, 147, 1, 0, // Opcode: DIV_ri_32
      85             : /* 238 */     MCD::OPC_FilterValue, 53, 4, 0, 0, // Skip to: 247
      86             : /* 243 */     MCD::OPC_Decode, 166, 1, 5, // Opcode: JUGE_ri
      87             : /* 247 */     MCD::OPC_FilterValue, 55, 4, 0, 0, // Skip to: 256
      88             : /* 252 */     MCD::OPC_Decode, 146, 1, 2, // Opcode: DIV_ri
      89             : /* 256 */     MCD::OPC_FilterValue, 60, 4, 0, 0, // Skip to: 265
      90             : /* 261 */     MCD::OPC_Decode, 149, 1, 3, // Opcode: DIV_rr_32
      91             : /* 265 */     MCD::OPC_FilterValue, 61, 4, 0, 0, // Skip to: 274
      92             : /* 270 */     MCD::OPC_Decode, 167, 1, 9, // Opcode: JUGE_rr
      93             : /* 274 */     MCD::OPC_FilterValue, 63, 4, 0, 0, // Skip to: 283
      94             : /* 279 */     MCD::OPC_Decode, 148, 1, 4, // Opcode: DIV_rr
      95             : /* 283 */     MCD::OPC_FilterValue, 64, 4, 0, 0, // Skip to: 292
      96             : /* 288 */     MCD::OPC_Decode, 186, 1, 11, // Opcode: LD_IND_W
      97             : /* 292 */     MCD::OPC_FilterValue, 68, 4, 0, 0, // Skip to: 301
      98             : /* 297 */     MCD::OPC_Decode, 205, 1, 0, // Opcode: OR_ri_32
      99             : /* 301 */     MCD::OPC_FilterValue, 71, 4, 0, 0, // Skip to: 310
     100             : /* 306 */     MCD::OPC_Decode, 204, 1, 2, // Opcode: OR_ri
     101             : /* 310 */     MCD::OPC_FilterValue, 72, 4, 0, 0, // Skip to: 319
     102             : /* 315 */     MCD::OPC_Decode, 185, 1, 11, // Opcode: LD_IND_H
     103             : /* 319 */     MCD::OPC_FilterValue, 76, 4, 0, 0, // Skip to: 328
     104             : /* 324 */     MCD::OPC_Decode, 207, 1, 3, // Opcode: OR_rr_32
     105             : /* 328 */     MCD::OPC_FilterValue, 79, 4, 0, 0, // Skip to: 337
     106             : /* 333 */     MCD::OPC_Decode, 206, 1, 4, // Opcode: OR_rr
     107             : /* 337 */     MCD::OPC_FilterValue, 80, 4, 0, 0, // Skip to: 346
     108             : /* 342 */     MCD::OPC_Decode, 184, 1, 11, // Opcode: LD_IND_B
     109             : /* 346 */     MCD::OPC_FilterValue, 84, 4, 0, 0, // Skip to: 355
     110             : /* 351 */     MCD::OPC_Decode, 140, 1, 0, // Opcode: AND_ri_32
     111             : /* 355 */     MCD::OPC_FilterValue, 85, 4, 0, 0, // Skip to: 364
     112             : /* 360 */     MCD::OPC_Decode, 156, 1, 5, // Opcode: JNE_ri
     113             : /* 364 */     MCD::OPC_FilterValue, 87, 4, 0, 0, // Skip to: 373
     114             : /* 369 */     MCD::OPC_Decode, 139, 1, 2, // Opcode: AND_ri
     115             : /* 373 */     MCD::OPC_FilterValue, 92, 4, 0, 0, // Skip to: 382
     116             : /* 378 */     MCD::OPC_Decode, 142, 1, 3, // Opcode: AND_rr_32
     117             : /* 382 */     MCD::OPC_FilterValue, 93, 4, 0, 0, // Skip to: 391
     118             : /* 387 */     MCD::OPC_Decode, 157, 1, 9, // Opcode: JNE_rr
     119             : /* 391 */     MCD::OPC_FilterValue, 95, 4, 0, 0, // Skip to: 400
     120             : /* 396 */     MCD::OPC_Decode, 141, 1, 4, // Opcode: AND_rr
     121             : /* 400 */     MCD::OPC_FilterValue, 97, 4, 0, 0, // Skip to: 409
     122             : /* 405 */     MCD::OPC_Decode, 179, 1, 12, // Opcode: LDW
     123             : /* 409 */     MCD::OPC_FilterValue, 99, 4, 0, 0, // Skip to: 418
     124             : /* 414 */     MCD::OPC_Decode, 226, 1, 13, // Opcode: STW
     125             : /* 418 */     MCD::OPC_FilterValue, 100, 4, 0, 0, // Skip to: 427
     126             : /* 423 */     MCD::OPC_Decode, 210, 1, 0, // Opcode: SLL_ri_32
     127             : /* 427 */     MCD::OPC_FilterValue, 101, 4, 0, 0, // Skip to: 436
     128             : /* 432 */     MCD::OPC_Decode, 160, 1, 5, // Opcode: JSGT_ri
     129             : /* 436 */     MCD::OPC_FilterValue, 103, 4, 0, 0, // Skip to: 445
     130             : /* 441 */     MCD::OPC_Decode, 209, 1, 2, // Opcode: SLL_ri
     131             : /* 445 */     MCD::OPC_FilterValue, 105, 4, 0, 0, // Skip to: 454
     132             : /* 450 */     MCD::OPC_Decode, 177, 1, 12, // Opcode: LDH
     133             : /* 454 */     MCD::OPC_FilterValue, 107, 4, 0, 0, // Skip to: 463
     134             : /* 459 */     MCD::OPC_Decode, 224, 1, 13, // Opcode: STH
     135             : /* 463 */     MCD::OPC_FilterValue, 108, 4, 0, 0, // Skip to: 472
     136             : /* 468 */     MCD::OPC_Decode, 212, 1, 3, // Opcode: SLL_rr_32
     137             : /* 472 */     MCD::OPC_FilterValue, 109, 4, 0, 0, // Skip to: 481
     138             : /* 477 */     MCD::OPC_Decode, 161, 1, 9, // Opcode: JSGT_rr
     139             : /* 481 */     MCD::OPC_FilterValue, 111, 4, 0, 0, // Skip to: 490
     140             : /* 486 */     MCD::OPC_Decode, 211, 1, 4, // Opcode: SLL_rr
     141             : /* 490 */     MCD::OPC_FilterValue, 113, 4, 0, 0, // Skip to: 499
     142             : /* 495 */     MCD::OPC_Decode, 174, 1, 12, // Opcode: LDB
     143             : /* 499 */     MCD::OPC_FilterValue, 115, 4, 0, 0, // Skip to: 508
     144             : /* 504 */     MCD::OPC_Decode, 221, 1, 13, // Opcode: STB
     145             : /* 508 */     MCD::OPC_FilterValue, 116, 4, 0, 0, // Skip to: 517
     146             : /* 513 */     MCD::OPC_Decode, 218, 1, 0, // Opcode: SRL_ri_32
     147             : /* 517 */     MCD::OPC_FilterValue, 117, 4, 0, 0, // Skip to: 526
     148             : /* 522 */     MCD::OPC_Decode, 158, 1, 5, // Opcode: JSGE_ri
     149             : /* 526 */     MCD::OPC_FilterValue, 119, 4, 0, 0, // Skip to: 535
     150             : /* 531 */     MCD::OPC_Decode, 217, 1, 2, // Opcode: SRL_ri
     151             : /* 535 */     MCD::OPC_FilterValue, 121, 4, 0, 0, // Skip to: 544
     152             : /* 540 */     MCD::OPC_Decode, 176, 1, 12, // Opcode: LDD
     153             : /* 544 */     MCD::OPC_FilterValue, 123, 4, 0, 0, // Skip to: 553
     154             : /* 549 */     MCD::OPC_Decode, 223, 1, 13, // Opcode: STD
     155             : /* 553 */     MCD::OPC_FilterValue, 124, 4, 0, 0, // Skip to: 562
     156             : /* 558 */     MCD::OPC_Decode, 220, 1, 3, // Opcode: SRL_rr_32
     157             : /* 562 */     MCD::OPC_FilterValue, 125, 4, 0, 0, // Skip to: 571
     158             : /* 567 */     MCD::OPC_Decode, 159, 1, 9, // Opcode: JSGE_rr
     159             : /* 571 */     MCD::OPC_FilterValue, 127, 4, 0, 0, // Skip to: 580
     160             : /* 576 */     MCD::OPC_Decode, 219, 1, 4, // Opcode: SRL_rr
     161             : /* 580 */     MCD::OPC_FilterValue, 132, 1, 4, 0, 0, // Skip to: 590
     162             : /* 586 */     MCD::OPC_Decode, 201, 1, 14, // Opcode: NEG_32
     163             : /* 590 */     MCD::OPC_FilterValue, 133, 1, 4, 0, 0, // Skip to: 600
     164             : /* 596 */     MCD::OPC_Decode, 151, 1, 10, // Opcode: JAL
     165             : /* 600 */     MCD::OPC_FilterValue, 135, 1, 4, 0, 0, // Skip to: 610
     166             : /* 606 */     MCD::OPC_Decode, 202, 1, 15, // Opcode: NEG_64
     167             : /* 610 */     MCD::OPC_FilterValue, 141, 1, 4, 0, 0, // Skip to: 620
     168             : /* 616 */     MCD::OPC_Decode, 152, 1, 10, // Opcode: JALX
     169             : /* 620 */     MCD::OPC_FilterValue, 149, 1, 11, 0, 0, // Skip to: 637
     170             : /* 626 */     MCD::OPC_CheckField, 0, 32, 0, 51, 1, 0, // Skip to: 940
     171             : /* 633 */     MCD::OPC_Decode, 208, 1, 6, // Opcode: RET
     172             : /* 637 */     MCD::OPC_FilterValue, 164, 1, 4, 0, 0, // Skip to: 647
     173             : /* 643 */     MCD::OPC_Decode, 235, 1, 0, // Opcode: XOR_ri_32
     174             : /* 647 */     MCD::OPC_FilterValue, 165, 1, 4, 0, 0, // Skip to: 657
     175             : /* 653 */     MCD::OPC_Decode, 172, 1, 5, // Opcode: JULT_ri
     176             : /* 657 */     MCD::OPC_FilterValue, 167, 1, 4, 0, 0, // Skip to: 667
     177             : /* 663 */     MCD::OPC_Decode, 234, 1, 2, // Opcode: XOR_ri
     178             : /* 667 */     MCD::OPC_FilterValue, 172, 1, 4, 0, 0, // Skip to: 677
     179             : /* 673 */     MCD::OPC_Decode, 237, 1, 3, // Opcode: XOR_rr_32
     180             : /* 677 */     MCD::OPC_FilterValue, 173, 1, 4, 0, 0, // Skip to: 687
     181             : /* 683 */     MCD::OPC_Decode, 173, 1, 9, // Opcode: JULT_rr
     182             : /* 687 */     MCD::OPC_FilterValue, 175, 1, 4, 0, 0, // Skip to: 697
     183             : /* 693 */     MCD::OPC_Decode, 236, 1, 4, // Opcode: XOR_rr
     184             : /* 697 */     MCD::OPC_FilterValue, 180, 1, 4, 0, 0, // Skip to: 707
     185             : /* 703 */     MCD::OPC_Decode, 194, 1, 16, // Opcode: MOV_ri_32
     186             : /* 707 */     MCD::OPC_FilterValue, 181, 1, 4, 0, 0, // Skip to: 717
     187             : /* 713 */     MCD::OPC_Decode, 170, 1, 5, // Opcode: JULE_ri
     188             : /* 717 */     MCD::OPC_FilterValue, 183, 1, 4, 0, 0, // Skip to: 727
     189             : /* 723 */     MCD::OPC_Decode, 193, 1, 7, // Opcode: MOV_ri
     190             : /* 727 */     MCD::OPC_FilterValue, 188, 1, 4, 0, 0, // Skip to: 737
     191             : /* 733 */     MCD::OPC_Decode, 196, 1, 17, // Opcode: MOV_rr_32
     192             : /* 737 */     MCD::OPC_FilterValue, 189, 1, 4, 0, 0, // Skip to: 747
     193             : /* 743 */     MCD::OPC_Decode, 171, 1, 9, // Opcode: JULE_rr
     194             : /* 747 */     MCD::OPC_FilterValue, 191, 1, 15, 0, 0, // Skip to: 768
     195             : /* 753 */     MCD::OPC_CheckField, 48, 8, 0, 4, 0, 0, // Skip to: 764
     196             : /* 760 */     MCD::OPC_Decode, 203, 1, 6, // Opcode: NOP
     197             : /* 764 */     MCD::OPC_Decode, 195, 1, 18, // Opcode: MOV_rr
     198             : /* 768 */     MCD::OPC_FilterValue, 195, 1, 4, 0, 0, // Skip to: 778
     199             : /* 774 */     MCD::OPC_Decode, 232, 1, 19, // Opcode: XADD32
     200             : /* 778 */     MCD::OPC_FilterValue, 196, 1, 4, 0, 0, // Skip to: 788
     201             : /* 784 */     MCD::OPC_Decode, 214, 1, 0, // Opcode: SRA_ri_32
     202             : /* 788 */     MCD::OPC_FilterValue, 197, 1, 4, 0, 0, // Skip to: 798
     203             : /* 794 */     MCD::OPC_Decode, 164, 1, 5, // Opcode: JSLT_ri
     204             : /* 798 */     MCD::OPC_FilterValue, 199, 1, 4, 0, 0, // Skip to: 808
     205             : /* 804 */     MCD::OPC_Decode, 213, 1, 2, // Opcode: SRA_ri
     206             : /* 808 */     MCD::OPC_FilterValue, 204, 1, 4, 0, 0, // Skip to: 818
     207             : /* 814 */     MCD::OPC_Decode, 216, 1, 3, // Opcode: SRA_rr_32
     208             : /* 818 */     MCD::OPC_FilterValue, 205, 1, 4, 0, 0, // Skip to: 828
     209             : /* 824 */     MCD::OPC_Decode, 165, 1, 9, // Opcode: JSLT_rr
     210             : /* 828 */     MCD::OPC_FilterValue, 207, 1, 4, 0, 0, // Skip to: 838
     211             : /* 834 */     MCD::OPC_Decode, 215, 1, 4, // Opcode: SRA_rr
     212             : /* 838 */     MCD::OPC_FilterValue, 212, 1, 30, 0, 0, // Skip to: 874
     213             : /* 844 */     MCD::OPC_ExtractField, 0, 32,  // Inst{31-0} ...
     214             : /* 847 */     MCD::OPC_FilterValue, 16, 4, 0, 0, // Skip to: 856
     215             : /* 852 */     MCD::OPC_Decode, 189, 1, 15, // Opcode: LE16
     216             : /* 856 */     MCD::OPC_FilterValue, 32, 4, 0, 0, // Skip to: 865
     217             : /* 861 */     MCD::OPC_Decode, 190, 1, 15, // Opcode: LE32
     218             : /* 865 */     MCD::OPC_FilterValue, 64, 70, 0, 0, // Skip to: 940
     219             : /* 870 */     MCD::OPC_Decode, 191, 1, 15, // Opcode: LE64
     220             : /* 874 */     MCD::OPC_FilterValue, 213, 1, 4, 0, 0, // Skip to: 884
     221             : /* 880 */     MCD::OPC_Decode, 162, 1, 5, // Opcode: JSLE_ri
     222             : /* 884 */     MCD::OPC_FilterValue, 219, 1, 4, 0, 0, // Skip to: 894
     223             : /* 890 */     MCD::OPC_Decode, 233, 1, 19, // Opcode: XADD64
     224             : /* 894 */     MCD::OPC_FilterValue, 220, 1, 30, 0, 0, // Skip to: 930
     225             : /* 900 */     MCD::OPC_ExtractField, 0, 32,  // Inst{31-0} ...
     226             : /* 903 */     MCD::OPC_FilterValue, 16, 4, 0, 0, // Skip to: 912
     227             : /* 908 */     MCD::OPC_Decode, 143, 1, 15, // Opcode: BE16
     228             : /* 912 */     MCD::OPC_FilterValue, 32, 4, 0, 0, // Skip to: 921
     229             : /* 917 */     MCD::OPC_Decode, 144, 1, 15, // Opcode: BE32
     230             : /* 921 */     MCD::OPC_FilterValue, 64, 14, 0, 0, // Skip to: 940
     231             : /* 926 */     MCD::OPC_Decode, 145, 1, 15, // Opcode: BE64
     232             : /* 930 */     MCD::OPC_FilterValue, 221, 1, 4, 0, 0, // Skip to: 940
     233             : /* 936 */     MCD::OPC_Decode, 163, 1, 9, // Opcode: JSLE_rr
     234             : /* 940 */     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, 0, // Skip to: 12
     241             : /* 8 */       MCD::OPC_Decode, 180, 1, 20, // Opcode: LDW32
     242             : /* 12 */      MCD::OPC_FilterValue, 99, 4, 0, 0, // Skip to: 21
     243             : /* 17 */      MCD::OPC_Decode, 227, 1, 21, // Opcode: STW32
     244             : /* 21 */      MCD::OPC_FilterValue, 105, 4, 0, 0, // Skip to: 30
     245             : /* 26 */      MCD::OPC_Decode, 178, 1, 20, // Opcode: LDH32
     246             : /* 30 */      MCD::OPC_FilterValue, 107, 4, 0, 0, // Skip to: 39
     247             : /* 35 */      MCD::OPC_Decode, 225, 1, 21, // Opcode: STH32
     248             : /* 39 */      MCD::OPC_FilterValue, 113, 4, 0, 0, // Skip to: 48
     249             : /* 44 */      MCD::OPC_Decode, 175, 1, 20, // Opcode: LDB32
     250             : /* 48 */      MCD::OPC_FilterValue, 115, 4, 0, 0, // Skip to: 57
     251             : /* 53 */      MCD::OPC_Decode, 222, 1, 21, // Opcode: STB32
     252             : /* 57 */      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 24-bit integer.
     443       18018 :       unsigned NumToSkip = *Ptr++;
     444       18018 :       NumToSkip |= (*Ptr++) << 8;
     445       18018 :       NumToSkip |= (*Ptr++) << 16;
     446             : 
     447             :       // Perform the filter operation.
     448       18018 :       if (Val != CurFieldValue)
     449       17594 :         Ptr += NumToSkip;
     450             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_FilterValue(" << Val << ", " << NumToSkip
     451             :                    << "): " << ((Val != CurFieldValue) ? "FAIL:" : "PASS:")
     452             :                    << " continuing at " << (Ptr - DecodeTable) << "\n");
     453             : 
     454             :       break;
     455             :     }
     456         108 :     case MCD::OPC_CheckField: {
     457         108 :       unsigned Start = *++Ptr;
     458         108 :       unsigned Len = *++Ptr;
     459             :       InsnType FieldValue = fieldFromInstruction(insn, Start, Len);
     460             :       // Decode the field value.
     461         108 :       uint32_t ExpectedValue = decodeULEB128(++Ptr, &Len);
     462         108 :       Ptr += Len;
     463             :       // NumToSkip is a plain 24-bit integer.
     464         108 :       unsigned NumToSkip = *Ptr++;
     465         108 :       NumToSkip |= (*Ptr++) << 8;
     466         108 :       NumToSkip |= (*Ptr++) << 16;
     467             : 
     468             :       // If the actual and expected values don't match, skip.
     469         108 :       if (ExpectedValue != FieldValue)
     470          67 :         Ptr += NumToSkip;
     471             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckField(" << Start << ", "
     472             :                    << Len << ", " << ExpectedValue << ", " << NumToSkip
     473             :                    << "): FieldValue = " << FieldValue << ", ExpectedValue = "
     474             :                    << ExpectedValue << ": "
     475             :                    << ((ExpectedValue == FieldValue) ? "PASS\n" : "FAIL\n"));
     476             :       break;
     477             :     }
     478           0 :     case MCD::OPC_CheckPredicate: {
     479             :       unsigned Len;
     480             :       // Decode the Predicate Index value.
     481           0 :       unsigned PIdx = decodeULEB128(++Ptr, &Len);
     482             :       Ptr += Len;
     483             :       // NumToSkip is a plain 24-bit integer.
     484             :       unsigned NumToSkip = *Ptr++;
     485             :       NumToSkip |= (*Ptr++) << 8;
     486             :       NumToSkip |= (*Ptr++) << 16;
     487             :       // Check the predicate.
     488             :       bool Pred;
     489             :       if (!(Pred = checkDecoderPredicate(PIdx, Bits)))
     490             :         Ptr += NumToSkip;
     491             :       (void)Pred;
     492             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckPredicate(" << PIdx << "): "
     493             :             << (Pred ? "PASS\n" : "FAIL\n"));
     494             : 
     495             :       break;
     496             :     }
     497         389 :     case MCD::OPC_Decode: {
     498             :       unsigned Len;
     499             :       // Decode the Opcode value.
     500         389 :       unsigned Opc = decodeULEB128(++Ptr, &Len);
     501         389 :       Ptr += Len;
     502         389 :       unsigned DecodeIdx = decodeULEB128(Ptr, &Len);
     503             :       Ptr += Len;
     504             : 
     505             :       MI.clear();
     506             :       MI.setOpcode(Opc);
     507             :       bool DecodeComplete;
     508         389 :       S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete);
     509             :       assert(DecodeComplete);
     510             : 
     511             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_Decode: opcode " << Opc
     512             :                    << ", using decoder " << DecodeIdx << ": "
     513             :                    << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
     514             :       return S;
     515             :     }
     516           0 :     case MCD::OPC_TryDecode: {
     517             :       unsigned Len;
     518             :       // Decode the Opcode value.
     519           0 :       unsigned Opc = decodeULEB128(++Ptr, &Len);
     520           0 :       Ptr += Len;
     521           0 :       unsigned DecodeIdx = decodeULEB128(Ptr, &Len);
     522           0 :       Ptr += Len;
     523             :       // NumToSkip is a plain 24-bit integer.
     524           0 :       unsigned NumToSkip = *Ptr++;
     525           0 :       NumToSkip |= (*Ptr++) << 8;
     526           0 :       NumToSkip |= (*Ptr++) << 16;
     527             : 
     528             :       // Perform the decode operation.
     529             :       MCInst TmpMI;
     530             :       TmpMI.setOpcode(Opc);
     531             :       bool DecodeComplete;
     532           0 :       S = decodeToMCInst(S, DecodeIdx, insn, TmpMI, Address, DisAsm, DecodeComplete);
     533             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_TryDecode: opcode " << Opc
     534             :                    << ", using decoder " << DecodeIdx << ": ");
     535             : 
     536           0 :       if (DecodeComplete) {
     537             :         // Decoding complete.
     538             :         LLVM_DEBUG(dbgs() << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
     539             :         MI = TmpMI;
     540             :         return S;
     541             :       } else {
     542             :         assert(S == MCDisassembler::Fail);
     543             :         // If the decoding was incomplete, skip.
     544           0 :         Ptr += NumToSkip;
     545             :         LLVM_DEBUG(dbgs() << "FAIL: continuing at " << (Ptr - DecodeTable) << "\n");
     546             :         // Reset decode status. This also drops a SoftFail status that could be
     547             :         // set before the decode attempt.
     548             :         S = MCDisassembler::Success;
     549             :       }
     550             :       break;
     551             :     }
     552           0 :     case MCD::OPC_SoftFail: {
     553             :       // Decode the mask values.
     554             :       unsigned Len;
     555           0 :       InsnType PositiveMask = decodeULEB128(++Ptr, &Len);
     556           0 :       Ptr += Len;
     557           0 :       InsnType NegativeMask = decodeULEB128(Ptr, &Len);
     558           0 :       Ptr += Len;
     559           0 :       bool Fail = (insn & PositiveMask) || (~insn & NegativeMask);
     560             :       if (Fail)
     561             :         S = MCDisassembler::SoftFail;
     562             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_SoftFail: " << (Fail ? "FAIL\n":"PASS\n"));
     563             :       break;
     564             :     }
     565             :     case MCD::OPC_Fail: {
     566             :       LLVM_DEBUG(dbgs() << Loc << ": OPC_Fail\n");
     567             :       return MCDisassembler::Fail;
     568             :     }
     569             :     }
     570             :   }
     571             :   llvm_unreachable("bogosity detected in disassembler state machine!");
     572             : }
     573             : 
     574             : 
     575             : } // End llvm namespace

Generated by: LCOV version 1.13