C-Breeze
C Compiler Infrastructure

[ Project home page]

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_mapproc_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.
memoryBlocknull () const
 Get the list of memoryBlocks Return the null object.
UnificationBasedPtrunification () const
 Get unification-based analyzer.
void unification (UnificationBasedPtr *u)
 Set unification-based analyzer.
memoryBlocklookup (Location *location, declNode *decl)
 Look up a memoryBLock.
memoryBlocklookup (stmtNode *location, declNode *decl)
 Look up a CI memoryBLock.
memoryBlocklookup_variable (Location *location, declNode *decl, procNode *local_to)
 Look up a variable.
memoryBlocklookup_heap_object (const string &name, stmtLocation *allocation_site, stmtNode *allocation_stmt, declNode *decl, bool synthetic_decl)
 Look up or create a heap object.
memoryBlocklookup_string_constant (constNode *the_string)
 Look up string constant.
memoryBlockgenerate_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

memoryBlockcreate_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.
memoryBlockcreate_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
memoryBlockNull
 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

typedef pair< stmtNode *, declNode * > memoryModel::ci_memorymodel_key
 

Definition at line 61 of file memorymodel.h.

typedef map< ci_memorymodel_key , memoryBlock *> memoryModel::ci_memorymodel_map
 

Definition at line 63 of file memorymodel.h.

typedef ci_memorymodel_map::const_iterator memoryModel::ci_memorymodel_map_cp
 

Definition at line 65 of file memorymodel.h.

typedef ci_memorymodel_map::iterator memoryModel::ci_memorymodel_map_p
 

Definition at line 64 of file memorymodel.h.

typedef pair< Location *, declNode * > memoryModel::memorymodel_key
 

Definition at line 51 of file memorymodel.h.

typedef map< memorymodel_key , memoryBlock *> memoryModel::memorymodel_map
 

Definition at line 53 of file memorymodel.h.

typedef memorymodel_map::const_iterator memoryModel::memorymodel_map_cp
 

Definition at line 55 of file memorymodel.h.

typedef memorymodel_map::iterator memoryModel::memorymodel_map_p
 

Definition at line 54 of file memorymodel.h.

typedef map< procNode *, memorymodel_map > memoryModel::proc_memorymodel_map
 

Definition at line 57 of file memorymodel.h.

typedef proc_memorymodel_map::const_iterator memoryModel::proc_memorymodel_map_cp
 

Definition at line 59 of file memorymodel.h.

typedef proc_memorymodel_map::iterator memoryModel::proc_memorymodel_map_p
 

Definition at line 58 of file memorymodel.h.

typedef map< constNode *, memoryBlock *> memoryModel::string_constant_map
 

Definition at line 68 of file memorymodel.h.

typedef string_constant_map::iterator memoryModel::string_constant_map_p
 

Definition at line 69 of file memorymodel.h.


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]
 

Counter.

Get the counter and increment it.

Definition at line 231 of file memorymodel.h.

References Counter.

memoryBlock* memoryModel::create_memory_object stmtNode location,
declNode decl,
bool  synthetic_decl,
memoryBlock container,
procNode local_to,
bool  is_alloc = false
[private]
 

Create a CI memory block.

memoryBlock* memoryModel::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
[private]
 

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.

memoryBlock* memoryModel::generate_su_field const string &  field_name,
declNode field_decl,
memoryBlock container
 

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.

void memoryModel::initialize_struct memoryBlock struct_object,
sueNode sue_type,
expr_list inits
[private]
 

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.

memoryBlock* memoryModel::lookup stmtNode location,
declNode decl
 

Look up a CI memoryBLock.

Look up a memoryblock, returning "null" if it's not found.

memoryBlock* memoryModel::lookup Location location,
declNode decl
 

Look up a memoryBLock.

Look up a memoryblock, returning "null" if it's not found.

memoryBlock* memoryModel::lookup_heap_object const string &  name,
stmtLocation allocation_site,
stmtNode allocation_stmt,
declNode decl,
bool  synthetic_decl
 

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.

memoryBlock* memoryModel::lookup_string_constant constNode the_string  ) 
 

Look up string constant.

String constants are indexed by their constNode.

memoryBlock* memoryModel::lookup_variable Location location,
declNode decl,
procNode local_to
 

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.

memoryBlock* memoryModel::null  )  const [inline]
 

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  ) 
 

Print statistics.

void memoryModel::unification UnificationBasedPtr u  )  [inline]
 

Set unification-based analyzer.

Definition at line 156 of file memorymodel.h.

References _unification_based.

UnificationBasedPtr* memoryModel::unification  )  const [inline]
 

Get unification-based analyzer.

Definition at line 152 of file memorymodel.h.

References _unification_based.

Referenced by Pointers::use_unification_analyzer().

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

TREE ci_memorymodel_map memoryModel::_ci_memory_blocks [private]
 

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.

map<declNode*,declNode*> memoryModel::_copy_decl [private]
 

Remember where a copy declaration originates from.

Definition at line 116 of file memorymodel.h.

TREE proc_memorymodel_map memoryModel::_memory_blocks [private]
 

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.

memoryBlock* memoryModel::_string_constant [private]
 

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_constant_map memoryModel::_string_constants [private]
 

String constants.

Create a separate repository of string constants, indexed by their constNodes

Definition at line 95 of file memorymodel.h.

UnificationBasedPtr* memoryModel::_unification_based [private]
 

Unification-based analyzer.

Definition at line 113 of file memorymodel.h.

Referenced by unification().

int memoryModel::Counter [private]
 

a counter to generate unique names

Definition at line 99 of file memorymodel.h.

Referenced by counter().

memoryBlock* memoryModel::Null [private]
 

special "null" object

Definition at line 103 of file memorymodel.h.

Referenced by null().


The documentation for this class was generated from the following file:

Generated on February 1, 2006
Back to the C-Breeze home page