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 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_EDOPERAND_H
17 #define LLVM_EDOPERAND_H
19 #include "llvm/Support/DataTypes.h"
23 struct EDDisassembler
;
26 typedef int (*EDRegisterReaderCallback
)(uint64_t *value
, unsigned regID
,
30 /// EDOperand - Encapsulates a single operand, which can be evaluated by the
33 /// The parent disassembler
34 const EDDisassembler
&Disassembler
;
35 /// The parent instruction
38 /// The index of the operand in the EDInst
40 /// The index of the first component of the operand in the MCInst
41 unsigned int MCOpIndex
;
43 /// Constructor - Initializes an EDOperand
45 /// @arg disassembler - The disassembler responsible for the operand
46 /// @arg inst - The instruction containing this operand
47 /// @arg opIndex - The index of the operand in inst
48 /// @arg mcOpIndex - The index of the operand in the original MCInst
49 EDOperand(const EDDisassembler
&disassembler
,
52 unsigned int &mcOpIndex
);
55 /// evaluate - Returns the numeric value of an operand to the extent possible,
56 /// returning 0 on success or -1 if there was some problem (such as a
57 /// register not being readable)
59 /// @arg result - A reference whose target is filled in with the value of
60 /// the operand (the address if it is a memory operand)
61 /// @arg callback - A function to call to obtain register values
62 /// @arg arg - An opaque argument to pass to callback
63 int evaluate(uint64_t &result
,
64 EDRegisterReaderCallback callback
,
67 /// isRegister - Returns 1 if the operand is a register or 0 otherwise
69 /// regVal - Returns the register value.
72 /// isImmediate - Returns 1 if the operand is an immediate or 0 otherwise
74 /// immediateVal - Returns the immediate value.
75 uint64_t immediateVal();
77 /// isMemory - Returns 1 if the operand is a memory location or 0 otherwise
81 typedef int (^EDRegisterBlock_t
)(uint64_t *value
, unsigned regID
);
83 /// evaluate - Like evaluate for a callback, but uses a block instead
84 int evaluate(uint64_t &result
,
85 EDRegisterBlock_t regBlock
);
89 } // end namespace llvm