From: Jan Vesely Date: Wed, 8 Oct 2014 14:43:01 +0000 (+0300) Subject: clover: Append implicit arguments to the kernel argument list. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5bffc5e2620db7631300527f937b3a4823f3f999;p=mesa.git 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 --- 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 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 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 )); }