summaryrefslogtreecommitdiff
path: root/tools/edis
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2010-02-04 01:43:08 +0000
committerSean Callanan <scallanan@apple.com>2010-02-04 01:43:08 +0000
commit76706584c2190f4a157ec7a3c89a7098ce9fd880 (patch)
treec6bac1147b6a6722a5aff9accaaf1ae699274ae2 /tools/edis
parent523d70ec1f8daa67bb8a9fe8f7b6b3d076a26c99 (diff)
downloadllvm-76706584c2190f4a157ec7a3c89a7098ce9fd880.tar.gz
llvm-76706584c2190f4a157ec7a3c89a7098ce9fd880.tar.bz2
llvm-76706584c2190f4a157ec7a3c89a7098ce9fd880.tar.xz
Filled in a few new APIs for the enhanced
disassembly library that provide access to instruction information, and fixed ambiguous wording in the comments for the header. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95274 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/edis')
-rw-r--r--tools/edis/EDMain.cpp28
-rw-r--r--tools/edis/EDOperand.cpp20
-rw-r--r--tools/edis/EDOperand.h13
3 files changed, 61 insertions, 0 deletions
diff --git a/tools/edis/EDMain.cpp b/tools/edis/EDMain.cpp
index c2c179693e..1d2a6078b5 100644
--- a/tools/edis/EDMain.cpp
+++ b/tools/edis/EDMain.cpp
@@ -201,6 +201,34 @@ int EDGetOperand(EDOperandRef *operand,
return inst->getOperand(*operand, index);
}
+int EDOperandIsRegister(EDOperandRef operand) {
+ return operand->isRegister();
+}
+
+int EDOperandIsImmediate(EDOperandRef operand) {
+ return operand->isImmediate();
+}
+
+int EDOperandIsMemory(EDOperandRef operand) {
+ return operand->isMemory();
+}
+
+int EDRegisterOperandValue(unsigned *value,
+ EDOperandRef operand) {
+ if(!operand->isRegister())
+ return -1;
+ *value = operand->regVal();
+ return 0;
+}
+
+int EDImmedateOperandValue(uint64_t *value,
+ EDOperandRef operand) {
+ if(!operand->isImmediate())
+ return -1;
+ *value = operand->immediateVal();
+ return 0;
+}
+
int EDEvaluateOperand(uint64_t *result,
EDOperandRef operand,
EDRegisterReaderCallback regReader,
diff --git a/tools/edis/EDOperand.cpp b/tools/edis/EDOperand.cpp
index c15860affd..da6797e035 100644
--- a/tools/edis/EDOperand.cpp
+++ b/tools/edis/EDOperand.cpp
@@ -125,6 +125,26 @@ int EDOperand::evaluate(uint64_t &result,
return -1;
}
+int EDOperand::isRegister() {
+ return(Inst.ThisInstInfo->operandFlags[OpIndex] & kOperandFlagRegister);
+}
+
+unsigned EDOperand::regVal() {
+ return Inst.Inst->getOperand(MCOpIndex).getReg();
+}
+
+int EDOperand::isImmediate() {
+ return(Inst.ThisInstInfo->operandFlags[OpIndex] & kOperandFlagImmediate);
+}
+
+uint64_t EDOperand::immediateVal() {
+ return Inst.Inst->getOperand(MCOpIndex).getImm();
+}
+
+int EDOperand::isMemory() {
+ return(Inst.ThisInstInfo->operandFlags[OpIndex] & kOperandFlagMemory);
+}
+
#ifdef __BLOCKS__
struct RegisterReaderWrapper {
EDRegisterBlock_t regBlock;
diff --git a/tools/edis/EDOperand.h b/tools/edis/EDOperand.h
index 32d3a5ef83..ad9345b758 100644
--- a/tools/edis/EDOperand.h
+++ b/tools/edis/EDOperand.h
@@ -54,6 +54,19 @@ struct EDOperand {
int evaluate(uint64_t &result,
EDRegisterReaderCallback callback,
void *arg);
+
+ /// isRegister - Returns 1 if the operand is a register or 0 otherwise
+ int isRegister();
+ /// regVal - Returns the register value.
+ unsigned regVal();
+
+ /// isImmediate - Returns 1 if the operand is an immediate or 0 otherwise
+ int isImmediate();
+ /// immediateVal - Returns the immediate value.
+ uint64_t immediateVal();
+
+ /// isMemory - Returns 1 if the operand is a memory location or 0 otherwise
+ int isMemory();
#ifdef __BLOCKS__
/// evaluate - Like evaluate for a callback, but uses a block instead