clover/module: add a printf support to module (v5)

This adds storage for printf formats encoded as number of
argument sizes + the printf format string, and storage
for sideband printf strings if the backend wants them.

It adds a flag that decides if the backend wants AMD (LLVM)
behaviour or NIR wrt the format of the global buffer and
how to decode strings.

Based on work by EdB in his printf support, but made useful
to be generic.

I'm not a huge fan of the buffer format flag, but this was
the easiest way to denote the llvm abi buffer format.

v3: rename buffer fmt

v4: use a single strings storage and one struct

v5: move printf_info into module, cleanup serialisation struct

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8254>
This commit is contained in:
Dave Airlie 2020-10-29 07:15:02 +10:00
parent 77b70fa35d
commit 95527fe229
2 changed files with 21 additions and 0 deletions

View file

@ -155,6 +155,17 @@ namespace {
} }
}; };
/// (De)serialize a printf format
template<>
struct _serializer<module::printf_info> {
template<typename S, typename QT>
static void
proc(S & s, QT &x) {
_proc(s, x.arg_sizes);
_proc(s, x.strings);
}
};
/// (De)serialize a module::section. /// (De)serialize a module::section.
template<> template<>
struct _serializer<module::section> { struct _serializer<module::section> {
@ -206,6 +217,8 @@ namespace {
proc(S &s, QT &x) { proc(S &s, QT &x) {
_proc(s, x.syms); _proc(s, x.syms);
_proc(s, x.secs); _proc(s, x.secs);
_proc(s, x.printf_infos);
_proc(s, x.printf_strings_in_buffer);
} }
}; };
}; };

View file

@ -55,6 +55,11 @@ namespace clover {
std::vector<char> data; std::vector<char> data;
}; };
struct printf_info {
std::vector<uint32_t> arg_sizes;
std::vector<uint8_t> strings;
};
struct arg_info { struct arg_info {
arg_info(const std::string &arg_name, const std::string &type_name, arg_info(const std::string &arg_name, const std::string &type_name,
const cl_kernel_arg_type_qualifier type_qualifier, const cl_kernel_arg_type_qualifier type_qualifier,
@ -153,6 +158,9 @@ namespace clover {
std::vector<symbol> syms; std::vector<symbol> syms;
std::vector<section> secs; std::vector<section> secs;
std::vector<printf_info> printf_infos;
// printfs strings stored in output buffer
uint32_t printf_strings_in_buffer;
}; };
} }