Don't overwrite previous value, if it succeeded.
[oota-llvm.git] / include / llvm-c / EnhancedDisassembly.h
index 46da1d85cc2ebc952614deb406d4b10e28bba1d4..9cd1e1f5f3cfe72aaf744a650246447ed88572d7 100644 (file)
@@ -51,12 +51,12 @@ typedef int (*EDRegisterReaderCallback)(uint64_t *value, unsigned regID,
  @typedef EDAssemblySyntax_t
  An assembly syntax for use in tokenizing instructions.
  */
-typedef uint32_t EDAssemblySyntax_t;
-
+typedef enum {
 /*! @constant kEDAssemblySyntaxX86Intel Intel syntax for i386 and x86_64. */
-const EDAssemblySyntax_t kEDAssemblySyntaxX86Intel  = 0;
+  kEDAssemblySyntaxX86Intel  = 0,
 /*! @constant kEDAssemblySyntaxX86ATT AT&T syntax for i386 and x86_64. */
-const EDAssemblySyntax_t kEDAssemblySyntaxX86ATT    = 1;  
+  kEDAssemblySyntaxX86ATT    = 1
+} EDAssemblySyntax_t;
 
 /*!
  @typedef EDDisassemblerRef
@@ -176,7 +176,7 @@ void EDReleaseInst(EDInstRef inst);
 /*!
  @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);
 
@@ -368,10 +368,55 @@ int EDNumOperands(EDInstRef inst);
 int EDGetOperand(EDOperandRef *operand,
                  EDInstRef inst,
                  int index);
+  
+/*!
+ @function EDOperandIsRegister
+ @param operand The operand to be queried.
+ @result 1 if the operand names a register; 0 if not; -1 on error.
+ */
+int EDOperandIsRegister(EDOperandRef operand);
+
+/*!
+ @function EDOperandIsImmediate
+ @param operand The operand to be queried.
+ @result 1 if the operand specifies an immediate value; 0 if not; -1 on error.
+ */
+int EDOperandIsImmediate(EDOperandRef operand);
+
+/*!
+ @function EDOperandIsMemory
+ @param operand The operand to be queried.
+ @result 1 if the operand specifies a location in memory; 0 if not; -1 on error.
+ */
+int EDOperandIsMemory(EDOperandRef operand);
+
+/*!
+ @function EDRegisterOperandValue
+ @param value A pointer whose target will be filled in with the LLVM register ID
+   of the register named by the operand.  
+ @param operand The operand to be queried.
+ @result 0 on success; -1 otherwise.
+ */
+int EDRegisterOperandValue(unsigned *value,
+                           EDOperandRef operand);
+  
+/*!
+ @function EDImmediateOperandValue
+ @param value A pointer whose target will be filled in with the value of the
+   immediate.
+ @param operand The operand to be queried.
+ @result 0 on success; -1 otherwise.
+ */
+int EDImmediateOperandValue(uint64_t *value,
+                            EDOperandRef operand);
 
 /*!
  @function EDEvaluateOperand
- Evaluates an operand using a client-supplied register state accessor.
+ Evaluates an operand using a client-supplied register state accessor.  Register
+ operands are evaluated by reading the value of the register; immediate operands
+ are evaluated by reporting the immediate value; memory operands are evaluated
+ by computing the target address (with only those relocations applied that were
+ already applied to the original bytes).
  @param result A pointer whose target is to be filled with the result of
    evaluating the operand.
  @param operand The operand to be evaluated.