made the previous changes in parameter passing mechanism and return

value mechanism settable with compile time constants
This commit is contained in:
ceriel 1989-03-22 09:53:47 +00:00
parent f9b6acf1dc
commit 3a3b5db45d
6 changed files with 106 additions and 10 deletions

View file

@ -76,3 +76,18 @@
*/ */
!File: bigparam.h
#define PASS_BIG_VAL_AS_VAR 1 /* define when big value parameters must be
passed as addresses
*/
!File: bigresult.h
#define BIG_RESULT_ON_STACK 1 /* define when function results must be
put on the stack; in this case, caller
reserves space for it. When not defined,
callee puts result in global data area and
returns a pointer to it
*/

View file

@ -43,7 +43,7 @@ SRC = $(CSRC) $(GENC)
OBJ = $(COBJ) $(LOBJ) Lpars.o OBJ = $(COBJ) $(LOBJ) Lpars.o
GENH= errout.h\ GENH= errout.h\
idfsize.h numsize.h strsize.h target_sizes.h \ idfsize.h numsize.h strsize.h target_sizes.h bigparam.h bigresult.h \
inputtype.h density.h squeeze.h nocross.h nostrict.h \ inputtype.h density.h squeeze.h nocross.h nostrict.h \
def.h debugcst.h type.h Lpars.h node.h desig.h strict3rd.h def.h debugcst.h type.h Lpars.h node.h desig.h strict3rd.h
HFILES= LLlex.h\ HFILES= LLlex.h\
@ -178,6 +178,7 @@ $(CURRDIR)cemain: $(OBJ) $(CURRDIR)Makefile
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO #AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
LLlex.o: LLlex.h LLlex.o: LLlex.h
LLlex.o: Lpars.h LLlex.o: Lpars.h
LLlex.o: bigparam.h
LLlex.o: class.h LLlex.o: class.h
LLlex.o: const.h LLlex.o: const.h
LLlex.o: debug.h LLlex.o: debug.h
@ -212,6 +213,7 @@ error.o: warning.h
main.o: LLlex.h main.o: LLlex.h
main.o: Lpars.h main.o: Lpars.h
main.o: SYSTEM.h main.o: SYSTEM.h
main.o: bigparam.h
main.o: debug.h main.o: debug.h
main.o: debugcst.h main.o: debugcst.h
main.o: def.h main.o: def.h
@ -236,6 +238,7 @@ input.o: f_info.h
input.o: input.h input.o: input.h
input.o: inputtype.h input.o: inputtype.h
type.o: LLlex.h type.o: LLlex.h
type.o: bigparam.h
type.o: chk_expr.h type.o: chk_expr.h
type.o: const.h type.o: const.h
type.o: debug.h type.o: debug.h
@ -253,6 +256,7 @@ type.o: walk.h
type.o: warning.h type.o: warning.h
def.o: LLlex.h def.o: LLlex.h
def.o: Lpars.h def.o: Lpars.h
def.o: bigparam.h
def.o: debug.h def.o: debug.h
def.o: debugcst.h def.o: debugcst.h
def.o: def.h def.o: def.h
@ -270,6 +274,7 @@ misc.o: idf.h
misc.o: misc.h misc.o: misc.h
misc.o: node.h misc.o: node.h
enter.o: LLlex.h enter.o: LLlex.h
enter.o: bigparam.h
enter.o: debug.h enter.o: debug.h
enter.o: debugcst.h enter.o: debugcst.h
enter.o: def.h enter.o: def.h
@ -284,6 +289,7 @@ enter.o: target_sizes.h
enter.o: type.h enter.o: type.h
defmodule.o: LLlex.h defmodule.o: LLlex.h
defmodule.o: Lpars.h defmodule.o: Lpars.h
defmodule.o: bigparam.h
defmodule.o: debug.h defmodule.o: debug.h
defmodule.o: debugcst.h defmodule.o: debugcst.h
defmodule.o: def.h defmodule.o: def.h
@ -299,6 +305,7 @@ defmodule.o: scope.h
defmodule.o: target_sizes.h defmodule.o: target_sizes.h
defmodule.o: type.h defmodule.o: type.h
typequiv.o: LLlex.h typequiv.o: LLlex.h
typequiv.o: bigparam.h
typequiv.o: debug.h typequiv.o: debug.h
typequiv.o: debugcst.h typequiv.o: debugcst.h
typequiv.o: def.h typequiv.o: def.h
@ -311,6 +318,7 @@ typequiv.o: target_sizes.h
typequiv.o: type.h typequiv.o: type.h
typequiv.o: warning.h typequiv.o: warning.h
node.o: LLlex.h node.o: LLlex.h
node.o: bigparam.h
node.o: debug.h node.o: debug.h
node.o: debugcst.h node.o: debugcst.h
node.o: def.h node.o: def.h
@ -321,6 +329,7 @@ node.o: target_sizes.h
node.o: type.h node.o: type.h
cstoper.o: LLlex.h cstoper.o: LLlex.h
cstoper.o: Lpars.h cstoper.o: Lpars.h
cstoper.o: bigparam.h
cstoper.o: debug.h cstoper.o: debug.h
cstoper.o: debugcst.h cstoper.o: debugcst.h
cstoper.o: idf.h cstoper.o: idf.h
@ -332,6 +341,7 @@ cstoper.o: type.h
cstoper.o: warning.h cstoper.o: warning.h
chk_expr.o: LLlex.h chk_expr.o: LLlex.h
chk_expr.o: Lpars.h chk_expr.o: Lpars.h
chk_expr.o: bigparam.h
chk_expr.o: chk_expr.h chk_expr.o: chk_expr.h
chk_expr.o: const.h chk_expr.o: const.h
chk_expr.o: debug.h chk_expr.o: debug.h
@ -349,6 +359,7 @@ chk_expr.o: strict3rd.h
chk_expr.o: target_sizes.h chk_expr.o: target_sizes.h
chk_expr.o: type.h chk_expr.o: type.h
chk_expr.o: warning.h chk_expr.o: warning.h
options.o: bigparam.h
options.o: class.h options.o: class.h
options.o: idfsize.h options.o: idfsize.h
options.o: main.h options.o: main.h
@ -361,6 +372,8 @@ options.o: type.h
options.o: warning.h options.o: warning.h
walk.o: LLlex.h walk.o: LLlex.h
walk.o: Lpars.h walk.o: Lpars.h
walk.o: bigparam.h
walk.o: bigresult.h
walk.o: chk_expr.h walk.o: chk_expr.h
walk.o: debug.h walk.o: debug.h
walk.o: debugcst.h walk.o: debugcst.h
@ -380,6 +393,7 @@ walk.o: type.h
walk.o: walk.h walk.o: walk.h
walk.o: warning.h walk.o: warning.h
desig.o: LLlex.h desig.o: LLlex.h
desig.o: bigparam.h
desig.o: debug.h desig.o: debug.h
desig.o: debugcst.h desig.o: debugcst.h
desig.o: def.h desig.o: def.h
@ -394,6 +408,8 @@ desig.o: walk.h
desig.o: warning.h desig.o: warning.h
code.o: LLlex.h code.o: LLlex.h
code.o: Lpars.h code.o: Lpars.h
code.o: bigparam.h
code.o: bigresult.h
code.o: debug.h code.o: debug.h
code.o: debugcst.h code.o: debugcst.h
code.o: def.h code.o: def.h
@ -407,6 +423,7 @@ code.o: target_sizes.h
code.o: type.h code.o: type.h
code.o: walk.h code.o: walk.h
lookup.o: LLlex.h lookup.o: LLlex.h
lookup.o: bigparam.h
lookup.o: debug.h lookup.o: debug.h
lookup.o: debugcst.h lookup.o: debugcst.h
lookup.o: def.h lookup.o: def.h
@ -420,6 +437,7 @@ lookup.o: type.h
tokenfile.o: Lpars.h tokenfile.o: Lpars.h
program.o: LLlex.h program.o: LLlex.h
program.o: Lpars.h program.o: Lpars.h
program.o: bigparam.h
program.o: debug.h program.o: debug.h
program.o: debugcst.h program.o: debugcst.h
program.o: def.h program.o: def.h
@ -435,6 +453,7 @@ program.o: type.h
program.o: warning.h program.o: warning.h
declar.o: LLlex.h declar.o: LLlex.h
declar.o: Lpars.h declar.o: Lpars.h
declar.o: bigparam.h
declar.o: chk_expr.h declar.o: chk_expr.h
declar.o: debug.h declar.o: debug.h
declar.o: debugcst.h declar.o: debugcst.h
@ -452,6 +471,7 @@ declar.o: type.h
declar.o: warning.h declar.o: warning.h
expression.o: LLlex.h expression.o: LLlex.h
expression.o: Lpars.h expression.o: Lpars.h
expression.o: bigparam.h
expression.o: chk_expr.h expression.o: chk_expr.h
expression.o: const.h expression.o: const.h
expression.o: debug.h expression.o: debug.h
@ -465,6 +485,7 @@ expression.o: type.h
expression.o: warning.h expression.o: warning.h
statement.o: LLlex.h statement.o: LLlex.h
statement.o: Lpars.h statement.o: Lpars.h
statement.o: bigparam.h
statement.o: def.h statement.o: def.h
statement.o: idf.h statement.o: idf.h
statement.o: nocross.h statement.o: nocross.h
@ -477,6 +498,7 @@ char.o: class.h
Lpars.o: Lpars.h Lpars.o: Lpars.h
casestat.o: LLlex.h casestat.o: LLlex.h
casestat.o: Lpars.h casestat.o: Lpars.h
casestat.o: bigparam.h
casestat.o: chk_expr.h casestat.o: chk_expr.h
casestat.o: debug.h casestat.o: debug.h
casestat.o: debugcst.h casestat.o: debugcst.h
@ -490,6 +512,7 @@ casestat.o: target_sizes.h
casestat.o: type.h casestat.o: type.h
casestat.o: walk.h casestat.o: walk.h
tmpvar.o: LLlex.h tmpvar.o: LLlex.h
tmpvar.o: bigparam.h
tmpvar.o: debug.h tmpvar.o: debug.h
tmpvar.o: debugcst.h tmpvar.o: debugcst.h
tmpvar.o: def.h tmpvar.o: def.h
@ -499,6 +522,7 @@ tmpvar.o: scope.h
tmpvar.o: target_sizes.h tmpvar.o: target_sizes.h
tmpvar.o: type.h tmpvar.o: type.h
scope.o: LLlex.h scope.o: LLlex.h
scope.o: bigparam.h
scope.o: debug.h scope.o: debug.h
scope.o: debugcst.h scope.o: debugcst.h
scope.o: def.h scope.o: def.h

View file

@ -76,3 +76,18 @@
*/ */
!File: bigparam.h
#undef PASS_BIG_VAL_AS_VAR 1 /* define when big value parameters must be
passed as addresses
*/
!File: bigresult.h
#define BIG_RESULT_ON_STACK 1 /* define when function results must be
put on the stack; in this case, caller
reserves space for it. When not defined,
callee puts result in global data area and
returns a pointer to it
*/

View file

@ -30,6 +30,7 @@
#include "Lpars.h" #include "Lpars.h"
#include "standards.h" #include "standards.h"
#include "walk.h" #include "walk.h"
#include "bigresult.h"
extern char *long2str(); extern char *long2str();
extern char *symbol2str(); extern char *symbol2str();
@ -321,11 +322,12 @@ CodeCall(nd)
assert(IsProc(left)); assert(IsProc(left));
if (result_tp = ResultType(left->nd_type)) { result_tp = ResultType(left->nd_type);
if (TooBigForReturnArea(result_tp)) { #ifdef BIG_RESULT_ON_STACK
if (result_tp && TooBigForReturnArea(result_tp)) {
C_asp(-WA(result_tp->tp_size)); C_asp(-WA(result_tp->tp_size));
} }
} #endif
if (nd->nd_right) { if (nd->nd_right) {
CodeParameters(ParamList(left->nd_type), nd->nd_right); CodeParameters(ParamList(left->nd_type), nd->nd_right);
@ -356,9 +358,14 @@ CodeCall(nd)
} }
C_asp(left->nd_type->prc_nbpar); C_asp(left->nd_type->prc_nbpar);
if (result_tp) { if (result_tp) {
arith sz = WA(result_tp->tp_size);
if (TooBigForReturnArea(result_tp)) { if (TooBigForReturnArea(result_tp)) {
#ifndef BIG_RESULT_ON_STACK
C_lfr(pointer_size);
C_loi(sz);
#endif
} }
else C_lfr(WA(result_tp->tp_size)); else C_lfr(sz);
} }
DoFilename(needs_fn); DoFilename(needs_fn);
DoLineno(nd); DoLineno(nd);

View file

@ -226,7 +226,13 @@ extern t_type
(tpx)) (tpx))
#define IsConstructed(tpx) ((tpx)->tp_fund & T_CONSTRUCTED) #define IsConstructed(tpx) ((tpx)->tp_fund & T_CONSTRUCTED)
#define TooBigForReturnArea(tpx) ((tpx)->tp_size > ret_area_size) #define TooBigForReturnArea(tpx) ((tpx)->tp_size > ret_area_size)
#include "bigparam.h"
#ifdef PASS_BIG_VAL_AS_VAR
#define IsBigParamTp(tpx) ((tpx)->tp_size > double_size) #define IsBigParamTp(tpx) ((tpx)->tp_size > double_size)
#else
#define IsBigParamTp(tpx) (0)
#endif PASS_BIG_VAL_AS_VAR
extern long full_mask[]; extern long full_mask[];
extern long max_int[]; extern long max_int[];

View file

@ -38,6 +38,7 @@
#include "walk.h" #include "walk.h"
#include "misc.h" #include "misc.h"
#include "warning.h" #include "warning.h"
#include "bigresult.h"
extern arith NewPtr(); extern arith NewPtr();
extern arith NewInt(); extern arith NewInt();
@ -234,7 +235,7 @@ WalkProcedure(procedure)
register t_scope *procscope = procedure->prc_vis->sc_scope; register t_scope *procscope = procedure->prc_vis->sc_scope;
register t_type *tp; register t_type *tp;
register t_param *param; register t_param *param;
int too_big = 0; /* returnsize larger than returnarea */ label too_big = 0; /* returnsize larger than returnarea */
arith StackAdjustment = 0; /* space for conformant arrays */ arith StackAdjustment = 0; /* space for conformant arrays */
arith retsav = 0; /* temporary space for return value */ arith retsav = 0; /* temporary space for return value */
arith func_res_size = 0; arith func_res_size = 0;
@ -254,11 +255,25 @@ WalkProcedure(procedure)
if (tp) { if (tp) {
func_res_size = WA(tp->tp_size); func_res_size = WA(tp->tp_size);
if (TooBigForReturnArea(tp)) { if (TooBigForReturnArea(tp)) {
/* The result type of this procedure is constructed. #ifdef BIG_RESULT_ON_STACK
/* The result type of this procedure is too big.
The caller will have reserved space on its stack, The caller will have reserved space on its stack,
above the parameters, to store the result. above the parameters, to store the result.
*/ */
too_big = 1; too_big = 1;
#else
/* The result type of this procedure is too big.
The actual procedure will return a pointer to a
global data area in which the function result is
stored.
Notice that this makes the code non-reentrant.
Here, we create the data area for the function
result.
*/
too_big = ++data_label;
C_df_dlb(too_big);
C_bss_cst(func_res_size, (arith)0, 0);
#endif BIG_RESULT_ON_STACK
} }
} }
@ -378,7 +393,11 @@ WalkProcedure(procedure)
/* Fill the data area reserved for the function result /* Fill the data area reserved for the function result
with the result with the result
*/ */
#ifdef BIG_RESULT_ON_STACK
C_lal(procedure->df_type->prc_nbpar); C_lal(procedure->df_type->prc_nbpar);
#else
c_lae_dlb(too_big);
#endif BIG_RESULT_ON_STACK
C_sti(func_res_size); C_sti(func_res_size);
if (StackAdjustment) { if (StackAdjustment) {
/* Remove copies of conformant arrays /* Remove copies of conformant arrays
@ -386,7 +405,12 @@ WalkProcedure(procedure)
LOL(StackAdjustment, pointer_size); LOL(StackAdjustment, pointer_size);
C_str((arith) 1); C_str((arith) 1);
} }
#ifdef BIG_RESULT_ON_STACK
func_res_size = 0; func_res_size = 0;
#else
c_lae_dlb(too_big);
func_res_size = pointer_size;
#endif BIG_RESULT_ON_STACK
} }
else if (StackAdjustment) { else if (StackAdjustment) {
/* First save the function result in a safe place. /* First save the function result in a safe place.
@ -406,8 +430,11 @@ WalkProcedure(procedure)
C_ret(func_res_size); C_ret(func_res_size);
C_beginpart(partno2); C_beginpart(partno2);
C_pro(procscope->sc_name, -procscope->sc_off); C_pro(procscope->sc_name, -procscope->sc_off);
C_ms_par(procedure->df_type->prc_nbpar + C_ms_par(procedure->df_type->prc_nbpar
(too_big ? func_res_size : 0)); #ifdef BIG_RESULT_ON_STACK
+ (too_big ? func_res_size : 0)
#endif
);
if (! options['n']) WalkDefList(procscope->sc_def, RegisterMessage); if (! options['n']) WalkDefList(procscope->sc_def, RegisterMessage);
C_endpart(partno2); C_endpart(partno2);
C_end(-procscope->sc_off); C_end(-procscope->sc_off);
@ -974,9 +1001,11 @@ UseWarnings(df)
warning = "never used/assigned"; warning = "never used/assigned";
break; break;
case D_USED|D_VARPAR: case D_USED|D_VARPAR:
#ifdef PASS_BIG_VAL_AS_VAR
if (df->df_type->tp_fund != T_EQUAL) { if (df->df_type->tp_fund != T_EQUAL) {
warning = "never assigned, could be value parameter"; warning = "never assigned, could be value parameter";
} }
#endif
break; break;
case D_USED: case D_USED:
warning = "never assigned"; warning = "never assigned";