#include <memorymodel.h>
Public Methods | |
memoryModel () | |
Create a new memory model. More... | |
~memoryModel () | |
Delete the memory model. More... | |
void | clear () |
Clear. More... | |
const memoryblock_map & | memory () const |
Get the list of memoryBlocks. More... | |
memoryBlock * | null () const |
Return the null object. More... | |
memoryBlock * | lookup (Location *location, declNode *decl) |
Look up a memory memoryBLock. More... | |
memoryBlock * | lookup_variable (Location *location, declNode *decl, procNode *local_to) |
Look up or create a memoryBlock. More... | |
memoryBlock * | generate_heap_object (const string &name, Location *location) |
Generate a heap object. More... | |
memoryBlock * | generate_su_field (const string &field_name, declNode *field_decl, memoryBlock *container) |
Generate a struct/union field. More... | |
void | update_def_use_chains () |
Update def-use chains. More... | |
void | stats (ostream &out) |
Print statistics. More... | |
void | print (ostream &o) const |
Private Types | |
typedef pair< Location *, declNode * > | memorymodel_key |
typedef map< memorymodel_key, memoryBlock *> | memoryblock_map |
typedef memoryblock_map::iterator | memoryblock_map_p |
typedef memoryblock_map::const_iterator | memoryblock_map_cp |
Private Methods | |
memoryBlock * | create_memory_object (Location *location, declNode *decl, bool synthetic_decl, memoryBlock *container, procNode *local_to) |
Create a new memory object. More... | |
void | generate_array_elements_for (memoryBlock *array_object) |
Generate array elements. More... | |
Private Attributes | |
TREE memoryblock_map | Memory |
the memoryBlocks. More... | |
int | Counter |
a counter to generate unique names. More... | |
memoryBlock * | Null |
special "null" object. More... |
|
|
|
|
|
|
|
|
|
Create a new memory model.
|
|
Delete the memory model. This also deallocates all memoryBlock objects created in this model. |
|
Clear. Visit all memoryBlocks and call clear, preparing for reanalysis. |
|
Create a new memory object. Create a new object that represents some entity in memory. These objects are indexed by the declaration node and the location given. In addition, we need the declaration node for built-in arrays, so that we can create the objects to represent the elements. The synthetic_decl flag indicates that the declNode passed was created just to distinguish this object. |
|
Generate array elements. For built-in arrays, we generate a single object for each dimension of the array. For example, int A[3][4][5] Results in A --> A_el_1 --> A_el_2 --> A_el_3 That way A[1][3] evaluates to A_el_2, as does *(A[1]) and **A. This structure is represented by storing the element as a field of the array object. We then add a special def that also causes the array to point-to it's element. |
|
Generate a heap object. Create a new memoryBlock that represents a memory object without an explicit declaration in the program. For example, heap allocated memory. This routine creates a synthetic declNode for the object. |
|
Generate a struct/union field. Given a field declaration and the container object, generate an object for the field. We use the type information from the field declaration to detect and handle fields that are arrays. The field_decl can be ommited. The method actually generates a new unique declNode for the object. |
|
Look up a memory memoryBLock. Look up a memoryblock, returning "null" if it's not found. |
|
Look up or create a memoryBlock. Create the memory block if it's not found. Also, when creating a new memory block, if it's a built-in array, then create objects for the elements. |
|
Get the list of memoryBlocks.
|
|
Return the null object.
|
|
|
|
Print statistics.
|
|
Update def-use chains. At the end of pointer analysis, call this method to populate the definition uses on each memoryDef. Only call this once! |
|
a counter to generate unique names.
|
|
the memoryBlocks. All memoryBlocks are stored and managed by the memoryModel object. They are indexed by combining their declaration with a program location. A synthetic declaration is generated for dynamic objects. |
|
special "null" object.
|