I don't object to text processing as that seems perfectly adequate at the moment. In the event people want the peephole optimization to apply to inlined asm, we'd also have to process the inlined z80 before passing to sdcc. If sdcc is not allowed to look at inlined asm, then it has to be more conservative. Inlined asm should be rare anyway.
For the text processing to work, z80asm needs to be updated to support the "GLOBAL" directive. That is on the docket but it's not implemented yet; that's Paulo's area so that depends on his time.
I think the following text processing will work if anyone would like to try:
**************REMOVE BLOCK OF TEXT FROM EVERY FILE
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area _INITIALIZED
{any amount text or until next .area}
;--------------------------------------------------------
replace with commented line of dashes
**************SUBSTITUTIONS (in order)
%s:: -> %s:
%s$ -> l_foo_%s
.area _XSEG -> SECTION IGNORE
.area _STACK -> SECTION IGNORE
.area _CODE_%s -> SECTION code_compiler_bank_%s
.area _CODE -> SECTION code_compiler
.area _DATA -> SECTION bss_compiler
.area _RSEG (ABS) -> SECTION IGNORE
.area _GSINIT -> SECTION code_crt_init
.area _GSFINAL -> SECTION code_crt_exit
.area _HOME -> SECTION IGNORE
.area _CABS (ABS) -> SECTION IGNORE
.area _DABS (ABS) -> SECTION IGNORE
.area _INITIALIZER -> SECTION data_compiler
.area -> SECTION
.ascii -> DEFM
.ds -> DEFS
.db -> DEFB
.dw -> DEFW
#<(%s) -> #(%s & 0xFF)
#>(%s) -> #(%s / 256)
.module -> MODULE
.globl -> GLOBAL
.org -> org
%s = . -> %s:
%s = %s -> defc %s = %s
%s(%s) -> (%s+%s)
__xinit_%s -> %s
# -> +
************** APPEND TEXT TO EVERY FILE
; sdcc implied primitives
EXTERN __divschar
EXTERN __divsint
EXTERN __divslong
EXTERN __divslonglong
EXTERN __divsuchar
EXTERN __divuchar
EXTERN __divuint
EXTERN __divulong
EXTERN __divulonglong
EXTERN __divuschar
EXTERN __modschar
EXTERN __modsint
EXTERN __modslong
EXTERN __modslonglong
EXTERN __modsuchar
EXTERN __moduchar
EXTERN __moduint
EXTERN __modulong
EXTERN __modulonglong
EXTERN __moduschar
EXTERN __mulint
EXTERN __mullong
EXTERN __mullonglong
EXTERN __mulschar
EXTERN __mulsuchar
EXTERN __muluschar
EXTERN __rlslonglong
EXTERN __rlulonglong
EXTERN __rrslonglong
EXTERN __rrulonglong
EXTERN __sdcc_call_hl
EXTERN banked_call
EXTERN banked_ret
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now.
http://goparallel.sourceforge.net/