|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
copyPropChanger Class ReferencePerforms global (intraprocedural) copy propagation.
More...
|
Public Types | |
typedef set< threeAddrNode * > | threeAddr_set |
typedef threeAddr_set::iterator | threeAddr_set_p |
typedef set< declNode * > | decl_set |
typedef decl_set::iterator | decl_set_p |
enum | Order { Preorder, Postorder, Both } |
enum | Depth { Subtree, NodeOnly } |
Public Member Functions | |
Accessors | |
Methods to get and set fields in the class. | |
Order | order () const |
Return the order in which Nodes of an AST should be visited. | |
Depth | depth () const |
Return which Nodes of an AST should be visited. | |
bool | delete_old () const |
Return whether this Changer deletes Nodes which are removed from the AST by "at_" methods. | |
"at_" methods | |
These methods define the functions that should be performed when different classes of Nodes are encountered in the AST. The most specific "at_" method that matches a given Node's class will be called. | |
virtual Node * | at_node (Node *the_node, Order ord) |
virtual Node * | at_unit (unitNode *the_unit, Order ord) |
virtual Node * | at_def (defNode *the_def, Order ord) |
virtual Node * | at_decl (declNode *the_decl, Order ord) |
virtual Node * | at_subdecl (subdeclNode *the_subdecl, Order ord) |
virtual Node * | at_type (typeNode *the_type, Order ord) |
virtual Node * | at_prim (primNode *the_prim, Order ord) |
virtual Node * | at_tdef (tdefNode *the_tdef, Order ord) |
virtual Node * | at_ptr (ptrNode *the_ptr, Order ord) |
virtual Node * | at_array (arrayNode *the_array, Order ord) |
virtual Node * | at_func (funcNode *the_func, Order ord) |
virtual Node * | at_sue (sueNode *the_sue, Order ord) |
virtual Node * | at_struct (structNode *the_struct, Order ord) |
virtual Node * | at_union (unionNode *the_union, Order ord) |
virtual Node * | at_enum (enumNode *the_enum, Order ord) |
virtual Node * | at_suespec (suespecNode *the_suespec, Order ord) |
virtual Node * | at_expr (exprNode *the_expr, Order ord) |
virtual Node * | at_index (indexNode *the_index, Order ord) |
virtual Node * | at_const (constNode *the_const, Order ord) |
virtual Node * | at_id (idNode *the_id, Order ord) |
virtual Node * | at_binary (binaryNode *the_binary, Order ord) |
virtual Node * | at_unary (unaryNode *the_unary, Order ord) |
virtual Node * | at_cast (castNode *the_cast, Order ord) |
virtual Node * | at_comma (commaNode *the_comma, Order ord) |
virtual Node * | at_ternary (ternaryNode *the_ternary, Order ord) |
virtual Node * | at_call (callNode *the_call, Order ord) |
virtual Node * | at_initializer (initializerNode *the_initializer, Order ord) |
virtual Node * | at_stmt (stmtNode *the_stmt, Order ord) |
virtual Node * | at_block (blockNode *the_block, Order ord) |
virtual Node * | at_basicblock (basicblockNode *the_basicblock, Order ord) |
virtual Node * | at_exprstmt (exprstmtNode *the_exprstmt, Order ord) |
virtual Node * | at_target (targetNode *the_target, Order ord) |
virtual Node * | at_label (labelNode *the_label, Order ord) |
virtual Node * | at_case (caseNode *the_case, Order ord) |
virtual Node * | at_selection (selectionNode *the_selection, Order ord) |
virtual Node * | at_if (ifNode *the_if, Order ord) |
virtual Node * | at_switch (switchNode *the_switch, Order ord) |
virtual Node * | at_loop (loopNode *the_loop, Order ord) |
virtual Node * | at_while (whileNode *the_while, Order ord) |
virtual Node * | at_do (doNode *the_do, Order ord) |
virtual Node * | at_for (forNode *the_for, Order ord) |
virtual Node * | at_jump (jumpNode *the_jump, Order ord) |
virtual Node * | at_goto (gotoNode *the_goto, Order ord) |
virtual Node * | at_continue (continueNode *the_continue, Order ord) |
virtual Node * | at_break (breakNode *the_break, Order ord) |
virtual Node * | at_return (returnNode *the_return, Order ord) |
virtual Node * | at_attrib (attribNode *the_attrib, Order ord) |
virtual Node * | at_operand (operandNode *the_oper, Order ord) |
virtual Node * | at_conditiongoto (conditiongotoNode *the_condgoto, Order ord) |
virtual Node * | at_threeAddr (threeAddrNode *the_3addr, Order ord) |
virtual Node * | at_text (textNode *the_text, Order ord) |
Static Public Member Functions | |
void | change () |
Copy propagation on entire program. | |
void | change (unitNode *) |
Copy propagation on one unit. | |
void | change (procNode *) |
Copy propagation on one procedure. | |
Private Types | |
typedef pair< declNode *, declNode * > | Var_pair |
typedef set< Var_pair > | ACP |
Private Member Functions | |
copyPropChanger () | |
Constructor. | |
Node * | at_proc (procNode *, Order ord) |
copyFlowVal * | create_copy_set (basicblockNode *) |
copyFlowVal * | create_kill_set (basicblockNode *, stmt_list) |
void | solve_global_dataflow (stmt_list) |
void | local_copy_prop (basicblockNode *) |
void | copy_value (operandNode *opnd, const ACP &acp) |
idNode * | copy_value (idNode *opnd, const ACP &acp) |
Static Private Member Functions | |
void | remove_ACP (ACP &acp, declNode *v) |
Private Attributes | |
threeAddr_set | copies |
threeAddr_set | ambiguous |
map< threeAddrNode *, declNode * > | defines |
copyFlowVal * | _top |
copyFlowVal * | _bottom |
map< basicblockNode *, copyFlowVal * > | Gen |
map< basicblockNode *, copyFlowVal * > | Kill |
map< basicblockNode *, copyFlowVal * > | In |
map< basicblockNode *, copyFlowVal * > | Out |
This class performs the constant propagation. The program must already be cfg'd. The three public static change() functions allow the optimization to be performed on the entire program, on one unit, or on a single procedure. The algorithm used is adopted from Muchnick chapter 12.5. Note that copy statements with casts are ignored. Also, the algorithm itself has limitation. For example.
if(..) x = y; else x = y; z = x; // <-- x not replaced by y.
Definition at line 64 of file copyprop.h.
|
Definition at line 115 of file copyprop.h. Referenced by local_copy_prop(). |
|
Definition at line 68 of file copyprop.h. Referenced by copy_value(), copyFlowVal::copyFlowVal(), and create_kill_set(). |
|
Definition at line 69 of file copyprop.h. Referenced by copy_value(), and copyFlowVal::copyFlowVal(). |
|
Definition at line 66 of file copyprop.h. Referenced by create_copy_set(), create_kill_set(), local_copy_prop(), and copyFlowVal::stmts(). |
|
Definition at line 67 of file copyprop.h. Referenced by copyFlowVal::clear_dummies(), copyFlowVal::copyFlowVal(), create_copy_set(), create_kill_set(), and local_copy_prop(). |
|
Definition at line 114 of file copyprop.h. Referenced by local_copy_prop(), and remove_ACP(). |
|
|
|
|
Constructor.
Definition at line 83 of file copyprop.h. References Changer::Preorder, and Changer::Subtree. |
|
Reimplemented in AllocSizeChanger. Definition at line 253 of file changer.h. References Changer::at_type(). Referenced by arrayNode::change(). |
|
Definition at line 364 of file changer.h. References Changer::at_stmt(). Referenced by attribNode::change(). |
|
Reimplemented in constantFoldingChanger. Definition at line 313 of file changer.h. References Changer::at_block(). Referenced by basicblockNode::change(). |
|
Reimplemented in SelectionDismantle, ArrowDismantle, and ExpressionDismantle. Definition at line 286 of file changer.h. References Changer::at_expr(). Referenced by binaryNode::change(). |
|
Reimplemented in StaticToGlobalDismantle, and InitializerDismantle. Definition at line 310 of file changer.h. References Changer::at_stmt(). Referenced by Changer::at_basicblock(), and blockNode::change(). |
|
Reimplemented in BreakContinueChanger. Definition at line 358 of file changer.h. References Changer::at_jump(). Referenced by breakNode::change(). |
|
Reimplemented in ExpressionDismantle. Definition at line 301 of file changer.h. References Changer::at_expr(). Referenced by callNode::change(). |
|
Definition at line 325 of file changer.h. References Changer::at_target(). Referenced by caseNode::change(). |
|
Reimplemented in ExpressionDismantle, and CastRemover. Definition at line 292 of file changer.h. References Changer::at_expr(). Referenced by castNode::change(). |
|
Reimplemented in ExpressionDismantle. Definition at line 295 of file changer.h. References Changer::at_expr(). Referenced by commaNode::change(). |
|
Reimplemented in constantPropChanger, constantFoldingChanger, and constantsChanger. Definition at line 370 of file changer.h. References Changer::at_goto(). Referenced by conditiongotoNode::change(). |
|
Definition at line 280 of file changer.h. References Changer::at_index(). Referenced by constNode::change(). |
|
Reimplemented in BreakContinueChanger. Definition at line 355 of file changer.h. References Changer::at_jump(). Referenced by continueNode::change(). |
|
Reimplemented in AllocSizeChanger, StaticToGlobalDismantle, InitializerDismantle, FlattenDismantle, ref_clone_changer, and TreeFixer. Definition at line 232 of file changer.h. References Changer::at_def(). Referenced by Changer::at_subdecl(), and declNode::change(). |
|
Definition at line 229 of file changer.h. References Changer::at_node(). Referenced by Changer::at_decl(), and Changer::at_proc(). |
|
Reimplemented in LoopDismantle. Definition at line 343 of file changer.h. References Changer::at_loop(). Referenced by doNode::change(). |
|
Reimplemented in AllocSizeChanger. Definition at line 268 of file changer.h. References Changer::at_sue(). Referenced by enumNode::change(). |
|
Reimplemented in ipConstantsChanger. Definition at line 274 of file changer.h. References Changer::at_node(). Referenced by Changer::at_binary(), Changer::at_call(), Changer::at_cast(), Changer::at_comma(), Changer::at_index(), Changer::at_initializer(), Changer::at_operand(), Changer::at_ternary(), Changer::at_unary(), and metaexprNode::change(). |
|
Reimplemented in SelectionDismantle, ExpressionDismantle, and FlattenDismantle. Definition at line 316 of file changer.h. References Changer::at_stmt(). Referenced by exprstmtNode::change(). |
|
Reimplemented in LoopDismantle. Definition at line 346 of file changer.h. References Changer::at_loop(). Referenced by forNode::change(). |
|
Definition at line 256 of file changer.h. References Changer::at_type(). Referenced by funcNode::change(). |
|
Reimplemented in FlattenDismantle. Definition at line 352 of file changer.h. References Changer::at_jump(). Referenced by Changer::at_conditiongoto(), and gotoNode::change(). |
|
Reimplemented in UnusedDeclarationCleanupChanger, and constantsChanger. Definition at line 283 of file changer.h. References Changer::at_index(). Referenced by idNode::change(). |
|
Reimplemented in SelectionDismantle, and CFS_Changer. Definition at line 331 of file changer.h. References Changer::at_selection(). Referenced by ifNode::change(). |
|
Definition at line 277 of file changer.h. References Changer::at_expr(). Referenced by Changer::at_const(), and Changer::at_id(). |
|
Definition at line 304 of file changer.h. References Changer::at_expr(). Referenced by initializerNode::change(). |
|
Definition at line 349 of file changer.h. References Changer::at_stmt(). Referenced by Changer::at_break(), Changer::at_continue(), Changer::at_goto(), and Changer::at_return(). |
|
Reimplemented in LabelDismantle, FlattenDismantle, and ref_clone_changer. Definition at line 322 of file changer.h. References Changer::at_target(). Referenced by labelNode::change(). |
|
Definition at line 337 of file changer.h. References Changer::at_stmt(). Referenced by Changer::at_do(), Changer::at_for(), and Changer::at_while(). |
|
Reimplemented in ref_clone_changer. Definition at line 223 of file changer.h. Referenced by Changer::at_def(), Changer::at_expr(), Changer::at_stmt(), Changer::at_text(), Changer::at_type(), and Changer::at_unit(). |
|
Definition at line 367 of file changer.h. References Changer::at_expr(). Referenced by operandNode::change(). |
|
Reimplemented in AllocSizeChanger. Definition at line 244 of file changer.h. References Changer::at_type(). Referenced by primNode::change(). |
|
Reimplemented from Changer. Definition at line 215 of file copyprop.cc. References _bottom, _top, ambiguous, Block, procNode::body(), copyFlowVal::clone(), stmtNode::comment(), copies, create_copy_set(), create_kill_set(), defines, Gen, In, Kill, Label, local_copy_prop(), Out, solve_global_dataflow(), stmt_list, stmt_list_p, blockNode::stmts(), basicblockNode::succs(), copyFlowVal::to_bottom(), and procNode::walk(). |
|
Reimplemented in AllocSizeChanger. Definition at line 250 of file changer.h. References Changer::at_type(). Referenced by ptrNode::change(). |
|
Reimplemented in SelectionDismantle, ReturnDismantle, FlattenDismantle, and constantPropChanger. Definition at line 361 of file changer.h. References Changer::at_jump(). Referenced by returnNode::change(). |
|
Definition at line 328 of file changer.h. References Changer::at_stmt(). Referenced by Changer::at_if(), and Changer::at_switch(). |
|
Reimplemented in TernaryDismantle, and SelectionDismantle. Definition at line 307 of file changer.h. References Changer::at_node(). Referenced by Changer::at_attrib(), Changer::at_block(), Changer::at_exprstmt(), Changer::at_jump(), Changer::at_loop(), Changer::at_selection(), Changer::at_target(), Changer::at_threeAddr(), and metastmtNode::change(). |
|
Reimplemented in AllocSizeChanger. Definition at line 262 of file changer.h. References Changer::at_sue(). Referenced by structNode::change(). |
|
Definition at line 235 of file changer.h. References Changer::at_decl(). Referenced by subdeclNode::change(). |
|
Definition at line 259 of file changer.h. References Changer::at_type(). Referenced by Changer::at_enum(), Changer::at_struct(), and Changer::at_union(). |
|
Definition at line 271 of file changer.h. References Changer::at_type(). Referenced by suespecNode::change(). |
|
Reimplemented in SelectionDismantle, and ref_clone_changer. Definition at line 334 of file changer.h. References Changer::at_selection(). Referenced by switchNode::change(). |
|
Definition at line 319 of file changer.h. References Changer::at_stmt(). Referenced by Changer::at_case(), and Changer::at_label(). |
|
Reimplemented in AllocSizeChanger, and UpdateTdefChanger. Definition at line 247 of file changer.h. References Changer::at_type(). Referenced by tdefNode::change(). |
|
Reimplemented in TernaryDismantle. Definition at line 298 of file changer.h. References Changer::at_expr(). Referenced by ternaryNode::change(). |
|
Definition at line 376 of file changer.h. References Changer::at_node(). Referenced by textNode::change(). |
|
Reimplemented in SizeofChanger, FlattenDismantle, function_inline, constantPropChanger, constantFoldingChanger, deadCodeEliminationChanger, constantsChanger, and deadcodeChanger. Definition at line 373 of file changer.h. References Changer::at_stmt(). Referenced by threeAddrNode::change(). |
|
Reimplemented in TernaryDismantle, and ExpressionDismantle. Definition at line 241 of file changer.h. References Changer::at_node(). Referenced by Changer::at_array(), Changer::at_func(), Changer::at_prim(), Changer::at_ptr(), Changer::at_sue(), Changer::at_suespec(), and Changer::at_tdef(). |
|
Reimplemented in AllocSizeChanger, and ExpressionDismantle. Definition at line 289 of file changer.h. References Changer::at_expr(). Referenced by unaryNode::change(). |
|
Reimplemented in AllocSizeChanger. Definition at line 265 of file changer.h. References Changer::at_sue(). Referenced by unionNode::change(). |
|
Reimplemented in Dismantle, StaticToGlobalDismantle, and Optimizer. Definition at line 226 of file changer.h. References Changer::at_node(). Referenced by unitNode::change(). |
|
Reimplemented in LoopDismantle. Definition at line 340 of file changer.h. References Changer::at_loop(). Referenced by whileNode::change(). |
|
Copy propagation on one procedure.
Definition at line 557 of file copyprop.cc. References procNode::change(). |
|
Copy propagation on one unit.
Definition at line 551 of file copyprop.cc. References change(), def_list_p, unitNode::defs(), and Proc. |
|
Copy propagation on entire program.
Definition at line 545 of file copyprop.cc. References CBZ::Program, and unit_list_p. Referenced by change(), and copypropphase::run(). |
|
Definition at line 519 of file copyprop.cc. References idNode::decl(), decl_set, and decl_set_p. |
|
Definition at line 503 of file copyprop.cc. References operandNode::addr(), Id, operandNode::index(), LirUtil::new_id(), and operandNode::var(). Referenced by local_copy_prop(). |
|
Definition at line 296 of file copyprop.cc. References _top, ambiguous, copyFlowVal::clone(), copies, idNode::decl(), defines, copyFlowVal::insert(), stmt_list_p, blockNode::stmts(), ThreeAddr, threeAddr_set, and threeAddr_set_p. Referenced by at_proc(). |
|
Definition at line 333 of file copyprop.cc. References _bottom, _top, ambiguous, copyFlowVal::clone(), decl_set, defines, Gen, copyFlowVal::insert(), stmt_list_p, blockNode::stmts(), ThreeAddr, threeAddr_set, and threeAddr_set_p. Referenced by at_proc(). |
|
Return whether this Changer deletes Nodes which are removed from the AST by "at_" methods.
Definition at line 209 of file changer.h. Referenced by subdeclNode::change(), change_list(), and Changer::Changer(). |
|
Return which Nodes of an AST should be visited. A value of SubTree specifies that the entire AST should be traversed. A value of NodeOnly specifies that only the root Node in the AST should be visited. |
|
Definition at line 411 of file copyprop.cc. References ACP, ambiguous, threeAddrNode::arg_list(), Condition, copies, copy_value(), Expr, returnNode::expr(), operandNode::fields(), Goto, Id, In, operandNode::index(), Label, conditiongotoNode::left(), threeAddrNode::lhs(), LirUtil::new_id(), operand_list_p, remove_ACP(), Return, threeAddrNode::rhs1(), threeAddrNode::rhs2(), conditiongotoNode::right(), operandNode::star(), stmt_list_p, blockNode::stmts(), ThreeAddr, threeAddr_set, threeAddr_set_p, operandNode::var(), and Var_pair. Referenced by at_proc(). |
|
|
Definition at line 494 of file copyprop.cc. References Var_pair. Referenced by local_copy_prop(). |
|
Definition at line 370 of file copyprop.cc. References _top, basicblock_list_p, copyFlowVal::clone(), copyFlowVal::copy(), copyFlowVal::diff(), copyFlowVal::Difference(), In, copyFlowVal::Intersect(), Out, basicblockNode::preds(), stmt_list, stmt_list_p, basicblockNode::succs(), copyFlowVal::to_top(), and copyFlowVal::Union(). Referenced by at_proc(). |
|
Definition at line 101 of file copyprop.h. Referenced by at_proc(), and create_kill_set(). |
|
Definition at line 101 of file copyprop.h. Referenced by at_proc(), create_copy_set(), create_kill_set(), and solve_global_dataflow(). |
|
Definition at line 87 of file copyprop.h. Referenced by at_proc(), GetDefsWalker::at_threeAddr(), create_copy_set(), create_kill_set(), and local_copy_prop(). |
|
Definition at line 87 of file copyprop.h. Referenced by at_proc(), create_copy_set(), and local_copy_prop(). |
|
Definition at line 90 of file copyprop.h. Referenced by at_proc(), create_copy_set(), and create_kill_set(). |
|
Definition at line 103 of file copyprop.h. Referenced by at_proc(), and create_kill_set(). |
|
Definition at line 103 of file copyprop.h. Referenced by at_proc(), local_copy_prop(), and solve_global_dataflow(). |
|
Definition at line 103 of file copyprop.h. Referenced by at_proc(). |
|
Definition at line 103 of file copyprop.h. Referenced by at_proc(), and solve_global_dataflow(). |
Generated on August 27, 2003
Back to the C-Breeze home page