/src/capstonenext/MCInst.h
| Line | Count | Source | 
| 1 |  | //===-- llvm/MC/MCInst.h - MCInst class -------------------------*- C++ -*-===// | 
| 2 |  | // | 
| 3 |  | //                     The LLVM Compiler Infrastructure | 
| 4 |  | // | 
| 5 |  | // This file is distributed under the University of Illinois Open Source | 
| 6 |  | // License. See LICENSE.TXT for details. | 
| 7 |  | // | 
| 8 |  | //===----------------------------------------------------------------------===// | 
| 9 |  | // | 
| 10 |  | // This file contains the declaration of the MCInst and MCOperand classes, which | 
| 11 |  | // is the basic representation used to represent low-level machine code | 
| 12 |  | // instructions. | 
| 13 |  | // | 
| 14 |  | //===----------------------------------------------------------------------===// | 
| 15 |  |  | 
| 16 |  | /* Capstone Disassembly Engine */ | 
| 17 |  | /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */ | 
| 18 |  |  | 
| 19 |  | #ifndef CS_MCINST_H | 
| 20 |  | #define CS_MCINST_H | 
| 21 |  |  | 
| 22 |  | #include "include/capstone/capstone.h" | 
| 23 |  | #include "MCInstrDesc.h" | 
| 24 |  | #include "MCRegisterInfo.h" | 
| 25 |  |  | 
| 26 |  | typedef struct MCInst MCInst; | 
| 27 |  | typedef struct cs_struct cs_struct; | 
| 28 |  | typedef struct MCOperand MCOperand; | 
| 29 |  |  | 
| 30 |  | /// MCOperand - Instances of this class represent operands of the MCInst class. | 
| 31 |  | /// This is a simple discriminated union. | 
| 32 |  | struct MCOperand { | 
| 33 |  |   enum { | 
| 34 |  |     kInvalid = 0,  ///< Uninitialized. | 
| 35 |  |     kRegister,     ///< Register operand. | 
| 36 |  |     kImmediate,    ///< Immediate operand. | 
| 37 |  |     kFPImmediate,  ///< Floating-point immediate operand. | 
| 38 |  |     kDFPImmediate, ///< Double-Floating-point immediate operand. | 
| 39 |  |     kExpr,         ///< Relocatable immediate operand. | 
| 40 |  |     kInst        ///< Sub-instruction operand. | 
| 41 |  |   } MachineOperandType; | 
| 42 |  |   unsigned char Kind; | 
| 43 |  |  | 
| 44 |  |   union { | 
| 45 |  |     unsigned RegVal; | 
| 46 |  |     int64_t ImmVal; | 
| 47 |  |     double FPImmVal; | 
| 48 |  |   }; | 
| 49 |  | }; | 
| 50 |  |  | 
| 51 |  | bool MCOperand_isValid(const MCOperand *op); | 
| 52 |  |  | 
| 53 |  | bool MCOperand_isReg(const MCOperand *op); | 
| 54 |  |  | 
| 55 |  | bool MCOperand_isImm(const MCOperand *op); | 
| 56 |  |  | 
| 57 |  | bool MCOperand_isFPImm(const MCOperand *op); | 
| 58 |  |  | 
| 59 |  | bool MCOperand_isDFPImm(const MCOperand *op); | 
| 60 |  |  | 
| 61 |  | bool MCOperand_isExpr(const MCOperand *op); | 
| 62 |  |  | 
| 63 |  | bool MCOperand_isInst(const MCOperand *op); | 
| 64 |  |  | 
| 65 |  | /// getReg - Returns the register number. | 
| 66 |  | unsigned MCOperand_getReg(const MCOperand *op); | 
| 67 |  |  | 
| 68 |  | /// setReg - Set the register number. | 
| 69 |  | void MCOperand_setReg(MCOperand *op, unsigned Reg); | 
| 70 |  |  | 
| 71 |  | int64_t MCOperand_getImm(MCOperand *op); | 
| 72 |  |  | 
| 73 |  | void MCOperand_setImm(MCOperand *op, int64_t Val); | 
| 74 |  |  | 
| 75 |  | double MCOperand_getFPImm(const MCOperand *op); | 
| 76 |  |  | 
| 77 |  | void MCOperand_setFPImm(MCOperand *op, double Val); | 
| 78 |  |  | 
| 79 |  | const MCInst *MCOperand_getInst(const MCOperand *op); | 
| 80 |  |  | 
| 81 |  | void MCOperand_setInst(MCOperand *op, const MCInst *Val); | 
| 82 |  |  | 
| 83 |  | // create Reg operand in the next slot | 
| 84 |  | void MCOperand_CreateReg0(MCInst *inst, unsigned Reg); | 
| 85 |  |  | 
| 86 |  | // create Reg operand use the last-unused slot | 
| 87 |  | MCOperand *MCOperand_CreateReg1(MCInst *inst, unsigned Reg); | 
| 88 |  |  | 
| 89 |  | // create Imm operand in the next slot | 
| 90 |  | void MCOperand_CreateImm0(MCInst *inst, int64_t Val); | 
| 91 |  |  | 
| 92 |  | // create Imm operand in the last-unused slot | 
| 93 |  | MCOperand *MCOperand_CreateImm1(MCInst *inst, int64_t Val); | 
| 94 |  |  | 
| 95 | 357M | #define MAX_MC_OPS 48 | 
| 96 |  |  | 
| 97 |  | /// MCInst - Instances of this class represent a single low-level machine | 
| 98 |  | /// instruction. | 
| 99 |  | struct MCInst { | 
| 100 |  |   unsigned OpcodePub;  // public opcode (<arch>_INS_yyy in header files <arch>.h) | 
| 101 |  |   uint8_t size; // number of operands | 
| 102 |  |   bool has_imm; // indicate this instruction has an X86_OP_IMM operand - used for ATT syntax | 
| 103 |  |   uint8_t op1_size; // size of 1st operand - for X86 Intel syntax | 
| 104 |  |   unsigned Opcode;  // private opcode | 
| 105 |  |   MCOperand Operands[MAX_MC_OPS]; | 
| 106 |  |   cs_insn *flat_insn; // insn to be exposed to public | 
| 107 |  |   uint64_t address; // address of this insn | 
| 108 |  |   cs_struct *csh; // save the main csh | 
| 109 |  |   uint8_t x86opsize;  // opsize for [mem] operand | 
| 110 |  |  | 
| 111 |  |   // These flags could be used to pass some info from one target subcomponent | 
| 112 |  |   // to another, for example, from disassembler to asm printer. The values of | 
| 113 |  |   // the flags have any sense on target level only (e.g. prefixes on x86). | 
| 114 |  |   unsigned flags; | 
| 115 |  |  | 
| 116 |  |   // (Optional) instruction prefix, which can be up to 4 bytes. | 
| 117 |  |   // A prefix byte gets value 0 when irrelevant. | 
| 118 |  |   // This is copied from cs_x86 struct | 
| 119 |  |   uint8_t x86_prefix[4]; | 
| 120 |  |   uint8_t imm_size; // immediate size for X86_OP_IMM operand | 
| 121 |  |   bool writeback;   // writeback for ARM | 
| 122 |  |   int8_t tied_op_idx | 
| 123 |  |     [MAX_MC_OPS]; ///< Tied operand indices. Index = Src op; Value: Dest op | 
| 124 |  |   // operand access index for list of registers sharing the same access right (for ARM) | 
| 125 |  |   uint8_t ac_idx; | 
| 126 |  |   uint8_t popcode_adjust;   // Pseudo X86 instruction adjust | 
| 127 |  |   char assembly[8]; // for special instruction, so that we dont need printer | 
| 128 |  |   unsigned char evm_data[32]; // for EVM PUSH operand | 
| 129 |  |   cs_wasm_op wasm_data;    // for WASM operand | 
| 130 |  |   MCRegisterInfo *MRI; | 
| 131 |  |   uint8_t xAcquireRelease;   // X86 xacquire/xrelease | 
| 132 |  |   bool isAliasInstr; // Flag if this MCInst is an alias. | 
| 133 |  |   bool fillDetailOps; // If set, detail->operands gets filled. | 
| 134 |  | }; | 
| 135 |  |  | 
| 136 |  | void MCInst_Init(MCInst *inst); | 
| 137 |  |  | 
| 138 |  | void MCInst_clear(MCInst *inst); | 
| 139 |  |  | 
| 140 |  | // do not free operand after inserting | 
| 141 |  | void MCInst_insert0(MCInst *inst, int index, MCOperand *Op); | 
| 142 |  |  | 
| 143 |  | void MCInst_setOpcode(MCInst *inst, unsigned Op); | 
| 144 |  |  | 
| 145 |  | unsigned MCInst_getOpcode(const MCInst*); | 
| 146 |  |  | 
| 147 |  | void MCInst_setOpcodePub(MCInst *inst, unsigned Op); | 
| 148 |  |  | 
| 149 |  | unsigned MCInst_getOpcodePub(const MCInst*); | 
| 150 |  |  | 
| 151 |  | MCOperand *MCInst_getOperand(MCInst *inst, unsigned i); | 
| 152 |  |  | 
| 153 |  | unsigned MCInst_getNumOperands(const MCInst *inst); | 
| 154 |  |  | 
| 155 |  | // This addOperand2 function doesnt free Op | 
| 156 |  | void MCInst_addOperand2(MCInst *inst, MCOperand *Op); | 
| 157 |  |  | 
| 158 |  | bool MCInst_isPredicable(const MCInstrDesc *MIDesc); | 
| 159 |  |  | 
| 160 |  | void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc); | 
| 161 |  |  | 
| 162 |  | bool MCInst_opIsTied(const MCInst *MI, unsigned OpNum); | 
| 163 |  |  | 
| 164 |  | bool MCInst_opIsTying(const MCInst *MI, unsigned OpNum); | 
| 165 |  |  | 
| 166 |  | uint64_t MCInst_getOpVal(MCInst *MI, unsigned OpNum); | 
| 167 |  |  | 
| 168 |  | void MCInst_setIsAlias(MCInst *MI, bool Flag); | 
| 169 |  |  | 
| 170 | 63.8k | static inline bool MCInst_isAlias(const MCInst *MI) { | 
| 171 | 63.8k |   return MI->isAliasInstr; | 
| 172 | 63.8k | } Unexecuted instantiation: cs.c:MCInst_isAliasUnexecuted instantiation: MCInst.c:MCInst_isAliasUnexecuted instantiation: SStream.c:MCInst_isAliasUnexecuted instantiation: utils.c:MCInst_isAliasUnexecuted instantiation: ARMModule.c:MCInst_isAliasUnexecuted instantiation: AArch64Module.c:MCInst_isAliasUnexecuted instantiation: MipsModule.c:MCInst_isAliasUnexecuted instantiation: PPCModule.c:MCInst_isAliasUnexecuted instantiation: X86Module.c:MCInst_isAliasUnexecuted instantiation: X86ATTInstPrinter.c:MCInst_isAliasUnexecuted instantiation: SparcModule.c:MCInst_isAliasUnexecuted instantiation: SystemZModule.c:MCInst_isAliasUnexecuted instantiation: XCoreModule.c:MCInst_isAliasUnexecuted instantiation: M68KModule.c:MCInst_isAliasUnexecuted instantiation: TMS320C64xModule.c:MCInst_isAliasUnexecuted instantiation: M680XModule.c:MCInst_isAliasUnexecuted instantiation: EVMModule.c:MCInst_isAliasUnexecuted instantiation: WASMModule.c:MCInst_isAliasUnexecuted instantiation: MOS65XXModule.c:MCInst_isAliasUnexecuted instantiation: MOS65XXDisassembler.c:MCInst_isAliasUnexecuted instantiation: BPFModule.c:MCInst_isAliasUnexecuted instantiation: RISCVModule.c:MCInst_isAliasUnexecuted instantiation: SHModule.c:MCInst_isAliasUnexecuted instantiation: TriCoreModule.c:MCInst_isAliasUnexecuted instantiation: ARMMapping.c:MCInst_isAliasUnexecuted instantiation: AArch64Disassembler.c:MCInst_isAliasUnexecuted instantiation: AArch64InstPrinter.c:MCInst_isAliasUnexecuted instantiation: AArch64Mapping.c:MCInst_isAliasUnexecuted instantiation: MipsDisassembler.c:MCInst_isAliasUnexecuted instantiation: MipsInstPrinter.c:MCInst_isAliasUnexecuted instantiation: MipsMapping.c:MCInst_isAliasUnexecuted instantiation: PPCMapping.c:MCInst_isAliasUnexecuted instantiation: X86Disassembler.c:MCInst_isAliasUnexecuted instantiation: X86DisassemblerDecoder.c:MCInst_isAliasUnexecuted instantiation: X86IntelInstPrinter.c:MCInst_isAliasUnexecuted instantiation: X86InstPrinterCommon.c:MCInst_isAliasUnexecuted instantiation: X86Mapping.c:MCInst_isAliasUnexecuted instantiation: SparcDisassembler.c:MCInst_isAliasUnexecuted instantiation: SparcInstPrinter.c:MCInst_isAliasUnexecuted instantiation: SparcMapping.c:MCInst_isAliasUnexecuted instantiation: SystemZDisassembler.c:MCInst_isAliasUnexecuted instantiation: SystemZInstPrinter.c:MCInst_isAliasUnexecuted instantiation: SystemZMapping.c:MCInst_isAliasUnexecuted instantiation: XCoreDisassembler.c:MCInst_isAliasUnexecuted instantiation: XCoreInstPrinter.c:MCInst_isAliasUnexecuted instantiation: XCoreMapping.c:MCInst_isAliasUnexecuted instantiation: M68KDisassembler.c:MCInst_isAliasUnexecuted instantiation: M68KInstPrinter.c:MCInst_isAliasUnexecuted instantiation: TMS320C64xDisassembler.c:MCInst_isAliasUnexecuted instantiation: TMS320C64xInstPrinter.c:MCInst_isAliasUnexecuted instantiation: TMS320C64xMapping.c:MCInst_isAliasUnexecuted instantiation: M680XDisassembler.c:MCInst_isAliasUnexecuted instantiation: M680XInstPrinter.c:MCInst_isAliasUnexecuted instantiation: EVMDisassembler.c:MCInst_isAliasUnexecuted instantiation: EVMInstPrinter.c:MCInst_isAliasUnexecuted instantiation: EVMMapping.c:MCInst_isAliasUnexecuted instantiation: WASMDisassembler.c:MCInst_isAliasUnexecuted instantiation: WASMInstPrinter.c:MCInst_isAliasUnexecuted instantiation: WASMMapping.c:MCInst_isAliasUnexecuted instantiation: BPFDisassembler.c:MCInst_isAliasUnexecuted instantiation: BPFInstPrinter.c:MCInst_isAliasUnexecuted instantiation: BPFMapping.c:MCInst_isAliasUnexecuted instantiation: RISCVDisassembler.c:MCInst_isAliasUnexecuted instantiation: RISCVInstPrinter.c:MCInst_isAliasUnexecuted instantiation: RISCVMapping.c:MCInst_isAliasUnexecuted instantiation: SHDisassembler.c:MCInst_isAliasUnexecuted instantiation: SHInstPrinter.c:MCInst_isAliasUnexecuted instantiation: TriCoreDisassembler.c:MCInst_isAliasUnexecuted instantiation: TriCoreMapping.c:MCInst_isAlias| Line | Count | Source |  | 170 | 63.8k | static inline bool MCInst_isAlias(const MCInst *MI) { |  | 171 | 63.8k |   return MI->isAliasInstr; |  | 172 | 63.8k | } | 
Unexecuted instantiation: ARMBaseInfo.c:MCInst_isAliasUnexecuted instantiation: ARMDisassembler.c:MCInst_isAliasUnexecuted instantiation: ARMDisassemblerExtension.c:MCInst_isAliasUnexecuted instantiation: ARMInstPrinter.c:MCInst_isAliasUnexecuted instantiation: AArch64BaseInfo.c:MCInst_isAliasUnexecuted instantiation: PPCDisassembler.c:MCInst_isAliasUnexecuted instantiation: PPCInstPrinter.c:MCInst_isAliasUnexecuted instantiation: TriCoreInstPrinter.c:MCInst_isAliasUnexecuted instantiation: MCInstPrinter.c:MCInst_isAlias | 
| 173 |  |  | 
| 174 |  | #endif |