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
extern void pic16_RegsUnMapLiveRanges(void);
extern void pic16_BuildFlowTree(pBlock *pb);
extern void pic16_pCodeRegOptimizeRegUsage(int level);
-extern int pic16_picIsInitialized(void);
extern void SAFE_snprintf(char **str, size_t *size, const char *format, ...);
extern int mnem2key(unsigned char const *mnem);
#endif
extern set *externs;
-extern void pic16_initStack(int base_address, int size);
extern regs *pic16_allocProcessorRegister(int rIdx, char * name, short po_type, int alias);
extern regs *pic16_allocInternalRegister(int rIdx, char * name, short po_type, int alias);
-extern void pic16_init_pic(char *);
void pic16_pCodeInitRegisters(void)
{
initialized = 1;
-// pic16_initStack(0xfff, 8);
- pic16_init_pic(port->processor);
-
pic16_pc_status.r = pic16_allocProcessorRegister(IDX_STATUS,"STATUS", PO_STATUS, 0x80);
pic16_pc_pcl.r = pic16_allocProcessorRegister(IDX_PCL,"PCL", PO_PCL, 0x80);
pic16_pc_pclath.r = pic16_allocProcessorRegister(IDX_PCLATH,"PCLATH", PO_PCLATH, 0x80);
/* 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;
if(!r) {
fprintf(stderr, "%s:%d Could not find a free GPR register\n",
__FUNCTION__, __LINE__);
- exit(-1);
+ exit(EXIT_FAILURE);
}
}
if(isPCI(pc) && (PCI(pc)->pci_magic != PCI_MAGIC)) {
fprintf(stderr, "%s:%d: pCodeInstruction initialization error in instruction %s, magic is %x (defaut: %x)\n",
__FILE__, __LINE__, PCI(pc)->mnemonic, PCI(pc)->pci_magic, PCI_MAGIC);
-// exit(-1);
+// exit(EXIT_FAILURE);
}
#endif
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] = {
{ ", 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]);
}
}
//
{
pCode *pc; pCodeLabel *pcl;
- if(!pb)
+ if(!pb || !pb->pcHead)
return;
for(pc = pb->pcHead; (pc=pic16_findNextInstruction(pc->next)) != NULL; ) {
pseudoBankNr getBankFromBanksel (pCode *pc)
{
char *sym;
- int data = (int)NULL;
+ int data = 0;
if (!pc) return INVALID_BANK;
defmap_t *map;
pCodeFlow *pcfl;
+ assert(pb);
+
pcfl = PCI(pic16_findNextInstruction (pb->pcHead))->pcflow;
/* find initial value (assigning pc == NULL) */
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)) {
static void pic16_destructDF (pBlock *pb) {
pCode *pc, *next;
+ if (!pb) return;
+
/* remove old defmaps */
pc = pic16_findNextInstruction (pb->pcHead);
while (pc) {
static int pic16_pBlockHasAsmdirs (pBlock *pb) {
pCode *pc;
+ if (!pb) return 0;
+
pc = pic16_findNextInstruction (pb->pcHead);
while (pc) {
if (isPCAD(pc)) return 1;
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);
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__);
char buf[BUF_SIZE];
pCode *pc;
+ if (!pb) return;
+
/* get function name */
pc = pb->pcHead;
while (pc && !isPCF(pc)) pc = pc->next;