summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/PPCGCodeGeneration.cpp
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-08-04 06:55:59 +0000
committerTobias Grosser <tobias@grosser.es>2016-08-04 06:55:59 +0000
commit00bb5a99f58c9b64d10aa3f204e44d2d3b000b16 (patch)
tree0cbe0700a0fc2e9d00a5e0bf74f639e6269e3149 /polly/lib/CodeGen/PPCGCodeGeneration.cpp
parent3216f8546c96a6613253901e79b056aede79f04e (diff)
downloadbcm5719-llvm-00bb5a99f58c9b64d10aa3f204e44d2d3b000b16.tar.gz
bcm5719-llvm-00bb5a99f58c9b64d10aa3f204e44d2d3b000b16.zip
GPGPU: Handle scalar array references
Pass the content of scalar array references to the alloca on the kernel side and do not pass them additional as normal LLVM scalar value. llvm-svn: 277699
Diffstat (limited to 'polly/lib/CodeGen/PPCGCodeGeneration.cpp')
-rw-r--r--polly/lib/CodeGen/PPCGCodeGeneration.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp
index 388ee8fdf05..46deae38a8a 100644
--- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp
+++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp
@@ -242,6 +242,12 @@ private:
/// @param Array The array for which to compute a size.
Value *getArraySize(gpu_array_info *Array);
+ /// Prepare the kernel arguments for kernel code generation
+ ///
+ /// @param Kernel The kernel to generate code for.
+ /// @param FN The function created for the kernel.
+ void prepareKernelArguments(ppcg_kernel *Kernel, Function *FN);
+
/// Create kernel function.
///
/// Create a kernel function located in a newly created module that can serve
@@ -775,7 +781,7 @@ isl_bool collectReferencesInGPUStmt(__isl_keep isl_ast_node *Node, void *User) {
auto Stmt = (ScopStmt *)KernelStmt->u.d.stmt->stmt;
isl_id_free(Id);
- addReferencesFromStmt(Stmt, User);
+ addReferencesFromStmt(Stmt, User, false /* CreateScalarRefs */);
return isl_bool_true;
}
@@ -1167,6 +1173,32 @@ void GPUNodeBuilder::insertKernelIntrinsics(ppcg_kernel *Kernel) {
}
}
+void GPUNodeBuilder::prepareKernelArguments(ppcg_kernel *Kernel, Function *FN) {
+ auto Arg = FN->arg_begin();
+ for (long i = 0; i < Kernel->n_array; i++) {
+ if (!ppcg_kernel_requires_array_argument(Kernel, i))
+ continue;
+
+ isl_id *Id = isl_space_get_tuple_id(Prog->array[i].space, isl_dim_set);
+ const ScopArrayInfo *SAI = ScopArrayInfo::getFromId(isl_id_copy(Id));
+ isl_id_free(Id);
+
+ if (SAI->getNumberOfDimensions() > 0) {
+ Arg++;
+ continue;
+ }
+
+ Value *Alloca = BlockGen.getOrCreateScalarAlloca(SAI->getBasePtr());
+ Value *ArgPtr = &*Arg;
+ Type *TypePtr = SAI->getElementType()->getPointerTo();
+ Value *TypedArgPtr = Builder.CreatePointerCast(ArgPtr, TypePtr);
+ Value *Val = Builder.CreateLoad(TypedArgPtr);
+ Builder.CreateStore(Val, Alloca);
+
+ Arg++;
+ }
+}
+
void GPUNodeBuilder::createKernelFunction(ppcg_kernel *Kernel,
SetVector<Value *> &SubtreeValues) {
@@ -1189,6 +1221,7 @@ void GPUNodeBuilder::createKernelFunction(ppcg_kernel *Kernel,
ScopDetection::markFunctionAsInvalid(FN);
+ prepareKernelArguments(Kernel, FN);
insertKernelIntrinsics(Kernel);
}
OpenPOWER on IntegriCloud