PATCH: implement printf call lowering in the NVPTX backend
Jingyue Wu
jingyue at google.com
Thu Mar 27 10:46:23 PDT 2014
+ if (BufSize == 0) {
+ // If no arguments, pass a null pointer as the second argument to
vprintf.
+ BufferPtr = ConstantInt::get(Int32Ty, 0);
+ } else {
+ // Create the buffer to hold all the arguments. Align it to the
preferred
+ // alignment of the first object going into the buffer. Note: if
BufSize >
+ // 0, we know there's at least one object so getArgOperand(1) is
safe.
+ unsigned AlignOfFirst =
+ DL->getPrefTypeAlignment(Call->getArgOperand(1)->getType());
Does aligning the first argument ensures aligning other arguments? Consider
2
arguments, 1st 4-aligned, and 2nd 8-aligned. If the base of alloca is not a
multiple of 8, we can guarantee 2nd argument 8-aligned. For example, if the
base is 36, the address of 2nd argument is 36 + 8 which is not a multiple
of 8.
Is this alignment mandatory? Looks like getPrefTypeAlignment gives
"preferred
type ailgnment". OK to use it here?
+ BufferPtr = new AllocaInst(Type::getInt8Ty(M.getContext()),
+ ConstantInt::get(Int32Ty, BufSize),
+ AlignOfFirst,
+ "buf_for_vprintf_args", Call);
On Wed, Mar 26, 2014 at 9:51 AM, Eli Bendersky <eliben at google.com> wrote:
> Hello,
>
> This patch implements lowering of the printf call to the vprintf syscall
> in the NVPTX backend. It is implemented as a target-specific IR pass that
> runs before codegen. The pass builds the required data structure from the
> varargs to pass to the vprintf calls.
>
> Tests (IR to IR, and IR to PTX) included.
>
> PTAL,
> Eli
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140327/5c3d7d1f/attachment.html>
More information about the llvm-commits
mailing list