| parrotcode: Some utility functions | |
| Contents | C |

src/utils.c - Some utility functions

Prototypes are in src/misc.h.
Opcode helper functions that don't really fit elsewhere.

INTVAL intval_mod x mod y = x - y * floor(x / y)
FLOATVAL floatval_modn2 mod n3.lcc compiler.
Based on the rand48() family of functions.
static void next_randX.static FLOATVAL _erand48double in the interval [0.0, 1.0).static FLOATVAL _drand48double in the interval [0.0, 1.0).static long _jrand48long in the interval [-2^31, 2^31).static long _nrand48long in the interval [0, 2^31).static long _lrand48long in the interval [0, 2^31).static long _mrand48long in the interval [-2^31, 2^31).static void _srand48seed. The low order 16 bits are set to the arbitrary value 0x330e.FLOATVAL Parrot_float_randFLOATVAL in the interval [0.0, 1.0).how_random is ignored.INTVAL Parrot_uint_randINTVAL in the interval [0, 2^31).how_random is ignored.INTVAL Parrot_int_randINTVAL in the interval [-2^31, 2^31).how_random is ignored.INTVAL Parrot_range_randINTVAL in the range [from, to].how_random is ignored.void Parrot_srandseed.PMC *tm_to_arrayINTVAL Parrot_byte_indexINTVAL Parrot_byte_rindexstatic void rec_climb_back_and_mark node_index ... the index of a destination (i.e. with a pred.) register
c ... the graph and all the needed params : the context
static void process_cycle_without_exit node_index ... the index of a destination (i.e. with a pred.) register
c ... the graph and all the needed params : the context
void Parrot_register_moven_regs from the given register list src_regs to dest_regs. n_regs ... amount of registers to move
dest_regs ... list of register numbers 0..255
src_regs ... list of register numbers 0..255
temp_reg ... a register number not in one of these lists
mov ... a register move function to be called to move one register
mov_alt ... a register move function to be called to move one register
which triese fetching from an alternate src (or NULLfunc):
(void) (mov)(interp, dest, src, info);
moved = (mov_alt)(interp, dest, src, info);
dest_regs might be the same as src_regs, which makes this a bit non-trivial, because if the destination is already clobbered, using it later as source doesn"t work. E.g. 0 <- 1
1 <- 0 # register 0 already clobbered
2 <- 0
0 <- 1
3 <- 2 # register 2 already clobbered - reorder moves
a) rearrange the order of moves (not possible in the first case)
and/or if that failed:
b) if an alternate move function is available, it may fetch the
source from a different (non-clobbered) location - call it.
if the function returns 0 also use c)
c) if no alternate move function is available, use the temp reg

Initial version by leo 2003.09.09.
|
|
|