memoryModel Class Reference#include <memorymodel.h>
List of all members.
|
Public Types |
typedef pair< Location *,
declNode * > | memorymodel_key |
typedef map< memorymodel_key,
memoryBlock * > | memorymodel_map |
typedef memorymodel_map::iterator | memorymodel_map_p |
typedef memorymodel_map::const_iterator | memorymodel_map_cp |
typedef map< procNode *, memorymodel_map > | proc_memorymodel_map |
typedef proc_memorymodel_map::iterator | proc_memorymodel_map_p |
typedef proc_memorymodel_map::const_iterator | proc_memorymodel_map_cp |
typedef pair< stmtNode *,
declNode * > | ci_memorymodel_key |
typedef map< ci_memorymodel_key,
memoryBlock * > | ci_memorymodel_map |
typedef ci_memorymodel_map::iterator | ci_memorymodel_map_p |
typedef ci_memorymodel_map::const_iterator | ci_memorymodel_map_cp |
typedef map< constNode *,
memoryBlock * > | string_constant_map |
typedef string_constant_map::iterator | string_constant_map_p |
Public Member Functions |
| memoryModel () |
| Create a new memory model.
|
| ~memoryModel () |
| Delete the memory model.
|
void | clear () |
| Clear.
|
int | size () |
| Get the number of memory blocks.
|
memoryBlock * | null () const |
| Get the list of memoryBlocks Return the null object.
|
UnificationBasedPtr * | unification () const |
| Get unification-based analyzer.
|
void | unification (UnificationBasedPtr *u) |
| Set unification-based analyzer.
|
memoryBlock * | lookup (Location *location, declNode *decl) |
| Look up a memoryBLock.
|
memoryBlock * | lookup (stmtNode *location, declNode *decl) |
| Look up a CI memoryBLock.
|
memoryBlock * | lookup_variable (Location *location, declNode *decl, procNode *local_to) |
| Look up a variable.
|
memoryBlock * | lookup_heap_object (const string &name, stmtLocation *allocation_site, stmtNode *allocation_stmt, declNode *decl, bool synthetic_decl) |
| Look up or create a heap object.
|
memoryBlock * | lookup_string_constant (constNode *the_string) |
| Look up string constant.
|
memoryBlock * | generate_su_field (const string &field_name, declNode *field_decl, memoryBlock *container) |
| Generate a struct/union field.
|
void | update_def_use_chains () |
| Update def-use chains.
|
int | counter () |
| Counter.
|
void | stats (ostream &out) |
| Print statistics.
|
void | print (ostream &o) const |
Static Public Member Functions |
static bool | is_in_non_unify_list (UnifyTypes &non_unify_types, UnifyType *obj) |
| Find in unify list.
|
Private Member Functions |
memoryBlock * | create_memory_object (Location *location, declNode *decl, bool synthetic_decl, memoryBlock *container, procNode *local_to, declNode *org_field_decl=0, bool is_alloc=false, bool is_array_elt=false) |
| Create a new memory object.
|
memoryBlock * | create_memory_object (stmtNode *location, declNode *decl, bool synthetic_decl, memoryBlock *container, procNode *local_to, bool is_alloc=false) |
| Create a CI memory block.
|
void | generate_array_elements_for (memoryBlock *array_object) |
| Generate array elements.
|
void | initialize_struct (memoryBlock *struct_object, sueNode *sue_type, expr_list &inits) |
| Initialize struct.
|
Private Attributes |
TREE proc_memorymodel_map | _memory_blocks |
| the memoryBlocks
|
TREE ci_memorymodel_map | _ci_memory_blocks |
| Context-insensitive memory.
|
string_constant_map | _string_constants |
| String constants.
|
int | Counter |
| a counter to generate unique names
|
memoryBlock * | Null |
| special "null" object
|
memoryBlock * | _string_constant |
| String constant object.
|
UnificationBasedPtr * | _unification_based |
| Unification-based analyzer.
|
map< declNode *, declNode * > | _copy_decl |
| Remember where a copy declaration originates from.
|
Member Typedef Documentation
Constructor & Destructor Documentation
memoryModel::memoryModel |
( |
|
) |
|
|
|
Create a new memory model.
|
memoryModel::~memoryModel |
( |
|
) |
|
|
|
Delete the memory model.
This also deallocates all memoryBlock objects created in this model. |
Member Function Documentation
void memoryModel::clear |
( |
|
) |
|
|
|
Clear.
Visit all memoryBlocks and call clear, preparing for reanalysis. |
int memoryModel::counter |
( |
|
) |
[inline] |
|
|
Create a CI memory block.
|
|
Create a new memory object.
Create a new object that represents some entity in memory. These objects are indexed by the location and Node given. For regular variables, this Node will be the same as the declNode. However, for heap objects and strings constants, we will use other kinds of nodes to distinguish them. In addition, we need the declaration node for built-in arrays, so that we can create the objects to represent the elements.
This is the only function that creates new memoryBlocks and stores them in the memory model.
The synthetic_decl flag indicates that the declNode passed was created just to distinguish this object. |
void memoryModel::generate_array_elements_for |
( |
memoryBlock * |
array_object |
) |
[private] |
|
|
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 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. |
|
Initialize struct.
Assign static initializers to a newly created struct. |
static bool memoryModel::is_in_non_unify_list |
( |
UnifyTypes & |
non_unify_types, |
|
|
UnifyType * |
obj |
|
) |
[static] |
|
|
Find in unify list.
Return true if the block is identified in the given list. |
|
Look up a CI memoryBLock.
Look up a memoryblock, returning "null" if it's not found. |
|
Look up a memoryBLock.
Look up a memoryblock, returning "null" if it's not found. |
|
Look up or create a heap object.
Lookup a heap object based on the given location and Node key. If it's not found, create a new one. The declaration can be NULL, in which case a synthetic declNode will be created using the name. |
|
Look up string constant.
String constants are indexed by their constNode. |
|
Look up a variable.
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.
Definition at line 148 of file memorymodel.h.
References Null. |
void memoryModel::print |
( |
ostream & |
o |
) |
const |
|
int memoryModel::size |
( |
|
) |
|
|
|
Get the number of memory blocks.
|
void memoryModel::stats |
( |
ostream & |
out |
) |
|
|
void memoryModel::update_def_use_chains |
( |
|
) |
|
|
|
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! |
Member Data Documentation
|
Context-insensitive memory.
We use this map to store memoryBlocks that are indexed by the stmtNode, not the location. This is only used in Context_insensitive_memory mode.
Definition at line 88 of file memorymodel.h. |
|
Remember where a copy declaration originates from.
Definition at line 116 of file memorymodel.h. |
|
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.
Definition at line 80 of file memorymodel.h. |
|
String constant object.
When we have the one-string-constant option trurned on, this holds a pointer to that object.
Definition at line 110 of file memorymodel.h. |
|
String constants.
Create a separate repository of string constants, indexed by their constNodes
Definition at line 95 of file memorymodel.h. |
The documentation for this class was generated from the following file:
|