1 //===-EDOperand.h - LLVM Enhanced Disassembler ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interface for the Enhanced Disassembly library's
11 // operand class. The operand is responsible for allowing evaluation given a
12 // particular register context.
14 //===----------------------------------------------------------------------===//
19 #include "llvm-c/EnhancedDisassembly.h"
21 /// EDOperand - Encapsulates a single operand, which can be evaluated by the
24 /// The parent disassembler
25 const EDDisassembler &Disassembler;
26 /// The parent instruction
29 /// The index of the operand in the EDInst
31 /// The index of the first component of the operand in the MCInst
32 unsigned int MCOpIndex;
34 /// Constructor - Initializes an EDOperand
36 /// @arg disassembler - The disassembler responsible for the operand
37 /// @arg inst - The instruction containing this operand
38 /// @arg opIndex - The index of the operand in inst
39 /// @arg mcOpIndex - The index of the operand in the original MCInst
40 EDOperand(const EDDisassembler &disassembler,
43 unsigned int &mcOpIndex);
46 /// evaluate - Returns the numeric value of an operand to the extent possible,
47 /// returning 0 on success or -1 if there was some problem (such as a
48 /// register not being readable)
50 /// @arg result - A reference whose target is filled in with the value of
51 /// the operand (the address if it is a memory operand)
52 /// @arg callback - A function to call to obtain register values
53 /// @arg arg - An opaque argument to pass to callback
54 int evaluate(uint64_t &result,
55 EDRegisterReaderCallback callback,
58 /// isRegister - Returns 1 if the operand is a register or 0 otherwise
60 /// regVal - Returns the register value.
63 /// isImmediate - Returns 1 if the operand is an immediate or 0 otherwise
65 /// immediateVal - Returns the immediate value.
66 uint64_t immediateVal();
68 /// isMemory - Returns 1 if the operand is a memory location or 0 otherwise
72 /// evaluate - Like evaluate for a callback, but uses a block instead
73 int evaluate(uint64_t &result,
74 EDRegisterBlock_t regBlock);