Menu

#253 Register parameter passing

open
nobody
z80 port (48)
5
2024-07-08
2008-03-20
No

Similar to RFE #979838, but #979838 is for mcs51, while this one is for Z80.

Passing arguments in registers would reduce call overhead.
However this makes sense for small parameters only: Any register pair can be pushed by the caller, but if the arguments are passed in registers that could mean that we'd have to move them around in registers a lot before the call. In a simialr way the callee would probably spend a lot of time reordering arguments, unless we take the registers used for arguments away from the register allocator.
Using the second register set is probably quite complicated.

I see two possible solutions:
*Use register arguments for functions where the sum of the arguments' sizes is below 24 bits only. We could then use a, h, l, which are not used by the register allocator for arguments.
*Let the user decide. The C standard allows use of the register storage class for function parameters.

Passing arguments in registers would mostly help with small function, which is currently one of sdcc's weak points.

Philipp

Related

Wiki: SDCC 4.3.0 Release
Wiki: SDCC 4.4.0 Release
Wiki: SDCC 4.5.0 Release

Discussion

<< < 1 2 3 (Page 3 of 3)
  • Aoineko

    Aoineko - 2022-05-03

    Seeing this ticket in the list of changes planned for 4.3.0 triggered me. What it is planed for the next big iteration of SDCC?
    Use of the register storage class for function parameters? ^^

     
    • Philipp Klaus Krause

      In 4.2.0, a new calling convention was introduced for stm8, z80, gbz80, z80n, z180. They now use register parameters.
      For 4.3.0, the focus will be on improving standard compliance. This spring, we already introduced struct parameters and return values for most ports. A lot of issues affecting C11 _Generic selections were fixed recently. There is ongoing work on C99 compound literals. We got C23 _BitInt this spring. For better C23 support, we'll need a new parser and preprocessor. C23 attributes are also planned.
      We might not get as far as we want for 4.3.0, but the goal is basically C23 compliance for stm8 and z80-related (i.e. architectures with good stack access) with the expection of double and long double only.

      P.S.: This ticket is still open for two reasons: 1) some z80-related ports (the Rabbits, eZ80 and TLCs-90) do not yet use register parameters by default. 2) We do not yet have user-specified calling conventions, to allow the user to specify the register for a parameter. Those will be supported via C23 attributes, so we'll first need the parser rewrite and C23 attribute support.

       

      Last edit: Philipp Klaus Krause 2022-05-03
      • Philipp Klaus Krause

        As of [r14373], all z80-related ports have switched to the new calling convention as default.
        So only user-specified calling conventions are still missing.

         

        Related

        Commit: [r14373]

  • Oleg Endo

    Oleg Endo - 2023-10-19

    Similar to RFE #979838, but #979838 is for mcs51, while this one is for Z80.

    @spth I can't find said RFE #979838 for mcs51, where is that? Highly interested in this one. Looking through the code generated for my mcs51 software, a different calling convention could improve things quite a bit.

     

    Last edit: Oleg Endo 2023-10-20
    • Philipp Klaus Krause

      Many years ago, ticket items got renumbered. Once they had global numbers, now they have per-tracker numbers. What was RFE #979838 is now [feature-requests:#79].

       
      👍
      1

      Related

      Feature Requests: #79

<< < 1 2 3 (Page 3 of 3)

Log in to post a comment.