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 <currojerez@riseup.net>
This commit is contained in:
parent
bf89a97748
commit
5bffc5e262
|
@ -308,24 +308,20 @@ namespace {
|
|||
bitcode_ostream.flush();
|
||||
|
||||
for (unsigned i = 0; i < kernels.size(); ++i) {
|
||||
llvm::Function *kernel_func;
|
||||
std::string kernel_name;
|
||||
llvm::Function *kernel_func = kernels[i];
|
||||
const std::string kernel_name = kernel_func->getName();
|
||||
#if HAVE_LLVM < 0x0302
|
||||
llvm::TargetData TD(kernel_func->getParent());
|
||||
#elif HAVE_LLVM < 0x0305
|
||||
llvm::DataLayout TD(kernel_func->getParent()->getDataLayout());
|
||||
#else
|
||||
llvm::DataLayout TD(mod);
|
||||
#endif
|
||||
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;
|
||||
#if HAVE_LLVM < 0x0302
|
||||
llvm::TargetData TD(kernel_func->getParent());
|
||||
#elif HAVE_LLVM < 0x0305
|
||||
llvm::DataLayout TD(kernel_func->getParent()->getDataLayout());
|
||||
#else
|
||||
llvm::DataLayout TD(mod);
|
||||
#endif
|
||||
|
||||
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 ));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue