File: MCInstrDesc.c

package info (click to toggle)
capstone 5.0.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,212 kB
  • sloc: ansic: 96,103; cpp: 67,489; cs: 29,510; python: 25,829; pascal: 24,412; java: 15,582; ml: 14,473; makefile: 1,274; sh: 479; ruby: 386
file content (41 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Capstone Disassembly Engine */
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */

#include "MCInstrDesc.h"

/// isPredicate - Set if this is one of the operands that made up of
/// the predicate operand that controls an isPredicable() instruction.
bool MCOperandInfo_isPredicate(const MCOperandInfo *m)
{
	return m->Flags & (1 << MCOI_Predicate);
}

/// isOptionalDef - Set if this operand is a optional def.
///
bool MCOperandInfo_isOptionalDef(const MCOperandInfo *m)
{
	return m->Flags & (1 << MCOI_OptionalDef);
}

/// Checks if operand is tied to another one.
bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m)
{
	if (m->Constraints & (1 << MCOI_TIED_TO))
		return true;
	return false;
}

/// Returns the value of the specified operand constraint if
/// it is present. Returns -1 if it is not present.
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *InstrDesc,
				       unsigned OpNum,
				       MCOI_OperandConstraint Constraint)
{
	const MCOperandInfo OpInfo = InstrDesc->OpInfo[OpNum];
	if (OpNum < InstrDesc->NumOperands &&
	    (OpInfo.Constraints & (1 << Constraint))) {
		unsigned ValuePos = 4 + Constraint * 4;
		return (OpInfo.Constraints >> ValuePos) & 0xf;
	}
	return -1;
}