From: Sandeep D. <sa...@dd...> - 2000-02-11 19:50:35
|
Michael, Welcome to the wonderful world of register packing.. this is a term I use to describe the phase for reducing temporaries (in a processor specific manner)..think of them as peephole optimizations on the intermediate code..in your case for example the iCode sequence would probably look something like itempX[b c] := iTempY[d e]; iTempX[b c] = iTempX[b c] + 1; iTempY[d e] := iTempX[b c]; Here register packing would reduce the code to iTempY := iTempY + 1; if there is no other usage of iTempX.. take a look @ packRegistersForAssign in mcs51/gen.c.. in a tree walking code generator (like burg - as in lcc) this phase would have been much simpler ... Couple of important things here to determie usage & definitions the MACRO ..OP_DEFS & OP_USES yeild the definition & usage bitvectors respectively.. bitVectnBitsOn(OP_DEFS(operand type*)) will yield number of definitions for this iTemp..similarly bitVectnBitsOn(OP_USES(operand type*)) will give you the number of uses.. to check if an operand is used in an iCode or not if (bitVectBitValue(OP_USES(operand type*),iCode type*->key)) then there are several other useful things you could do with these bit vectors... to see if two operands are used in the same icode if (bitVectBitsInCommon(OP_USES(op1),OP_USES(op2)); Hope this information helps.. Sandeep > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > It's messier than I thought :) The first optimisation seems to be pointer > fetch/inc dependent. This code: > > Is: Should be: > - ---------------------------------------- -------------------- > ; genAssign > ld -4(ix),e ; tmp = d -4(ix) = de > ld -3(ix),d > ; genPlus > ; genPlusIncr > ld c,e inc de > ld b,d (ie really bad !) > inc bc > ; genAssign > ld e,c > ld d,b > ; genAssign > ld l,-2(ix) ; 0 hl = -2(ix) > ld h,-1(ix) ; 1 > ; genPlus > ; genPlusIncr > ld c,-2(ix) ; 0 inc -2(ix) > ld b,-1(ix) ; 1 jr > inc bc inc -1(ix) > ; genAssign > ld -2(ix),c > ld -1(ix),b > ; genPointerGet > ld a,(hl) a = (hl) > ld c,a > ; genAssign (pointer) > ld l,-4(ix) ; 0 hl = -4(ix) > ld h,-3(ix) ; 1 > ld (hl),c ld (hl),a > ; genGoto > jp 00101$ jp > > is generated from part of a standard memcpy: > *d++ = *s++ > > - -- Michael > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.0 (GNU/Linux) > Comment: For info see http://www.gnupg.org > > iD8DBQE4o5qLUejL3SuzxEgRAkYnAJwJT9BQU4nj1QbS/BGzqJPPHbxieACeKUrm > CBfr/S6MAFK+fDBkDUzFAlA= > =ER8C > -----END PGP SIGNATURE----- > > _______________________________________________ > sdcc-devel mailing list > sdc...@li... > http://lists.sourceforge.net/mailman/listinfo/sdcc-devel -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sandeep Dutta Phone: 650-356-5417 Diab-SDS Fax: 650-356-5490 323 Vintage Park Drive Email: sa...@dd... Foster City, CA 94404 URL: www.ddi.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |