jkmcnk / sx-gcc

The GNU Compiler Collection port to NEC SX CPU architecture.
GNU General Public License v2.0
0 stars 2 forks source link

returning unions/structs does not work #110

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
according to SX calling conventions, structs returning in memory is done by
the *caller* allocating stack space for return, and passing address to that
space in s123. (disassembly of super-ux libc div() routine seems to confirm
that)

this does not work when calling code compiled with SX cc (like libc) that
returns structs. otoh, calls to gcc-compiled struct-returning code works.
this is due to the fact that our implementation passes return value address
*on stack* instead of in register s123.

the fix is obvious: pass return value address in register. the non-obvious
part is that I need to find out how to tell it to gcc. ;)

Original issue reported on code.google.com by jmoc...@gmail.com on 16 Feb 2009 at 12:33

GoogleCodeExporter commented 8 years ago
also, struct-returning calls are expanded all wrong:

1. they don't "set" the memory that will contain results; i.e. they are 
expanded to

#(call_insn 11 10 13 (parallel [
#            (call (mem:QI (reg/f:DI 35 s35 [139]) [0 S1 A8])
#                (const_int 8 [0x8]))
#            (clobber (reg:DI 32 s32))
#            (clobber (reg:DI 33 s33))
#            (clobber (reg:DI 34 s34))
#            (clobber (reg:DI 36 s36))
#        ]) 89 {call_indirect} (nil)
#    (expr_list:REG_EH_REGION (const_int 0 [0x0])
#        (nil))
#    (nil))

instead of (set (mem ...) (call ...)): I suppose they should.

2. they don't mark s123 as used by the call. then again, calls don't really 
mark s3
etc. as used and these regs are not available for the allocator, so it might not
matter at all. however, it's probably better to be on the safe side ...

Original comment by jmoc...@gmail.com on 16 Feb 2009 at 12:43

GoogleCodeExporter commented 8 years ago
fixed with r239.

Original comment by jmoc...@gmail.com on 16 Feb 2009 at 1:38