subnode.hpp revision 1396
1472N/A * Copyright 1997-2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1472N/A * CA 95054 USA or visit www.sun.com if you need additional information or 1879N/A// Portions of code courtesy of Clifford Click 1879N/A//------------------------------SUBNode---------------------------------------- 1879N/A// Class SUBTRACTION functionality. This covers all the usual 'subtract' 1879N/A// behaviors. Subtract-integer, -float, -double, binary xor, compare-integer, 1879N/A// -float, and -double are all inherited from this class. The compare 1879N/A// functions behave like subtract functions, except that all negative answers 1879N/A// are compressed into -1, and all positive answers compressed to 1. 1879N/A // Handle algebraic identities here. If we have an identity, return the Node 1879N/A // we are equivalent to. We look for "add of zero" as an identity. 1879N/A // Compute a new Type for this node. Basically we just do the pre-check, 0N/A // then call the virtual add() to set the type. 0N/A // Supplied function returns the subtractend of the inputs. 0N/A // This also type-checks the inputs for sanity. Guaranteed never to 0N/A // be passed a TOP or BOTTOM type, these are filtered out by a pre-check. 0N/A // Supplied function to return the additive identity type. 0N/A // This is returned whenever the subtracts inputs are the same. 0N/A// NOTE: SubINode should be taken away and replaced by add and negate 0N/A//------------------------------SubINode--------------------------------------- 0N/A// Subtract 2 integers 0N/A//------------------------------SubLNode--------------------------------------- 0N/A// Subtract 2 integers 0N/A// NOTE: SubFPNode should be taken away and replaced by add and negate 0N/A//------------------------------SubFPNode-------------------------------------- 0N/A// Subtract 2 floats or doubles 0N/A// NOTE: SubFNode should be taken away and replaced by add and negate 0N/A//------------------------------SubFNode--------------------------------------- 0N/A// Subtract 2 doubles 0N/A// NOTE: SubDNode should be taken away and replaced by add and negate 0N/A//------------------------------SubDNode--------------------------------------- 0N/A// Subtract 2 doubles 0N/A//------------------------------CmpNode--------------------------------------- 0N/A// Compare 2 values, returning condition codes (-1, 0 or 1). 0N/A//------------------------------CmpINode--------------------------------------- 0N/A// Compare 2 signed values, returning condition codes (-1, 0 or 1). 0N/A//------------------------------CmpUNode--------------------------------------- 0N/A// Compare 2 unsigned values (integer or pointer), returning condition codes (-1, 0 or 1). 0N/A//------------------------------CmpPNode--------------------------------------- 304N/A// Compare 2 pointer values, returning condition codes (-1, 0 or 1). 0N/A//------------------------------CmpNNode-------------------------------------- 0N/A// Compare 2 narrow oop values, returning condition codes (-1, 0 or 1). 0N/A//------------------------------CmpLNode--------------------------------------- 0N/A// Compare 2 long values, returning condition codes (-1, 0 or 1). 0N/A//------------------------------CmpL3Node-------------------------------------- 0N/A// Compare 2 long values, returning integer value (-1, 0 or 1). 1601N/A // Since it is not consumed by Bools, it is not really a Cmp. 0N/A//------------------------------CmpFNode--------------------------------------- 0N/A// Compare 2 float values, returning condition codes (-1, 0 or 1). 0N/A// This implements the Java bytecode fcmpl, so unordered returns -1. 0N/A// Operands may not commute. 0N/A//------------------------------CmpF3Node-------------------------------------- 0N/A// Compare 2 float values, returning integer value (-1, 0 or 1). 0N/A// This implements the Java bytecode fcmpl, so unordered returns -1. 0N/A// Operands may not commute. 0N/A // Since it is not consumed by Bools, it is not really a Cmp. 0N/A // Since it is not consumed by Bools, it is not really a Cmp. 0N/A//------------------------------CmpDNode--------------------------------------- 0N/A// Compare 2 double values, returning condition codes (-1, 0 or 1). 0N/A// This implements the Java bytecode dcmpl, so unordered returns -1. 0N/A// Operands may not commute. 0N/A//------------------------------CmpD3Node-------------------------------------- 0N/A// Compare 2 double values, returning integer value (-1, 0 or 1). 0N/A// This implements the Java bytecode dcmpl, so unordered returns -1. 0N/A// Operands may not commute. 0N/A // Since it is not consumed by Bools, it is not really a Cmp. 0N/A//------------------------------BoolTest--------------------------------------- 0N/A// Convert condition codes to a boolean test value (0 or -1). 0N/A// We pick the values as 3 bits; the low order 2 bits we compare against the 0N/A// condition codes, the high bit flips the sense of the result. 0N/A // Commute the test. I use a small table lookup. The table is created as 0N/A // a simple char array where each element is the ASCII version of a 'mask' 0N/A//------------------------------BoolNode--------------------------------------- 0N/A// A Node to convert a Condition Codes to a Logical result. 0N/A // Convert an arbitrary int value to a Bool or other suitable predicate. 0N/A // Convert self back to an integer value. 0N/A // Invert sense of self, returning new Bool. 0N/A//------------------------------AbsNode---------------------------------------- 0N/A// Abstract class for absolute value. Mostly used to get a handy wrapper 0N/A// for finding this pattern in the graph. 0N/A//------------------------------AbsINode--------------------------------------- 0N/A// Absolute value an integer. Since a naive graph involves control flow, we 0N/A// "match" it in the ideal world (so the control flow can be removed). 0N/A//------------------------------AbsFNode--------------------------------------- 0N/A// Absolute value a float, a common float-point idiom with a cheap hardware 0N/A// implemention on most chips. Since a naive graph involves control flow, we 0N/A// "match" it in the ideal world (so the control flow can be removed). 0N/A//------------------------------AbsDNode--------------------------------------- 0N/A// Absolute value a double, a common float-point idiom with a cheap hardware 0N/A// implemention on most chips. Since a naive graph involves control flow, we 0N/A// "match" it in the ideal world (so the control flow can be removed). 0N/A//------------------------------CmpLTMaskNode---------------------------------- 0N/A// If p < q, return -1 else return 0. Nice for flow-free idioms. 0N/A//------------------------------NegNode---------------------------------------- 0N/A//------------------------------NegFNode--------------------------------------- 0N/A// Negate value a float. Negating 0.0 returns -0.0, but subtracting from 0N/A// zero returns +0.0 (per JVM spec on 'fneg' bytecode). As subtraction 0N/A// cannot be used to replace negation we have to implement negation as ideal 0N/A// node; note that negation and addition can replace subtraction. 0N/A//------------------------------NegDNode--------------------------------------- 0N/A// Negate value a double. Negating 0.0 returns -0.0, but subtracting from 0N/A// zero returns +0.0 (per JVM spec on 'dneg' bytecode). As subtraction 0N/A// cannot be used to replace negation we have to implement negation as ideal 0N/A// node; note that negation and addition can replace subtraction. 0N/A//------------------------------CosDNode--------------------------------------- 0N/A// Cosinus of a double 0N/A//------------------------------CosDNode--------------------------------------- 0N/A//------------------------------TanDNode--------------------------------------- 0N/A// tangens of a double 0N/A//------------------------------AtanDNode-------------------------------------- 0N/A// arcus tangens of a double 0N/A//------------------------------SqrtDNode-------------------------------------- 0N/A// square root a double 0N/A//------------------------------ExpDNode--------------------------------------- 0N/A// Exponentiate a double 0N/A//------------------------------LogDNode--------------------------------------- 0N/A//------------------------------Log10DNode--------------------------------------- 0N/A// Log_10 of a double 0N/A//------------------------------PowDNode--------------------------------------- 0N/A// Raise a double to a double power 0N/A//-------------------------------ReverseBytesINode-------------------------------- 0N/A// reverse bytes of an integer 0N/A//-------------------------------ReverseBytesLNode-------------------------------- 0N/A// reverse bytes of a long 0N/A//-------------------------------ReverseBytesUSNode-------------------------------- 0N/A// reverse bytes of an unsigned short / char 0N/A//-------------------------------ReverseBytesSNode-------------------------------- 0N/A// reverse bytes of a short