%type <sym> struct_declarator_list struct_declaration struct_declaration_list
%type <sym> declaration init_declarator_list init_declarator
%type <sym> declaration_list identifier_list parameter_identifier_list
-%type <sym> declarator2_using_reentrant while do for
+%type <sym> declarator2_function_attributes while do for
%type <lnk> pointer type_specifier_list type_specifier type_name
%type <lnk> storage_class_specifier struct_or_union_specifier
%type <lnk> declaration_specifiers sfr_reg_bit type_specifier2
-%type <lnk> using_reentrant using_reentrant_interrupt enum_specifier
+%type <lnk> function_attribute function_attributes enum_specifier
%type <lnk> abstract_declarator abstract_declarator2 unqualified_pointer
%type <val> parameter_type_list parameter_list parameter_declaration opt_assign_expr
%type <sdef> stag opt_stag
;
external_definition
- : function_definition { blockNo=0;}
+ : function_definition {
+ blockNo=0;
+ }
| declaration {
if ($1 && $1->type
&& IS_FUNC($1->type))
}
;
-using_reentrant
- : using_reentrant_interrupt
- | using_reentrant_interrupt using_reentrant { $$ = mergeSpec($1,$2,"using_reentrant"); }
+function_attribute
+ : function_attributes
+ | function_attributes function_attribute { $$ = mergeSpec($1,$2,"function_attribute"); }
;
-using_reentrant_interrupt
+function_attributes
: USING CONSTANT {
$$ = newLink() ;
$$->class = SPECIFIER ;
- SPEC_BNKF($$) = 1;
- SPEC_BANK($$) = (int) floatFromVal($2);
+ FUNC_REGBANK($$) = (int) floatFromVal($2);
+ //FUNC_RBANK($$) = 1;
}
| REENTRANT { $$ = newLink ();
$$->class = SPECIFIER ;
- SPEC_RENT($$) = 1;
+ FUNC_ISREENT($$)=1;
}
| CRITICAL { $$ = newLink ();
$$->class = SPECIFIER ;
- SPEC_CRTCL($$) = 1;
+ FUNC_ISCRITICAL($$) = 1;
}
| NAKED { $$ = newLink ();
$$->class = SPECIFIER ;
- SPEC_NAKED($$) = 1;
+ FUNC_ISNAKED($$)=1;
}
| NONBANKED {$$ = newLink ();
$$->class = SPECIFIER ;
- SPEC_NONBANKED($$) = 1;
- if (SPEC_BANKED($$)) {
+ FUNC_NONBANKED($$) = 1;
+ if (FUNC_BANKED($$)) {
werror(W_BANKED_WITH_NONBANKED);
}
}
| BANKED {$$ = newLink ();
$$->class = SPECIFIER ;
- SPEC_BANKED($$) = 1;
- if (SPEC_NONBANKED($$)) {
+ FUNC_BANKED($$) = 1;
+ if (FUNC_NONBANKED($$)) {
werror(W_BANKED_WITH_NONBANKED);
}
if (SPEC_STAT($$)) {
{
$$ = newLink () ;
$$->class = SPECIFIER ;
- SPEC_INTN($$) = $1 ;
- SPEC_INTRTN($$) = 1;
+ FUNC_INTNO($$) = $1 ;
+ FUNC_ISISR($$) = 1;
}
;
;
declarator
- : declarator2_using_reentrant { $$ = $1; }
- | pointer declarator2_using_reentrant
+ : declarator2_function_attributes { $$ = $1; }
+ | pointer declarator2_function_attributes
{
addDecl ($2,0,reverseLink($1));
$$ = $2 ;
}
;
-declarator2_using_reentrant
+declarator2_function_attributes
: declarator2 { $$ = $1 ; }
- | declarator2 using_reentrant { addDecl ($1,0,$2); }
+ | declarator2 function_attribute {
+ // do the functionAttributes (not the args and hasVargs !!)
+ sym_link *funcType=$1->etype;
+ struct value *args=FUNC_ARGS(funcType);
+ unsigned hasVargs=FUNC_HASVARARGS(funcType);
+
+ memcpy (&funcType->funcAttrs, &$2->funcAttrs,
+ sizeof($2->funcAttrs));
+
+ FUNC_ARGS(funcType)=args;
+ FUNC_HASVARARGS(funcType)=hasVargs;
+
+ // just to be sure
+ memset (&$2->funcAttrs, 0,
+ sizeof($2->funcAttrs));
+
+ addDecl ($1,0,$2);
+ }
;
declarator2
addDecl ($1,FUNCTION,NULL) ;
- $1->hasVargs = IS_VARG($4);
- $1->args = reverseVal($4) ;
-
+ FUNC_HASVARARGS($1->type) = IS_VARG($4);
+ FUNC_ARGS($1->type) = reverseVal($4);
/* nest level was incremented to take care of the parms */
NestLevel-- ;
currBlockno--;
- // if this was a pointer to a function, remove the symbol args
- // (if any)
- if (IS_PTR($1->type) && IS_FUNC($1->etype)) {
+ // if this was a pointer (to a function)
+ if (IS_PTR($1->type)) {
+ // move the args and hasVargs to the function
+ FUNC_ARGS($1->etype)=FUNC_ARGS($1->type);
+ FUNC_HASVARARGS($1->etype)=FUNC_HASVARARGS($1->type);
+ memset (&$1->type->funcAttrs, 0,
+ sizeof($1->type->funcAttrs));
+ // remove the symbol args (if any)
cleanUpLevel(SymbolTab,NestLevel+1);
- /* fprintf (stderr, "Removed parm symbols of %s in line %d\n",
- $1->name, yylineno); */
}
$$ = $1;
{
ebb->hasFcall = 1;
if (currFunc)
- currFunc->hasFcall = 1;
+ FUNC_HASFCALL(currFunc->type) = 1;
}
/* if the next one is a label */
dest->lineno = src->lineno;
dest->level = src->level;
dest->funcName = src->funcName;
- dest->argSym = src->argSym;
/* if this is a leaf */
/* if value */
/* create the symbol */
sym = newSymbol (name, 0);
+ /* setup return value */
+ sym->type = newLink ();
+ DCL_TYPE (sym->type) = FUNCTION;
+ sym->type->next = copyLinkChain (type);
+ sym->etype = getSpec (sym->type);
+ FUNC_ISREENT(sym->type) = rent;
+
/* if arguments required */
if (nArgs)
{
-
value *args;
- args = sym->args = newValue ();
+ args = FUNC_ARGS(sym->type) = newValue ();
while (nArgs--)
{
}
}
- /* setup return value */
- sym->type = newLink ();
- DCL_TYPE (sym->type) = FUNCTION;
- sym->type->next = copyLinkChain (type);
- sym->etype = getSpec (sym->type);
- SPEC_RENT (sym->etype) = rent;
-
/* save it */
addSymChain (sym);
sym->cdef = 1;
/*-----------------------------------------------------------------*/
int
processParms (ast * func,
- value * defParm,
+ value *defParm,
ast * actParm,
int *parmNumber, // unused, although updated
bool rightmost) // double checked?
{
- sym_link *fetype = func->etype;
-
/* if none of them exist */
if (!defParm && !actParm)
return 0;
/* if the function is being called via a pointer & */
/* it has not been defined a reentrant then we cannot */
/* have parameters */
- if (func->type != EX_VALUE && !IS_RENT (fetype) && !options.stackAuto)
+ if (func->type != EX_VALUE && !IFFUNC_ISREENT (func->ftype) && !options.stackAuto)
{
werror (W_NONRENT_ARGS);
return 1;
/* if defined parameters ended but actual parameters */
/* exist and this is not defined as a variable arg */
- /* also check if statckAuto option is specified */ // jwk: WHY?
- if ((!defParm) && actParm && (!func->hasVargs)
- /* && !options.stackAuto && !IS_RENT (fetype) */)
+ if (!defParm && actParm && !IFFUNC_HASVARARGS(func->ftype))
{
werror (E_TOO_MANY_PARMS);
return 1;
}
/* If this is a varargs function... */
- if (!defParm && actParm && func->hasVargs)
+ if (!defParm && actParm && IFFUNC_HASVARARGS(func->ftype))
{
ast *newType = NULL;
sym_link *ftype;
if (IS_AGGREGATE (ftype))
{
+ // jwk: don't we need aggregateToPointer here?
newType = newAst_LINK (copyLinkChain (ftype));
DCL_TYPE (newType->opval.lnk) = GPOINTER;
}
/* if defined parameters ended but actual has not & */
/* stackAuto */
if (!defParm && actParm &&
- (options.stackAuto || IS_RENT (fetype)))
+ (options.stackAuto || IFFUNC_ISREENT (func->ftype)))
return 0;
resolveSymbols (actParm);
* Therefore, if there are more defined parameters, the caller didn't
* supply enough.
*/
- if (rightmost && defParm->next)
+ if (0 && rightmost && defParm->next)
{
werror (E_TOO_FEW_PARMS);
return 1;
actParm->ftype = defParm->type;
}
-/* actParm->argSym = resolveFromTable(defParm)->sym ; */
-
- actParm->argSym = defParm->sym;
/* make a copy and change the regparm type to the defined parm */
actParm->etype = getSpec (actParm->ftype = copyLinkChain (actParm->ftype));
SPEC_REGPARM (actParm->etype) = SPEC_REGPARM (defParm->etype);
/* otherwise just copy the type information */
COPYTYPE (TTYPE (tree), TETYPE (tree), tree->opval.val->type);
- if (funcInChain (tree->opval.val->type))
- {
- tree->hasVargs = tree->opval.val->sym->hasVargs;
- tree->args = copyValueChain (tree->opval.val->sym->args);
- }
return tree;
}
/* and mark it as referenced */
tree->opval.val->sym->isref = 1;
- /* if this is of type function or function pointer */
- if (funcInChain (tree->opval.val->type))
- {
- tree->hasVargs = tree->opval.val->sym->hasVargs;
- tree->args = copyValueChain (tree->opval.val->sym->args);
-
- }
}
}
}
}
TTYPE (tree) = structElemType (LTYPE (tree),
(tree->right->type == EX_VALUE ?
- tree->right->opval.val : NULL), &tree->args);
+ tree->right->opval.val : NULL));
TETYPE (tree) = getSpec (TTYPE (tree));
return tree;
TTYPE (tree) = structElemType (LTYPE (tree)->next,
(tree->right->type == EX_VALUE ?
- tree->right->opval.val : NULL), &tree->args);
+ tree->right->opval.val : NULL));
TETYPE (tree) = getSpec (TTYPE (tree));
return tree;
}
TTYPE (tree) = copyLinkChain ((IS_PTR (LTYPE (tree)) || IS_ARRAY (LTYPE (tree))) ?
LTYPE (tree)->next : NULL);
- TETYPE (tree) = getSpec (TTYPE (tree));
- tree->args = tree->left->args;
- tree->hasVargs = tree->left->hasVargs;
+ TETYPE (tree) = getSpec (TTYPE (tree));
SPEC_CONST (TETYPE (tree)) = DCL_PTR_CONST (LTYPE(tree));
return tree;
}
parmNumber = 1;
if (processParms (tree->left,
- tree->left->args,
+ FUNC_ARGS(tree->left->ftype),
tree->right, &parmNumber, TRUE))
goto errorTreeReturn;
- if (options.stackAuto || IS_RENT (LETYPE (tree)))
+ if (options.stackAuto || IFFUNC_ISREENT (LTYPE (tree)))
{
- tree->left->args = reverseVal (tree->left->args);
+ //IFFUNC_ARGS(tree->left->ftype) =
+ //reverseVal (IFFUNC_ARGS(tree->left->ftype));
reverseParms (tree->right);
}
- tree->args = tree->left->args;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree)->next);
return tree;
iCode *piCode = NULL;
/* if check function return 0 then some problem */
- if (checkFunction (name) == 0)
+ if (checkFunction (name, NULL) == 0)
return NULL;
/* create a dummy block if none exists */
/* set the stack pointer */
/* PENDING: check this for the mcs51 */
stackPtr = -port->stack.direction * port->stack.call_overhead;
- if (IS_ISR (name->etype))
+ if (IFFUNC_ISISR (name->type))
stackPtr -= port->stack.direction * port->stack.isr_overhead;
- if (IS_RENT (name->etype) || options.stackAuto)
+ if (IFFUNC_ISREENT (name->type) || options.stackAuto)
stackPtr -= port->stack.direction * port->stack.reent_overhead;
xstackPtr = -port->stack.direction * port->stack.call_overhead;
fetype = getSpec (name->type); /* get the specifier for the function */
/* if this is a reentrant function then */
- if (IS_RENT (fetype))
+ if (IFFUNC_ISREENT (name->type))
reentrant++;
- allocParms (name->args); /* allocate the parameters */
+ allocParms (FUNC_ARGS(name->type)); /* allocate the parameters */
/* do processing for parameters that are passed in registers */
- processRegParms (name->args, body);
+ processRegParms (FUNC_ARGS(name->type), body);
/* set the stack pointer */
stackPtr = 0;
ex = newAst_VALUE (symbolVal (name)); /* create name */
ex = newNode (FUNCTION, ex, body);
- ex->values.args = name->args;
+ ex->values.args = FUNC_ARGS(name->type);
if (fatalError)
{
/* dealloc the block variables */
processBlockVars (body, &stack, DEALLOCATE);
/* deallocate paramaters */
- deallocParms (name->args);
+ deallocParms (FUNC_ARGS(name->type));
- if (IS_RENT (fetype))
+ if (IFFUNC_ISREENT (name->type))
reentrant--;
/* we are done freeup memory & cleanup */
noLineno--;
labelKey = 1;
name->key = 0;
- name->fbody = 1;
+ FUNC_HASBODY(name->type) = 1;
addSet (&operKeyReset, name);
applyToSet (operKeyReset, resetParmKey);
unsigned type:3;
unsigned decorated:1;
- unsigned hasVargs:1;
unsigned isError:1;
unsigned funcName:1;
unsigned rvalue:1;
sym_link *etype; /* end of type chain for this subtree */
symbol *argSym; /* argument symbols */
- value *args; /* args of a function */
struct ast *left; /* pointer to left tree */
struct ast *right; /* pointer to right tree */
symbol *trueLabel; /* if statement trueLabel */
(sym->_isparm && !IS_REGPARM (sym->etype))) &&
addPublics &&
!IS_STATIC (sym->etype) &&
- (IS_FUNC(sym->type) ? (sym->used || sym->fbody) : 1))
+ (IS_FUNC(sym->type) ? (sym->used || IFFUNC_HASBODY(sym->type)) : 1))
{
addSetHead (&publics, sym);
}
}
/* if the main is only a prototype ie. no body then do nothing */
- if (!mainf->fbody)
+ if (!IFFUNC_HASBODY(mainf->type))
{
/* if ! compile only then main function should be present */
if (!options.cc_only && !noAssemble)
copyFile (asmFile, ovrFile);
/* create the stack segment MOF */
- if (mainf && mainf->fbody)
+ if (mainf && IFFUNC_HASBODY(mainf->type))
{
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; Stack segment in internal ram \n");
copyFile (asmFile, bit->oFile);
/* if external stack then reserve space of it */
- if (mainf && mainf->fbody && options.useXstack)
+ if (mainf && IFFUNC_HASBODY(mainf->type) && options.useXstack)
{
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; external stack \n");
copyFile (asmFile, xdata->oFile);
/* copy the interrupt vector table */
- if (mainf && mainf->fbody)
+ if (mainf && IFFUNC_HASBODY(mainf->type))
{
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; interrupt vector \n");
tfprintf (asmFile, "\t!area\n", port->mem.post_static_name);
tfprintf (asmFile, "\t!area\n", port->mem.static_name);
- if (mainf && mainf->fbody)
+ if (mainf && IFFUNC_HASBODY(mainf->type))
{
fprintf (asmFile, "__sdcc_gsinit_startup:\n");
/* if external stack is specified then the
}
copyFile (asmFile, statsg->oFile);
- if (port->general.glue_up_main && mainf && mainf->fbody)
+ if (port->general.glue_up_main && mainf && IFFUNC_HASBODY(mainf->type))
{
/* This code is generated in the post-static area.
* This area is guaranteed to follow the static area
fprintf (asmFile, "; code\n");
fprintf (asmFile, "%s", iComments2);
tfprintf (asmFile, "\t!areacode\n", CODE_NAME);
- if (mainf && mainf->fbody)
+ if (mainf && IFFUNC_HASBODY(mainf->type))
{
/* entry point @ start of CSEG */
register equivalent for a local symbol */
if (sym->level && sym->etype && SPEC_OCLS (sym->etype) &&
(IN_FARSPACE (SPEC_OCLS (sym->etype)) &&
- /* (!TARGET_IS_DS390)) && */
(!(options.model == MODEL_FLAT24)) ) &&
options.stackAuto == 0)
ok = 0;
else
IC_RESULT (ic)->isaddr = (!IS_AGGREGATE (sym->type));
- IC_RESULT (ic)->operand.symOperand->args = sym->args;
-
ADDTOCHAIN (ic);
return IC_RESULT (ic);
/* ic->supportRtn = ((IS_GENPTR(type) | op->isGptr) & op->isaddr); */
- /* if the right is a symbol */
- if (op->type == SYMBOL)
- IC_RESULT (ic)->operand.symOperand->args =
- op->operand.symOperand->args;
ADDTOCHAIN (ic);
return IC_RESULT (ic);
/*-----------------------------------------------------------------*/
/* geniCodeParms - generates parameters */
/*-----------------------------------------------------------------*/
-static void
-geniCodeParms (ast * parms, int *stack, sym_link * fetype, symbol * func,int lvl)
+value *
+geniCodeParms (ast * parms, value *argVals, int *stack,
+ sym_link * fetype, symbol * func,int lvl)
{
iCode *ic;
operand *pval;
if (!parms)
- return;
+ return argVals;
+
+ if (argVals==NULL) {
+ // first argument
+ argVals=FUNC_ARGS(func->type);
+ }
+
+ if (parms->argSym ||
+ (parms->type!=EX_OP && parms->type!=EX_OPERAND)) {
+ fprintf (stderr, "What the fuck??\n");
+ }
/* if this is a param node then do the left & right */
if (parms->type == EX_OP && parms->opval.op == PARAM)
{
- geniCodeParms (parms->left, stack, fetype, func,lvl);
- geniCodeParms (parms->right, stack, fetype, func,lvl);
- return;
+ argVals=geniCodeParms (parms->left, argVals, stack, fetype, func,lvl);
+ argVals=geniCodeParms (parms->right, argVals, stack, fetype, func,lvl);
+ return argVals;
}
/* get the parameter value */
pval = geniCodeRValue (ast2iCode (parms,lvl+1), FALSE);
}
- /* if register parm then make it a send */
- if (((parms->argSym && IS_REGPARM (parms->argSym->etype)) ||
- IS_REGPARM (parms->etype)) && !func->hasVargs)
+ /* if register arg then make it a send */
+ if (((argVals->sym && IS_REGPARM (argVals->sym->etype)) ||
+ IS_REGPARM (parms->etype)) && !IFFUNC_HASVARARGS(func->type))
+ //!DECL_HASVARARGS(func->type) &&
+ //!options.stackAuto &&
+ //!IS_RENT(func->etype) &&
+ //IS_REGPARM (argVals->sym->etype))
{
ic = newiCode (SEND, pval, NULL);
ADDTOCHAIN (ic);
else
{
/* now decide whether to push or assign */
- if (!(options.stackAuto || IS_RENT (fetype)))
+ if (!(options.stackAuto || IFFUNC_ISREENT (func->type)))
{
/* assign */
- operand *top = operandFromSymbol (parms->argSym);
+ operand *top = operandFromSymbol (argVals->sym);
geniCodeAssign (top, pval, 1);
}
else
}
}
+ argVals=argVals->next;
+ return argVals;
}
/*-----------------------------------------------------------------*/
geniCodeSEParms (parms,lvl);
/* first the parameters */
- geniCodeParms (parms, &stack, getSpec (operandType (left)), OP_SYMBOL (left),lvl);
+ 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))
else
ic = newiCode (CALL, left, NULL);
- IC_ARGS (ic) = left->operand.symOperand->args;
+ IC_ARGS (ic) = FUNC_ARGS(left->operand.symOperand->type);
type = copyLinkChain (operandType (left)->next);
etype = getSpec (type);
SPEC_EXTR (etype) = 0;
union
{
symbol *label; /* for a goto statement */
- value *args;
+ value *args; /* for a function */
}
argLabel;
SPEC_OCLS (sym->etype) = code;
/* if this is an interrupt service routine
then put it in the interrupt service array */
- if (IS_ISR (sym->etype))
+ if (FUNC_ISISR (sym->type))
{
- if (interrupts[SPEC_INTN (sym->etype)])
+ if (interrupts[FUNC_INTNO (sym->type)])
werror (E_INT_DEFINED,
- SPEC_INTN (sym->etype),
- interrupts[SPEC_INTN (sym->etype)]->name);
+ FUNC_INTNO (sym->type),
+ interrupts[FUNC_INTNO (sym->type)]->name);
else
- interrupts[SPEC_INTN (sym->etype)] = sym;
+ interrupts[FUNC_INTNO (sym->type)] = sym;
/* automagically extend the maximum interrupts */
- if (SPEC_INTN (sym->etype) >= maxInterrupts)
- maxInterrupts = SPEC_INTN (sym->etype) + 1;
+ if (FUNC_INTNO (sym->type) >= maxInterrupts)
+ maxInterrupts = FUNC_INTNO (sym->type) + 1;
}
/* if it is not compiler defined */
if (!sym->cdef)
/* if automatic variables r 2b stacked */
- if (options.stackAuto || IS_RENT (currFunc->etype))
+ if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
{
if (lval->sym)
if (port->stack.direction > 0)
{
SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
- stackPtr - (SPEC_BANK (currFunc->etype) ? port->stack.bank_overhead : 0) -
+ stackPtr - (FUNC_REGBANK (currFunc->type) ? port->stack.bank_overhead : 0) -
getSize (lval->type) -
- (IS_ISR (currFunc->etype) ? port->stack.isr_overhead : 0);
+ (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0);
stackPtr -= getSize (lval->type);
}
else
/* PENDING: isr, bank overhead, ... */
SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
stackPtr +
- (IS_BANKEDCALL (currFunc->etype) ? port->stack.banked_overhead : 0) +
- (IS_ISR (currFunc->etype) ? port->stack.isr_overhead : 0) +
+ ((IFFUNC_ISBANKEDCALL (currFunc->type) && !SPEC_STAT(getSpec(currFunc->etype)))? port->stack.banked_overhead : 0) +
+ (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0) +
0;
stackPtr += getSize (lval->type);
}
processFuncArgs (csym, 1);
/* if register bank specified then update maxRegBank */
- if (maxRegBank < SPEC_BANK (csym->etype))
- maxRegBank = SPEC_BANK (csym->etype);
+ if (maxRegBank < FUNC_REGBANK (csym->type))
+ maxRegBank = FUNC_REGBANK (csym->type);
}
/* if this is a extern variable then change the */
if (options.noOverlay ||
options.stackAuto ||
(currFunc &&
- (IS_RENT (currFunc->etype) ||
- IS_ISR (currFunc->etype))) ||
+ (IFFUNC_ISREENT (currFunc->type) ||
+ FUNC_ISISR (currFunc->type))) ||
elementsInSet (overlay->syms) == 0)
return FALSE;
{
/* first one */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
{
newic = newiCode (SEND, IC_LEFT (ic), NULL);
}
else
{
newic = newiCode ('=', NULL, IC_LEFT (ic));
- IC_RESULT (newic) = operandFromValue (func->args);
+ IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
newic->lineno = lineno;
/* second one */
- if (IS_REGPARM (func->args->next->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
{
newic = newiCode (SEND, IC_LEFT (ic), NULL);
}
else
{
newic = newiCode ('=', NULL, IC_RIGHT (ic));
- IC_RESULT (newic) = operandFromValue (func->args->next);
+ IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type)->next);
}
addiCodeToeBBlock (ebp, newic, ip);
newic->lineno = lineno;
{
/* push right */
- if (IS_REGPARM (func->args->next->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
{
newic = newiCode (SEND, right, NULL);
}
newic->lineno = lineno;
/* insert push left */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
{
newic = newiCode (SEND, left, NULL);
}
if (!options.float_rent)
{
/* first one */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
newic = newiCode (SEND, IC_RIGHT (ic), NULL);
else
{
newic = newiCode ('=', NULL, IC_RIGHT (ic));
- IC_RESULT (newic) = operandFromValue (func->args);
+ IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
newic->lineno = linenno;
else
{
/* push the left */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
newic = newiCode (SEND, IC_RIGHT (ic), NULL);
else
{
if (!options.float_rent)
{
/* first one */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
newic = newiCode (SEND, IC_RIGHT (ic), NULL);
else
{
newic = newiCode ('=', NULL, IC_RIGHT (ic));
- IC_RESULT (newic) = operandFromValue (func->args);
+ IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
newic->lineno = lineno;
{
/* push the left */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
newic = newiCode (SEND, IC_RIGHT (ic), NULL);
else
{
if (!options.intlong_rent)
{
/* first one */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
newic = newiCode (SEND, IC_LEFT (ic), NULL);
else
{
newic = newiCode ('=', NULL, IC_LEFT (ic));
- IC_RESULT (newic) = operandFromValue (func->args);
+ IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
}
addiCodeToeBBlock (ebp, newic, ip);
newic->lineno = lineno;
/* second one */
- if (IS_REGPARM (func->args->next->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
newic = newiCode (SEND, IC_RIGHT (ic), NULL);
else
{
newic = newiCode ('=', NULL, IC_RIGHT (ic));
- IC_RESULT (newic) = operandFromValue (func->args->next);
+ IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type)->next);
}
addiCodeToeBBlock (ebp, newic, ip);
newic->lineno = lineno;
{
/* compiled as reentrant then push */
/* push right */
- if (IS_REGPARM (func->args->next->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->next->etype))
{
newic = newiCode (SEND, IC_RIGHT (ic), NULL);
}
newic->lineno = lineno;
/* insert push left */
- if (IS_REGPARM (func->args->etype))
+ if (IS_REGPARM (FUNC_ARGS(func->type)->etype))
{
newic = newiCode (SEND, IC_LEFT (ic), NULL);
}
sym_link *
mergeSpec (sym_link * dest, sym_link * src, char *name)
{
-
sym_link *symlink=dest;
-#if 0
- if (!IS_SPEC(dest)) {
- // This can happen for pointers, find the end type
- while (dest && !IS_SPEC(dest))
- dest=dest->next;
- }
- if (!IS_SPEC(src)) {
- // here we have a declarator as source, reverse them
- symlink=src;
- src=dest;
- dest=symlink;
- while (dest && !IS_SPEC(dest)) {
- // and find the specifier
- dest=dest->next;
- }
- } else {
- symlink=dest;
- }
-#endif
-
if (!IS_SPEC(dest) || !IS_SPEC(src)) {
werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "cannot merge declarator");
exit (1);
SPEC_STAT (dest) |= SPEC_STAT (src);
SPEC_EXTR (dest) |= SPEC_EXTR (src);
SPEC_ABSA (dest) |= SPEC_ABSA (src);
- SPEC_RENT (dest) |= SPEC_RENT (src);
- SPEC_INTN (dest) |= SPEC_INTN (src);
- SPEC_BANK (dest) |= SPEC_BANK (src);
SPEC_VOLATILE (dest) |= SPEC_VOLATILE (src);
- SPEC_CRTCL (dest) |= SPEC_CRTCL (src);
SPEC_ADDR (dest) |= SPEC_ADDR (src);
SPEC_OCLS (dest) = SPEC_OCLS (src);
SPEC_BLEN (dest) |= SPEC_BLEN (src);
SPEC_BSTR (dest) |= SPEC_BSTR (src);
SPEC_TYPEDEF (dest) |= SPEC_TYPEDEF (src);
- SPEC_NONBANKED (dest) |= SPEC_NONBANKED (src);
- SPEC_NAKED (dest) |= SPEC_NAKED (src);
if (IS_STRUCT (dest) && SPEC_STRUCT (dest) == NULL)
SPEC_STRUCT (dest) = SPEC_STRUCT (src);
+ /* these are the only function attributes that will be set
+ in a specifier while parsing */
+ FUNC_NONBANKED(dest) |= FUNC_NONBANKED(src);
+ FUNC_BANKED(dest) |= FUNC_BANKED(src);
+ FUNC_ISCRITICAL(dest) |= FUNC_ISCRITICAL(src);
+ FUNC_ISREENT(dest) |= FUNC_ISREENT(src);
+ FUNC_ISNAKED(dest) |= FUNC_ISNAKED(src);
+
return symlink;
}
dest->type = copyLinkChain (src->type);
dest->etype = getSpec (dest->type);
dest->next = NULL;
- dest->args = copyValueChain (src->args);
dest->key = src->key;
- dest->calleeSave = src->calleeSave;
dest->allocreq = src->allocreq;
return dest;
}
/* structElemType - returns the type info of a sturct member */
/*------------------------------------------------------------------*/
sym_link *
-structElemType (sym_link * stype, value * id, value ** argsp)
+structElemType (sym_link * stype, value * id)
{
symbol *fields = (SPEC_STRUCT (stype) ? SPEC_STRUCT (stype)->fields : NULL);
sym_link *type, *etype;
{
if (strcmp (fields->rname, id->name) == 0)
{
- if (argsp)
- {
- *argsp = fields->args;
- }
type = copyLinkChain (fields->type);
etype = getSpec (type);
SPEC_SCLS (etype) = (SPEC_SCLS (petype) == S_REGISTER ?
if (sym->level && SPEC_SCLS (sym->etype) == S_FIXED &&
!IS_STATIC(sym->etype))
{
- if (options.stackAuto || (currFunc && IS_RENT (currFunc->etype)))
+ if (options.stackAuto || (currFunc && IFFUNC_ISREENT (currFunc->type)))
{
SPEC_SCLS (sym->etype) = (options.useXstack ?
S_XSTACK : S_STACK);
{
if (IS_DECL (src))
{
- if (DCL_TYPE (src) == DCL_TYPE (dest))
+ if (DCL_TYPE (src) == DCL_TYPE (dest)) {
+ if (IS_FUNC(src)) {
+ //checkFunction(src,dest);
+ }
return compareType (dest->next, src->next);
+ }
if (IS_PTR (src) && IS_GENPTR (dest))
return -1;
if (IS_PTR (dest) && IS_ARRAY (src)) {
/* checkFunction - does all kinds of check on a function */
/*------------------------------------------------------------------*/
int
-checkFunction (symbol * sym)
+checkFunction (symbol * sym, symbol *csym)
{
- symbol *csym;
value *exargs, *acargs;
value *checkValue;
int argCnt = 0;
/* check if this function is defined as calleeSaves
then mark it as such */
- sym->calleeSave = inCalleeSaveList (sym->name);
+ FUNC_CALLEESAVES(sym->type) = inCalleeSaveList (sym->name);
/* if interrupt service routine */
/* then it cannot have arguments */
- if (sym->args && IS_ISR (sym->etype) && !IS_VOID (sym->args->type))
+ if (IFFUNC_ARGS(sym->type) && FUNC_ISISR (sym->type))
{
- werror (E_INT_ARGS, sym->name);
- sym->args = NULL;
+ if (!IS_VOID(FUNC_ARGS(sym->type)->type)) {
+ werror (E_INT_ARGS, sym->name);
+ FUNC_ARGS(sym->type)=NULL;
+ }
}
- if (!(csym = findSym (SymbolTab, sym, sym->name)))
+ if (!csym && !(csym = findSym (SymbolTab, sym, sym->name)))
return 1; /* not defined nothing more to check */
/* check if body already present */
- if (csym && csym->fbody)
+ if (csym && IFFUNC_HASBODY(csym->type))
{
werror (E_FUNC_BODY, sym->name);
return 0;
return 0;
}
- if (SPEC_INTRTN (csym->etype) != SPEC_INTRTN (sym->etype))
+ if (FUNC_ISISR (csym->type) != FUNC_ISISR (sym->type))
{
werror (E_PREV_DEF_CONFLICT, csym->name, "interrupt");
}
- if (SPEC_BANK (csym->etype) != SPEC_BANK (sym->etype))
+ if (FUNC_REGBANK (csym->type) != FUNC_REGBANK (sym->type))
{
werror (E_PREV_DEF_CONFLICT, csym->name, "using");
}
- if (SPEC_NAKED (csym->etype) != SPEC_NAKED (sym->etype))
+ if (IFFUNC_ISNAKED (csym->type) != IFFUNC_ISNAKED (sym->type))
{
werror (E_PREV_DEF_CONFLICT, csym->name, "_naked");
}
/* compare expected args with actual args */
- exargs = csym->args;
- acargs = sym->args;
+ exargs = FUNC_ARGS(csym->type);
+ acargs = FUNC_ARGS(sym->type);
/* for all the expected args do */
for (argCnt = 1;
/* if this function has variable argument list */
/* then make the function a reentrant one */
- if (func->hasVargs)
- SPEC_RENT (func->etype) = 1;
+ if (IFFUNC_HASVARARGS(func->type))
+ FUNC_ISREENT(func->type)=1;
/* check if this function is defined as calleeSaves
then mark it as such */
- func->calleeSave = inCalleeSaveList (func->name);
+ FUNC_CALLEESAVES(func->type) = inCalleeSaveList (func->name);
- val = func->args; /* loop thru all the arguments */
+ /* loop thru all the arguments */
+ val = FUNC_ARGS(func->type);
/* if it is void then remove parameters */
if (val && IS_VOID (val->type))
{
- func->args = NULL;
+ FUNC_ARGS(func->type) = NULL;
return;
}
/* mark it as a register parameter if
the function does not have VA_ARG
and as port dictates */
- if (!func->hasVargs &&
+ if (!IFFUNC_HASVARARGS(func->type) &&
(*port->reg_parm) (val->type))
{
SPEC_REGPARM (val->etype) = 1;
if (func->cdef) {
/* ignore --stack-auto for this one, we don't know how it is compiled */
/* simply trust on --int-long-reent or --float-reent */
- if (IS_RENT(func->etype)) {
+ if (IFFUNC_ISREENT(func->type)) {
return;
}
} else {
/* if this function is reentrant or */
/* automatics r 2b stacked then nothing */
- if (IS_RENT (func->etype) || options.stackAuto)
+ if (IFFUNC_ISREENT (func->type) || options.stackAuto)
return;
}
- val = func->args;
+ val = FUNC_ARGS(func->type);
pNum = 1;
while (val)
{
if is it an interrupt routine & interrupt number
and the register bank it is using */
if (isFunc)
- fprintf (of, ",%d,%d,%d", SPEC_INTRTN (sym->etype),
- SPEC_INTN (sym->etype), SPEC_BANK (sym->etype));
+ fprintf (of, ",%d,%d,%d", FUNC_ISISR (sym->type),
+ FUNC_INTNO (sym->type), FUNC_REGBANK (sym->type));
/* alternate location to find this symbol @ : eg registers
or spillication */
ssu[su],
sbwd[bwd]);
__muldiv[muldivmod][bwd][su] = funcOfType (_mangleFunctionName(buffer), __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
- SPEC_NONBANKED (__muldiv[muldivmod][bwd][su]->etype) = 1;
+ FUNC_NONBANKED (__muldiv[muldivmod][bwd][su]->type) = 1;
}
}
}
ssu[su],
sbwd[bwd]);
__rlrr[rlrr][bwd][su] = funcOfType (_mangleFunctionName(buffer), __multypes[bwd][su], __multypes[0][0], 2, options.intlong_rent);
- SPEC_NONBANKED (__rlrr[rlrr][bwd][su]->etype) = 1;
+ FUNC_NONBANKED (__rlrr[rlrr][bwd][su]->type) = 1;
}
}
}
unsigned _static:1; /* 1=static keyword found */
unsigned _extern:1; /* 1=extern found */
unsigned _absadr:1; /* absolute address specfied */
- unsigned _reent:1; /* function is reentrant */
- unsigned _intrtn:1; /* this is an interrupt routin */
- unsigned _rbank:1; /* seperate register bank */
unsigned _volatile:1; /* is marked as volatile */
unsigned _const:1; /* is a constant */
- unsigned _critical:1; /* critical function */
- unsigned _naked:1; /* naked function */
unsigned _typedef:1; /* is typedefed */
unsigned _isregparm:1; /* is the first parameter */
unsigned _isenum:1; /* is an enumerated type */
- unsigned nonbanked:1; /* function has the nonbanked attribute */
- unsigned banked:1; /* function has the banked attribute */
- unsigned _IntNo; /* 1=Interrupt svc routine */
- short _regbank; /* register bank 2b used */
unsigned _addr; /* address of symbol */
unsigned _stack; /* stack offset for stacked v */
unsigned _bitStart; /* bit start position */
unsigned int num_elem; /* # of elems if type==array */
short ptr_const:1; /* pointer is constant */
short ptr_volatile:1; /* pointer is volatile */
- struct sym_link *tspec; /* pointer type specifier */
+ struct sym_link *tspec; /* pointer type specifier */
}
declarator;
{
specifier s; /* if CLASS == SPECIFIER */
declarator d; /* if CLASS == DECLARATOR */
- }
- select;
+ } select;
+
+ /* function attributes */
+ struct {
+ struct value *args; /* the defined arguments */
+ unsigned hasVargs:1; /* functions has varargs */
+ unsigned calleeSaves:1; /* functions uses callee save */
+ unsigned hasbody:1; /* function body defined */
+ //unsigned ret:1; /* return statement for a function */
+ unsigned hasFcall:1; /* does it call other functions */
+ unsigned reent:1; /* function is reentrant */
+ unsigned naked:1; /* naked function */
+
+ unsigned nonbanked:1; /* function has the nonbanked attribute */
+ unsigned banked:1; /* function has the banked attribute */
+ unsigned critical:1; /* critical function */
+ unsigned intrtn:1; /* this is an interrupt routin */
+ unsigned rbank:1; /* seperate register bank */
+ unsigned intno; /* 1=Interrupt svc routine */
+ unsigned regbank; /* register bank 2b used */
+ } funcAttrs;
struct sym_link *next; /* next element on the chain */
}
short level; /* declration lev,fld offset */
short block; /* sequential block # of defintion */
int key;
- unsigned fbody:1; /* function body defined */
unsigned implicit:1; /* implicit flag */
unsigned undefined:1; /* undefined variable */
- unsigned ret:1; /* return statement for a function */
- unsigned hasVargs:1; /* has a variable argument list */
unsigned _isparm:1; /* is a parameter */
unsigned ismyparm:1; /* is parameter of the function being generated */
unsigned isitmp:1; /* is an intermediate temp */
unsigned allocreq:1; /* allocation is required for this variable */
unsigned addrtaken:1; /* address of the symbol was taken */
unsigned isreqv:1; /* is the register quivalent of a symbol */
- unsigned hasFcall:1; /* for functions does it call other functions */
- unsigned calleeSave:1; /* for functions uses callee save paradigm */
unsigned udChked:1; /* use def checking has been already done */
/* following flags are used by the backend
int lastLine; /* for functions the last line */
struct sym_link *type; /* 1st link to declator chain */
struct sym_link *etype; /* last link to declarator chn */
- struct value *args; /* arguments if function */
struct symbol *next; /* crosslink to next symbol */
struct symbol *localof; /* local variable of which function */
struct initList *ival; /* ptr to initializer if any */
#define DCL_PTR_CONST(l) l->select.d.ptr_const
#define DCL_PTR_VOLATILE(l) l->select.d.ptr_volatile
#define DCL_TSPEC(l) l->select.d.tspec
+
+#define FUNC_DEBUG //assert(IS_FUNC(x));
+#define FUNC_HASVARARGS(x) (x->funcAttrs.hasVargs)
+#define IFFUNC_HASVARARGS(x) (IS_FUNC(x) && FUNC_HASVARARGS(x))
+#define FUNC_ARGS(x) (x->funcAttrs.args)
+#define IFFUNC_ARGS(x) (IS_FUNC(x) && FUNC_ARGS(x))
+#define FUNC_HASFCALL(x) (x->funcAttrs.hasFcall)
+#define IFFUNC_HASFCALL(x) (IS_FUNC(x) && FUNC_HASFCALL(x))
+#define FUNC_HASBODY(x) (x->funcAttrs.hasbody)
+#define IFFUNC_HASBODY(x) (IS_FUNC(x) && FUNC_HASBODY(x))
+#define FUNC_CALLEESAVES(x) (x->funcAttrs.calleeSaves)
+#define IFFUNC_CALLEESAVES(x) (IS_FUNC(x) && FUNC_CALLEESAVES(x))
+#define FUNC_ISISR(x) (x->funcAttrs.intrtn)
+#define IFFUNC_ISISR(x) (IS_FUNC(x) && FUNC_ISISR(x))
+//#define FUNC_RBANK(x) (x->funcAttrs.rbank)
+#define IFFUNC_RBANK(x) (IS_FUNC(x) && FUNC_RBANK(x))
+#define FUNC_INTNO(x) (x->funcAttrs.intno)
+#define FUNC_REGBANK(x) (x->funcAttrs.regbank)
+
+#define FUNC_ISREENT(x) (x->funcAttrs.reent)
+#define IFFUNC_ISREENT(x) (IS_FUNC(x) && FUNC_ISREENT(x))
+#define FUNC_ISNAKED(x) (x->funcAttrs.naked)
+#define IFFUNC_ISNAKED(x) (IS_FUNC(x) && FUNC_ISNAKED(x))
+#define FUNC_NONBANKED(x) (x->funcAttrs.nonbanked)
+#define IFFUNC_NONBANKED(x) (IS_FUNC(x) && FUNC_NONBANKED(x))
+#define FUNC_BANKED(x) (x->funcAttrs.banked)
+#define IFFUNC_BANKED(x) (IS_FUNC(x) && FUNC_BANKED(x))
+#define FUNC_ISCRITICAL(x) (x->funcAttrs.critical)
+#define IFFUNC_ISCRITICAL(x) (IS_FUNC(x) && FUNC_ISCRITICAL(x))
+
+// jwk: I am not sure about this
+#define IFFUNC_ISBANKEDCALL(x) (!IFFUNC_NONBANKED(x) && \
+ (options.model == MODEL_LARGE || \
+ options.model == MODEL_MEDIUM || \
+ IFFUNC_BANKED(x)))
+
#define SPEC_NOUN(x) x->select.s.noun
#define SPEC_LONG(x) x->select.s._long
#define SPEC_USIGN(x) x->select.s._unsigned
#define SPEC_STAT(x) x->select.s._static
#define SPEC_EXTR(x) x->select.s._extern
#define SPEC_CODE(x) x->select.s._codesg
-#define SPEC_RENT(x) x->select.s._reent
-#define SPEC_INTN(x) x->select.s._IntNo
#define SPEC_ABSA(x) x->select.s._absadr
#define SPEC_BANK(x) x->select.s._regbank
#define SPEC_ADDR(x) x->select.s._addr
* _bitStart field instead of defining a new field.
*/
#define SPEC_ISR_SAVED_BANKS(x) x->select.s._bitStart
-#define SPEC_BNKF(x) x->select.s._rbank
-#define SPEC_INTRTN(x) x->select.s._intrtn
-#define SPEC_CRTCL(x) x->select.s._critical
-#define SPEC_NAKED(x) x->select.s._naked
#define SPEC_VOLATILE(x) x->select.s._volatile
#define SPEC_CONST(x) x->select.s._const
#define SPEC_STRUCT(x) x->select.s.v_struct
#define SPEC_TYPEDEF(x) x->select.s._typedef
#define SPEC_REGPARM(x) x->select.s._isregparm
-#define SPEC_NONBANKED(x) x->select.s.nonbanked
-#define SPEC_BANKED(x) x->select.s.banked
/* type check macros */
#define IS_DECL(x) ( x && x->class == DECLARATOR )
#define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x))
#define IS_AGGREGATE(x) (IS_ARRAY(x) || IS_STRUCT(x))
#define IS_LITERAL(x) (IS_SPEC(x) && x->select.s.sclass == S_LITERAL)
-#define IS_ISR(x) (IS_SPEC(x) && SPEC_INTRTN(x))
#define IS_REGPARM(x) (IS_SPEC(x) && SPEC_REGPARM(x))
-#define IS_NONBANKED(x) (IS_SPEC(x) && SPEC_NONBANKED(x))
-#define IS_BANKED(x) (IS_SPEC(x) && SPEC_BANKED(x))
-#define IS_BANKEDCALL(x) (IS_SPEC(x) && !SPEC_NONBANKED(x) && !SPEC_STAT(x) && (options.model == MODEL_LARGE || options.model == MODEL_MEDIUM || SPEC_BANKED(x)))
/* forward declaration for the global vars */
extern bucket *SymbolTab[];
sym_link *newCharLink ();
sym_link *newLongLink ();
int compareType (sym_link *, sym_link *);
-int checkFunction (symbol *);
+int checkFunction (symbol *, symbol *);
void cleanUpLevel (bucket **, int);
void cleanUpBlock (bucket **, int);
int funcInChain (sym_link *);
void addSymChain (symbol *);
-sym_link *structElemType (sym_link *, value *, value **);
+sym_link *structElemType (sym_link *, value *);
symbol *getStructElement (structdef *, symbol *);
sym_link *computeType (sym_link *, sym_link *);
void processFuncArgs (symbol *, int);
genFunction (iCode * ic)
{
symbol *sym;
- sym_link *fetype;
+ sym_link *ftype;
int i = 0;
_G.nRegsSaved = 0;
emitcode (";", "-----------------------------------------");
emitcode ("", "%s:", sym->rname);
- fetype = getSpec (operandType (IC_LEFT (ic)));
+ ftype = operandType (IC_LEFT (ic));
/* if critical function then turn interrupts off */
- if (SPEC_CRTCL (fetype))
+ if (IFFUNC_ISCRITICAL (ftype))
emitcode ("cli", "");
- if (IS_ISR (sym->etype)) {
+ if (IFFUNC_ISISR (sym->type)) {
}
/* save the preserved registers that are used in this function */
}
}
- if (SPEC_CRTCL (sym->etype))
+ if (IFFUNC_ISCRITICAL (sym->type))
emitcode ("sti", "");
- if (IS_ISR (sym->etype)) {
+ if (IFFUNC_ISISR (sym->type)) {
emitcode ("rti", "");
}
else {
regsAVR[i].type = (regsAVR[i].type & ~REG_MASK) | REG_SCR;
regsAVR[i].isFree = 1;
}
- if (!currFunc->hasFcall) {
+ if (!IFFUNC_HASFCALL(currFunc->type)) {
preAssignParms (ebbs[0]->sch);
}
/* Y - is not allocated (it is the stack frame) */
/* if the registers have been saved already then
do nothing */
- if (ic->regsSaved || (OP_SYMBOL (IC_LEFT (ic))->calleeSave) ||
- SPEC_NAKED(OP_SYM_ETYPE(IC_LEFT(ic))))
+ if (ic->regsSaved || IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type) ||
+ IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT(ic))))
return;
/* find the registers in use at this time
static void
genCall (iCode * ic)
{
- sym_link *detype;
+ sym_link *dtype;
bool restoreBank = FALSE;
bool swapBanks = FALSE;
/* if we are calling a not _naked function that is not using
the same register bank then we need to save the
destination registers on the stack */
- detype = getSpec (operandType (IC_LEFT (ic)));
- if (detype && !SPEC_NAKED(detype) &&
- (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) &&
- IS_ISR (currFunc->etype))
+ dtype = operandType (IC_LEFT (ic));
+ if (dtype && !IFFUNC_ISNAKED(dtype) &&
+ (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) &&
+ IFFUNC_ISISR (currFunc->type))
{
if (!ic->bankSaved)
{
/* This is unexpected; the bank should have been saved in
* genFunction.
*/
- saveRBank (SPEC_BANK (detype), ic, FALSE);
+ saveRBank (FUNC_REGBANK (dtype), ic, FALSE);
restoreBank = TRUE;
}
swapBanks = TRUE;
if (swapBanks)
{
emitcode ("mov", "psw,#0x%02x",
- ((SPEC_BANK(detype)) << 3) & 0xff);
+ ((FUNC_REGBANK(dtype)) << 3) & 0xff);
}
/* make the call */
if (swapBanks)
{
emitcode ("mov", "psw,#0x%02x",
- ((SPEC_BANK(currFunc->etype)) << 3) & 0xff);
+ ((FUNC_REGBANK(currFunc->type)) << 3) & 0xff);
}
/* if we need assign a result value */
}
/* if we hade saved some registers then unsave them */
- if (ic->regsSaved && !(OP_SYMBOL (IC_LEFT (ic))->calleeSave))
+ if (ic->regsSaved && !IFFUNC_CALLEESAVES(dtype))
unsaveRegisters (ic);
/* if register bank was saved then pop them */
if (restoreBank)
- unsaveRBank (SPEC_BANK (detype), ic, FALSE);
+ unsaveRBank (FUNC_REGBANK (dtype), ic, FALSE);
}
/*-----------------------------------------------------------------*/
static void
genPcall (iCode * ic)
{
- sym_link *detype;
+ sym_link *dtype;
symbol *rlbl = newiTempLabel (NULL);
D (emitcode (";", "genPcall ");
/* if we are calling a function that is not using
the same register bank then we need to save the
destination registers on the stack */
- detype = getSpec (operandType (IC_LEFT (ic)));
- if (detype &&
- IS_ISR (currFunc->etype) &&
- (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)))
- saveRBank (SPEC_BANK (detype), ic, TRUE);
+ dtype = operandType (IC_LEFT (ic));
+ if (dtype &&
+ IFFUNC_ISISR (currFunc->type) &&
+ (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)))
+ saveRBank (FUNC_REGBANK (dtype), ic, TRUE);
/* push the return address on to the stack */
}
/* if register bank was saved then unsave them */
- if (detype &&
- (SPEC_BANK (currFunc->etype) !=
- SPEC_BANK (detype)))
- unsaveRBank (SPEC_BANK (detype), ic, TRUE);
+ if (dtype &&
+ (FUNC_REGBANK (currFunc->type) !=
+ FUNC_REGBANK (dtype)))
+ unsaveRBank (FUNC_REGBANK (dtype), ic, TRUE);
/* if we hade saved some registers then
unsave them */
genFunction (iCode * ic)
{
symbol *sym;
- sym_link *fetype;
+ sym_link *ftype;
bool switchedPSW = FALSE;
D (emitcode (";", "genFunction "););
emitcode (";", "-----------------------------------------");
emitcode ("", "%s:", sym->rname);
- fetype = getSpec (operandType (IC_LEFT (ic)));
+ ftype = operandType (IC_LEFT (ic));
- if (SPEC_NAKED(fetype))
+ if (IFFUNC_ISNAKED(ftype))
{
emitcode(";", "naked function: no prologue.");
return;
}
/* if critical function then turn interrupts off */
- if (SPEC_CRTCL (fetype))
+ if (IFFUNC_ISCRITICAL (ftype))
emitcode ("clr", "ea");
/* here we need to generate the equates for the
register bank if required */
- if (SPEC_BANK (fetype) != rbank)
+ if (FUNC_REGBANK (ftype) != rbank)
{
int i;
- rbank = SPEC_BANK (fetype);
+ rbank = FUNC_REGBANK (ftype);
for (i = 0; i < ds390_nRegs; i++)
{
if (strcmp (regs390[i].base, "0") == 0)
/* if this is an interrupt service routine then
save acc, b, dpl, dph */
- if (IS_ISR (sym->etype))
+ if (IFFUNC_ISISR (sym->type))
{
if (!inExcludeList ("acc"))
/* if this isr has no bank i.e. is going to
run with bank 0 , then we need to save more
registers :-) */
- if (!SPEC_BANK (sym->etype))
+ if (!FUNC_REGBANK (sym->type))
{
/* if this function does not call any other
function then we can be economical and
save only those registers that are used */
- if (!sym->hasFcall)
+ if (!IFFUNC_HASFCALL(sym->type))
{
int i;
*/
unsigned long banksToSave = 0;
- if (sym->hasFcall)
+ if (IFFUNC_HASFCALL(sym->type))
{
#define MAX_REGISTER_BANKS 4
if (i->op == CALL)
{
- sym_link *detype;
+ sym_link *dtype;
- detype = getSpec(operandType (IC_LEFT(i)));
- if (detype
- && SPEC_BANK(detype) != SPEC_BANK(sym->etype))
+ dtype = operandType (IC_LEFT(i));
+ if (dtype
+ && FUNC_REGBANK(dtype) != FUNC_REGBANK(sym->type))
{
/* Mark this bank for saving. */
- if (SPEC_BANK(detype) >= MAX_REGISTER_BANKS)
+ if (FUNC_REGBANK(dtype) >= MAX_REGISTER_BANKS)
{
- werror(E_NO_SUCH_BANK, SPEC_BANK(detype));
+ werror(E_NO_SUCH_BANK, FUNC_REGBANK(dtype));
}
else
{
- banksToSave |= (1 << SPEC_BANK(detype));
+ banksToSave |= (1 << FUNC_REGBANK(dtype));
}
/* And note that we don't need to do it in
*/
emitcode ("push", "psw");
emitcode ("mov", "psw,#0x%02x",
- (SPEC_BANK (sym->etype) << 3) & 0x00ff);
+ (FUNC_REGBANK (sym->type) << 3) & 0x00ff);
switchedPSW = TRUE;
}
}
}
}
+ // jwk: this needs a closer look
SPEC_ISR_SAVED_BANKS(currFunc->etype) = banksToSave;
}
}
{
/* if callee-save to be used for this function
then save the registers being used in this function */
- if (sym->calleeSave)
+ if (IFFUNC_CALLEESAVES(sym->type))
{
int i;
}
/* set the register bank to the desired value */
- if ((SPEC_BANK (sym->etype) || IS_ISR (sym->etype))
+ if ((FUNC_REGBANK (sym->type) || FUNC_ISISR (sym->type))
&& !switchedPSW)
{
emitcode ("push", "psw");
- emitcode ("mov", "psw,#0x%02x", (SPEC_BANK (sym->etype) << 3) & 0x00ff);
+ emitcode ("mov", "psw,#0x%02x", (FUNC_REGBANK (sym->type) << 3) & 0x00ff);
}
- if (IS_RENT (sym->etype) || options.stackAuto)
+ if (IFFUNC_ISREENT (sym->type) || options.stackAuto)
{
if (options.useXstack)
D (emitcode (";", "genEndFunction "););
- if (SPEC_NAKED(sym->etype))
+ if (IFFUNC_ISNAKED(sym->type))
{
emitcode(";", "naked function: no epilogue.");
return;
}
- if (IS_RENT (sym->etype) || options.stackAuto)
+ if (IFFUNC_ISREENT (sym->type) || options.stackAuto)
{
emitcode ("mov", "%s,_bp", spname);
}
}
- if ((IS_RENT (sym->etype) || options.stackAuto))
+ if ((IFFUNC_ISREENT (sym->type) || options.stackAuto))
{
if (options.useXstack)
{
}
/* restore the register bank */
- if (SPEC_BANK (sym->etype) || IS_ISR (sym->etype))
+ if (FUNC_REGBANK (sym->type) || IFFUNC_ISISR (sym->type))
{
- if (!SPEC_BANK (sym->etype) || !IS_ISR (sym->etype)
+ if (!FUNC_REGBANK (sym->type) || !IFFUNC_ISISR (sym->type)
|| !options.useXstack)
{
/* Special case of ISR using non-zero bank with useXstack
}
}
- if (IS_ISR (sym->etype))
+ if (IFFUNC_ISISR (sym->type))
{
/* now we need to restore the registers */
/* if this isr has no bank i.e. is going to
run with bank 0 , then we need to save more
registers :-) */
- if (!SPEC_BANK (sym->etype))
+ if (!FUNC_REGBANK (sym->type))
{
/* if this function does not call any other
function then we can be economical and
save only those registers that are used */
- if (!sym->hasFcall)
+ if (!IFFUNC_HASFCALL(sym->type))
{
int i;
* Restore any register banks saved by genFunction
* in reverse order.
*/
+ // jwk: this needs a closer look
unsigned savedBanks = SPEC_ISR_SAVED_BANKS(currFunc->etype);
int ix;
if (!inExcludeList ("acc"))
emitcode ("pop", "acc");
- if (SPEC_CRTCL (sym->etype))
+ if (IFFUNC_ISCRITICAL (sym->type))
emitcode ("setb", "ea");
/* if debug then send end of function */
}
else
{
- if (SPEC_CRTCL (sym->etype))
+ if (IFFUNC_ISCRITICAL (sym->type))
emitcode ("setb", "ea");
- if (sym->calleeSave)
+ if (IFFUNC_CALLEESAVES(sym->type))
{
int i;
/* if the registers have been saved already or don't need to be then
do nothing */
- if (ic->regsSaved || (OP_SYMBOL (IC_LEFT (ic))->calleeSave) ||
- SPEC_NAKED(OP_SYM_ETYPE(IC_LEFT (ic))))
+ if (ic->regsSaved || IFFUNC_CALLEESAVES(OP_SYMBOL(IC_LEFT(ic))->type) ||
+ IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT (ic))))
return;
/* find the registers in use at this time
static void
genCall (iCode * ic)
{
- sym_link *detype;
+ sym_link *dtype;
bool restoreBank = FALSE;
bool swapBanks = FALSE;
/* if we are calling a not _naked function that is not using
the same register bank then we need to save the
destination registers on the stack */
- detype = getSpec (operandType (IC_LEFT (ic)));
- if (detype && !SPEC_NAKED(detype) &&
- (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) &&
- IS_ISR (currFunc->etype))
+ dtype = operandType (IC_LEFT (ic));
+ if (dtype && !IFFUNC_ISNAKED(dtype) &&
+ (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) &&
+ IFFUNC_ISISR (currFunc->type))
{
if (!ic->bankSaved)
{
/* This is unexpected; the bank should have been saved in
* genFunction.
*/
- saveRBank (SPEC_BANK (detype), ic, FALSE);
+ saveRBank (FUNC_REGBANK (dtype), ic, FALSE);
restoreBank = TRUE;
}
swapBanks = TRUE;
if (swapBanks)
{
emitcode ("mov", "psw,#0x%02x",
- ((SPEC_BANK(detype)) << 3) & 0xff);
+ ((FUNC_REGBANK(dtype)) << 3) & 0xff);
}
/* make the call */
if (swapBanks)
{
emitcode ("mov", "psw,#0x%02x",
- ((SPEC_BANK(currFunc->etype)) << 3) & 0xff);
+ ((FUNC_REGBANK(currFunc->type)) << 3) & 0xff);
}
/* if we need assign a result value */
}
/* if we hade saved some registers then unsave them */
- if (ic->regsSaved && !(OP_SYMBOL (IC_LEFT (ic))->calleeSave))
+ if (ic->regsSaved && !IFFUNC_CALLEESAVES(dtype))
unsaveRegisters (ic);
/* if register bank was saved then pop them */
if (restoreBank)
- unsaveRBank (SPEC_BANK (detype), ic, FALSE);
+ unsaveRBank (FUNC_REGBANK (dtype), ic, FALSE);
}
/*-----------------------------------------------------------------*/
static void
genPcall (iCode * ic)
{
- sym_link *detype;
+ sym_link *dtype;
symbol *rlbl = newiTempLabel (NULL);
/* if we are calling a function that is not using
the same register bank then we need to save the
destination registers on the stack */
- detype = getSpec (operandType (IC_LEFT (ic)));
- if (detype &&
- IS_ISR (currFunc->etype) &&
- (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)))
- saveRBank (SPEC_BANK (detype), ic, TRUE);
+ dtype = operandType (IC_LEFT (ic));
+ if (dtype &&
+ IFFUNC_ISISR (currFunc->type) &&
+ (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)))
+ saveRBank (FUNC_REGBANK (dtype), ic, TRUE);
/* push the return address on to the stack */
}
/* if register bank was saved then unsave them */
- if (detype &&
- (SPEC_BANK (currFunc->etype) !=
- SPEC_BANK (detype)))
- unsaveRBank (SPEC_BANK (detype), ic, TRUE);
+ if (dtype &&
+ (FUNC_REGBANK (currFunc->type) !=
+ FUNC_REGBANK (dtype)))
+ unsaveRBank (FUNC_REGBANK (dtype), ic, TRUE);
/* if we hade saved some registers then
unsave them */
if (ic->regsSaved)
unsaveRegisters (ic);
-
}
/*-----------------------------------------------------------------*/
genFunction (iCode * ic)
{
symbol *sym;
- sym_link *fetype;
+ sym_link *ftype;
bool switchedPSW = FALSE;
_G.nRegsSaved = 0;
emitcode (";", "-----------------------------------------");
emitcode ("", "%s:", sym->rname);
- fetype = getSpec (operandType (IC_LEFT (ic)));
+ ftype = operandType (IC_LEFT (ic));
- if (SPEC_NAKED(fetype))
+ if (IFFUNC_ISNAKED(ftype))
{
emitcode(";", "naked function: no prologue.");
return;
}
/* if critical function then turn interrupts off */
- if (SPEC_CRTCL (fetype))
+ if (IFFUNC_ISCRITICAL (ftype))
emitcode ("clr", "ea");
/* here we need to generate the equates for the
register bank if required */
- if (SPEC_BANK (fetype) != rbank)
+ if (FUNC_REGBANK (ftype) != rbank)
{
int i;
- rbank = SPEC_BANK (fetype);
+ rbank = FUNC_REGBANK (ftype);
for (i = 0; i < mcs51_nRegs; i++)
{
if (strcmp (regs8051[i].base, "0") == 0)
/* if this is an interrupt service routine then
save acc, b, dpl, dph */
- if (IS_ISR (sym->etype))
+ if (IFFUNC_ISISR (sym->type))
{
if (!inExcludeList ("acc"))
/* if this isr has no bank i.e. is going to
run with bank 0 , then we need to save more
registers :-) */
- if (!SPEC_BANK (sym->etype))
+ if (!FUNC_REGBANK (sym->type))
{
/* if this function does not call any other
function then we can be economical and
save only those registers that are used */
- if (!sym->hasFcall)
+ if (!IFFUNC_HASFCALL(sym->type))
{
int i;
*/
unsigned long banksToSave = 0;
- if (sym->hasFcall)
+ if (IFFUNC_HASFCALL(sym->type))
{
#define MAX_REGISTER_BANKS 4
if (i->op == CALL)
{
- sym_link *detype;
+ sym_link *dtype;
- detype = getSpec(operandType (IC_LEFT(i)));
- if (detype
- && SPEC_BANK(detype) != SPEC_BANK(sym->etype))
+ dtype = operandType (IC_LEFT(i));
+ if (dtype
+ && FUNC_REGBANK(dtype) != FUNC_REGBANK(sym->type))
{
/* Mark this bank for saving. */
- if (SPEC_BANK(detype) >= MAX_REGISTER_BANKS)
+ if (FUNC_REGBANK(dtype) >= MAX_REGISTER_BANKS)
{
- werror(E_NO_SUCH_BANK, SPEC_BANK(detype));
+ werror(E_NO_SUCH_BANK, FUNC_REGBANK(dtype));
}
else
{
- banksToSave |= (1 << SPEC_BANK(detype));
+ banksToSave |= (1 << FUNC_REGBANK(dtype));
}
/* And note that we don't need to do it in
*/
emitcode ("push", "psw");
emitcode ("mov", "psw,#0x%02x",
- (SPEC_BANK (sym->etype) << 3) & 0x00ff);
+ (FUNC_REGBANK (sym->type) << 3) & 0x00ff);
switchedPSW = TRUE;
}
}
}
}
+ // jwk: this needs a closer look
SPEC_ISR_SAVED_BANKS(currFunc->etype) = banksToSave;
}
}
{
/* if callee-save to be used for this function
then save the registers being used in this function */
- if (sym->calleeSave)
+ if (IFFUNC_CALLEESAVES(sym->type))
{
int i;
}
/* set the register bank to the desired value */
- if ((SPEC_BANK (sym->etype) || IS_ISR (sym->etype))
+ if ((FUNC_REGBANK (sym->type) || IFFUNC_ISISR (sym->type))
&& !switchedPSW)
{
emitcode ("push", "psw");
- emitcode ("mov", "psw,#0x%02x", (SPEC_BANK (sym->etype) << 3) & 0x00ff);
+ emitcode ("mov", "psw,#0x%02x", (FUNC_REGBANK (sym->type) << 3) & 0x00ff);
}
- if (IS_RENT (sym->etype) || options.stackAuto)
+ if (IFFUNC_ISREENT (sym->type) || options.stackAuto)
{
if (options.useXstack)
{
symbol *sym = OP_SYMBOL (IC_LEFT (ic));
- if (SPEC_NAKED(sym->etype))
+ if (IFFUNC_ISNAKED(sym->type))
{
emitcode(";", "naked function: no epilogue.");
return;
}
- if (IS_RENT (sym->etype) || options.stackAuto)
+ if (IFFUNC_ISREENT (sym->type) || options.stackAuto)
{
emitcode ("mov", "%s,_bp", spname);
}
}
- if ((IS_RENT (sym->etype) || options.stackAuto))
+ if ((IFFUNC_ISREENT (sym->type) || options.stackAuto))
{
if (options.useXstack)
{
}
/* restore the register bank */
- if (SPEC_BANK (sym->etype) || IS_ISR (sym->etype))
+ if (FUNC_REGBANK (sym->type) || IFFUNC_ISISR (sym->type))
{
- if (!SPEC_BANK (sym->etype) || !IS_ISR (sym->etype)
+ if (!FUNC_REGBANK (sym->type) || !IFFUNC_ISISR (sym->type)
|| !options.useXstack)
{
/* Special case of ISR using non-zero bank with useXstack
}
}
- if (IS_ISR (sym->etype))
+ if (IFFUNC_ISISR (sym->type))
{
/* now we need to restore the registers */
/* if this isr has no bank i.e. is going to
run with bank 0 , then we need to save more
registers :-) */
- if (!SPEC_BANK (sym->etype))
+ if (!FUNC_REGBANK (sym->type))
{
/* if this function does not call any other
function then we can be economical and
save only those registers that are used */
- if (!sym->hasFcall)
+ if (!IFFUNC_HASFCALL(sym->type))
{
int i;
* Restore any register banks saved by genFunction
* in reverse order.
*/
+ // jwk: this needs a closer look
unsigned savedBanks = SPEC_ISR_SAVED_BANKS(currFunc->etype);
int ix;
if (!inExcludeList ("acc"))
emitcode ("pop", "acc");
- if (SPEC_CRTCL (sym->etype))
+ if (IFFUNC_ISCRITICAL (sym->type))
emitcode ("setb", "ea");
/* if debug then send end of function */
}
else
{
- if (SPEC_CRTCL (sym->etype))
+ if (IFFUNC_ISCRITICAL (sym->type))
emitcode ("setb", "ea");
- if (sym->calleeSave)
+ if (IFFUNC_CALLEESAVES(sym->type))
{
int i;
int i;
iCode *ic;
bitVect *rsave;
- sym_link *detype;
+ sym_link *dtype;
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
/* look for call */
/* if the registers have been saved already then
do nothing */
- if (ic->regsSaved || (OP_SYMBOL(IC_LEFT(ic))->calleeSave))
+ if (ic->regsSaved || IFFUNC_CALLEESAVES(OP_SYMBOL(IC_LEFT(ic))->type))
return ;
/* find the registers in use at this time
pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
}
- detype = getSpec(operandType(IC_LEFT(ic)));
- if (detype &&
- (SPEC_BANK(currFunc->etype) != SPEC_BANK(detype)) &&
- IS_ISR(currFunc->etype) &&
+ dtype = operandType(IC_LEFT(ic));
+ if (dtype &&
+ (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)) &&
+ IFFUNC_ISISR(currFunc->type) &&
!ic->bankSaved)
- saverbank(SPEC_BANK(detype),ic,TRUE);
+ saverbank(FUNC_REGBANK(dtype),ic,TRUE);
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
static void genCall (iCode *ic)
{
- sym_link *detype;
+ sym_link *dtype;
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
/* if we are calling a function that is not using
the same register bank then we need to save the
destination registers on the stack */
- detype = getSpec(operandType(IC_LEFT(ic)));
- if (detype &&
- (SPEC_BANK(currFunc->etype) != SPEC_BANK(detype)) &&
- IS_ISR(currFunc->etype) &&
+ dtype = operandType(IC_LEFT(ic));
+ if (dtype &&
+ (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)) &&
+ IFFUNC_ISISR(currFunc->type) &&
!ic->bankSaved)
- saverbank(SPEC_BANK(detype),ic,TRUE);
+ saverbank(FUNC_REGBANK(dtype),ic,TRUE);
/* if send set is not empty the assign */
if (_G.sendSet) {
/* if register bank was saved then pop them */
if (ic->bankSaved)
- unsaverbank(SPEC_BANK(detype),ic,TRUE);
+ unsaverbank(FUNC_REGBANK(dtype),ic,TRUE);
/* if we hade saved some registers then unsave them */
- if (ic->regsSaved && !(OP_SYMBOL(IC_LEFT(ic))->calleeSave))
+ if (ic->regsSaved && !IFFUNC_CALLEESAVES(dtype))
unsaveRegisters (ic);
/*-----------------------------------------------------------------*/
static void genPcall (iCode *ic)
{
- sym_link *detype;
+ sym_link *dtype;
symbol *rlbl = newiTempLabel(NULL);
/* if we are calling a function that is not using
the same register bank then we need to save the
destination registers on the stack */
- detype = getSpec(operandType(IC_LEFT(ic)));
- if (detype &&
- IS_ISR(currFunc->etype) &&
- (SPEC_BANK(currFunc->etype) != SPEC_BANK(detype)))
- saverbank(SPEC_BANK(detype),ic,TRUE);
+ dtype = operandType(IC_LEFT(ic));
+ if (dtype &&
+ IFFUNC_ISISR(currFunc->type) &&
+ (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)))
+ saverbank(FUNC_REGBANK(dtype),ic,TRUE);
/* push the return address on to the stack */
}
/* if register bank was saved then unsave them */
- if (detype &&
- (SPEC_BANK(currFunc->etype) !=
- SPEC_BANK(detype)))
- unsaverbank(SPEC_BANK(detype),ic,TRUE);
+ if (dtype &&
+ (FUNC_REGBANK(currFunc->type) != FUNC_REGBANK(dtype)))
+ unsaverbank(FUNC_REGBANK(dtype),ic,TRUE);
/* if we hade saved some registers then
unsave them */
static void genFunction (iCode *ic)
{
symbol *sym;
- sym_link *fetype;
+ sym_link *ftype;
DEBUGpic14_emitcode ("; ***","%s %d previous max_key=%d ",__FUNCTION__,__LINE__,max_key);
pic14_emitcode("","%s:",sym->rname);
addpCode2pBlock(pb,newpCodeFunction(NULL,sym->rname));
- fetype = getSpec(operandType(IC_LEFT(ic)));
+ ftype = operandType(IC_LEFT(ic));
/* if critical function then turn interrupts off */
- if (SPEC_CRTCL(fetype))
+ if (IFFUNC_ISCRITICAL(ftype))
pic14_emitcode("clr","ea");
/* here we need to generate the equates for the
register bank if required */
#if 0
- if (SPEC_BANK(fetype) != rbank) {
+ if (FUNC_REGBANK(ftype) != rbank) {
int i ;
- rbank = SPEC_BANK(fetype);
+ rbank = FUNC_REGBANK(ftype);
for ( i = 0 ; i < pic14_nRegs ; i++ ) {
if (strcmp(regspic14[i].base,"0") == 0)
pic14_emitcode("","%s = 0x%02x",
/* if this is an interrupt service routine then
save acc, b, dpl, dph */
- if (IS_ISR(sym->etype)) {
+ if (IFFUNC_ISISR(sym->type)) {
if (!inExcludeList("acc"))
pic14_emitcode ("push","acc");
/* if this isr has no bank i.e. is going to
run with bank 0 , then we need to save more
registers :-) */
- if (!SPEC_BANK(sym->etype)) {
+ if (!FUNC_REGBANK(sym->type)) {
/* if this function does not call any other
function then we can be economical and
save only those registers that are used */
- if (! sym->hasFcall) {
+ if (! IFFUNC_HASFCALL(sym->type)) {
int i;
/* if any registers used */
} else {
/* if callee-save to be used for this function
then save the registers being used in this function */
- if (sym->calleeSave) {
+ if (IFFUNC_CALLEESAVES(sym->type)) {
int i;
/* if any registers used */
}
/* set the register bank to the desired value */
- if (SPEC_BANK(sym->etype) || IS_ISR(sym->etype)) {
+ if (FUNC_REGBANK(sym->type) || FUNC_ISISR(sym->type)) {
pic14_emitcode("push","psw");
- pic14_emitcode("mov","psw,#0x%02x",(SPEC_BANK(sym->etype) << 3)&0x00ff);
+ pic14_emitcode("mov","psw,#0x%02x",(FUNC_REGBANK(sym->type) << 3)&0x00ff);
}
- if (IS_RENT(sym->etype) || options.stackAuto) {
+ if (IFFUNC_ISREENT(sym->type) || options.stackAuto) {
if (options.useXstack) {
pic14_emitcode("mov","r0,%s",spname);
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- if (IS_RENT(sym->etype) || options.stackAuto)
+ if (IFFUNC_ISREENT(sym->type) || options.stackAuto)
{
pic14_emitcode ("mov","%s,_bp",spname);
}
}
- if ((IS_RENT(sym->etype) || options.stackAuto)) {
+ if ((IFFUNC_ISREENT(sym->type) || options.stackAuto)) {
if (options.useXstack) {
pic14_emitcode("mov","r0,%s",spname);
pic14_emitcode("movx","a,@r0");
}
/* restore the register bank */
- if (SPEC_BANK(sym->etype) || IS_ISR(sym->etype))
+ if (FUNC_REGBANK(sym->type) || FUNC_ISISR(sym->type))
pic14_emitcode ("pop","psw");
- if (IS_ISR(sym->etype)) {
+ if (IFFUNC_ISISR(sym->type)) {
/* now we need to restore the registers */
/* if this isr has no bank i.e. is going to
run with bank 0 , then we need to save more
registers :-) */
- if (!SPEC_BANK(sym->etype)) {
+ if (!FUNC_REGBANK(sym->type)) {
/* if this function does not call any other
function then we can be economical and
save only those registers that are used */
- if (! sym->hasFcall) {
+ if (! IFFUNC_HASFCALL(sym->type)) {
int i;
/* if any registers used */
if (!inExcludeList("acc"))
pic14_emitcode ("pop","acc");
- if (SPEC_CRTCL(sym->etype))
+ if (IFFUNC_ISCRITICAL(sym->type))
pic14_emitcode("setb","ea");
/* if debug then send end of function */
pic14_emitcode ("reti","");
}
else {
- if (SPEC_CRTCL(sym->etype))
+ if (IFFUNC_ISCRITICAL(sym->type))
pic14_emitcode("setb","ea");
- if (sym->calleeSave) {
+ if (IFFUNC_CALLEESAVES(sym->type)) {
int i;
/* if any registers used */
/*-----------------------------------------------------------------*/
void genMinus (iCode *ic)
{
- int size, offset = 0,same;
+ int size, offset = 0, same=0;
unsigned long lit = 0L;
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
}
/* if the main is only a prototype ie. no body then do nothing */
- if (!mainf->fbody)
+ if (!IFFUNC_HASBODY(mainf->type))
{
/* if ! compile only then main function should be present */
if (!options.cc_only)
addSetHead(&tmpfileSet,ovrFile);
- if (mainf && mainf->fbody) {
+ if (mainf && IFFUNC_HASBODY(mainf->type)) {
pBlock *pb = newpCodeChain(NULL,'X',newpCodeCharP("; Starting pCode block"));
addpBlock(pb);
copyFile (asmFile, ovrFile);
/* create the stack segment MOF */
- if (mainf && mainf->fbody) {
+ if (mainf && IFFUNC_HASBODY(mainf->type)) {
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; Stack segment in internal ram \n");
fprintf (asmFile, "%s", iComments2);
copyFile (asmFile, idata->oFile);
/* if external stack then reserve space of it */
- if (mainf && mainf->fbody && options.useXstack ) {
+ if (mainf && IFFUNC_HASBODY(mainf->type) && options.useXstack ) {
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; external stack \n");
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "\tORG 0\n");
/* copy the interrupt vector table */
- if (mainf && mainf->fbody) {
+ if (mainf && IFFUNC_HASBODY(mainf->type)) {
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; interrupt vector \n");
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, ";\t.area %s\n", port->mem.post_static_name);
fprintf (asmFile, ";\t.area %s\n", port->mem.static_name);
- if (mainf && mainf->fbody) {
+ if (mainf && IFFUNC_HASBODY(mainf->type)) {
fprintf (asmFile,"__sdcc_gsinit_startup:\n");
/* if external stack is specified then the
higher order byte of the xdatalocation is
}
- if (port->general.glue_up_main && mainf && mainf->fbody)
+ if (port->general.glue_up_main && mainf && IFFUNC_HASBODY(mainf->type))
{
/* This code is generated in the post-static area.
* This area is guaranteed to follow the static area
static void
emitCall (iCode * ic, bool ispcall)
{
- sym_link *detype = getSpec (operandType (IC_LEFT (ic)));
+ sym_link *dtype = operandType (IC_LEFT (ic));
bitVect *rInUse = bitVectCplAnd (bitVectCopy (ic->rMask), ic->rUsed);
if (ispcall)
{
- if (IS_BANKEDCALL (detype))
+ if (IFFUNC_ISBANKEDCALL (dtype) && !SPEC_STAT(getSpec(dtype)))
{
werror (W_INDIR_BANKED);
}
char *name = OP_SYMBOL (IC_LEFT (ic))->rname[0] ?
OP_SYMBOL (IC_LEFT (ic))->rname :
OP_SYMBOL (IC_LEFT (ic))->name;
- if (IS_BANKEDCALL (detype))
+ if (IFFUNC_ISBANKEDCALL (dtype) && !SPEC_STAT(getSpec(dtype)))
{
emit2 ("call banked_call");
emit2 ("!dws", name);
genFunction (iCode * ic)
{
symbol *sym = OP_SYMBOL (IC_LEFT (ic));
- sym_link *fetype;
+ sym_link *ftype;
#if CALLEE_SAVES
bool bcInUse = FALSE;
bool deInUse = FALSE;
#endif
- setArea (IS_NONBANKED (sym->etype));
+ setArea (IFFUNC_NONBANKED (sym->type));
/* PENDING: Reset the receive offset as it doesn't seem to get reset anywhere
else.
emit2 ("!profileenter");
}
- fetype = getSpec (operandType (IC_LEFT (ic)));
+ ftype = operandType (IC_LEFT (ic));
/* if critical function then turn interrupts off */
- if (SPEC_CRTCL (fetype))
+ if (IFFUNC_ISCRITICAL (ftype))
emit2 ("!di");
/* if this is an interrupt service routine then save all potentially used registers. */
- if (IS_ISR (sym->etype))
+ if (IFFUNC_ISISR (sym->type))
{
emit2 ("!pusha");
}
{
symbol *sym = OP_SYMBOL (IC_LEFT (ic));
- if (IS_ISR (sym->etype))
+ if (IFFUNC_ISISR (sym->type))
{
wassertl (0, "Tried to close an interrupt support function");
}
else
{
- if (SPEC_CRTCL (sym->etype))
+ if (IFFUNC_ISCRITICAL (sym->type))
emit2 ("!ei");
/* PENDING: calleeSave */
The child will be killed.
*/
+#include <sys/time.h>
+#include <sys/resource.h>
+
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>