int pic14_nRegs = 128; // = sizeof (regspic14) / sizeof (regs);
int Gstack_base_addr=0; /* The starting address of registers that
-* are used to pass and return parameters */
+ * are used to pass and return parameters */
+int Gstack_size = 0;
fprintf (debugF, "%s", buffer);
/*
- while (isspace(*bufferP)) bufferP++;
+ while (isspace((unsigned char)*bufferP)) bufferP++;
if (bufferP && *bufferP)
lineCurr = (lineCurr ?
int i;
Gstack_base_addr = base_address;
- //fprintf(stderr,"initStack");
+ Gstack_size = size;
+ //fprintf(stderr,"initStack [base:0x%02x, size:%d]\n", base_address, size);
for(i = 0; i<size; i++) {
- regs *r = newReg(REG_STK, PO_GPR_TEMP,base_address,NULL,1,0);
+ char buffer[16];
+ SNPRINTF(&buffer[0], 16, "STK%02d", i);
+ regs *r = newReg(REG_STK, PO_GPR_TEMP,base_address,buffer,1,0);
r->address = base_address; // Pseudo stack needs a fixed location that can be known by all modules
r->isFixed = 1;
- r->name[0] = 's';
+ r->isPublic = 1;
+ //r->name[0] = 's';
r->alias = 0x180; // Using shared memory for pseudo stack
addSet(&dynStackRegs,r);
base_address--;
/* if it does not end here */
if (sym->liveTo > ic->seq)
continue;
-
- /* HACK: result and addr must be disjoint for POINTER_GET */
- if (sym->liveTo == ic->seq && POINTER_GET(ic))
+
+ /* Prevent the result from being assigned the same registers as (one)
+ * operand as many genXXX-functions fail otherwise.
+ * POINTER_GET(ic) || ic->op == LEFT_OP || ic->op == RIGHT_OP || ic->op == NOT
+ * are known to fail. */
+ if (sym->liveTo == ic->seq && IC_RESULT(ic))
{
- //piCode (ic, stderr); fprintf (stderr, " -- registers NOT deallocated\n");
- continue;
+ switch (ic->op)
+ {
+ case '=': /* assignment */
+ case BITWISEAND: /* bitwise AND */
+ case '|': /* bitwise OR */
+ case '^': /* bitwise XOR */
+ case '~': /* bitwise negate */
+ case RLC: /* rotate through carry */
+ case RRC:
+ case UNARYMINUS:
+ case '+': /* addition */
+ case '-': /* subtraction */
+ /* go ahead, these are safe to use with
+ * non-disjoint register sets */
+ break;
+
+ default:
+ /* do not release operand registers */
+ //fprintf (stderr, "%s:%u: operand not freed: ", __FILE__, __LINE__); piCode (ic, stderr); fprintf (stderr, "\n");
+ continue;
+ } // switch
}
-
+
/* if it was spilt on stack then we can
mark the stack spil location as free */
if (sym->isspilt)