From: Frieder F. <fri...@we...> - 2003-01-19 15:57:23
|
Hi, (sorry for the somewhat lengthy mail) The subject of this mail could have been: "improved readabily of generated assembly source" "hierarchical indentation" "white spaces in assembly generation" The assembly source is somewhat hard to read, because peephole roules spring to the eye whereas the higher levels (c-source, genXxx) seem somewhat hidden. An example: int tst_ib ( unsigned char t) { if(t) return 0; else return 0x1234; } compiles to: ;------------------------------------------------------------ ; test_ret.c:20: int tst_ib ( unsigned char t) ; ----------------------------------------- ; function tst_ib ; ----------------------------------------- _tst_ib: ; genReceive mov r2,dpl ; test_ret.c:22: if(t) return 0; ; genIfx mov a,r2 ; genIfxJump ; Peephole 110 removed ljmp by inverse jump logic jz 00102$ 00107$: ; genRet ; Peephole 181 used 16 bit load of dptr mov dptr,#0x0000 ; Peephole 132 changed ljmp to sjmp ; test_ret.c:23: else return 0x1234; ; genRet ; Peephole 182 used 16 bit load of dptr ; Peephole 237a removed sjmp to ret ret 00102$: mov dptr,#(((0x12)<<8) + 0x34) 00104$: ret Which is hard to read if you read more lines, or stare at the same lines a little longer;) (although I once was pleased that the peephole comments were so prominent) Using another scheme for indentation (f.e. +2 columns for each abstraction level), there is no "hierarchy inversion" in white spacing. So what about: ;------------------------------------------------------------ ; test_ret.c:20: int tst_ib ( unsigned char t) ; ----------------------------------------- ; function tst_ib ; ----------------------------------------- _tst_ib: ; genReceive mov r2,dpl ; test_ret.c:22: if(t) return 0; ; genIfx mov a,r2 ; genIfxJump ; Peephole 110 removed ljmp by inverse jump logic jz 00102$ 00107$: ; genRet ; Peephole 181 used 16 bit load of dptr mov dptr,#0x0000 ; Peephole 132 changed ljmp to sjmp ; test_ret.c:23: else return 0x1234; ; genRet ; Peephole 182 used 16 bit load of dptr ; Peephole 237a removed sjmp to ret ret 00102$: mov dptr,#(((0x12)<<8) + 0x34) 00104$: ret The PIC port already uses a similar indentation scheme. I'd submit a patch (mcs51) if this scheme makes sense and no tools are broken by it? Regards, Frieder |