freedreno/ir3: fix register usage calculations
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_debug.cpp
index 621290fdfbdee9ab44066f13bddf5467a2608039..402d29e9681d52a6236e86fcf0a85980c90a741e 100644 (file)
 #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>
@@ -47,7 +52,9 @@
 #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
 
@@ -136,6 +143,8 @@ lp_debug_dump_value(LLVMValueRef value)
 }
 
 
+#if HAVE_LLVM < 0x0306
+
 /*
  * MemoryObject wrapper around a buffer of memory, to be used by MC
  * disassembler.
@@ -171,6 +180,8 @@ public:
    }
 };
 
+#endif /* HAVE_LLVM < 0x0306 */
+
 
 /*
  * Disassemble a function, using the LLVM MC disassembler.
@@ -265,12 +276,20 @@ 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
     */
+#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;
@@ -400,6 +419,7 @@ disassemble(const void* func, llvm::raw_ostream & Out)
 extern "C" void
 lp_disassemble(LLVMValueRef func, const void *code) {
    raw_debug_ostream Out;
+   Out << LLVMGetValueName(func) << ":\n";
    disassemble(code, Out);
 }