blob: c14a9d3f2bbbcf99d01dd41a9389683dd809bd28 [file] [log] [blame]
Peter Collingbournefe883422011-10-06 18:29:37 +00001//===----- CGCUDARuntime.cpp - Interface to CUDA Runtimes -----------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Peter Collingbournefe883422011-10-06 18:29:37 +00006//
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#include "CGCUDARuntime.h"
Peter Collingbournefe883422011-10-06 18:29:37 +000016#include "CGCall.h"
17#include "CodeGenFunction.h"
Chandler Carruth3a022472012-12-04 09:13:33 +000018#include "clang/AST/Decl.h"
19#include "clang/AST/ExprCXX.h"
Peter Collingbournefe883422011-10-06 18:29:37 +000020
21using namespace clang;
22using namespace CodeGen;
23
Angel Garcia Gomez637d1e62015-10-20 13:23:58 +000024CGCUDARuntime::~CGCUDARuntime() {}
Peter Collingbournefe883422011-10-06 18:29:37 +000025
26RValue CGCUDARuntime::EmitCUDAKernelCallExpr(CodeGenFunction &CGF,
27 const CUDAKernelCallExpr *E,
28 ReturnValueSlot ReturnValue) {
29 llvm::BasicBlock *ConfigOKBlock = CGF.createBasicBlock("kcall.configok");
30 llvm::BasicBlock *ContBlock = CGF.createBasicBlock("kcall.end");
31
32 CodeGenFunction::ConditionalEvaluation eval(CGF);
Justin Bogneref512b92014-01-06 22:27:43 +000033 CGF.EmitBranchOnBoolExpr(E->getConfig(), ContBlock, ConfigOKBlock,
34 /*TrueCount=*/0);
Peter Collingbournefe883422011-10-06 18:29:37 +000035
36 eval.begin(CGF);
37 CGF.EmitBlock(ConfigOKBlock);
John McCallb92ab1a2016-10-26 23:46:34 +000038 CGF.EmitSimpleCallExpr(E, ReturnValue);
Peter Collingbournefe883422011-10-06 18:29:37 +000039 CGF.EmitBranch(ContBlock);
40
41 CGF.EmitBlock(ContBlock);
42 eval.end(CGF);
43
Craig Topper8a13c412014-05-21 05:09:00 +000044 return RValue::get(nullptr);
Peter Collingbournefe883422011-10-06 18:29:37 +000045}