CGCUDARuntime.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include "CGCUDARuntime.h"
  15. #include "CGCall.h"
  16. #include "CodeGenFunction.h"
  17. #include "clang/AST/Decl.h"
  18. #include "clang/AST/ExprCXX.h"
  19. using namespace clang;
  20. using namespace CodeGen;
  21. CGCUDARuntime::~CGCUDARuntime() {}
  22. RValue CGCUDARuntime::EmitCUDAKernelCallExpr(CodeGenFunction &CGF,
  23. const CUDAKernelCallExpr *E,
  24. ReturnValueSlot ReturnValue) {
  25. llvm::BasicBlock *ConfigOKBlock = CGF.createBasicBlock("kcall.configok");
  26. llvm::BasicBlock *ContBlock = CGF.createBasicBlock("kcall.end");
  27. CodeGenFunction::ConditionalEvaluation eval(CGF);
  28. CGF.EmitBranchOnBoolExpr(E->getConfig(), ContBlock, ConfigOKBlock,
  29. /*TrueCount=*/0);
  30. eval.begin(CGF);
  31. CGF.EmitBlock(ConfigOKBlock);
  32. CGF.EmitSimpleCallExpr(E, ReturnValue);
  33. CGF.EmitBranch(ContBlock);
  34. CGF.EmitBlock(ContBlock);
  35. eval.end(CGF);
  36. return RValue::get(nullptr);
  37. }