/src/capstonenext/MCInstrDesc.c
Line  | Count  | Source  | 
1  |  | /* Capstone Disassembly Engine */  | 
2  |  | /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */  | 
3  |  |  | 
4  |  | #include "MCInstrDesc.h"  | 
5  |  |  | 
6  |  | /// isPredicate - Set if this is one of the operands that made up of  | 
7  |  | /// the predicate operand that controls an isPredicable() instruction.  | 
8  |  | bool MCOperandInfo_isPredicate(const MCOperandInfo *m)  | 
9  | 9.31M  | { | 
10  | 9.31M  |   return m->Flags & (1 << MCOI_Predicate);  | 
11  | 9.31M  | }  | 
12  |  |  | 
13  |  | /// isOptionalDef - Set if this operand is a optional def.  | 
14  |  | ///  | 
15  |  | bool MCOperandInfo_isOptionalDef(const MCOperandInfo *m)  | 
16  | 721k  | { | 
17  | 721k  |   return m->Flags & (1 << MCOI_OptionalDef);  | 
18  | 721k  | }  | 
19  |  |  | 
20  |  | /// Checks if operand is tied to another one.  | 
21  |  | bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m)  | 
22  | 6.78M  | { | 
23  | 6.78M  |   if (m->Constraints & (1 << MCOI_TIED_TO))  | 
24  | 356k  |     return true;  | 
25  | 6.42M  |   return false;  | 
26  | 6.78M  | }  | 
27  |  |  | 
28  |  | /// Returns the value of the specified operand constraint if  | 
29  |  | /// it is present. Returns -1 if it is not present.  | 
30  |  | int MCOperandInfo_getOperandConstraint(const MCInstrDesc *InstrDesc,  | 
31  |  |                unsigned OpNum,  | 
32  |  |                MCOI_OperandConstraint Constraint)  | 
33  | 367k  | { | 
34  | 367k  |   const MCOperandInfo OpInfo = InstrDesc->OpInfo[OpNum];  | 
35  | 367k  |   if (OpNum < InstrDesc->NumOperands &&  | 
36  | 367k  |       (OpInfo.Constraints & (1 << Constraint))) { | 
37  | 367k  |     unsigned ValuePos = 4 + Constraint * 4;  | 
38  | 367k  |     return (OpInfo.Constraints >> ValuePos) & 0xf;  | 
39  | 367k  |   }  | 
40  | 0  |   return -1;  | 
41  | 367k  | }  | 
42  |  |  | 
43  |  | /// Returns the instruction description for the given MCInst opcode.  | 
44  |  | /// Function should be called like:  | 
45  |  | /// MCInstrDesc_get(MCInst_getOpcode(MI), ARCHInstDesc, ARR_SIZE(ARCHInstDesc));  | 
46  |  | const MCInstrDesc *MCInstrDesc_get(unsigned opcode, const MCInstrDesc *table,  | 
47  |  |            unsigned tbl_size)  | 
48  | 5.15M  | { | 
49  | 5.15M  |   return &table[tbl_size - 1 - opcode];  | 
50  | 5.15M  | }  |