24
25 #ifndef SHARE_VM_OPTO_ADDNODE_HPP
26 #define SHARE_VM_OPTO_ADDNODE_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 class PhaseTransform;
35
36 //------------------------------AddNode----------------------------------------
37 // Classic Add functionality. This covers all the usual 'add' behaviors for
38 // an algebraic ring. Add-integer, add-float, add-double, and binary-or are
39 // all inherited from this class. The various identity values are supplied
40 // by virtual functions.
41 class AddNode : public Node {
42 virtual uint hash() const;
43 public:
44 AddNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
45 init_class_id(Class_Add);
46 }
47
48 // Handle algebraic identities here. If we have an identity, return the Node
49 // we are equivalent to. We look for "add of zero" as an identity.
50 virtual Node* Identity(PhaseGVN* phase);
51
52 // We also canonicalize the Node, moving constants to the right input,
53 // and flatten expressions (so that 1+x+2 becomes x+3).
54 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
55
56 // Compute a new Type for this node. Basically we just do the pre-check,
57 // then call the virtual add() to set the type.
58 virtual const Type* Value(PhaseGVN* phase) const;
59
60 // Check if this addition involves the additive identity
61 virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
62
63 // Supplied function returns the sum of the inputs.
64 // This also type-checks the inputs for sanity. Guaranteed never to
65 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
66 virtual const Type *add_ring( const Type *, const Type * ) const = 0;
67
68 // Supplied function to return the additive identity type
69 virtual const Type *add_id() const = 0;
70
71 };
72
73 //------------------------------AddINode---------------------------------------
74 // Add 2 integers
75 class AddINode : public AddNode {
76 public:
77 AddINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
78 virtual int Opcode() const;
79 virtual const Type *add_ring( const Type *, const Type * ) const;
80 virtual const Type *add_id() const { return TypeInt::ZERO; }
81 virtual const Type *bottom_type() const { return TypeInt::INT; }
82 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
83 virtual Node* Identity(PhaseGVN* phase);
84 virtual uint ideal_reg() const { return Op_RegI; }
85 };
86
87 //------------------------------AddLNode---------------------------------------
88 // Add 2 longs
89 class AddLNode : public AddNode {
90 public:
|
24
25 #ifndef SHARE_VM_OPTO_ADDNODE_HPP
26 #define SHARE_VM_OPTO_ADDNODE_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 class PhaseTransform;
35
36 //------------------------------AddNode----------------------------------------
37 // Classic Add functionality. This covers all the usual 'add' behaviors for
38 // an algebraic ring. Add-integer, add-float, add-double, and binary-or are
39 // all inherited from this class. The various identity values are supplied
40 // by virtual functions.
41 class AddNode : public Node {
42 virtual uint hash() const;
43 public:
44 AddNode(Node *in1, Node *in2) : Node(0,in1,in2) {
45 init_class_id(Class_Add);
46 }
47
48 // Handle algebraic identities here. If we have an identity, return the Node
49 // we are equivalent to. We look for "add of zero" as an identity.
50 virtual Node* Identity(PhaseGVN* phase);
51
52 // We also canonicalize the Node, moving constants to the right input,
53 // and flatten expressions (so that 1+x+2 becomes x+3).
54 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
55
56 // Compute a new Type for this node. Basically we just do the pre-check,
57 // then call the virtual add() to set the type.
58 virtual const Type* Value(PhaseGVN* phase) const;
59
60 // Check if this addition involves the additive identity
61 virtual const Type *add_of_identity(const Type *t1, const Type *t2) const;
62
63 // Supplied function returns the sum of the inputs.
64 // This also type-checks the inputs for sanity. Guaranteed never to
65 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
66 virtual const Type *add_ring(const Type*, const Type*) const = 0;
67
68 // Supplied function to return the additive identity type
69 virtual const Type *add_id() const = 0;
70
71 static AddNode* make(BasicType bt, Node *in1, Node *in2);
72 };
73
74 //------------------------------AddINode---------------------------------------
75 // Add 2 integers
76 class AddINode : public AddNode {
77 public:
78 AddINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
79 virtual int Opcode() const;
80 virtual const Type *add_ring( const Type *, const Type * ) const;
81 virtual const Type *add_id() const { return TypeInt::ZERO; }
82 virtual const Type *bottom_type() const { return TypeInt::INT; }
83 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
84 virtual Node* Identity(PhaseGVN* phase);
85 virtual uint ideal_reg() const { return Op_RegI; }
86 };
87
88 //------------------------------AddLNode---------------------------------------
89 // Add 2 longs
90 class AddLNode : public AddNode {
91 public:
|