0N/A/*
1879N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OPTO_COALESCE_HPP
1879N/A#define SHARE_VM_OPTO_COALESCE_HPP
1879N/A
1879N/A#include "opto/phase.hpp"
1879N/A
0N/Aclass LoopTree;
0N/Aclass LRG;
0N/Aclass LRG_List;
0N/Aclass Matcher;
0N/Aclass PhaseIFG;
0N/Aclass PhaseCFG;
0N/A
0N/A//------------------------------PhaseCoalesce----------------------------------
0N/Aclass PhaseCoalesce : public Phase {
0N/Aprotected:
0N/A PhaseChaitin &_phc;
0N/A
0N/Apublic:
0N/A // Coalesce copies
0N/A PhaseCoalesce( PhaseChaitin &chaitin ) : Phase(Coalesce), _phc(chaitin) { }
0N/A
0N/A virtual void verify() = 0;
0N/A
0N/A // Coalesce copies
0N/A void coalesce_driver( );
0N/A
0N/A // Coalesce copies in this block
0N/A virtual void coalesce( Block *b ) = 0;
0N/A
0N/A // Attempt to coalesce live ranges defined by these 2
0N/A void combine_these_two( Node *n1, Node *n2 );
0N/A
0N/A LRG &lrgs( uint lidx ) { return _phc.lrgs(lidx); }
0N/A#ifndef PRODUCT
0N/A // Dump internally name
0N/A void dump( Node *n ) const;
0N/A // Dump whole shebang
0N/A void dump() const;
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------PhaseAggressiveCoalesce------------------------
0N/A// Aggressively, pessimistic coalesce copies. Aggressive means ignore graph
0N/A// colorability; perhaps coalescing to the point of forcing a spill.
0N/A// Pessimistic means we cannot coalesce if 2 live ranges interfere. This
0N/A// implies we do not hit a fixed point right away.
0N/Aclass PhaseAggressiveCoalesce : public PhaseCoalesce {
0N/A uint _unique;
0N/Apublic:
0N/A // Coalesce copies
0N/A PhaseAggressiveCoalesce( PhaseChaitin &chaitin ) : PhaseCoalesce(chaitin) {}
0N/A
0N/A virtual void verify() { };
0N/A
0N/A // Aggressively coalesce copies in this block
0N/A virtual void coalesce( Block *b );
0N/A
0N/A // Where I fail to coalesce, manifest virtual copies as the Real Thing
0N/A void insert_copies( Matcher &matcher );
0N/A
0N/A // Copy insertion needs some smarts in case live ranges overlap
0N/A void insert_copy_with_overlap( Block *b, Node *copy, uint dst_name, uint src_name );
0N/A};
0N/A
0N/A
0N/A//------------------------------PhaseConservativeCoalesce----------------------
0N/A// Conservatively, pessimistic coalesce copies. Conservative means do not
0N/A// coalesce if the resultant live range will be uncolorable. Pessimistic
0N/A// means we cannot coalesce if 2 live ranges interfere. This implies we do
0N/A// not hit a fixed point right away.
0N/Aclass PhaseConservativeCoalesce : public PhaseCoalesce {
0N/A IndexSet _ulr; // Union live range interferences
0N/Apublic:
0N/A // Coalesce copies
0N/A PhaseConservativeCoalesce( PhaseChaitin &chaitin );
0N/A
0N/A virtual void verify();
0N/A
0N/A // Conservatively coalesce copies in this block
0N/A virtual void coalesce( Block *b );
0N/A
0N/A // Coalesce this chain of copies away
0N/A bool copy_copy( Node *dst_copy, Node *src_copy, Block *b, uint bindex );
0N/A
0N/A void union_helper( Node *lr1_node, Node *lr2_node, uint lr1, uint lr2, Node *src_def, Node *dst_copy, Node *src_copy, Block *b, uint bindex );
0N/A
0N/A uint compute_separating_interferences(Node *dst_copy, Node *src_copy, Block *b, uint bindex, RegMask &rm, uint rm_size, uint reg_degree, uint lr1, uint lr2);
0N/A
0N/A void update_ifg(uint lr1, uint lr2, IndexSet *n_lr1, IndexSet *n_lr2);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_OPTO_COALESCE_HPP