656 DEFINE_CLASS_ID(Vector, Node, 13)
657 DEFINE_CLASS_ID(ClearArray, Node, 14)
658
659 _max_classes = ClassMask_ClearArray
660 };
661 #undef DEFINE_CLASS_ID
662
663 // Flags are sorted by usage frequency.
664 enum NodeFlags {
665 Flag_is_Copy = 0x01, // should be first bit to avoid shift
666 Flag_rematerialize = Flag_is_Copy << 1,
667 Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
668 Flag_is_macro = Flag_needs_anti_dependence_check << 1,
669 Flag_is_Con = Flag_is_macro << 1,
670 Flag_is_cisc_alternate = Flag_is_Con << 1,
671 Flag_is_dead_loop_safe = Flag_is_cisc_alternate << 1,
672 Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
673 Flag_avoid_back_to_back_before = Flag_may_be_short_branch << 1,
674 Flag_avoid_back_to_back_after = Flag_avoid_back_to_back_before << 1,
675 Flag_has_call = Flag_avoid_back_to_back_after << 1,
676 Flag_is_expensive = Flag_has_call << 1,
677 _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
678 };
679
680 private:
681 jushort _class_id;
682 jushort _flags;
683
684 protected:
685 // These methods should be called from constructors only.
686 void init_class_id(jushort c) {
687 assert(c <= _max_classes, "invalid node class");
688 _class_id = c; // cast out const
689 }
690 void init_flags(jushort fl) {
691 assert(fl <= _max_flags, "invalid node flag");
692 _flags |= fl;
693 }
694 void clear_flag(jushort fl) {
695 assert(fl <= _max_flags, "invalid node flag");
696 _flags &= ~fl;
697 }
698
699 public:
700 const jushort class_id() const { return _class_id; }
701
702 const jushort flags() const { return _flags; }
703
704 // Return a dense integer opcode number
705 virtual int Opcode() const;
706
707 // Virtual inherited Node size
708 virtual uint size_of() const;
709
710 // Other interesting Node properties
711 #define DEFINE_CLASS_QUERY(type) \
712 bool is_##type() const { \
713 return ((_class_id & ClassMask_##type) == Class_##type); \
714 } \
715 type##Node *as_##type() const { \
716 assert(is_##type(), "invalid node class"); \
717 return (type##Node*)this; \
718 } \
719 type##Node* isa_##type() const { \
720 return (is_##type()) ? as_##type() : NULL; \
721 }
722
723 DEFINE_CLASS_QUERY(AbstractLock)
835 // When building basic blocks, I need to have a notion of block beginning
836 // Nodes, next block selector Nodes (block enders), and next block
837 // projections. These calls need to work on their machine equivalents. The
838 // Ideal beginning Nodes are RootNode, RegionNode and StartNode.
839 bool is_block_start() const {
840 if ( is_Region() )
841 return this == (const Node*)in(0);
842 else
843 return is_Start();
844 }
845
846 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root,
847 // Goto and Return. This call also returns the block ending Node.
848 virtual const Node *is_block_proj() const;
849
850 // The node is a "macro" node which needs to be expanded before matching
851 bool is_macro() const { return (_flags & Flag_is_macro) != 0; }
852 // The node is expensive: the best control is set during loop opts
853 bool is_expensive() const { return (_flags & Flag_is_expensive) != 0 && in(0) != NULL; }
854
855 //----------------- Optimization
856
857 // Get the worst-case Type output for this Node.
858 virtual const class Type *bottom_type() const;
859
860 // If we find a better type for a node, try to record it permanently.
861 // Return true if this node actually changed.
862 // Be sure to do the hash_delete game in the "rehash" variant.
863 void raise_bottom_type(const Type* new_type);
864
865 // Get the address type with which this node uses and/or defs memory,
866 // or NULL if none. The address type is conservatively wide.
867 // Returns non-null for calls, membars, loads, stores, etc.
868 // Returns TypePtr::BOTTOM if the node touches memory "broadly".
869 virtual const class TypePtr *adr_type() const { return NULL; }
870
871 // Return an existing node which computes the same function as this node.
872 // The optimistic combined algorithm requires this to return a Node which
873 // is a small number of steps away (e.g., one of my inputs).
874 virtual Node *Identity( PhaseTransform *phase );
|
656 DEFINE_CLASS_ID(Vector, Node, 13)
657 DEFINE_CLASS_ID(ClearArray, Node, 14)
658
659 _max_classes = ClassMask_ClearArray
660 };
661 #undef DEFINE_CLASS_ID
662
663 // Flags are sorted by usage frequency.
664 enum NodeFlags {
665 Flag_is_Copy = 0x01, // should be first bit to avoid shift
666 Flag_rematerialize = Flag_is_Copy << 1,
667 Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
668 Flag_is_macro = Flag_needs_anti_dependence_check << 1,
669 Flag_is_Con = Flag_is_macro << 1,
670 Flag_is_cisc_alternate = Flag_is_Con << 1,
671 Flag_is_dead_loop_safe = Flag_is_cisc_alternate << 1,
672 Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
673 Flag_avoid_back_to_back_before = Flag_may_be_short_branch << 1,
674 Flag_avoid_back_to_back_after = Flag_avoid_back_to_back_before << 1,
675 Flag_has_call = Flag_avoid_back_to_back_after << 1,
676 Flag_is_reduction = Flag_has_call << 1,
677 Flag_is_expensive = Flag_is_reduction << 1,
678 _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
679 };
680
681 private:
682 jushort _class_id;
683 jushort _flags;
684
685 protected:
686 // These methods should be called from constructors only.
687 void init_class_id(jushort c) {
688 assert(c <= _max_classes, "invalid node class");
689 _class_id = c; // cast out const
690 }
691 void init_flags(jushort fl) {
692 assert(fl <= _max_flags, "invalid node flag");
693 _flags |= fl;
694 }
695 void clear_flag(jushort fl) {
696 assert(fl <= _max_flags, "invalid node flag");
697 _flags &= ~fl;
698 }
699
700 public:
701 const jushort class_id() const { return _class_id; }
702
703 const jushort flags() const { return _flags; }
704
705 void add_flag(jushort fl) { init_flags(fl); }
706
707 void remove_flag(jushort fl) { clear_flag(fl); }
708
709 // Return a dense integer opcode number
710 virtual int Opcode() const;
711
712 // Virtual inherited Node size
713 virtual uint size_of() const;
714
715 // Other interesting Node properties
716 #define DEFINE_CLASS_QUERY(type) \
717 bool is_##type() const { \
718 return ((_class_id & ClassMask_##type) == Class_##type); \
719 } \
720 type##Node *as_##type() const { \
721 assert(is_##type(), "invalid node class"); \
722 return (type##Node*)this; \
723 } \
724 type##Node* isa_##type() const { \
725 return (is_##type()) ? as_##type() : NULL; \
726 }
727
728 DEFINE_CLASS_QUERY(AbstractLock)
840 // When building basic blocks, I need to have a notion of block beginning
841 // Nodes, next block selector Nodes (block enders), and next block
842 // projections. These calls need to work on their machine equivalents. The
843 // Ideal beginning Nodes are RootNode, RegionNode and StartNode.
844 bool is_block_start() const {
845 if ( is_Region() )
846 return this == (const Node*)in(0);
847 else
848 return is_Start();
849 }
850
851 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root,
852 // Goto and Return. This call also returns the block ending Node.
853 virtual const Node *is_block_proj() const;
854
855 // The node is a "macro" node which needs to be expanded before matching
856 bool is_macro() const { return (_flags & Flag_is_macro) != 0; }
857 // The node is expensive: the best control is set during loop opts
858 bool is_expensive() const { return (_flags & Flag_is_expensive) != 0 && in(0) != NULL; }
859
860 // An arithmetic node which accumulates a data in a loop.
861 // It must have the loop's phi as input and provide a def to the phi.
862 bool is_reduction() const { return (_flags & Flag_is_reduction) != 0; }
863
864 //----------------- Optimization
865
866 // Get the worst-case Type output for this Node.
867 virtual const class Type *bottom_type() const;
868
869 // If we find a better type for a node, try to record it permanently.
870 // Return true if this node actually changed.
871 // Be sure to do the hash_delete game in the "rehash" variant.
872 void raise_bottom_type(const Type* new_type);
873
874 // Get the address type with which this node uses and/or defs memory,
875 // or NULL if none. The address type is conservatively wide.
876 // Returns non-null for calls, membars, loads, stores, etc.
877 // Returns TypePtr::BOTTOM if the node touches memory "broadly".
878 virtual const class TypePtr *adr_type() const { return NULL; }
879
880 // Return an existing node which computes the same function as this node.
881 // The optimistic combined algorithm requires this to return a Node which
882 // is a small number of steps away (e.g., one of my inputs).
883 virtual Node *Identity( PhaseTransform *phase );
|