* src/pic16/pcode.c (pic16_pCodeReplace): also update pcflow->end
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 6 Apr 2005 07:55:10 +0000 (07:55 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 6 Apr 2005 07:55:10 +0000 (07:55 +0000)
* (createDefmap): fixed CALLs to depend on FSR1 and RETLW to restore
  callers stack/frame pointers

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3720 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/pic16/pcode.c

index 5cc0a663ebd535a222882479c9e43a65ebe1484e..39475bebdce09698e1cae98b3dcc5d2001e9ad57 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-06 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/pcode.c (pic16_pCodeReplace): also update pcflow->end
+       * (createDefmap): fixed CALLs to depend on FSR1 and RETLW to restore
+         callers stack/frame pointers
+
 2005-04-06 Vangelis Rokas <vrokas AT users.sourceforge.net>
 
         * device/include/pic16/usart.h: added, missing in previous commit,
index 08a439af3e513863d9b69a3225507ccf8308fdd0..49f86f72703350854168553a20bc1beb5e437c5c 100644 (file)
@@ -7240,6 +7240,9 @@ void pic16_pCodeReplace (pCode *oldPC, pCode *newPC) {
   /* keep flow information intact */
   newPC->seq = oldPC->seq;
   PCI(newPC)->pcflow = PCI(oldPC)->pcflow;
+  if (PCI(newPC)->pcflow && PCI(newPC)->pcflow->end == oldPC) {
+    PCI(newPC)->pcflow->end = newPC;
+  }
 
   /* insert a comment stating which pCode has been replaced */
 #if 1
@@ -10530,7 +10533,7 @@ static int pic16_regIsLocal (regs *r) {
     case SPO_WREG:
     case SPO_FSR0L: // used in ptrget/ptrput
     case SPO_FSR0H: // ... as well
-    case SPO_FSR1L: // used as stack pointer...
+    case SPO_FSR1L: // used as stack pointer... (so not really local but shared among function calls)
     case SPO_FSR1H: // ... as well
     case SPO_FSR2L: // used as frame pointer
     case SPO_FSR2H: // ... as well
@@ -10865,6 +10868,10 @@ static defmap_t *createDefmap (pCode *pc, defmap_t *list) {
     list = newDefmap (SPO_PRODL, 0xff, 0xff, 1, 1, pc, newValnum (), list);
     list = newDefmap (SPO_PRODH, 0xff, 0xff, 1, 1, pc, newValnum (), list);
     list = newDefmap (SPO_FSR0L, 0xff, 0xff, 1, 1, pc, newValnum (), list);
+
+    /* needs correctly set-up stack pointer */
+    list = newDefmap (SPO_FSR1L, 0xff, 0x00, 1, 0, pc, 0, list);
+    list = newDefmap (SPO_FSR1H, 0xff, 0x00, 1, 0, pc, 0, list);
     break;
 
   case POC_RETLW: // return values: WREG, PRODx, FSR0L
@@ -10873,6 +10880,12 @@ static defmap_t *createDefmap (pCode *pc, defmap_t *list) {
     list = newDefmap (SPO_PRODL, 0xff, 0x00, 1, 0, pc, 0, list);
     list = newDefmap (SPO_PRODH, 0xff, 0x00, 1, 0, pc, 0, list);
     list = newDefmap (SPO_FSR0L, 0xff, 0x00, 1, 0, pc, 0, list);
+
+    /* caller's stack pointers must be restored */
+    list = newDefmap (SPO_FSR1L, 0xff, 0x00, 1, 0, pc, 0, list);
+    list = newDefmap (SPO_FSR1H, 0xff, 0x00, 1, 0, pc, 0, list);
+    list = newDefmap (SPO_FSR2L, 0xff, 0x00, 1, 0, pc, 0, list);
+    list = newDefmap (SPO_FSR2H, 0xff, 0x00, 1, 0, pc, 0, list);
     break;
 
   case POC_RETURN: // return values; WREG, PRODx, FSR0L