From 6188e1e2fdee0a239398c2c133892861c1988765 Mon Sep 17 00:00:00 2001 From: maartenbrock Date: Sun, 6 Mar 2005 11:50:17 +0000 Subject: [PATCH] * src/SDCCicode.h: moved CRITICAL and ENDCRITICAL from SKIP_IC2 to SKIP_IC * src/mcs51/ralloc.c (willCauseSpill): added check for REG_BIT type, (regTypeNum): set REG_BIT type if necessary * src/mcs51/ralloc.h: added define REG_BIT, used to fix bug 1144613 * support/regression/tests/critical.c: check bug 1144613 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3689 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 36 ++++++++++++++++++----------- src/SDCCicode.h | 6 ++--- src/mcs51/ralloc.c | 24 +++++++++++-------- src/mcs51/ralloc.h | 32 ++++++++++++------------- support/regression/tests/critical.c | 5 ++++ 5 files changed, 60 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89cc5421..3a32fced 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,16 @@ +2005-03-06 Maarten Brock + + * src/SDCCicode.h: moved CRITICAL and ENDCRITICAL from SKIP_IC2 to SKIP_IC + * src/mcs51/ralloc.c (willCauseSpill): added check for REG_BIT type, + (regTypeNum): set REG_BIT type if necessary + * src/mcs51/ralloc.h: added define REG_BIT, used to fix bug 1144613 + * support/regression/tests/critical.c: check bug 1144613 + 2005-03-02 Raphael Neider * src/pic16/gen.c (genRightShiftLiteral): fixed bug #1154256 -2004-02-26 Erik Petrich +2005-02-26 Erik Petrich * src/avr/ralloc.c (serialRegAssign), * src/ds390/ralloc.c (serialRegAssign), @@ -17,13 +25,13 @@ * src/SDCCast.c (decorateType): fixed bug 1124787 -2004-02-20 Hubert Sack +2005-02-20 Hubert Sack committed by Frieder Ferlemann * src/mcs51/peeph.def: added peepholes 3.h-k and 132.a-f from patch #1121755 -2004-02-20 Frieder Ferlemann +2005-02-20 Frieder Ferlemann * src/SDCCpeeph.def: new keyword "labelRefCountChange" which allows peepholes to keep the correct label reference count when adding/removing references @@ -85,7 +93,7 @@ * src/pic/gen.c : Fix for bugs #1080519 & #1115662. -2004-02-03 Maarten Brock +2005-02-03 Maarten Brock * device/include/mcs51/c8051f120.h: added declarations for sbit port 2,3&4 @@ -97,7 +105,7 @@ * (genPackBits): improved accessing full bytes, implemented for GPOINTERs * device/include/pic16/{stddef.h,stdbool.h}: added -2004-02-02 Maarten Brock +2005-02-02 Maarten Brock * device/include/mcs51/c8051f040.h: added define CPT2_PAGE @@ -107,28 +115,28 @@ * src/pic16/Makefile.bcc : Do not use this file but added file graph.c as it appeared to be required -2004-01-31 Borut Razem +2005-01-31 Borut Razem * support/scripts/sdcc.nsi: added include/asm/ds390, include/asm/mcs51, include/mcs51 and include/z80 directories to the package -2004-01-26 Erik Petrich +2005-01-26 Erik Petrich * src/hc08/gen.c (genFunction): fixed bug #1112752 -2004-01-30 Frieder Ferlemann +2005-01-30 Frieder Ferlemann * src/mcs51/peeph.def: adapted peephole 258.x to changed gen.c (genAnd) -2004-01-29 Frieder Ferlemann +2005-01-29 Frieder Ferlemann * src/mcs51/gen.c (genAnd): accessing LSB/MSB by rotating acc -2004-01-29 Maarten Brock +2005-01-29 Maarten Brock * device/include/Makefile.in: create/copy mcs51 and z80 include subdirs -2004-01-27 Maarten Brock +2005-01-27 Maarten Brock * device/include/c8051fxxx.h: removed these 6 files * device/include/mcs51/c8051fxxx.h: added these 11 new files @@ -142,11 +150,11 @@ * src/pic16/glue.c (emitStatistics): beautified * device/lib/pic16/libm/Makefile: added include path -2004-01-26 Erik Petrich +2005-01-26 Erik Petrich * src/z80/gen.c (aopPut): fixed bug #1103902 -2004-01-25 Erik Petrich +2005-01-25 Erik Petrich * device/lib/expf.c: fixed bug #1095792 @@ -236,7 +244,7 @@ * src/pic16/pcoderegs.c (pCodeOptime2pCodes): disabled optimization to fix #1106967 (pCode->seq are not set up correctly) -2004-01-22 Erik Petrich +2005-01-22 Erik Petrich * src/SDCCglue.c (glue): make sure code area is declared before the static initialization area. diff --git a/src/SDCCicode.h b/src/SDCCicode.h index 2968911f..d0aab4c0 100644 --- a/src/SDCCicode.h +++ b/src/SDCCicode.h @@ -211,9 +211,7 @@ iCodeTable; x->op == LABEL || \ x->op == FUNCTION || \ x->op == INLINEASM || \ - x->op == ENDFUNCTION || \ - x->op == CRITICAL || \ - x->op == ENDCRITICAL ) + x->op == ENDFUNCTION ) #define SKIP_IC1(x) (x->op == CALL || \ SKIP_IC2(x) ) @@ -225,6 +223,8 @@ iCodeTable; x->op == RECEIVE || \ x->op == ARRAYINIT || \ SKIP_IC1(x) || \ + x->op == CRITICAL || \ + x->op == ENDCRITICAL || \ x->op == SEND ) #define SKIP_IC3(x) (SKIP_IC2(x) || \ diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index c6db735b..f606f076 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -866,7 +866,7 @@ tryAgain: } /*-----------------------------------------------------------------*/ -/* getRegPtrNoSpil - get it cannot split */ +/* getRegPtrNoSpil - get it cannot be spilt */ /*-----------------------------------------------------------------*/ static regs *getRegPtrNoSpil() { @@ -887,7 +887,7 @@ static regs *getRegPtrNoSpil() } /*-----------------------------------------------------------------*/ -/* getRegGprNoSpil - get it cannot split */ +/* getRegGprNoSpil - get it cannot be spilt */ /*-----------------------------------------------------------------*/ static regs *getRegGprNoSpil() { @@ -1054,8 +1054,8 @@ reassignLR (operand * op) static int willCauseSpill (int nr, int rt) { - /* first check if there are any avlb registers - of te type required */ + /* first check if there are any available registers + of the type required */ if (rt == REG_PTR) { /* special case for pointer type @@ -1066,6 +1066,11 @@ willCauseSpill (int nr, int rt) if (nFreeRegs (REG_GPR) >= nr) return 0; } + else if (rt == REG_BIT) + { + if (nFreeRegs (rt) >= nr) + return 0; + } else { if (mcs51_ptrRegReq) @@ -1217,7 +1222,7 @@ serialRegAssign (eBBlock ** ebbs, int count) int j; int ptrRegSet = 0; - /* Make sure any spill location is definately allocated */ + /* Make sure any spill location is definitely allocated */ if (sym->isspilt && !sym->remat && sym->usl.spillLoc && !sym->usl.spillLoc->allocreq) { @@ -1457,7 +1462,7 @@ static void fillGaps() } } - D(printf("Atemping fillGaps on %s: [",sym->name)); + D(printf("Attempting fillGaps on %s: [",sym->name)); /* THERE IS HOPE !!!! */ for (i=0; i < sym->nRegs ; i++ ) { if (sym->regType == REG_PTR) @@ -1825,13 +1830,12 @@ regTypeNum (eBBlock *ebbs) } /* determine the type of register required */ - if (sym->nRegs == 1 && - IS_PTR (sym->type) && - sym->uptr) + if (sym->nRegs == 1 && IS_PTR (sym->type) && sym->uptr) sym->regType = REG_PTR; + else if (IS_BIT(sym->type)) + sym->regType = REG_BIT; else sym->regType = REG_GPR; - } else /* for the first run we don't provide */ diff --git a/src/mcs51/ralloc.h b/src/mcs51/ralloc.h index 978ccfc5..cd92de4f 100644 --- a/src/mcs51/ralloc.h +++ b/src/mcs51/ralloc.h @@ -8,19 +8,19 @@ under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! + what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ #include "SDCCicode.h" #include "SDCCBBlock.h" @@ -29,10 +29,9 @@ enum { - R2_IDX = 0, R3_IDX, R4_IDX, - R5_IDX, R6_IDX, R7_IDX, - R0_IDX, R1_IDX, X8_IDX, - X9_IDX, X10_IDX, X11_IDX, + R2_IDX = 0, R3_IDX, R4_IDX, R5_IDX, + R6_IDX, R7_IDX, R0_IDX, R1_IDX, + X8_IDX, X9_IDX, X10_IDX, X11_IDX, X12_IDX, CND_IDX, DPL_IDX, DPH_IDX, B_IDX, A_IDX, END_IDX @@ -42,18 +41,19 @@ enum #define REG_PTR 0x01 #define REG_GPR 0x02 #define REG_CND 0x04 +#define REG_BIT 0x08 /* definition for the registers */ typedef struct regs { - short type; /* can have value - REG_GPR, REG_PTR or REG_CND */ - short rIdx; /* index into register table */ + short type; /* can have value + REG_GPR, REG_PTR or REG_CND */ + short rIdx; /* index into register table */ short otype; - char *name; /* name */ - char *dname; /* name when direct access needed */ - char *base; /* base address */ - short offset; /* offset from the base */ - unsigned isFree:1; /* is currently unassigned */ + char *name; /* name */ + char *dname; /* name when direct access needed */ + char *base; /* base address */ + short offset; /* offset from the base */ + unsigned isFree:1; /* is currently unassigned */ } regs; extern regs regs8051[]; diff --git a/support/regression/tests/critical.c b/support/regression/tests/critical.c index 918cbdb4..2d66520e 100644 --- a/support/regression/tests/critical.c +++ b/support/regression/tests/critical.c @@ -17,6 +17,7 @@ typedef union //must be at least 2 bytes big and volatile volatile big global_var = { 0 }; +int y; unsigned int get_global (void) critical { @@ -52,6 +53,10 @@ testCritical(void) } //check the interrupt has run at all ASSERT(x.a != 0); + + critical y = 0; + //check the interrupts are still enabled + ASSERT(EA); #else ASSERT(1); #endif -- 2.30.2