22 *
23 */
24
25 #ifndef SHARE_VM_OPTO_SUBNODE_HPP
26 #define SHARE_VM_OPTO_SUBNODE_HPP
27
28 #include "opto/node.hpp"
29 #include "opto/opcodes.hpp"
30 #include "opto/type.hpp"
31
32 // Portions of code courtesy of Clifford Click
33
34 //------------------------------SUBNode----------------------------------------
35 // Class SUBTRACTION functionality. This covers all the usual 'subtract'
36 // behaviors. Subtract-integer, -float, -double, binary xor, compare-integer,
37 // -float, and -double are all inherited from this class. The compare
38 // functions behave like subtract functions, except that all negative answers
39 // are compressed into -1, and all positive answers compressed to 1.
40 class SubNode : public Node {
41 public:
42 SubNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
43 init_class_id(Class_Sub);
44 }
45
46 // Handle algebraic identities here. If we have an identity, return the Node
47 // we are equivalent to. We look for "add of zero" as an identity.
48 virtual Node* Identity(PhaseGVN* phase);
49
50 // Compute a new Type for this node. Basically we just do the pre-check,
51 // then call the virtual add() to set the type.
52 virtual const Type* Value(PhaseGVN* phase) const;
53 const Type* Value_common( PhaseTransform *phase ) const;
54
55 // Supplied function returns the subtractend of the inputs.
56 // This also type-checks the inputs for sanity. Guaranteed never to
57 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
58 virtual const Type *sub( const Type *, const Type * ) const = 0;
59
60 // Supplied function to return the additive identity type.
61 // This is returned whenever the subtracts inputs are the same.
62 virtual const Type *add_id() const = 0;
63 };
64
65
66 // NOTE: SubINode should be taken away and replaced by add and negate
67 //------------------------------SubINode---------------------------------------
68 // Subtract 2 integers
69 class SubINode : public SubNode {
70 public:
71 SubINode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
72 virtual int Opcode() const;
73 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
74 virtual const Type *sub( const Type *, const Type * ) const;
75 const Type *add_id() const { return TypeInt::ZERO; }
76 const Type *bottom_type() const { return TypeInt::INT; }
77 virtual uint ideal_reg() const { return Op_RegI; }
78 };
79
80 //------------------------------SubLNode---------------------------------------
81 // Subtract 2 integers
82 class SubLNode : public SubNode {
|
22 *
23 */
24
25 #ifndef SHARE_VM_OPTO_SUBNODE_HPP
26 #define SHARE_VM_OPTO_SUBNODE_HPP
27
28 #include "opto/node.hpp"
29 #include "opto/opcodes.hpp"
30 #include "opto/type.hpp"
31
32 // Portions of code courtesy of Clifford Click
33
34 //------------------------------SUBNode----------------------------------------
35 // Class SUBTRACTION functionality. This covers all the usual 'subtract'
36 // behaviors. Subtract-integer, -float, -double, binary xor, compare-integer,
37 // -float, and -double are all inherited from this class. The compare
38 // functions behave like subtract functions, except that all negative answers
39 // are compressed into -1, and all positive answers compressed to 1.
40 class SubNode : public Node {
41 public:
42 SubNode(Node *in1, Node *in2) : Node(0,in1,in2) {
43 init_class_id(Class_Sub);
44 }
45
46 // Handle algebraic identities here. If we have an identity, return the Node
47 // we are equivalent to. We look for "add of zero" as an identity.
48 virtual Node* Identity(PhaseGVN* phase);
49
50 // Compute a new Type for this node. Basically we just do the pre-check,
51 // then call the virtual add() to set the type.
52 virtual const Type* Value(PhaseGVN* phase) const;
53 const Type* Value_common(PhaseTransform *phase) const;
54
55 // Supplied function returns the subtractend of the inputs.
56 // This also type-checks the inputs for sanity. Guaranteed never to
57 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
58 virtual const Type *sub(const Type*, const Type*) const = 0;
59
60 // Supplied function to return the additive identity type.
61 // This is returned whenever the subtracts inputs are the same.
62 virtual const Type *add_id() const = 0;
63
64 static SubNode* make(BasicType bt, Node *in1, Node *in2);
65 };
66
67
68 // NOTE: SubINode should be taken away and replaced by add and negate
69 //------------------------------SubINode---------------------------------------
70 // Subtract 2 integers
71 class SubINode : public SubNode {
72 public:
73 SubINode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
74 virtual int Opcode() const;
75 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
76 virtual const Type *sub( const Type *, const Type * ) const;
77 const Type *add_id() const { return TypeInt::ZERO; }
78 const Type *bottom_type() const { return TypeInt::INT; }
79 virtual uint ideal_reg() const { return Op_RegI; }
80 };
81
82 //------------------------------SubLNode---------------------------------------
83 // Subtract 2 integers
84 class SubLNode : public SubNode {
|