diff options
author | Jan Vesely <[email protected]> | 2014-10-08 17:43:01 +0300 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2014-10-12 01:50:13 +0300 |
commit | 5bffc5e2620db7631300527f937b3a4823f3f999 (patch) | |
tree | 0c8e345c259f7b03ca6353e3e724fc66f3e8650a /src/gallium/state_trackers | |
parent | bf89a97748748592639087e8167e29c98c740d33 (diff) |
clover: Append implicit arguments to the kernel argument list.
[ Francisco Jerez: Split off from a larger patch, and take a slightly
different approach for passing the implicit arguments around. ]
Reviewed-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/clover/llvm/invocation.cpp | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp index 7bca0d68357..212b4e48f62 100644 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -308,24 +308,20 @@ namespace { bitcode_ostream.flush(); for (unsigned i = 0; i < kernels.size(); ++i) { - llvm::Function *kernel_func; - std::string kernel_name; - compat::vector<module::argument> args; - - kernel_func = kernels[i]; - kernel_name = kernel_func->getName(); - - for (llvm::Function::arg_iterator I = kernel_func->arg_begin(), - E = kernel_func->arg_end(); I != E; ++I) { - llvm::Argument &arg = *I; + llvm::Function *kernel_func = kernels[i]; + const std::string kernel_name = kernel_func->getName(); #if HAVE_LLVM < 0x0302 - llvm::TargetData TD(kernel_func->getParent()); + llvm::TargetData TD(kernel_func->getParent()); #elif HAVE_LLVM < 0x0305 - llvm::DataLayout TD(kernel_func->getParent()->getDataLayout()); + llvm::DataLayout TD(kernel_func->getParent()->getDataLayout()); #else - llvm::DataLayout TD(mod); + llvm::DataLayout TD(mod); #endif + compat::vector<module::argument> args; + for (llvm::Function::arg_iterator I = kernel_func->arg_begin(), + E = kernel_func->arg_end(); I != E; ++I) { + llvm::Argument &arg = *I; llvm::Type *arg_type = arg.getType(); const unsigned arg_store_size = TD.getTypeStoreSize(arg_type); @@ -384,6 +380,26 @@ namespace { } } + // Append implicit arguments. XXX - The types, ordering and + // vector size of the implicit arguments should depend on the + // target according to the selected calling convention. + llvm::Type *size_type = + TD.getSmallestLegalIntType(mod->getContext(), sizeof(cl_uint) * 8); + + args.push_back( + module::argument(module::argument::scalar, sizeof(cl_uint), + TD.getTypeStoreSize(size_type), + TD.getABITypeAlignment(size_type), + module::argument::zero_ext, + module::argument::grid_dimension)); + + args.push_back( + module::argument(module::argument::scalar, sizeof(cl_uint), + TD.getTypeStoreSize(size_type), + TD.getABITypeAlignment(size_type), + module::argument::zero_ext, + module::argument::grid_offset)); + m.syms.push_back(module::symbol(kernel_name, 0, i, args )); } |