summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/PPCGCodeGeneration.cpp
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-08-04 06:55:49 +0000
committerTobias Grosser <tobias@grosser.es>2016-08-04 06:55:49 +0000
commit576932728db66de3e39278f10c132fb960e378ab (patch)
treef878501617e01c437b6e8d7f59883e7fd028b95e /polly/lib/CodeGen/PPCGCodeGeneration.cpp
parentabb2b54ad3909a9b47b7696fbd48160c77f4d6d6 (diff)
downloadbcm5719-llvm-576932728db66de3e39278f10c132fb960e378ab.tar.gz
bcm5719-llvm-576932728db66de3e39278f10c132fb960e378ab.zip
GPGPU: Pass subtree values correctly to the kernel
llvm-svn: 277697
Diffstat (limited to 'polly/lib/CodeGen/PPCGCodeGeneration.cpp')
-rw-r--r--polly/lib/CodeGen/PPCGCodeGeneration.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp
index 0d6e6ca078d..388ee8fdf05 100644
--- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp
+++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp
@@ -221,12 +221,14 @@ private:
/// Create kernel launch parameters.
///
- /// @param Kernel The kernel to create parameters for.
- /// @param F The kernel function that has been created.
+ /// @param Kernel The kernel to create parameters for.
+ /// @param F The kernel function that has been created.
+ /// @param SubtreeValues The set of llvm::Values referenced by this kernel.
///
/// @returns A stack allocated array with pointers to the parameter
/// values that are passed to the kernel.
- Value *createLaunchParameters(ppcg_kernel *Kernel, Function *F);
+ Value *createLaunchParameters(ppcg_kernel *Kernel, Function *F,
+ SetVector<Value *> SubtreeValues);
/// Create GPU kernel.
///
@@ -879,8 +881,9 @@ GPUNodeBuilder::getBlockSizes(ppcg_kernel *Kernel) {
return std::make_tuple(Sizes[0], Sizes[1], Sizes[2]);
}
-Value *GPUNodeBuilder::createLaunchParameters(ppcg_kernel *Kernel,
- Function *F) {
+Value *
+GPUNodeBuilder::createLaunchParameters(ppcg_kernel *Kernel, Function *F,
+ SetVector<Value *> SubtreeValues) {
Type *ArrayTy = ArrayType::get(Builder.getInt8PtrTy(),
std::distance(F->arg_begin(), F->arg_end()));
@@ -948,6 +951,19 @@ Value *GPUNodeBuilder::createLaunchParameters(ppcg_kernel *Kernel,
Index++;
}
+ for (auto Val : SubtreeValues) {
+ Instruction *Param = new AllocaInst(
+ Val->getType(), Launch + "_param_" + std::to_string(Index),
+ EntryBlock->getTerminator());
+ Builder.CreateStore(Val, Param);
+ Value *Slot = Builder.CreateGEP(
+ Parameters, {Builder.getInt64(0), Builder.getInt64(Index)});
+ Value *ParamTyped =
+ Builder.CreatePointerCast(Param, Builder.getInt8PtrTy());
+ Builder.CreateStore(ParamTyped, Slot);
+ Index++;
+ }
+
auto Location = EntryBlock->getTerminator();
return new BitCastInst(Parameters, Builder.getInt8PtrTy(),
Launch + "_params_i8ptr", Location);
@@ -1003,7 +1019,7 @@ void GPUNodeBuilder::createKernel(__isl_take isl_ast_node *KernelStmt) {
S.invalidateScopArrayInfo(BasePtr, ScopArrayInfo::MK_Array);
LocalArrays.clear();
- Value *Parameters = createLaunchParameters(Kernel, F);
+ Value *Parameters = createLaunchParameters(Kernel, F, SubtreeValues);
std::string ASMString = finalizeKernelFunction();
std::string Name = "kernel_" + std::to_string(Kernel->id);
OpenPOWER on IntegriCloud