Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#85 Z80 peephole and code generation patch

closed-accepted
Maarten Brock
None
5
2007-05-05
2007-04-14
No

This patch contains a complete rewrite of the Z80 peephole rules and a minor modification of Z80 code generation.

This patch significantly improves size and speed of generated Z80 asm code. The regression tests pass without failures. In my test program I got this size reduction:

sdcc 2.6.5 #4749: 23354 bytes.
sdcc 2.6.5 #4749 with this patch: 23081 bytes.
sdcc 2.6.5 #4749 with this patch and the one in bugreport 1677178: 22940 bytes.

This test program contains ~15KB data and hand-coded asm, so we see a significant improvement in the sdcc-generated code.

Philipp

Discussion

1 2 > >> (Page 1 of 2)
  • Logged In: YES
    user_id=564030
    Originator: YES

    One of the optimizations in this patch implements feature request #1491847.

     
  • Logged In: YES
    user_id=589052
    Originator: NO

    Hi Z80 users, hi Philip,

    being a Z80 illiterate I cannot review the patch.
    Yet I feel the change to gen.c should go in (before 2.7.0)

    As to the changes to the peephole rules I'm not sure
    (the regression test suite would for example be
    a poor test bed for missing "notVolatile" checks).
    Without review by Z80 users I feel this is
    "post 2.7.0".
    Currently the Z80 community is surprisingly silent
    although SDCC for Z80 seems to be in use
    (f.e. http://aredfox.com/eqa.htm\).

    Borut would have the last word on this.

     
  • Borut Ražem
    Borut Ražem
    2007-04-21

    Logged In: YES
    user_id=568035
    Originator: NO

    Hi Philip,

    I took a look to the patch and I have a question: if I understand well you put all z80 peephole rules to peeph-z80.def and you remove everything from peeph.def.

    But now the problem are gbz80 rules: they are in peeph.def and peeph-gbz80.def, but peeph.def is now empty!?

    Is this correct?
    Probably we should move the old content of peeph.def to peeph-gbz80.def?

    Borut

     
  • Borut Ražem
    Borut Ražem
    2007-04-21

    • assigned_to: nobody --> borutr
     
  • Logged In: YES
    user_id=564030
    Originator: YES

    > Is this correct?

    I do not know much about the gbz80 CPU, so I placed my new peephole rules in peeph-z80.def to not breake the gbz80 port. I've looked at some information about the gbz80 CPU though and noticed that some of the instructions used in peephole rules in the old peeph.def are not valid gbz80 instructions. So I decided to not add rules from peeph.def to peeph-gbz80.def.
    I'll post a new patch with some rules moved from peeph-z80.def to peeph.def, but only rules from the top of peeph-z80.def where I am sure that they'll cause not problems on the gbz80. a gbz80 expert should look at it some day in the future and decide if more rules can be moved to peeph.def or if simular rules should be added to peeph-gbz80.def.

     
  • Borut Ražem
    Borut Ražem
    2007-04-21

    Logged In: YES
    user_id=568035
    Originator: NO

    > I've looked at some
    > information about the gbz80 CPU though and noticed that some of the
    > instructions used in peephole rules in the old peeph.def are not valid
    > gbz80 instructions. So I decided to not add rules from peeph.def to
    > peeph-gbz80.def.

    How is this possible??? gbz80 includes both peeph.def and peeph-gbz80.def, so it means that gbz80 was broken?

    Borut

     
  • Logged In: NO

    Here's a new patch. I've added a few peephole rules, moved many peephole rules which should work on the gbz80 from peeph-z80.def to peeph.def.
    I've run the Z80 regression tests and got no errors.
    I used sdcc #4749.
    Now all peephole rules except for the gbz80-specific ones add comments to the .asm-files. This should make debugging and improving the peephole rules easier.

     
  • Z80 peephole and code generation patch - new version

     
    Attachments
  • Logged In: YES
    user_id=564030
    Originator: YES

    Here's the patch, sorry for not logging in for the last post.
    File Added: Z80peephole.patch

     
  • Maarten Brock
    Maarten Brock
    2007-05-05

    • assigned_to: borutr --> maartenbrock
    • status: open --> closed-accepted
     
1 2 > >> (Page 1 of 2)