From: ceriel Date: Fri, 7 Oct 1988 16:52:44 +0000 (+0000) Subject: many changes: optimize generated code somewhat, X-Git-Tag: release-5-5~2800 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f397d35b6a19591a7e169f621937e380b000760e;p=ack.git many changes: optimize generated code somewhat, reduce relocation-table size --- diff --git a/mach/sun3/ce/EM_table b/mach/sun3/ce/EM_table index 5b47fe27d..379051700 100644 --- a/mach/sun3/ce/EM_table +++ b/mach/sun3/ce/EM_table @@ -18,8 +18,8 @@ C_loe.. ==> "move.l ($1+$2), -(sp)". C_lil ==> "move.l ([$1,a6]), -(sp)". -C_lof ==> "move.l (sp)+, a0"; - "move.l ($1,a0), -(sp)". +C_lof ==> "move.l (sp), a0"; + "move.l ($1,a0), (sp)". C_lal ==> "pea ($1,a6)". @@ -44,16 +44,16 @@ C_lxa "pea (8,a0)". C_loi - $1 == 1 ==> "move.l (sp)+, a0"; - "clr.l -(sp)"; + $1 == 1 ==> "move.l (sp), a0"; + "clr.l (sp)"; "move.b (a0), (3,sp)". - $1 == 2 ==> "move.l (sp)+, a0"; - "clr.l -(sp)"; + $1 == 2 ==> "move.l (sp), a0"; + "clr.l (sp)"; "move.w (a0), (2,sp)". - $1 == 4 ==> "move.l (sp)+, a0"; - "move.l (a0), -(sp)". - $1 == 8 ==> "move.l (sp)+, a0"; - "move.l (4,a0), -(sp)"; + $1 == 4 ==> "move.l (sp), a0"; + "move.l (a0), (sp)". + $1 == 8 ==> "move.l (sp), a0"; + "move.l (4,a0), (sp)"; "move.l (a0), -(sp)". $1 % 4 == 0 ==> "move.l (sp)+, a0"; "move.l #$1/4-1, d0"; @@ -74,8 +74,8 @@ C_ldl ==> "move.l ($1+4, a6), -(sp)"; C_lde.. ==> "move.l ($1+$2+4), -(sp)"; "move.l ($1+$2), -(sp)". -C_ldf ==> "move.l (sp)+, a0"; - "move.l ($1+4,a0), -(sp)"; +C_ldf ==> "move.l (sp), a0"; + "move.l ($1+4,a0), (sp)"; "move.l ($1,a0), -(sp)". C_lpi ==> "pea ($1)". @@ -142,22 +142,23 @@ C_sbi C_mli $1 == 4 ==> "move.l (sp)+, d0"; - "muls.l (sp)+, d0"; - "move.l d0, -(sp)". + "muls.l (sp), d0"; + "move.l d0, (sp)". default ==> arg_error( "mli", $1). C_dvi $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "divs.l d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> arg_error( "dvi", $1). C_rmi $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; - "divsl.l d0, d2:d1"; - "move.l d2, -(sp)". + "move.l (sp), d1"; + "move.l d0, (sp)"; + "divsl.l (sp), d0:d1"; + "move.l d0, (sp)". default ==> arg_error( "rmi", $1). C_ngi @@ -167,16 +168,16 @@ C_ngi C_sli $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "asl.l d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> arg_error( "sli", $1). C_sri $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "asr.l d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> arg_error( "sri", $1). @@ -193,31 +194,32 @@ C_sbu ==> C_sbi( w). C_mlu $1 == 4 ==> "move.l (sp)+, d0"; - "mulu.l (sp)+, d0"; - "move.l d0, -(sp)". + "mulu.l (sp), d0"; + "move.l d0, (sp)". default ==> arg_error( "mlu", $1). C_dvu $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "divu.l d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> arg_error( "dvu", $1). C_rmu $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; - "divul.l d0, d2:d1"; - "move.l d2, -(sp)". + "move.l (sp), d1"; + "move.l d0, (sp)"; + "divul.l (sp), d0:d1"; + "move.l d0, (sp)". default ==> arg_error( "rmu", $1). C_slu ==> C_sli( w). C_sru $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "lsr.l d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> arg_error( "sru", $1). @@ -319,25 +321,19 @@ C_zer /* */ /******************************************************************************/ -C_cii ==> " move.l (sp), d0"; - " move.l (4, sp), d1"; +/* cii, ciu, cuu, cui are assumed to be called with legal arguments only */ + +C_cii ==> " move.l (sp)+, d0"; + " move.l (sp)+, d1"; " cmp.l d1, d0"; " ble 4f"; - " cmp.l #4, d1"; - " bge 4f"; - " move.l (8, sp), d2"; + " move.l (sp), d0"; " cmp.l #1, d1"; " bne 2f"; - " cmp.l #2, d0"; - " bne 1f"; - " ext.w d2"; - " bra 3f"; - "1: extl.l d2"; - " bra 3f"; - "2: ext.l d2"; - "3: move.l d2, (8, sp)"; - " move.l #4, (4, sp)"; - "4: jsr (.cii)". + " ext.w d0"; + "2: ext.l d0"; + " move.l d0,(sp)"; + "4:". C_cuu ==> "lea (8,sp),sp". @@ -403,16 +399,16 @@ C_com C_rol $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "rol.l d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> arg_error( "rol", $1). C_ror $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "ror.l d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> arg_error( "ror", $1). @@ -424,11 +420,11 @@ C_ror C_inn $1 == 4 ==> "move.l (sp)+, d0"; - "move.l (sp)+, d1"; + "move.l (sp), d1"; "btst d0, d1"; "sne d1"; "and.l #1, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> "move.l (sp)+, d0"; "move.l #$1, d1"; "jsr (.inn)"; @@ -440,10 +436,10 @@ C_inn_narg ==> "move.l (sp)+, d1"; "move.l d0, -(sp)". C_set - $1 == 4 ==> "move.l (sp)+, d0"; + $1 == 4 ==> "move.l (sp), d0"; "clr.l d1"; "bset d0, d1"; - "move.l d1, -(sp)". + "move.l d1, (sp)". default ==> "move.l (sp)+, d0"; "move.l #$1, d1"; "jsr (.set)". @@ -526,43 +522,43 @@ C_cms_narg ==> "move.l (sp)+, d0"; C_cmp ==> C_cmu( (arith)4). -C_tlt ==> "move.l (sp)+, d0"; - "move.l #1, -(sp)"; +C_tlt ==> "move.l (sp), d0"; + "move.l #1, (sp)"; "tst.l d0"; "blt 1f"; "clr.l (sp)"; "1:". -C_tle ==> "move.l (sp)+, d0"; - "move.l #1, -(sp)"; +C_tle ==> "move.l (sp), d0"; + "move.l #1, (sp)"; "tst.l d0"; "ble 1f"; "clr.l (sp)"; "1:". -C_teq ==> "move.l (sp)+, d0"; - "move.l #1, -(sp)"; +C_teq ==> "move.l (sp), d0"; + "move.l #1, (sp)"; "tst.l d0"; "beq 1f"; "clr.l (sp)"; "1:". -C_tne ==> "move.l (sp)+, d0"; - "move.l #1, -(sp)"; +C_tne ==> "move.l (sp), d0"; + "move.l #1, (sp)"; "tst.l d0"; "bne 1f"; "clr.l (sp)"; "1:". -C_tge ==> "move.l (sp)+, d0"; - "move.l #1, -(sp)"; +C_tge ==> "move.l (sp), d0"; + "move.l #1, (sp)"; "tst.l d0"; "bge 1f"; "clr.l (sp)"; "1:". -C_tgt ==> "move.l (sp)+, d0"; - "move.l #1, -(sp)"; +C_tgt ==> "move.l (sp), d0"; + "move.l #1, (sp)"; "tst.l d0"; "bgt 1f"; "clr.l (sp)"; @@ -800,6 +796,6 @@ C_trp ==> "jsr (.trp)". prolog ==> . -jump ==> "jmp $1". +jump ==> "bra $1". locals ==> "link a6, #-$1". diff --git a/mach/sun3/ce/mach.h b/mach/sun3/ce/mach.h index f9091c4c8..78770e9e4 100644 --- a/mach/sun3/ce/mach.h +++ b/mach/sun3/ce/mach.h @@ -36,6 +36,7 @@ #define RELOC2_FMT ".data2 %s + %ld\n" #define RELOC4_FMT ".data4 %s + %ld\n" +#define GENLAB 'I' /* compiler-generated labels start with ... */ diff --git a/mach/sun3/ce/output.c b/mach/sun3/ce/output.c index c960e75cc..5a0765b27 100644 --- a/mach/sun3/ce/output.c +++ b/mach/sun3/ce/output.c @@ -39,18 +39,21 @@ output() Malloc((unsigned)nrelo*sizeof(struct relocation_info)); for (i = 0; i < nrelo; i++) { - if ( ( reloc_info[i].or_sect-S_MIN) == SEGTXT) { - convert_reloc( &reloc_info[i], u_reloc++); + if ( ( reloc_info[i].or_sect-S_MIN) == SEGTXT && + convert_reloc( &reloc_info[i], u_reloc)) { trsize++; + u_reloc++; } } for (i = 0; i < nrelo; i++) { - if ( ( reloc_info[i].or_sect-S_MIN) != SEGTXT) { - convert_reloc( &reloc_info[i], u_reloc++); + if ( ( reloc_info[i].or_sect-S_MIN) != SEGTXT && + convert_reloc( &reloc_info[i], u_reloc)) { + u_reloc++; drsize++; } } + nrelo = trsize + drsize; u_reloc -= nrelo; init_unixheader(); @@ -104,6 +107,8 @@ convert_reloc( a_relo, u_relo) struct outrelo *a_relo; struct relocation_info *u_relo; { + int retval = 1; + u_relo->r_address = a_relo->or_addr; u_relo->r_symbolnum = a_relo->or_nami; u_relo->r_pcrel = (a_relo->or_type & RELPC) >> 3; @@ -116,6 +121,9 @@ struct relocation_info *u_relo; if ( u_relo->r_extern == 0) { switch ( (symbol_table[ a_relo->or_nami].on_type & S_TYP) - S_MIN) { case SEGTXT : u_relo->r_symbolnum = N_TEXT; + if (u_relo->r_pcrel && + (a_relo->or_sect-S_MIN == SEGTXT)) + retval = 0; break; case SEGCON : u_relo->r_symbolnum = N_DATA; break; @@ -126,6 +134,7 @@ struct relocation_info *u_relo; (symbol_table[ a_relo->or_nami].on_type & S_TYP) - S_MIN); } } + return retval; } @@ -176,8 +185,7 @@ long valu; { int sect; - *u_type = '\0'; - *u_type |= ( *a_type & S_EXT) ? N_EXT : N_UNDF; + *u_type = ((*a_type&S_TYP) == S_UND || (*a_type & S_EXT)) ? N_EXT : 0; if ( valu != -1 && (! (*a_type & S_COM))) { sect = ( *a_type & S_TYP ) - S_MIN; diff --git a/mach/sun3/ce/relocation.c b/mach/sun3/ce/relocation.c index f1c41a6d9..e4a92c58c 100644 --- a/mach/sun3/ce/relocation.c +++ b/mach/sun3/ce/relocation.c @@ -5,63 +5,51 @@ long get4(); extern long base_address(); +/* extern short get2(); extern char get1(); - -static do_relo(); +*/ do_local_relocation() { - register struct outrelo *ptr; - register int s; + register struct outrelo *rp; /* print( "n relocation records %d\n", relo - reloc_info); */ - for ( ptr = reloc_info; ptr < relo; ptr++) { - s = ptr->or_nami; - if ( symbol_table[ s].on_valu != -1 && - ! (symbol_table[s].on_type & S_COM)) - do_relo(&symbol_table[ s], ptr); - } -} + for ( rp = reloc_info; rp < relo; rp++) { + register struct outname *np = &symbol_table[rp->or_nami]; + if ( np->on_valu != -1 && ! (np->on_type & S_COM)) { + register long oldval,newval; + register char *sect; -static -do_relo(np,rp) -struct outname *np; -struct outrelo *rp; -{ - long oldval,newval; - char *sect; - - switch( rp->or_sect - S_MIN) { - case SEGTXT: - sect = text_area; - break; - case SEGCON: - sect = data_area; - break; - default: - fprint( STDERR, - "do_local_relo(): bad section %d\n", - rp->or_sect - S_MIN); - break; + switch( rp->or_sect - S_MIN) { + case SEGTXT: + sect = text_area; + break; + case SEGCON: + sect = data_area; + break; + default: + fprint( STDERR, + "do_local_relo(): bad section %d\n", + rp->or_sect - S_MIN); + break; + } + oldval = get4( sect, rp->or_addr); + newval = oldval + np->on_valu + + base_address( (np->on_type & S_TYP) -S_MIN); + if ( rp->or_type & RELO4) + put4( sect, rp->or_addr, newval); + /* + else if ( rp->or_type & RELO2) + put2( sect, rp->or_addr, (int) newval); + else if ( rp->or_type & RELO1) + put1( sect, rp->or_addr, (char) newval); + */ + else + print( STDERR, + "do_relo() : bad relocation size\n"); + } } - oldval = get4( sect, rp->or_addr); - newval = oldval + np->on_valu + - base_address( (np->on_type & S_TYP) -S_MIN); - if ( rp->or_type & RELO4) - put4( sect, rp->or_addr, newval); - /* - else if ( rp->or_type & RELO2) - put2( sect, rp->or_addr, (int) newval); - else if ( rp->or_type & RELO1) - put1( sect, rp->or_addr, (char) newval); - */ - else - print( STDERR, "do_relo() : bad relocation size\n"); - /* print( "reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n", -np->on_foff + string_area, rp->or_addr, rp->or_sect-S_MIN, oldval, newval, -np->on_valu); - */ }