chaitin.hpp revision 3982
3845N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A//------------------------------LRG-------------------------------------------- 0N/A// Live-RanGe structure. 0N/A enum {
SPILL_REG=
29999 };
// Register number of a spilled LRG 0N/A double _cost;
// 2 for loads/1 for stores times block freq 0N/A double _area;
// Sum of all simultaneously live values 0N/A double score()
const;
// Compute score from cost and area 0N/A double _maxfreq;
// Maximum frequency of any def or use 0N/A uint _reg;
// Chosen register; undefined if mask is plural 0N/A // Return chosen register for this LRG. Error if the LRG is not bound to 0N/A // a single register. 0N/A // Degree starts not valid and any change to the IFG neighbor 0N/A // set makes it not valid. 0N/A // Made a change that hammered degree 0N/A // Incrementally modify degree. If it was correct, it should remain correct 0N/A // Compute the degree between 2 live ranges 0N/A // Get the last mask size computed, even if it does not match the 0N/A // count of bits in the current mask. 0N/A // Number of registers this live range uses when it colors 0N/A // except _num_regs is kill count for fat_proj 0N/A // Number of physical registers this live range uses when it colors 0N/A // Architecture and register-set dependent 0N/A // How much 'wiggle room' does this live range have? 0N/A // How many color choices can it make (scaled by _num_regs)? 0N/A // Bound LRGs have ZERO degrees of freedom. We also count 0N/A // must_spill as bound. 0N/A // Negative degrees-of-freedom; even with no neighbors this 0N/A // live range must spill. 0N/A // Is this live range of "low-degree"? Trivially colorable? 0N/A // Is this live range just barely "low-degree"? Trivially colorable? 0N/A // degrees of freedom. 0N/A // If _fat_proj is set, live range does NOT require aligned, adjacent 0N/A // registers and has NO interferences. 0N/A // If _fat_proj is clear, live range requires num_regs() to be a power of 0N/A // 2, and it requires registers to form an aligned, adjacent set. 0N/A _at_risk:
1;
// Simplify says this guy is at risk to spill 0N/A // Alive if non-zero, dead if zero 0N/A//------------------------------LRG_List--------------------------------------- 0N/A// Map Node indices to Live RanGe indices. 0N/A// Array lookup in the optimized case. 0N/A//------------------------------IFG-------------------------------------------- 0N/A// InterFerence Graph 0N/A// An undirected graph implementation. Created with a fixed number of 0N/A// vertices. Edges can be added & tested. Vertices can be removed, then 0N/A// added back later with all edges intact. Can add edges between one vertex 0N/A// and a list of other vertices. Can union vertices (and their edges) 0N/A// together. The IFG needs to be really really fast, and also fairly 0N/A// abstract! It needs abstraction so I can fiddle with the implementation to 0N/A// get even more speed. 0N/A // Current implementation: a triangular adjacency list. 0N/A // Array of adjacency-lists, indexed by live-range number 0N/A // Assertion bit for proper use of Squaring 0N/A // Live range structure goes here 0N/A // Largest live-range number 0N/A // Keep track of inserted and deleted Nodes 0N/A // Add edge between a and b. Returns true if actually addded. 0N/A // Add edge between a and everything in the vector 0N/A // Test for edge existance 0N/A // Square-up matrix for faster Union 0N/A // Return number of LRG neighbors 0N/A // Union edges of b into a on Squared-up matrix 0N/A // Test for edge in Squared-up matrix 0N/A // Yank a Node and all connected edges from the IFG. Be prepared to 0N/A // re-insert the yanked Node in reverse order of yanking. Return a 0N/A // list of neighbors (edges) yanked. 0N/A // Reinsert a yanked Node 0N/A // Return set of neighbors 0N/A //--------------- Live Range Accessors 0N/A // Compute and set effective degree. Might be folded into SquareUp(). 0N/A // Compute effective degree as the sum of neighbors' _sizes. 0N/A// TEMPORARILY REPLACED WITH COMMAND LINE FLAG 0N/A//// !!!!! Magic Constants need to move into ad file 0N/A//#define FLOAT_PRESSURE 30 /* SFLT_REG_mask.Size() - 1 */ 0N/A//#define INT_PRESSURE 23 /* NOTEMP_I_REG_mask.Size() - 1 */ 0N/A//#define FLOAT_PRESSURE 6 0N/A//#define INT_PRESSURE 6 0N/A//------------------------------Chaitin---------------------------------------- 0N/A// Briggs-Chaitin style allocation, mostly. 0N/A // Union-find map. Declared as a short for speed. 0N/A // Indexed by live-range number, it returns the compacted live-range number 0N/A // Reset the Union-Find map to identity 0N/A // Remove the need for the Union-Find mapping 0N/A // Combine the Live Range Indices for these 2 Nodes into a single live 0N/A // range. Future requests for any Node in either live range will 0N/A // return the live range index for the combined live range. 0N/A // Compact live ranges, removing unused ones. Return new maxlrg. 0N/A // Helper functions for Split() 0N/A // True if lidx is used before any real register is def'd in the block 605N/A // Insert the spill at chosen location. Skip over any intervening Proj's or 0N/A // Phis. Skip over a CatchNode and projs, inserting in the fall-through block 0N/A // instead. Update high-pressure indices. Create a new live range. 0N/A Block **
_blks;
// Array of blocks sorted by frequency for coalescing 0N/A // Convert a Node into a Live Range Index - a lidx 0N/A // Do all the real work of allocate 0N/A // De-SSA the world. Assign registers to Nodes. Use the same register for 0N/A // all inputs to a PhiNode, effectively coalescing live ranges. Insert 0N/A // copies as needed. 0N/A // Add edge between reg and everything in the vector. 0N/A // Same as _ifg->add_vector(reg,live) EXCEPT use the RegMask 0N/A // information to trim the set of interferences. Return the 0N/A // count of edges added. 0N/A // Count register pressure for asserts 0N/A // Build the interference graph using virtual registers only. 0N/A // Used for aggressive coalescing. 0N/A // Build the interference graph using physical registers when available. 0N/A // That is, if 2 live ranges are simultaneously alive but in their 0N/A // acceptable register sets do not overlap, then they do not interfere. 0N/A // Gather LiveRanGe information, including register masks and base pointer/ 0N/A // derived pointer relationships. 0N/A // Force the bases of derived pointers to be alive at GC points. 0N/A // Helper to stretch above; recursively discover the base Node for 0N/A // a given derived Node. Easy for AddP-related machine nodes, but 0N/A // needs to be recursive for derived Phis. 0N/A // Set the was-lo-degree bit. Conservative coalescing should not change the 0N/A // colorability of the graph. If any live range was of low-degree before 0N/A // coalescing, it should Simplify. This call sets the was-lo-degree bit. 0N/A // Split live-ranges that must spill due to register conflicts (as opposed 0N/A // to capacity spills). Typically these are things def'd in a register 0N/A // and used on the stack or vice-versa. 0N/A // Init LRG caching of degree, numregs. Init lo_degree list. 0N/A // Simplify the IFG by removing LRGs of low degree with no copies 0N/A // Simplify the IFG by removing LRGs of low degree 0N/A // Select colors by re-inserting edges into the IFG. 605N/A // Return TRUE if any spills occurred. 0N/A // Helper function for select which allows biased coloring 0N/A // Helper function which implements biasing heuristic 0N/A // Split uncolorable live ranges 0N/A // Return new number of live ranges 0N/A // Copy 'was_spilled'-edness from one Node to another. 0N/A // Set the 'spilled_once' or 'spilled_twice' flag on a node. 0N/A // Convert ideal spill-nodes into machine loads & stores 0N/A // Set C->failing when fixup spills could not complete, node limit exceeded. 0N/A // Post-Allocation peephole copy removal 923N/A // Replace the old node with the current live version of that value 923N/A // and yank the old value if it's dead. 0N/A // If nreg already contains the same constant as val then eliminate it 0N/A // Extend the node to LRG mapping 1923N/A // dump defs and uses by default 0N/A // Verify that base pointers and derived pointers are still sane 1879N/A#
endif // SHARE_VM_OPTO_CHAITIN_HPP