1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/coalesce.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,109 @@ 1.4 +/* 1.5 + * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +class LoopTree; 1.29 +class LRG; 1.30 +class LRG_List; 1.31 +class Matcher; 1.32 +class PhaseIFG; 1.33 +class PhaseCFG; 1.34 + 1.35 +//------------------------------PhaseCoalesce---------------------------------- 1.36 +class PhaseCoalesce : public Phase { 1.37 +protected: 1.38 + PhaseChaitin &_phc; 1.39 + 1.40 +public: 1.41 + // Coalesce copies 1.42 + PhaseCoalesce( PhaseChaitin &chaitin ) : Phase(Coalesce), _phc(chaitin) { } 1.43 + 1.44 + virtual void verify() = 0; 1.45 + 1.46 + // Coalesce copies 1.47 + void coalesce_driver( ); 1.48 + 1.49 + // Coalesce copies in this block 1.50 + virtual void coalesce( Block *b ) = 0; 1.51 + 1.52 + // Attempt to coalesce live ranges defined by these 2 1.53 + void combine_these_two( Node *n1, Node *n2 ); 1.54 + 1.55 + LRG &lrgs( uint lidx ) { return _phc.lrgs(lidx); } 1.56 +#ifndef PRODUCT 1.57 + // Dump internally name 1.58 + void dump( Node *n ) const; 1.59 + // Dump whole shebang 1.60 + void dump() const; 1.61 +#endif 1.62 +}; 1.63 + 1.64 +//------------------------------PhaseAggressiveCoalesce------------------------ 1.65 +// Aggressively, pessimistic coalesce copies. Aggressive means ignore graph 1.66 +// colorability; perhaps coalescing to the point of forcing a spill. 1.67 +// Pessimistic means we cannot coalesce if 2 live ranges interfere. This 1.68 +// implies we do not hit a fixed point right away. 1.69 +class PhaseAggressiveCoalesce : public PhaseCoalesce { 1.70 + uint _unique; 1.71 +public: 1.72 + // Coalesce copies 1.73 + PhaseAggressiveCoalesce( PhaseChaitin &chaitin ) : PhaseCoalesce(chaitin) {} 1.74 + 1.75 + virtual void verify() { }; 1.76 + 1.77 + // Aggressively coalesce copies in this block 1.78 + virtual void coalesce( Block *b ); 1.79 + 1.80 + // Where I fail to coalesce, manifest virtual copies as the Real Thing 1.81 + void insert_copies( Matcher &matcher ); 1.82 + 1.83 + // Copy insertion needs some smarts in case live ranges overlap 1.84 + void insert_copy_with_overlap( Block *b, Node *copy, uint dst_name, uint src_name ); 1.85 +}; 1.86 + 1.87 + 1.88 +//------------------------------PhaseConservativeCoalesce---------------------- 1.89 +// Conservatively, pessimistic coalesce copies. Conservative means do not 1.90 +// coalesce if the resultant live range will be uncolorable. Pessimistic 1.91 +// means we cannot coalesce if 2 live ranges interfere. This implies we do 1.92 +// not hit a fixed point right away. 1.93 +class PhaseConservativeCoalesce : public PhaseCoalesce { 1.94 + IndexSet _ulr; // Union live range interferences 1.95 +public: 1.96 + // Coalesce copies 1.97 + PhaseConservativeCoalesce( PhaseChaitin &chaitin ); 1.98 + 1.99 + virtual void verify(); 1.100 + 1.101 + // Conservatively coalesce copies in this block 1.102 + virtual void coalesce( Block *b ); 1.103 + 1.104 + // Coalesce this chain of copies away 1.105 + bool copy_copy( Node *dst_copy, Node *src_copy, Block *b, uint bindex ); 1.106 + 1.107 + 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 ); 1.108 + 1.109 + 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); 1.110 + 1.111 + void update_ifg(uint lr1, uint lr2, IndexSet *n_lr1, IndexSet *n_lr2); 1.112 +};