/* Copyright (c) 1979 Regents of the University of California */
static char sccsid
[] = "@(#)tmps.c 1.5 6/1/81";
* This routine defines the register allocation strategy
* All temporaries are allocated here, and this routines decides
* where they are to be put.
* allocate runtime temporary variables
tmpalloc(size
, type
, mode
)
register struct om
*op
= &sizes
[ cbn
];
if (mode
== REGOK
&& size
>= MINREGSIZE
&& size
<= MAXREGSIZE
&&
op
->curtmps
.reg_off
< MAXREGS
) {
offset
= op
->curtmps
.reg_off
++;
if ( offset
> op
->reg_max
) {
nlp
= defnl( 0 , VAR
, type
, offset
+ FIRSTREG
);
nlp
-> extra_flags
= NLOCAL
| NREGVAR
;
offset
= op
->curtmps
.om_off
-= leven( size
);
if ( offset
< op
->om_max
) {
nlp
= defnl( 0 , VAR
, type
, offset
);
nlp
-> extra_flags
= NLOCAL
;
putlbracket( ftnno
, -offset
);
* deallocate runtime temporary variables
register struct tmps
*restore
;
register struct om
*op
= &sizes
[ cbn
];
if (restore
->reg_off
< op
->curtmps
.reg_off
) {
op
->curtmps
.reg_off
= restore
->reg_off
;
if (restore
->om_off
> op
->curtmps
.om_off
) {
op
->curtmps
.om_off
= restore
->om_off
;
putlbracket( ftnno
, -restore
->om_off
);
* create a save mask for registers which have been used
for (i
= 0; i
<= sizes
[ cbn
].reg_max
; i
++)
mask
|= 1 << (FIRSTREG
+ i
);