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))

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

PARROT_WARN_UNUSED_RESULT static int old_blocks(void)

get size/line of bytecode in ops till now

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

TODO: Not yet documented!!!

static void make_new_sub(NOTNULL(IMC_Unit *unit))

allocate a new globals.cs->subs structure

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)

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

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

TODO: 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

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

get a global label, return the pc (absolute)

static void fixup_globals(PARROT_INTERP)

fix global stuff

STRING *IMCC_string_from_reg(PARROT_INTERP, NOTNULL(const SymReg *r))

TODO: Not yet documented!!!

static int add_const_str(PARROT_INTERP, NOTNULL(const SymReg *r))

add constant string to constant_table

static int add_const_num(PARROT_INTERP, const char *buf)

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

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

add constant key to constant_table

PARROT_CONST_FUNCTION static const char *slice_deb(int bits)

TODO: 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, NOTNULL(const SymReg *r))

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

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

TODO: 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))

TODO: Not yet documented!!!

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

TODO: Not yet documented!!!

static void verify_signature(PARROT_INTERP, NOTNULL(const Instruction *ins), 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), NOTNULL(const Instruction *ins))

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

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

TODO: Not yet documented!!!


parrot