* src/pic16/genarith.c,
[fw/sdcc] / src / pic16 / pcode.c
index baec7f296a4e5f60b86a0e2320fddd34b811d528..9ff1d2fd4174316efde09ad912715510048a5c88 100644 (file)
 extern char *pic16_aopGet (struct asmop *aop, int offset, bool bit16, bool dname);
 
 #if defined(__BORLANDC__) || defined(_MSC_VER)
-#define STRCASECMP stricmp
 #define inline
-#else
-#define STRCASECMP strcasecmp
 #endif
 
 #define DUMP_DF_GRAPHS 0
@@ -3805,7 +3802,7 @@ pCodeFlowLink *pic16_newpCodeFlowLink(pCodeFlow *pcflow)
 /* pic16_newpCodeCSource - create a new pCode Source Symbol        */
 /*-----------------------------------------------------------------*/
 
-pCode *pic16_newpCodeCSource(int ln, char *f, char *l)
+pCode *pic16_newpCodeCSource(int ln, const char *f, const char *l)
 {
 
   pCodeCSource *pccs;
@@ -5022,7 +5019,7 @@ char *pic16_pCode2str(char *str, size_t size, pCode *pc)
 
           r = pic16_getRegFromInstruction(pc);
 //              fprintf(stderr, "%s:%d reg = %p\tname= %s, accessBank= %d\n",
-//                      __FUNCTION__, __LINE__, r, (r)?r->name:"<null>", (r)?r->accessBank:-1);
+//                      __FUNCTION__, __LINE__, r, (r)?r->name:"<null>", (r)?isACCESS_BANK(r):-1);
 
           if(PCI(pc)->isAccess) {
            static char *bank_spec[2][2] = {
@@ -5030,7 +5027,7 @@ char *pic16_pCode2str(char *str, size_t size, pCode *pc)
              { ", B", ", BANKED" }/* MPASM (should) use BANKED by default */
            };
             
-           SAFE_snprintf(&s,&size,"%s", bank_spec[(r && !r->accessBank) ? 1 : 0][pic16_mplab_comp ? 1 : 0]);
+           SAFE_snprintf(&s,&size,"%s", bank_spec[(r && !isACCESS_BANK(r)) ? 1 : 0][pic16_mplab_comp ? 1 : 0]);
          }
         }
 //      
@@ -6727,7 +6724,7 @@ static void pBlockRemoveUnusedLabels(pBlock *pb)
 {
   pCode *pc; pCodeLabel *pcl;
 
-  if(!pb)
+  if(!pb || !pb->pcHead)
     return;
 
   for(pc = pb->pcHead; (pc=pic16_findNextInstruction(pc->next)) != NULL; ) {
@@ -10106,6 +10103,8 @@ static defmap_t *pic16_pBlockAddInval (pBlock *pb, symbol_t sym) {
   defmap_t *map;
   pCodeFlow *pcfl;
 
+  assert(pb);
+
   pcfl = PCI(pic16_findNextInstruction (pb->pcHead))->pcflow;
 
   /* find initial value (assigning pc == NULL) */
@@ -11304,6 +11303,8 @@ static void createReachingDefinitions (pBlock *pb) {
   set *todo;
   set *blacklist;
 
+  if (!pb) return;
+
   /* initialize out_vals to unique'fied defmaps per pCodeFlow */
   for (pc = pic16_findNextInstruction (pb->pcHead); pc; pc = pic16_findNextInstruction (pc->next)) {
     if (isPCFL(pc)) {
@@ -11813,6 +11814,8 @@ static void assignValnums (pCode *pc) {
 static void pic16_destructDF (pBlock *pb) {
   pCode *pc, *next;
 
+  if (!pb) return;
+
   /* remove old defmaps */
   pc = pic16_findNextInstruction (pb->pcHead);
   while (pc) {
@@ -11838,6 +11841,8 @@ static void pic16_destructDF (pBlock *pb) {
 static int pic16_pBlockHasAsmdirs (pBlock *pb) {
   pCode *pc;
 
+  if (!pb) return 0;
+
   pc = pic16_findNextInstruction (pb->pcHead);
   while (pc) {
     if (isPCAD(pc)) return 1;
@@ -11925,6 +11930,8 @@ static void pic16_createDF (pBlock *pb) {
   pCode *pc, *next;
   int change=0;
 
+  if (!pb) return;
+
   //fprintf (stderr, "creating DF for pb %p (%s)\n", pb, pic16_pBlockGetFunctionName (pb));
 
   pic16_destructDF (pb);
@@ -12218,6 +12225,8 @@ static void pic16_vcg_dumpedges (pCode *pc, FILE *of) {
 static void pic16_vcg_dump (FILE *of, pBlock *pb) {
   pCode *pc;
 
+  if (!pb) return;
+
   /* check pBlock: do not analyze pBlocks with ASMDIRs (for now...) */
   if (pic16_pBlockHasAsmdirs (pb)) {
     //fprintf (stderr, "%s: pBlock contains ASMDIRs -- data flow analysis not performed!\n", __FUNCTION__);
@@ -12238,6 +12247,8 @@ static void pic16_vcg_dump_default (pBlock *pb) {
   char buf[BUF_SIZE];
   pCode *pc;
 
+  if (!pb) return;
+
   /* get function name */
   pc = pb->pcHead;
   while (pc && !isPCF(pc)) pc = pc->next;