#include <llvm/Target/TargetInstrInfo.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/Format.h>
+
+#if HAVE_LLVM >= 0x0306
+#include <llvm/Target/TargetSubtargetInfo.h>
+#else
#include <llvm/Support/MemoryObject.h>
+#endif
#include <llvm/Support/TargetRegistry.h>
#include <llvm/MC/MCSubtargetInfo.h>
#include <llvm/MC/MCInstPrinter.h>
#include <llvm/MC/MCRegisterInfo.h>
-#if HAVE_LLVM >= 0x0303
+#if HAVE_LLVM >= 0x0305
+#define OwningPtr std::unique_ptr
+#else
#include <llvm/ADT/OwningPtr.h>
#endif
}
+#if HAVE_LLVM < 0x0306
+
/*
* MemoryObject wrapper around a buffer of memory, to be used by MC
* disassembler.
}
};
+#endif /* HAVE_LLVM < 0x0306 */
+
/*
* Disassemble a function, using the LLVM MC disassembler.
#endif
OwningPtr<TargetMachine> TM(T->createTargetMachine(Triple, sys::getHostCPUName(), "", options));
+#if HAVE_LLVM >= 0x0306
+ const TargetInstrInfo *TII = TM->getSubtargetImpl()->getInstrInfo();
+#else
const TargetInstrInfo *TII = TM->getInstrInfo();
+#endif
/*
* Wrap the data in a MemoryObject
*/
+#if HAVE_LLVM >= 0x0306
+ ArrayRef<uint8_t> memoryObject((const uint8_t *)bytes, extent);
+#else
BufferMemoryObject memoryObject((const uint8_t *)bytes, extent);
+#endif
uint64_t pc;
pc = 0;
extern "C" void
lp_disassemble(LLVMValueRef func, const void *code) {
raw_debug_ostream Out;
+ Out << LLVMGetValueName(func) << ":\n";
disassemble(code, Out);
}