PreviousUpNext

15.3.148  src/lib/compiler/back/low/regor/pick-available-hardware-register.api

## pick-available-hardware-register.api
#
# During register allocation, when the time arrives to assign
# a codetemp to a specific hardware register, there will often
# be several possibilities, and also a preference for some
# registers over others if both are available.
#
# This API defines access to strategy modules for deciding
# which register to pick in such cases.  This isn't rocket
# science; our current two strategies are
#
#  1) Just scan the registers in order and pick the first free one.
#  2) Scan circularly around the registers, each time picking up where
#     we left off, and return first free one.
#
# (In both cases we check preferred registers first, if any.)
# Currently we use strategy 2); in such situations it is usually
# a bit of a win to de-correlate our choices. (A pseudo-random
# strategy might be slightly better -- might be worth trying sometime.)

# Compiled by:
#     src/lib/compiler/back/low/lib/lowhalf.lib


stipulate
    package rwv = rw_vector;                                                            # rw_vector             is from   src/lib/std/src/rw-vector.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/compiler/back/low/regor/pick-available-hardware-register-by-first-available-g.pkg
    #     src/lib/compiler/back/low/regor/pick-available-hardware-register-by-round-robin-g.pkg
    #
    api Pick_Available_Hardware_Register {
        #
        exception GET_REGISTER;

        reset_register_picker_state:  Void -> Void;

        pick_available_hardware_register
          :
          { preferred_registers:        List( Int ),
            register_is_taken:          rwv::Rw_Vector( Int ),
            true_value:                 Int                                                     # Speedhack: register is taken iff:    register_is_taken[ register ] == true_value.
          }
          -> Int; 
          #
          # Get a register, unconstrained but with optional preference 
          # if sub (prohibitions, r) = stamp that means the register is prohibited 


        pick_available_hardware_registerpair                                                    # This is a stillborn idea -- never used.
          :
          { preferred_registers:        List( Int ),
            register_is_taken:          rwv::Rw_Vector( Int ),
            true_value:                 Int                                                     # Speedhack: register is taken iff:    register_is_taken[ register ] == true_value.
          }
          -> Int;
          #
          # Get a registerpair, must be an even/odd pair, returns the
          # even register (i.e. the smaller one)
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext