aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_OPTO_SUBNODE_HPP aoqi@0: #define SHARE_VM_OPTO_SUBNODE_HPP aoqi@0: aoqi@0: #include "opto/node.hpp" aoqi@0: #include "opto/opcodes.hpp" aoqi@0: #include "opto/type.hpp" aoqi@0: aoqi@0: // Portions of code courtesy of Clifford Click aoqi@0: aoqi@0: //------------------------------SUBNode---------------------------------------- aoqi@0: // Class SUBTRACTION functionality. This covers all the usual 'subtract' aoqi@0: // behaviors. Subtract-integer, -float, -double, binary xor, compare-integer, aoqi@0: // -float, and -double are all inherited from this class. The compare aoqi@0: // functions behave like subtract functions, except that all negative answers aoqi@0: // are compressed into -1, and all positive answers compressed to 1. aoqi@0: class SubNode : public Node { aoqi@0: public: aoqi@0: SubNode( Node *in1, Node *in2 ) : Node(0,in1,in2) { aoqi@0: init_class_id(Class_Sub); aoqi@0: } aoqi@0: aoqi@0: // Handle algebraic identities here. If we have an identity, return the Node aoqi@0: // we are equivalent to. We look for "add of zero" as an identity. aoqi@0: virtual Node *Identity( PhaseTransform *phase ); aoqi@0: aoqi@0: // Compute a new Type for this node. Basically we just do the pre-check, aoqi@0: // then call the virtual add() to set the type. aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: const Type* Value_common( PhaseTransform *phase ) const; aoqi@0: aoqi@0: // Supplied function returns the subtractend of the inputs. aoqi@0: // This also type-checks the inputs for sanity. Guaranteed never to aoqi@0: // be passed a TOP or BOTTOM type, these are filtered out by a pre-check. aoqi@0: virtual const Type *sub( const Type *, const Type * ) const = 0; aoqi@0: aoqi@0: // Supplied function to return the additive identity type. aoqi@0: // This is returned whenever the subtracts inputs are the same. aoqi@0: virtual const Type *add_id() const = 0; aoqi@0: aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: // NOTE: SubINode should be taken away and replaced by add and negate aoqi@0: //------------------------------SubINode--------------------------------------- aoqi@0: // Subtract 2 integers aoqi@0: class SubINode : public SubNode { aoqi@0: public: aoqi@0: SubINode( Node *in1, Node *in2 ) : SubNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: const Type *add_id() const { return TypeInt::ZERO; } aoqi@0: const Type *bottom_type() const { return TypeInt::INT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------SubLNode--------------------------------------- aoqi@0: // Subtract 2 integers aoqi@0: class SubLNode : public SubNode { aoqi@0: public: aoqi@0: SubLNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: const Type *add_id() const { return TypeLong::ZERO; } aoqi@0: const Type *bottom_type() const { return TypeLong::LONG; } aoqi@0: virtual uint ideal_reg() const { return Op_RegL; } aoqi@0: }; aoqi@0: aoqi@0: // NOTE: SubFPNode should be taken away and replaced by add and negate aoqi@0: //------------------------------SubFPNode-------------------------------------- aoqi@0: // Subtract 2 floats or doubles aoqi@0: class SubFPNode : public SubNode { aoqi@0: protected: aoqi@0: SubFPNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {} aoqi@0: public: aoqi@0: const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: // NOTE: SubFNode should be taken away and replaced by add and negate aoqi@0: //------------------------------SubFNode--------------------------------------- aoqi@0: // Subtract 2 doubles aoqi@0: class SubFNode : public SubFPNode { aoqi@0: public: aoqi@0: SubFNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: const Type *add_id() const { return TypeF::ZERO; } aoqi@0: const Type *bottom_type() const { return Type::FLOAT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegF; } aoqi@0: }; aoqi@0: aoqi@0: // NOTE: SubDNode should be taken away and replaced by add and negate aoqi@0: //------------------------------SubDNode--------------------------------------- aoqi@0: // Subtract 2 doubles aoqi@0: class SubDNode : public SubFPNode { aoqi@0: public: aoqi@0: SubDNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: const Type *add_id() const { return TypeD::ZERO; } aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpNode--------------------------------------- aoqi@0: // Compare 2 values, returning condition codes (-1, 0 or 1). aoqi@0: class CmpNode : public SubNode { aoqi@0: public: aoqi@0: CmpNode( Node *in1, Node *in2 ) : SubNode(in1,in2) { aoqi@0: init_class_id(Class_Cmp); aoqi@0: } aoqi@0: virtual Node *Identity( PhaseTransform *phase ); aoqi@0: const Type *add_id() const { return TypeInt::ZERO; } aoqi@0: const Type *bottom_type() const { return TypeInt::CC; } aoqi@0: virtual uint ideal_reg() const { return Op_RegFlags; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpINode--------------------------------------- aoqi@0: // Compare 2 signed values, returning condition codes (-1, 0 or 1). aoqi@0: class CmpINode : public CmpNode { aoqi@0: public: aoqi@0: CmpINode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpUNode--------------------------------------- aoqi@0: // Compare 2 unsigned values (integer or pointer), returning condition codes (-1, 0 or 1). aoqi@0: class CmpUNode : public CmpNode { aoqi@0: public: aoqi@0: CmpUNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: const Type *Value( PhaseTransform *phase ) const; aoqi@0: bool is_index_range_check() const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpPNode--------------------------------------- aoqi@0: // Compare 2 pointer values, returning condition codes (-1, 0 or 1). aoqi@0: class CmpPNode : public CmpNode { aoqi@0: public: aoqi@0: CmpPNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpNNode-------------------------------------- aoqi@0: // Compare 2 narrow oop values, returning condition codes (-1, 0 or 1). aoqi@0: class CmpNNode : public CmpNode { aoqi@0: public: aoqi@0: CmpNNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpLNode--------------------------------------- aoqi@0: // Compare 2 long values, returning condition codes (-1, 0 or 1). aoqi@0: class CmpLNode : public CmpNode { aoqi@0: public: aoqi@0: CmpLNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual const Type *sub( const Type *, const Type * ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpL3Node-------------------------------------- aoqi@0: // Compare 2 long values, returning integer value (-1, 0 or 1). aoqi@0: class CmpL3Node : public CmpLNode { aoqi@0: public: aoqi@0: CmpL3Node( Node *in1, Node *in2 ) : CmpLNode(in1,in2) { aoqi@0: // Since it is not consumed by Bools, it is not really a Cmp. aoqi@0: init_class_id(Class_Sub); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpFNode--------------------------------------- aoqi@0: // Compare 2 float values, returning condition codes (-1, 0 or 1). aoqi@0: // This implements the Java bytecode fcmpl, so unordered returns -1. aoqi@0: // Operands may not commute. aoqi@0: class CmpFNode : public CmpNode { aoqi@0: public: aoqi@0: CmpFNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return NULL; } aoqi@0: const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpF3Node-------------------------------------- aoqi@0: // Compare 2 float values, returning integer value (-1, 0 or 1). aoqi@0: // This implements the Java bytecode fcmpl, so unordered returns -1. aoqi@0: // Operands may not commute. aoqi@0: class CmpF3Node : public CmpFNode { aoqi@0: public: aoqi@0: CmpF3Node( Node *in1, Node *in2 ) : CmpFNode(in1,in2) { aoqi@0: // Since it is not consumed by Bools, it is not really a Cmp. aoqi@0: init_class_id(Class_Sub); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: // Since it is not consumed by Bools, it is not really a Cmp. aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: //------------------------------CmpDNode--------------------------------------- aoqi@0: // Compare 2 double values, returning condition codes (-1, 0 or 1). aoqi@0: // This implements the Java bytecode dcmpl, so unordered returns -1. aoqi@0: // Operands may not commute. aoqi@0: class CmpDNode : public CmpNode { aoqi@0: public: aoqi@0: CmpDNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return NULL; } aoqi@0: const Type *Value( PhaseTransform *phase ) const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CmpD3Node-------------------------------------- aoqi@0: // Compare 2 double values, returning integer value (-1, 0 or 1). aoqi@0: // This implements the Java bytecode dcmpl, so unordered returns -1. aoqi@0: // Operands may not commute. aoqi@0: class CmpD3Node : public CmpDNode { aoqi@0: public: aoqi@0: CmpD3Node( Node *in1, Node *in2 ) : CmpDNode(in1,in2) { aoqi@0: // Since it is not consumed by Bools, it is not really a Cmp. aoqi@0: init_class_id(Class_Sub); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: //------------------------------BoolTest--------------------------------------- aoqi@0: // Convert condition codes to a boolean test value (0 or -1). aoqi@0: // We pick the values as 3 bits; the low order 2 bits we compare against the aoqi@0: // condition codes, the high bit flips the sense of the result. aoqi@0: struct BoolTest VALUE_OBJ_CLASS_SPEC { aoqi@0: enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, illegal = 8 }; aoqi@0: mask _test; aoqi@0: BoolTest( mask btm ) : _test(btm) {} aoqi@0: const Type *cc2logical( const Type *CC ) const; aoqi@0: // Commute the test. I use a small table lookup. The table is created as aoqi@0: // a simple char array where each element is the ASCII version of a 'mask' aoqi@0: // enum from above. aoqi@0: mask commute( ) const { return mask("032147658"[_test]-'0'); } aoqi@0: mask negate( ) const { return mask(_test^4); } aoqi@0: bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le || _test == BoolTest::overflow); } aoqi@0: #ifndef PRODUCT aoqi@0: void dump_on(outputStream *st) const; aoqi@0: #endif aoqi@0: }; aoqi@0: aoqi@0: //------------------------------BoolNode--------------------------------------- aoqi@0: // A Node to convert a Condition Codes to a Logical result. aoqi@0: class BoolNode : public Node { aoqi@0: virtual uint hash() const; aoqi@0: virtual uint cmp( const Node &n ) const; aoqi@0: virtual uint size_of() const; aoqi@0: public: aoqi@0: const BoolTest _test; aoqi@0: BoolNode( Node *cc, BoolTest::mask t): _test(t), Node(0,cc) { aoqi@0: init_class_id(Class_Bool); aoqi@0: } aoqi@0: // Convert an arbitrary int value to a Bool or other suitable predicate. aoqi@0: static Node* make_predicate(Node* test_value, PhaseGVN* phase); aoqi@0: // Convert self back to an integer value. aoqi@0: Node* as_int_value(PhaseGVN* phase); aoqi@0: // Invert sense of self, returning new Bool. aoqi@0: BoolNode* negate(PhaseGVN* phase); aoqi@0: virtual int Opcode() const; aoqi@0: virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: virtual const Type *bottom_type() const { return TypeInt::BOOL; } aoqi@0: uint match_edge(uint idx) const { return 0; } aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: aoqi@0: bool is_counted_loop_exit_test(); aoqi@0: #ifndef PRODUCT aoqi@0: virtual void dump_spec(outputStream *st) const; aoqi@0: #endif aoqi@0: }; aoqi@0: aoqi@0: //------------------------------AbsNode---------------------------------------- aoqi@0: // Abstract class for absolute value. Mostly used to get a handy wrapper aoqi@0: // for finding this pattern in the graph. aoqi@0: class AbsNode : public Node { aoqi@0: public: aoqi@0: AbsNode( Node *value ) : Node(0,value) {} aoqi@0: }; aoqi@0: aoqi@0: //------------------------------AbsINode--------------------------------------- aoqi@0: // Absolute value an integer. Since a naive graph involves control flow, we aoqi@0: // "match" it in the ideal world (so the control flow can be removed). aoqi@0: class AbsINode : public AbsNode { aoqi@0: public: aoqi@0: AbsINode( Node *in1 ) : AbsNode(in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return TypeInt::INT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------AbsFNode--------------------------------------- aoqi@0: // Absolute value a float, a common float-point idiom with a cheap hardware aoqi@0: // implemention on most chips. Since a naive graph involves control flow, we aoqi@0: // "match" it in the ideal world (so the control flow can be removed). aoqi@0: class AbsFNode : public AbsNode { aoqi@0: public: aoqi@0: AbsFNode( Node *in1 ) : AbsNode(in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::FLOAT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegF; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------AbsDNode--------------------------------------- aoqi@0: // Absolute value a double, a common float-point idiom with a cheap hardware aoqi@0: // implemention on most chips. Since a naive graph involves control flow, we aoqi@0: // "match" it in the ideal world (so the control flow can be removed). aoqi@0: class AbsDNode : public AbsNode { aoqi@0: public: aoqi@0: AbsDNode( Node *in1 ) : AbsNode(in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: //------------------------------CmpLTMaskNode---------------------------------- aoqi@0: // If p < q, return -1 else return 0. Nice for flow-free idioms. aoqi@0: class CmpLTMaskNode : public Node { aoqi@0: public: aoqi@0: CmpLTMaskNode( Node *p, Node *q ) : Node(0, p, q) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return TypeInt::INT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: //------------------------------NegNode---------------------------------------- aoqi@0: class NegNode : public Node { aoqi@0: public: aoqi@0: NegNode( Node *in1 ) : Node(0,in1) {} aoqi@0: }; aoqi@0: aoqi@0: //------------------------------NegFNode--------------------------------------- aoqi@0: // Negate value a float. Negating 0.0 returns -0.0, but subtracting from aoqi@0: // zero returns +0.0 (per JVM spec on 'fneg' bytecode). As subtraction aoqi@0: // cannot be used to replace negation we have to implement negation as ideal aoqi@0: // node; note that negation and addition can replace subtraction. aoqi@0: class NegFNode : public NegNode { aoqi@0: public: aoqi@0: NegFNode( Node *in1 ) : NegNode(in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::FLOAT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegF; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------NegDNode--------------------------------------- aoqi@0: // Negate value a double. Negating 0.0 returns -0.0, but subtracting from aoqi@0: // zero returns +0.0 (per JVM spec on 'dneg' bytecode). As subtraction aoqi@0: // cannot be used to replace negation we have to implement negation as ideal aoqi@0: // node; note that negation and addition can replace subtraction. aoqi@0: class NegDNode : public NegNode { aoqi@0: public: aoqi@0: NegDNode( Node *in1 ) : NegNode(in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CosDNode--------------------------------------- aoqi@0: // Cosinus of a double aoqi@0: class CosDNode : public Node { aoqi@0: public: aoqi@0: CosDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------CosDNode--------------------------------------- aoqi@0: // Sinus of a double aoqi@0: class SinDNode : public Node { aoqi@0: public: aoqi@0: SinDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: //------------------------------TanDNode--------------------------------------- aoqi@0: // tangens of a double aoqi@0: class TanDNode : public Node { aoqi@0: public: aoqi@0: TanDNode(Compile* C, Node *c,Node *in1) : Node(c, in1) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: //------------------------------AtanDNode-------------------------------------- aoqi@0: // arcus tangens of a double aoqi@0: class AtanDNode : public Node { aoqi@0: public: aoqi@0: AtanDNode(Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: //------------------------------SqrtDNode-------------------------------------- aoqi@0: // square root a double aoqi@0: class SqrtDNode : public Node { aoqi@0: public: aoqi@0: SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------ExpDNode--------------------------------------- aoqi@0: // Exponentiate a double aoqi@0: class ExpDNode : public Node { aoqi@0: public: aoqi@0: ExpDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------LogDNode--------------------------------------- aoqi@0: // Log_e of a double aoqi@0: class LogDNode : public Node { aoqi@0: public: aoqi@0: LogDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------Log10DNode--------------------------------------- aoqi@0: // Log_10 of a double aoqi@0: class Log10DNode : public Node { aoqi@0: public: aoqi@0: Log10DNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: //------------------------------PowDNode--------------------------------------- aoqi@0: // Raise a double to a double power aoqi@0: class PowDNode : public Node { aoqi@0: public: aoqi@0: PowDNode(Compile* C, Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) { aoqi@0: init_flags(Flag_is_expensive); aoqi@0: C->add_expensive_node(this); aoqi@0: } aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return Type::DOUBLE; } aoqi@0: virtual uint ideal_reg() const { return Op_RegD; } aoqi@0: virtual const Type *Value( PhaseTransform *phase ) const; aoqi@0: }; aoqi@0: aoqi@0: //-------------------------------ReverseBytesINode-------------------------------- aoqi@0: // reverse bytes of an integer aoqi@0: class ReverseBytesINode : public Node { aoqi@0: public: aoqi@0: ReverseBytesINode(Node *c, Node *in1) : Node(c, in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return TypeInt::INT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: //-------------------------------ReverseBytesLNode-------------------------------- aoqi@0: // reverse bytes of a long aoqi@0: class ReverseBytesLNode : public Node { aoqi@0: public: aoqi@0: ReverseBytesLNode(Node *c, Node *in1) : Node(c, in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return TypeLong::LONG; } aoqi@0: virtual uint ideal_reg() const { return Op_RegL; } aoqi@0: }; aoqi@0: aoqi@0: //-------------------------------ReverseBytesUSNode-------------------------------- aoqi@0: // reverse bytes of an unsigned short / char aoqi@0: class ReverseBytesUSNode : public Node { aoqi@0: public: aoqi@0: ReverseBytesUSNode(Node *c, Node *in1) : Node(c, in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return TypeInt::CHAR; } aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: //-------------------------------ReverseBytesSNode-------------------------------- aoqi@0: // reverse bytes of a short aoqi@0: class ReverseBytesSNode : public Node { aoqi@0: public: aoqi@0: ReverseBytesSNode(Node *c, Node *in1) : Node(c, in1) {} aoqi@0: virtual int Opcode() const; aoqi@0: const Type *bottom_type() const { return TypeInt::SHORT; } aoqi@0: virtual uint ideal_reg() const { return Op_RegI; } aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_OPTO_SUBNODE_HPP