added #ifdef ISPC_NVPTX_ENALED ... #endif guards
This commit is contained in:
26
func.cpp
26
func.cpp
@@ -47,7 +47,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#ifdef ISPC_NVPTX_ENABLED
|
||||
#include <llvm/Metadata.h>
|
||||
#endif /* ISPC_NVPTX_ENABLED */
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Type.h>
|
||||
@@ -55,7 +57,9 @@
|
||||
#include <llvm/Intrinsics.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#else
|
||||
#ifdef ISPC_NVPTX_ENABLED
|
||||
#include <llvm/IR/Metadata.h>
|
||||
#endif /* ISPC_NVPTX_ENABLED */
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Type.h>
|
||||
@@ -131,7 +135,11 @@ Function::Function(Symbol *s, Stmt *c) {
|
||||
sym->parentFunction = this;
|
||||
}
|
||||
|
||||
if (type->isTask && g->target->getISA() != Target::NVPTX) {
|
||||
if (type->isTask
|
||||
#ifdef ISPC_NVPTX_ENABLED
|
||||
&& (g->target->getISA() != Target::NVPTX)
|
||||
#endif
|
||||
){
|
||||
threadIndexSym = m->symbolTable->LookupVariable("threadIndex");
|
||||
Assert(threadIndexSym);
|
||||
threadCountSym = m->symbolTable->LookupVariable("threadCount");
|
||||
@@ -242,7 +250,11 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
#endif
|
||||
const FunctionType *type = CastType<FunctionType>(sym->type);
|
||||
Assert(type != NULL);
|
||||
if (type->isTask == true && g->target->getISA() != Target::NVPTX) {
|
||||
if (type->isTask == true
|
||||
#ifdef ISPC_NVPTX_ENABLED
|
||||
&& (g->target->getISA() != Target::NVPTX)
|
||||
#endif
|
||||
){
|
||||
// For tasks, there should always be three parameters: the
|
||||
// pointer to the structure that holds all of the arguments, the
|
||||
// thread index, and the thread count variables.
|
||||
@@ -340,6 +352,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
ctx->SetFunctionMask(argIter);
|
||||
Assert(++argIter == function->arg_end());
|
||||
}
|
||||
#ifdef ISPC_NVPTX_ENABLED
|
||||
if (type->isTask == true && g->target->getISA() == Target::NVPTX)
|
||||
{
|
||||
llvm::NamedMDNode* annotations =
|
||||
@@ -350,6 +363,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
av.push_back(LLVMInt32(1));
|
||||
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
||||
}
|
||||
#endif /* ISPC_NVPTX_ENABLED */
|
||||
}
|
||||
|
||||
// Finally, we can generate code for the function
|
||||
@@ -505,15 +519,14 @@ Function::GenerateIR() {
|
||||
// the application can call it
|
||||
const FunctionType *type = CastType<FunctionType>(sym->type);
|
||||
Assert(type != NULL);
|
||||
if (type->isExported) {
|
||||
if (type->isExported) {
|
||||
if (!type->isTask) {
|
||||
llvm::FunctionType *ftype = type->LLVMFunctionType(g->ctx, true);
|
||||
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::ExternalLinkage;
|
||||
std::string functionName = sym->name;
|
||||
|
||||
if (g->mangleFunctionsWithTarget)
|
||||
functionName += std::string("_") + g->target->GetISAString();
|
||||
|
||||
#ifdef ISPC_NVPTX_ENABLED
|
||||
if (g->target->getISA() == Target::NVPTX)
|
||||
{
|
||||
functionName += std::string("___export"); /* add ___export to the end, for ptxcc to recognize it is exported */
|
||||
@@ -527,6 +540,7 @@ Function::GenerateIR() {
|
||||
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
||||
#endif
|
||||
}
|
||||
#endif /* ISPC_NVPTX_ENABLED */
|
||||
llvm::Function *appFunction =
|
||||
llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module);
|
||||
#if defined(LLVM_3_1)
|
||||
@@ -566,6 +580,7 @@ Function::GenerateIR() {
|
||||
FATAL("Function verificication failed");
|
||||
}
|
||||
}
|
||||
#ifdef ISPC_NVPTX_ENABLED
|
||||
if (g->target->getISA() == Target::NVPTX)
|
||||
{
|
||||
llvm::NamedMDNode* annotations =
|
||||
@@ -576,6 +591,7 @@ Function::GenerateIR() {
|
||||
av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1));
|
||||
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
||||
}
|
||||
#endif /* ISPC_NVPTX_ENABLED */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user