clang  6.0.0svn
Go to the documentation of this file.
1 //===----- CGCUDARuntime.cpp - Interface to CUDA Runtimes -----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This provides an abstract class for CUDA code generation. Concrete
11 // subclasses of this implement code generation for specific CUDA
12 // runtime libraries.
13 //
14 //===----------------------------------------------------------------------===//
16 #include "CGCUDARuntime.h"
17 #include "CGCall.h"
18 #include "CodeGenFunction.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/ExprCXX.h"
22 using namespace clang;
23 using namespace CodeGen;
28  const CUDAKernelCallExpr *E,
29  ReturnValueSlot ReturnValue) {
30  llvm::BasicBlock *ConfigOKBlock = CGF.createBasicBlock("kcall.configok");
31  llvm::BasicBlock *ContBlock = CGF.createBasicBlock("kcall.end");
34  CGF.EmitBranchOnBoolExpr(E->getConfig(), ContBlock, ConfigOKBlock,
35  /*TrueCount=*/0);
37  eval.begin(CGF);
38  CGF.EmitBlock(ConfigOKBlock);
39  CGF.EmitSimpleCallExpr(E, ReturnValue);
40  CGF.EmitBranch(ContBlock);
42  CGF.EmitBlock(ContBlock);
43  eval.end(CGF);
45  return RValue::get(nullptr);
46 }
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Definition: CGCall.h:281
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
Defines the clang::Expr interface and subclasses for C++ expressions.
An object to manage conditionally-evaluated expressions.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF, const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
const CallExpr * getConfig() const
Definition: ExprCXX.h:216
RValue EmitSimpleCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
Emit a CallExpr without considering whether it might be a subclass.
Definition: CGExpr.cpp:4209
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
Definition: CGValue.h:39
Dataflow Directional Tag Classes.
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:203
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
Definition: CGStmt.cpp:436
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block, taking care to avoid creation of branches from dummy blocks.
Definition: CGStmt.cpp:456
static RValue get(llvm::Value *V)
Definition: CGValue.h:86