Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/CodeGen/CGCUDARuntime.h
Line
Count
Source
1
//===----- CGCUDARuntime.h - Interface to CUDA Runtimes ---------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This provides an abstract class for CUDA code generation.  Concrete
10
// subclasses of this implement code generation for specific CUDA
11
// runtime libraries.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
16
#define LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
17
18
#include "llvm/ADT/StringRef.h"
19
20
namespace llvm {
21
class Function;
22
class GlobalVariable;
23
}
24
25
namespace clang {
26
27
class CUDAKernelCallExpr;
28
class VarDecl;
29
30
namespace CodeGen {
31
32
class CodeGenFunction;
33
class CodeGenModule;
34
class FunctionArgList;
35
class ReturnValueSlot;
36
class RValue;
37
38
class CGCUDARuntime {
39
protected:
40
  CodeGenModule &CGM;
41
42
public:
43
  // Global variable properties that must be passed to CUDA runtime.
44
  enum DeviceVarFlags {
45
    ExternDeviceVar = 0x01,   // extern
46
    ConstantDeviceVar = 0x02, // __constant__
47
  };
48
49
103
  CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {}
50
  virtual ~CGCUDARuntime();
51
52
  virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF,
53
                                        const CUDAKernelCallExpr *E,
54
                                        ReturnValueSlot ReturnValue);
55
56
  /// Emits a kernel launch stub.
57
  virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) = 0;
58
  virtual void registerDeviceVar(const VarDecl *VD, llvm::GlobalVariable &Var,
59
                                 unsigned Flags) = 0;
60
61
  /// Constructs and returns a module initialization function or nullptr if it's
62
  /// not needed. Must be called after all kernels have been emitted.
63
  virtual llvm::Function *makeModuleCtorFunction() = 0;
64
65
  /// Returns a module cleanup function or nullptr if it's not needed.
66
  /// Must be called after ModuleCtorFunction
67
  virtual llvm::Function *makeModuleDtorFunction() = 0;
68
69
  /// Construct and return the stub name of a kernel.
70
  virtual std::string getDeviceStubName(llvm::StringRef Name) const = 0;
71
};
72
73
/// Creates an instance of a CUDA runtime class.
74
CGCUDARuntime *CreateNVCUDARuntime(CodeGenModule &CGM);
75
76
}
77
}
78
79
#endif