It seems to work to allocate and free registers with a kind of reference counting by membership in an auxilliary list.