| 1 | //===----- CGCUDARuntime.cpp - Interface to CUDA Runtimes -----------------===// |
|---|---|
| 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 | #include "CGCUDARuntime.h" |
| 16 | #include "CGCall.h" |
| 17 | #include "CodeGenFunction.h" |
| 18 | #include "clang/AST/ExprCXX.h" |
| 19 | |
| 20 | using namespace clang; |
| 21 | using namespace CodeGen; |
| 22 | |
| 23 | CGCUDARuntime::~CGCUDARuntime() {} |
| 24 | |
| 25 | RValue CGCUDARuntime::EmitCUDAKernelCallExpr(CodeGenFunction &CGF, |
| 26 | const CUDAKernelCallExpr *E, |
| 27 | ReturnValueSlot ReturnValue, |
| 28 | llvm::CallBase **CallOrInvoke) { |
| 29 | llvm::BasicBlock *ConfigOKBlock = CGF.createBasicBlock(name: "kcall.configok"); |
| 30 | llvm::BasicBlock *ContBlock = CGF.createBasicBlock(name: "kcall.end"); |
| 31 | |
| 32 | CodeGenFunction::ConditionalEvaluation eval(CGF); |
| 33 | CGF.EmitBranchOnBoolExpr(Cond: E->getConfig(), TrueBlock: ContBlock, FalseBlock: ConfigOKBlock, |
| 34 | /*TrueCount=*/0); |
| 35 | |
| 36 | eval.begin(CGF); |
| 37 | CGF.EmitBlock(BB: ConfigOKBlock); |
| 38 | CGF.EmitSimpleCallExpr(E, ReturnValue, CallOrInvoke); |
| 39 | CGF.EmitBranch(Block: ContBlock); |
| 40 | |
| 41 | CGF.EmitBlock(BB: ContBlock); |
| 42 | eval.end(CGF); |
| 43 | |
| 44 | return RValue::get(V: nullptr); |
| 45 | } |
| 46 |