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 int, const int, const int);
00044
00045 void memoryRegister_destruct (ExpandableTable * restrict );
00046
00047 void memoryRegister_expand (ExpandableTable * restrict, const int);
00048
00049 void memoryRegister_push (ExpandableTable * restrict, const int, const char * const restrict );
00050
00051 void memoryRegister_pop (ExpandableTable * restrict, const int, const char * const restrict );
00052
00053 void memoryRegister_pack (ExpandableTable * restrict);
00054
00063 static inline MemRegElement
00064 memoryRegister_find (const ExpandableTable * restrict table, const int sp, const int dp,
00065 const char * const pointer)
00066 {
00067 int count;
00068 const MemRegElement * restrict array;
00069 const int srccol = table->rows * sp;
00070 const int dstcol = table->rows * dp;
00071 array = (MemRegElement *) table->data + srccol;
00072 for ( count = table->count[sp]-1; count >= 0; count--)
00073 {
00074 if (array[count] == pointer && !table->info.reg.removed[count])
00075 return *(array + count - srccol + dstcol);
00076 }
00077 bsp_intern_abort (ERR_POP_REG_WITHOUT_PUSH, __func__, __FILE__, __LINE__);
00078 return NULL;
00079 }
00080
00090 static inline MemRegElement
00091 memoryRegister_memoized_find (const ExpandableTable * restrict table, const int dp,
00092 const char * const pointer)
00093 {
00094 const int dstcol = table->rows * dp;
00095 const MemRegElement * restrict data_iter = table->info.reg.memoized_data_iter;
00096
00097
00098 while(*data_iter != pointer)
00099 data_iter--;
00100
00101 return *(data_iter - table->info.reg.memoized_srccol + dstcol);
00102 }
00103
00104 #endif