clang  10.0.0svn
CGCUDARuntime.h
Go to the documentation of this file.
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 
39 protected:
41 
42 public:
43  // Global variable properties that must be passed to CUDA runtime.
45  ExternDeviceVar = 0x01, // extern
46  ConstantDeviceVar = 0x02, // __constant__
47  };
48 
49  CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {}
50  virtual ~CGCUDARuntime();
51 
52  virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF,
53  const CUDAKernelCallExpr *E,
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.
75 
76 }
77 }
78 
79 #endif
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Definition: CGCall.h:363
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Definition: Dominators.h:30
constexpr XRayInstrMask Function
Definition: XRayInstr.h:38
bool ReturnValue(const T &V, APValue &R)
Convers a value to an APValue.
Definition: Interp.h:41
Represents a variable declaration or definition.
Definition: Decl.h:812
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
Definition: CGValue.h:38
FunctionArgList - Type for representing both the decl and type of parameters to a function...
Definition: CGCall.h:358
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:223
CGCUDARuntime * CreateNVCUDARuntime(CodeGenModule &CGM)
Creates an instance of a CUDA runtime class.
Definition: CGCUDANV.cpp:801
CGCUDARuntime(CodeGenModule &CGM)
Definition: CGCUDARuntime.h:49