00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #ifndef BSP_MEMREG_H
00036 #define BSP_MEMREG_H
00037 #include <stdlib.h>
00038 #include "bsp_abort.h"
00039 #include "bsp_exptable.h"
00040 #include <config.h>
00041
00042 void
00043 memoryRegister_initialize (ExpandableTable * restrict , const unsigned int,
00044 const unsigned int, const unsigned int);
00045
00046 void memoryRegister_destruct (ExpandableTable * restrict );
00047
00048 void memoryRegister_expand (ExpandableTable * restrict, const unsigned int);
00049
00050 void memoryRegister_push (ExpandableTable * restrict, const unsigned int, const char * const restrict );
00051
00052 void memoryRegister_pop (ExpandableTable * restrict, const unsigned int, const char * const restrict );
00053
00054 void memoryRegister_pack (ExpandableTable * restrict);
00055
00064 static inline MemRegElement
00065 memoryRegister_find (const ExpandableTable * restrict table,
00066 const unsigned int sp, const unsigned int dp,
00067 const char * const pointer)
00068 {
00069 int count;
00070 const MemRegElement * restrict array;
00071 const unsigned int srccol = table->rows * sp;
00072 const unsigned int dstcol = table->rows * dp;
00073 array = (MemRegElement *) table->data + srccol;
00074 for ( count = table->used_slot_count[sp]-1; count >= 0; count--)
00075 {
00076 if (array[count] == pointer && !table->info.reg.removed[count])
00077 return *(array + count - srccol + dstcol);
00078 }
00079 bsp_intern_abort (ERR_POP_REG_WITHOUT_PUSH, __func__, __FILE__, __LINE__);
00080 return NULL;
00081 }
00082
00092 static inline MemRegElement
00093 memoryRegister_memoized_find (const ExpandableTable * restrict table,
00094 const unsigned int dp, const char * const pointer)
00095 {
00096 const unsigned int dstcol = table->rows * dp;
00097 const MemRegElement * restrict data_iter = table->info.reg.memoized_data_iter;
00098
00099
00100 while(*data_iter != pointer)
00101 data_iter--;
00102
00103 return *(data_iter - table->info.reg.memoized_srccol + dstcol);
00104 }
00105
00106 #endif