clang  14.0.0git
CGCUDARuntime.cpp
Go to the documentation of this file.
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/Decl.h"
19 #include "clang/AST/ExprCXX.h"
20 
21 using namespace clang;
22 using namespace CodeGen;
23 
25 
27  const CUDAKernelCallExpr *E,
28  ReturnValueSlot ReturnValue) {
29  llvm::BasicBlock *ConfigOKBlock = CGF.createBasicBlock("kcall.configok");
30  llvm::BasicBlock *ContBlock = CGF.createBasicBlock("kcall.end");
31 
33  CGF.EmitBranchOnBoolExpr(E->getConfig(), ContBlock, ConfigOKBlock,
34  /*TrueCount=*/0);
35 
36  eval.begin(CGF);
37  CGF.EmitBlock(ConfigOKBlock);
38  CGF.EmitSimpleCallExpr(E, ReturnValue);
39  CGF.EmitBranch(ContBlock);
40 
41  CGF.EmitBlock(ContBlock);
42  eval.end(CGF);
43 
44  return RValue::get(nullptr);
45 }
clang::CodeGen::RValue
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
Definition: CGValue.h:39
CodeGenFunction.h
clang::CodeGen::CodeGenFunction::createBasicBlock
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
Definition: CodeGenFunction.h:2394
Decl.h
clang::CodeGen::ReturnValueSlot
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
Definition: CGCall.h:362
CGCall.h
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount, Stmt::Likelihood LH=Stmt::LH_None)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
Definition: CodeGenFunction.cpp:1632
clang::CodeGen::CodeGenFunction::ConditionalEvaluation::begin
void begin(CodeGenFunction &CGF)
Definition: CodeGenFunction.h:1153
clang::CodeGen::CGCUDARuntime::EmitCUDAKernelCallExpr
virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF, const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
Definition: CGCUDARuntime.cpp:26
clang::CodeGen::CodeGenFunction::EmitSimpleCallExpr
RValue EmitSimpleCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
Emit a CallExpr without considering whether it might be a subclass.
Definition: CGExpr.cpp:4889
ExprCXX.h
clang::CodeGen::CodeGenFunction::ConditionalEvaluation
An object to manage conditionally-evaluated expressions.
Definition: CodeGenFunction.h:1146
clang::CodeGen::CodeGenFunction
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Definition: CodeGenFunction.h:235
clang::CUDAKernelCallExpr
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:232
clang
Definition: CalledOnceCheck.h:17
clang::CUDAKernelCallExpr::getConfig
const CallExpr * getConfig() const
Definition: ExprCXX.h:258
clang::CodeGen::RValue::get
static RValue get(llvm::Value *V)
Definition: CGValue.h:86
CGCUDARuntime.h
clang::CodeGen::CGCUDARuntime::~CGCUDARuntime
virtual ~CGCUDARuntime()
Definition: CGCUDARuntime.cpp:24
clang::CodeGen::CodeGenFunction::EmitBlock
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
Definition: CGStmt.cpp:529
clang::CodeGen::CodeGenFunction::EmitBranch
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block,...
Definition: CGStmt.cpp:549
clang::CodeGen::CodeGenFunction::ConditionalEvaluation::end
void end(CodeGenFunction &CGF)
Definition: CodeGenFunction.h:1159