NAME ^

compilers/imcc/symreg.c

DESCRIPTION ^

imcc symbol handling

XXX: SymReg stuff has become overused. SymReg should be for symbolic registers, reg allocation, etc. but we are now using it for extensive symbol table management. Need to convert much of this over the use Symbol and SymbolTable (see symbol.h and symbol.c)

Functions ^

void push_namespace

RT#48260: Not yet documented!!!

void pop_namespace

RT#48260: Not yet documented!!!

static SymReg *_get_sym_typed

Gets a symbol from the hash

static SymReg *_mk_symreg

Makes a new SymReg from its varname and type.

SymReg *mk_symreg

RT#48260: Not yet documented!!!

char *symreg_to_str

Dump a SymReg to a printable format.

SymReg *mk_temp_reg

RT#48260: Not yet documented!!!

SymReg *mk_pcc_sub

RT#48260: Not yet documented!!!

void add_namespace

add current namespace to sub decl

void add_pcc_arg

Add a register or constant to the function arg list

void add_pcc_param

RT#48260: Not yet documented!!!

void add_pcc_result

RT#48260: Not yet documented!!!

void add_pcc_multi

RT#48260: Not yet documented!!!

void add_pcc_return

RT#48260: Not yet documented!!!

void add_pcc_sub

RT#48260: Not yet documented!!!

void add_pcc_cc

RT#48260: Not yet documented!!!

SymReg *mk_pasm_reg

RT#48260: Not yet documented!!!

static char *_mk_fullname

Combines the namespace and name together, separated by a ::. If there's no namespace, the name is returned on its own.

The returned string must be free()d.

SymReg *mk_ident

Makes a new identifier.

SymReg *mk_ident_ur

RT#48260: Not yet documented!!!

static SymReg *mk_pmc_const_2

RT#48260: Not yet documented!!!

SymReg *mk_const_ident

Makes a new identifier constant with value val

SymReg *_mk_const

Makes a new constant

SymReg *mk_const

RT#48260: Not yet documented!!!

static char *add_ns

add namespace to sub if any

SymReg *_mk_address

Makes a new address

SymReg *mk_sub_label

Make and store a new address label for a sub. Label gets a fixup entry.

SymReg *mk_sub_address

Make a symbol for a label, symbol gets a fixup entry.

SymReg *mk_local_label

Make a local symbol, no fixup entry.

SymReg *mk_label_address

Wrapper for _mk_address.

SymReg *dup_sym

link keys to a keys structure = SymReg

we might have

what op type pbc.c:build_key() -------------------------------------------------- int const _kic VTCONST no int reg _ki VTREG no str const _kc VTCONST yes str reg _kc VTREG yes

 "key" ';' "key" _kc           -> (list of above)   yes
 "key" ';' $I0   _kc  VTREGKEY -> (list of above)   yes

 The information about which reg should be passed to build_key() is
 in the instruction.

 A key containing a variable has a special flag VTREGKEY
 because this key must be considered for life analysis for
 all the chain members, that are variables.

 An instruction with a keychain looks like this

 e.h. set I0, P["abc";0;I1]

 ins->r[2]  = keychain  'K'
 keychain->nextkey = SymReg(VTCONST) "abc"
             ->nextkey = SymReg(VTCONST) 0
                ->nextkey = SymReg(VTREG), ...->reg = VTVAR I1
                   ->nextkey = 0

 We can't use the consts or keys in the chain directly,
 because a different usage would destroy the ->nextkey pointers
 so these are all copies.
 XXX and currently not freed
SymReg *link_keys

RT#48260: Not yet documented!!!

void free_sym

Free all memory of the specified SymReg. If it has a pcc_sub_t entry, free all memory of that structure as well.

void create_symhash

Create a symbol hash table with space for 16 entries.

static void resize_symhash

Resize a symbol hash table.

void _store_symreg

Stores a symbol into the hash

void store_symreg

Wrapper for _store_symreg.

SymReg *_get_sym

Gets a symbol from the hash

SymReg *get_sym

Gets a symbol from the current unit symbol table

SymReg *_find_sym

find a symbol hash or ghash

SymReg *find_sym

Wrapper for _find_sym; only if there's a current IMC_Unit, will _find_sym be invoked; otherwise NULL is returned.

void clear_sym_hash

Free all memory of the symbols in the specified hash table.

void debug_dump_sym_hash

Print all identifiers in the specified hash table.

void clear_locals

Deletes all local symbols and clears life info

void clear_globals

Clear global symbols

unsigned int hash_str

Compute the hash value for the string argument.


parrot