tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Questions about commit 5b28165: Fix test 131 for 32 b


From: Ziyao
Subject: Re: [Tinycc-devel] Questions about commit 5b28165: Fix test 131 for 32 bits targets
Date: Sat, 08 Jul 2023 16:12:42 +0800

On 2023-07-08 01:25, grischka wrote:
Hi,

well, problem is simply that with 32-bit longs your data
   0x1234567890abcd
would be truncated to
   0x7890abcd
and the output from %lx would not match the .expect file.

Thanks for explanation. But replacing 0x1234567890abcd with
0x12345678 (32-bit length) may be better?

Btw is your fix incorrect.  The code that you "fixed" is about
alignment but there was no alignment problem in your case.

The real problem is below at "vtop->c.i += regsize;" which can
advance the location to load the 2nd register only for local or
global/static memory.

If the struct is not aligned, it will be copied to an aligned
address on stack. With this fix, returned structs without
VT_LVAL | VT_LLOCAL will also be copied onto stack as the same way
in which unaligned ones are copied, thus code below could handle it.

For pointers it would need to emit an 'add r, regsize' instruction
You can see such code in gv():

    gaddrof();
    vpushs(PTR_SIZE);
    gen_op('+');
    vtop->r |= VT_LVAL;

-- gr


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

--
Ziyao



reply via email to

[Prev in Thread] Current Thread [Next in Thread]