C-Breeze
C Compiler Infrastructure

[ Project home page]

constantAnalyzer Class Reference

#include <constants.h>

List of all members.

Public Member Functions

 constantAnalyzer ()
 Create a new constant analysis.
 ~constantAnalyzer ()
 Destructor.
void clear ()
 Clear.
void set_null_object (memoryBlock *null_object)
 Set the null object.
const constanttop () const
 TOP value.
const constantbottom () const
 BOTTOM value.
bool has_value (const constant *val)
 Has value.
bool has_truth_value (const constant *val, bool &value)
 Check for truth value.
const constantlookup (const constant &value)
 Lookup a constant value.
const constantlookup_flowvalue (memoryDef *def)
 Lookup a variable value.
bool update_flowvalue (const constant *val, memoryDef *def)
 Update a variable value.
const constantmeet (const constant *one, const constant *two)
 Meet function.
const constantrebuild_flowvalue (pointerValue &pointer)
 Rebuild the flow value.
void record_expression (exprNode *expr, const constant *val)
 Record the value of an expression.
void record_stmt (stmtNode *stmt, const constant *val)
 Record the rhs value of an threeAddr.
const constantevaluate_points_to (const memoryblock_set &points_to)
 Evaluate points-to set.
const constantlookup_expression (exprNode *expr)
 Look up an expression.
const constantlookup_stmt (stmtNode *expr)
void at_id (stmtLocation *current, idNode *id, pointerValue &value)
void at_unary (stmtLocation *current, stmtNode *t, pointerValue &operand, pointerValue &result)
void at_sizeof (stmtLocation *current, threeAddrNode *t, pointerValue &operand, pointerValue &result)
void at_binary (stmtLocation *current, stmtNode *s, pointerValue &left, pointerValue &right, pointerValue &result)
void at_const (stmtLocation *current, constNode *cons, pointerValue &result)
void at_address (stmtLocation *current, operandNode *operand, pointerValue &result)
void at_cast (stmtLocation *current, operandNode *operand, pointerValue &operand_val, pointerValue &result)
void at_dereference (stmtLocation *current, operandNode *operand, pointerValue &result)
void at_field_access (stmtLocation *current, operandNode *operand, pointerValue &result)
void at_index (stmtLocation *current, operandNode *operand, pointerValue &result)
void at_assignment (stmtLocation *current, pointerValue &left, pointerValue &right, pointerValue &result, memoryblock_set &changes)
void at_parameter_pass (Location *current, pointerValue &left, pointerValue &right, memoryblock_set &changes)
void at_self_assignment (Location *source, Location *target, memoryBlock *block, memoryblock_set &changes)
void at_return (stmtLocation *stmt, returnNode *ret, pointerValue &result, pointerValue &return_val)
void at_merge (Location *where, memoryBlock *block, memoryuse_list &phi_uses, pointerValue &result, memoryblock_set &changes)
void at_basicblock_entry (basicblockLocation *block, procedureInfo *info, pointerValue &initial)
void at_stmt_entry (stmtLocation *stmt, pointerValue &result)
void at_conservative_procedure_call (stmtLocation *current, operandNode *call, operand_list &args, pointerValue &call_target, pointervalue_list &arguments, memoryblock_set &reachable_blocks, pointerValue &return_val, memoryblock_set &changes)
void print (ostream &o, const constant *val)
string to_string (const constant *val)

Private Types

typedef set< constantconstant_set
typedef constant_set::iterator constant_set_p
typedef map< exprNode *, const
constant * > 
expr_value_map
typedef expr_value_map::iterator expr_value_map_p
typedef map< stmtNode *, const
constant * > 
stmt_value_map
typedef stmt_value_map::iterator stmt_value_map_p

Private Member Functions

void record_change (memoryDef *def)
 Obsolete: Record a value change.

Private Attributes

TREE constant_set _schar_constants
 The set of all constants.
TREE constant_set _uchar_constants
TREE constant_set _sshort_constants
TREE constant_set _ushort_constants
TREE constant_set _sint_constants
TREE constant_set _uint_constants
TREE constant_set _slong_constants
TREE constant_set _ulong_constants
TREE constant_set _float_constants
TREE constant_set _double_constants
REF memoryBlock_null
 Null object.
const constant_top
 Unique lattice top element.
const constant_bottom
 Unique lattice bottom element.
const constant_non_null
 Special non-null element.
expr_value_map _expr_values
 Record the value of each expression.
stmt_value_map _stmt_values


Member Typedef Documentation

typedef set< constant > constantAnalyzer::constant_set [private]
 

Definition at line 53 of file constants.h.

typedef constant_set::iterator constantAnalyzer::constant_set_p [private]
 

Definition at line 54 of file constants.h.

typedef map< exprNode *, const constant * > constantAnalyzer::expr_value_map [private]
 

Definition at line 56 of file constants.h.

typedef expr_value_map::iterator constantAnalyzer::expr_value_map_p [private]
 

Definition at line 57 of file constants.h.

typedef map< stmtNode *, const constant * > constantAnalyzer::stmt_value_map [private]
 

Definition at line 59 of file constants.h.

typedef stmt_value_map::iterator constantAnalyzer::stmt_value_map_p [private]
 

Definition at line 60 of file constants.h.


Constructor & Destructor Documentation

constantAnalyzer::constantAnalyzer  ) 
 

Create a new constant analysis.

constantAnalyzer::~constantAnalyzer  ) 
 

Destructor.


Member Function Documentation

void constantAnalyzer::at_address stmtLocation current,
operandNode operand,
pointerValue result
 

void constantAnalyzer::at_assignment stmtLocation current,
pointerValue left,
pointerValue right,
pointerValue result,
memoryblock_set changes
 

void constantAnalyzer::at_basicblock_entry basicblockLocation block,
procedureInfo info,
pointerValue initial
 

void constantAnalyzer::at_binary stmtLocation current,
stmtNode s,
pointerValue left,
pointerValue right,
pointerValue result
 

void constantAnalyzer::at_cast stmtLocation current,
operandNode operand,
pointerValue operand_val,
pointerValue result
 

void constantAnalyzer::at_conservative_procedure_call stmtLocation current,
operandNode call,
operand_list args,
pointerValue call_target,
pointervalue_list arguments,
memoryblock_set reachable_blocks,
pointerValue return_val,
memoryblock_set changes
 

void constantAnalyzer::at_const stmtLocation current,
constNode cons,
pointerValue result
 

void constantAnalyzer::at_dereference stmtLocation current,
operandNode operand,
pointerValue result
 

void constantAnalyzer::at_field_access stmtLocation current,
operandNode operand,
pointerValue result
 

void constantAnalyzer::at_id stmtLocation current,
idNode id,
pointerValue value
 

void constantAnalyzer::at_index stmtLocation current,
operandNode operand,
pointerValue result
 

void constantAnalyzer::at_merge Location where,
memoryBlock block,
memoryuse_list phi_uses,
pointerValue result,
memoryblock_set changes
 

void constantAnalyzer::at_parameter_pass Location current,
pointerValue left,
pointerValue right,
memoryblock_set changes
 

void constantAnalyzer::at_return stmtLocation stmt,
returnNode ret,
pointerValue result,
pointerValue return_val
 

void constantAnalyzer::at_self_assignment Location source,
Location target,
memoryBlock block,
memoryblock_set changes
 

void constantAnalyzer::at_sizeof stmtLocation current,
threeAddrNode t,
pointerValue operand,
pointerValue result
 

void constantAnalyzer::at_stmt_entry stmtLocation stmt,
pointerValue result
 

void constantAnalyzer::at_unary stmtLocation current,
stmtNode t,
pointerValue operand,
pointerValue result
 

const constant* constantAnalyzer::bottom  )  const [inline]
 

BOTTOM value.

Definition at line 133 of file constants.h.

References _bottom.

void constantAnalyzer::clear  ) 
 

Clear.

Prepare for a new analysis.

const constant* constantAnalyzer::evaluate_points_to const memoryblock_set points_to  ) 
 

Evaluate points-to set.

Determine the constant value of a pointer by looking at what it points to. There are basically three cases: (1) it only points to the NULL object, in which case it is zero, (2) it points to heap objects, which might fail to be allocated, so the value is bottom, or (3) it points to regular variables, whose addresses cannot be zero, so the value is non-null.

bool constantAnalyzer::has_truth_value const constant val,
bool &  value
 

Check for truth value.

Return true if the given constant is true (including non-null).

bool constantAnalyzer::has_value const constant val  )  [inline]
 

Has value.

Return true if the constant is not top, bottom, or non-null

Definition at line 139 of file constants.h.

References _bottom, _non_null, and _top.

const constant* constantAnalyzer::lookup const constant value  ) 
 

Lookup a constant value.

All constants are stored in a set so that there is only one constant object for each unique value.

const constant* constantAnalyzer::lookup_expression exprNode expr  ) 
 

Look up an expression.

const constant* constantAnalyzer::lookup_flowvalue memoryDef def  ) 
 

Lookup a variable value.

Look for the constant value associated with a specific def. Default is TOP if none is found.

const constant* constantAnalyzer::lookup_stmt stmtNode expr  ) 
 

const constant* constantAnalyzer::meet const constant one,
const constant two
 

Meet function.

void constantAnalyzer::print ostream &  o,
const constant val
[inline]
 

Definition at line 313 of file constants.h.

References _bottom, _top, and constant::to_string().

const constant* constantAnalyzer::rebuild_flowvalue pointerValue pointer  ) 
 

Rebuild the flow value.

Collect the current values of the given pointer using the meet function

void constantAnalyzer::record_change memoryDef def  )  [private]
 

Obsolete: Record a value change.

void constantAnalyzer::record_expression exprNode expr,
const constant val
 

Record the value of an expression.

void constantAnalyzer::record_stmt stmtNode stmt,
const constant val
 

Record the rhs value of an threeAddr.

void constantAnalyzer::set_null_object memoryBlock null_object  )  [inline]
 

Set the null object.

The pointer analyzer needs to provide this so that we can properly handle null pointers as constants.

Definition at line 125 of file constants.h.

References _null.

string constantAnalyzer::to_string const constant val  )  [inline]
 

Definition at line 325 of file constants.h.

References _bottom, _non_null, _top, and constant::to_string().

const constant* constantAnalyzer::top  )  const [inline]
 

TOP value.

Definition at line 129 of file constants.h.

References _top.

bool constantAnalyzer::update_flowvalue const constant val,
memoryDef def
 

Update a variable value.

Don't record any TOP values (because lookup_flowvalue() will return TOP by default). Also, return a boolean indicating if the update resulted in a change.


Member Data Documentation

const constant* constantAnalyzer::_bottom [private]
 

Unique lattice bottom element.

Definition at line 91 of file constants.h.

Referenced by bottom(), has_value(), print(), and to_string().

TREE constant_set constantAnalyzer::_double_constants [private]
 

Definition at line 77 of file constants.h.

expr_value_map constantAnalyzer::_expr_values [private]
 

Record the value of each expression.

This ends up as the context insensitive information

Definition at line 101 of file constants.h.

TREE constant_set constantAnalyzer::_float_constants [private]
 

Definition at line 76 of file constants.h.

const constant* constantAnalyzer::_non_null [private]
 

Special non-null element.

Definition at line 95 of file constants.h.

Referenced by has_value(), and to_string().

REF memoryBlock* constantAnalyzer::_null [private]
 

Null object.

Keep this around so that we handle null pointers properly.

Definition at line 83 of file constants.h.

Referenced by set_null_object().

TREE constant_set constantAnalyzer::_schar_constants [private]
 

The set of all constants.

This set ensures that each unique constant value is represented by exactly one constant object. It "owns" all of the constant values. All other data structures refer to these.

Definition at line 68 of file constants.h.

TREE constant_set constantAnalyzer::_sint_constants [private]
 

Definition at line 72 of file constants.h.

TREE constant_set constantAnalyzer::_slong_constants [private]
 

Definition at line 74 of file constants.h.

TREE constant_set constantAnalyzer::_sshort_constants [private]
 

Definition at line 70 of file constants.h.

stmt_value_map constantAnalyzer::_stmt_values [private]
 

Definition at line 102 of file constants.h.

const constant* constantAnalyzer::_top [private]
 

Unique lattice top element.

Definition at line 87 of file constants.h.

Referenced by has_value(), print(), to_string(), and top().

TREE constant_set constantAnalyzer::_uchar_constants [private]
 

Definition at line 69 of file constants.h.

TREE constant_set constantAnalyzer::_uint_constants [private]
 

Definition at line 73 of file constants.h.

TREE constant_set constantAnalyzer::_ulong_constants [private]
 

Definition at line 75 of file constants.h.

TREE constant_set constantAnalyzer::_ushort_constants [private]
 

Definition at line 71 of file constants.h.


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

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