Polaris: lambda_util.cc File Reference

lambda_util.cc File Reference

Go to the source code of this file.

Typedefs

typedef RefDatabase< int,
Expression
ArgDatabase

Enumerations

enum  ARG_EVAL_TYPE {
  NON_STRICT,
  STRICT
}
 Definitions for lambda call replacement code. More...
enum  STRICT_BOOL {
  PRESERVE_TYPE = 0,
  MAKE_NON_STRICT = 1
}

Functions

template ostream & operator<< (ostream &, const List< ArgExprElem > &)
void collect_lambda_formals (const Expression &e, ExtraInfo &extra_info)
 (Note: This function is a traverse_action_func_t function)
Expressionreplace_lambda_call_expr (Expression *e, ExtraInfo &extra_info)
 Replace a LambdaCallExpr with itself to prevent further checking of its subexpressions.
Expressionreplace_lambda_call (Expression *e, ExtraInfo &extra_info)
 replace_lambda_call returns the fully-substituted lambda expression from LAMBDA_CALL expression e.
Expressionremove_lambda_calls (Expression *e, LambdaInfo &lambda)
 Remove lambda calls from expression - argument must point to a LambdaInfo object.
void remove_all_statement_functions (ProgramUnit &pgm)
 Inline functions.


Typedef Documentation

typedef RefDatabase<int, Expression> ArgDatabase
 

Definition at line 32 of file lambda_util.cc.


Enumeration Type Documentation

enum ARG_EVAL_TYPE
 

Definitions for lambda call replacement code.

Enumeration values:
NON_STRICT 
STRICT  ... Argument must be evaluated

Definition at line 22 of file lambda_util.cc.

enum STRICT_BOOL
 

Enumeration values:
PRESERVE_TYPE 
MAKE_NON_STRICT 

Definition at line 27 of file lambda_util.cc.


Function Documentation

template ostream& operator<< ostream &  ,
const List< ArgExprElem > & 
 

void collect_lambda_formals const Expression e,
ExtraInfo extra_info
 

(Note: This function is a traverse_action_func_t function)

... Point to CollectPair

... Create an argument expression element

... Insert the argument expression element into formal_list

... Create a new collect pair

... Recursively invoke collect_lambda_formals on parameter ... subexpression (whose unhidden lambda call args, if any, ... are ours)

... Absorb the new collect_pair into the existing one

... Create a new collect pair

... Recursively invoke collect_lambda_formals on subexpressions

... Absorb the new collect_pair into the existing one, making ... the new variable references NON_STRICT

Definition at line 230 of file lambda_util.cc.

References CollectPair::absorb(), AND_OP, Expression::arg_list(), ARG_OP, collect_lambda_formals(), CollectPair::CollectPair(), e, List< T >::ins_last(), LAMBDA_CALL_OP, CollectPair::list, MAKE_NON_STRICT, MULT_OP, NON_RECURSIVE_REPLACE, Expression::op(), OR_OP, CollectPair::pattern, PREORDER_REPLACE, STRICT, traverse(), and List< T >::valid().

Referenced by collect_lambda_formals(), and replace_lambda_call().

Expression* replace_lambda_call_expr Expression e,
ExtraInfo extra_info
 

Replace a LambdaCallExpr with itself to prevent further checking of its subexpressions.

... If lambda call, recursively examine its parameter expression

... Point at argument map

... Delete the old expression

... Return a clone to caller

Definition at line 311 of file lambda_util.cc.

References Expression::arg_list(), ARG_OP, List< T >::assign(), Expression::clone(), e, ProtoRefDatabase< S, T >::find_ref(), LAMBDA_CALL_OP, NON_RECURSIVE_REPLACE, Expression::op(), PREORDER_REPLACE, List< T >::pull(), replace(), replace_lambda_call_expr(), and Expression::value().

Referenced by replace_lambda_call(), and replace_lambda_call_expr().

Expression* replace_lambda_call Expression e,
ExtraInfo extra_info
 

replace_lambda_call returns the fully-substituted lambda expression from LAMBDA_CALL expression e.

... patterns for LAMBDA_CALL replacement

... Retrieve parameters from argument

... Reinvoke recursive search on the parameter expression

... Set up list to collect data

... Collect lambda formals from lambda expression, grabbing lambda ... expression out of its containing list

... Define the argument map

... Define the list of precalculated ID node prototypes

... Set the initial argument reference number

... Iterate over the LAMBDA_CALL's parameter expression (which may ... have been changed by earlier LAMBDA_CALLs)

... Grab corresponding arguments from collect_pair to ... formal_list

... Find correct actual parameter

... Handle actual parameter cases

... Handle constant and ID actual parameters. Insert ... reference to actual parameter into argument map

... If there is more than one formal reference to ... parameter, or there is only one non-strict ... reference which is not side-effect free, ... precalculate parameter.

... Precalculate parameter, getting an ID node in ... return

... Put ID node on owning list (for later cleanup)

... Insert reference to ID node prototype into ... argument map.

... Insert reference to actual parameter into ... argument map.

... Increment argument number

... Substitute all arguments in lambda expression. Use preorder search, ... a wildcard which matches on ArgNumberExprs and LambdaCallExprs, and ... non-recursion.

... Simplification is too dangerous here when inlining (where not ... all variables with the same name are the same!) ... If this is a statement function call, simplify fully-substituted ... lambda expression before return and put parentheses around the ... expression to prevent inadvertant call-by-reference access

Definition at line 349 of file lambda_util.cc.

References AND_OP, Expression::arg_list(), BinaryExpr::arg_list(), ARG_OP, List< T >::assign(), Expression::clone(), collect_lambda_formals(), COMPLEX_OP, Expression::data(), e, List< T >::entries(), Expression::expr_guarded(), get_precalc(), ID_OP, RefDatabase< S, T >::ins(), List< T >::ins_last(), INTEGER_CONSTANT_OP, Expression::is_side_effect_free(), LAMBDA_CALL_OP, LambdaInfo::lc_type, CollectPair::list, MULT_OP, NON_RECURSIVE_REPLACE, NON_STRICT, Expression::op(), OR_OP, LambdaCallExpr::parameters_guarded(), LambdaCallExpr::parameters_valid(), PAREN_OP, CollectPair::pattern, PREORDER_REPLACE, StmtInfo::program_ref, List< T >::pull(), REAL_CONSTANT_OP, RECURSIVE_REPLACE, replace(), replace_lambda_call(), replace_lambda_call_expr(), simplify(), STMT_FUNCTION_CALL, StmtInfo::stmt_ref, traverse(), Expression::type(), and List< T >::valid().

Referenced by remove_lambda_calls(), and replace_lambda_call().

Expression* remove_lambda_calls Expression e,
LambdaInfo lambda
 

Remove lambda calls from expression - argument must point to a LambdaInfo object.

Precalculation is avoided for constant expressions (IDs are constant thanks to F77 pg 6-15 ln 55!) and for formals referenced once or not at all.

... pattern for LAMBDA_CALL replacement

... Call replace to recursively replace LAMBDA_CALL expressions

Definition at line 520 of file lambda_util.cc.

References e, LAMBDA_CALL_OP, PREORDER_REPLACE, RECURSIVE_REPLACE, replace(), and replace_lambda_call().

Referenced by InlineObject::remap_expr(), remove_all_statement_functions(), and trans_update_expr().

void remove_all_statement_functions ProgramUnit pgm  ) 
 

Inline functions.

The bound variables have no names; they are identified positionally. A LAMBDA_CALL node resembles a FUNCTION_CALL node, with the function ID replaced by the statement function definition. Remove all statement functions from program and rebuild in-out refs

... Initialize LambdaInfo object

... Iterate over statements

... Iterate over expressions and remove statement functions

... Rebuild statement references

Definition at line 542 of file lambda_util.cc.

References Statement::build_refs(), Statement::iterate_expressions(), StmtInfo::program_ref, remove_lambda_calls(), STMT_FUNCTION_CALL, and StmtInfo::stmt_ref.

 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:06:23 2005