Produce a relocation for pcrel absolute values. Based on a patch by David Meyer.
[oota-llvm.git] / lib / Target / X86 / Disassembler / X86DisassemblerDecoder.h
index f548c65dad534c2dfc2e12200a7d4728a7cf3356..4f4fbcdd394cfd02f28407f36689fe08c1a3e014 100644 (file)
@@ -24,7 +24,7 @@ extern "C" {
   const char*             name;
 
 #define INSTRUCTION_IDS     \
-  InstrUID*  instructionIDs;
+  const InstrUID *instructionIDs;
 
 #include "X86DisassemblerDecoderCommon.h"
   
@@ -34,16 +34,16 @@ extern "C" {
 /*
  * Accessor functions for various fields of an Intel instruction
  */
-static inline uint8_t modFromModRM(uint8_t modRM){ return (modRM & 0xc0) >> 6; }
-static inline uint8_t regFromModRM(uint8_t modRM){ return (modRM & 0x38) >> 3; }
-static inline uint8_t rmFromModRM(uint8_t modRM) { return (modRM & 0x7);       }
-static inline uint8_t scaleFromSIB(uint8_t sib)  { return (sib & 0xc0) >> 6;   }
-static inline uint8_t indexFromSIB(uint8_t sib)  { return (sib & 0x38) >> 3;   }
-static inline uint8_t baseFromSIB(uint8_t sib)   { return (sib & 0x7);         }
-static inline uint8_t wFromREX(uint8_t rex)      { return (rex & 0x8) >> 3;    }
-static inline uint8_t rFromREX(uint8_t rex)      { return (rex & 0x4) >> 2;    }
-static inline uint8_t xFromREX(uint8_t rex)      { return (rex & 0x2) >> 1;    }
-static inline uint8_t bFromREX(uint8_t rex)      { return (rex & 0x1);         }
+#define modFromModRM(modRM)  ((modRM & 0xc0) >> 6)
+#define regFromModRM(modRM)  ((modRM & 0x38) >> 3)
+#define rmFromModRM(modRM)   (modRM & 0x7)
+#define scaleFromSIB(sib)    ((sib & 0xc0) >> 6)
+#define indexFromSIB(sib)    ((sib & 0x38) >> 3)
+#define baseFromSIB(sib)     (sib & 0x7)
+#define wFromREX(rex)        ((rex & 0x8) >> 3)
+#define rFromREX(rex)        ((rex & 0x4) >> 2)
+#define xFromREX(rex)        ((rex & 0x2) >> 1)
+#define bFromREX(rex)        (rex & 0x1)
 
 /*
  * These enums represent Intel registers for use by the decoder.
@@ -225,26 +225,16 @@ static inline uint8_t bFromREX(uint8_t rex)      { return (rex & 0x1);         }
   ENTRY(DR6)        \
   ENTRY(DR7)
 
-#define REGS_CONTROL_32BIT  \
-  ENTRY(ECR0)               \
-  ENTRY(ECR1)               \
-  ENTRY(ECR2)               \
-  ENTRY(ECR3)               \
-  ENTRY(ECR4)               \
-  ENTRY(ECR5)               \
-  ENTRY(ECR6)               \
-  ENTRY(ECR7)
-
-#define REGS_CONTROL_64BIT  \
-  ENTRY(RCR0)               \
-  ENTRY(RCR1)               \
-  ENTRY(RCR2)               \
-  ENTRY(RCR3)               \
-  ENTRY(RCR4)               \
-  ENTRY(RCR5)               \
-  ENTRY(RCR6)               \
-  ENTRY(RCR7)               \
-  ENTRY(RCR8)
+#define REGS_CONTROL  \
+  ENTRY(CR0)          \
+  ENTRY(CR1)          \
+  ENTRY(CR2)          \
+  ENTRY(CR3)          \
+  ENTRY(CR4)          \
+  ENTRY(CR5)          \
+  ENTRY(CR6)          \
+  ENTRY(CR7)          \
+  ENTRY(CR8)
   
 #define ALL_EA_BASES  \
   EA_BASES_16BIT      \
@@ -264,8 +254,7 @@ static inline uint8_t bFromREX(uint8_t rex)      { return (rex & 0x1);         }
   REGS_XMM            \
   REGS_SEGMENT        \
   REGS_DEBUG          \
-  REGS_CONTROL_32BIT  \
-  REGS_CONTROL_64BIT  \
+  REGS_CONTROL        \
   ENTRY(RIP)
 
 /*
@@ -324,10 +313,10 @@ typedef enum {
  * Reg - All possible values of the reg field in the ModR/M byte.
  */
 typedef enum {
-#define ENTRY(x) REG_##x,
+#define ENTRY(x) MODRM_REG_##x,
   ALL_REGS
 #undef ENTRY
-  REG_max
+  MODRM_REG_max
 } Reg;
   
 /*
@@ -434,7 +423,7 @@ struct InternalInstruction {
   /* The instruction ID, extracted from the decode table */
   uint16_t instructionID;
   /* The specifier for the instruction, from the instruction info table */
-  struct InstructionSpecifier* spec;
+  const struct InstructionSpecifier *spec;
   
   /* state for additional bytes, consumed during operand decode.  Pattern:
      consumed___ indicates that the byte was already consumed and does not
@@ -508,6 +497,17 @@ int decodeInstruction(struct InternalInstruction* insn,
                       uint64_t startLoc,
                       DisassemblerMode mode);
 
+/* x86DisassemblerDebug - C-accessible function for printing a message to
+ *   debugs()
+ * @param file  - The name of the file printing the debug message.
+ * @param line  - The line number that printed the debug message.
+ * @param s     - The message to print.
+ */
+  
+void x86DisassemblerDebug(const char *file,
+                          unsigned line,
+                          const char *s);
+
 #ifdef __cplusplus 
 }
 #endif