NAME ^

compilers/imcc/pbc.c

DESCRIPTION ^

emit imcc instructions into Parrot interpreter

the e_pbc_emit function is called per instruction

Notes:

I'm using existing data structures here (SymReg*) to store various global items (currently only PMC constants). The index in the constant table is in SymReg* ->color data member. This looks odd, but the register number from imc.c:allocate is also there for variables, so it's a little bit consistent at least.

So when reading color here it's either a constant table index or a Parrot register number, depending on data type.

TODO memory clean up

-lt

Functions ^

static void imcc_globals_destroy(SHIM_INTERP, SHIM(int ex), SHIM(void *param))

RT#48260: Not yet documented!!!

int e_pbc_open(PARROT_INTERP, SHIM(void *param))

RT#48260: Not yet documented!!!

PARROT_WARN_UNUSED_RESULT static int old_blocks(void)

get size/line of bytecode in ops till now

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL opcode_t *make_jit_info(PARROT_INTERP, NOTNULL(IMC_Unit *unit))

RT#48260: Not yet documented!!!

static void make_new_sub(NOTNULL(IMC_Unit *unit))

allocate a new globals.cs->subs structure

PARROT_WARN_UNUSED_RESULT static int get_old_size(PARROT_INTERP, NOTNULL(int *ins_line))

get size/line of bytecode in ops till now

static void store_sub_size(size_t size, size_t ins_line)

RT#48260: Not yet documented!!!

static void store_fixup(PARROT_INTERP, NOTNULL(SymReg *r), int pc, int offset)

RT#48260: Not yet documented!!!

static void store_key_const(ARGIN(const char *str), int idx)

RT#48260: Not yet documented!!!

PARROT_WARN_UNUSED_RESULT static int get_codesize(PARROT_INTERP, NOTNULL(IMC_Unit *unit), NOTNULL(int *src_lines))

store globals for later fixup return size in ops

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static subs_t *find_global_label(ARGIN(const char *name), ARGIN(const subs_t *sym), NOTNULL(int *pc))

get a global label, return the pc (absolute)

static void fixup_globals(PARROT_INTERP)

fix global stuff

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL STRING *IMCC_string_from_reg(PARROT_INTERP, ARGIN(const SymReg *r))

RT#48260: Not yet documented!!!

PARROT_WARN_UNUSED_RESULT static int add_const_str(PARROT_INTERP, ARGIN(const SymReg *r))

add constant string to constant_table

PARROT_WARN_UNUSED_RESULT static int add_const_num(PARROT_INTERP, ARGIN_NULLOK(const char *buf))

RT#48260: Not yet documented!!!

PARROT_CANNOT_RETURN_NULL PARROT_MALLOC static PMC *mk_multi_sig(PARROT_INTERP, NOTNULL(SymReg *r))

RT#48260: Not yet documented!!!

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static PMC *create_lexinfo(PARROT_INTERP, NOTNULL(IMC_Unit *unit), NOTNULL(PMC *sub), int need_lex)

RT#48260: Not yet documented!!!

PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static PMC *find_outer(PARROT_INTERP, NOTNULL(IMC_Unit *unit))

RT#48260: Not yet documented!!!

static int add_const_pmc_sub(PARROT_INTERP, NOTNULL(SymReg *r), int offs, int end)

RT#48260: Not yet documented!!!

static int add_const_key(PARROT_INTERP, NOTNULL(opcode_t key[]), int size, ARGIN(const char *s_key))

add constant key to constant_table

PARROT_CONST_FUNCTION PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static const char *slice_deb(int bits)

RT#48260: Not yet documented!!!

static opcode_t build_key(PARROT_INTERP, NOTNULL(SymReg *key_reg))

color is a Parrot register number or a constant table index

for the rest, please consult PDD08_KEYS(1)

additionally, I build a string representation of the key, which gets cached in the globals.keys

INTVAL IMCC_int_from_reg(PARROT_INTERP, ARGIN(const SymReg *r))

RT#48260: Not yet documented!!!

static void make_pmc_const(PARROT_INTERP, NOTNULL(SymReg *r))

RT#48260: Not yet documented!!!

static void add_1_const(PARROT_INTERP, NOTNULL(SymReg *r))

RT#48260: Not yet documented!!!

static void constant_folding(PARROT_INTERP, NOTNULL(IMC_Unit *unit))

store a constants idx for later reuse

int e_pbc_new_sub(SHIM_INTERP, SHIM(void *param), NOTNULL(IMC_Unit *unit))

RT#48260: Not yet documented!!!

int e_pbc_end_sub(PARROT_INTERP, SHIM(void *param), NOTNULL(IMC_Unit *unit))

RT#48260: Not yet documented!!!

static void verify_signature(PARROT_INTERP, ARGIN(const Instruction *ins), NOTNULL(opcode_t *pc))

 - check if any get_ argument contains constants
 - fill in type bits for argument types and constants, if missing
int e_pbc_emit(PARROT_INTERP, SHIM(void *param), NOTNULL(IMC_Unit *unit), ARGIN(const Instruction *ins))

now let the fun begin, actually emit code for one ins

int e_pbc_close(PARROT_INTERP, SHIM(void *param))

RT#48260: Not yet documented!!!


parrot