gallivm: Fix build with llvm-3.0
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_debug.cpp
index 49388aadcc81e5846c9307a7f0f39e3311b72354..29dfb868d95a521bccb2169100f91cda9c0a42c2 100644 (file)
 #include <llvm/Target/TargetInstrInfo.h>
 #include <llvm/Support/raw_ostream.h>
 #include <llvm/Support/MemoryObject.h>
+
+#if HAVE_LLVM >= 0x0209
+#include <llvm/Support/Host.h>
+#else
 #include <llvm/System/Host.h>
+#endif
 
 #if HAVE_LLVM >= 0x0207
 #include <llvm/MC/MCDisassembler.h>
@@ -111,6 +116,7 @@ lp_debug_dump_value(LLVMValueRef value)
 }
 
 
+#if HAVE_LLVM >= 0x0207
 /*
  * MemoryObject wrapper around a buffer of memory, to be used by MC
  * disassembler.
@@ -145,6 +151,7 @@ public:
       return 0;
    }
 };
+#endif /* HAVE_LLVM >= 0x0207 */
 
 
 /*
@@ -201,7 +208,11 @@ lp_disassemble(const void* func)
 
    raw_debug_ostream Out;
 
+#if HAVE_LLVM >= 0x0300
+   unsigned int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
+#else
    int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
+#endif
 #if HAVE_LLVM >= 0x0208
    OwningPtr<MCInstPrinter> Printer(
          T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo));
@@ -214,7 +225,11 @@ lp_disassemble(const void* func)
       return;
    }
 
+#if HAVE_LLVM >= 0x0300
+   TargetMachine *TM = T->createTargetMachine(Triple, sys::getHostCPUName(), "");
+#else
    TargetMachine *TM = T->createTargetMachine(Triple, "");
+#endif
 
    const TargetInstrInfo *TII = TM->getInstrInfo();
 
@@ -274,7 +289,11 @@ lp_disassemble(const void* func)
 
       pc += Size;
 
+#if HAVE_LLVM >= 0x0300
+      const MCInstrDesc &TID = TII->get(Inst.getOpcode());
+#else
       const TargetInstrDesc &TID = TII->get(Inst.getOpcode());
+#endif
 
       /*
        * Keep track of forward jumps to a nearby address.
@@ -348,8 +367,8 @@ lp_disassemble(const void* func)
    }
 
    debug_printf("\n");
-#else
+#else /* HAVE_LLVM < 0x0207 */
    (void)func;
-#endif
+#endif /* HAVE_LLVM < 0x0207 */
 }