draw: hack around weird primitive id input in gs
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_debug.cpp
index 5d6d45d61ecd0366bb1bcf076309242d1b9416a5..b6b52c80efcab2fdb07c68116ff6d910bb9c16ca 100644 (file)
 #include <llvm/Support/Format.h>
 #include <llvm/Support/MemoryObject.h>
 
+#if HAVE_LLVM >= 0x0306
+#include <llvm/Target/TargetSubtargetInfo.h>
+#endif
+
 #include <llvm/Support/TargetRegistry.h>
 #include <llvm/MC/MCSubtargetInfo.h>
 
 #include <llvm/Support/Host.h>
 
+#if HAVE_LLVM >= 0x0303
+#include <llvm/IR/Module.h>
+#else
+#include <llvm/Module.h>
+#endif
+
 #include <llvm/MC/MCDisassembler.h>
 #include <llvm/MC/MCAsmInfo.h>
 #include <llvm/MC/MCInst.h>
 #include <llvm/MC/MCInstPrinter.h>
 #include <llvm/MC/MCRegisterInfo.h>
 
-#if HAVE_LLVM >= 0x0303
+#if HAVE_LLVM >= 0x0305
+#define OwningPtr std::unique_ptr
+#elif HAVE_LLVM >= 0x0303
 #include <llvm/ADT/OwningPtr.h>
 #endif
 
@@ -111,6 +123,13 @@ raw_debug_ostream::write_impl(const char *Ptr, size_t Size)
 }
 
 
+extern "C" const char *
+lp_get_module_id(LLVMModuleRef module)
+{
+   return llvm::unwrap(module)->getModuleIdentifier().c_str();
+}
+
+
 /**
  * Same as LLVMDumpValue, but through our debugging channels.
  */
@@ -256,7 +275,11 @@ disassemble(const void* func, llvm::raw_ostream & Out)
 #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