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 16#ifndef LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H 17#define LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H 18 19namespace llvm { 20class Function; 21} 22 23namespace clang { 24 25class CUDAKernelCallExpr; 26 27namespace CodeGen { 28 29class CodeGenFunction; 30class CodeGenModule; 31class FunctionArgList; 32class ReturnValueSlot; 33class RValue; 34 35class CGCUDARuntime { 36protected: 37 CodeGenModule &CGM; 38 39public: 40 CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {} 41 virtual ~CGCUDARuntime(); 42 43 virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF, 44 const CUDAKernelCallExpr *E, 45 ReturnValueSlot ReturnValue); 46 47 /// Emits a kernel launch stub. 48 virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) = 0; 49 50 /// Constructs and returns a module initialization function or nullptr if it's 51 /// not needed. Must be called after all kernels have been emitted. 52 virtual llvm::Function *makeModuleCtorFunction() = 0; 53 54 /// Returns a module cleanup function or nullptr if it's not needed. 55 /// Must be called after ModuleCtorFunction 56 virtual llvm::Function *makeModuleDtorFunction() = 0; 57}; 58 59/// Creates an instance of a CUDA runtime class. 60CGCUDARuntime *CreateNVCUDARuntime(CodeGenModule &CGM); 61 62} 63} 64 65#endif 66