From: bernhardheld Date: Wed, 23 Jul 2003 20:15:49 +0000 (+0000) Subject: added DUMMY_READ_VOLATILE: X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=0900d4c3a2f72f0f6acff40372d845eb04387378;p=fw%2Fsdcc added DUMMY_READ_VOLATILE: * src/SDCC.y: * src/avr/gen.c: * src/xa51/gen.c: * src/z80/gen.c: * src/pic/gen.c: * src/pic16/gen.c: * src/mcs51/gen.c: * src/ds390/gen.c: * src/SDCCcse.c (algebraicOpts): many improvements * src/SDCCcse.h: removed algebraicOpts() * src/SDCCicode.c (picDummyRead): added git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2766 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index a4efdd7d..5d86caeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-07-23 Bernhard Held + + added DUMMY_READ_VOLATILE: + * src/SDCC.y: + * src/avr/gen.c: + * src/xa51/gen.c: + * src/z80/gen.c: + * src/pic/gen.c: + * src/pic16/gen.c: + * src/mcs51/gen.c: + * src/ds390/gen.c: + * src/SDCCcse.c (algebraicOpts): many improvements + * src/SDCCcse.h: removed algebraicOpts() + * src/SDCCicode.c (picDummyRead): added + 2003-07-23 Jesus Calvino-Fraga * as/mcs51/lkmem.c: Changed message "Insufficient DRAM memory" to diff --git a/src/SDCC.y b/src/SDCC.y index 644ecc51..4d4d5fa2 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -92,6 +92,7 @@ value *cenum = NULL ; /* current enumeration type chain*/ %token BITWISEAND UNARYMINUS IPUSH IPOP PCALL ENDFUNCTION JUMPTABLE %token RRC RLC %token CAST CALL PARAM NULLOP BLOCK LABEL RECEIVE SEND ARRAYINIT +%token DUMMY_READ_VOLATILE %type Interrupt_storage %type identifier declarator declarator2 enumerator_list enumerator diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 16553d4a..a25b9f48 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -633,8 +633,8 @@ iCode *findBackwardDef(operand *op,iCode *ic) /*-----------------------------------------------------------------*/ /* algebraicOpts - does some algebraic optimizations */ /*-----------------------------------------------------------------*/ -void -algebraicOpts (iCode * ic) +static void +algebraicOpts (iCode * ic, eBBlock * ebp) { /* we don't deal with the following iCodes here */ @@ -951,29 +951,30 @@ algebraicOpts (iCode * ic) } break; case BITWISEAND: - if (IS_OP_LITERAL (IC_LEFT (ic))) + /* if both operands are equal */ + /* if yes turn it into assignment */ + if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic))) { - /* if BITWISEAND then check if one of them is a zero */ - /* if yes turn it into 0 assignment */ - if (operandLitValue (IC_LEFT (ic)) == 0.0) + if (IS_OP_VOLATILE (IC_LEFT (ic))) { - if (IS_OP_VOLATILE (IC_RIGHT (ic))) - return; - ic->op = '='; - IC_RIGHT (ic) = IC_LEFT (ic); - IC_LEFT (ic) = NULL; - SET_RESULT_RIGHT (ic); - return; - } - /* if BITWISEAND then check if one of them is 0xff... */ - /* if yes turn it into assignment */ - if (operandLitValue (IC_LEFT (ic)) == -1.0) - { - ic->op = '='; - IC_LEFT (ic) = NULL; - SET_RESULT_RIGHT (ic); - return; + iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic)); + IC_RESULT (newic) = IC_LEFT (ic); + newic->lineno = ic->lineno; + addiCodeToeBBlock (ebp, newic, ic->next); } + ic->op = '='; + IC_LEFT (ic) = NULL; + SET_RESULT_RIGHT (ic); + return; + } + /* swap literal to right ic */ + if (IS_OP_LITERAL (IC_LEFT (ic))) + { + operand *op; + + op = IC_LEFT (ic); + IC_LEFT (ic) = IC_RIGHT (ic); + IC_RIGHT (ic) = op; } if (IS_OP_LITERAL (IC_RIGHT (ic))) { @@ -982,7 +983,12 @@ algebraicOpts (iCode * ic) if (operandLitValue (IC_RIGHT (ic)) == 0.0) { if (IS_OP_VOLATILE (IC_LEFT (ic))) - return; + { + iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic)); + IC_RESULT (newic) = IC_LEFT (ic); + newic->lineno = ic->lineno; + addiCodeToeBBlock (ebp, newic, ic->next); + } ic->op = '='; IC_LEFT (ic) = NULL; SET_RESULT_RIGHT (ic); @@ -990,7 +996,24 @@ algebraicOpts (iCode * ic) } /* if BITWISEAND then check if one of them is 0xff... */ /* if yes turn it into assignment */ - if (operandLitValue (IC_RIGHT (ic)) == -1.0) + { + long val; + + switch (getSize (operandType (IC_RIGHT (ic)))) + { + case 1: + val = 0xff; + break; + case 2: + val = 0xffff; + break; + case 4: + val = 0xffffffff; + break; + default: + return; + } + if (((long) operandLitValue (IC_RIGHT (ic)) & val) == val) { ic->op = '='; IC_RIGHT (ic) = IC_LEFT (ic); @@ -998,30 +1021,34 @@ algebraicOpts (iCode * ic) SET_RESULT_RIGHT (ic); return; } + } } break; case '|': - if (IS_OP_LITERAL (IC_LEFT (ic))) + /* if both operands are equal */ + /* if yes turn it into assignment */ + if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic))) { - /* if BITWISEOR then check if one of them is a zero */ - /* if yes turn it into assignment */ - if (operandLitValue (IC_LEFT (ic)) == 0.0) + if (IS_OP_VOLATILE (IC_LEFT (ic))) { - ic->op = '='; - IC_LEFT (ic) = NULL; - SET_RESULT_RIGHT (ic); - return; - } - /* if BITWISEOR then check if one of them is 0xff... */ - /* if yes turn it into 0xff... assignment */ - if (operandLitValue (IC_LEFT (ic)) == -1.0) - { - ic->op = '='; - IC_RIGHT (ic) = IC_LEFT (ic); - IC_LEFT (ic) = NULL; - SET_RESULT_RIGHT (ic); - return; + iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic)); + IC_RESULT (newic) = IC_LEFT (ic); + newic->lineno = ic->lineno; + addiCodeToeBBlock (ebp, newic, ic->next); } + ic->op = '='; + IC_LEFT (ic) = NULL; + SET_RESULT_RIGHT (ic); + return; + } + /* swap literal to right ic */ + if (IS_OP_LITERAL (IC_LEFT (ic))) + { + operand *op; + + op = IC_LEFT (ic); + IC_LEFT (ic) = IC_RIGHT (ic); + IC_RIGHT (ic) = op; } if (IS_OP_LITERAL (IC_RIGHT (ic))) { @@ -1037,34 +1064,84 @@ algebraicOpts (iCode * ic) } /* if BITWISEOR then check if one of them is 0xff... */ /* if yes turn it into 0xff... assignment */ - if (operandLitValue (IC_RIGHT (ic)) == -1.0) - { - ic->op = '='; - IC_LEFT (ic) = NULL; - SET_RESULT_RIGHT (ic); - return; - } + { + long val; + + switch (getSize (operandType (IC_RIGHT (ic)))) + { + case 1: + val = 0xff; + break; + case 2: + val = 0xffff; + break; + case 4: + val = 0xffffffff; + break; + default: + return; + } + if (((long) operandLitValue (IC_RIGHT (ic)) & val) == val) + { + if (IS_OP_VOLATILE (IC_LEFT (ic))) + { + iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic)); + IC_RESULT (newic) = IC_LEFT (ic); + newic->lineno = ic->lineno; + addiCodeToeBBlock (ebp, newic, ic->next); + } + ic->op = '='; + IC_LEFT (ic) = NULL; + SET_RESULT_RIGHT (ic); + return; + } + } } break; case '^': + /* if both operands are equal */ + /* if yes turn it into 0 assignment */ + if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic))) + { + if (IS_OP_VOLATILE (IC_LEFT (ic))) + { + iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic)); + IC_RESULT (newic) = IC_LEFT (ic); + newic->lineno = ic->lineno; + addiCodeToeBBlock (ebp, newic, ic->next); + + newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic)); + IC_RESULT (newic) = IC_LEFT (ic); + newic->lineno = ic->lineno; + addiCodeToeBBlock (ebp, newic, ic->next); + } + ic->op = '='; + IC_RIGHT (ic) = operandFromLit (0); + IC_LEFT (ic) = NULL; + SET_RESULT_RIGHT (ic); + return; + } + /* swap literal to right ic */ + if (IS_OP_LITERAL (IC_LEFT (ic))) + { + operand *op; + + op = IC_LEFT (ic); + IC_LEFT (ic) = IC_RIGHT (ic); + IC_RIGHT (ic) = op; + } /* if XOR then check if one of them is a zero */ /* if yes turn it into assignment */ - if (IS_OP_LITERAL (IC_LEFT (ic)) && - operandLitValue (IC_LEFT (ic)) == 0.0) - { - ic->op = '='; - IC_LEFT (ic) = NULL; - SET_RESULT_RIGHT (ic); - return; - } - if (IS_OP_LITERAL (IC_RIGHT (ic)) && - operandLitValue (IC_RIGHT (ic)) == 0.0) + if (IS_OP_LITERAL (IC_RIGHT (ic))) { - ic->op = '='; - IC_RIGHT (ic) = IC_LEFT (ic); - IC_LEFT (ic) = NULL; - SET_RESULT_RIGHT (ic); - return; + if (operandLitValue (IC_RIGHT (ic)) == 0.0) + { + ic->op = '='; + IC_RIGHT (ic) = IC_LEFT (ic); + IC_LEFT (ic) = NULL; + SET_RESULT_RIGHT (ic); + return; + } } break; } @@ -1409,9 +1486,9 @@ deleteGetPointers (set ** cseSet, set ** pss, operand * op, eBBlock * ebb) list . This will take care of situations like iTemp1 = iTemp0 + 8; iTemp2 = iTemp1 + 8; */ - if (isinSetWith (compItems, (void*)IC_LEFT (cdp->diCode), + if (isinSetWith (compItems, (void*)IC_LEFT (cdp->diCode), (insetwithFunc)isOperandEqual) || - isinSetWith (compItems, (void*)IC_RIGHT (cdp->diCode), + isinSetWith (compItems, (void*)IC_RIGHT (cdp->diCode), (insetwithFunc)isOperandEqual)) { addSet (&compItems, IC_RESULT (cdp->diCode)); @@ -1459,7 +1536,7 @@ DEFSETFUNC (delGetPointerSucc) /*-----------------------------------------------------------------*/ /* fixUpTypes - KLUGE HACK fixup a lowering problem */ /*-----------------------------------------------------------------*/ -static void +static void fixUpTypes (iCode * ic) { sym_link *t1 = operandType (IC_LEFT (ic)), *t2; @@ -1536,7 +1613,7 @@ static int isSignedOp (iCode *ic) /* system. also the most important, since almost all */ /* data flow related information is computed by it */ /*-----------------------------------------------------------------*/ -int +int cseBBlock (eBBlock * ebb, int computeOnly, eBBlock ** ebbs, int count) { @@ -1670,7 +1747,7 @@ cseBBlock (eBBlock * ebb, int computeOnly, if (!computeOnly) { /* do some algebraic optimizations if possible */ - algebraicOpts (ic); + algebraicOpts (ic, ebb); while (constFold (ic, cseSet)); } @@ -1781,7 +1858,7 @@ cseBBlock (eBBlock * ebb, int computeOnly, /* if left or right changed then do algebraic */ if (!computeOnly && change) { - algebraicOpts (ic); + algebraicOpts (ic, ebb); while (constFold (ic, cseSet)); } @@ -1946,7 +2023,7 @@ cseBBlock (eBBlock * ebb, int computeOnly, /*-----------------------------------------------------------------*/ /* cseAllBlocks - will sequentially go thru & do cse for all blocks */ /*-----------------------------------------------------------------*/ -int +int cseAllBlocks (eBBlock ** ebbs, int count, int computeOnly) { int i; diff --git a/src/SDCCcse.h b/src/SDCCcse.h index b9532c0b..374bb5cf 100644 --- a/src/SDCCcse.h +++ b/src/SDCCcse.h @@ -42,7 +42,6 @@ cseDef; cseDef *newCseDef (operand *, iCode *); int isCseDefEqual (void *, void *); int pcseDef (void *, va_list); -void algebraicOpts (iCode *); DEFSETFUNC (ifDiCodeIsX); int ifDiCodeIs (set *, iCode *); DEFSETFUNC (ifDefSymIsX); diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 9dde59a1..7ae60225 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -67,6 +67,7 @@ PRINTFUNC (picIfx); PRINTFUNC (picJumpTable); PRINTFUNC (picInline); PRINTFUNC (picReceive); +PRINTFUNC (picDummyRead); iCodeTable codeTable[] = { @@ -113,6 +114,7 @@ iCodeTable codeTable[] = {RECEIVE, "recv", picReceive, NULL}, {SEND, "send", picGenericOne, NULL}, {ARRAYINIT, "arrayInit", picGenericOne, NULL}, + {DUMMY_READ_VOLATILE, "dummy = (volatile)", picDummyRead, NULL} }; /*-----------------------------------------------------------------*/ @@ -126,7 +128,7 @@ iCodeTable codeTable[] = pedantic>1: "char c=200" is not allowed (evaluates to -56) */ -void checkConstantRange(sym_link *ltype, value *val, char *msg, +void checkConstantRange(sym_link *ltype, value *val, char *msg, int pedantic) { double max; int warnings=0; @@ -461,10 +463,18 @@ PRINTFUNC (picReceive) fprintf (of, "\n"); } +PRINTFUNC (picDummyRead) +{ + fprintf (of, "\t"); + fprintf (of, "%s ", s); + printOperand (IC_RIGHT (ic), of); + fprintf (of, "\n"); +} + /*-----------------------------------------------------------------*/ /* piCode - prints one iCode */ /*-----------------------------------------------------------------*/ -int +int piCode (void *item, FILE * of) { iCode *ic = item; @@ -488,7 +498,7 @@ void PICC(iCode *ic) /*-----------------------------------------------------------------*/ /* printiCChain - prints intermediate code for humans */ /*-----------------------------------------------------------------*/ -void +void printiCChain (iCode * icChain, FILE * of) { iCode *loop; @@ -722,7 +732,7 @@ copyiCode (iCode * ic) iCodeTable * getTableEntry (int oper) { - int i; + unsigned i; for (i = 0; i < (sizeof (codeTable) / sizeof (iCodeTable)); i++) if (oper == codeTable[i].icode) @@ -1028,7 +1038,7 @@ operandOperation (operand * left, operand * right, { sym_link *let , *ret=NULL; operand *retval = (operand *) 0; - + assert (isOperandLiteral (left)); let = getSpec(operandType(left)); if (right) { @@ -1070,27 +1080,27 @@ operandOperation (operand * left, operand * right, werror (E_DIVIDE_BY_ZERO); retval = right; } - else - retval = operandFromLit ((SPEC_USIGN(let) ? + else + retval = operandFromLit ((SPEC_USIGN(let) ? (unsigned long) operandLitValue (left) : (long) operandLitValue (left)) % - (SPEC_USIGN(ret) ? + (SPEC_USIGN(ret) ? (unsigned long) operandLitValue (right) : (long) operandLitValue (right))); break; case LEFT_OP: - retval = operandFromLit ((SPEC_USIGN(let) ? + retval = operandFromLit ((SPEC_USIGN(let) ? (unsigned long) operandLitValue (left) : (long) operandLitValue (left)) << - (SPEC_USIGN(ret) ? + (SPEC_USIGN(ret) ? (unsigned long) operandLitValue (right) : (long) operandLitValue (right))); break; case RIGHT_OP: { double lval = operandLitValue(left), rval = operandLitValue(right); double res=0; - switch ((SPEC_USIGN(let) ? 2 : 0) + (SPEC_USIGN(ret) ? 1 : 0)) + switch ((SPEC_USIGN(let) ? 2 : 0) + (SPEC_USIGN(ret) ? 1 : 0)) { case 0: // left=unsigned right=unsigned res=(unsigned long)lval >> (unsigned long)rval; diff --git a/src/avr/gen.c b/src/avr/gen.c index 6a0e9a9e..9ca76c62 100644 --- a/src/avr/gen.c +++ b/src/avr/gen.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- - avrgen.c - source file for code generation for ATMEL AVR + gen.c - source file for code generation for ATMEL AVR Written By - Sandeep Dutta . sandeep.dutta@usa.net (2000) @@ -5086,6 +5086,18 @@ genReceive (iCode * ic) freeAsmop (IC_RESULT (ic), NULL, ic, TRUE); } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + emitcode ("; genDummyRead",""); + emitcode ("; not implemented,""); + + ic; +} + /*-----------------------------------------------------------------*/ /* gen51Code - generate code for 8051 based controllers */ /*-----------------------------------------------------------------*/ @@ -5317,6 +5329,10 @@ genAVRCode (iCode * lic) addSet (&_G.sendSet, ic); break; + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + default: ic = ic; } diff --git a/src/ds390/gen.c b/src/ds390/gen.c index f697a3b1..a718ba17 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -12604,6 +12604,42 @@ static void genSystemGetCurrentID(iCode *ic,int nparms, operand **parms,char *na } } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + operand *right; + int size, offset; + + D(emitcode("; genDummyRead","")); + + right = IC_RIGHT (ic); + + aopOp (right, ic, FALSE, FALSE); + + /* if the result is a bit */ + if (AOP_TYPE (right) == AOP_CRY) + { + emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir); + goto release; + } + + /* bit variables done */ + /* general case */ + size = AOP_SIZE (right); + offset = 0; + while (size--) + { + emitcode ("mov", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE, FALSE)); + offset++; + } + +release: + freeAsmop (right, NULL, ic, TRUE); +} + /*-----------------------------------------------------------------*/ /* genBuiltIn - calls the appropriate function to generating code */ /* for a built in function */ @@ -12973,6 +13009,10 @@ gen390Code (iCode * lic) else addSet (&_G.sendSet, ic); break; + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + #if 0 // obsolete, and buggy for != xdata case ARRAYINIT: genArrayInit(ic); diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index a5dd2d9e..456ffac4 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -62,7 +62,7 @@ char **fReturn = fReturn8051; static char *accUse[] = {"a", "b"}; -static short rbank = -1; +static unsigned short rbank = -1; static struct { @@ -111,7 +111,7 @@ static unsigned char SRMask[] = /* emitcode - writes the code into a file : for now it is simple */ /*-----------------------------------------------------------------*/ static void -emitcode (char *inst, char *fmt,...) +emitcode (char *inst, const char *fmt,...) { va_list ap; char lb[INITIAL_INLINEASM]; @@ -146,7 +146,7 @@ emitcode (char *inst, char *fmt,...) /* mova - moves specified value into accumulator */ /*-----------------------------------------------------------------*/ static void -mova (char *x) +mova (const char *x) { /* do some early peephole optimization */ if (!strcmp(x, "a") || !strcmp(x, "acc")) @@ -947,7 +947,7 @@ aopGet (asmop * aop, int offset, bool bit16, bool dname) /* aopPut - puts a string for a aop */ /*-----------------------------------------------------------------*/ static void -aopPut (asmop * aop, char *s, int offset) +aopPut (asmop * aop, const char *s, int offset, bool bvolatile) { char *d = buffer; @@ -969,7 +969,8 @@ aopPut (asmop * aop, char *s, int offset) else sprintf (d, "%s", aop->aopu.aop_dir); - if (strcmp (d, s)) + if (strcmp (d, s) || + bvolatile) emitcode ("mov", "%s,%s", d, s); break; @@ -999,7 +1000,7 @@ aopPut (asmop * aop, char *s, int offset) if (aop->code) { werror (E_INTERNAL_ERROR, __FILE__, __LINE__, - "aopPut writting to code space"); + "aopPut writing to code space"); exit (1); } @@ -1112,16 +1113,19 @@ aopPut (asmop * aop, char *s, int offset) case AOP_STR: aop->coff = offset; - if (strcmp (aop->aopu.aop_str[offset], s)) + if (strcmp (aop->aopu.aop_str[offset], s) || + bvolatile) emitcode ("mov", "%s,%s", aop->aopu.aop_str[offset], s); break; case AOP_ACC: aop->coff = offset; - if (!offset && (strcmp (s, "acc") == 0)) + if (!offset && (strcmp (s, "acc") == 0) && + !bvolatile) break; - if (strcmp (aop->aopu.aop_str[offset], s)) + if (strcmp (aop->aopu.aop_str[offset], s) && + !bvolatile) emitcode ("mov", "%s,%s", aop->aopu.aop_str[offset], s); break; @@ -1215,7 +1219,7 @@ genNotFloat (operand * op, operand * res) /* we will put 127 in the first byte of the result */ - aopPut (AOP (res), "#127", 0); + aopPut (AOP (res), "#127", 0, isOperandVolatile (op, FALSE)); size = AOP_SIZE (op) - 1; offset = 1; @@ -1230,16 +1234,16 @@ genNotFloat (operand * op, operand * res) } tlbl = newiTempLabel (NULL); - aopPut (res->aop, one, 1); + aopPut (res->aop, one, 1, isOperandVolatile (op, FALSE)); emitcode ("jz", "%05d$", (tlbl->key + 100)); - aopPut (res->aop, zero, 1); + 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++); + aopPut (res->aop, zero, offset++, isOperandVolatile (op, FALSE)); } /*-----------------------------------------------------------------*/ @@ -1290,13 +1294,13 @@ outAcc (operand * result) size = getDataSize (result); if (size) { - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); size--; offset = 1; /* unsigned or positive */ while (size--) { - aopPut (AOP (result), zero, offset++); + aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); } } } @@ -1309,7 +1313,7 @@ outBitC (operand * result) { /* if the result is bit */ if (AOP_TYPE (result) == AOP_CRY) - aopPut (AOP (result), "c", 0); + aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); else { emitcode ("clr", "a"); @@ -1415,7 +1419,7 @@ genCpl (iCode * ic) char *l = aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE); MOVA (l); emitcode ("cpl", "a"); - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } @@ -1444,7 +1448,8 @@ genUminusFloat (operand * op, operand * result) { aopPut (AOP (result), aopGet (AOP (op), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); offset++; } @@ -1453,7 +1458,7 @@ genUminusFloat (operand * op, operand * result) MOVA (l); emitcode ("cpl", "acc.7"); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -1515,7 +1520,7 @@ genUminus (iCode * ic) emitcode ("clr", "a"); emitcode ("subb", "a,%s", l); } - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } /* if any remaining bytes in the result */ @@ -1525,7 +1530,7 @@ genUminus (iCode * ic) emitcode ("rlc", "a"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } release: @@ -1675,7 +1680,7 @@ assignResultValue (operand * oper) int size = AOP_SIZE (oper); while (size--) { - aopPut (AOP (oper), fReturn[offset], offset); + aopPut (AOP (oper), fReturn[offset], offset, isOperandVolatile (oper, FALSE)); offset++; } } @@ -2977,7 +2982,7 @@ genPlusIncr (iCode * ic) { MOVA (aopGet (AOP (IC_LEFT (ic)), 0, FALSE, FALSE)); emitcode ("add", "a,#0x%02x", ((char) icount) & 0xff); - aopPut (AOP (IC_RESULT (ic)), "a", 0); + aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); } else { @@ -3002,7 +3007,7 @@ outBitAcc (operand * result) /* if the result is a bit */ if (AOP_TYPE (result) == AOP_CRY) { - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); } else { @@ -3055,14 +3060,16 @@ adjustArithmeticResult (iCode * ic) !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic)))) aopPut (AOP (IC_RESULT (ic)), aopGet (AOP (IC_LEFT (ic)), 2, FALSE, FALSE), - 2); + 2, + isOperandVolatile (IC_RESULT (ic), FALSE)); if (AOP_SIZE (IC_RESULT (ic)) == 3 && AOP_SIZE (IC_RIGHT (ic)) == 3 && !sameRegs (AOP (IC_RESULT (ic)), AOP (IC_RIGHT (ic)))) aopPut (AOP (IC_RESULT (ic)), aopGet (AOP (IC_RIGHT (ic)), 2, FALSE, FALSE), - 2); + 2, + isOperandVolatile (IC_RESULT (ic), FALSE)); if (AOP_SIZE (IC_RESULT (ic)) == 3 && AOP_SIZE (IC_LEFT (ic)) < 3 && @@ -3072,7 +3079,7 @@ adjustArithmeticResult (iCode * ic) { char buffer[5]; sprintf (buffer, "#%d", pointerCode (getSpec (operandType (IC_LEFT (ic))))); - aopPut (AOP (IC_RESULT (ic)), buffer, 2); + aopPut (AOP (IC_RESULT (ic)), buffer, 2, isOperandVolatile (IC_RESULT (ic), FALSE)); } } #else @@ -3089,7 +3096,8 @@ adjustArithmeticResult (iCode * ic) { aopPut (AOP (IC_RESULT (ic)), aopGet (AOP (IC_LEFT (ic)), GPTRSIZE - 1, FALSE, FALSE), - GPTRSIZE - 1); + GPTRSIZE - 1, + isOperandVolatile (IC_RESULT (ic), FALSE)); } if (opIsGptr (IC_RESULT (ic)) && @@ -3098,7 +3106,8 @@ adjustArithmeticResult (iCode * ic) { aopPut (AOP (IC_RESULT (ic)), aopGet (AOP (IC_RIGHT (ic)), GPTRSIZE - 1, FALSE, FALSE), - GPTRSIZE - 1); + GPTRSIZE - 1, + isOperandVolatile (IC_RESULT (ic), FALSE)); } if (opIsGptr (IC_RESULT (ic)) && @@ -3109,7 +3118,7 @@ adjustArithmeticResult (iCode * ic) { char buffer[5]; sprintf (buffer, "#%d", pointerCode (getSpec (operandType (IC_LEFT (ic))))); - aopPut (AOP (IC_RESULT (ic)), buffer, GPTRSIZE - 1); + aopPut (AOP (IC_RESULT (ic)), buffer, GPTRSIZE - 1, isOperandVolatile (IC_RESULT (ic), FALSE)); } } #endif @@ -3172,7 +3181,7 @@ genPlus (iCode * ic) { MOVA (aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE)); emitcode ("addc", "a,#00"); - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } goto release; @@ -3209,7 +3218,7 @@ genPlus (iCode * ic) MOVA (aopGet (rightOp, offset, FALSE, TRUE)); emitcode (add, "a,%s", aopGet (leftOp, offset, FALSE, TRUE)); } - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); add = "addc"; /* further adds must propagate carry */ } @@ -3356,11 +3365,11 @@ addSign (operand * result, int offset, int sign) emitcode ("rlc", "a"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } else while (size--) - aopPut (AOP (result), zero, offset++); + aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); } } @@ -3389,7 +3398,7 @@ genMinusBits (iCode * ic) emitcode ("jnb", "%s,%05d$", AOP (IC_LEFT (ic))->aopu.aop_dir, (lbl->key + 100)); emitcode ("inc", "a"); emitcode ("", "%05d$:", (lbl->key + 100)); - aopPut (AOP (IC_RESULT (ic)), "a", 0); + aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); addSign (IC_RESULT (ic), MSB16, SPEC_USIGN (getSpec (operandType (IC_RESULT (ic))))); } } @@ -3437,17 +3446,17 @@ genMinus (iCode * ic) MOVA (aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE)); /* first add without previous c */ if (!offset) { - if (!size && lit==-1) { + if (!size && lit== (unsigned long) -1) { emitcode ("dec", "a"); } else { - emitcode ("add", "a,#0x%02x", + emitcode ("add", "a,#0x%02x", (unsigned int) (lit & 0x0FFL)); } } else { emitcode ("addc", "a,#0x%02x", (unsigned int) ((lit >> (offset * 8)) & 0x0FFL)); } - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } else @@ -3475,7 +3484,7 @@ genMinus (iCode * ic) aopGet(rightOp, offset, FALSE, TRUE)); } - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } @@ -3521,7 +3530,7 @@ genMultOneByte (operand * left, if (size<1 || size>2) { // this should never happen - fprintf (stderr, "size!=1||2 (%d) in %s at line:%d \n", + fprintf (stderr, "size!=1||2 (%d) in %s at line:%d \n", AOP_SIZE(result), __FILE__, lineno); exit (1); } @@ -3546,9 +3555,9 @@ genMultOneByte (operand * left, emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE)); MOVA (aopGet (AOP (left), 0, FALSE, FALSE)); emitcode ("mul", "ab"); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); if (size==2) { - aopPut (AOP (result), "b", 1); + aopPut (AOP (result), "b", 1, isOperandVolatile (result, FALSE)); } return; } @@ -3606,9 +3615,9 @@ genMultOneByte (operand * left, } emitcode ("", "%05d$:", lbl->key+100); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); if (size==2) { - aopPut (AOP (result), "b", 1); + aopPut (AOP (result), "b", 1, isOperandVolatile (result, FALSE)); } } @@ -3682,7 +3691,7 @@ genDivbits (operand * left, emitcode ("div", "ab"); emitcode ("rrc", "a"); - aopPut (AOP (result), "c", 0); + aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -3710,9 +3719,9 @@ genDivOneByte (operand * left, l = aopGet (AOP (left), 0, FALSE, FALSE); MOVA (l); emitcode ("div", "ab"); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); while (size--) - aopPut (AOP (result), zero, offset++); + aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); return; } @@ -3762,14 +3771,14 @@ genDivOneByte (operand * left, emitcode ("", "%05d$:", (lbl->key + 100)); /* now we are done */ - aopPut (AOP (result), "b", 0); + aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE)); if (size > 0) { emitcode ("mov", "c,b.7"); emitcode ("subb", "a,acc"); } while (size--) - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } @@ -3837,7 +3846,7 @@ genModbits (operand * left, emitcode ("div", "ab"); emitcode ("mov", "a,b"); emitcode ("rrc", "a"); - aopPut (AOP (result), "c", 0); + aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -3862,7 +3871,7 @@ genModOneByte (operand * left, l = aopGet (AOP (left), 0, FALSE, FALSE); MOVA (l); emitcode ("div", "ab"); - aopPut (AOP (result), "b", 0); + aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE)); return; } @@ -3913,7 +3922,7 @@ genModOneByte (operand * left, emitcode ("", "%05d$:", (lbl->key + 100)); /* now we are done */ - aopPut (AOP (result), "b", 0); + aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE)); } @@ -4415,7 +4424,7 @@ genCmpEq (iCode * ic, iCode * ifx) gencjne (left, right, newiTempLabel (NULL)); if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result)) { - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); goto release; } if (ifx) @@ -4837,12 +4846,14 @@ genAnd (iCode * ic, iCode * ifx) if ((bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL)) == 0x0FF) continue; else if (bytelit == 0) - aopPut (AOP (result), zero, offset); + { + aopPut (AOP (result), zero, offset, isOperandVolatile (result, FALSE)); + } else if (IS_AOP_PREG (result)) { MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); emitcode ("anl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("anl", "%s,%s", @@ -4859,7 +4870,7 @@ genAnd (iCode * ic, iCode * ifx) if (IS_AOP_PREG (result)) { emitcode ("anl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else @@ -4921,12 +4932,16 @@ genAnd (iCode * ic, iCode * ifx) { aopPut (AOP (result), aopGet (AOP (left), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); continue; } else if (bytelit == 0) { - aopPut (AOP (result), zero, offset); + /* dummy read of volatile operand */ + if (isOperandVolatile (left, FALSE)) + MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + aopPut (AOP (result), zero, offset, isOperandVolatile (result, FALSE)); continue; } } @@ -4940,7 +4955,7 @@ genAnd (iCode * ic, iCode * ifx) emitcode ("anl", "a,%s", aopGet (AOP (left), offset, FALSE, FALSE)); } - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } } } @@ -5120,12 +5135,18 @@ genOr (iCode * ic, iCode * ifx) if (AOP_TYPE (right) == AOP_LIT) { if (((lit >> (offset * 8)) & 0x0FFL) == 0x00L) - continue; + { + /* dummy read of volatile operand */ + if (isOperandVolatile (left, FALSE)) + MOVA (aopGet (AOP (left), offset, FALSE, FALSE)); + else + continue; + } else if (IS_AOP_PREG (left)) { MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); emitcode ("orl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("orl", "%s,%s", @@ -5142,7 +5163,7 @@ genOr (iCode * ic, iCode * ifx) if (IS_AOP_PREG (left)) { emitcode ("orl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("orl", "%s,a", @@ -5196,7 +5217,8 @@ genOr (iCode * ic, iCode * ifx) { aopPut (AOP (result), aopGet (AOP (left), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); continue; } } @@ -5210,7 +5232,7 @@ genOr (iCode * ic, iCode * ifx) emitcode ("orl", "a,%s", aopGet (AOP (left), offset, FALSE, FALSE)); } - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } } @@ -5377,7 +5399,7 @@ genXor (iCode * ic, iCode * ifx) { MOVA (aopGet (AOP (right), offset, FALSE, FALSE)); emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("xrl", "%s,%s", @@ -5394,7 +5416,7 @@ genXor (iCode * ic, iCode * ifx) if (IS_AOP_PREG (left)) { emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else emitcode ("xrl", "%s,a", @@ -5456,7 +5478,8 @@ genXor (iCode * ic, iCode * ifx) { aopPut (AOP (result), aopGet (AOP (left), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); continue; } } @@ -5470,7 +5493,7 @@ genXor (iCode * ic, iCode * ifx) emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE)); } - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } } @@ -5558,7 +5581,7 @@ genRRC (iCode * ic) MOVA (l); emitcode ("rrc", "a"); if (AOP_SIZE (result) > 1) - aopPut (AOP (result), "a", offset--); + aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE)); } /* now we need to put the carry into the highest order byte of the result */ @@ -5569,7 +5592,7 @@ genRRC (iCode * ic) } emitcode ("mov", "acc.7,c"); release: - aopPut (AOP (result), "a", AOP_SIZE (result) - 1); + aopPut (AOP (result), "a", AOP_SIZE (result) - 1, isOperandVolatile (result, FALSE)); freeAsmop (left, NULL, ic, TRUE); freeAsmop (result, NULL, ic, TRUE); } @@ -5605,14 +5628,14 @@ genRLC (iCode * ic) } emitcode ("add", "a,acc"); if (AOP_SIZE (result) > 1) - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); while (size--) { l = aopGet (AOP (left), offset, FALSE, FALSE); MOVA (l); emitcode ("rlc", "a"); if (AOP_SIZE (result) > 1) - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } } /* now we need to put the carry into the @@ -5624,7 +5647,7 @@ genRLC (iCode * ic) } emitcode ("mov", "acc.0,c"); release: - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); freeAsmop (left, NULL, ic, TRUE); freeAsmop (result, NULL, ic, TRUE); } @@ -5801,7 +5824,7 @@ shiftR1Left2Result (operand * left, int offl, AccSRsh (shCount); else AccRsh (shCount); - aopPut (AOP (result), "a", offr); + aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -5816,7 +5839,7 @@ shiftL1Left2Result (operand * left, int offl, MOVA (l); /* shift left accumulator */ AccLsh (shCount); - aopPut (AOP (result), "a", offr); + aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -5834,19 +5857,19 @@ movLeft2Result (operand * left, int offl, if (*l == '@' && (IS_AOP_PREG (result))) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offr); + aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); } else { if (!sign) - aopPut (AOP (result), l, offr); + aopPut (AOP (result), l, offr, isOperandVolatile (result, FALSE)); else { /* MSB sign in acc.7 ! */ if (getDataSize (left) == offl + 1) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offr); + aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); } } } @@ -6174,7 +6197,7 @@ shiftL2Left2Result (operand * left, int offl, } /* ax << shCount (x = lsb(result)) */ AccAXLsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount); - aopPut (AOP (result), "a", offr + MSB16); + aopPut (AOP (result), "a", offr + MSB16, isOperandVolatile (result, FALSE)); } @@ -6204,7 +6227,7 @@ shiftR2Left2Result (operand * left, int offl, else AccAXRsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount); if (getDataSize (result) > 1) - aopPut (AOP (result), "a", offr + MSB16); + aopPut (AOP (result), "a", offr + MSB16, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -6220,7 +6243,7 @@ shiftLLeftOrResult (operand * left, int offl, /* or with result */ emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE)); /* back to result */ - aopPut (AOP (result), "a", offr); + aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -6236,7 +6259,7 @@ shiftRLeftOrResult (operand * left, int offl, /* or with result */ emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE)); /* back to result */ - aopPut (AOP (result), "a", offr); + aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -6274,7 +6297,7 @@ genlshTwo (operand * result, operand * left, int shCount) else movLeft2Result (left, LSB, result, MSB16, 0); } - aopPut (AOP (result), zero, LSB); + aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); } /* 1 <= shCount <= 7 */ @@ -6307,7 +6330,7 @@ shiftLLong (operand * left, operand * result, int offr) emitcode ("xch", "a,%s", aopGet (AOP (left), LSB + offr, FALSE, FALSE)); else - aopPut (AOP (result), "a", LSB + offr); + aopPut (AOP (result), "a", LSB + offr, isOperandVolatile (result, FALSE)); } if (size >= MSB16 + offr) @@ -6323,7 +6346,7 @@ shiftLLong (operand * left, operand * result, int offr) emitcode ("xch", "a,%s", aopGet (AOP (left), MSB16 + offr, FALSE, FALSE)); else - aopPut (AOP (result), "a", MSB16 + offr); + aopPut (AOP (result), "a", MSB16 + offr, isOperandVolatile (result, FALSE)); } if (size >= MSB24 + offr) @@ -6339,7 +6362,7 @@ shiftLLong (operand * left, operand * result, int offr) emitcode ("xch", "a,%s", aopGet (AOP (left), MSB24 + offr, FALSE, FALSE)); else - aopPut (AOP (result), "a", MSB24 + offr); + aopPut (AOP (result), "a", MSB24 + offr, isOperandVolatile (result, FALSE)); } if (size > MSB32 + offr) @@ -6350,10 +6373,10 @@ shiftLLong (operand * left, operand * result, int offr) MOVA (l); } emitcode ("rlc", "a"); - aopPut (AOP (result), "a", MSB32 + offr); + aopPut (AOP (result), "a", MSB32 + offr, isOperandVolatile (result, FALSE)); } if (offr != LSB) - aopPut (AOP (result), zero, LSB); + aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); } /*-----------------------------------------------------------------*/ @@ -6378,9 +6401,9 @@ genlshFour (operand * result, operand * left, int shCount) shiftL1Left2Result (left, LSB, result, MSB32, shCount); else movLeft2Result (left, LSB, result, MSB32, 0); - aopPut (AOP (result), zero, LSB); - aopPut (AOP (result), zero, MSB16); - aopPut (AOP (result), zero, MSB24); + aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); + aopPut (AOP (result), zero, MSB16, isOperandVolatile (result, FALSE)); + aopPut (AOP (result), zero, MSB24, isOperandVolatile (result, FALSE)); return; } @@ -6397,8 +6420,8 @@ genlshFour (operand * result, operand * left, int shCount) movLeft2Result (left, MSB16, result, MSB32, 0); movLeft2Result (left, LSB, result, MSB24, 0); } - aopPut (AOP (result), zero, MSB16); - aopPut (AOP (result), zero, LSB); + aopPut (AOP (result), zero, MSB16, isOperandVolatile (result, FALSE)); + aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); return; } @@ -6421,7 +6444,7 @@ genlshFour (operand * result, operand * left, int shCount) movLeft2Result (left, MSB24, result, MSB32, 0); movLeft2Result (left, MSB16, result, MSB24, 0); movLeft2Result (left, LSB, result, MSB16, 0); - aopPut (AOP (result), zero, LSB); + aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); } else if (shCount == 1) shiftLLong (left, result, MSB16); @@ -6430,7 +6453,7 @@ genlshFour (operand * result, operand * left, int shCount) shiftL2Left2Result (left, MSB16, result, MSB24, shCount); shiftL1Left2Result (left, LSB, result, MSB16, shCount); shiftRLeftOrResult (left, LSB, result, MSB24, 8 - shCount); - aopPut (AOP (result), zero, LSB); + aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE)); } } } @@ -6488,7 +6511,7 @@ genLeftShiftLiteral (operand * left, else if (shCount >= (size * 8)) while (size--) - aopPut (AOP (result), zero, size); + aopPut (AOP (result), zero, size, isOperandVolatile (result, FALSE)); else { switch (size) @@ -6568,10 +6591,10 @@ genLeftShift (iCode * ic) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else - aopPut (AOP (result), l, offset); + aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE)); offset++; } } @@ -6593,7 +6616,7 @@ genLeftShift (iCode * ic) emitcode ("add", "a,acc"); emitcode ("", "%05d$:", tlbl1->key + 100); emitcode ("djnz", "b,%05d$", tlbl->key + 100); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -6604,13 +6627,13 @@ genLeftShift (iCode * ic) l = aopGet (AOP (result), offset, FALSE, FALSE); MOVA (l); emitcode ("add", "a,acc"); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); while (--size) { l = aopGet (AOP (result), offset, FALSE, FALSE); MOVA (l); emitcode ("rlc", "a"); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } reAdjustPreg (AOP (result)); @@ -6684,11 +6707,11 @@ shiftRLong (operand * left, int offl, if (isSameRegs) emitcode ("xch", "a,%s", aopGet(AOP(left), MSB32, FALSE, FALSE)); else { - aopPut (AOP (result), "a", MSB32); + aopPut (AOP (result), "a", MSB32, isOperandVolatile (result, FALSE)); MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE)); } } else { - aopPut (AOP(result), zero, MSB32); + aopPut (AOP(result), zero, MSB32, isOperandVolatile (result, FALSE)); } } @@ -6703,7 +6726,7 @@ shiftRLong (operand * left, int offl, if (isSameRegs && offl==MSB16) { emitcode ("xch", "a,%s",aopGet (AOP (left), MSB24, FALSE, FALSE)); } else { - aopPut (AOP (result), "a", MSB32-offl); + aopPut (AOP (result), "a", MSB32-offl, isOperandVolatile (result, FALSE)); MOVA (aopGet (AOP (left), MSB24, FALSE, FALSE)); } @@ -6711,17 +6734,17 @@ shiftRLong (operand * left, int offl, if (isSameRegs && offl==1) { emitcode ("xch", "a,%s",aopGet (AOP (left), MSB16, FALSE, FALSE)); } else { - aopPut (AOP (result), "a", MSB24-offl); + aopPut (AOP (result), "a", MSB24-offl, isOperandVolatile (result, FALSE)); MOVA (aopGet (AOP (left), MSB16, FALSE, FALSE)); } emitcode ("rrc", "a"); - aopPut (AOP (result), "a", MSB16 - offl); + aopPut (AOP (result), "a", MSB16 - offl, isOperandVolatile (result, FALSE)); if (offl == LSB) { MOVA (aopGet (AOP (left), LSB, FALSE, FALSE)); emitcode ("rrc", "a"); - aopPut (AOP (result), "a", LSB); + aopPut (AOP (result), "a", LSB, isOperandVolatile (result, FALSE)); } } @@ -6916,10 +6939,10 @@ genSignedRightShift (iCode * ic) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else - aopPut (AOP (result), l, offset); + aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE)); offset++; } } @@ -6944,7 +6967,7 @@ genSignedRightShift (iCode * ic) emitcode ("rrc", "a"); emitcode ("", "%05d$:", tlbl1->key + 100); emitcode ("djnz", "b,%05d$", tlbl->key + 100); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -6957,7 +6980,7 @@ genSignedRightShift (iCode * ic) l = aopGet (AOP (result), offset, FALSE, FALSE); MOVA (l); emitcode ("rrc", "a"); - aopPut (AOP (result), "a", offset--); + aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE)); } reAdjustPreg (AOP (result)); emitcode ("", "%05d$:", tlbl1->key + 100); @@ -7040,10 +7063,10 @@ genRightShift (iCode * ic) { emitcode ("mov", "a,%s", l); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else - aopPut (AOP (result), l, offset); + aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE)); offset++; } } @@ -7064,7 +7087,7 @@ genRightShift (iCode * ic) emitcode ("rrc", "a"); emitcode ("", "%05d$:", tlbl1->key + 100); emitcode ("djnz", "b,%05d$", tlbl->key + 100); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -7077,7 +7100,7 @@ genRightShift (iCode * ic) l = aopGet (AOP (result), offset, FALSE, FALSE); MOVA (l); emitcode ("rrc", "a"); - aopPut (AOP (result), "a", offset--); + aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE)); } reAdjustPreg (AOP (result)); @@ -7146,12 +7169,12 @@ genUnpackBits (operand * result, char *rname, int ptype) emitcode ("anl", "a,#0x%02x", ((unsigned char) -1) >> (8 - SPEC_BLEN (etype))); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); goto finish; } /* bit field did not fit in a byte */ - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); while (1) { @@ -7191,7 +7214,7 @@ genUnpackBits (operand * result, char *rname, int ptype) if (rlen < 8) break; - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } @@ -7199,7 +7222,7 @@ genUnpackBits (operand * result, char *rname, int ptype) { // emitcode("anl","a,#0x%02x",((unsigned char)-1)>>(rlen)); AccLsh (8 - rlen); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } finish: @@ -7207,7 +7230,7 @@ finish: { rsize -= offset; while (rsize--) - aopPut (AOP (result), zero, offset++); + aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); } return; } @@ -7238,7 +7261,7 @@ genDataPointerGet (operand * left, sprintf (buffer, "(%s + %d)", l + 1, offset); else sprintf (buffer, "%s", l + 1); - aopPut (AOP (result), buffer, offset++); + aopPut (AOP (result), buffer, offset++, isOperandVolatile (result, FALSE)); } freeAsmop (left, NULL, ic, TRUE); @@ -7313,12 +7336,12 @@ genNearPointerGet (operand * left, { emitcode ("mov", "a,@%s", rname); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); } else { sprintf (buffer, "@%s", rname); - aopPut (AOP (result), buffer, offset); + aopPut (AOP (result), buffer, offset, isOperandVolatile (result, FALSE)); } offset++; if (size || pi) @@ -7330,7 +7353,7 @@ genNearPointerGet (operand * left, if (aop) /* we had to allocate for this iCode */ { if (pi) { /* post increment present */ - aopPut(AOP ( left ),rname,0); + aopPut(AOP ( left ),rname,0, isOperandVolatile (left, FALSE)); } freeAsmop (NULL, aop, ic, TRUE); } @@ -7410,7 +7433,7 @@ genPagedPointerGet (operand * left, { emitcode ("movx", "a,@%s", rname); - aopPut (AOP (result), "a", offset); + aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE)); offset++; @@ -7422,7 +7445,7 @@ genPagedPointerGet (operand * left, /* now some housekeeping stuff */ if (aop) /* we had to allocate for this iCode */ { - if (pi) aopPut ( AOP (left), rname, 0); + if (pi) aopPut ( AOP (left), rname, 0, isOperandVolatile (left, FALSE)); freeAsmop (NULL, aop, ic, TRUE); } else @@ -7492,15 +7515,15 @@ genFarPointerGet (operand * left, while (size--) { emitcode ("movx", "a,@dptr"); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); if (size || pi) emitcode ("inc", "dptr"); } } if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) { - aopPut ( AOP (left), "dpl", 0); - aopPut ( AOP (left), "dph", 1); + aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE)); + aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE)); pi->generated = 1; } freeAsmop (left, NULL, ic, TRUE); @@ -7551,21 +7574,21 @@ genCodePointerGet (operand * left, { emitcode ("clr", "a"); emitcode ("movc", "a,@a+dptr"); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); emitcode ("inc", "dptr"); } else { emitcode ("mov", "a,#0x%02x", offset); emitcode ("movc", "a,@a+dptr"); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } } } if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) { - aopPut ( AOP (left), "dpl", 0); - aopPut ( AOP (left), "dph", 1); + aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE)); + aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE)); pi->generated = 1; } freeAsmop (left, NULL, ic, TRUE); @@ -7620,15 +7643,16 @@ genGenPointerGet (operand * left, while (size--) { emitcode ("lcall", "__gptrget"); - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); if (size || pi) emitcode ("inc", "dptr"); } } if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) { - aopPut ( AOP (left), "dpl", 0); - aopPut ( AOP (left), "dph", 1); + aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE)); + aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE)); + aopPut ( AOP (left), "b", 2, isOperandVolatile (left, FALSE)); pi->generated = 1; } freeAsmop (left, NULL, ic, TRUE); @@ -8000,7 +8024,8 @@ genNearPointerSet (operand * right, /* now some housekeeping stuff */ if (aop) /* we had to allocate for this iCode */ { - if (pi) aopPut (AOP (result),rname,0); + if (pi) + aopPut (AOP (result), rname, 0, isOperandVolatile (result, FALSE)); freeAsmop (NULL, aop, ic, TRUE); } else @@ -8092,7 +8117,8 @@ genPagedPointerSet (operand * right, /* now some housekeeping stuff */ if (aop) /* we had to allocate for this iCode */ { - if (pi) aopPut (AOP (result),rname,0); + if (pi) + aopPut (AOP (result), rname, 0, isOperandVolatile (result, FALSE)); freeAsmop (NULL, aop, ic, TRUE); } else @@ -8170,8 +8196,8 @@ genFarPointerSet (operand * right, } } if (pi && AOP_TYPE (result) != AOP_STR && AOP_TYPE (result) != AOP_IMMD) { - aopPut (AOP(result),"dpl",0); - aopPut (AOP(result),"dph",1); + aopPut (AOP(result), "dpl", 0, isOperandVolatile (result, FALSE)); + aopPut (AOP(result), "dph", 1, isOperandVolatile (result, FALSE)); pi->generated=1; } freeAsmop (result, NULL, ic, TRUE); @@ -8235,8 +8261,9 @@ genGenPointerSet (operand * right, } if (pi && AOP_TYPE (result) != AOP_STR && AOP_TYPE (result) != AOP_IMMD) { - aopPut (AOP(result),"dpl",0); - aopPut (AOP(result),"dph",1); + aopPut (AOP(result), "dpl", 0, isOperandVolatile (result, FALSE)); + aopPut (AOP(result), "dph", 1, isOperandVolatile (result, FALSE)); + aopPut (AOP(result), "b", 2, isOperandVolatile (result, FALSE)); pi->generated=1; } freeAsmop (result, NULL, ic, TRUE); @@ -8372,12 +8399,12 @@ genAddrOf (iCode * ic) emitcode ("add", "a,#0x%02x", ((sym->stack < 0) ? ((char) (sym->stack - _G.nRegsSaved)) : ((char) sym->stack)) & 0xff); - aopPut (AOP (IC_RESULT (ic)), "a", 0); + aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); } else { /* we can just move _bp */ - aopPut (AOP (IC_RESULT (ic)), "_bp", 0); + aopPut (AOP (IC_RESULT (ic)), "_bp", 0, isOperandVolatile (IC_RESULT (ic), FALSE)); } /* fill the result with zero */ size = AOP_SIZE (IC_RESULT (ic)) - 1; @@ -8385,7 +8412,7 @@ genAddrOf (iCode * ic) offset = 1; while (size--) { - aopPut (AOP (IC_RESULT (ic)), zero, offset++); + aopPut (AOP (IC_RESULT (ic)), zero, offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } goto release; @@ -8404,7 +8431,7 @@ genAddrOf (iCode * ic) offset * 8); else sprintf (s, "#%s", sym->rname); - aopPut (AOP (IC_RESULT (ic)), s, offset++); + aopPut (AOP (IC_RESULT (ic)), s, offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } release: @@ -8439,7 +8466,7 @@ genFarFarAssign (operand * result, operand * right, iCode * ic) while (size--) { emitcode ("pop", "acc"); - aopPut (AOP (result), "a", --offset); + aopPut (AOP (result), "a", --offset, isOperandVolatile (result, FALSE)); } freeAsmop (result, NULL, ic, FALSE); @@ -8461,9 +8488,10 @@ genAssign (iCode * ic) right = IC_RIGHT (ic); /* if they are the same */ - if (operandsEqu (result, right)) { + if (operandsEqu (result, right) && + !isOperandVolatile (result, FALSE) && + !isOperandVolatile (right, FALSE)) return; - } aopOp (right, ic, FALSE); @@ -8480,7 +8508,9 @@ genAssign (iCode * ic) aopOp (result, ic, TRUE); /* if they are the same registers */ - if (sameRegs (AOP (right), AOP (result))) + if (sameRegs (AOP (right), AOP (result)) && + !isOperandVolatile (result, FALSE) && + !isOperandVolatile (right, FALSE)) goto release; /* if the result is a bit */ @@ -8492,9 +8522,9 @@ genAssign (iCode * ic) if (AOP_TYPE (right) == AOP_LIT) { if (((int) operandLitValue (right))) - aopPut (AOP (result), one, 0); + aopPut (AOP (result), one, 0, isOperandVolatile (result, FALSE)); else - aopPut (AOP (result), zero, 0); + aopPut (AOP (result), zero, 0, isOperandVolatile (result, FALSE)); goto release; } @@ -8502,13 +8532,13 @@ genAssign (iCode * ic) if (AOP_TYPE (right) == AOP_CRY) { emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir); - aopPut (AOP (result), "c", 0); + aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); goto release; } /* we need to or */ toBoolean (right); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -8528,11 +8558,12 @@ genAssign (iCode * ic) while (size--) { if ((unsigned int) ((lit >> (size * 8)) & 0x0FFL) == 0) - aopPut (AOP (result), "a", size); + aopPut (AOP (result), "a", size, isOperandVolatile (result, FALSE)); else aopPut (AOP (result), aopGet (AOP (right), size, FALSE, FALSE), - size); + size, + isOperandVolatile (result, FALSE)); } } else @@ -8541,7 +8572,8 @@ genAssign (iCode * ic) { aopPut (AOP (result), aopGet (AOP (right), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); offset++; } } @@ -8611,9 +8643,9 @@ genCast (iCode * ic) if (AOP_TYPE (right) == AOP_LIT) { if (((int) operandLitValue (right))) - aopPut (AOP (result), one, 0); + aopPut (AOP (result), one, 0, isOperandVolatile (result, FALSE)); else - aopPut (AOP (result), zero, 0); + aopPut (AOP (result), zero, 0, isOperandVolatile (result, FALSE)); goto release; } @@ -8622,13 +8654,13 @@ genCast (iCode * ic) if (AOP_TYPE (right) == AOP_CRY) { emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir); - aopPut (AOP (result), "c", 0); + aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE)); goto release; } /* we need to or */ toBoolean (right); - aopPut (AOP (result), "a", 0); + aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE)); goto release; } @@ -8647,7 +8679,8 @@ genCast (iCode * ic) { aopPut (AOP (result), aopGet (AOP (right), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); offset++; } goto release; @@ -8685,7 +8718,8 @@ genCast (iCode * ic) { aopPut (AOP (result), aopGet (AOP (right), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); offset++; } /* the last byte depending on type */ @@ -8700,7 +8734,7 @@ genCast (iCode * ic) } sprintf(gpValStr, "#0x%d", gpVal); - aopPut (AOP (result), gpValStr, GPTRSIZE - 1); + aopPut (AOP (result), gpValStr, GPTRSIZE - 1, isOperandVolatile (result, FALSE)); } goto release; } @@ -8712,7 +8746,8 @@ genCast (iCode * ic) { aopPut (AOP (result), aopGet (AOP (right), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); offset++; } goto release; @@ -8727,7 +8762,8 @@ genCast (iCode * ic) { aopPut (AOP (result), aopGet (AOP (right), offset, FALSE, FALSE), - offset); + offset, + isOperandVolatile (result, FALSE)); offset++; } @@ -8737,7 +8773,7 @@ genCast (iCode * ic) if (!IS_SPEC (rtype) || SPEC_USIGN (rtype) || AOP_TYPE(right)==AOP_CRY) { while (size--) - aopPut (AOP (result), zero, offset++); + aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE)); } else { @@ -8748,7 +8784,7 @@ genCast (iCode * ic) emitcode ("rlc", "a"); emitcode ("subb", "a,acc"); while (size--) - aopPut (AOP (result), "a", offset++); + aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE)); } /* we are done hurray !!!! */ @@ -8816,7 +8852,7 @@ genDjnz (iCode * ic, iCode * ifx) return 0; } emitcode ("dec", "%s", rByte); - aopPut(AOP(IC_RESULT(ic)), rByte, 0); + aopPut(AOP(IC_RESULT(ic)), rByte, 0, isOperandVolatile (IC_RESULT (ic), FALSE)); emitcode ("jnz", "%05d$", lbl->key + 100); } else if (IS_AOP_PREG (IC_RESULT (ic))) @@ -8855,7 +8891,7 @@ genReceive (iCode * ic) if (isOperandInFarSpace (IC_RESULT (ic)) && (OP_SYMBOL (IC_RESULT (ic))->isspilt || IS_TRUE_SYMOP (IC_RESULT (ic)))) { - + offset = fReturnSizeMCS51 - size; while (size--) { emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeMCS51 - offset - 1], "a") ? @@ -8867,9 +8903,9 @@ genReceive (iCode * ic) offset = 0; while (size--) { emitcode ("pop", "acc"); - aopPut (AOP (IC_RESULT (ic)), "a", offset++); + aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } - + } else { _G.accInUse++; aopOp (IC_RESULT (ic), ic, FALSE); @@ -8881,12 +8917,48 @@ genReceive (iCode * ic) aopOp (IC_RESULT (ic), ic, FALSE); rb1off = ic->argreg; while (size--) { - aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++); + aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++, isOperandVolatile (IC_RESULT (ic), FALSE)); } } freeAsmop (IC_RESULT (ic), NULL, ic, TRUE); } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + operand *right; + int size, offset; + + D(emitcode("; genDummyRead","")); + + right = IC_RIGHT (ic); + + aopOp (right, ic, FALSE); + + /* if the result is a bit */ + if (AOP_TYPE (right) == AOP_CRY) + { + emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir); + goto release; + } + + /* bit variables done */ + /* general case */ + size = AOP_SIZE (right); + offset = 0; + while (size--) + { + emitcode ("mov", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE)); + offset++; + } + +release: + freeAsmop (right, NULL, ic, TRUE); +} + /*-----------------------------------------------------------------*/ /* gen51Code - generate code for 8051 based controllers */ /*-----------------------------------------------------------------*/ @@ -9140,6 +9212,10 @@ gen51Code (iCode * lic) addSet (&_G.sendSet, ic); break; + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + default: ic = ic; } diff --git a/src/pic/gen.c b/src/pic/gen.c index 95b75a28..28d5db4e 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- - SDCCgen51.c - source file for code generation for 8051 + gen.c - source file for code generation for pic Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) and - Jean-Louis VERN.jlvern@writeme.com (1999) @@ -9871,10 +9871,10 @@ static int genDjnz (iCode *ic, iCode *ifx) /* genReceive - generate code for a receive iCode */ /*-----------------------------------------------------------------*/ static void genReceive (iCode *ic) -{ +{ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__); - if (isOperandInFarSpace(IC_RESULT(ic)) && + if (isOperandInFarSpace(IC_RESULT(ic)) && ( OP_SYMBOL(IC_RESULT(ic))->isspilt || IS_TRUE_SYMOP(IC_RESULT(ic))) ) { @@ -9885,24 +9885,36 @@ static void genReceive (iCode *ic) fReturn[fReturnSizePic - offset - 1] : "acc")); offset++; } - aopOp(IC_RESULT(ic),ic,FALSE); + aopOp(IC_RESULT(ic),ic,FALSE); size = AOP_SIZE(IC_RESULT(ic)); offset = 0; while (size--) { pic14_emitcode ("pop","acc"); aopPut (AOP(IC_RESULT(ic)),"a",offset++); } - + } else { _G.accInUse++; - aopOp(IC_RESULT(ic),ic,FALSE); + aopOp(IC_RESULT(ic),ic,FALSE); _G.accInUse--; - assignResultValue(IC_RESULT(ic)); + assignResultValue(IC_RESULT(ic)); } freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + pic14_emitcode ("; genDummyRead",""); + pic14_emitcode ("; not implemented",""); + + ic; +} + /*-----------------------------------------------------------------*/ /* genpic14Code - generate code for pic14 based controllers */ /*-----------------------------------------------------------------*/ @@ -10160,13 +10172,17 @@ void genpic14Code (iCode *lic) addSet(&_G.sendSet,ic); break; + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + default : ic = ic; } } - - /* now we are ready to call the + + /* now we are ready to call the peep hole optimizer */ if (!options.nopeep) { peepHole (&lineHead); diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 405bbbe5..35eebd89 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- - SDCCgen51.c - source file for code generation for 8051 - + gen.c - source file for code generation for pic16 + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) and - Jean-Louis VERN.jlvern@writeme.com (1999) Bug Fixes - Wojciech Stryjewski wstryj1@tiger.lsu.edu (1999 v2.1.9a) @@ -9963,6 +9963,18 @@ static void genReceive (iCode *ic) pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + pic16_emitcode ("; genDummyRead",""); + pic16_emitcode ("; not implemented",""); + + ic; +} + /*-----------------------------------------------------------------*/ /* genpic16Code - generate code for pic16 based controllers */ /*-----------------------------------------------------------------*/ @@ -9987,7 +9999,7 @@ void genpic16Code (iCode *lic) #if 0 /* if debug information required */ - if (options.debug && currFunc) { + if (options.debug && currFunc) { if (currFunc) { cdbSymbol(currFunc,cdbFile,FALSE,TRUE); _G.debugLine = 1; @@ -10220,13 +10232,17 @@ void genpic16Code (iCode *lic) addSet(&_G.sendSet,ic); break; + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + default : ic = ic; } } - - /* now we are ready to call the + + /* now we are ready to call the peep hole optimizer */ if (!options.nopeep) { peepHole (&lineHead); diff --git a/src/xa51/gen.c b/src/xa51/gen.c index ecc91197..08e68fc3 100755 --- a/src/xa51/gen.c +++ b/src/xa51/gen.c @@ -1889,15 +1889,24 @@ static void genReceive (iCode * ic) { printIc (0, "genReceive", ic, 1,0,0); } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + emitcode ("; genDummyRead",""); +} + /*-----------------------------------------------------------------*/ /* gen51Code - generate code for 8051 based controllers */ /*-----------------------------------------------------------------*/ void genXA51Code (iCode * lic) { iCode *ic; int cln = 0; - + lineHead = lineCurr = NULL; - + /* if debug information required */ if (options.debug && currFunc) { @@ -1909,7 +1918,7 @@ void genXA51Code (iCode * lic) { emitcode ("", "G$%s$0$0 ==.", currFunc->name); _G.debugLine = 0; } - + for (ic = lic; ic; ic = ic->next) { if (ic->lineno && cln != ic->lineno) { if (options.debug) { @@ -1920,7 +1929,7 @@ void genXA51Code (iCode * lic) { _G.debugLine = 0; } if (!options.noCcodeInAsm) { - emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, + emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, printCLine(ic->filename, ic->lineno)); } cln = ic->lineno; @@ -1928,25 +1937,25 @@ void genXA51Code (iCode * lic) { if (options.iCodeInAsm) { emitcode("", ";ic:%d: %s", ic->key, printILine(ic)); } - + /* if the result is marked as spilt and rematerializable or code for this has already been generated then do nothing */ if (resultRemat (ic) || ic->generated) continue; - + /* depending on the operation */ switch (ic->op) { case '!': genNot (ic); break; - + case '~': genCpl (ic); break; - + case UNARYMINUS: genUminus (ic); break; @@ -2072,7 +2081,7 @@ void genXA51Code (iCode * lic) { case RLC: genRLC (ic); break; - + case GETHBIT: genGetHbit (ic); break; @@ -2115,22 +2124,26 @@ void genXA51Code (iCode * lic) { case RECEIVE: genReceive (ic); break; - + case SEND: addSet (&_G.sendSet, ic); break; - + + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + default: ic = ic; } } - - + + /* now we are ready to call the peep hole optimizer */ if (!options.nopeep) peepHole (&lineHead); - + /* now do the actual printing */ printLine (lineHead, codeOutFile); return; diff --git a/src/z80/gen.c b/src/z80/gen.c index 63b54786..127c0b20 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -426,11 +426,11 @@ emitDebug (const char *szFormat,...) if (!DISABLE_DEBUG) { va_list ap; - + va_start (ap, szFormat); - + _vemit2 (szFormat, ap); - + va_end (ap); } } @@ -1832,11 +1832,9 @@ commitPair (asmop * aop, PAIR_ID id) if (id == PAIR_HL && requiresHL (aop) && IS_GB) { emit2 ("ld a,l"); - if (aop->size>1) - emit2 ("ld d,h"); + emit2 ("ld d,h"); aopPut (aop, "a", 0); - if (aop->size>1) - aopPut (aop, "d", 1); + aopPut (aop, "d", 1); } else { @@ -1851,8 +1849,7 @@ commitPair (asmop * aop, PAIR_ID id) else { aopPut (aop, _pairs[id].l, 0); - if (aop->size>1) - aopPut (aop, _pairs[id].h, 1); + aopPut (aop, _pairs[id].h, 1); } } } @@ -6709,6 +6706,17 @@ genReceive (iCode * ic) freeAsmop (IC_RESULT (ic), NULL, ic); } +/*-----------------------------------------------------------------*/ +/* genDummyRead - generate code for dummy read of volatiles */ +/*-----------------------------------------------------------------*/ +static void +genDummyRead (iCode * ic) +{ + emit2 ("; genDummyRead not implemented"); + + ic; +} + enum { /** Maximum number of bytes to emit per line. */ @@ -7512,7 +7520,11 @@ genZ80Code (iCode * lic) emitDebug ("; genArrayInit"); genArrayInit(ic); break; - + + case DUMMY_READ_VOLATILE: + genDummyRead (ic); + break; + default: ic = ic; }