blob: 32d3a5ef83dcd19ace0c85254b9e1dd768f01a16 [file] [log] [blame]
Sean Callananee5dfd42010-02-01 08:49:35 +00001//===-EDOperand.h - LLVM Enhanced Disassembler ------------------*- 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 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.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef EDOperand_
17#define EDOperand_
18
19#include "llvm-c/EnhancedDisassembly.h"
20
21/// EDOperand - Encapsulates a single operand, which can be evaluated by the
22/// client
23struct EDOperand {
24 /// The parent disassembler
25 const EDDisassembler &Disassembler;
26 /// The parent instruction
27 const EDInst &Inst;
28
29 /// The index of the operand in the EDInst
30 unsigned int OpIndex;
31 /// The index of the first component of the operand in the MCInst
32 unsigned int MCOpIndex;
33
34 /// Constructor - Initializes an EDOperand
35 ///
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,
41 const EDInst &inst,
42 unsigned int opIndex,
43 unsigned int &mcOpIndex);
44 ~EDOperand();
45
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)
49 ///
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,
56 void *arg);
57
58#ifdef __BLOCKS__
59 /// evaluate - Like evaluate for a callback, but uses a block instead
60 int evaluate(uint64_t &result,
61 EDRegisterBlock_t regBlock);
62#endif
63};
64
65#endif