export functions are now also generated... next add proper CDP calls..
This commit is contained in:
12
ctx.cpp
12
ctx.cpp
@@ -3595,7 +3595,7 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
}
|
}
|
||||||
else /* isPTX == true */
|
else /* isPTX == true */
|
||||||
{
|
{
|
||||||
assert(0); /* must only be called in export */
|
//assert(0); /* must only be called in export */
|
||||||
// assert(g->target->getISA() != Target::NVPTX64);
|
// assert(g->target->getISA() != Target::NVPTX64);
|
||||||
|
|
||||||
if (callee == NULL) {
|
if (callee == NULL) {
|
||||||
@@ -3606,6 +3606,7 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
launchedTasks = true;
|
launchedTasks = true;
|
||||||
|
|
||||||
AssertPos(currentPos, llvm::isa<llvm::Function>(callee));
|
AssertPos(currentPos, llvm::isa<llvm::Function>(callee));
|
||||||
|
#if 0
|
||||||
llvm::Type *argType =
|
llvm::Type *argType =
|
||||||
(llvm::dyn_cast<llvm::Function>(callee))->arg_begin()->getType();
|
(llvm::dyn_cast<llvm::Function>(callee))->arg_begin()->getType();
|
||||||
AssertPos(currentPos, llvm::PointerType::classof(argType));
|
AssertPos(currentPos, llvm::PointerType::classof(argType));
|
||||||
@@ -3614,6 +3615,7 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
AssertPos(currentPos, llvm::StructType::classof(pt->getElementType()));
|
AssertPos(currentPos, llvm::StructType::classof(pt->getElementType()));
|
||||||
llvm::StructType *argStructType =
|
llvm::StructType *argStructType =
|
||||||
static_cast<llvm::StructType *>(pt->getElementType());
|
static_cast<llvm::StructType *>(pt->getElementType());
|
||||||
|
#endif
|
||||||
|
|
||||||
llvm::Function *falloc = m->module->getFunction("CUDAAlloc");
|
llvm::Function *falloc = m->module->getFunction("CUDAAlloc");
|
||||||
AssertPos(currentPos, falloc != NULL);
|
AssertPos(currentPos, falloc != NULL);
|
||||||
@@ -3648,9 +3650,13 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
* this, and other parts are reverse enginered via
|
* this, and other parts are reverse enginered via
|
||||||
* cpp(clang++ -S -emit-llvm)->IR and then IR(llc -march=cpp)->cpp
|
* cpp(clang++ -S -emit-llvm)->IR and then IR(llc -march=cpp)->cpp
|
||||||
*/
|
*/
|
||||||
for (unsigned int i = 0; i < argVals.size(); ++i)
|
llvm::Function *func = llvm::dyn_cast<llvm::Function>(callee);
|
||||||
|
llvm::Function::arg_iterator argIter =func->arg_begin();
|
||||||
|
llvm::Function::arg_iterator argIterEnd =func->arg_end();
|
||||||
|
int i = 0;
|
||||||
|
for (; argIter != argIterEnd; argIter++, i++)
|
||||||
{
|
{
|
||||||
llvm::Type* type = argStructType->getElementType(i);
|
llvm::Type* type = argIter->getType(); //argStructType->getElementType(i);
|
||||||
llvm::Value* ptr_arg1_addr = AllocaInst(type, "argptr");
|
llvm::Value* ptr_arg1_addr = AllocaInst(type, "argptr");
|
||||||
StoreInst(argVals[i], ptr_arg1_addr);
|
StoreInst(argVals[i], ptr_arg1_addr);
|
||||||
|
|
||||||
|
|||||||
32
func.cpp
32
func.cpp
@@ -354,15 +354,16 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
|||||||
Assert(++argIter == function->arg_end());
|
Assert(++argIter == function->arg_end());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
if (g->target->isPTX() && g->target->getISA() == Target::NVPTX64)
|
||||||
llvm::NamedMDNode* annotations =
|
{
|
||||||
m->module->getOrInsertNamedMetadata("nvvm.annotations");
|
llvm::NamedMDNode* annotations =
|
||||||
llvm::SmallVector<llvm::Value*, 3> av;
|
m->module->getOrInsertNamedMetadata("nvvm.annotations");
|
||||||
av.push_back(function);
|
llvm::SmallVector<llvm::Value*, 3> av;
|
||||||
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
av.push_back(function);
|
||||||
av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1));
|
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
||||||
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1));
|
||||||
#endif
|
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -538,7 +539,6 @@ Function::GenerateIR() {
|
|||||||
/* export function with NVPTX64 target should be emitted host architecture */
|
/* export function with NVPTX64 target should be emitted host architecture */
|
||||||
#if 0
|
#if 0
|
||||||
const FunctionType *func_type= CastType<FunctionType>(sym->type);
|
const FunctionType *func_type= CastType<FunctionType>(sym->type);
|
||||||
/* exported functions are not supported yet */
|
|
||||||
if (g->target->getISA() == Target::NVPTX64 && func_type->isExported)
|
if (g->target->getISA() == Target::NVPTX64 && func_type->isExported)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@@ -567,7 +567,7 @@ Function::GenerateIR() {
|
|||||||
// the application can call it
|
// the application can call it
|
||||||
const FunctionType *type = CastType<FunctionType>(sym->type);
|
const FunctionType *type = CastType<FunctionType>(sym->type);
|
||||||
Assert(type != NULL);
|
Assert(type != NULL);
|
||||||
if (type->isExported) { // && g->target->getISA() != Target::NVPTX64) {
|
if (type->isExported) { // && g->target->getISA() != Target::VPTX64) {
|
||||||
if (!type->isTask) {
|
if (!type->isTask) {
|
||||||
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;
|
||||||
@@ -602,6 +602,16 @@ Function::GenerateIR() {
|
|||||||
FATAL("Function verificication failed");
|
FATAL("Function verificication failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (g->target->isPTX() && g->target->getISA() == Target::NVPTX64)
|
||||||
|
{
|
||||||
|
llvm::NamedMDNode* annotations =
|
||||||
|
m->module->getOrInsertNamedMetadata("nvvm.annotations");
|
||||||
|
llvm::SmallVector<llvm::Value*, 3> av;
|
||||||
|
av.push_back(appFunction);
|
||||||
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -796,6 +796,7 @@ 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 this must not be used, cause crash, dunno why */
|
||||||
if (functionType->isTask && g->target->getISA() != Target::NVPTX64)
|
if (functionType->isTask && g->target->getISA() != Target::NVPTX64)
|
||||||
// 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user