| 1 | /* Capstone Disassembly Engine */ |
| 2 | /* By Nguyen Anh Quynh <[email protected]>, 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 | { |
| 10 | return m->Flags & (1 << MCOI_Predicate); |
| 11 | } |
| 12 | |
| 13 | /// isOptionalDef - Set if this operand is a optional def. |
| 14 | /// |
| 15 | bool MCOperandInfo_isOptionalDef(const MCOperandInfo *m) |
| 16 | { |
| 17 | return m->Flags & (1 << MCOI_OptionalDef); |
| 18 | } |
| 19 | |
| 20 | /// Checks if operand is tied to another one. |
| 21 | bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m) |
| 22 | { |
| 23 | if (m->Constraints & (1 << MCOI_TIED_TO)) |
| 24 | return true; |
| 25 | return false; |
| 26 | } |
| 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 | { |
| 34 | const MCOperandInfo OpInfo = InstrDesc->OpInfo[OpNum]; |
| 35 | if (OpNum < InstrDesc->NumOperands && |
| 36 | (OpInfo.Constraints & (1 << Constraint))) { |
| 37 | unsigned ValuePos = 4 + Constraint * 4; |
| 38 | return (OpInfo.Constraints >> ValuePos) & 0xf; |
| 39 | } |
| 40 | return -1; |
| 41 | } |