From: tecodev Date: Mon, 19 May 2008 08:11:40 +0000 (+0000) Subject: * src/regression/empty.c: suppress warning X-Git-Url: https://git.gag.com/?p=fw%2Fsdcc;a=commitdiff_plain;h=c21e1e2719c65dd3811b6a50b03229176c251a60 * src/regression/empty.c: suppress warning * src/regression/pointer1.c: enabled index_by_pointer() * src/regression/inline.c: now works for pic16 as well * src/pic16/device.c: include dbuf declarations * src/pic16/device.h: removed obsolete prototypes * src/pic16/gen.c, src/pic16/gen.h: moved generic pointer tags * src/pic16/glue.c: made purely local functions static, (pic16_printGPointerType, pic16_printIvalCharPtr, pic16_printIvalFuncPtr, pic16_printIvalPtr): fixed initialized generic pointers' tags (#1961866) * src/pic16/pcode.c (assignValnums): optimize literal assignments git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5161 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ad4f7521..43e1fdde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2008-05-19 Raphael Neider + + * src/regression/empty.c: suppress warning + * src/regression/pointer1.c: enabled index_by_pointer() + * src/regression/inline.c: now works for pic16 as well + + * src/pic16/device.c: include dbuf declarations + * src/pic16/device.h: removed obsolete prototypes + + * src/pic16/gen.c, src/pic16/gen.h: moved generic pointer tags + * src/pic16/glue.c: made purely local functions static, + (pic16_printGPointerType, pic16_printIvalCharPtr, + pic16_printIvalFuncPtr, pic16_printIvalPtr): fixed initialized + generic pointers' tags (#1961866) + + * src/pic16/pcode.c (assignValnums): optimize literal assignments + 2008-05-19 Borut Razem * support/scripts/sdcc.nsi: remove uninstall.exe after uninstallation, diff --git a/src/pic16/device.c b/src/pic16/device.c index c22d8e78..e8ce0575 100644 --- a/src/pic16/device.c +++ b/src/pic16/device.c @@ -33,6 +33,7 @@ #include "common.h" // Include everything in the SDCC src directory #include "newalloc.h" +#include "dbuf_string.h" #include "main.h" diff --git a/src/pic16/device.h b/src/pic16/device.h index 5d7e87c5..0bda0f11 100644 --- a/src/pic16/device.h +++ b/src/pic16/device.h @@ -128,9 +128,6 @@ void pic16_assignConfigWordValue(int address, unsigned int value); void pic16_assignIdByteValue(int address, char value); int pic16_isREGinBank(regs *reg, int bank); int pic16_REGallBanks(regs *reg); -int PIC16_IS_CONFIG_ADDRESS(int address); -int PIC16_IS_IDLOC_ADDRESS(int address); -int PIC16_IS_HWREG_ADDRESS(int address); int checkAddReg(set **set, regs *reg); int checkAddSym(set **set, symbol *reg); diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 3858e448..1176cb87 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -56,12 +56,6 @@ #define PIC_IS_TAGGED(x) (IS_GENPTR(x) || IS_CODEPTR(x)) #define IS_DIRECT(op) ((AOP_TYPE(op) == AOP_PCODE) && (AOP(op)->aopu.pcop->type == PO_DIR)) -/* If you change these, you also have to update the library files - * device/lib/pic16/libsdcc/gptr{get,put}{1,2,3,4}.c */ -#define GPTR_TAG_DATA 0x80 -#define GPTR_TAG_EEPROM 0x40 -#define GPTR_TAG_CODE 0x00 /* must be 0 becaue of UPPER(sym)==0 */ - /* Wrapper to execute `code' at most once. */ #define PERFORM_ONCE(id,code) do { static char id = 0; if (!id) { id = 1; code } } while (0) diff --git a/src/pic16/gen.h b/src/pic16/gen.h index 9411174b..437fa83b 100644 --- a/src/pic16/gen.h +++ b/src/pic16/gen.h @@ -27,6 +27,12 @@ #ifndef SDCCGENPIC16_H #define SDCCGENPIC16_H +/* If you change these, you also have to update the library files + * device/lib/pic16/libsdcc/gptr{get,put}{1,2,3,4}.c */ +#define GPTR_TAG_DATA 0x80 +#define GPTR_TAG_EEPROM 0x40 +#define GPTR_TAG_CODE 0x00 /* must be 0 becaue of UPPER(sym)==0 */ + struct pCodeOp; enum diff --git a/src/pic16/glue.c b/src/pic16/glue.c index 76a883c6..22ef72f0 100644 --- a/src/pic16/glue.c +++ b/src/pic16/glue.c @@ -374,7 +374,8 @@ pic16emitRegularMap (memmap * map, bool addPublics, bool arFlag) /*-----------------------------------------------------------------*/ /* pic16_initPointer - pointer initialization code massaging */ /*-----------------------------------------------------------------*/ -value *pic16_initPointer (initList * ilist, sym_link *toType) +static value * +pic16_initPointer (initList * ilist, sym_link *toType) { value *val; ast *expr; @@ -516,7 +517,8 @@ value *pic16_initPointer (initList * ilist, sym_link *toType) /*-----------------------------------------------------------------*/ /* printPointerType - generates ival for pointer type */ /*-----------------------------------------------------------------*/ -void _pic16_printPointerType (const char *name, char ptype, void *p) +static void +_pic16_printPointerType (const char *name, char ptype, void *p) { char buf[256]; @@ -529,7 +531,8 @@ void _pic16_printPointerType (const char *name, char ptype, void *p) /*-----------------------------------------------------------------*/ /* printPointerType - generates ival for pointer type */ /*-----------------------------------------------------------------*/ -void pic16_printPointerType (const char *name, char ptype, void *p) +static void +pic16_printPointerType (const char *name, char ptype, void *p) { _pic16_printPointerType (name, ptype, p); //pic16_flushDB(ptype, p); /* breaks char* const arr[] = {&c, &c, &c}; */ @@ -538,7 +541,8 @@ void pic16_printPointerType (const char *name, char ptype, void *p) /*-----------------------------------------------------------------*/ /* printGPointerType - generates ival for generic pointer type */ /*-----------------------------------------------------------------*/ -void pic16_printGPointerType (const char *iname, const unsigned int itype, +static void +pic16_printGPointerType (const char *iname, const unsigned int itype, char ptype, void *p) { char buf[256]; @@ -547,15 +551,16 @@ void pic16_printGPointerType (const char *iname, const unsigned int itype, switch (itype) { - case CPOINTER: - case FUNCTION: + case CPOINTER: /* fall through */ + case FUNCTION: /* fall through */ + case GPOINTER: + /* GPTRs pointing to __data space should be reported as POINTERs */ sprintf (buf, "UPPER(%s)", iname); pic16_emitDS (buf, ptype, p); break; - case GPOINTER: - case POINTER: - sprintf (buf, "0x80"); + case POINTER: /* __data space */ + sprintf (buf, "0x%02x", GPTR_TAG_DATA); pic16_emitDS (buf, ptype, p); break; @@ -569,6 +574,10 @@ void pic16_printGPointerType (const char *iname, const unsigned int itype, assert (0); } + if (itype == GPOINTER) { + fprintf(stderr, "%s: initialized generic pointer with unknown storage class assumes object in code space\n", __func__); + } + //pic16_flushDB(ptype, p); /* might break char* const arr[] = {...}; */ } @@ -772,7 +781,8 @@ pic16_printIvalArray (symbol * sym, sym_link * type, initList * ilist, /*-----------------------------------------------------------------*/ /* pic16_printIvalBitFields - generate initializer for bitfields */ /*-----------------------------------------------------------------*/ -void pic16_printIvalBitFields(symbol **sym, initList **ilist, char ptype, void *p) +static void +pic16_printIvalBitFields(symbol **sym, initList **ilist, char ptype, void *p) { value *val ; symbol *lsym = *sym; @@ -837,7 +847,8 @@ void pic16_printIvalBitFields(symbol **sym, initList **ilist, char ptype, void * /*-----------------------------------------------------------------*/ /* printIvalStruct - generates initial value for structures */ /*-----------------------------------------------------------------*/ -void pic16_printIvalStruct (symbol * sym, sym_link * type, +static void +pic16_printIvalStruct (symbol * sym, sym_link * type, initList * ilist, char ptype, void *p) { symbol *sflds; @@ -876,7 +887,8 @@ void pic16_printIvalStruct (symbol * sym, sym_link * type, /*-----------------------------------------------------------------*/ /* printIvalUnion - generates initial value for unions */ /*-----------------------------------------------------------------*/ -void pic16_printIvalUnion (symbol * sym, sym_link * type, +static void +pic16_printIvalUnion (symbol * sym, sym_link * type, initList * ilist, char ptype, void *p) { //symbol *sflds; @@ -925,7 +937,8 @@ pic16_isUnion( symbol *sym, sym_link *type ) /*--------------------------------------------------------------------------*/ /* pic16_printIvalCharPtr - generates initial values for character pointers */ /*--------------------------------------------------------------------------*/ -int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char ptype, void *p) +static int +pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char ptype, void *p) { int size = 0; @@ -956,14 +969,10 @@ int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char pty else if (size == 3) { int type; - if (IS_PTR (val->type)) { - type = DCL_TYPE (val->type); - } else { - type = PTR_TYPE (SPEC_OCLS (val->etype)); - } + type = PTR_TYPE (SPEC_OCLS (val->etype)); if (val->sym && val->sym->isstrlit) { // this is a literal string - type=CPOINTER; + type = CPOINTER; } pic16_printGPointerType(val->name, type, ptype, p); } @@ -1008,7 +1017,8 @@ int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char pty /*-----------------------------------------------------------------------*/ /* pic16_printIvalFuncPtr - generate initial value for function pointers */ /*-----------------------------------------------------------------------*/ -void pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void *p) +static void +pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void *p) { value *val; int dLvl = 0; @@ -1029,7 +1039,7 @@ void pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void } if (IS_LITERAL(val->etype)) { - if (compareType(type, val->etype) == 0) { + if (0 && compareType(type, val->etype) == 0) { werrorfl (ilist->filename, ilist->lineno, E_INCOMPAT_TYPES); printFromToType (val->type, type); } @@ -1046,9 +1056,9 @@ void pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void /* now generate the name */ if (!val->sym) { - pic16_printGPointerType (val->name, DCL_TYPE(val->type), ptype, p); + pic16_printGPointerType (val->name, CPOINTER /*DCL_TYPE(val->type)*/, ptype, p); } else { - pic16_printGPointerType (val->sym->rname, DCL_TYPE(val->type), ptype, p); + pic16_printGPointerType (val->sym->rname, CPOINTER /*DCL_TYPE(val->type)*/, ptype, p); if(IS_FUNC(val->sym->type) && !val->sym->used && !IS_STATIC(val->sym->etype)) { @@ -1070,7 +1080,8 @@ void pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void /*-----------------------------------------------------------------*/ /* pic16_printIvalPtr - generates initial value for pointers */ /*-----------------------------------------------------------------*/ -void pic16_printIvalPtr (symbol * sym, sym_link * type, initList * ilist, char ptype, void *p) +static void +pic16_printIvalPtr (symbol * sym, sym_link * type, initList * ilist, char ptype, void *p) { value *val; int size; @@ -1142,8 +1153,9 @@ void pic16_printIvalPtr (symbol * sym, sym_link * type, initList * ilist, char p } else if (size == 3) { - pic16_printGPointerType (val->name, (IS_PTR(type)?DCL_TYPE(type):PTR_TYPE(SPEC_OCLS(sym->etype))), - ptype, p); + int itype = 0; + itype = PTR_TYPE (SPEC_OCLS (val->etype)); + pic16_printGPointerType (val->name, itype, ptype, p); } else assert(0); return; @@ -1240,23 +1252,18 @@ void pic16_printIval (symbol * sym, sym_link * type, initList * ilist, char ptyp } } -int PIC16_IS_CONFIG_ADDRESS(int address) +static int +PIC16_IS_CONFIG_ADDRESS(int address) { return ((address >= pic16->cwInfo.confAddrStart && address <= pic16->cwInfo.confAddrEnd)); } -int PIC16_IS_IDLOC_ADDRESS(int address) +static int +PIC16_IS_IDLOC_ADDRESS(int address) { return ((address >= pic16->idInfo.idAddrStart && address <= pic16->idInfo.idAddrEnd)); } -/* wrapper function for the above */ -int PIC16_IS_HWREG_ADDRESS(int address) -{ - return (PIC16_IS_CONFIG_ADDRESS(address) || PIC16_IS_IDLOC_ADDRESS(address)); -} - - /*-----------------------------------------------------------------*/ /* emitStaticSeg - emitcode for the static segment */ /*-----------------------------------------------------------------*/ @@ -1687,7 +1694,8 @@ pic16emitOverlay (struct dbuf_s *aBuf) } } -void emitStatistics(FILE *asmFile) +static void +emitStatistics(FILE *asmFile) { unsigned long isize, udsize, ramsize; statistics.isize = pic16_countInstructions(); diff --git a/src/pic16/pcode.c b/src/pic16/pcode.c index f473a880..b0d1fcec 100644 --- a/src/pic16/pcode.c +++ b/src/pic16/pcode.c @@ -11695,6 +11695,40 @@ static void assignValnums (pCode *pc) { if (val && oldval && (val->in_val != 0) && (val->in_val == oldval->in_val)) { //fprintf (stderr, "MOVFW: W already set up correctly (%x) at %p\n", oldval->in_val, pc); if (!pic16_isAlive (SPO_STATUS, pc)) pic16_safepCodeRemove (pc, "=DF= redundant MOVFW removed"); + } else { + defmap_t *pred, *predpred; + /* Optimize MOVLW immd; MOVWF reg1; [...]; MOVFW reg1 + * into MOVLW immd; MOVWF reg1; [...]; MOVLW immd + * This might allow removal of the first two assignments. */ + pred = defmapFindDef (list, sym1, pc); + predpred = pred ? defmapFindDef (list, SPO_WREG, pred->pc) : NULL; + if (pred && predpred && (PCI(pred->pc)->op == POC_MOVWF) && (PCI(predpred->pc)->op == POC_MOVLW) + && !pic16_isAlive (SPO_STATUS, pc)) + { + newpc = pic16_newpCode (POC_MOVLW, pic16_pCodeOpCopy (PCI(predpred->pc)->pcop)); + + if (pic16_debug_verbose || pic16_pcode_verbose) { + pic16_InsertCommentAfter (pc->prev, "=DF= MOVFW: replaced last of MOVLW;MOVWF;MOVFW by MOVLW"); + } // if + pic16_pCodeReplace (pc, newpc); + defmapReplaceSymRef (pc, sym1, 0, 1); + pic16_fixDefmap (pc, newpc); + pc = newpc; + + /* This breaks the defmap chain's references to pCodes... fix it! */ + if (!val->prev) PCI(pc)->pcflow->defmap = val->next; + if (!val->acc.access.isWrite) { + deleteDefmap (val); // delete reference to reg1 as in value + val = NULL; + } else { + val->acc.access.isRead = 0; // delete reference to reg1 as in value + } + oldval = PCI(pc)->pcflow->defmap; + while (oldval) { + if (oldval->pc == pc) oldval->pc = newpc; + oldval = oldval->next; + } // while + } // if } if (val) defmapUpdate (list, SPO_WREG, pc, val->in_val); } diff --git a/src/regression/empty.c b/src/regression/empty.c index 60522559..fb4fd262 100644 --- a/src/regression/empty.c +++ b/src/regression/empty.c @@ -6,6 +6,7 @@ void foo(void) { } void bar(int arg0) { + (void)arg0; } void diff --git a/src/regression/inline.c b/src/regression/inline.c index bb86d661..3198d99f 100644 --- a/src/regression/inline.c +++ b/src/regression/inline.c @@ -35,12 +35,21 @@ void main(void) { TRISA = 0x0f; +#if defined(__pic14) _asm BSF STATUS,RP0 MOVF TRISA,W BCF STATUS,RP0 MOVWF _test_tris _endasm; +#else // !defined(__pic14) + _asm + BANKSEL _TRISA + MOVF _TRISA,W + BANKSEL _test_tris + MOVWF _test_tris + _endasm; +#endif // !defined(__pic14) if(test_tris != 0x0f) failures++; diff --git a/src/regression/pointer1.c b/src/regression/pointer1.c index a0236b1a..23075b42 100644 --- a/src/regression/pointer1.c +++ b/src/regression/pointer1.c @@ -11,7 +11,7 @@ unsigned char achar0 = 0; unsigned char achar1 = 0; unsigned char *acharP = 0; -char buff[10]; +unsigned char buff[10]; void done() @@ -92,10 +92,8 @@ void check_array(char base_value) void index_by_pointer(unsigned char *index, unsigned char expected_value) { -/* if(buff[*index] != expected_value) failures++; -*/ }