Now the pointer_type information of a storeage
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 13 Feb 2000 17:32:05 +0000 (17:32 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 13 Feb 2000 17:32:05 +0000 (17:32 +0000)
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

src/SDCCast.c
src/SDCCglue.c
src/SDCCicode.c
src/SDCCmem.c
src/SDCCmem.h
src/SDCCsymt.c
src/SDCCsymt.h
src/SDCCval.c
src/mcs51/gen.c

index d917e84ff3d9a606c43daca66c1cc0ec1a7330f1..772fadb78a5c385f9b3f8ef550db92f29b0abcd9 100644 (file)
@@ -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;
index 131a958fb176ae8a76f249a9e053c853a6b212e4..f80af473487d55c5fe0e524ba2b6b97130b48210 100644 (file)
@@ -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;
index fd7b49a1d3f0e9f4333cb5594742812f6184a01e..23bc6c5d4d037500208cfc329c28b84885d28bdc 100644 (file)
@@ -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)) 
index cd8df6a4f4359567bcce660ad4014eec67aa7225..c23df68cc311132c79948065664fa9912808d43c 100644 (file)
@@ -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
index 7a5517c359b296e9aac9636d42b2f39129a12e2e..6f10c4e165f074676afb66c51c67019c2caf86b6 100644 (file)
@@ -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 );
index 037bf4792230936ca69d6e586f9757d63c185455..25040c1b751bf9c9e3c0221fd305d67e0763295c 100644 (file)
@@ -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;
index beea79c2381deeadd61625f6975394db74bafc0c..6f7ee2621bb805a47438a5d88d280a759bdd0794 100644 (file)
@@ -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))
index 5818c72607e7a0453eb3817180a833429f8ec314..df091eb152175915262b3d739ae7c0c8e98df562 100644 (file)
@@ -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; 
index b153c4fd8a1f3cbd449ff0b2b12100d7a608d33a..9c221fc954a7eef1852809060dfb21e197f22b18 100644 (file)
@@ -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 */