675 }
676
677 return nullptr; // No progress
678 }
679
680 //------------------------------bottom_type------------------------------------
681 // Bottom-type is the pointer-type with unknown offset.
682 const Type *AddPNode::bottom_type() const {
683 if (in(Address) == nullptr) return TypePtr::BOTTOM;
684 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
685 if( !tp ) return Type::TOP; // TOP input means TOP output
686 assert( in(Offset)->Opcode() != Op_ConP, "" );
687 const Type *t = in(Offset)->bottom_type();
688 if( t == Type::TOP )
689 return tp->add_offset(Type::OffsetTop);
690 const TypeX *tx = t->is_intptr_t();
691 intptr_t txoffset = Type::OffsetBot;
692 if (tx->is_con()) { // Left input is an add of a constant?
693 txoffset = tx->get_con();
694 }
695 return tp->add_offset(txoffset);
696 }
697
698 //------------------------------Value------------------------------------------
699 const Type* AddPNode::Value(PhaseGVN* phase) const {
700 // Either input is TOP ==> the result is TOP
701 const Type *t1 = phase->type( in(Address) );
702 const Type *t2 = phase->type( in(Offset) );
703 if( t1 == Type::TOP ) return Type::TOP;
704 if( t2 == Type::TOP ) return Type::TOP;
705
706 // Left input is a pointer
707 const TypePtr *p1 = t1->isa_ptr();
708 // Right input is an int
709 const TypeX *p2 = t2->is_intptr_t();
710 // Add 'em
711 intptr_t p2offset = Type::OffsetBot;
712 if (p2->is_con()) { // Left input is an add of a constant?
713 p2offset = p2->get_con();
714 }
715 return p1->add_offset(p2offset);
716 }
717
718 //------------------------Ideal_base_and_offset--------------------------------
719 // Split an oop pointer into a base and offset.
720 // (The offset might be Type::OffsetBot in the case of an array.)
721 // Return the base, or null if failure.
722 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
723 // second return value:
724 intptr_t& offset) {
725 if (ptr->is_AddP()) {
726 Node* base = ptr->in(AddPNode::Base);
727 Node* addr = ptr->in(AddPNode::Address);
728 Node* offs = ptr->in(AddPNode::Offset);
729 if (base == addr || base->is_top()) {
730 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
731 if (offset != Type::OffsetBot) {
732 return addr;
733 }
734 }
|
675 }
676
677 return nullptr; // No progress
678 }
679
680 //------------------------------bottom_type------------------------------------
681 // Bottom-type is the pointer-type with unknown offset.
682 const Type *AddPNode::bottom_type() const {
683 if (in(Address) == nullptr) return TypePtr::BOTTOM;
684 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
685 if( !tp ) return Type::TOP; // TOP input means TOP output
686 assert( in(Offset)->Opcode() != Op_ConP, "" );
687 const Type *t = in(Offset)->bottom_type();
688 if( t == Type::TOP )
689 return tp->add_offset(Type::OffsetTop);
690 const TypeX *tx = t->is_intptr_t();
691 intptr_t txoffset = Type::OffsetBot;
692 if (tx->is_con()) { // Left input is an add of a constant?
693 txoffset = tx->get_con();
694 }
695 if (tp->isa_aryptr()) {
696 // In the case of a flat inline type array, each field has its
697 // own slice so we need to extract the field being accessed from
698 // the address computation
699 return tp->is_aryptr()->add_field_offset_and_offset(txoffset);
700 }
701 return tp->add_offset(txoffset);
702 }
703
704 //------------------------------Value------------------------------------------
705 const Type* AddPNode::Value(PhaseGVN* phase) const {
706 // Either input is TOP ==> the result is TOP
707 const Type *t1 = phase->type( in(Address) );
708 const Type *t2 = phase->type( in(Offset) );
709 if( t1 == Type::TOP ) return Type::TOP;
710 if( t2 == Type::TOP ) return Type::TOP;
711
712 // Left input is a pointer
713 const TypePtr *p1 = t1->isa_ptr();
714 // Right input is an int
715 const TypeX *p2 = t2->is_intptr_t();
716 // Add 'em
717 intptr_t p2offset = Type::OffsetBot;
718 if (p2->is_con()) { // Left input is an add of a constant?
719 p2offset = p2->get_con();
720 }
721 if (p1->isa_aryptr()) {
722 // In the case of a flat inline type array, each field has its
723 // own slice so we need to extract the field being accessed from
724 // the address computation
725 return p1->is_aryptr()->add_field_offset_and_offset(p2offset);
726 }
727 return p1->add_offset(p2offset);
728 }
729
730 //------------------------Ideal_base_and_offset--------------------------------
731 // Split an oop pointer into a base and offset.
732 // (The offset might be Type::OffsetBot in the case of an array.)
733 // Return the base, or null if failure.
734 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
735 // second return value:
736 intptr_t& offset) {
737 if (ptr->is_AddP()) {
738 Node* base = ptr->in(AddPNode::Base);
739 Node* addr = ptr->in(AddPNode::Address);
740 Node* offs = ptr->in(AddPNode::Offset);
741 if (base == addr || base->is_top()) {
742 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
743 if (offset != Type::OffsetBot) {
744 return addr;
745 }
746 }
|