Polaris: InlineObject Class Reference

InlineObject Class Reference

#include <InlineObject.h>

Inheritance diagram for InlineObject:

Inheritance graph
[legend]
List of all members.

Public Types

enum  TRANS_CLEANUP_TYPE {
  NO_CLEANUP_NEEDED,
  CLEANUP_NEEDED
}

Public Member Functions

const Expressionactual_arg (const Symbol &formal) const
 return the actual argument from the formal arg's Symbol
const AbstractAccessaccess_region (const Symbol &formal) const
 return the caller's AbstractAccess object for the formal arg
void remap_arg_names (Statement &s)
 insert formal->actual name mapping into _symbol_map
 InlineObject (ProgramUnit *pgm_ptr, ProgramUnit &pgm_main)
 Create an InlineObject for a owned subprogram.
 InlineObject (ProgramUnit &pgm, ProgramUnit &pgm_main)
 Create an InlineObject for a referred-to subprogram.
 InlineObject (ProgramUnit &pgm)
 Create an InlineObject for a stand-alone program (for equivalence normalization).
virtual ~InlineObject ()
 Destroy an InlineObject.
void prepare_routines_for_arg_mapping ()
 make necessary changes to prepare for mapping interface variables from called routine to calling routine
virtual Listablelistable_clone () const
 Return a reference to the inline work space.
virtual void print (ostream &o) const
 Listable functions.
RefElement< InlineWorkSpace > & ws_ref ()
 Return a reference to the inline workspace.
void map_existing_common_block (CommonBlock &common_local, CommonBlock *common_main_ptr)
 Map the variables from a COMMON in a called routine to a COMMON by the same name in a calling routine.
Statementinline_expand (Statement &s, bool recursive)
 Inline expansion of program represented by the InlineObject into the main program referred to by the InlineObject at statement s + recursive added (kjackson).
Expressionmake_conformable (VariableSymbol *name_ptr, Expression &main_expr)
 Make a parameter (or multi-dimensional variable) conformable with a main program expression.
void translate_symbol_refs (TRANS_CLEANUP_TYPE cleanup)
 Translate symbol references for all statements within the subprogram.
int remap_expr (Expression **ex, LambdaInfo &lambda, REF_TYPE ref) const
 Take an expression and map the variables in it from the called routine into the caller routine.

Friends

ostream & operator<< (ostream &o, const InlineObject &h)

Member Enumeration Documentation

enum InlineObject::TRANS_CLEANUP_TYPE
 

Enumeration values:
NO_CLEANUP_NEEDED 
CLEANUP_NEEDED 

Definition at line 46 of file InlineObject.h.


Constructor & Destructor Documentation

InlineObject::InlineObject ProgramUnit pgm_ptr,
ProgramUnit pgm_main
[inline]
 

Create an InlineObject for a owned subprogram.

Definition at line 162 of file InlineObject.h.

References register_instance().

Referenced by listable_clone().

InlineObject::InlineObject ProgramUnit pgm,
ProgramUnit pgm_main
[inline]
 

Create an InlineObject for a referred-to subprogram.

Definition at line 171 of file InlineObject.h.

References register_instance().

InlineObject::InlineObject ProgramUnit pgm  )  [inline]
 

Create an InlineObject for a stand-alone program (for equivalence normalization).

Definition at line 180 of file InlineObject.h.

References register_instance().

InlineObject::~InlineObject  )  [inline, virtual]
 

Destroy an InlineObject.

Definition at line 201 of file InlineObject.h.

References unregister_instance().


Member Function Documentation

const Expression * InlineObject::actual_arg const Symbol formal  )  const
 

return the actual argument from the formal arg's Symbol

Definition at line 3939 of file InlineObject.cc.

References ProtoMap< S, T >::find_ref().

Referenced by remap_arg_names().

const AbstractAccess * InlineObject::access_region const Symbol formal  )  const
 

return the caller's AbstractAccess object for the formal arg

Definition at line 3945 of file InlineObject.cc.

References ProtoMap< S, T >::find_ref().

void InlineObject::remap_arg_names Statement s  ) 
 

insert formal->actual name mapping into _symbol_map

USED ONLY FOR ACCESS REGION ARGUMENT TRANSLATION.

... ostrstream *str_ref; ... char *data;

... CALL statement: find the pointer to the actual list in main ... pgm and the pointer to the contained entry name symbol

... Function call: find the pointer to the actual list in main ... pgm, the pointer to the contained entry name sym, and the ... pointer to the symbol for the temporary variable to which the ... function value is assigned in pgm (cloning it from main pgm)

... Map the entry name symbol to the temporary name in main program

_symbol_map.ins(*entry_name_ptr,

... Find the entry point and its parameter list

... Set c to point to current statement

... Define the default number of actual and formal entries in each list

... If mismatching numbers of arguments, error

... Build iterators for argument list and parameter list

... Prepare the formal-actual mapping.

... This must be in GSA form! CALL x(<beta>(ALPHA(,input),output), ... )

... Check for reshaping, if required

... Point at formal variable and expression in main program

... If both actual and formal are arrays, then check for reshaping

... Found both are arrays.

... If the declared upper bound of the formal is a variable, ... which is also a parameter, substitute the actual expression ... for the variable.

... Increment the iterators

Definition at line 2300 of file InlineObject.cc.

References _ar_reshape, actual_arg(), add(), ALPHA_OP, AR_READWRITE, Expression::arg_list(), ARRAY_REF_OP, Expression::base_variable_ref(), CALL_STMT, Expression::clone(), compute_abstract_access(), constant(), convert_case(), Iterator< T >::current(), VariableSymbol::dim(), List< T >::entries(), Symtab::find_ref(), FLOW_ENTRY_STMT, Symbol::formal(), Expression::function(), FUNCTION_CALL_OP, ID_OP, Map< S, T >::ins(), VariableSymbol::is_array(), is_integer_zero(), StmtList::iterate_entry_points(), ArrayBounds::lower_exists(), ArrayBounds::lower_guarded(), Symbol::name_ref(), Expression::op(), Expression::parameters_guarded(), Statement::parameters_guarded(), Expression::parameters_valid(), Statement::parameters_valid(), ArrayDims::print(), Iterator< T >::reset(), Statement::rhs(), Statement::routine_guarded(), simplify(), Statement::stmt_class(), ProgramUnit::stmts(), sub(), Expression::symbol(), ProgramUnit::symtab(), ArrayBounds::upper_exists(), ArrayBounds::upper_guarded(), and Iterator< T >::valid().

void InlineObject::prepare_routines_for_arg_mapping  ) 
 

make necessary changes to prepare for mapping interface variables from called routine to calling routine

_precalc_adjustable_array_bounds(); Moved back to inline_expand()

Definition at line 3918 of file InlineObject.cc.

References IGNORE_REALS, and substitute_parameters().

Referenced by inline_expand().

Listable * InlineObject::listable_clone  )  const [inline, virtual]
 

Return a reference to the inline work space.

Reimplemented from TranslateObject.

Definition at line 209 of file InlineObject.h.

References InlineObject().

void InlineObject::print ostream &  o  )  const [virtual]
 

Listable functions.

Reimplemented from TranslateObject.

Definition at line 121 of file InlineObject.cc.

References TranslateObject::print(), and RefElement< T >::valid().

RefElement< InlineWorkSpace > & InlineObject::ws_ref  )  [inline]
 

Return a reference to the inline workspace.

Definition at line 218 of file InlineObject.h.

void InlineObject::map_existing_common_block CommonBlock common_local,
CommonBlock common_main_ptr
 

Map the variables from a COMMON in a called routine to a COMMON by the same name in a calling routine.

COMMON in called routine: common_local COMMON in calling routine: common_main_ptr Calling routine: pgm_main

... There's a similar common block in main pgm, so build ... common_map and common_main_map and perform overlapping ... common block processing

... Propagate SAVE if inlining into another subprogram

... Iterate over variables in common blocks

... Calculate offset information for contained variable

... If current main pgm variable doesn't overlap the ... contained variable, look at the next main pgm variable.

... Fall out of the loop if the main pgm common block runs ... out; this case will be implemented later.

... Generate subscript expression

... Absorb ID and subscript expressions into array ... reference.

... Generate equivalent variable (eventually, attempt ... to generate an alternate expression here for ... complex mapped to real)

... Point at base variable

... Delete ID expression because it wasn't absorbed

... Generate subscript expression

... Absorb ID and subscript expressions into array ... reference.

... Make the common block variables conform to one another

... Delete main program expression

... Increment common_offset by size of variable

Definition at line 1849 of file InlineObject.cc.

References Expression::arg_list(), array_reference(), Expression::base_variable_ref(), common_offset(), Iterator< T >::current(), VariableSizes::elem_size, List< T >::grab(), id(), CommonBlock::iterator(), make_conformable(), PROGRAM_PU_TYPE, ProgramUnit::pu_class(), VariableSizes::remap(), CommonBlock::saved(), VariableSizes::size, unlinearize_array_ref(), and Iterator< T >::valid().

Statement & InlineObject::inline_expand Statement s,
bool  recursive
 

Inline expansion of program represented by the InlineObject into the main program referred to by the InlineObject at statement s + recursive added (kjackson).

recursive indicates if this is a RECURSIVE_INLINE expansion

... If first inlining, make permanent changes

... Allocate work InlineObject from saved one

... Rename branch targets

... Remap argument uses

... Translate symbol references

... Merge pgm_work into main program, adding RECURSIVE_INLINE assertions ... to appropriate statements if necessary (kjackson)

... substitute any parameters which may have been inlined

... Return insertion point ref to caller

Definition at line 3868 of file InlineObject.cc.

References _remap_arg_uses(), _remap_merge_stmts(), _rename_branch_targets(), CLEANUP_NEEDED, float_entry_points(), IGNORE_REALS, prepare_routines_for_arg_mapping(), sink_return_points(), substitute_parameters(), switch_value(), translate_symbol_refs(), and Statement::write().

Expression * InlineObject::make_conformable VariableSymbol name_ptr,
Expression main_expr
 

Make a parameter (or multi-dimensional variable) conformable with a main program expression.

... Check conformability of variables

... If complex passed to real, attempt to generate an alternate ... expression which avoids use of the equivalence

... Map non-constant references from name to main_name

... TODO: Handle conformable but different sized character variables ... properly

... Remap transformable references ... VariableSymbol *main_name_ptr = NULL;

... Map references from name to a constant

... Map references from name to main_name

... Get the dimension information for each symbol

... Absorb name_lb, main_name_lb as subexpressions of ... main_name_offptr

... If subscript, adjust main_name_offptr and iterate ... subscript iterator

... Insert main_name_offptr into lambda ref

... Increment variable iterators

... Insert lambda call reference into map

... Build a subscript reference for one to many ... dimension case.

... Insert into subscript_ref

... Linearize subscript reference

... If subscript on main_name, adjust lambda_ref

... Absorb main_name_lb as subexpresion of offset

... Insert offset into lambda ref

... Insert lambda call reference into map

... Insert lambda call reference into map

... Handle non-conformable case

... Insert test expression into list for later assertion

... Test expression is either irrelevantly true or ... catastrophically false

... Clean up main expression

Definition at line 1501 of file InlineObject.cc.

References add(), Expression::arg_list(), ARRAY_REF_OP, Expression::base_variable_ref(), Expression::bound(), Expression::clone(), comma(), COMPLEX_TYPE, conformable_test(), constant(), Iterator< T >::current(), Expression::data_ref(), VariableSymbol::dim(), List< T >::entries(), gen_alternate_expr(), List< T >::grab(), initial_array_ref(), RefMap< S, T >::ins(), Map< S, T >::ins(), List< T >::ins_first(), List< T >::ins_last(), INTEGER_TYPE, LOGICAL_CONSTANT_OP, ArrayBounds::lower_ref(), make_type(), NON_CONFORMABLE, Expression::op(), REAL_TYPE, Expression::string(), sub(), Expression::subscript(), TRANSFORMABLE_ARRAY, TRANSFORMABLE_CONSTANT, TRANSFORMABLE_SUBSTRING, and TRANSFORMABLE_SUBSTRING_ARRAY.

Referenced by map_existing_common_block().

void InlineObject::translate_symbol_refs TRANS_CLEANUP_TYPE  cleanup  ) 
 

Translate symbol references for all statements within the subprogram.

If there is no translation to do, return to caller

Translate each statement

Definition at line 3458 of file InlineObject.cc.

References BaseMapRoot::entries(), ENTRY_STMT, INLINE_CALL, StmtList::iterator(), NO_CLEANUP_NEEDED, StmtInfo::program_ref, Statement::stmt_class(), StmtInfo::stmt_ref, ProgramUnit::stmts(), and Iterator< T >::valid().

Referenced by inline_expand().

int InlineObject::remap_expr Expression **  ex,
LambdaInfo lambda,
REF_TYPE  ref
const
 

Take an expression and map the variables in it from the called routine into the caller routine.

... Nothing replaced so far

... If this expression was replaced, remove lambda ... calls and check the expression again.

Definition at line 3216 of file InlineObject.cc.

References TranslateObject::_translate_symbol_refs_expr(), and remove_lambda_calls().


Friends And Related Function Documentation

ostream& operator<< ostream &  o,
const InlineObject h
[friend]
 

Definition at line 104 of file InlineObject.h.


The documentation for this class was generated from the following files:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:32 2005