Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 1 | //===----- CGCUDARuntime.cpp - Interface to CUDA Runtimes -----------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 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 | #include "CGCUDARuntime.h" |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 16 | #include "CGCall.h" |
| 17 | #include "CodeGenFunction.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 18 | #include "clang/AST/Decl.h" |
| 19 | #include "clang/AST/ExprCXX.h" |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace clang; |
| 22 | using namespace CodeGen; |
| 23 | |
Angel Garcia Gomez | 637d1e6 | 2015-10-20 13:23:58 +0000 | [diff] [blame] | 24 | CGCUDARuntime::~CGCUDARuntime() {} |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 25 | |
| 26 | RValue 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 Bogner | ef512b9 | 2014-01-06 22:27:43 +0000 | [diff] [blame] | 33 | CGF.EmitBranchOnBoolExpr(E->getConfig(), ContBlock, ConfigOKBlock, |
| 34 | /*TrueCount=*/0); |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 35 | |
| 36 | eval.begin(CGF); |
| 37 | CGF.EmitBlock(ConfigOKBlock); |
John McCall | b92ab1a | 2016-10-26 23:46:34 +0000 | [diff] [blame] | 38 | CGF.EmitSimpleCallExpr(E, ReturnValue); |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 39 | CGF.EmitBranch(ContBlock); |
| 40 | |
| 41 | CGF.EmitBlock(ContBlock); |
| 42 | eval.end(CGF); |
| 43 | |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 44 | return RValue::get(nullptr); |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 45 | } |