[llvm-commits] [llvm] r95274 - in /llvm/trunk: include/llvm-c/EnhancedDisassembly.h tools/edis/EDMain.cpp tools/edis/EDOperand.cpp tools/edis/EDOperand.h

Sean Callanan scallanan at apple.com
Wed Feb 3 17:43:08 PST 2010


Author: spyffe
Date: Wed Feb  3 19:43:08 2010
New Revision: 95274

URL: http://llvm.org/viewvc/llvm-project?rev=95274&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm-c/EnhancedDisassembly.h
    llvm/trunk/tools/edis/EDMain.cpp
    llvm/trunk/tools/edis/EDOperand.cpp
    llvm/trunk/tools/edis/EDOperand.h

Modified: llvm/trunk/include/llvm-c/EnhancedDisassembly.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/EnhancedDisassembly.h?rev=95274&r1=95273&r2=95274&view=diff

==============================================================================
--- llvm/trunk/include/llvm-c/EnhancedDisassembly.h (original)
+++ llvm/trunk/include/llvm-c/EnhancedDisassembly.h Wed Feb  3 19:43:08 2010
@@ -176,7 +176,7 @@
 /*!
  @function EDInstByteSize
  @param inst The instruction to be queried.
- @result The number of bytes consumed by the instruction.
+ @result The number of bytes in the instruction's machine-code representation.
  */
 int EDInstByteSize(EDInstRef inst);
 

Modified: llvm/trunk/tools/edis/EDMain.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/edis/EDMain.cpp?rev=95274&r1=95273&r2=95274&view=diff

==============================================================================
--- llvm/trunk/tools/edis/EDMain.cpp (original)
+++ llvm/trunk/tools/edis/EDMain.cpp Wed Feb  3 19:43:08 2010
@@ -201,6 +201,34 @@
   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,

Modified: llvm/trunk/tools/edis/EDOperand.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/edis/EDOperand.cpp?rev=95274&r1=95273&r2=95274&view=diff

==============================================================================
--- llvm/trunk/tools/edis/EDOperand.cpp (original)
+++ llvm/trunk/tools/edis/EDOperand.cpp Wed Feb  3 19:43:08 2010
@@ -125,6 +125,26 @@
   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;

Modified: llvm/trunk/tools/edis/EDOperand.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/edis/EDOperand.h?rev=95274&r1=95273&r2=95274&view=diff

==============================================================================
--- llvm/trunk/tools/edis/EDOperand.h (original)
+++ llvm/trunk/tools/edis/EDOperand.h Wed Feb  3 19:43:08 2010
@@ -54,6 +54,19 @@
   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





More information about the llvm-commits mailing list