1fe883422SPeter Collingbourne //===----- CGCUDARuntime.cpp - Interface to CUDA Runtimes -----------------===//
2fe883422SPeter Collingbourne //
3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe883422SPeter Collingbourne //
7fe883422SPeter Collingbourne //===----------------------------------------------------------------------===//
8fe883422SPeter Collingbourne //
9fe883422SPeter Collingbourne // This provides an abstract class for CUDA code generation.  Concrete
10fe883422SPeter Collingbourne // subclasses of this implement code generation for specific CUDA
11fe883422SPeter Collingbourne // runtime libraries.
12fe883422SPeter Collingbourne //
13fe883422SPeter Collingbourne //===----------------------------------------------------------------------===//
14fe883422SPeter Collingbourne 
15fe883422SPeter Collingbourne #include "CGCUDARuntime.h"
16fe883422SPeter Collingbourne #include "CGCall.h"
17fe883422SPeter Collingbourne #include "CodeGenFunction.h"
183a02247dSChandler Carruth #include "clang/AST/Decl.h"
193a02247dSChandler Carruth #include "clang/AST/ExprCXX.h"
20fe883422SPeter Collingbourne 
21fe883422SPeter Collingbourne using namespace clang;
22fe883422SPeter Collingbourne using namespace CodeGen;
23fe883422SPeter Collingbourne 
~CGCUDARuntime()24637d1e66SAngel Garcia Gomez CGCUDARuntime::~CGCUDARuntime() {}
25fe883422SPeter Collingbourne 
EmitCUDAKernelCallExpr(CodeGenFunction & CGF,const CUDAKernelCallExpr * E,ReturnValueSlot ReturnValue)26fe883422SPeter Collingbourne RValue CGCUDARuntime::EmitCUDAKernelCallExpr(CodeGenFunction &CGF,
27fe883422SPeter Collingbourne                                              const CUDAKernelCallExpr *E,
28fe883422SPeter Collingbourne                                              ReturnValueSlot ReturnValue) {
29fe883422SPeter Collingbourne   llvm::BasicBlock *ConfigOKBlock = CGF.createBasicBlock("kcall.configok");
30fe883422SPeter Collingbourne   llvm::BasicBlock *ContBlock = CGF.createBasicBlock("kcall.end");
31fe883422SPeter Collingbourne 
32fe883422SPeter Collingbourne   CodeGenFunction::ConditionalEvaluation eval(CGF);
33ef512b99SJustin Bogner   CGF.EmitBranchOnBoolExpr(E->getConfig(), ContBlock, ConfigOKBlock,
34ef512b99SJustin Bogner                            /*TrueCount=*/0);
35fe883422SPeter Collingbourne 
36fe883422SPeter Collingbourne   eval.begin(CGF);
37fe883422SPeter Collingbourne   CGF.EmitBlock(ConfigOKBlock);
38b92ab1afSJohn McCall   CGF.EmitSimpleCallExpr(E, ReturnValue);
39fe883422SPeter Collingbourne   CGF.EmitBranch(ContBlock);
40fe883422SPeter Collingbourne 
41fe883422SPeter Collingbourne   CGF.EmitBlock(ContBlock);
42fe883422SPeter Collingbourne   eval.end(CGF);
43fe883422SPeter Collingbourne 
448a13c418SCraig Topper   return RValue::get(nullptr);
45fe883422SPeter Collingbourne }
46