From: johanknol Date: Wed, 13 Jun 2001 09:25:31 +0000 (+0000) Subject: Next step in 16 bits short X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=777749ea16f6ffb540f71c834281e153fc8dc885;p=fw%2Fsdcc Next step in 16 bits short git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@884 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCC.y b/src/SDCC.y index afb2e5a9..7fe71788 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -565,7 +565,7 @@ type_specifier2 | SHORT { $$=newLink(); $$->class = SPECIFIER ; - SPEC_SHORT($$) = 1 ; + $$->select.s._short = 1 ; } | INT { $$=newLink(); @@ -580,7 +580,7 @@ type_specifier2 | SIGNED { $$=newLink(); $$->class = SPECIFIER ; - SPEC_SIGNED($$) = 1 ; + $$->select.s._signed = 1 ; } | UNSIGNED { $$=newLink(); diff --git a/src/SDCCast.c b/src/SDCCast.c index 9c62ab82..e76c932e 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2299,19 +2299,17 @@ decorateType (ast * tree) } LRVAL (tree) = RRVAL (tree) = 1; - /* promote result to int if left & right are char / short + /* promote result to int if left & right are char this will facilitate hardware multiplies 8bit x 8bit = 16bit */ - if ((IS_CHAR(LETYPE(tree)) || IS_SHORT(LETYPE(tree))) && - (IS_CHAR(RETYPE(tree)) || IS_SHORT(RETYPE(tree)))) { - TETYPE (tree) = getSpec (TTYPE (tree) = - computeType (LTYPE (tree), - RTYPE (tree))); - SPEC_NOUN(TETYPE(tree)) = V_INT; - SPEC_SHORT(TETYPE(tree))=0; + if (IS_CHAR(LETYPE(tree)) && IS_CHAR(RETYPE(tree))) { + TETYPE (tree) = getSpec (TTYPE (tree) = + computeType (LTYPE (tree), + RTYPE (tree))); + SPEC_NOUN(TETYPE(tree)) = V_INT; } else { - TETYPE (tree) = getSpec (TTYPE (tree) = - computeType (LTYPE (tree), - RTYPE (tree))); + TETYPE (tree) = getSpec (TTYPE (tree) = + computeType (LTYPE (tree), + RTYPE (tree))); } return tree; diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 5345f49e..8d059f92 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -302,7 +302,6 @@ DEFSETFUNC (findCheaperOp) if ((*opp) && (SPEC_USIGN(operandType (cop))==SPEC_USIGN(operandType (*opp))) && - (SPEC_SHORT(operandType (cop))==SPEC_SHORT(operandType (*opp))) && (SPEC_LONG(operandType (cop))==SPEC_LONG(operandType (*opp)))) { diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 6196ce22..02482ec7 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1623,7 +1623,6 @@ geniCodeMultiply (operand * left, operand * right,int resultIsInt) if (resultIsInt) { SPEC_NOUN(getSpec(resType))=V_INT; - SPEC_SHORT(getSpec(resType))=0; } /* if the right is a literal & power of 2 */ diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 363e39a4..661e8e6a 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -30,7 +30,7 @@ char *nounName(sym_link *sl) { { case V_INT: { if (SPEC_LONG(sl)) return "long"; - if (SPEC_SHORT(sl)) return "short"; + if (sl->select.s._short) return "short"; return "int"; } case V_FLOAT: return "float"; @@ -485,27 +485,26 @@ void checkTypeSanity(sym_link *etype, char *name) { SPEC_NOUN(etype)==V_FLOAT || SPEC_NOUN(etype)==V_DOUBLE || SPEC_NOUN(etype)==V_VOID) && - (SPEC_SHORT(etype) || SPEC_LONG(etype))) { + (etype->select.s._short || SPEC_LONG(etype))) { // long or short for char float double or void werror (E_LONG_OR_SHORT_INVALID, noun, name); } if ((SPEC_NOUN(etype)==V_FLOAT || SPEC_NOUN(etype)==V_DOUBLE || SPEC_NOUN(etype)==V_VOID) && - (SPEC_SIGNED(etype) || SPEC_USIGN(etype))) { + (etype->select.s._signed || SPEC_USIGN(etype))) { // signed or unsigned for float double or void werror (E_SIGNED_OR_UNSIGNED_INVALID, noun, name); } if (!SPEC_NOUN(etype)) { // special case for just "signed" or "unsigned" or "long" - if (SPEC_SIGNED(etype) || SPEC_USIGN(etype) || SPEC_LONG(etype)) { + if (etype->select.s._signed || SPEC_USIGN(etype) || SPEC_LONG(etype)) { SPEC_NOUN(etype)=V_INT; } // special case for just "short" - if (SPEC_SHORT(etype)) { + if (etype->select.s._short) { SPEC_NOUN(etype)=V_CHAR; // or maybe V_INT - SPEC_SHORT(etype)=0; } } @@ -514,11 +513,11 @@ void checkTypeSanity(sym_link *etype, char *name) { SPEC_NOUN(etype)=V_INT; } - if (SPEC_SIGNED(etype) && SPEC_USIGN(etype)) { + if (etype->select.s._signed && SPEC_USIGN(etype)) { // signed AND unsigned werror (E_SIGNED_AND_UNSIGNED_INVALID, noun, name); } - if (SPEC_SHORT(etype) && SPEC_LONG(etype)) { + if (etype->select.s._short && SPEC_LONG(etype)) { // short AND long werror (E_LONG_AND_SHORT_INVALID, noun, name); } @@ -539,8 +538,8 @@ mergeSpec (sym_link * dest, sym_link * src) /* we shouldn't redeclare the type */ if (getenv("DEBUG_SANITY")) { fprintf (stderr, "mergeSpec: "); - werror(E_TWO_OR_MORE_DATA_TYPES, yylval.yychar); } + werror(E_TWO_OR_MORE_DATA_TYPES, yylval.yychar); } } @@ -568,11 +567,11 @@ mergeSpec (sym_link * dest, sym_link * src) } #endif // but there are more important thing right now - + SPEC_LONG (dest) |= SPEC_LONG (src); - SPEC_SHORT (dest) |= SPEC_SHORT (src); + dest->select.s._short=src->select.s._short; SPEC_USIGN (dest) |= SPEC_USIGN (src); - SPEC_SIGNED (dest) |= SPEC_SIGNED (src); + dest->select.s._signed=src->select.s._signed; SPEC_STAT (dest) |= SPEC_STAT (src); SPEC_EXTR (dest) |= SPEC_EXTR (src); SPEC_ABSA (dest) |= SPEC_ABSA (src); @@ -715,7 +714,7 @@ getSize (sym_link * p) switch (SPEC_NOUN (p)) { /* depending on the specifier type */ case V_INT: - return (IS_LONG (p) ? LONGSIZE : (IS_SHORT (p) ? SHORTSIZE : INTSIZE)); + return (IS_LONG (p) ? LONGSIZE : INTSIZE); case V_FLOAT: return FLOATSIZE; case V_CHAR: @@ -774,7 +773,7 @@ bitsForType (sym_link * p) switch (SPEC_NOUN (p)) { /* depending on the specifier type */ case V_INT: - return (IS_LONG (p) ? LONGSIZE * 8 : (IS_SHORT (p) ? SHORTSIZE * 8 : INTSIZE * 8)); + return (IS_LONG (p) ? LONGSIZE * 8 : INTSIZE * 8); case V_FLOAT: return FLOATSIZE * 8; case V_CHAR: @@ -1456,17 +1455,6 @@ checkType (sym_link * dest, sym_link * src) SPEC_NOUN (src) == V_VOID) return -1; - /* char === to short */ - if (SPEC_NOUN (dest) == V_CHAR && - SPEC_NOUN (src) == V_INT && - SPEC_SHORT (src)) - return (SPEC_USIGN (src) == SPEC_USIGN (dest) ? 1 : -2); - - if (SPEC_NOUN (src) == V_CHAR && - SPEC_NOUN (dest) == V_INT && - SPEC_SHORT (dest)) - return (SPEC_USIGN (src) == SPEC_USIGN (dest) ? 1 : -2); - /* if they are both bitfields then if the lengths and starts don't match */ if (IS_BITFIELD (dest) && IS_BITFIELD (src) && @@ -1496,9 +1484,6 @@ checkType (sym_link * dest, sym_link * src) if (SPEC_LONG (dest) != SPEC_LONG (src)) return -1; - if (SPEC_SHORT (dest) != SPEC_SHORT (src)) - return -1; - if (SPEC_USIGN (dest) != SPEC_USIGN (src)) return -2; @@ -1936,8 +1921,6 @@ printTypeChain (sym_link * type, FILE * of) case V_INT: if (IS_LONG (type)) fprintf (of, "long "); - if (IS_SHORT (type)) - fprintf (of, "short "); fprintf (of, "int "); break; @@ -2031,8 +2014,6 @@ cdbTypeInfo (sym_link * type, FILE * of) case V_INT: if (IS_LONG (type)) fprintf (of, "SL"); - else if (IS_SHORT (type)) - fprintf (of, "SS"); else fprintf (of, "SI"); break; diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 65270620..5414d119 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -279,9 +279,9 @@ symbol; #define DCL_TSPEC(l) l->select.d.tspec #define SPEC_NOUN(x) x->select.s.noun #define SPEC_LONG(x) x->select.s._long -#define SPEC_SHORT(x) x->select.s._short +//#define SPEC_SHORT(x) x->select.s._short // only for type checking #define SPEC_USIGN(x) x->select.s._unsigned -#define SPEC_SIGNED(x) x->select.s._signed +//#define SPEC_SIGNED(x) x->select.s._signed // only for type checking #define SPEC_SCLS(x) x->select.s.sclass #define SPEC_ENUM(x) x->select.s._isenum #define SPEC_OCLS(x) x->select.s.oclass @@ -334,7 +334,7 @@ symbol; #define IS_GENPTR(x) (IS_DECL(x) && DCL_TYPE(x) == GPOINTER) #define IS_FUNC(x) (IS_DECL(x) && DCL_TYPE(x) == FUNCTION) #define IS_LONG(x) (IS_SPEC(x) && x->select.s._long) -#define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short) +//#define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short) #define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef) #define IS_CONSTANT(x) (IS_SPEC(x) && ( x->select.s._const == 1)) #define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT)