CGOpenCLRuntime.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //===----- CGOpenCLRuntime.cpp - Interface to OpenCL Runtimes -------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This provides an abstract class for OpenCL code generation. Concrete
  11. // subclasses of this implement code generation for specific OpenCL
  12. // runtime libraries.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #include "CGOpenCLRuntime.h"
  16. #include "CodeGenFunction.h"
  17. #include "llvm/IR/DerivedTypes.h"
  18. #include "llvm/IR/GlobalValue.h"
  19. #include <assert.h>
  20. using namespace clang;
  21. using namespace CodeGen;
  22. // HLSL Change Starts
  23. // No OpenCL codegen support, so simply skip all of this compilation.
  24. // Here are enough stubs to link the current targets.
  25. #if 0
  26. // HLSL Change Ends
  27. CGOpenCLRuntime::~CGOpenCLRuntime() {}
  28. void CGOpenCLRuntime::EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF,
  29. const VarDecl &D) {
  30. return CGF.EmitStaticVarDecl(D, llvm::GlobalValue::InternalLinkage);
  31. }
  32. llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) {
  33. assert(T->isOpenCLSpecificType() &&
  34. "Not an OpenCL specific type!");
  35. llvm::LLVMContext& Ctx = CGM.getLLVMContext();
  36. uint32_t ImgAddrSpc =
  37. CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
  38. switch (cast<BuiltinType>(T)->getKind()) {
  39. default:
  40. llvm_unreachable("Unexpected opencl builtin type!");
  41. return nullptr;
  42. case BuiltinType::OCLImage1d:
  43. return llvm::PointerType::get(llvm::StructType::create(
  44. Ctx, "opencl.image1d_t"), ImgAddrSpc);
  45. case BuiltinType::OCLImage1dArray:
  46. return llvm::PointerType::get(llvm::StructType::create(
  47. Ctx, "opencl.image1d_array_t"), ImgAddrSpc);
  48. case BuiltinType::OCLImage1dBuffer:
  49. return llvm::PointerType::get(llvm::StructType::create(
  50. Ctx, "opencl.image1d_buffer_t"), ImgAddrSpc);
  51. case BuiltinType::OCLImage2d:
  52. return llvm::PointerType::get(llvm::StructType::create(
  53. Ctx, "opencl.image2d_t"), ImgAddrSpc);
  54. case BuiltinType::OCLImage2dArray:
  55. return llvm::PointerType::get(llvm::StructType::create(
  56. Ctx, "opencl.image2d_array_t"), ImgAddrSpc);
  57. case BuiltinType::OCLImage3d:
  58. return llvm::PointerType::get(llvm::StructType::create(
  59. Ctx, "opencl.image3d_t"), ImgAddrSpc);
  60. case BuiltinType::OCLSampler:
  61. return llvm::IntegerType::get(Ctx, 32);
  62. case BuiltinType::OCLEvent:
  63. return llvm::PointerType::get(llvm::StructType::create(
  64. Ctx, "opencl.event_t"), 0);
  65. }
  66. }
  67. #endif // HLSL Change