pedantic>1: "char c=200" is not allowed (evaluates to -56)
*/
-void checkConstantRange(sym_link *ltype, value *val, char *msg, int pedantic) {
+void checkConstantRange(sym_link *ltype, value *val, char *msg,
+ int pedantic) {
double max;
- char message[132]="";
int warnings=0;
int negative=0;
long v;
warnings++;
}
+#if 0 // temporary disabled, leaving the warning as a reminder
if (warnings) {
sprintf (message, "for %s %s in %s",
SPEC_USIGN(ltype) ? "unsigned" : "signed",
if (pedantic>1)
fatalError++;
}
+#endif
}
/*-----------------------------------------------------------------*/
case SYMBOL:
#define REGA 1
#ifdef REGA
- fprintf (file, "%s [k%d lr%d:%d so:%d]{ ia%d re%d rm%d nos%d}", /*{ar%d rm%d ru%d p%d a%d u%d i%d au%d k%d ks%d}" , */
+ fprintf (file, "%s [k%d lr%d:%d so:%d]{ ia%d re%d rm%d nos%d ru%d dp%d}", /*{ar%d rm%d ru%d p%d a%d u%d i%d au%d k%d ks%d}" , */
(OP_SYMBOL (op)->rname[0] ? OP_SYMBOL (op)->rname : OP_SYMBOL (op)->name),
op->key,
OP_LIVEFROM (op), OP_LIVETO (op),
OP_SYMBOL (op)->stack,
- op->isaddr, OP_SYMBOL (op)->isreqv, OP_SYMBOL (op)->remat,OP_SYMBOL(op)->noSpilLoc
+ op->isaddr, OP_SYMBOL (op)->isreqv,
+ OP_SYMBOL (op)->remat,OP_SYMBOL(op)->noSpilLoc,
+ OP_SYMBOL(op)->ruonly,OP_SYMBOL(op)->dptr
);
{
fprintf (file, "{");
if (!IC_RESULT (ic) && !IC_LEFT (ic))
fprintf (of, s);
+ if (ic->op == SEND || ic->op == RECEIVE) {
+ fprintf(of,"{argreg = %d}",ic->argreg);
+ }
fprintf (of, "\n");
}
return 0;
}
+
/*-----------------------------------------------------------------*/
/* isOperandInFarSpace - will return true if operand is in farSpace */
/*-----------------------------------------------------------------*/
return (IN_FARSPACE (SPEC_OCLS (etype)) ? TRUE : FALSE);
}
+/*------------------------------------------------------------------*/
+/* isOperandInDirSpace - will return true if operand is in dirSpace */
+/*------------------------------------------------------------------*/
+bool
+isOperandInDirSpace (operand * op)
+{
+ sym_link *etype;
+
+ if (!op)
+ return FALSE;
+
+ if (!IS_SYMOP (op))
+ return FALSE;
+
+ if (!IS_TRUE_SYMOP (op))
+ {
+ if (SPIL_LOC (op))
+ etype = SPIL_LOC (op)->etype;
+ else
+ return FALSE;
+ }
+ else
+ {
+ etype = getSpec (operandType (op));
+ }
+ return (IN_DIRSPACE (SPEC_OCLS (etype)) ? TRUE : FALSE);
+}
+
+/*--------------------------------------------------------------------*/
+/* isOperandInCodeSpace - will return true if operand is in codeSpace */
+/*--------------------------------------------------------------------*/
+bool
+isOperandInCodeSpace (operand * op)
+{
+ sym_link *etype;
+
+ if (!op)
+ return FALSE;
+
+ if (!IS_SYMOP (op))
+ return FALSE;
+
+ etype = getSpec (operandType (op));
+
+ if (!IS_TRUE_SYMOP (op))
+ {
+ if (SPIL_LOC (op))
+ etype = SPIL_LOC (op)->etype;
+ else
+ return FALSE;
+ }
+ else
+ {
+ etype = getSpec (operandType (op));
+ }
+ return (IN_CODESPACE (SPEC_OCLS (etype)) ? TRUE : FALSE);
+}
+
/*-----------------------------------------------------------------*/
/* isOperandOnStack - will return true if operand is on stack */
/*-----------------------------------------------------------------*/
return FALSE;
etype = getSpec (operandType (op));
+ if (IN_STACK (etype) ||
+ OP_SYMBOL(op)->onStack ||
+ (SPIL_LOC(op) && SPIL_LOC(op)->onStack))
+ return TRUE;
- return ((IN_STACK (etype)) ? TRUE : FALSE);
+ return FALSE;
}
/*-----------------------------------------------------------------*/
return floatFromVal (op->operand.valOperand);
}
+/*-----------------------------------------------------------------*/
+/* getBuiltInParms - returns parameters to a builtin functions */
+/*-----------------------------------------------------------------*/
+iCode *getBuiltinParms (iCode *ic, int *pcount, operand **parms)
+{
+ sym_link *ftype;
+
+ *pcount = 0;
+ /* builtin functions uses only SEND for parameters */
+ while (ic->op != CALL) {
+ assert(ic->op == SEND && ic->builtinSEND);
+ ic->generated = 1; /* mark the icode as generated */
+ parms[*pcount] = IC_LEFT(ic);
+ ic = ic->next;
+ (*pcount)++;
+ }
+
+ ic->generated = 1;
+ /* make sure this is a builtin function call */
+ assert(IS_SYMOP(IC_LEFT(ic)));
+ ftype = operandType(IC_LEFT(ic));
+ assert(IFFUNC_ISBUILTIN(ftype));
+ return ic;
+}
+
/*-----------------------------------------------------------------*/
/* operandOperation - perforoms operations on operands */
/*-----------------------------------------------------------------*/
if (IS_PTR(type)) { // to a pointer
if (!IS_PTR(optype) && !IS_FUNC(optype) && !IS_AGGREGATE(optype)) { // from a non pointer
if (IS_INTEGRAL(optype)) {
- // maybe this is NULL, than it's ok.
+ // maybe this is NULL, than it's ok.
if (!(IS_LITERAL(optype) && (SPEC_CVAL(optype).v_ulong ==0))) {
if (!TARGET_IS_Z80 && !TARGET_IS_GBZ80 && IS_GENPTR(type)) {
// no way to set the storage
/* preserve the storage class & output class */
/* of the original variable */
restype = getSpec (operandType (IC_RESULT (ic)));
- SPEC_SCLS (restype) = SPEC_SCLS (opetype);
+ if (!IS_LITERAL(opetype))
+ SPEC_SCLS (restype) = SPEC_SCLS (opetype);
SPEC_OCLS (restype) = SPEC_OCLS (opetype);
ADDTOCHAIN (ic);
/* geniCodeAdd - generates iCode for addition */
/*-----------------------------------------------------------------*/
operand *
-geniCodeAdd (operand * left, operand * right,int lvl)
+geniCodeAdd (operand * left, operand * right, int lvl)
{
iCode *ic;
sym_link *resType;
if (IS_LITERAL (letype) && left->isLiteral && !floatFromVal (valFromType (letype)))
return right;
- /* if left is an array or pointer then size */
+ /* if left is a pointer then size */
if (IS_PTR (ltype))
{
isarray = left->isaddr;
resType = copyLinkChain (ltype);
}
else
- { /* make them the same size */
+ { // make them the same size
resType = usualBinaryConversions (&left, &right);
}
{
left = geniCodeRValue (left, FALSE);
}
- return geniCodeDerefPtr (geniCodeAdd (left, right,lvl),lvl);
+ return geniCodeDerefPtr (geniCodeAdd (left, right, lvl), lvl);
}
right = geniCodeMultiply (right,
{
iCode *ic;
- // bitwise operations must be done unsigned
- // WHY ? causes very bad things to happen with CSE
- // SPEC_USIGN(resType)=1;
-
left = geniCodeCast (resType, left, TRUE);
right = geniCodeCast (resType, right, TRUE);
true = ast2iCode (tree->right->left,lvl+1);
/* move the value to a new Operand */
- result = newiTempOperand (operandType (true), 0);
+ result = newiTempOperand (tree->right->ftype, 0);
geniCodeAssign (result, geniCodeRValue (true, FALSE), 0);
/* generate an unconditional goto */
IS_ADDRESS_OF_OP (parms->right))
parms->right->left->lvalue = 1;
- parms->opval.oprnd =
+ parms->opval.oprnd =
geniCodeRValue (ast2iCode (parms,lvl+1), FALSE);
-
+
parms->type = EX_OPERAND;
+ AST_ARGREG(parms) = SPEC_ARGREG(parms->etype);
}
/*-----------------------------------------------------------------*/
}
/* if register parm then make it a send */
- if (IS_REGPARM (parms->etype) && !IFFUNC_HASVARARGS(func->type))
+ if ((IS_REGPARM (parms->etype) && !IFFUNC_HASVARARGS(func->type)) ||
+ IFFUNC_ISBUILTIN(func->type))
{
ic = newiCode (SEND, pval, NULL);
+ ic->argreg = SPEC_ARGREG(parms->etype);
+ ic->builtinSEND = FUNC_ISBUILTIN(func->type);
ADDTOCHAIN (ic);
}
else
/* assign */
operand *top = operandFromSymbol (argVals->sym);
+ /* clear useDef and other bitVectors */
+ OP_USES (top) = OP_DEFS (top) = OP_SYMBOL(top)->clashes = NULL;
geniCodeAssign (top, pval, 1);
}
else
geniCodeParms (parms, NULL, &stack, getSpec (operandType (left)), OP_SYMBOL (left),lvl);
/* now call : if symbol then pcall */
- if (IS_OP_POINTER (left) || IS_ITEMP(left))
+ if (IS_OP_POINTER (left) || IS_ITEMP(left)) {
ic = newiCode (PCALL, left, NULL);
- else
+ } else {
ic = newiCode (CALL, left, NULL);
+ }
type = copyLinkChain (operandType (left)->next);
etype = getSpec (type);
/* for all arguments that are passed in registers */
while (args)
{
-
+ int first = 1;
if (IS_REGPARM (args->etype))
{
operand *opr = operandFromValue (args);
}
}
- ic = newiCode (RECEIVE, NULL, NULL);
- currFunc->recvSize = getSize (sym->etype);
+ ic = newiCode (RECEIVE, NULL, NULL);
+ ic->argreg = SPEC_ARGREG(args->etype);
+ if (first) {
+ currFunc->recvSize = getSize (sym->type);
+ first = 0;
+ }
IC_RESULT (ic) = opr;
ADDTOCHAIN (ic);
}
/* create a proc icode */
ic = newiCode (FUNCTION, func, NULL);
- ic->lineno = OP_SYMBOL (func)->lineDef;
+ lineno=ic->lineno = OP_SYMBOL (func)->lineDef;
ADDTOCHAIN (ic);
operand *right = NULL;
if (!tree)
return NULL;
+
/* set the global variables for filename & line number */
if (tree->filename)
filename = tree->filename;