This patch adds support for calling the printf and fprintf functions
from the GPU. The overall goal is to provide an implementation of
printf that is light-weight enough to be used on the GPU without
straining resources or being too slow.
The RPC interface allows for streaming arbitrary bytes from the client to
the server. To implement printf, we first stream the format string to
the server. Then, both sides use an extremely minimal parser to identify
the sizes and number of arguments that will be exchanged. The client will
then use this information to traverse through the variadic list with the
appropriate sizes and send the argument to the server. The server uses
this to build an array of all the argument to printf.
Once the server has these arguments, we can re-use the LLVM C library
handling of printf. With a custom argument list we can instead
traverse this array of pointers instead of a varadic list.
This patch depends on correct codegen and implementation of variadics on
the GPU, which is being handled by @JonChesterfield.
Depends on D158246
Should the argument be const & here and below?