From 07ee425c67c57e814fa5874cc893cde07bb843d4 Mon Sep 17 00:00:00 2001 From: johanknol Date: Fri, 9 Nov 2001 15:40:49 +0000 Subject: [PATCH] some prelimanary floating point fixes git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1536 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCast.c | 30 +----------------------------- src/SDCCicode.c | 3 +++ src/SDCCval.c | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 40 deletions(-) diff --git a/src/SDCCast.c b/src/SDCCast.c index 441bedc9..b8abb0c0 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2089,38 +2089,10 @@ decorateType (ast * tree) return decorateType (otree); } -#if 0 - // we can't do this because of "(int & 0xff) << 3" - - /* if right or left is literal then result of that type */ - if (IS_LITERAL (RTYPE (tree))) - { - - TTYPE (tree) = copyLinkChain (RTYPE (tree)); - TETYPE (tree) = getSpec (TTYPE (tree)); - SPEC_SCLS (TETYPE (tree)) = S_AUTO; - } - else - { - if (IS_LITERAL (LTYPE (tree))) - { - TTYPE (tree) = copyLinkChain (LTYPE (tree)); - TETYPE (tree) = getSpec (TTYPE (tree)); - SPEC_SCLS (TETYPE (tree)) = S_AUTO; - - } - else - { - TTYPE (tree) = - computeType (LTYPE (tree), RTYPE (tree)); - TETYPE (tree) = getSpec (TTYPE (tree)); - } - } -#else TTYPE (tree) = computeType (LTYPE (tree), RTYPE (tree)); TETYPE (tree) = getSpec (TTYPE (tree)); -#endif + LRVAL (tree) = RRVAL (tree) = 1; return tree; } diff --git a/src/SDCCicode.c b/src/SDCCicode.c index f2080570..4ca47ca5 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2291,6 +2291,9 @@ geniCodeBitwise (operand * left, operand * right, { iCode *ic; + // bitwise operations must be done unsigned + SPEC_USIGN(resType)=1; + left = geniCodeCast (resType, left, TRUE); right = geniCodeCast (resType, right, TRUE); diff --git a/src/SDCCval.c b/src/SDCCval.c index 2e3448a5..c61a6c8c 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -340,28 +340,28 @@ value *cheapestVal (value *val) { if (uval<=0xffff) { SPEC_LONG(val->type)=0; SPEC_CVAL(val->type).v_uint = uval; - } - if (uval<=0xff) { - SPEC_NOUN(val->type)=V_CHAR; + if (uval<=0xff) { + SPEC_NOUN(val->type)=V_CHAR; + } } } else { // not unsigned if (sval<0) { if (sval>=-32768) { SPEC_LONG(val->type)=0; SPEC_CVAL(val->type).v_int = sval & 0xffff; - } - if (sval>=-128) { - SPEC_NOUN(val->type)=V_CHAR; - SPEC_CVAL(val->type).v_int &= 0xff; + if (sval>=-128) { + SPEC_NOUN(val->type)=V_CHAR; + SPEC_CVAL(val->type).v_int &= 0xff; + } } } else { // sval>=0 SPEC_USIGN(val->type)=1; if (sval<=65535) { SPEC_LONG(val->type)=0; SPEC_CVAL(val->type).v_int = sval; - } - if (sval<=255) { - SPEC_NOUN(val->type)=V_CHAR; + if (sval<=255) { + SPEC_NOUN(val->type)=V_CHAR; + } } } } @@ -860,7 +860,7 @@ valFromType (sym_link * type) } /*------------------------------------------------------------------*/ -/* floatFromVal - value to unsinged integer conversion */ +/* floatFromVal - value to double float conversion */ /*------------------------------------------------------------------*/ double floatFromVal (value * val) -- 2.30.2