本文整理汇总了C++中Sema::IdentifyCUDATarget方法的典型用法代码示例。如果您正苦于以下问题:C++ Sema::IdentifyCUDATarget方法的具体用法?C++ Sema::IdentifyCUDATarget怎么用?C++ Sema::IdentifyCUDATarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sema
的用法示例。
在下文中一共展示了Sema::IdentifyCUDATarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsKnownEmitted
// Do we know that we will eventually codegen the given function?
static bool IsKnownEmitted(Sema &S, FunctionDecl *FD) {
// Templates are emitted when they're instantiated.
if (FD->isDependentContext())
return false;
// When compiling for device, host functions are never emitted. Similarly,
// when compiling for host, device and global functions are never emitted.
// (Technically, we do emit a host-side stub for global functions, but this
// doesn't count for our purposes here.)
Sema::CUDAFunctionTarget T = S.IdentifyCUDATarget(FD);
if (S.getLangOpts().CUDAIsDevice && T == Sema::CFT_Host)
return false;
if (!S.getLangOpts().CUDAIsDevice &&
(T == Sema::CFT_Device || T == Sema::CFT_Global))
return false;
// Check whether this function is externally visible -- if so, it's
// known-emitted.
//
// We have to check the GVA linkage of the function's *definition* -- if we
// only have a declaration, we don't know whether or not the function will be
// emitted, because (say) the definition could include "inline".
FunctionDecl *Def = FD->getDefinition();
if (Def &&
!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
return true;
// Otherwise, the function is known-emitted if it's in our set of
// known-emitted functions.
return S.DeviceKnownEmittedFns.count(FD) > 0;
}
示例2: IsKnownEmitted
// Do we know that we will eventually codegen the given function?
static bool IsKnownEmitted(Sema &S, FunctionDecl *FD) {
// Templates are emitted when they're instantiated.
if (FD->isDependentContext())
return false;
// When compiling for device, host functions are never emitted. Similarly,
// when compiling for host, device and global functions are never emitted.
// (Technically, we do emit a host-side stub for global functions, but this
// doesn't count for our purposes here.)
Sema::CUDAFunctionTarget T = S.IdentifyCUDATarget(FD);
if (S.getLangOpts().CUDAIsDevice && T == Sema::CFT_Host)
return false;
if (!S.getLangOpts().CUDAIsDevice &&
(T == Sema::CFT_Device || T == Sema::CFT_Global))
return false;
// Externally-visible and similar functions are always emitted.
if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
return true;
// Otherwise, the function is known-emitted if it's in our set of
// known-emitted functions.
return S.CUDAKnownEmittedFns.count(FD) > 0;
}