added compile-time constant __is_nvptx_traget that can be used with stdlib.ispc
This commit is contained in:
@@ -1181,6 +1181,9 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod
|
|||||||
lDefineConstantInt("__have_native_transcendentals", g->target->hasTranscendentals(),
|
lDefineConstantInt("__have_native_transcendentals", g->target->hasTranscendentals(),
|
||||||
module, symbolTable);
|
module, symbolTable);
|
||||||
|
|
||||||
|
lDefineConstantInt("__is_nvptx_target", (int)(g->target->getISA() == Target::NVPTX),
|
||||||
|
module, symbolTable);
|
||||||
|
|
||||||
if (g->forceAlignment != -1) {
|
if (g->forceAlignment != -1) {
|
||||||
llvm::GlobalVariable *alignment = module->getGlobalVariable("memory_alignment", true);
|
llvm::GlobalVariable *alignment = module->getGlobalVariable("memory_alignment", true);
|
||||||
alignment->setInitializer(LLVMInt32(g->forceAlignment));
|
alignment->setInitializer(LLVMInt32(g->forceAlignment));
|
||||||
|
|||||||
@@ -521,6 +521,9 @@ __declspec(safe)
|
|||||||
static inline uniform int popcnt(bool v) {
|
static inline uniform int popcnt(bool v) {
|
||||||
// As with any() and all(), only count across the active lanes
|
// As with any() and all(), only count across the active lanes
|
||||||
#if (ISPC_MASK_BITS == 1)
|
#if (ISPC_MASK_BITS == 1)
|
||||||
|
if (__is_nvptx_target)
|
||||||
|
return __popcnt_int64(__movmsk_ptx(v & __mask));
|
||||||
|
else
|
||||||
return __popcnt_int64(__movmsk(v & __mask));
|
return __popcnt_int64(__movmsk(v & __mask));
|
||||||
#else
|
#else
|
||||||
return __popcnt_int64(__movmsk((UIntMaskType)__sext_varying_bool(v) & __mask));
|
return __popcnt_int64(__movmsk((UIntMaskType)__sext_varying_bool(v) & __mask));
|
||||||
|
|||||||
Reference in New Issue
Block a user