CGCUDARuntime.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //===----- CGCUDARuntime.h - Interface to CUDA Runtimes ---------*- C++ -*-===//
  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 CUDA code generation. Concrete
  11. // subclasses of this implement code generation for specific CUDA
  12. // runtime libraries.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
  16. #define LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
  17. namespace llvm {
  18. class Function;
  19. }
  20. namespace clang {
  21. class CUDAKernelCallExpr;
  22. namespace CodeGen {
  23. class CodeGenFunction;
  24. class CodeGenModule;
  25. class FunctionArgList;
  26. class ReturnValueSlot;
  27. class RValue;
  28. class CGCUDARuntime {
  29. protected:
  30. CodeGenModule &CGM;
  31. public:
  32. CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {}
  33. virtual ~CGCUDARuntime();
  34. virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF,
  35. const CUDAKernelCallExpr *E,
  36. ReturnValueSlot ReturnValue);
  37. /// Emits a kernel launch stub.
  38. virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) = 0;
  39. /// Constructs and returns a module initialization function or nullptr if it's
  40. /// not needed. Must be called after all kernels have been emitted.
  41. virtual llvm::Function *makeModuleCtorFunction() = 0;
  42. /// Returns a module cleanup function or nullptr if it's not needed.
  43. /// Must be called after ModuleCtorFunction
  44. virtual llvm::Function *makeModuleDtorFunction() = 0;
  45. };
  46. /// Creates an instance of a CUDA runtime class.
  47. CGCUDARuntime *CreateNVCUDARuntime(CodeGenModule &CGM);
  48. }
  49. }
  50. #endif