From 868dec7b340646d592b34da606c7fdef3d35a267 Mon Sep 17 00:00:00 2001 From: epetrich Date: Wed, 20 Aug 2003 06:51:32 +0000 Subject: [PATCH] Changed the type of the result of the ! (NOT) operator to char; previously it returned the same type as the source. This allows us to eliminate all the genFloatNot functions (all of its target implementations were very buggy) since !float can use the same code as !long now. * src/SDCCicode.c (ast2iCode): ! returns char * src/mcs51/gen.c (genNot, genNotFloat), * src/ds390/gen.c (genNot, genNotFloat), * src/z80/gen.c (genNot, genNotFloat), * src/pic/gen.c (genNot, genNotFloat), * src/pic16/gen.c (genNot, genNotFloat): eliminated genNotFloat git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2839 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 17 ++++++++++++++++- src/SDCCicode.c | 2 +- src/ds390/gen.c | 49 ----------------------------------------------- src/mcs51/gen.c | 51 ++----------------------------------------------- src/pic/gen.c | 47 +-------------------------------------------- src/pic16/gen.c | 47 +-------------------------------------------- src/z80/gen.c | 46 -------------------------------------------- 7 files changed, 21 insertions(+), 238 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ebd65e3..8e9ca1c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-08-20 Erik Petrich + + Changed the type of the result of the ! (NOT) operator to char; + previously it returned the same type as the source. This allows + us to eliminate all the genFloatNot functions (all of its target + implementations were very buggy) since !float can use the same + code as !long now. + + * src/SDCCicode.c (ast2iCode): ! returns char + * src/mcs51/gen.c (genNot, genNotFloat), + * src/ds390/gen.c (genNot, genNotFloat), + * src/z80/gen.c (genNot, genNotFloat), + * src/pic/gen.c (genNot, genNotFloat), + * src/pic16/gen.c (genNot, genNotFloat): eliminated genNotFloat + 2003-08-19 Bernhard Held pic patch provided by Slade Rich @@ -26,7 +41,7 @@ 2003-08-18 Erik Petrich - * src/z80/gen.c (isUnsplitable, fetchPairLog): fixed bug #770454 + * src/z80/gen.c (isUnsplitable, fetchPairLong): fixed bug #770454 2003-08-18 Erik Petrich diff --git a/src/SDCCicode.c b/src/SDCCicode.c index eac7ec10..abafe41f 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -3637,11 +3637,11 @@ ast2iCode (ast * tree,int lvl) #endif case '~': - case '!': case RRC: case RLC: return geniCodeUnary (geniCodeRValue (left, FALSE), tree->opval.op); + case '!': case GETHBIT: { operand *op = geniCodeUnary (geniCodeRValue (left, FALSE), tree->opval.op); diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 419896b1..4deb61a2 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -1607,47 +1607,6 @@ reAdjustPreg (asmop * aop) emitcode("nop", "; workaround for DS80C390 div bug."); \ } -/*-----------------------------------------------------------------*/ -/* genNotFloat - generates not for float operations */ -/*-----------------------------------------------------------------*/ -static void -genNotFloat (operand * op, operand * res) -{ - int size, offset; - symbol *tlbl; - - D (emitcode (";", "genNotFloat ");); - - /* we will put 127 in the first byte of - the result */ - aopPut (AOP (res), "#127", 0); - size = AOP_SIZE (op) - 1; - offset = 1; - - _startLazyDPSEvaluation (); - MOVA(aopGet(op->aop, offset++, FALSE, FALSE, NULL)); - - while (size--) - { - emitcode ("orl", "a,%s", - aopGet (op->aop, - offset++, FALSE, FALSE, - DP2_RESULT_REG)); - } - _endLazyDPSEvaluation (); - - tlbl = newiTempLabel (NULL); - aopPut (res->aop, one, 1); - emitcode ("jz", "!tlabel", (tlbl->key + 100)); - aopPut (res->aop, zero, 1); - emitcode ("", "!tlabeldef", (tlbl->key + 100)); - - size = res->aop->size - 2; - offset = 2; - /* put zeros in the rest */ - while (size--) - aopPut (res->aop, zero, offset++); -} /*-----------------------------------------------------------------*/ /* opIsGptr: returns non-zero if the passed operand is */ @@ -1797,7 +1756,6 @@ static void genNot (iCode * ic) { symbol *tlbl; - sym_link *optype = operandType (IC_LEFT (ic)); D (emitcode (";", "genNot ");); @@ -1814,13 +1772,6 @@ genNot (iCode * ic) goto release; } - /* if type float then do float */ - if (IS_FLOAT (optype)) - { - genNotFloat (IC_LEFT (ic), IC_RESULT (ic)); - goto release; - } - toBoolean (IC_LEFT (ic)); tlbl = newiTempLabel (NULL); diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 7e1494c8..0a5e3598 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -132,7 +132,8 @@ emitcode (char *inst, const char *fmt,...) while (isspace (*lbp)) lbp++; - +// printf ("%s\n", lb); // EEP - debugging + if (lbp && *lbp) lineCurr = (lineCurr ? connectLine (lineCurr, newLineNode (lb)) : @@ -1205,46 +1206,6 @@ reAdjustPreg (asmop * aop) (x->aopu.aop_reg[0] == mcs51_regWithIdx(R0_IDX) || \ x->aopu.aop_reg[0] == mcs51_regWithIdx(R1_IDX) ))) -/*-----------------------------------------------------------------*/ -/* genNotFloat - generates not for float operations */ -/*-----------------------------------------------------------------*/ -static void -genNotFloat (operand * op, operand * res) -{ - int size, offset; - char *l; - symbol *tlbl; - - D(emitcode ("; genNotFloat","")); - - /* we will put 127 in the first byte of - the result */ - aopPut (AOP (res), "#127", 0, isOperandVolatile (op, FALSE)); - size = AOP_SIZE (op) - 1; - offset = 1; - - l = aopGet (op->aop, offset++, FALSE, FALSE); - MOVA (l); - - while (size--) - { - emitcode ("orl", "a,%s", - aopGet (op->aop, - offset++, FALSE, FALSE)); - } - - tlbl = newiTempLabel (NULL); - aopPut (res->aop, one, 1, isOperandVolatile (op, FALSE)); - emitcode ("jz", "%05d$", (tlbl->key + 100)); - aopPut (res->aop, zero, 1, isOperandVolatile (op, FALSE)); - emitcode ("", "%05d$:", (tlbl->key + 100)); - - size = res->aop->size - 2; - offset = 2; - /* put zeros in the rest */ - while (size--) - aopPut (res->aop, zero, offset++, isOperandVolatile (op, FALSE)); -} /*-----------------------------------------------------------------*/ /* opIsGptr: returns non-zero if the passed operand is */ @@ -1343,7 +1304,6 @@ static void genNot (iCode * ic) { symbol *tlbl; - sym_link *optype = operandType (IC_LEFT (ic)); D(emitcode ("; genNot","")); @@ -1360,13 +1320,6 @@ genNot (iCode * ic) goto release; } - /* if type float then do float */ - if (IS_FLOAT (optype)) - { - genNotFloat (IC_LEFT (ic), IC_RESULT (ic)); - goto release; - } - toBoolean (IC_LEFT (ic)); tlbl = newiTempLabel (NULL); diff --git a/src/pic/gen.c b/src/pic/gen.c index eadf223a..c2bb459f 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -1732,44 +1732,6 @@ static void reAdjustPreg (asmop *aop) } -/*-----------------------------------------------------------------*/ -/* genNotFloat - generates not for float operations */ -/*-----------------------------------------------------------------*/ -static void genNotFloat (operand *op, operand *res) -{ - int size, offset; - char *l; - symbol *tlbl ; - - DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__); - /* we will put 127 in the first byte of - the result */ - aopPut(AOP(res),"#127",0); - size = AOP_SIZE(op) - 1; - offset = 1; - - l = aopGet(op->aop,offset++,FALSE,FALSE); - MOVA(l); - - while(size--) { - pic14_emitcode("orl","a,%s", - aopGet(op->aop, - offset++,FALSE,FALSE)); - } - tlbl = newiTempLabel(NULL); - - tlbl = newiTempLabel(NULL); - aopPut(res->aop,one,1); - pic14_emitcode("jz","%05d_DS_",(tlbl->key+100)); - aopPut(res->aop,zero,1); - pic14_emitcode("","%05d_DS_:",(tlbl->key+100)); - - size = res->aop->size - 2; - offset = 2; - /* put zeros in the rest */ - while (size--) - aopPut(res->aop,zero,offset++); -} #if 0 /*-----------------------------------------------------------------*/ @@ -1884,7 +1846,6 @@ void pic14_toBoolean(operand *oper) static void genNot (iCode *ic) { symbol *tlbl; - sym_link *optype = operandType(IC_LEFT(ic)); int size; DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__); @@ -1906,13 +1867,7 @@ static void genNot (iCode *ic) goto release; } - /* if type float then do float */ - if (IS_FLOAT(optype)) { - genNotFloat(IC_LEFT(ic),IC_RESULT(ic)); - goto release; - } - - size = AOP_SIZE(IC_RESULT(ic)); + size = AOP_SIZE(IC_LEFT(ic)); if(size == 1) { emitpcode(POC_COMFW,popGet(AOP(IC_LEFT(ic)),0)); emitpcode(POC_ANDLW,popGetLit(1)); diff --git a/src/pic16/gen.c b/src/pic16/gen.c index cf80da3c..d9fd14dc 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -1728,44 +1728,6 @@ static void reAdjustPreg (asmop *aop) } -/*-----------------------------------------------------------------*/ -/* genNotFloat - generates not for float operations */ -/*-----------------------------------------------------------------*/ -static void genNotFloat (operand *op, operand *res) -{ - int size, offset; - char *l; - symbol *tlbl ; - - DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__); - /* we will put 127 in the first byte of - the result */ - pic16_aopPut(AOP(res),"#127",0); - size = AOP_SIZE(op) - 1; - offset = 1; - - l = pic16_aopGet(op->aop,offset++,FALSE,FALSE); - MOVA(l); - - while(size--) { - pic16_emitcode("orl","a,%s", - pic16_aopGet(op->aop, - offset++,FALSE,FALSE)); - } - tlbl = newiTempLabel(NULL); - - tlbl = newiTempLabel(NULL); - pic16_aopPut(res->aop,one,1); - pic16_emitcode("jz","%05d_DS_",(tlbl->key+100)); - pic16_aopPut(res->aop,zero,1); - pic16_emitcode("","%05d_DS_:",(tlbl->key+100)); - - size = res->aop->size - 2; - offset = 2; - /* put zeros in the rest */ - while (size--) - pic16_aopPut(res->aop,zero,offset++); -} #if 0 /*-----------------------------------------------------------------*/ @@ -1880,7 +1842,6 @@ void pic16_toBoolean(operand *oper) static void genNot (iCode *ic) { symbol *tlbl; - sym_link *optype = operandType(IC_LEFT(ic)); int size; DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__); @@ -1902,13 +1863,7 @@ static void genNot (iCode *ic) goto release; } - /* if type float then do float */ - if (IS_FLOAT(optype)) { - genNotFloat(IC_LEFT(ic),IC_RESULT(ic)); - goto release; - } - - size = AOP_SIZE(IC_RESULT(ic)); + size = AOP_SIZE(IC_LEFT(ic)); if(size == 1) { pic16_emitpcode(POC_COMFW,pic16_popGet(AOP(IC_LEFT(ic)),0)); pic16_emitpcode(POC_ANDLW,pic16_popGetLit(1)); diff --git a/src/z80/gen.c b/src/z80/gen.c index 9df93337..17463dc0 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -2033,43 +2033,6 @@ _toBoolean (operand * oper) } } -/*-----------------------------------------------------------------*/ -/* genNotFloat - generates not for float operations */ -/*-----------------------------------------------------------------*/ -static void -genNotFloat (operand * op, operand * res) -{ - int size, offset; - symbol *tlbl; - - emitDebug ("; genNotFloat"); - - /* we will put 127 in the first byte of - the result */ - aopPut (AOP (res), "!immedbyte", 0x7F); - size = AOP_SIZE (op) - 1; - offset = 1; - - _moveA (aopGet (op->aop, offset++, FALSE)); - - while (size--) - { - emit2 ("or a,%s", aopGet (op->aop, offset++, FALSE)); - } - - tlbl = newiTempLabel (NULL); - aopPut (res->aop, "!one", 1); - emit2 ("!shortjp z !tlabel", tlbl->key + 100); - aopPut (res->aop, "!zero", 1); - - emitLabel(tlbl->key + 100); - - size = res->aop->size - 2; - offset = 2; - /* put zeros in the rest */ - while (size--) - aopPut (res->aop, "!zero", offset++); -} /*-----------------------------------------------------------------*/ /* genNot - generate code for ! operation */ @@ -2077,7 +2040,6 @@ genNotFloat (operand * op, operand * res) static void genNot (iCode * ic) { - sym_link *optype = operandType (IC_LEFT (ic)); /* assign asmOps to operand & result */ aopOp (IC_LEFT (ic), ic, FALSE, TRUE); @@ -2089,13 +2051,6 @@ genNot (iCode * ic) wassertl (0, "Tried to negate a bit"); } - /* if type float then do float */ - if (IS_FLOAT (optype)) - { - genNotFloat (IC_LEFT (ic), IC_RESULT (ic)); - goto release; - } - _toBoolean (IC_LEFT (ic)); /* Not of A: @@ -2105,7 +2060,6 @@ genNot (iCode * ic) emit2 ("sub a,!one"); outBitC (IC_RESULT (ic)); - release: /* release the aops */ freeAsmop (IC_LEFT (ic), NULL, ic); freeAsmop (IC_RESULT (ic), NULL, ic); -- 2.30.2