From: sandeep Date: Sun, 13 Feb 2000 17:32:05 +0000 (+0000) Subject: Now the pointer_type information of a storeage X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=26ee19aa2f7d419112c283ab517dfe3cef69d2e4;p=fw%2Fsdcc Now the pointer_type information of a storeage class is stored in the memory-map don't need ugly ifs just get it from the ocls data-structure. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@104 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index d917e84f..772fadb7 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1763,7 +1763,10 @@ ast *decorateType (ast *tree) if (SPEC_SCLS(tree->left->etype) == S_IDATA) DCL_TYPE(p) = IPOINTER ; else - DCL_TYPE(p) = POINTER ; + if (SPEC_SCLS(tree->left->etype) == S_FLASH) + DCL_TYPE(p) = FLPOINTER ; + else + DCL_TYPE(p) = POINTER ; if (IS_AST_SYM_VALUE(tree->left)) { AST_SYMBOL(tree->left)->addrtaken = 1; diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 131a958f..f80af473 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -226,7 +226,10 @@ value *initPointer (initList *ilist) if (SPEC_SCLS(expr->left->etype) == S_IDATA) DCL_TYPE(val->type) = IPOINTER ; else - DCL_TYPE(val->type) = POINTER ; + if (SPEC_SCLS(expr->left->etype) == S_FLASH) + DCL_TYPE(val->type) = FLPOINTER ; + else + DCL_TYPE(val->type) = POINTER ; val->type->next = expr->left->ftype; val->etype = getSpec(val->type); return val; diff --git a/src/SDCCicode.c b/src/SDCCicode.c index fd7b49a1..23bc6c5d 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1653,24 +1653,27 @@ link *aggrToPtr ( link *type, bool force) ptype->next = type; /* if the output class is generic */ - if (SPEC_OCLS(etype) == generic) - DCL_TYPE(ptype) = GPOINTER; - else - if (SPEC_OCLS(etype)->codesp ) { - DCL_TYPE(ptype) = CPOINTER ; - DCL_PTR_CONST(ptype) = 1; - } - else - if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) - DCL_TYPE(ptype) = FPOINTER ; - else - if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) - DCL_TYPE(ptype) = PPOINTER ; - else - if (SPEC_OCLS(etype) == idata) - DCL_TYPE(ptype) = IPOINTER; - else - DCL_TYPE(ptype) = POINTER ; + if ((DCL_TYPE(ptype) = PTR_TYPE(SPEC_OCLS(etype))) == CPOINTER) + DCL_PTR_CONST(ptype) = 1; + +/* if (SPEC_OCLS(etype) == generic) */ +/* DCL_TYPE(ptype) = GPOINTER; */ +/* else */ +/* if (SPEC_OCLS(etype)->codesp ) { */ +/* DCL_TYPE(ptype) = CPOINTER ; */ +/* DCL_PTR_CONST(ptype) = 1; */ +/* } */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) */ +/* DCL_TYPE(ptype) = FPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) */ +/* DCL_TYPE(ptype) = PPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype) == idata) */ +/* DCL_TYPE(ptype) = IPOINTER; */ +/* else */ +/* DCL_TYPE(ptype) = POINTER ; */ /* if the variable was declared a constant */ /* then the pointer points to a constant */ @@ -1691,22 +1694,25 @@ operand *geniCodeArray2Ptr (operand *op) link *optype = operandType(op); link *opetype = getSpec(optype); - /* set the pointer depending on the storage class */ - if (SPEC_OCLS(opetype)->codesp ) { - DCL_TYPE(optype) = CPOINTER ; + if ((DCL_TYPE(optype) = PTR_TYPE(SPEC_OCLS(opetype))) == CPOINTER) DCL_PTR_CONST(optype) = 1; - } - else - if (SPEC_OCLS(opetype)->fmap && !SPEC_OCLS(opetype)->paged) - DCL_TYPE(optype) = FPOINTER ; - else - if (SPEC_OCLS(opetype)->fmap && SPEC_OCLS(opetype)->paged) - DCL_TYPE(optype) = PPOINTER ; - else - if (SPEC_OCLS(opetype) == idata) - DCL_TYPE(optype) = IPOINTER; - else - DCL_TYPE(optype) = POINTER ; + + /* set the pointer depending on the storage class */ +/* if (SPEC_OCLS(opetype)->codesp ) { */ +/* DCL_TYPE(optype) = CPOINTER ; */ +/* DCL_PTR_CONST(optype) = 1; */ +/* } */ +/* else */ +/* if (SPEC_OCLS(opetype)->fmap && !SPEC_OCLS(opetype)->paged) */ +/* DCL_TYPE(optype) = FPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(opetype)->fmap && SPEC_OCLS(opetype)->paged) */ +/* DCL_TYPE(optype) = PPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(opetype) == idata) */ +/* DCL_TYPE(optype) = IPOINTER; */ +/* else */ +/* DCL_TYPE(optype) = POINTER ; */ /* if the variable was declared a constant */ /* then the pointer points to a constant */ @@ -1975,26 +1981,30 @@ operand *geniCodeAddressOf (operand *op) p = newLink(); p->class = DECLARATOR ; - /* set the pointer depending on the storage class */ - if (SPEC_OCLS(opetype)->codesp ) { - DCL_TYPE(p) = CPOINTER ; + + if ((DCL_TYPE(p) = PTR_TYPE(SPEC_OCLS(opetype))) == CPOINTER) DCL_PTR_CONST(p) = 1; - } - else - if (SPEC_OCLS(opetype)->fmap && !SPEC_OCLS(opetype)->paged) - DCL_TYPE(p) = FPOINTER ; - else - if (SPEC_OCLS(opetype)->fmap && SPEC_OCLS(opetype)->paged) - DCL_TYPE(p) = PPOINTER ; - else - if (SPEC_OCLS(opetype) == idata) - DCL_TYPE(p) = IPOINTER; - else - if (SPEC_OCLS(opetype) == data || - SPEC_OCLS(opetype) == overlay) - DCL_TYPE(p) = POINTER ; - else - DCL_TYPE(p) = GPOINTER; + + /* set the pointer depending on the storage class */ +/* if (SPEC_OCLS(opetype)->codesp ) { */ +/* DCL_TYPE(p) = CPOINTER ; */ +/* DCL_PTR_CONST(p) = 1; */ +/* } */ +/* else */ +/* if (SPEC_OCLS(opetype)->fmap && !SPEC_OCLS(opetype)->paged) */ +/* DCL_TYPE(p) = FPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(opetype)->fmap && SPEC_OCLS(opetype)->paged) */ +/* DCL_TYPE(p) = PPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(opetype) == idata) */ +/* DCL_TYPE(p) = IPOINTER; */ +/* else */ +/* if (SPEC_OCLS(opetype) == data || */ +/* SPEC_OCLS(opetype) == overlay) */ +/* DCL_TYPE(p) = POINTER ; */ +/* else */ +/* DCL_TYPE(p) = GPOINTER; */ /* make sure we preserve the const & volatile */ if (IS_CONSTANT(opetype)) diff --git a/src/SDCCmem.c b/src/SDCCmem.c index cd8df6a4..c23df68c 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -89,7 +89,7 @@ void initMem () DEBUG-NAME - 'A' POINTER-TYPE - FPOINTER */ - xstack = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, XSTACK_NAME,'A',FPOINTER); + xstack = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, XSTACK_NAME,'A',PPOINTER); /* internal stack segment ; SFRSPACE - NO diff --git a/src/SDCCmem.h b/src/SDCCmem.h index 7a5517c3..6f10c4e1 100644 --- a/src/SDCCmem.h +++ b/src/SDCCmem.h @@ -63,6 +63,8 @@ extern struct set *ovrSetSets; #define IN_DIRSPACE(map) (map && map->direct) #define IN_PAGEDSPACE(map) (map && map->paged ) #define IN_CODESPACE(map) (map && map->codesp) +#define PTR_TYPE(map) (map ? (map->ptrType ? map->ptrType : POINTER)\ + : GPOINTER) /* forward decls for functions */ memmap *allocMap (char,char,char,char,char,char,unsigned, const char *,char,int ); diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 037bf479..25040c1b 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -296,6 +296,9 @@ void pointerTypes (link *ptr, link *type) DCL_PTR_CONST(ptr) = 1; DCL_TYPE(ptr) = CPOINTER ; break; + case S_FLASH: + DCL_TYPE(ptr) = FLPOINTER; + break; default: DCL_TYPE(ptr) = GPOINTER; break; @@ -564,10 +567,11 @@ unsigned int getSize ( link *p ) case PPOINTER: case POINTER: return ( PTRSIZE ) ; + case FLPOINTER: case FPOINTER: case CPOINTER: return ( FPTRSIZE ); - case GPOINTER: + case GPOINTER: return ( GPTRSIZE ); default : @@ -618,6 +622,7 @@ unsigned int bitsForType ( link *p ) case PPOINTER: case POINTER: return ( PTRSIZE * 8) ; + case FLPOINTER: case FPOINTER: case CPOINTER: return ( FPTRSIZE * 8); @@ -1439,6 +1444,9 @@ void processFuncArgs (symbol *func, int ignoreName) case S_XDATA: DCL_TYPE(val->type) = FPOINTER; break; + case S_FLASH: + DCL_TYPE(val->type) = FLPOINTER; + break; default : DCL_TYPE(val->type) = GPOINTER; } @@ -1548,6 +1556,12 @@ void printTypeChain (link *type, FILE *of) if (DCL_PTR_CONST(type)) fprintf(of,"const "); break; + case FLPOINTER: + fprintf (of,"_flash * "); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + case POINTER: fprintf (of,"_near * "); if (DCL_PTR_CONST(type)) @@ -1651,6 +1665,9 @@ void cdbTypeInfo (link *type,FILE *of) case PPOINTER: fprintf (of,"DP,"); break; + case FLPOINTER: + fprintf (of,"DA,"); + break; case ARRAY : fprintf (of,"DA%d,",DCL_ELEM(type)); break; diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index beea79c2..6f7ee262 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -278,6 +278,7 @@ typedef struct symbol { DCL_TYPE(x) == GPOINTER || \ DCL_TYPE(x) == IPOINTER || \ DCL_TYPE(x) == PPOINTER || \ + DCL_TYPE(x) == FLPOINTER || \ DCL_TYPE(x) == CPOINTER || \ DCL_TYPE(x) == UPOINTER )) #define IS_PTR_CONST(x) (IS_PTR(x) && DCL_PTR_CONST(x)) diff --git a/src/SDCCval.c b/src/SDCCval.c index 5818c726..df091eb1 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -1198,7 +1198,7 @@ value *valForArray (ast *arrExpr) sprintf(val->name,"(%s + %d)",buffer, (int)AST_LIT_VALUE(arrExpr->right)*size); - val->type = newLink(); + val->type = newLink(); if (SPEC_SCLS(arrExpr->left->etype) == S_CODE) { DCL_TYPE(val->type) = CPOINTER ; DCL_PTR_CONST(val->type) = 1; @@ -1213,7 +1213,10 @@ value *valForArray (ast *arrExpr) if (SPEC_SCLS(arrExpr->left->etype) == S_IDATA) DCL_TYPE(val->type) = IPOINTER ; else - DCL_TYPE(val->type) = POINTER ; + if (SPEC_SCLS(arrExpr->left->etype) == S_FLASH) + DCL_TYPE(val->type) = FLPOINTER ; + else + DCL_TYPE(val->type) = POINTER ; val->type->next = arrExpr->left->ftype; val->etype = getSpec(val->type); return val; @@ -1279,7 +1282,10 @@ value *valForStructElem(ast *structT, ast *elemT) if (SPEC_SCLS(structT->etype) == S_IDATA) DCL_TYPE(val->type) = IPOINTER ; else - DCL_TYPE(val->type) = POINTER ; + if (SPEC_SCLS(structT->etype) == S_FLASH) + DCL_TYPE(val->type) = FLPOINTER ; + else + DCL_TYPE(val->type) = POINTER ; val->type->next = sym->type; val->etype = getSpec(val->type); return val; diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index b153c4fd..9c221fc9 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -236,21 +236,24 @@ static asmop *newAsmop (short type) static int pointerCode (link *etype) { int p_type; - if (SPEC_OCLS(etype)->codesp ) { - p_type = CPOINTER ; - } - else - if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) - p_type = FPOINTER ; - else - if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) - p_type = PPOINTER; - else - if (SPEC_OCLS(etype) == idata ) - p_type = IPOINTER; - else - p_type = POINTER ; - return p_type; + + return PTR_TYPE(SPEC_OCLS(etype)); + +/* if (SPEC_OCLS(etype)->codesp ) { */ +/* p_type = CPOINTER ; */ +/* } */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) */ +/* p_type = FPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) */ +/* p_type = PPOINTER; */ +/* else */ +/* if (SPEC_OCLS(etype) == idata ) */ +/* p_type = IPOINTER; */ +/* else */ +/* p_type = POINTER ; */ +/* return p_type; */ } /*-----------------------------------------------------------------*/ @@ -6134,22 +6137,23 @@ static void genPointerGet (iCode *ic) if (IS_PTR(type) && !IS_FUNC(type->next)) p_type = DCL_TYPE(type); else { - /* we have to go by the storage class */ - if (SPEC_OCLS(etype)->codesp ) { - p_type = CPOINTER ; - } - else - if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) - p_type = FPOINTER ; - else - if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) - p_type = PPOINTER; - else - if (SPEC_OCLS(etype) == idata ) - p_type = IPOINTER; - else - p_type = POINTER ; + p_type = PTR_TYPE(SPEC_OCLS(etype)); + +/* if (SPEC_OCLS(etype)->codesp ) { */ +/* p_type = CPOINTER ; */ +/* } */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) */ +/* p_type = FPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) */ +/* p_type = PPOINTER; */ +/* else */ +/* if (SPEC_OCLS(etype) == idata ) */ +/* p_type = IPOINTER; */ +/* else */ +/* p_type = POINTER ; */ } /* now that we have the pointer type we assign @@ -6657,22 +6661,23 @@ static void genPointerSet (iCode *ic) p_type = DCL_TYPE(type); } else { - /* we have to go by the storage class */ - if (SPEC_OCLS(etype)->codesp ) { - p_type = CPOINTER ; - } - else - if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) - p_type = FPOINTER ; - else - if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) - p_type = PPOINTER ; - else - if (SPEC_OCLS(etype) == idata ) - p_type = IPOINTER ; - else - p_type = POINTER ; + p_type = PTR_TYPE(SPEC_OCLS(etype)); + +/* if (SPEC_OCLS(etype)->codesp ) { */ +/* p_type = CPOINTER ; */ +/* } */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) */ +/* p_type = FPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) */ +/* p_type = PPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype) == idata ) */ +/* p_type = IPOINTER ; */ +/* else */ +/* p_type = POINTER ; */ } /* now that we have the pointer type we assign @@ -7006,60 +7011,62 @@ static void genCast (iCode *ic) /* pointer to generic pointer */ if (IS_GENPTR(ctype)) { - char *l = zero; - - if (IS_PTR(type)) - p_type = DCL_TYPE(type); - else { - /* we have to go by the storage class */ - if (SPEC_OCLS(etype)->codesp ) - p_type = CPOINTER ; - else - if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) - p_type = FPOINTER ; - else - if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) - p_type = PPOINTER; - else - if (SPEC_OCLS(etype) == idata ) - p_type = IPOINTER ; - else - p_type = POINTER ; - } + char *l = zero; + + if (IS_PTR(type)) + p_type = DCL_TYPE(type); + else { + /* we have to go by the storage class */ + p_type = PTR_TYPE(SPEC_OCLS(etype)); + +/* if (SPEC_OCLS(etype)->codesp ) */ +/* p_type = CPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) */ +/* p_type = FPOINTER ; */ +/* else */ +/* if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) */ +/* p_type = PPOINTER; */ +/* else */ +/* if (SPEC_OCLS(etype) == idata ) */ +/* p_type = IPOINTER ; */ +/* else */ +/* p_type = POINTER ; */ + } - /* the first two bytes are known */ - size = GPTRSIZE - 1; - offset = 0 ; - while (size--) { - aopPut(AOP(result), - aopGet(AOP(right),offset,FALSE,FALSE), - offset); - offset++; - } - /* the last byte depending on type */ - switch (p_type) { - case IPOINTER: - case POINTER: - l = zero; - break; - case FPOINTER: - l = one; - break; - case CPOINTER: - l = "#0x02"; - break; - case PPOINTER: - l = "#0x03"; - break; - - default: - /* this should never happen */ - werror(E_INTERNAL_ERROR,__FILE__,__LINE__, - "got unknown pointer type"); - exit(1); - } - aopPut(AOP(result),l, GPTRSIZE - 1); - goto release ; + /* the first two bytes are known */ + size = GPTRSIZE - 1; + offset = 0 ; + while (size--) { + aopPut(AOP(result), + aopGet(AOP(right),offset,FALSE,FALSE), + offset); + offset++; + } + /* the last byte depending on type */ + switch (p_type) { + case IPOINTER: + case POINTER: + l = zero; + break; + case FPOINTER: + l = one; + break; + case CPOINTER: + l = "#0x02"; + break; + case PPOINTER: + l = "#0x03"; + break; + + default: + /* this should never happen */ + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "got unknown pointer type"); + exit(1); + } + aopPut(AOP(result),l, GPTRSIZE - 1); + goto release ; } /* just copy the pointers */