1 //===----- CGCUDARuntime.h - Interface to CUDA Runtimes ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This provides an abstract class for CUDA code generation. Concrete
11 // subclasses of this implement code generation for specific CUDA
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
17 #define LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
26 class CUDAKernelCallExpr;
30 class CodeGenFunction;
32 class FunctionArgList;
33 class ReturnValueSlot;
41 // Global variable properties that must be passed to CUDA runtime.
43 ExternDeviceVar = 0x01, // extern
44 ConstantDeviceVar = 0x02, // __constant__
47 CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {}
48 virtual ~CGCUDARuntime();
50 virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF,
51 const CUDAKernelCallExpr *E,
52 ReturnValueSlot ReturnValue);
54 /// Emits a kernel launch stub.
55 virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) = 0;
56 virtual void registerDeviceVar(llvm::GlobalVariable &Var, unsigned Flags) = 0;
58 /// Constructs and returns a module initialization function or nullptr if it's
59 /// not needed. Must be called after all kernels have been emitted.
60 virtual llvm::Function *makeModuleCtorFunction() = 0;
62 /// Returns a module cleanup function or nullptr if it's not needed.
63 /// Must be called after ModuleCtorFunction
64 virtual llvm::Function *makeModuleDtorFunction() = 0;
67 /// Creates an instance of a CUDA runtime class.
68 CGCUDARuntime *CreateNVCUDARuntime(CodeGenModule &CGM);