#ifndef _rename_alloc_fs
#define _rename_alloc_fs
/******************************************************************************
** FILE: rename_alloc.fs
** Restrict the number of available physical registers.
*/
#include "param.h"
#include "rename_regs.h"
#include "rename_types.fs"
#include "rename_data.fs"
///////////////////////////////////////////////////////////////////////////////
// Limit the quantity of physical registers in use.
// rmap_alloc() -- reserve a physical register
// rmap_free() -- return register to free pool
//
fun rmap_alloc(rtype,num)
{
val preg = rtype_to_preg_map[rtype];
val num2 = num_regs_allocated[preg] + num;
if(num2 > num_physical_regs[preg]) return false;
num_regs_allocated[preg] = num2;
return true;
}
fun rmap_free(rtype,num)
{
val preg = rtype_to_preg_map[rtype];
assert(num_regs_allocated[preg] >= num);
num_regs_allocated[preg] = num_regs_allocated[preg] - num;
}
#endif