50 class CallJavaNode; 51 class CallLeafNode; 52 class CallNode; 53 class CallRuntimeNode; 54 class CallStaticJavaNode; 55 class CatchNode; 56 class CatchProjNode; 57 class CheckCastPPNode; 58 class ClearArrayNode; 59 class CmpNode; 60 class CodeBuffer; 61 class ConstraintCastNode; 62 class ConNode; 63 class CountedLoopNode; 64 class CountedLoopEndNode; 65 class DecodeNNode; 66 class EncodePNode; 67 class FastLockNode; 68 class FastUnlockNode; 69 class IfNode; 70 class InitializeNode; 71 class JVMState; 72 class JumpNode; 73 class JumpProjNode; 74 class LoadNode; 75 class LoadStoreNode; 76 class LockNode; 77 class LoopNode; 78 class MachCallDynamicJavaNode; 79 class MachCallJavaNode; 80 class MachCallLeafNode; 81 class MachCallNode; 82 class MachCallRuntimeNode; 83 class MachCallStaticJavaNode; 84 class MachConstantBaseNode; 85 class MachConstantNode; 86 class MachIfNode; 87 class MachNode; 88 class MachNullCheckNode; 89 class MachReturnNode; 90 class MachSafePointNode; 91 class MachSpillCopyNode; 92 class MachTempNode; 93 class Matcher; 94 class MemBarNode; 95 class MemNode; 96 class MergeMemNode; 97 class MulNode; 98 class MultiNode; 99 class MultiBranchNode; 100 class NeverBranchNode; 101 class Node; 102 class Node_Array; 103 class Node_List; 104 class Node_Stack; 105 class NullCheckNode; 106 class OopMap; 107 class ParmNode; 108 class PCTableNode; 109 class PhaseCCP; 110 class PhaseGVN; 111 class PhaseIterGVN; 112 class PhaseRegAlloc; 113 class PhaseTransform; 114 class PhaseValues; 115 class PhiNode; 116 class Pipeline; 117 class ProjNode; 118 class RegMask; 119 class RegionNode; 120 class RootNode; 121 class SafePointNode; 122 class SafePointScalarObjectNode; 123 class StartNode; 124 class State; 125 class StoreNode; 126 class SubNode; 127 class Type; 128 class TypeNode; 129 class UnlockNode; 130 class VectorSet; 131 class IfTrueNode; 132 class IfFalseNode; 133 typedef void (*NFunc)(Node&,void*); 134 extern "C" { 135 typedef int (*C_sort_func_t)(const void *, const void *); 136 } 137 138 // The type of all node counts and indexes. 139 // It must hold at least 16 bits, but must also be fast to load and store. 140 // This type, if less than 32 bits, could limit the number of possible nodes. 141 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.) 142 typedef unsigned int node_idx_t; 143 144 145 #ifndef OPTO_DU_ITERATOR_ASSERT 146 #ifdef ASSERT 147 #define OPTO_DU_ITERATOR_ASSERT 1 148 #else 149 #define OPTO_DU_ITERATOR_ASSERT 0 150 #endif 151 #endif //OPTO_DU_ITERATOR_ASSERT 152 557 DEFINE_CLASS_ID(NeverBranch, MultiBranch, 2) 558 DEFINE_CLASS_ID(Start, Multi, 2) 559 DEFINE_CLASS_ID(MemBar, Multi, 3) 560 DEFINE_CLASS_ID(Initialize, MemBar, 0) 561 562 DEFINE_CLASS_ID(Mach, Node, 1) 563 DEFINE_CLASS_ID(MachReturn, Mach, 0) 564 DEFINE_CLASS_ID(MachSafePoint, MachReturn, 0) 565 DEFINE_CLASS_ID(MachCall, MachSafePoint, 0) 566 DEFINE_CLASS_ID(MachCallJava, MachCall, 0) 567 DEFINE_CLASS_ID(MachCallStaticJava, MachCallJava, 0) 568 DEFINE_CLASS_ID(MachCallDynamicJava, MachCallJava, 1) 569 DEFINE_CLASS_ID(MachCallRuntime, MachCall, 1) 570 DEFINE_CLASS_ID(MachCallLeaf, MachCallRuntime, 0) 571 DEFINE_CLASS_ID(MachSpillCopy, Mach, 1) 572 DEFINE_CLASS_ID(MachNullCheck, Mach, 2) 573 DEFINE_CLASS_ID(MachIf, Mach, 3) 574 DEFINE_CLASS_ID(MachTemp, Mach, 4) 575 DEFINE_CLASS_ID(MachConstantBase, Mach, 5) 576 DEFINE_CLASS_ID(MachConstant, Mach, 6) 577 578 DEFINE_CLASS_ID(Proj, Node, 2) 579 DEFINE_CLASS_ID(CatchProj, Proj, 0) 580 DEFINE_CLASS_ID(JumpProj, Proj, 1) 581 DEFINE_CLASS_ID(IfTrue, Proj, 2) 582 DEFINE_CLASS_ID(IfFalse, Proj, 3) 583 DEFINE_CLASS_ID(Parm, Proj, 4) 584 585 DEFINE_CLASS_ID(Region, Node, 3) 586 DEFINE_CLASS_ID(Loop, Region, 0) 587 DEFINE_CLASS_ID(Root, Loop, 0) 588 DEFINE_CLASS_ID(CountedLoop, Loop, 1) 589 590 DEFINE_CLASS_ID(Sub, Node, 4) 591 DEFINE_CLASS_ID(Cmp, Sub, 0) 592 DEFINE_CLASS_ID(FastLock, Cmp, 0) 593 DEFINE_CLASS_ID(FastUnlock, Cmp, 1) 594 595 DEFINE_CLASS_ID(Type, Node, 5) 596 DEFINE_CLASS_ID(Phi, Type, 0) 597 DEFINE_CLASS_ID(ConstraintCast, Type, 1) 598 DEFINE_CLASS_ID(CheckCastPP, Type, 2) 599 DEFINE_CLASS_ID(CMove, Type, 3) 600 DEFINE_CLASS_ID(SafePointScalarObject, Type, 4) 601 DEFINE_CLASS_ID(DecodeN, Type, 5) 602 DEFINE_CLASS_ID(EncodeP, Type, 6) 603 604 DEFINE_CLASS_ID(Mem, Node, 6) 605 DEFINE_CLASS_ID(Load, Mem, 0) 606 DEFINE_CLASS_ID(Store, Mem, 1) 607 DEFINE_CLASS_ID(LoadStore, Mem, 2) 608 609 DEFINE_CLASS_ID(MergeMem, Node, 7) 610 DEFINE_CLASS_ID(Bool, Node, 8) 611 DEFINE_CLASS_ID(AddP, Node, 9) 612 DEFINE_CLASS_ID(BoxLock, Node, 10) 613 DEFINE_CLASS_ID(Add, Node, 11) 614 DEFINE_CLASS_ID(Mul, Node, 12) 615 DEFINE_CLASS_ID(ClearArray, Node, 13) 616 617 _max_classes = ClassMask_ClearArray 618 }; 619 #undef DEFINE_CLASS_ID 620 621 // Flags are sorted by usage frequency. 622 enum NodeFlags { 623 Flag_is_Copy = 0x01, // should be first bit to avoid shift 624 Flag_is_Call = Flag_is_Copy << 1, 625 Flag_rematerialize = Flag_is_Call << 1, 626 Flag_needs_anti_dependence_check = Flag_rematerialize << 1, 627 Flag_is_macro = Flag_needs_anti_dependence_check << 1, 628 Flag_is_Con = Flag_is_macro << 1, 629 Flag_is_cisc_alternate = Flag_is_Con << 1, 630 Flag_is_Branch = Flag_is_cisc_alternate << 1, 631 Flag_is_block_start = Flag_is_Branch << 1, 632 Flag_is_Goto = Flag_is_block_start << 1, 633 Flag_is_dead_loop_safe = Flag_is_Goto << 1, 634 Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1, 635 Flag_is_safepoint_node = Flag_may_be_short_branch << 1, 636 Flag_is_pc_relative = Flag_is_safepoint_node << 1, 637 Flag_is_Vector = Flag_is_pc_relative << 1, 638 _max_flags = (Flag_is_Vector << 1) - 1 // allow flags combination 639 }; 640 641 private: 642 jushort _class_id; 643 jushort _flags; 644 645 protected: 646 // These methods should be called from constructors only. 647 void init_class_id(jushort c) { 648 assert(c <= _max_classes, "invalid node class"); 649 _class_id = c; // cast out const 650 } 651 void init_flags(jushort fl) { 652 assert(fl <= _max_flags, "invalid node flag"); 653 _flags |= fl; 654 } 655 void clear_flag(jushort fl) { 656 assert(fl <= _max_flags, "invalid node flag"); 657 _flags &= ~fl; 658 } 659 660 public: 661 const jushort class_id() const { return _class_id; } 662 663 const jushort flags() const { return _flags; } 664 665 // Return a dense integer opcode number 666 virtual int Opcode() const; 667 668 // Virtual inherited Node size 669 virtual uint size_of() const; 670 671 // Other interesting Node properties 672 673 // Special case: is_Call() returns true for both CallNode and MachCallNode. 674 bool is_Call() const { 675 return (_flags & Flag_is_Call) != 0; 676 } 677 678 CallNode* isa_Call() const { 679 return is_Call() ? as_Call() : NULL; 680 } 681 682 CallNode *as_Call() const { // Only for CallNode (not for MachCallNode) 683 assert((_class_id & ClassMask_Call) == Class_Call, "invalid node class"); 684 return (CallNode*)this; 685 } 686 687 #define DEFINE_CLASS_QUERY(type) \ 688 bool is_##type() const { \ 689 return ((_class_id & ClassMask_##type) == Class_##type); \ 690 } \ 691 type##Node *as_##type() const { \ 692 assert(is_##type(), "invalid node class"); \ 693 return (type##Node*)this; \ 694 } \ 695 type##Node* isa_##type() const { \ 696 return (is_##type()) ? as_##type() : NULL; \ 697 } 698 699 DEFINE_CLASS_QUERY(AbstractLock) 700 DEFINE_CLASS_QUERY(Add) 701 DEFINE_CLASS_QUERY(AddP) 702 DEFINE_CLASS_QUERY(Allocate) 703 DEFINE_CLASS_QUERY(AllocateArray) 704 DEFINE_CLASS_QUERY(Bool) 705 DEFINE_CLASS_QUERY(BoxLock) 706 DEFINE_CLASS_QUERY(CallDynamicJava) 707 DEFINE_CLASS_QUERY(CallJava) 708 DEFINE_CLASS_QUERY(CallLeaf) 709 DEFINE_CLASS_QUERY(CallRuntime) 710 DEFINE_CLASS_QUERY(CallStaticJava) 711 DEFINE_CLASS_QUERY(Catch) 712 DEFINE_CLASS_QUERY(CatchProj) 713 DEFINE_CLASS_QUERY(CheckCastPP) 714 DEFINE_CLASS_QUERY(ConstraintCast) 715 DEFINE_CLASS_QUERY(ClearArray) 716 DEFINE_CLASS_QUERY(CMove) 717 DEFINE_CLASS_QUERY(Cmp) 718 DEFINE_CLASS_QUERY(CountedLoop) 719 DEFINE_CLASS_QUERY(CountedLoopEnd) 720 DEFINE_CLASS_QUERY(DecodeN) 721 DEFINE_CLASS_QUERY(EncodeP) 722 DEFINE_CLASS_QUERY(FastLock) 723 DEFINE_CLASS_QUERY(FastUnlock) 724 DEFINE_CLASS_QUERY(If) 725 DEFINE_CLASS_QUERY(IfFalse) 726 DEFINE_CLASS_QUERY(IfTrue) 727 DEFINE_CLASS_QUERY(Initialize) 728 DEFINE_CLASS_QUERY(Jump) 729 DEFINE_CLASS_QUERY(JumpProj) 730 DEFINE_CLASS_QUERY(Load) 731 DEFINE_CLASS_QUERY(LoadStore) 732 DEFINE_CLASS_QUERY(Lock) 733 DEFINE_CLASS_QUERY(Loop) 734 DEFINE_CLASS_QUERY(Mach) 735 DEFINE_CLASS_QUERY(MachCall) 736 DEFINE_CLASS_QUERY(MachCallDynamicJava) 737 DEFINE_CLASS_QUERY(MachCallJava) 738 DEFINE_CLASS_QUERY(MachCallLeaf) 739 DEFINE_CLASS_QUERY(MachCallRuntime) 740 DEFINE_CLASS_QUERY(MachCallStaticJava) 741 DEFINE_CLASS_QUERY(MachConstantBase) 742 DEFINE_CLASS_QUERY(MachConstant) 743 DEFINE_CLASS_QUERY(MachIf) 744 DEFINE_CLASS_QUERY(MachNullCheck) 745 DEFINE_CLASS_QUERY(MachReturn) 746 DEFINE_CLASS_QUERY(MachSafePoint) 747 DEFINE_CLASS_QUERY(MachSpillCopy) 748 DEFINE_CLASS_QUERY(MachTemp) 749 DEFINE_CLASS_QUERY(Mem) 750 DEFINE_CLASS_QUERY(MemBar) 751 DEFINE_CLASS_QUERY(MergeMem) 752 DEFINE_CLASS_QUERY(Mul) 753 DEFINE_CLASS_QUERY(Multi) 754 DEFINE_CLASS_QUERY(MultiBranch) 755 DEFINE_CLASS_QUERY(Parm) 756 DEFINE_CLASS_QUERY(PCTable) 757 DEFINE_CLASS_QUERY(Phi) 758 DEFINE_CLASS_QUERY(Proj) 759 DEFINE_CLASS_QUERY(Region) 760 DEFINE_CLASS_QUERY(Root) 761 DEFINE_CLASS_QUERY(SafePoint) 762 DEFINE_CLASS_QUERY(SafePointScalarObject) 763 DEFINE_CLASS_QUERY(Start) 764 DEFINE_CLASS_QUERY(Store) 765 DEFINE_CLASS_QUERY(Sub) 766 DEFINE_CLASS_QUERY(Type) 767 DEFINE_CLASS_QUERY(Unlock) 768 769 #undef DEFINE_CLASS_QUERY 770 771 // duplicate of is_MachSpillCopy() 772 bool is_SpillCopy () const { 773 return ((_class_id & ClassMask_MachSpillCopy) == Class_MachSpillCopy); 774 } 775 776 bool is_Con () const { return (_flags & Flag_is_Con) != 0; } 777 bool is_Goto() const { return (_flags & Flag_is_Goto) != 0; } 778 // The data node which is safe to leave in dead loop during IGVN optimization. 779 bool is_dead_loop_safe() const { 780 return is_Phi() || (is_Proj() && in(0) == NULL) || 781 ((_flags & (Flag_is_dead_loop_safe | Flag_is_Con)) != 0 && 782 (!is_Proj() || !in(0)->is_Allocate())); 783 } 784 785 // is_Copy() returns copied edge index (0 or 1) 786 uint is_Copy() const { return (_flags & Flag_is_Copy); } 787 788 virtual bool is_CFG() const { return false; } 789 790 // If this node is control-dependent on a test, can it be 791 // rerouted to a dominating equivalent test? This is usually 792 // true of non-CFG nodes, but can be false for operations which 793 // depend for their correct sequencing on more than one test. 794 // (In that case, hoisting to a dominating test may silently 795 // skip some other important test.) 796 virtual bool depends_only_on_test() const { assert(!is_CFG(), ""); return true; }; 797 798 // defined for MachNodes that match 'If' | 'Goto' | 'CountedLoopEnd' 799 bool is_Branch() const { return (_flags & Flag_is_Branch) != 0; } 800 801 // When building basic blocks, I need to have a notion of block beginning 802 // Nodes, next block selector Nodes (block enders), and next block 803 // projections. These calls need to work on their machine equivalents. The 804 // Ideal beginning Nodes are RootNode, RegionNode and StartNode. 805 bool is_block_start() const { 806 if ( is_Region() ) 807 return this == (const Node*)in(0); 808 else 809 return (_flags & Flag_is_block_start) != 0; 810 } 811 812 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root, 813 // Goto and Return. This call also returns the block ending Node. 814 virtual const Node *is_block_proj() const; 815 816 // The node is a "macro" node which needs to be expanded before matching 817 bool is_macro() const { return (_flags & Flag_is_macro) != 0; } 818 819 // Value is a vector of primitive values 820 bool is_Vector() const { return (_flags & Flag_is_Vector) != 0; } 821 822 //----------------- Optimization 823 824 // Get the worst-case Type output for this Node. 825 virtual const class Type *bottom_type() const; 826 827 // If we find a better type for a node, try to record it permanently. 828 // Return true if this node actually changed. 829 // Be sure to do the hash_delete game in the "rehash" variant. 830 void raise_bottom_type(const Type* new_type); 831 832 // Get the address type with which this node uses and/or defs memory, 833 // or NULL if none. The address type is conservatively wide. 834 // Returns non-null for calls, membars, loads, stores, etc. 835 // Returns TypePtr::BOTTOM if the node touches memory "broadly". 836 virtual const class TypePtr *adr_type() const { return NULL; } 837 838 // Return an existing node which computes the same function as this node. 839 // The optimistic combined algorithm requires this to return a Node which 840 // is a small number of steps away (e.g., one of my inputs). 841 virtual Node *Identity( PhaseTransform *phase ); | 50 class CallJavaNode; 51 class CallLeafNode; 52 class CallNode; 53 class CallRuntimeNode; 54 class CallStaticJavaNode; 55 class CatchNode; 56 class CatchProjNode; 57 class CheckCastPPNode; 58 class ClearArrayNode; 59 class CmpNode; 60 class CodeBuffer; 61 class ConstraintCastNode; 62 class ConNode; 63 class CountedLoopNode; 64 class CountedLoopEndNode; 65 class DecodeNNode; 66 class EncodePNode; 67 class FastLockNode; 68 class FastUnlockNode; 69 class IfNode; 70 class IfFalseNode; 71 class IfTrueNode; 72 class InitializeNode; 73 class JVMState; 74 class JumpNode; 75 class JumpProjNode; 76 class LoadNode; 77 class LoadStoreNode; 78 class LockNode; 79 class LoopNode; 80 class MachCallDynamicJavaNode; 81 class MachCallJavaNode; 82 class MachCallLeafNode; 83 class MachCallNode; 84 class MachCallRuntimeNode; 85 class MachCallStaticJavaNode; 86 class MachConstantBaseNode; 87 class MachConstantNode; 88 class MachGotoNode; 89 class MachIfNode; 90 class MachNode; 91 class MachNullCheckNode; 92 class MachProjNode; 93 class MachReturnNode; 94 class MachSafePointNode; 95 class MachSpillCopyNode; 96 class MachTempNode; 97 class Matcher; 98 class MemBarNode; 99 class MemNode; 100 class MergeMemNode; 101 class MultiNode; 102 class MultiBranchNode; 103 class NeverBranchNode; 104 class Node; 105 class Node_Array; 106 class Node_List; 107 class Node_Stack; 108 class NullCheckNode; 109 class OopMap; 110 class ParmNode; 111 class PCTableNode; 112 class PhaseCCP; 113 class PhaseGVN; 114 class PhaseIterGVN; 115 class PhaseRegAlloc; 116 class PhaseTransform; 117 class PhaseValues; 118 class PhiNode; 119 class Pipeline; 120 class ProjNode; 121 class RegMask; 122 class RegionNode; 123 class RootNode; 124 class SafePointNode; 125 class SafePointScalarObjectNode; 126 class StartNode; 127 class State; 128 class StoreNode; 129 class SubNode; 130 class Type; 131 class TypeNode; 132 class UnlockNode; 133 class VectorNode; 134 class VectorLoadNode; 135 class VectorStoreNode; 136 class VectorSet; 137 typedef void (*NFunc)(Node&,void*); 138 extern "C" { 139 typedef int (*C_sort_func_t)(const void *, const void *); 140 } 141 142 // The type of all node counts and indexes. 143 // It must hold at least 16 bits, but must also be fast to load and store. 144 // This type, if less than 32 bits, could limit the number of possible nodes. 145 // (To make this type platform-specific, move to globalDefinitions_xxx.hpp.) 146 typedef unsigned int node_idx_t; 147 148 149 #ifndef OPTO_DU_ITERATOR_ASSERT 150 #ifdef ASSERT 151 #define OPTO_DU_ITERATOR_ASSERT 1 152 #else 153 #define OPTO_DU_ITERATOR_ASSERT 0 154 #endif 155 #endif //OPTO_DU_ITERATOR_ASSERT 156 561 DEFINE_CLASS_ID(NeverBranch, MultiBranch, 2) 562 DEFINE_CLASS_ID(Start, Multi, 2) 563 DEFINE_CLASS_ID(MemBar, Multi, 3) 564 DEFINE_CLASS_ID(Initialize, MemBar, 0) 565 566 DEFINE_CLASS_ID(Mach, Node, 1) 567 DEFINE_CLASS_ID(MachReturn, Mach, 0) 568 DEFINE_CLASS_ID(MachSafePoint, MachReturn, 0) 569 DEFINE_CLASS_ID(MachCall, MachSafePoint, 0) 570 DEFINE_CLASS_ID(MachCallJava, MachCall, 0) 571 DEFINE_CLASS_ID(MachCallStaticJava, MachCallJava, 0) 572 DEFINE_CLASS_ID(MachCallDynamicJava, MachCallJava, 1) 573 DEFINE_CLASS_ID(MachCallRuntime, MachCall, 1) 574 DEFINE_CLASS_ID(MachCallLeaf, MachCallRuntime, 0) 575 DEFINE_CLASS_ID(MachSpillCopy, Mach, 1) 576 DEFINE_CLASS_ID(MachNullCheck, Mach, 2) 577 DEFINE_CLASS_ID(MachIf, Mach, 3) 578 DEFINE_CLASS_ID(MachTemp, Mach, 4) 579 DEFINE_CLASS_ID(MachConstantBase, Mach, 5) 580 DEFINE_CLASS_ID(MachConstant, Mach, 6) 581 DEFINE_CLASS_ID(MachGoto, Mach, 7) 582 583 DEFINE_CLASS_ID(Type, Node, 2) 584 DEFINE_CLASS_ID(Phi, Type, 0) 585 DEFINE_CLASS_ID(ConstraintCast, Type, 1) 586 DEFINE_CLASS_ID(CheckCastPP, Type, 2) 587 DEFINE_CLASS_ID(CMove, Type, 3) 588 DEFINE_CLASS_ID(SafePointScalarObject, Type, 4) 589 DEFINE_CLASS_ID(DecodeN, Type, 5) 590 DEFINE_CLASS_ID(EncodeP, Type, 6) 591 592 DEFINE_CLASS_ID(Proj, Node, 3) 593 DEFINE_CLASS_ID(CatchProj, Proj, 0) 594 DEFINE_CLASS_ID(JumpProj, Proj, 1) 595 DEFINE_CLASS_ID(IfTrue, Proj, 2) 596 DEFINE_CLASS_ID(IfFalse, Proj, 3) 597 DEFINE_CLASS_ID(Parm, Proj, 4) 598 DEFINE_CLASS_ID(MachProj, Proj, 5) 599 600 DEFINE_CLASS_ID(Mem, Node, 4) 601 DEFINE_CLASS_ID(Load, Mem, 0) 602 DEFINE_CLASS_ID(VectorLoad, Load, 0) 603 DEFINE_CLASS_ID(Store, Mem, 1) 604 DEFINE_CLASS_ID(VectorStore, Store, 0) 605 DEFINE_CLASS_ID(LoadStore, Mem, 2) 606 607 DEFINE_CLASS_ID(Region, Node, 5) 608 DEFINE_CLASS_ID(Loop, Region, 0) 609 DEFINE_CLASS_ID(Root, Loop, 0) 610 DEFINE_CLASS_ID(CountedLoop, Loop, 1) 611 612 DEFINE_CLASS_ID(Sub, Node, 6) 613 DEFINE_CLASS_ID(Cmp, Sub, 0) 614 DEFINE_CLASS_ID(FastLock, Cmp, 0) 615 DEFINE_CLASS_ID(FastUnlock, Cmp, 1) 616 617 DEFINE_CLASS_ID(MergeMem, Node, 7) 618 DEFINE_CLASS_ID(Bool, Node, 8) 619 DEFINE_CLASS_ID(AddP, Node, 9) 620 DEFINE_CLASS_ID(BoxLock, Node, 10) 621 DEFINE_CLASS_ID(Add, Node, 11) 622 DEFINE_CLASS_ID(Vector, Node, 12) 623 DEFINE_CLASS_ID(ClearArray, Node, 13) 624 625 _max_classes = ClassMask_ClearArray 626 }; 627 #undef DEFINE_CLASS_ID 628 629 // Flags are sorted by usage frequency. 630 enum NodeFlags { 631 Flag_is_Copy = 0x01, // should be first bit to avoid shift 632 Flag_rematerialize = Flag_is_Copy << 1, 633 Flag_needs_anti_dependence_check = Flag_rematerialize << 1, 634 Flag_is_macro = Flag_needs_anti_dependence_check << 1, 635 Flag_is_Con = Flag_is_macro << 1, 636 Flag_is_cisc_alternate = Flag_is_Con << 1, 637 Flag_is_Branch = Flag_is_cisc_alternate << 1, 638 Flag_is_dead_loop_safe = Flag_is_Branch << 1, 639 Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1, 640 _max_flags = (Flag_may_be_short_branch << 1) - 1 // allow flags combination 641 }; 642 643 private: 644 jushort _class_id; 645 jushort _flags; 646 647 protected: 648 // These methods should be called from constructors only. 649 void init_class_id(jushort c) { 650 assert(c <= _max_classes, "invalid node class"); 651 _class_id = c; // cast out const 652 } 653 void init_flags(jushort fl) { 654 assert(fl <= _max_flags, "invalid node flag"); 655 _flags |= fl; 656 } 657 void clear_flag(jushort fl) { 658 assert(fl <= _max_flags, "invalid node flag"); 659 _flags &= ~fl; 660 } 661 662 public: 663 const jushort class_id() const { return _class_id; } 664 665 const jushort flags() const { return _flags; } 666 667 // Return a dense integer opcode number 668 virtual int Opcode() const; 669 670 // Virtual inherited Node size 671 virtual uint size_of() const; 672 673 // Other interesting Node properties 674 #define DEFINE_CLASS_QUERY(type) \ 675 bool is_##type() const { \ 676 return ((_class_id & ClassMask_##type) == Class_##type); \ 677 } \ 678 type##Node *as_##type() const { \ 679 assert(is_##type(), "invalid node class"); \ 680 return (type##Node*)this; \ 681 } \ 682 type##Node* isa_##type() const { \ 683 return (is_##type()) ? as_##type() : NULL; \ 684 } 685 686 DEFINE_CLASS_QUERY(AbstractLock) 687 DEFINE_CLASS_QUERY(Add) 688 DEFINE_CLASS_QUERY(AddP) 689 DEFINE_CLASS_QUERY(Allocate) 690 DEFINE_CLASS_QUERY(AllocateArray) 691 DEFINE_CLASS_QUERY(Bool) 692 DEFINE_CLASS_QUERY(BoxLock) 693 DEFINE_CLASS_QUERY(Call) 694 DEFINE_CLASS_QUERY(CallDynamicJava) 695 DEFINE_CLASS_QUERY(CallJava) 696 DEFINE_CLASS_QUERY(CallLeaf) 697 DEFINE_CLASS_QUERY(CallRuntime) 698 DEFINE_CLASS_QUERY(CallStaticJava) 699 DEFINE_CLASS_QUERY(Catch) 700 DEFINE_CLASS_QUERY(CatchProj) 701 DEFINE_CLASS_QUERY(CheckCastPP) 702 DEFINE_CLASS_QUERY(ConstraintCast) 703 DEFINE_CLASS_QUERY(ClearArray) 704 DEFINE_CLASS_QUERY(CMove) 705 DEFINE_CLASS_QUERY(Cmp) 706 DEFINE_CLASS_QUERY(CountedLoop) 707 DEFINE_CLASS_QUERY(CountedLoopEnd) 708 DEFINE_CLASS_QUERY(DecodeN) 709 DEFINE_CLASS_QUERY(EncodeP) 710 DEFINE_CLASS_QUERY(FastLock) 711 DEFINE_CLASS_QUERY(FastUnlock) 712 DEFINE_CLASS_QUERY(If) 713 DEFINE_CLASS_QUERY(IfFalse) 714 DEFINE_CLASS_QUERY(IfTrue) 715 DEFINE_CLASS_QUERY(Initialize) 716 DEFINE_CLASS_QUERY(Jump) 717 DEFINE_CLASS_QUERY(JumpProj) 718 DEFINE_CLASS_QUERY(Load) 719 DEFINE_CLASS_QUERY(LoadStore) 720 DEFINE_CLASS_QUERY(Lock) 721 DEFINE_CLASS_QUERY(Loop) 722 DEFINE_CLASS_QUERY(Mach) 723 DEFINE_CLASS_QUERY(MachCall) 724 DEFINE_CLASS_QUERY(MachCallDynamicJava) 725 DEFINE_CLASS_QUERY(MachCallJava) 726 DEFINE_CLASS_QUERY(MachCallLeaf) 727 DEFINE_CLASS_QUERY(MachCallRuntime) 728 DEFINE_CLASS_QUERY(MachCallStaticJava) 729 DEFINE_CLASS_QUERY(MachConstantBase) 730 DEFINE_CLASS_QUERY(MachConstant) 731 DEFINE_CLASS_QUERY(MachGoto) 732 DEFINE_CLASS_QUERY(MachIf) 733 DEFINE_CLASS_QUERY(MachNullCheck) 734 DEFINE_CLASS_QUERY(MachProj) 735 DEFINE_CLASS_QUERY(MachReturn) 736 DEFINE_CLASS_QUERY(MachSafePoint) 737 DEFINE_CLASS_QUERY(MachSpillCopy) 738 DEFINE_CLASS_QUERY(MachTemp) 739 DEFINE_CLASS_QUERY(Mem) 740 DEFINE_CLASS_QUERY(MemBar) 741 DEFINE_CLASS_QUERY(MergeMem) 742 DEFINE_CLASS_QUERY(Multi) 743 DEFINE_CLASS_QUERY(MultiBranch) 744 DEFINE_CLASS_QUERY(Parm) 745 DEFINE_CLASS_QUERY(PCTable) 746 DEFINE_CLASS_QUERY(Phi) 747 DEFINE_CLASS_QUERY(Proj) 748 DEFINE_CLASS_QUERY(Region) 749 DEFINE_CLASS_QUERY(Root) 750 DEFINE_CLASS_QUERY(SafePoint) 751 DEFINE_CLASS_QUERY(SafePointScalarObject) 752 DEFINE_CLASS_QUERY(Start) 753 DEFINE_CLASS_QUERY(Store) 754 DEFINE_CLASS_QUERY(Sub) 755 DEFINE_CLASS_QUERY(Type) 756 DEFINE_CLASS_QUERY(Vector) 757 DEFINE_CLASS_QUERY(VectorLoad) 758 DEFINE_CLASS_QUERY(VectorStore) 759 DEFINE_CLASS_QUERY(Unlock) 760 761 #undef DEFINE_CLASS_QUERY 762 763 // duplicate of is_MachSpillCopy() 764 bool is_SpillCopy () const { 765 return ((_class_id & ClassMask_MachSpillCopy) == Class_MachSpillCopy); 766 } 767 768 bool is_Con () const { return (_flags & Flag_is_Con) != 0; } 769 // The data node which is safe to leave in dead loop during IGVN optimization. 770 bool is_dead_loop_safe() const { 771 return is_Phi() || (is_Proj() && in(0) == NULL) || 772 ((_flags & (Flag_is_dead_loop_safe | Flag_is_Con)) != 0 && 773 (!is_Proj() || !in(0)->is_Allocate())); 774 } 775 776 // is_Copy() returns copied edge index (0 or 1) 777 uint is_Copy() const { return (_flags & Flag_is_Copy); } 778 779 virtual bool is_CFG() const { return false; } 780 781 // If this node is control-dependent on a test, can it be 782 // rerouted to a dominating equivalent test? This is usually 783 // true of non-CFG nodes, but can be false for operations which 784 // depend for their correct sequencing on more than one test. 785 // (In that case, hoisting to a dominating test may silently 786 // skip some other important test.) 787 virtual bool depends_only_on_test() const { assert(!is_CFG(), ""); return true; }; 788 789 // defined for MachNodes that match 'If' | 'Goto' | 'CountedLoopEnd' | 'Jump' 790 bool is_Branch() const { return (_flags & Flag_is_Branch) != 0; } 791 792 // When building basic blocks, I need to have a notion of block beginning 793 // Nodes, next block selector Nodes (block enders), and next block 794 // projections. These calls need to work on their machine equivalents. The 795 // Ideal beginning Nodes are RootNode, RegionNode and StartNode. 796 bool is_block_start() const { 797 if ( is_Region() ) 798 return this == (const Node*)in(0); 799 else 800 return is_Start(); 801 } 802 803 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root, 804 // Goto and Return. This call also returns the block ending Node. 805 virtual const Node *is_block_proj() const; 806 807 // The node is a "macro" node which needs to be expanded before matching 808 bool is_macro() const { return (_flags & Flag_is_macro) != 0; } 809 810 //----------------- Optimization 811 812 // Get the worst-case Type output for this Node. 813 virtual const class Type *bottom_type() const; 814 815 // If we find a better type for a node, try to record it permanently. 816 // Return true if this node actually changed. 817 // Be sure to do the hash_delete game in the "rehash" variant. 818 void raise_bottom_type(const Type* new_type); 819 820 // Get the address type with which this node uses and/or defs memory, 821 // or NULL if none. The address type is conservatively wide. 822 // Returns non-null for calls, membars, loads, stores, etc. 823 // Returns TypePtr::BOTTOM if the node touches memory "broadly". 824 virtual const class TypePtr *adr_type() const { return NULL; } 825 826 // Return an existing node which computes the same function as this node. 827 // The optimistic combined algorithm requires this to return a Node which 828 // is a small number of steps away (e.g., one of my inputs). 829 virtual Node *Identity( PhaseTransform *phase ); |