1//===----- CIRGenCUDARuntime.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 "CIRGenCUDARuntime.h"
16#include "CIRGenBuilder.h"
17#include "CIRGenFunction.h"
18#include "clang/AST/ExprCXX.h"
19
20using namespace clang;
21using namespace CIRGen;
22
23CIRGenCUDARuntime::~CIRGenCUDARuntime() {}
24
25RValue CIRGenCUDARuntime::emitCUDAKernelCallExpr(CIRGenFunction &cgf,
26 const CUDAKernelCallExpr *expr,
27 ReturnValueSlot retValue) {
28
29 mlir::Location loc = cgf.getLoc(srcLoc: SourceLocation{});
30
31 cgf.emitIfOnBoolExpr(
32 cond: expr->getConfig(),
33 thenBuilder: [&](mlir::OpBuilder &b, mlir::Location l) { cir::YieldOp::create(builder&: b, location: l); },
34 thenLoc: loc,
35 elseBuilder: [&](mlir::OpBuilder &b, mlir::Location l) {
36 CIRGenCallee callee = cgf.emitCallee(e: expr->getCallee());
37 cgf.emitCall(calleeTy: expr->getCallee()->getType(), callee, e: expr, returnValue: retValue);
38 cir::YieldOp::create(builder&: b, location: l);
39 },
40 elseLoc: loc);
41
42 return RValue::get(v: nullptr);
43}
44