849 }
850
851 return nullptr; // No progress
852 }
853
854 //------------------------------bottom_type------------------------------------
855 // Bottom-type is the pointer-type with unknown offset.
856 const Type *AddPNode::bottom_type() const {
857 if (in(Address) == nullptr) return TypePtr::BOTTOM;
858 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
859 if( !tp ) return Type::TOP; // TOP input means TOP output
860 assert( in(Offset)->Opcode() != Op_ConP, "" );
861 const Type *t = in(Offset)->bottom_type();
862 if( t == Type::TOP )
863 return tp->add_offset(Type::OffsetTop);
864 const TypeX *tx = t->is_intptr_t();
865 intptr_t txoffset = Type::OffsetBot;
866 if (tx->is_con()) { // Left input is an add of a constant?
867 txoffset = tx->get_con();
868 }
869 return tp->add_offset(txoffset);
870 }
871
872 //------------------------------Value------------------------------------------
873 const Type* AddPNode::Value(PhaseGVN* phase) const {
874 // Either input is TOP ==> the result is TOP
875 const Type *t1 = phase->type( in(Address) );
876 const Type *t2 = phase->type( in(Offset) );
877 if( t1 == Type::TOP ) return Type::TOP;
878 if( t2 == Type::TOP ) return Type::TOP;
879
880 // Left input is a pointer
881 const TypePtr *p1 = t1->isa_ptr();
882 // Right input is an int
883 const TypeX *p2 = t2->is_intptr_t();
884 // Add 'em
885 intptr_t p2offset = Type::OffsetBot;
886 if (p2->is_con()) { // Left input is an add of a constant?
887 p2offset = p2->get_con();
888 }
889 return p1->add_offset(p2offset);
890 }
891
892 //------------------------Ideal_base_and_offset--------------------------------
893 // Split an oop pointer into a base and offset.
894 // (The offset might be Type::OffsetBot in the case of an array.)
895 // Return the base, or null if failure.
896 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
897 // second return value:
898 intptr_t& offset) {
899 if (ptr->is_AddP()) {
900 Node* base = ptr->in(AddPNode::Base);
901 Node* addr = ptr->in(AddPNode::Address);
902 Node* offs = ptr->in(AddPNode::Offset);
903 if (base == addr || base->is_top()) {
904 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
905 if (offset != Type::OffsetBot) {
906 return addr;
907 }
908 }
|
849 }
850
851 return nullptr; // No progress
852 }
853
854 //------------------------------bottom_type------------------------------------
855 // Bottom-type is the pointer-type with unknown offset.
856 const Type *AddPNode::bottom_type() const {
857 if (in(Address) == nullptr) return TypePtr::BOTTOM;
858 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
859 if( !tp ) return Type::TOP; // TOP input means TOP output
860 assert( in(Offset)->Opcode() != Op_ConP, "" );
861 const Type *t = in(Offset)->bottom_type();
862 if( t == Type::TOP )
863 return tp->add_offset(Type::OffsetTop);
864 const TypeX *tx = t->is_intptr_t();
865 intptr_t txoffset = Type::OffsetBot;
866 if (tx->is_con()) { // Left input is an add of a constant?
867 txoffset = tx->get_con();
868 }
869 if (tp->isa_aryptr()) {
870 // In the case of a flat inline type array, each field has its
871 // own slice so we need to extract the field being accessed from
872 // the address computation
873 return tp->is_aryptr()->add_field_offset_and_offset(txoffset);
874 }
875 return tp->add_offset(txoffset);
876 }
877
878 //------------------------------Value------------------------------------------
879 const Type* AddPNode::Value(PhaseGVN* phase) const {
880 // Either input is TOP ==> the result is TOP
881 const Type *t1 = phase->type( in(Address) );
882 const Type *t2 = phase->type( in(Offset) );
883 if( t1 == Type::TOP ) return Type::TOP;
884 if( t2 == Type::TOP ) return Type::TOP;
885
886 // Left input is a pointer
887 const TypePtr *p1 = t1->isa_ptr();
888 // Right input is an int
889 const TypeX *p2 = t2->is_intptr_t();
890 // Add 'em
891 intptr_t p2offset = Type::OffsetBot;
892 if (p2->is_con()) { // Left input is an add of a constant?
893 p2offset = p2->get_con();
894 }
895 if (p1->isa_aryptr()) {
896 // In the case of a flat inline type array, each field has its
897 // own slice so we need to extract the field being accessed from
898 // the address computation
899 return p1->is_aryptr()->add_field_offset_and_offset(p2offset);
900 }
901 return p1->add_offset(p2offset);
902 }
903
904 //------------------------Ideal_base_and_offset--------------------------------
905 // Split an oop pointer into a base and offset.
906 // (The offset might be Type::OffsetBot in the case of an array.)
907 // Return the base, or null if failure.
908 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
909 // second return value:
910 intptr_t& offset) {
911 if (ptr->is_AddP()) {
912 Node* base = ptr->in(AddPNode::Base);
913 Node* addr = ptr->in(AddPNode::Address);
914 Node* offs = ptr->in(AddPNode::Offset);
915 if (base == addr || base->is_top()) {
916 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
917 if (offset != Type::OffsetBot) {
918 return addr;
919 }
920 }
|