From dbb96c1885a3fd097cc5ac9e1b5755bf2dd3184d Mon Sep 17 00:00:00 2001 From: Evghenii Date: Tue, 12 Nov 2013 13:41:03 +0100 Subject: [PATCH] need to fix launch code --- ctx.cpp | 8 ++++++-- decl.cpp | 2 +- func.cpp | 11 +++++++++-- module.cpp | 5 +++-- type.cpp | 4 +++- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ctx.cpp b/ctx.cpp index be2f55b0..45130b66 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -3524,8 +3524,9 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee, std::vector &argVals, llvm::Value *launchCount[3]){ - if (1) // if (!g->target->isPTX()) + if (!g->target->isPTX()) { + assert(0); /* evghenii: must be removed after testing is done */ if (callee == NULL) { AssertPos(currentPos, m->errorCount > 0); return NULL; @@ -3594,7 +3595,8 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee, } else /* isPTX == true */ { - assert(g->target->getISA() != Target::NVPTX64); + assert(0); /* must only be called in export */ + // assert(g->target->getISA() != Target::NVPTX64); if (callee == NULL) { AssertPos(currentPos, m->errorCount > 0); @@ -3673,8 +3675,10 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee, StoreInst(ptr_15, ptr_arrayinit_element); } +#if 0 /* evghenii:: must work uncommented */ if (argStructType->getNumElements() == argVals.size() + 1) assert(0); /* must not happen as task function is unmasked for PTX target */ +#endif // And emit the call to the user-supplied task launch function, passing // a pointer to the task function being called and a pointer to the diff --git a/decl.cpp b/decl.cpp index adb6f521..1506b416 100644 --- a/decl.cpp +++ b/decl.cpp @@ -534,7 +534,7 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) { if (isTask && g->target->isPTX()) //getISA() == Target::NVPTX64) { // ds->storageClass = SC_EXTERN_C; -// ds->typeQualifiers |= TYPEQUAL_UNMASKED; + ds->typeQualifiers |= TYPEQUAL_UNMASKED; } bool isExternC = ds && (ds->storageClass == SC_EXTERN_C); diff --git a/func.cpp b/func.cpp index 1424edfb..6417df7a 100644 --- a/func.cpp +++ b/func.cpp @@ -242,8 +242,9 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, // pointer to the structure that holds all of the arguments, the // thread index, and the thread count variables. - if (1) //if (g->target->getISA() != Target::NVPTX64) + if (!g->target->isPTX()) //if (g->target->getISA() != Target::NVPTX64) { + assert(0); /* evghenii: must be removed in final, just for test for nvptx64 target */ llvm::Function::arg_iterator argIter = function->arg_begin(); llvm::Value *structParamPtr = argIter++; // Copy the function parameter values from the structure into local @@ -343,7 +344,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, } else /* for NVPTX64 , function must be unmasked */ { - //assert(0); + assert(0); Assert(type->isUnmasked == false); // Otherwise use the mask to set the entry mask value @@ -353,6 +354,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, Assert(++argIter == function->arg_end()); } +#if 0 llvm::NamedMDNode* annotations = m->module->getOrInsertNamedMetadata("nvvm.annotations"); llvm::SmallVector av; @@ -360,6 +362,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, av.push_back(llvm::MDString::get(*g->ctx, "kernel")); av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1)); annotations->addOperand(llvm::MDNode::get(*g->ctx, av)); +#endif } } else { @@ -535,8 +538,12 @@ Function::GenerateIR() { /* export function with NVPTX64 target should be emitted host architecture */ #if 0 const FunctionType *func_type= CastType(sym->type); + /* exported functions are not supported yet */ if (g->target->getISA() == Target::NVPTX64 && func_type->isExported) return; +#endif + +#if 0 if (g->target->getISA() != Target::NVPTX64 && g->target->isPTX() && func_type->isTask) return; #endif diff --git a/module.cpp b/module.cpp index 1f9db87c..def0c6d7 100644 --- a/module.cpp +++ b/module.cpp @@ -733,7 +733,8 @@ Module::AddFunctionDeclaration(const std::string &name, if (storageClass == SC_EXTERN_C) { // Make sure the user hasn't supplied both an 'extern "C"' and a // 'task' qualifier with the function - if (functionType->isTask) { // && !g->target->isPTX()) { //tISA() != Target::NVPTX64) { + if (functionType->isTask) //&& !g->target->isPTX()) //tISA() != Target::NVPTX64) + { Error(pos, "\"task\" qualifier is illegal with C-linkage extern " "function \"%s\". Ignoring this function.", name.c_str()); return; @@ -795,7 +796,7 @@ Module::AddFunctionDeclaration(const std::string &name, #else // LLVM 3.1 and 3.3+ function->addFnAttr(llvm::Attribute::AlwaysInline); #endif - if (functionType->isTask) // && g->target->getISA() != Target::NVPTX64) + if (functionType->isTask && g->target->getISA() != Target::NVPTX64) // This also applies transitively to members I think? #if defined(LLVM_3_1) function->setDoesNotAlias(1, true); diff --git a/type.cpp b/type.cpp index d4c969f2..4dbbbf0a 100644 --- a/type.cpp +++ b/type.cpp @@ -2957,8 +2957,9 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const { // marshalled in a struct so that it's easy to allocate space to // hold them until the task actually runs.) // if (g->target->getISA() != Target::NVPTX64) - if (1) //if (!g->target->isPTX()) + if (!g->target->isPTX()) { + assert(0); /* evghenii: must be removed in final, just for test for nvptx64 target */ llvm::Type *st = llvm::StructType::get(*ctx, llvmArgTypes); callTypes.push_back(llvm::PointerType::getUnqual(st)); callTypes.push_back(LLVMTypes::Int32Type); // threadIndex @@ -2978,6 +2979,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const { callTypes = llvmArgTypes; else { + assert(0); /* evghenii: must be removed in final, just for test for nvptx64 target */ llvm::Type *st = llvm::StructType::get(*ctx, llvmArgTypes); callTypes.push_back(llvm::PointerType::getUnqual(st)); }