From: kvigor Date: Thu, 3 May 2001 23:27:22 +0000 (+0000) Subject: slight improvement in generating literal shifts; not as good as re-enabling genLeftSh... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e23b1187a2343c3f73442f8ceebf57969a12cb7b;p=fw%2Fsdcc slight improvement in generating literal shifts; not as good as re-enabling genLeftShiftLiteral, but much easier git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@770 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 880b2e74..5c075290 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -6873,8 +6873,20 @@ genLeftShift (iCode * ic) more that 32 bits make no sense anyway, ( the largest size of an object can be only 32 bits ) */ - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE, FALSE)); - emitcode ("inc", "b"); + if (AOP_TYPE (right) == AOP_LIT) + { + /* Really should be handled by genLeftShiftLiteral, + * but since I'm too lazy to fix that today, at least we can make + * some small improvement. + */ + emitcode("mov", "b,#0x%02x", + ((int) floatFromVal (AOP (right)->aopu.aop_lit)) + 1); + } + else + { + emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE, FALSE)); + emitcode ("inc", "b"); + } freeAsmop (right, NULL, ic, TRUE); aopOp (left, ic, FALSE, FALSE); aopOp (result, ic, FALSE, AOP_TYPE (left) == AOP_DPTR); @@ -7189,8 +7201,7 @@ genSignedRightShift (iCode * ic) char *l; symbol *tlbl, *tlbl1; - D (emitcode (";", "genSignedRightShift "); - ); + D (emitcode (";", "genSignedRightShift ");); /* we do it the hard way put the shift count in b and loop thru preserving the sign */ @@ -7214,8 +7225,20 @@ genSignedRightShift (iCode * ic) more that 32 bits make no sense anyway, ( the largest size of an object can be only 32 bits ) */ - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE, FALSE)); - emitcode ("inc", "b"); + if (AOP_TYPE (right) == AOP_LIT) + { + /* Really should be handled by genRightShiftLiteral, + * but since I'm too lazy to fix that today, at least we can make + * some small improvement. + */ + emitcode("mov", "b,#0x%02x", + ((int) floatFromVal (AOP (right)->aopu.aop_lit)) + 1); + } + else + { + emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE, FALSE)); + emitcode ("inc", "b"); + } freeAsmop (right, NULL, ic, TRUE); aopOp (left, ic, FALSE, FALSE); aopOp (result, ic, FALSE, AOP_TYPE (left) == AOP_DPTR); @@ -7303,8 +7326,7 @@ genRightShift (iCode * ic) char *l; symbol *tlbl, *tlbl1; - D (emitcode (";", "genRightShift "); - ); + D (emitcode (";", "genRightShift ");); /* if signed then we do it the hard way preserve the sign bit moving it inwards */ @@ -7344,9 +7366,21 @@ genRightShift (iCode * ic) only the lower order byte since shifting more that 32 bits make no sense anyway, ( the largest size of an object can be only 32 bits ) */ - - emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE, FALSE)); - emitcode ("inc", "b"); + + if (AOP_TYPE (right) == AOP_LIT) + { + /* Really should be handled by genRightShiftLiteral, + * but since I'm too lazy to fix that today, at least we can make + * some small improvement. + */ + emitcode("mov", "b,#0x%02x", + ((int) floatFromVal (AOP (right)->aopu.aop_lit)) + 1); + } + else + { + emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE, FALSE)); + emitcode ("inc", "b"); + } freeAsmop (right, NULL, ic, TRUE); aopOp (left, ic, FALSE, FALSE); aopOp (result, ic, FALSE, AOP_TYPE (left) == AOP_DPTR);