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: 117 149 78.5 %
Date: 2017-09-14 15:23:50 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         184 :     if (numBits == sizeof(InsnType)*8)
      26             :       fieldMask = (InsnType)(-1LL);
      27             :     else
      28         480 :       fieldMask = (((InsnType)1 << numBits) - 1) << startBit;
      29         429 :     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, 5, 3, 0, // Skip to: 10
      35             : /* 7 */       MCD::OPC_Decode, 119, 0, // Opcode: JMP
      36             : /* 10 */      MCD::OPC_FilterValue, 7, 3, 0, // Skip to: 17
      37             : /* 14 */      MCD::OPC_Decode, 104, 1, // Opcode: ADD_ri
      38             : /* 17 */      MCD::OPC_FilterValue, 15, 3, 0, // Skip to: 24
      39             : /* 21 */      MCD::OPC_Decode, 105, 2, // Opcode: ADD_rr
      40             : /* 24 */      MCD::OPC_FilterValue, 21, 3, 0, // Skip to: 31
      41             : /* 28 */      MCD::OPC_Decode, 117, 3, // Opcode: JEQ_ri
      42             : /* 31 */      MCD::OPC_FilterValue, 23, 4, 0, // Skip to: 39
      43             : /* 35 */      MCD::OPC_Decode, 168, 1, 1, // Opcode: SUB_ri
      44             : /* 39 */      MCD::OPC_FilterValue, 24, 36, 0, // Skip to: 79
      45             : /* 43 */      MCD::OPC_ExtractField, 32, 16,  // Inst{47-32} ...
      46             : /* 46 */      MCD::OPC_FilterValue, 0, 14, 2, // Skip to: 576
      47             : /* 50 */      MCD::OPC_CheckField, 48, 8, 32, 9, 0, // Skip to: 65
      48             : /* 56 */      MCD::OPC_CheckField, 0, 32, 0, 3, 0, // Skip to: 65
      49             : /* 62 */      MCD::OPC_Decode, 115, 4, // Opcode: FI_ri
      50             : /* 65 */      MCD::OPC_CheckField, 52, 4, 0, 4, 0, // Skip to: 75
      51             : /* 71 */      MCD::OPC_Decode, 148, 1, 5, // Opcode: LD_imm64
      52             : /* 75 */      MCD::OPC_Decode, 149, 1, 6, // Opcode: LD_pseudo
      53             : /* 79 */      MCD::OPC_FilterValue, 29, 3, 0, // Skip to: 86
      54             : /* 83 */      MCD::OPC_Decode, 118, 7, // Opcode: JEQ_rr
      55             : /* 86 */      MCD::OPC_FilterValue, 31, 4, 0, // Skip to: 94
      56             : /* 90 */      MCD::OPC_Decode, 169, 1, 2, // Opcode: SUB_rr
      57             : /* 94 */      MCD::OPC_FilterValue, 32, 4, 0, // Skip to: 102
      58             : /* 98 */      MCD::OPC_Decode, 144, 1, 8, // Opcode: LD_ABS_W
      59             : /* 102 */     MCD::OPC_FilterValue, 37, 4, 0, // Skip to: 110
      60             : /* 106 */     MCD::OPC_Decode, 132, 1, 3, // Opcode: JUGT_ri
      61             : /* 110 */     MCD::OPC_FilterValue, 39, 4, 0, // Skip to: 118
      62             : /* 114 */     MCD::OPC_Decode, 152, 1, 1, // Opcode: MUL_ri
      63             : /* 118 */     MCD::OPC_FilterValue, 40, 4, 0, // Skip to: 126
      64             : /* 122 */     MCD::OPC_Decode, 143, 1, 8, // Opcode: LD_ABS_H
      65             : /* 126 */     MCD::OPC_FilterValue, 45, 4, 0, // Skip to: 134
      66             : /* 130 */     MCD::OPC_Decode, 133, 1, 7, // Opcode: JUGT_rr
      67             : /* 134 */     MCD::OPC_FilterValue, 47, 4, 0, // Skip to: 142
      68             : /* 138 */     MCD::OPC_Decode, 153, 1, 2, // Opcode: MUL_rr
      69             : /* 142 */     MCD::OPC_FilterValue, 48, 4, 0, // Skip to: 150
      70             : /* 146 */     MCD::OPC_Decode, 142, 1, 8, // Opcode: LD_ABS_B
      71             : /* 150 */     MCD::OPC_FilterValue, 53, 4, 0, // Skip to: 158
      72             : /* 154 */     MCD::OPC_Decode, 130, 1, 3, // Opcode: JUGE_ri
      73             : /* 158 */     MCD::OPC_FilterValue, 55, 3, 0, // Skip to: 165
      74             : /* 162 */     MCD::OPC_Decode, 113, 1, // Opcode: DIV_ri
      75             : /* 165 */     MCD::OPC_FilterValue, 61, 4, 0, // Skip to: 173
      76             : /* 169 */     MCD::OPC_Decode, 131, 1, 7, // Opcode: JUGE_rr
      77             : /* 173 */     MCD::OPC_FilterValue, 63, 3, 0, // Skip to: 180
      78             : /* 177 */     MCD::OPC_Decode, 114, 2, // Opcode: DIV_rr
      79             : /* 180 */     MCD::OPC_FilterValue, 64, 4, 0, // Skip to: 188
      80             : /* 184 */     MCD::OPC_Decode, 147, 1, 9, // Opcode: LD_IND_W
      81             : /* 188 */     MCD::OPC_FilterValue, 71, 4, 0, // Skip to: 196
      82             : /* 192 */     MCD::OPC_Decode, 155, 1, 1, // Opcode: OR_ri
      83             : /* 196 */     MCD::OPC_FilterValue, 72, 4, 0, // Skip to: 204
      84             : /* 200 */     MCD::OPC_Decode, 146, 1, 9, // Opcode: LD_IND_H
      85             : /* 204 */     MCD::OPC_FilterValue, 79, 4, 0, // Skip to: 212
      86             : /* 208 */     MCD::OPC_Decode, 156, 1, 2, // Opcode: OR_rr
      87             : /* 212 */     MCD::OPC_FilterValue, 80, 4, 0, // Skip to: 220
      88             : /* 216 */     MCD::OPC_Decode, 145, 1, 9, // Opcode: LD_IND_B
      89             : /* 220 */     MCD::OPC_FilterValue, 85, 3, 0, // Skip to: 227
      90             : /* 224 */     MCD::OPC_Decode, 120, 3, // Opcode: JNE_ri
      91             : /* 227 */     MCD::OPC_FilterValue, 87, 3, 0, // Skip to: 234
      92             : /* 231 */     MCD::OPC_Decode, 108, 1, // Opcode: AND_ri
      93             : /* 234 */     MCD::OPC_FilterValue, 93, 3, 0, // Skip to: 241
      94             : /* 238 */     MCD::OPC_Decode, 121, 7, // Opcode: JNE_rr
      95             : /* 241 */     MCD::OPC_FilterValue, 95, 3, 0, // Skip to: 248
      96             : /* 245 */     MCD::OPC_Decode, 109, 2, // Opcode: AND_rr
      97             : /* 248 */     MCD::OPC_FilterValue, 97, 4, 0, // Skip to: 256
      98             : /* 252 */     MCD::OPC_Decode, 141, 1, 10, // Opcode: LDW
      99             : /* 256 */     MCD::OPC_FilterValue, 99, 4, 0, // Skip to: 264
     100             : /* 260 */     MCD::OPC_Decode, 167, 1, 11, // Opcode: STW
     101             : /* 264 */     MCD::OPC_FilterValue, 101, 3, 0, // Skip to: 271
     102             : /* 268 */     MCD::OPC_Decode, 124, 3, // Opcode: JSGT_ri
     103             : /* 271 */     MCD::OPC_FilterValue, 103, 4, 0, // Skip to: 279
     104             : /* 275 */     MCD::OPC_Decode, 158, 1, 1, // Opcode: SLL_ri
     105             : /* 279 */     MCD::OPC_FilterValue, 105, 4, 0, // Skip to: 287
     106             : /* 283 */     MCD::OPC_Decode, 140, 1, 10, // Opcode: LDH
     107             : /* 287 */     MCD::OPC_FilterValue, 107, 4, 0, // Skip to: 295
     108             : /* 291 */     MCD::OPC_Decode, 166, 1, 11, // Opcode: STH
     109             : /* 295 */     MCD::OPC_FilterValue, 109, 3, 0, // Skip to: 302
     110             : /* 299 */     MCD::OPC_Decode, 125, 7, // Opcode: JSGT_rr
     111             : /* 302 */     MCD::OPC_FilterValue, 111, 4, 0, // Skip to: 310
     112             : /* 306 */     MCD::OPC_Decode, 159, 1, 2, // Opcode: SLL_rr
     113             : /* 310 */     MCD::OPC_FilterValue, 113, 4, 0, // Skip to: 318
     114             : /* 314 */     MCD::OPC_Decode, 138, 1, 10, // Opcode: LDB
     115             : /* 318 */     MCD::OPC_FilterValue, 115, 4, 0, // Skip to: 326
     116             : /* 322 */     MCD::OPC_Decode, 164, 1, 11, // Opcode: STB
     117             : /* 326 */     MCD::OPC_FilterValue, 117, 3, 0, // Skip to: 333
     118             : /* 330 */     MCD::OPC_Decode, 122, 3, // Opcode: JSGE_ri
     119             : /* 333 */     MCD::OPC_FilterValue, 119, 4, 0, // Skip to: 341
     120             : /* 337 */     MCD::OPC_Decode, 162, 1, 1, // Opcode: SRL_ri
     121             : /* 341 */     MCD::OPC_FilterValue, 121, 4, 0, // Skip to: 349
     122             : /* 345 */     MCD::OPC_Decode, 139, 1, 10, // Opcode: LDD
     123             : /* 349 */     MCD::OPC_FilterValue, 123, 4, 0, // Skip to: 357
     124             : /* 353 */     MCD::OPC_Decode, 165, 1, 11, // Opcode: STD
     125             : /* 357 */     MCD::OPC_FilterValue, 125, 3, 0, // Skip to: 364
     126             : /* 361 */     MCD::OPC_Decode, 123, 7, // Opcode: JSGE_rr
     127             : /* 364 */     MCD::OPC_FilterValue, 127, 4, 0, // Skip to: 372
     128             : /* 368 */     MCD::OPC_Decode, 163, 1, 2, // Opcode: SRL_rr
     129             : /* 372 */     MCD::OPC_FilterValue, 133, 1, 3, 0, // Skip to: 380
     130             : /* 377 */     MCD::OPC_Decode, 116, 8, // Opcode: JAL
     131             : /* 380 */     MCD::OPC_FilterValue, 149, 1, 10, 0, // Skip to: 395
     132             : /* 385 */     MCD::OPC_CheckField, 0, 32, 0, 185, 0, // Skip to: 576
     133             : /* 391 */     MCD::OPC_Decode, 157, 1, 4, // Opcode: RET
     134             : /* 395 */     MCD::OPC_FilterValue, 165, 1, 4, 0, // Skip to: 404
     135             : /* 400 */     MCD::OPC_Decode, 136, 1, 3, // Opcode: JULT_ri
     136             : /* 404 */     MCD::OPC_FilterValue, 167, 1, 4, 0, // Skip to: 413
     137             : /* 409 */     MCD::OPC_Decode, 174, 1, 1, // Opcode: XOR_ri
     138             : /* 413 */     MCD::OPC_FilterValue, 173, 1, 4, 0, // Skip to: 422
     139             : /* 418 */     MCD::OPC_Decode, 137, 1, 7, // Opcode: JULT_rr
     140             : /* 422 */     MCD::OPC_FilterValue, 175, 1, 4, 0, // Skip to: 431
     141             : /* 427 */     MCD::OPC_Decode, 175, 1, 2, // Opcode: XOR_rr
     142             : /* 431 */     MCD::OPC_FilterValue, 181, 1, 4, 0, // Skip to: 440
     143             : /* 436 */     MCD::OPC_Decode, 134, 1, 3, // Opcode: JULE_ri
     144             : /* 440 */     MCD::OPC_FilterValue, 183, 1, 4, 0, // Skip to: 449
     145             : /* 445 */     MCD::OPC_Decode, 150, 1, 5, // Opcode: MOV_ri
     146             : /* 449 */     MCD::OPC_FilterValue, 189, 1, 4, 0, // Skip to: 458
     147             : /* 454 */     MCD::OPC_Decode, 135, 1, 7, // Opcode: JULE_rr
     148             : /* 458 */     MCD::OPC_FilterValue, 191, 1, 14, 0, // Skip to: 477
     149             : /* 463 */     MCD::OPC_CheckField, 48, 8, 0, 4, 0, // Skip to: 473
     150             : /* 469 */     MCD::OPC_Decode, 154, 1, 4, // Opcode: NOP
     151             : /* 473 */     MCD::OPC_Decode, 151, 1, 12, // Opcode: MOV_rr
     152             : /* 477 */     MCD::OPC_FilterValue, 195, 1, 4, 0, // Skip to: 486
     153             : /* 482 */     MCD::OPC_Decode, 172, 1, 13, // Opcode: XADD32
     154             : /* 486 */     MCD::OPC_FilterValue, 197, 1, 4, 0, // Skip to: 495
     155             : /* 491 */     MCD::OPC_Decode, 128, 1, 3, // Opcode: JSLT_ri
     156             : /* 495 */     MCD::OPC_FilterValue, 199, 1, 4, 0, // Skip to: 504
     157             : /* 500 */     MCD::OPC_Decode, 160, 1, 1, // Opcode: SRA_ri
     158             : /* 504 */     MCD::OPC_FilterValue, 205, 1, 4, 0, // Skip to: 513
     159             : /* 509 */     MCD::OPC_Decode, 129, 1, 7, // Opcode: JSLT_rr
     160             : /* 513 */     MCD::OPC_FilterValue, 207, 1, 4, 0, // Skip to: 522
     161             : /* 518 */     MCD::OPC_Decode, 161, 1, 2, // Opcode: SRA_rr
     162             : /* 522 */     MCD::OPC_FilterValue, 213, 1, 3, 0, // Skip to: 530
     163             : /* 527 */     MCD::OPC_Decode, 126, 3, // Opcode: JSLE_ri
     164             : /* 530 */     MCD::OPC_FilterValue, 219, 1, 4, 0, // Skip to: 539
     165             : /* 535 */     MCD::OPC_Decode, 173, 1, 13, // Opcode: XADD64
     166             : /* 539 */     MCD::OPC_FilterValue, 220, 1, 24, 0, // Skip to: 568
     167             : /* 544 */     MCD::OPC_ExtractField, 0, 32,  // Inst{31-0} ...
     168             : /* 547 */     MCD::OPC_FilterValue, 16, 3, 0, // Skip to: 554
     169             : /* 551 */     MCD::OPC_Decode, 110, 14, // Opcode: BSWAP16
     170             : /* 554 */     MCD::OPC_FilterValue, 32, 3, 0, // Skip to: 561
     171             : /* 558 */     MCD::OPC_Decode, 111, 14, // Opcode: BSWAP32
     172             : /* 561 */     MCD::OPC_FilterValue, 64, 11, 0, // Skip to: 576
     173             : /* 565 */     MCD::OPC_Decode, 112, 14, // Opcode: BSWAP64
     174             : /* 568 */     MCD::OPC_FilterValue, 221, 1, 3, 0, // Skip to: 576
     175             : /* 573 */     MCD::OPC_Decode, 127, 7, // Opcode: JSLE_rr
     176             : /* 576 */     MCD::OPC_Fail,
     177             :   0
     178             : };
     179             : 
     180             : static bool checkDecoderPredicate(unsigned Idx, const FeatureBitset& Bits) {
     181           0 :   llvm_unreachable("Invalid index!");
     182             : }
     183             : 
     184             : template<typename InsnType>
     185         133 : static DecodeStatus decodeToMCInst(DecodeStatus S, unsigned Idx, InsnType insn, MCInst &MI,
     186             :                                    uint64_t Address, const void *Decoder, bool &DecodeComplete) {
     187         133 :   DecodeComplete = true;
     188             :   InsnType tmp;
     189         133 :   switch (Idx) {
     190           0 :   default: llvm_unreachable("Invalid index!");
     191           1 :   case 0:
     192           1 :     tmp = fieldFromInstruction(insn, 32, 16);
     193           3 :     MI.addOperand(MCOperand::createImm(tmp));
     194             :     return S;
     195          16 :   case 1:
     196          16 :     tmp = fieldFromInstruction(insn, 48, 4);
     197          16 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     198          16 :     tmp = fieldFromInstruction(insn, 48, 4);
     199          16 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     200          16 :     tmp = fieldFromInstruction(insn, 0, 32);
     201          48 :     MI.addOperand(MCOperand::createImm(tmp));
     202             :     return S;
     203          18 :   case 2:
     204          18 :     tmp = fieldFromInstruction(insn, 48, 4);
     205          18 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     206          18 :     tmp = fieldFromInstruction(insn, 48, 4);
     207          18 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     208          18 :     tmp = fieldFromInstruction(insn, 52, 4);
     209          18 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     210             :     return S;
     211          10 :   case 3:
     212          10 :     tmp = fieldFromInstruction(insn, 48, 4);
     213          10 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     214          10 :     tmp = fieldFromInstruction(insn, 0, 32);
     215          30 :     MI.addOperand(MCOperand::createImm(tmp));
     216          10 :     tmp = fieldFromInstruction(insn, 32, 16);
     217          30 :     MI.addOperand(MCOperand::createImm(tmp));
     218             :     return S;
     219             :   case 4:
     220             :     return S;
     221           9 :   case 5:
     222           9 :     tmp = fieldFromInstruction(insn, 48, 4);
     223           9 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     224           9 :     tmp = fieldFromInstruction(insn, 0, 32);
     225          27 :     MI.addOperand(MCOperand::createImm(tmp));
     226             :     return S;
     227           1 :   case 6:
     228           1 :     tmp = fieldFromInstruction(insn, 48, 4);
     229           1 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     230           1 :     tmp = fieldFromInstruction(insn, 52, 4);
     231           3 :     MI.addOperand(MCOperand::createImm(tmp));
     232           1 :     tmp = fieldFromInstruction(insn, 0, 32);
     233           3 :     MI.addOperand(MCOperand::createImm(tmp));
     234             :     return S;
     235          11 :   case 7:
     236          11 :     tmp = fieldFromInstruction(insn, 48, 4);
     237          11 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     238          11 :     tmp = fieldFromInstruction(insn, 52, 4);
     239          11 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     240          11 :     tmp = fieldFromInstruction(insn, 32, 16);
     241          33 :     MI.addOperand(MCOperand::createImm(tmp));
     242             :     return S;
     243          10 :   case 8:
     244          10 :     tmp = fieldFromInstruction(insn, 0, 32);
     245          30 :     MI.addOperand(MCOperand::createImm(tmp));
     246             :     return S;
     247           6 :   case 9:
     248           6 :     tmp = fieldFromInstruction(insn, 52, 4);
     249           6 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     250             :     return S;
     251           7 :   case 10:
     252           7 :     tmp = fieldFromInstruction(insn, 48, 4);
     253           7 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     254           7 :     tmp = 0;
     255           7 :     tmp |= fieldFromInstruction(insn, 32, 16) << 0;
     256           7 :     tmp |= fieldFromInstruction(insn, 52, 4) << 16;
     257           7 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     258             :     return S;
     259           5 :   case 11:
     260           5 :     tmp = fieldFromInstruction(insn, 52, 4);
     261           5 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     262           5 :     tmp = fieldFromInstruction(insn, 32, 20);
     263           5 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     264             :     return S;
     265          19 :   case 12:
     266          19 :     tmp = fieldFromInstruction(insn, 48, 4);
     267          19 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     268          19 :     tmp = fieldFromInstruction(insn, 52, 4);
     269          19 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     270             :     return S;
     271           4 :   case 13:
     272           4 :     tmp = fieldFromInstruction(insn, 52, 4);
     273           4 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     274           4 :     tmp = fieldFromInstruction(insn, 32, 20);
     275           4 :     if (decodeMemoryOpValue(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     276           4 :     tmp = fieldFromInstruction(insn, 52, 4);
     277           4 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     278             :     return S;
     279           6 :   case 14:
     280           6 :     tmp = fieldFromInstruction(insn, 48, 4);
     281           6 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     282           6 :     tmp = fieldFromInstruction(insn, 48, 4);
     283           6 :     if (DecodeGPRRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
     284             :     return S;
     285             :   }
     286             : }
     287             : 
     288             : template<typename InsnType>
     289         134 : static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
     290             :                                       InsnType insn, uint64_t Address,
     291             :                                       const void *DisAsm,
     292             :                                       const MCSubtargetInfo &STI) {
     293             :   const FeatureBitset& Bits = STI.getFeatureBits();
     294             : 
     295             :   const uint8_t *Ptr = DecodeTable;
     296             :   uint32_t CurFieldValue = 0;
     297             :   DecodeStatus S = MCDisassembler::Success;
     298             :   while (true) {
     299        5186 :     ptrdiff_t Loc = Ptr - DecodeTable;
     300        5186 :     switch (*Ptr) {
     301           0 :     default:
     302           0 :       errs() << Loc << ": Unexpected decode table opcode!\n";
     303             :       return MCDisassembler::Fail;
     304         145 :     case MCD::OPC_ExtractField: {
     305         145 :       unsigned Start = *++Ptr;
     306         145 :       unsigned Len = *++Ptr;
     307         145 :       ++Ptr;
     308         145 :       CurFieldValue = fieldFromInstruction(insn, Start, Len);
     309             :       DEBUG(dbgs() << Loc << ": OPC_ExtractField(" << Start << ", "
     310             :                    << Len << "): " << CurFieldValue << "\n");
     311             :       break;
     312             :     }
     313        4868 :     case MCD::OPC_FilterValue: {
     314             :       // Decode the field value.
     315             :       unsigned Len;
     316        4868 :       InsnType Val = decodeULEB128(++Ptr, &Len);
     317        4868 :       Ptr += Len;
     318             :       // NumToSkip is a plain 16-bit integer.
     319        4868 :       unsigned NumToSkip = *Ptr++;
     320        4868 :       NumToSkip |= (*Ptr++) << 8;
     321             : 
     322             :       // Perform the filter operation.
     323        4868 :       if (Val != CurFieldValue)
     324        4724 :         Ptr += NumToSkip;
     325             :       DEBUG(dbgs() << Loc << ": OPC_FilterValue(" << Val << ", " << NumToSkip
     326             :                    << "): " << ((Val != CurFieldValue) ? "FAIL:" : "PASS:")
     327             :                    << " continuing at " << (Ptr - DecodeTable) << "\n");
     328             : 
     329             :       break;
     330             :     }
     331          39 :     case MCD::OPC_CheckField: {
     332          39 :       unsigned Start = *++Ptr;
     333          39 :       unsigned Len = *++Ptr;
     334          78 :       InsnType FieldValue = fieldFromInstruction(insn, Start, Len);
     335             :       // Decode the field value.
     336          39 :       uint32_t ExpectedValue = decodeULEB128(++Ptr, &Len);
     337          39 :       Ptr += Len;
     338             :       // NumToSkip is a plain 16-bit integer.
     339          39 :       unsigned NumToSkip = *Ptr++;
     340          39 :       NumToSkip |= (*Ptr++) << 8;
     341             : 
     342             :       // If the actual and expected values don't match, skip.
     343          39 :       if (ExpectedValue != FieldValue)
     344          25 :         Ptr += NumToSkip;
     345             :       DEBUG(dbgs() << Loc << ": OPC_CheckField(" << Start << ", "
     346             :                    << Len << ", " << ExpectedValue << ", " << NumToSkip
     347             :                    << "): FieldValue = " << FieldValue << ", ExpectedValue = "
     348             :                    << ExpectedValue << ": "
     349             :                    << ((ExpectedValue == FieldValue) ? "PASS\n" : "FAIL\n"));
     350             :       break;
     351             :     }
     352           0 :     case MCD::OPC_CheckPredicate: {
     353             :       unsigned Len;
     354             :       // Decode the Predicate Index value.
     355           0 :       unsigned PIdx = decodeULEB128(++Ptr, &Len);
     356           0 :       Ptr += Len;
     357             :       // NumToSkip is a plain 16-bit integer.
     358           0 :       unsigned NumToSkip = *Ptr++;
     359           0 :       NumToSkip |= (*Ptr++) << 8;
     360             :       // Check the predicate.
     361             :       bool Pred;
     362           0 :       if (!(Pred = checkDecoderPredicate(PIdx, Bits)))
     363             :         Ptr += NumToSkip;
     364             :       (void)Pred;
     365             :       DEBUG(dbgs() << Loc << ": OPC_CheckPredicate(" << PIdx << "): "
     366             :             << (Pred ? "PASS\n" : "FAIL\n"));
     367             : 
     368             :       break;
     369             :     }
     370         133 :     case MCD::OPC_Decode: {
     371             :       unsigned Len;
     372             :       // Decode the Opcode value.
     373         133 :       unsigned Opc = decodeULEB128(++Ptr, &Len);
     374         133 :       Ptr += Len;
     375         133 :       unsigned DecodeIdx = decodeULEB128(Ptr, &Len);
     376         133 :       Ptr += Len;
     377             : 
     378         133 :       MI.clear();
     379         266 :       MI.setOpcode(Opc);
     380             :       bool DecodeComplete;
     381         133 :       S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete);
     382             :       assert(DecodeComplete);
     383             : 
     384             :       DEBUG(dbgs() << Loc << ": OPC_Decode: opcode " << Opc
     385             :                    << ", using decoder " << DecodeIdx << ": "
     386             :                    << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
     387             :       return S;
     388             :     }
     389           0 :     case MCD::OPC_TryDecode: {
     390             :       unsigned Len;
     391             :       // Decode the Opcode value.
     392           0 :       unsigned Opc = decodeULEB128(++Ptr, &Len);
     393           0 :       Ptr += Len;
     394           0 :       unsigned DecodeIdx = decodeULEB128(Ptr, &Len);
     395           0 :       Ptr += Len;
     396             :       // NumToSkip is a plain 16-bit integer.
     397           0 :       unsigned NumToSkip = *Ptr++;
     398           0 :       NumToSkip |= (*Ptr++) << 8;
     399             : 
     400             :       // Perform the decode operation.
     401           0 :       MCInst TmpMI;
     402           0 :       TmpMI.setOpcode(Opc);
     403             :       bool DecodeComplete;
     404           0 :       S = decodeToMCInst(S, DecodeIdx, insn, TmpMI, Address, DisAsm, DecodeComplete);
     405             :       DEBUG(dbgs() << Loc << ": OPC_TryDecode: opcode " << Opc
     406             :                    << ", using decoder " << DecodeIdx << ": ");
     407             : 
     408           0 :       if (DecodeComplete) {
     409             :         // Decoding complete.
     410             :         DEBUG(dbgs() << (S != MCDisassembler::Fail ? "PASS" : "FAIL") << "\n");
     411           0 :         MI = TmpMI;
     412           0 :         return S;
     413             :       } else {
     414             :         assert(S == MCDisassembler::Fail);
     415             :         // If the decoding was incomplete, skip.
     416           0 :         Ptr += NumToSkip;
     417             :         DEBUG(dbgs() << "FAIL: continuing at " << (Ptr - DecodeTable) << "\n");
     418             :         // Reset decode status. This also drops a SoftFail status that could be
     419             :         // set before the decode attempt.
     420           0 :         S = MCDisassembler::Success;
     421             :       }
     422           0 :       break;
     423             :     }
     424           0 :     case MCD::OPC_SoftFail: {
     425             :       // Decode the mask values.
     426             :       unsigned Len;
     427           0 :       InsnType PositiveMask = decodeULEB128(++Ptr, &Len);
     428           0 :       Ptr += Len;
     429           0 :       InsnType NegativeMask = decodeULEB128(Ptr, &Len);
     430           0 :       Ptr += Len;
     431           0 :       bool Fail = (insn & PositiveMask) || (~insn & NegativeMask);
     432             :       if (Fail)
     433             :         S = MCDisassembler::SoftFail;
     434             :       DEBUG(dbgs() << Loc << ": OPC_SoftFail: " << (Fail ? "FAIL\n":"PASS\n"));
     435             :       break;
     436             :     }
     437             :     case MCD::OPC_Fail: {
     438             :       DEBUG(dbgs() << Loc << ": OPC_Fail\n");
     439             :       return MCDisassembler::Fail;
     440             :     }
     441             :     }
     442             :   }
     443             :   llvm_unreachable("bogosity detected in disassembler state machine!");
     444             : }
     445             : 
     446             : 
     447             : } // End llvm namespace

Generated by: LCOV version 1.13