beignet-1.3.2-llvm9-support.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. --- a/CMake/FindLLVM.cmake
  2. +++ b/CMake/FindLLVM.cmake
  3. @@ -116,6 +116,9 @@ macro(add_one_lib name)
  4. endmacro()
  5. #Assume clang lib path same as llvm lib path
  6. +if (LLVM_VERSION_NODOT VERSION_GREATER 80)
  7. +add_one_lib("clang-cpp")
  8. +endif (LLVM_VERSION_NODOT VERSION_GREATER 80)
  9. add_one_lib("clangCodeGen")
  10. add_one_lib("clangFrontend")
  11. add_one_lib("clangSerialization")
  12. --- a/backend/src/llvm/llvm_intrinsic_lowering.cpp
  13. +++ b/backend/src/llvm/llvm_intrinsic_lowering.cpp
  14. @@ -77,7 +77,11 @@ namespace gbe {
  15. std::vector<Type *> ParamTys;
  16. for (Value** I = ArgBegin; I != ArgEnd; ++I)
  17. ParamTys.push_back((*I)->getType());
  18. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  19. + FunctionCallee FCache = M->getOrInsertFunction(NewFn,
  20. +#else
  21. Constant* FCache = M->getOrInsertFunction(NewFn,
  22. +#endif
  23. FunctionType::get(RetTy, ParamTys, false));
  24. IRBuilder<> Builder(CI->getParent(), BasicBlock::iterator(CI));
  25. --- a/backend/src/llvm/llvm_sampler_fix.cpp
  26. +++ b/backend/src/llvm/llvm_sampler_fix.cpp
  27. @@ -82,7 +82,11 @@ namespace gbe {
  28. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 40
  29. Module *M = I->getParent()->getParent()->getParent();
  30. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
  31. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  32. + FunctionCallee samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
  33. +#else
  34. Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
  35. +#endif
  36. #else
  37. Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType(), nullptr);
  38. #endif
  39. @@ -124,7 +128,11 @@ namespace gbe {
  40. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 40
  41. Module *M = I->getParent()->getParent()->getParent();
  42. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
  43. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  44. + FunctionCallee samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
  45. +#else
  46. Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
  47. +#endif
  48. #else
  49. Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType(), nullptr);
  50. #endif
  51. --- a/backend/src/llvm/llvm_profiling.cpp
  52. +++ b/backend/src/llvm/llvm_profiling.cpp
  53. @@ -163,10 +163,18 @@ namespace gbe
  54. // __gen_ocl_store_timestamp(int nth, int type);
  55. Value *Args[2] = {ConstantInt::get(intTy, pointNum++), ConstantInt::get(intTy, profilingType)};
  56. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
  57. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  58. + builder->CreateCall(module->getOrInsertFunction(
  59. +#else
  60. builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
  61. +#endif
  62. "__gen_ocl_calc_timestamp", Type::getVoidTy(module->getContext()),
  63. IntegerType::getInt32Ty(module->getContext()),
  64. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  65. + IntegerType::getInt32Ty(module->getContext())),
  66. +#else
  67. IntegerType::getInt32Ty(module->getContext()))),
  68. +#endif
  69. ArrayRef<Value*>(Args));
  70. #else
  71. builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
  72. @@ -185,10 +193,18 @@ namespace gbe
  73. Value *Args2[2] = {profilingBuf, ConstantInt::get(intTy, profilingType)};
  74. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
  75. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  76. + builder->CreateCall(module->getOrInsertFunction(
  77. +#else
  78. builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
  79. +#endif
  80. "__gen_ocl_store_profiling", Type::getVoidTy(module->getContext()),
  81. ptrTy,
  82. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  83. + IntegerType::getInt32Ty(module->getContext())),
  84. +#else
  85. IntegerType::getInt32Ty(module->getContext()))),
  86. +#endif
  87. ArrayRef<Value*>(Args2));
  88. #else
  89. builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
  90. --- a/backend/src/llvm/llvm_device_enqueue.cpp
  91. +++ b/backend/src/llvm/llvm_device_enqueue.cpp
  92. @@ -398,8 +398,13 @@ namespace gbe {
  93. std::vector<Type *> ParamTys;
  94. for (Value** iter = args.begin(); iter != args.end(); ++iter)
  95. ParamTys.push_back((*iter)->getType());
  96. +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
  97. + CallInst* newCI = builder.CreateCall(mod->getOrInsertFunction(
  98. + "__gen_enqueue_kernel_slm", FunctionType::get(intTy, ParamTys, false)), args);
  99. +#else
  100. CallInst* newCI = builder.CreateCall(cast<llvm::Function>(mod->getOrInsertFunction(
  101. "__gen_enqueue_kernel_slm", FunctionType::get(intTy, ParamTys, false))), args);
  102. +#endif
  103. CI->replaceAllUsesWith(newCI);
  104. deadInsnSet.insert(CI);
  105. }