Path: blob/master/src/hotspot/share/opto/coalesce.hpp
40930 views
/*1* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_OPTO_COALESCE_HPP25#define SHARE_OPTO_COALESCE_HPP2627#include "opto/phase.hpp"2829class LoopTree;30class LRG;31class Matcher;32class PhaseIFG;33class PhaseCFG;3435//------------------------------PhaseCoalesce----------------------------------36class PhaseCoalesce : public Phase {37protected:38PhaseChaitin &_phc;3940public:41// Coalesce copies42PhaseCoalesce(PhaseChaitin &phc)43: Phase(Coalesce)44, _phc(phc) {}4546virtual void verify() = 0;4748// Coalesce copies49void coalesce_driver();5051// Coalesce copies in this block52virtual void coalesce(Block *b) = 0;5354// Attempt to coalesce live ranges defined by these 255void combine_these_two(Node *n1, Node *n2);5657LRG &lrgs(uint lidx) { return _phc.lrgs(lidx); }58#ifndef PRODUCT59// Dump internally name60void dump(Node *n) const;61// Dump whole shebang62void dump() const;63#endif64};6566//------------------------------PhaseAggressiveCoalesce------------------------67// Aggressively, pessimistic coalesce copies. Aggressive means ignore graph68// colorability; perhaps coalescing to the point of forcing a spill.69// Pessimistic means we cannot coalesce if 2 live ranges interfere. This70// implies we do not hit a fixed point right away.71class PhaseAggressiveCoalesce : public PhaseCoalesce {72uint _unique;73public:74// Coalesce copies75PhaseAggressiveCoalesce( PhaseChaitin &chaitin ) : PhaseCoalesce(chaitin) {}7677virtual void verify() { };7879// Aggressively coalesce copies in this block80virtual void coalesce( Block *b );8182// Where I fail to coalesce, manifest virtual copies as the Real Thing83void insert_copies( Matcher &matcher );8485// Copy insertion needs some smarts in case live ranges overlap86void insert_copy_with_overlap( Block *b, Node *copy, uint dst_name, uint src_name );87};888990//------------------------------PhaseConservativeCoalesce----------------------91// Conservatively, pessimistic coalesce copies. Conservative means do not92// coalesce if the resultant live range will be uncolorable. Pessimistic93// means we cannot coalesce if 2 live ranges interfere. This implies we do94// not hit a fixed point right away.95class PhaseConservativeCoalesce : public PhaseCoalesce {96IndexSet _ulr; // Union live range interferences97public:98// Coalesce copies99PhaseConservativeCoalesce( PhaseChaitin &chaitin );100101virtual void verify();102103// Conservatively coalesce copies in this block104virtual void coalesce( Block *b );105106// Coalesce this chain of copies away107bool copy_copy( Node *dst_copy, Node *src_copy, Block *b, uint bindex );108109void 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 );110111uint 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);112113void update_ifg(uint lr1, uint lr2, IndexSet *n_lr1, IndexSet *n_lr2);114};115116#endif // SHARE_OPTO_COALESCE_HPP117118119