added mask for tasking function

This commit is contained in:
Evghenii
2014-01-06 16:18:28 +01:00
parent 7fbe2eba59
commit 3972d740a6
4 changed files with 15 additions and 9 deletions

15
ctx.cpp
View File

@@ -3617,8 +3617,12 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
AssertPos(currentPos, llvm::isa<llvm::Function>(callee));
std::vector<llvm::Type*> argTypes;
for (unsigned int i = 0; i < argVals.size(); i++)
argTypes.push_back(argVals[i]->getType());
llvm::Function *F = llvm::dyn_cast<llvm::Function>(callee);
const unsigned int nArgs = F->arg_size();
llvm::Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
for (; I != E; ++I)
argTypes.push_back(I->getType());
llvm::Type *st = llvm::StructType::get(*g->ctx, argTypes);
llvm::StructType *argStructType = static_cast<llvm::StructType *>(st);
llvm::Value *structSize = g->target->SizeOf(argStructType, bblock);
@@ -3661,6 +3665,13 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
// don't need to do masked store here, I think
StoreInst(argVals[i], ptr);
}
if (nArgs == argVals.size() + 1) {
// copy in the mask
llvm::Value *mask = GetFullMask();
llvm::Value *ptr = AddElementOffset(argmem, argVals.size(), NULL,
"funarg_mask");
StoreInst(mask, ptr);
}
BranchInst(if_false);
/**********************/

View File

@@ -531,12 +531,6 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
returnType = returnType->ResolveUnboundVariability(Variability::Varying);
bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0);
#if 1 /* evghenii: without this, PTX fails on some examples, like deferred, with #if 0 */
if (isTask && g->target->getISA() == Target::NVPTX)
ds->typeQualifiers |= TYPEQUAL_UNMASKED;
#endif
bool isExternC = ds && (ds->storageClass == SC_EXTERN_C);
bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0);
bool isUnmasked = ds && ((ds->typeQualifiers & TYPEQUAL_UNMASKED) != 0);

View File

@@ -359,7 +359,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
// entire thing inside code that tests to see if the mask is all
// on, all off, or mixed. If this is a simple function, then this
// isn't worth the code bloat / overhead.
bool checkMask = (type->isTask == true && g->target->getISA() != Target::NVPTX) ||
bool checkMask = (type->isTask == true) ||
(
#if defined(LLVM_3_1)
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)

View File

@@ -795,6 +795,7 @@ Module::AddFunctionDeclaration(const std::string &name,
#else // LLVM 3.1 and 3.3+
function->addFnAttr(llvm::Attribute::AlwaysInline);
#endif
/* evghenii: fails function verification when "if" executed in nvptx target */
if (functionType->isTask && g->target->getISA() != Target::NVPTX)
// This also applies transitively to members I think?
#if defined(LLVM_3_1)