sort --fails
This commit is contained in:
134
ctx.cpp
134
ctx.cpp
@@ -3559,7 +3559,6 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
llvm::StructType *argStructType =
|
llvm::StructType *argStructType =
|
||||||
static_cast<llvm::StructType *>(pt->getElementType());
|
static_cast<llvm::StructType *>(pt->getElementType());
|
||||||
|
|
||||||
|
|
||||||
llvm::Function *falloc = m->module->getFunction("ISPCAlloc");
|
llvm::Function *falloc = m->module->getFunction("ISPCAlloc");
|
||||||
AssertPos(currentPos, falloc != NULL);
|
AssertPos(currentPos, falloc != NULL);
|
||||||
llvm::Value *structSize = g->target->SizeOf(argStructType, bblock);
|
llvm::Value *structSize = g->target->SizeOf(argStructType, bblock);
|
||||||
@@ -3680,129 +3679,34 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
llvm::Value *ret = CallInst(flaunch, NULL, args, "");
|
llvm::Value *ret = CallInst(flaunch, NULL, args, "");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
if (callee == NULL) {
|
|
||||||
AssertPos(currentPos, m->errorCount > 0);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
launchedTasks = true;
|
|
||||||
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::Type *st = llvm::StructType::get(*g->ctx, argTypes);
|
|
||||||
llvm::StructType *argStructType = static_cast<llvm::StructType *>(st);
|
|
||||||
llvm::Value *structSize = g->target->SizeOf(argStructType, bblock);
|
|
||||||
if (structSize->getType() != LLVMTypes::Int64Type)
|
|
||||||
structSize = ZExtInst(structSize, LLVMTypes::Int64Type,
|
|
||||||
"struct_size_to_64");
|
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
std::string str; llvm::raw_string_ostream rso(str); llvm::formatted_raw_ostream fos(rso);
|
|
||||||
structSize->print(fos);
|
|
||||||
fos.flush(); fprintf(stderr, ">>> %s\n", str.c_str());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
int align = 8;
|
|
||||||
llvm::Function *falloc = m->module->getFunction("ISPCGetParamBuffer");
|
|
||||||
AssertPos(currentPos, falloc != NULL);
|
|
||||||
std::vector<llvm::Value *> allocArgs;
|
|
||||||
allocArgs.push_back(launchGroupHandlePtr);
|
|
||||||
allocArgs.push_back(LLVMInt64(align));
|
|
||||||
allocArgs.push_back(structSize);
|
|
||||||
llvm::Value *voidmem = CallInst(falloc, NULL, allocArgs, "args_ptr");
|
|
||||||
llvm::Value *voidi64 = PtrToIntInst(voidmem, "args_i64");
|
|
||||||
llvm::BasicBlock* if_true = CreateBasicBlock("if_true");
|
|
||||||
llvm::BasicBlock* if_false = CreateBasicBlock("if_false");
|
|
||||||
// llvm::BasicBlock* bblock_bak = bblock;
|
|
||||||
|
|
||||||
/* check if the pointer returned by ISPCGetParamBuffer is not NULL
|
|
||||||
* --------------
|
|
||||||
* this is a workaround for not checking which laneIdx we are in,
|
|
||||||
* because ISPCGetParamBuffer will return NULL pointer for all laneIdx, except when laneIdx = 0
|
|
||||||
* of course, if ISPCGetParamBuffer fails to get parameter buffer, the pointer for laneIdx = 0
|
|
||||||
* will also be zero.
|
|
||||||
* This check must be added, and also rewrite the code to make it less opaque
|
|
||||||
*/
|
|
||||||
llvm::Value* cmp1 = CmpInst(llvm::Instruction::ICmp, llvm::CmpInst::ICMP_NE, voidi64, LLVMInt64(0), "cmp1");
|
|
||||||
BranchInst(if_true, if_false, cmp1);
|
|
||||||
|
|
||||||
bblock = if_true;
|
|
||||||
|
|
||||||
// label_if_then block:
|
|
||||||
llvm::Type *pt = llvm::PointerType::getUnqual(st);
|
|
||||||
llvm::Value *argmem = BitCastInst(voidmem, pt);
|
|
||||||
for (unsigned int i = 0; i < argVals.size(); ++i)
|
|
||||||
{
|
|
||||||
llvm::Value *ptr = AddElementOffset(argmem, i, NULL, "funarg");
|
|
||||||
// don't need to do masked store here, I think
|
|
||||||
StoreInst(argVals[i], ptr);
|
|
||||||
}
|
|
||||||
BranchInst(if_false);
|
|
||||||
|
|
||||||
bblock = if_false;
|
|
||||||
|
|
||||||
llvm::Value *fptr = BitCastInst(callee, LLVMTypes::VoidPointerType);
|
|
||||||
llvm::Function *flaunch = m->module->getFunction("ISPCLaunch");
|
|
||||||
AssertPos(currentPos, flaunch != NULL);
|
|
||||||
std::vector<llvm::Value *> args;
|
|
||||||
args.push_back(launchGroupHandlePtr);
|
|
||||||
args.push_back(fptr);
|
|
||||||
args.push_back(voidmem);
|
|
||||||
args.push_back(launchCount[0]);
|
|
||||||
args.push_back(launchCount[1]);
|
|
||||||
args.push_back(launchCount[2]);
|
|
||||||
return CallInst(flaunch, NULL, args, "");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::SyncInst() {
|
FunctionEmitContext::SyncInst() {
|
||||||
#if 0
|
llvm::Value *launchGroupHandle = LoadInst(launchGroupHandlePtr);
|
||||||
if (g->target->getISA() != Target::NVPTX)
|
llvm::Value *nullPtrValue =
|
||||||
{
|
llvm::Constant::getNullValue(LLVMTypes::VoidPointerType);
|
||||||
#endif
|
llvm::Value *nonNull = CmpInst(llvm::Instruction::ICmp,
|
||||||
llvm::Value *launchGroupHandle = LoadInst(launchGroupHandlePtr);
|
llvm::CmpInst::ICMP_NE,
|
||||||
llvm::Value *nullPtrValue =
|
launchGroupHandle, nullPtrValue);
|
||||||
llvm::Constant::getNullValue(LLVMTypes::VoidPointerType);
|
llvm::BasicBlock *bSync = CreateBasicBlock("call_sync");
|
||||||
llvm::Value *nonNull = CmpInst(llvm::Instruction::ICmp,
|
llvm::BasicBlock *bPostSync = CreateBasicBlock("post_sync");
|
||||||
llvm::CmpInst::ICMP_NE,
|
BranchInst(bSync, bPostSync, nonNull);
|
||||||
launchGroupHandle, nullPtrValue);
|
|
||||||
llvm::BasicBlock *bSync = CreateBasicBlock("call_sync");
|
|
||||||
llvm::BasicBlock *bPostSync = CreateBasicBlock("post_sync");
|
|
||||||
BranchInst(bSync, bPostSync, nonNull);
|
|
||||||
|
|
||||||
SetCurrentBasicBlock(bSync);
|
SetCurrentBasicBlock(bSync);
|
||||||
llvm::Function *fsync = m->module->getFunction("ISPCSync");
|
llvm::Function *fsync = m->module->getFunction("ISPCSync");
|
||||||
if (fsync == NULL)
|
if (fsync == NULL)
|
||||||
FATAL("Couldn't find ISPCSync declaration?!");
|
FATAL("Couldn't find ISPCSync declaration?!");
|
||||||
CallInst(fsync, NULL, launchGroupHandle, "");
|
CallInst(fsync, NULL, launchGroupHandle, "");
|
||||||
|
|
||||||
// zero out the handle so that if ISPCLaunch is called again in this
|
// zero out the handle so that if ISPCLaunch is called again in this
|
||||||
// function, it knows it's starting out from scratch
|
// function, it knows it's starting out from scratch
|
||||||
StoreInst(nullPtrValue, launchGroupHandlePtr);
|
StoreInst(nullPtrValue, launchGroupHandlePtr);
|
||||||
|
|
||||||
BranchInst(bPostSync);
|
BranchInst(bPostSync);
|
||||||
|
|
||||||
SetCurrentBasicBlock(bPostSync);
|
SetCurrentBasicBlock(bPostSync);
|
||||||
#if 0
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
llvm::Value *launchGroupHandle = LoadInst(launchGroupHandlePtr);
|
|
||||||
llvm::Value *nullPtrValue =
|
|
||||||
llvm::Constant::getNullValue(LLVMTypes::VoidPointerType);
|
|
||||||
llvm::Function *fsync = m->module->getFunction("ISPCSync");
|
|
||||||
if (fsync == NULL)
|
|
||||||
FATAL("Couldn't find ISPCSync declaration?!");
|
|
||||||
CallInst(fsync, NULL, launchGroupHandle, "");
|
|
||||||
StoreInst(nullPtrValue, launchGroupHandlePtr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
decl.cpp
5
decl.cpp
@@ -531,12 +531,9 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
|
|||||||
returnType = returnType->ResolveUnboundVariability(Variability::Varying);
|
returnType = returnType->ResolveUnboundVariability(Variability::Varying);
|
||||||
|
|
||||||
bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0);
|
bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0);
|
||||||
|
/* evghenii: without this, PTX fails on some examples, like deferred */
|
||||||
if (isTask && g->target->getISA() == Target::NVPTX)
|
if (isTask && g->target->getISA() == Target::NVPTX)
|
||||||
{
|
|
||||||
// ds->storageClass = SC_EXTERN_C;
|
|
||||||
ds->typeQualifiers |= TYPEQUAL_UNMASKED;
|
ds->typeQualifiers |= TYPEQUAL_UNMASKED;
|
||||||
// ds->typeQualifiers |= TYPEQUAL_INLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isExternC = ds && (ds->storageClass == SC_EXTERN_C);
|
bool isExternC = ds && (ds->storageClass == SC_EXTERN_C);
|
||||||
bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0);
|
bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0);
|
||||||
|
|||||||
13
examples_ptx/rt/Makefile_gpu
Normal file
13
examples_ptx/rt/Makefile_gpu
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
PROG=rt
|
||||||
|
ISPC_SRC=rt.ispc
|
||||||
|
CU_SRC=rt.cu
|
||||||
|
CXX_SRC=rt.cpp rt_serial.cpp
|
||||||
|
PTXCC_REGMAX=32
|
||||||
|
|
||||||
|
LLVM_GPU=1
|
||||||
|
NVVM_GPU=1
|
||||||
|
|
||||||
|
include ../common_gpu.mk
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
191
func.cpp
191
func.cpp
@@ -186,7 +186,6 @@ lCopyInTaskParameter(int i, llvm::Value *structArgPtr, const
|
|||||||
FunctionEmitContext *ctx) {
|
FunctionEmitContext *ctx) {
|
||||||
// We expect the argument structure to come in as a poitner to a
|
// We expect the argument structure to come in as a poitner to a
|
||||||
// structure. Confirm and figure out its type here.
|
// structure. Confirm and figure out its type here.
|
||||||
|
|
||||||
const llvm::Type *structArgType = structArgPtr->getType();
|
const llvm::Type *structArgType = structArgPtr->getType();
|
||||||
Assert(llvm::isa<llvm::PointerType>(structArgType));
|
Assert(llvm::isa<llvm::PointerType>(structArgType));
|
||||||
const llvm::PointerType *pt = llvm::dyn_cast<const llvm::PointerType>(structArgType);
|
const llvm::PointerType *pt = llvm::dyn_cast<const llvm::PointerType>(structArgType);
|
||||||
@@ -346,173 +345,6 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
|||||||
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (type->isTask == true) {
|
|
||||||
// For tasks, we there should always be three parmeters: the
|
|
||||||
// pointer to the structure that holds all of the arguments, the
|
|
||||||
// thread index, and the thread count variables.
|
|
||||||
|
|
||||||
if (g->target->getISA() != Target::NVPTX)
|
|
||||||
{
|
|
||||||
llvm::Function::arg_iterator argIter = function->arg_begin();
|
|
||||||
llvm::Value *structParamPtr = argIter++;
|
|
||||||
// Copy the function parameter values from the structure into local
|
|
||||||
// storage
|
|
||||||
for (unsigned int i = 0; i < args.size(); ++i)
|
|
||||||
lCopyInTaskParameter(i, structParamPtr, args, ctx);
|
|
||||||
|
|
||||||
if (type->isUnmasked == false) {
|
|
||||||
// Copy in the mask as well.
|
|
||||||
int nArgs = (int)args.size();
|
|
||||||
// The mask is the last parameter in the argument structure
|
|
||||||
llvm::Value *ptr = ctx->AddElementOffset(structParamPtr, nArgs, NULL,
|
|
||||||
"task_struct_mask");
|
|
||||||
llvm::Value *ptrval = ctx->LoadInst(ptr, "mask");
|
|
||||||
ctx->SetFunctionMask(ptrval);
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::Value *threadIndex = argIter++;
|
|
||||||
llvm::Value *threadCount = argIter++;
|
|
||||||
llvm::Value *taskIndex = argIter++;
|
|
||||||
llvm::Value *taskCount = argIter++;
|
|
||||||
llvm::Value *taskIndex0 = argIter++;
|
|
||||||
llvm::Value *taskIndex1 = argIter++;
|
|
||||||
llvm::Value *taskIndex2 = argIter++;
|
|
||||||
llvm::Value *taskCount0 = argIter++;
|
|
||||||
llvm::Value *taskCount1 = argIter++;
|
|
||||||
llvm::Value *taskCount2 = argIter++;
|
|
||||||
|
|
||||||
// Copy threadIndex and threadCount into stack-allocated storage so
|
|
||||||
// that their symbols point to something reasonable.
|
|
||||||
threadIndexSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "threadIndex");
|
|
||||||
ctx->StoreInst(threadIndex, threadIndexSym->storagePtr);
|
|
||||||
|
|
||||||
threadCountSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "threadCount");
|
|
||||||
ctx->StoreInst(threadCount, threadCountSym->storagePtr);
|
|
||||||
|
|
||||||
// Copy taskIndex and taskCount into stack-allocated storage so
|
|
||||||
// that their symbols point to something reasonable.
|
|
||||||
taskIndexSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex");
|
|
||||||
ctx->StoreInst(taskIndex, taskIndexSym->storagePtr);
|
|
||||||
|
|
||||||
taskCountSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount");
|
|
||||||
ctx->StoreInst(taskCount, taskCountSym->storagePtr);
|
|
||||||
|
|
||||||
/* nvptx map:
|
|
||||||
* programCount : llvm.nvvm.read.ptx.sreg.warpsize
|
|
||||||
* programIndex : llvm.ptx.read.laneid _or_ ed.ptx.sreg.tid.llvm.nvvm.read.ptx.sreg.tid.x & programCount
|
|
||||||
* taskIndex0 : llvm.nvvm.read.ptx.sreg.ctaid.x
|
|
||||||
* taskIndex1 : llvm.nvvm.read.ptx.sreg.ctaid.y
|
|
||||||
* taskIndex3 : llvm.nvvm.read.ptx.sreg.ctaid.z
|
|
||||||
* taskCount0 : llvm.nvvm.read.ptx.sreg.nctaid.x
|
|
||||||
* taskCount1 : llvm.nvvm.read.ptx.sreg.nctaid.y
|
|
||||||
* taskCount3 : llvm.nvvm.read.ptx.sreg.nctaid.z
|
|
||||||
*/
|
|
||||||
|
|
||||||
// llvm.nvvm.read.ptx.sreg.ctaid.x
|
|
||||||
taskIndexSym0->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex0");
|
|
||||||
ctx->StoreInst(taskIndex0, taskIndexSym0->storagePtr);
|
|
||||||
// llvm.nvvm.read.ptx.sreg.ctaid.y
|
|
||||||
taskIndexSym1->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex1");
|
|
||||||
ctx->StoreInst(taskIndex1, taskIndexSym1->storagePtr);
|
|
||||||
// llvm.nvvm.read.ptx.sreg.ctaid.z
|
|
||||||
taskIndexSym2->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex2");
|
|
||||||
ctx->StoreInst(taskIndex2, taskIndexSym2->storagePtr);
|
|
||||||
|
|
||||||
// llvm.nvvm.read.ptx.sreg.nctaid.x
|
|
||||||
taskCountSym0->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount0");
|
|
||||||
ctx->StoreInst(taskCount0, taskCountSym0->storagePtr);
|
|
||||||
// llvm.nvvm.read.ptx.sreg.nctaid.y
|
|
||||||
taskCountSym1->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount1");
|
|
||||||
ctx->StoreInst(taskCount1, taskCountSym1->storagePtr);
|
|
||||||
// llvm.nvvm.read.ptx.sreg.nctaid.z
|
|
||||||
taskCountSym2->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount2");
|
|
||||||
ctx->StoreInst(taskCount2, taskCountSym2->storagePtr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
llvm::Function::arg_iterator argIter = function->arg_begin();
|
|
||||||
for (unsigned int i = 0; i < args.size(); ++i, ++argIter) {
|
|
||||||
Symbol *sym = args[i];
|
|
||||||
if (sym == NULL)
|
|
||||||
// anonymous function parameter
|
|
||||||
continue;
|
|
||||||
|
|
||||||
argIter->setName(sym->name.c_str());
|
|
||||||
|
|
||||||
// Allocate stack storage for the parameter and emit code
|
|
||||||
// to store the its value there.
|
|
||||||
sym->storagePtr = ctx->AllocaInst(argIter->getType(), sym->name.c_str());
|
|
||||||
ctx->StoreInst(argIter, sym->storagePtr);
|
|
||||||
ctx->EmitFunctionParameterDebugInfo(sym, i);
|
|
||||||
}
|
|
||||||
if (argIter == function->arg_end())
|
|
||||||
{
|
|
||||||
Assert(type->isUnmasked || type->isExported);
|
|
||||||
ctx->SetFunctionMask(LLVMMaskAllOn);
|
|
||||||
}
|
|
||||||
else /* for NVPTX, function must be unmasked */
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
Assert(type->isUnmasked == false);
|
|
||||||
|
|
||||||
// Otherwise use the mask to set the entry mask value
|
|
||||||
argIter->setName("__mask");
|
|
||||||
Assert(argIter->getType() == LLVMTypes::MaskType);
|
|
||||||
ctx->SetFunctionMask(argIter);
|
|
||||||
Assert(++argIter == function->arg_end());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g->target->getISA() == Target::NVPTX)
|
|
||||||
{
|
|
||||||
llvm::NamedMDNode* annotations =
|
|
||||||
m->module->getOrInsertNamedMetadata("nvvm.annotations");
|
|
||||||
llvm::SmallVector<llvm::Value*, 3> av;
|
|
||||||
av.push_back(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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Regular, non-task function
|
|
||||||
llvm::Function::arg_iterator argIter = function->arg_begin();
|
|
||||||
for (unsigned int i = 0; i < args.size(); ++i, ++argIter) {
|
|
||||||
Symbol *sym = args[i];
|
|
||||||
if (sym == NULL)
|
|
||||||
// anonymous function parameter
|
|
||||||
continue;
|
|
||||||
|
|
||||||
argIter->setName(sym->name.c_str());
|
|
||||||
|
|
||||||
// Allocate stack storage for the parameter and emit code
|
|
||||||
// to store the its value there.
|
|
||||||
sym->storagePtr = ctx->AllocaInst(argIter->getType(), sym->name.c_str());
|
|
||||||
ctx->StoreInst(argIter, sym->storagePtr);
|
|
||||||
ctx->EmitFunctionParameterDebugInfo(sym, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the number of actual function arguments is equal to the
|
|
||||||
// number of declared arguments in decl->functionParams, then we
|
|
||||||
// don't have a mask parameter, so set it to be all on. This
|
|
||||||
// happens for exmaple with 'export'ed functions that the app
|
|
||||||
// calls.
|
|
||||||
if (argIter == function->arg_end()) {
|
|
||||||
Assert(type->isUnmasked || type->isExported);
|
|
||||||
ctx->SetFunctionMask(LLVMMaskAllOn);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Assert(type->isUnmasked == false);
|
|
||||||
|
|
||||||
// Otherwise use the mask to set the entry mask value
|
|
||||||
argIter->setName("__mask");
|
|
||||||
Assert(argIter->getType() == LLVMTypes::MaskType);
|
|
||||||
ctx->SetFunctionMask(argIter);
|
|
||||||
Assert(++argIter == function->arg_end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Finally, we can generate code for the function
|
// Finally, we can generate code for the function
|
||||||
if (code != NULL) {
|
if (code != NULL) {
|
||||||
@@ -527,7 +359,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
|||||||
// entire thing inside code that tests to see if the mask is all
|
// 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
|
// on, all off, or mixed. If this is a simple function, then this
|
||||||
// isn't worth the code bloat / overhead.
|
// isn't worth the code bloat / overhead.
|
||||||
bool checkMask = (type->isTask == true) ||
|
bool checkMask = (type->isTask == true && g->target->getISA() != Target::NVPTX) ||
|
||||||
(
|
(
|
||||||
#if defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
|
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
|
||||||
@@ -665,16 +497,6 @@ Function::GenerateIR() {
|
|||||||
Assert(type != NULL);
|
Assert(type != NULL);
|
||||||
if (type->isExported) {
|
if (type->isExported) {
|
||||||
if (!type->isTask) {
|
if (!type->isTask) {
|
||||||
if (g->target->getISA() == Target::NVPTX)
|
|
||||||
{
|
|
||||||
llvm::NamedMDNode* annotations =
|
|
||||||
m->module->getOrInsertNamedMetadata("nvvm.annotations");
|
|
||||||
llvm::SmallVector<llvm::Value*, 3> av;
|
|
||||||
av.push_back(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));
|
|
||||||
}
|
|
||||||
llvm::FunctionType *ftype = type->LLVMFunctionType(g->ctx, true);
|
llvm::FunctionType *ftype = type->LLVMFunctionType(g->ctx, true);
|
||||||
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::ExternalLinkage;
|
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::ExternalLinkage;
|
||||||
std::string functionName = sym->name;
|
std::string functionName = sym->name;
|
||||||
@@ -683,7 +505,16 @@ Function::GenerateIR() {
|
|||||||
functionName += std::string("_") + g->target->GetISAString();
|
functionName += std::string("_") + g->target->GetISAString();
|
||||||
|
|
||||||
if (g->target->getISA() == Target::NVPTX)
|
if (g->target->getISA() == Target::NVPTX)
|
||||||
functionName += std::string("___export");
|
{
|
||||||
|
functionName += std::string("___export"); /* add ___export to the end, for ptxcc to recognize it is exported */
|
||||||
|
llvm::NamedMDNode* annotations =
|
||||||
|
m->module->getOrInsertNamedMetadata("nvvm.annotations");
|
||||||
|
llvm::SmallVector<llvm::Value*, 3> av;
|
||||||
|
av.push_back(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));
|
||||||
|
}
|
||||||
llvm::Function *appFunction =
|
llvm::Function *appFunction =
|
||||||
llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module);
|
llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module);
|
||||||
#if defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
|
|||||||
5
ispc.cpp
5
ispc.cpp
@@ -769,11 +769,6 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
|||||||
dl_string = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
|
dl_string = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
|
||||||
"i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-"
|
"i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-"
|
||||||
"f80:128:128-n8:16:32:64-S128-v16:16:16-v32:32:32-v4:128:128";
|
"f80:128:128-n8:16:32:64-S128-v16:16:16-v32:32:32-v4:128:128";
|
||||||
#if 0 /* evghenii: this generate warrning about Module DataLayout is incompatible with .." */
|
|
||||||
} else if (m_isa == Target::NVPTX)
|
|
||||||
{
|
|
||||||
dl_string = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64";
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Finally set member data
|
// 3. Finally set member data
|
||||||
|
|||||||
@@ -733,8 +733,7 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
if (storageClass == SC_EXTERN_C) {
|
if (storageClass == SC_EXTERN_C) {
|
||||||
// Make sure the user hasn't supplied both an 'extern "C"' and a
|
// Make sure the user hasn't supplied both an 'extern "C"' and a
|
||||||
// 'task' qualifier with the function
|
// 'task' qualifier with the function
|
||||||
if (functionType->isTask)
|
if (functionType->isTask) {
|
||||||
{
|
|
||||||
Error(pos, "\"task\" qualifier is illegal with C-linkage extern "
|
Error(pos, "\"task\" qualifier is illegal with C-linkage extern "
|
||||||
"function \"%s\". Ignoring this function.", name.c_str());
|
"function \"%s\". Ignoring this function.", name.c_str());
|
||||||
return;
|
return;
|
||||||
@@ -796,7 +795,6 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
#else // LLVM 3.1 and 3.3+
|
#else // LLVM 3.1 and 3.3+
|
||||||
function->addFnAttr(llvm::Attribute::AlwaysInline);
|
function->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||||
#endif
|
#endif
|
||||||
/* evghenii: on PTX target the following must not be set ... why ?!? */
|
|
||||||
if (functionType->isTask && g->target->getISA() != Target::NVPTX)
|
if (functionType->isTask && g->target->getISA() != Target::NVPTX)
|
||||||
// This also applies transitively to members I think?
|
// This also applies transitively to members I think?
|
||||||
#if defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
|
|||||||
2
type.cpp
2
type.cpp
@@ -2924,7 +2924,6 @@ FunctionType::GetReturnTypeString() const {
|
|||||||
|
|
||||||
llvm::FunctionType *
|
llvm::FunctionType *
|
||||||
FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
|
FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
|
||||||
|
|
||||||
if (isTask == true)
|
if (isTask == true)
|
||||||
Assert(removeMask == false);
|
Assert(removeMask == false);
|
||||||
|
|
||||||
@@ -2973,7 +2972,6 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
|
|||||||
// Otherwise we already have the types of the arguments
|
// Otherwise we already have the types of the arguments
|
||||||
callTypes = llvmArgTypes;
|
callTypes = llvmArgTypes;
|
||||||
|
|
||||||
|
|
||||||
if (returnType == NULL) {
|
if (returnType == NULL) {
|
||||||
Assert(m->errorCount > 0);
|
Assert(m->errorCount > 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user