625 }
626
627 return nullptr; // No progress
628 }
629
630 //------------------------------bottom_type------------------------------------
631 // Bottom-type is the pointer-type with unknown offset.
632 const Type *AddPNode::bottom_type() const {
633 if (in(Address) == nullptr) return TypePtr::BOTTOM;
634 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
635 if( !tp ) return Type::TOP; // TOP input means TOP output
636 assert( in(Offset)->Opcode() != Op_ConP, "" );
637 const Type *t = in(Offset)->bottom_type();
638 if( t == Type::TOP )
639 return tp->add_offset(Type::OffsetTop);
640 const TypeX *tx = t->is_intptr_t();
641 intptr_t txoffset = Type::OffsetBot;
642 if (tx->is_con()) { // Left input is an add of a constant?
643 txoffset = tx->get_con();
644 }
645 return tp->add_offset(txoffset);
646 }
647
648 //------------------------------Value------------------------------------------
649 const Type* AddPNode::Value(PhaseGVN* phase) const {
650 // Either input is TOP ==> the result is TOP
651 const Type *t1 = phase->type( in(Address) );
652 const Type *t2 = phase->type( in(Offset) );
653 if( t1 == Type::TOP ) return Type::TOP;
654 if( t2 == Type::TOP ) return Type::TOP;
655
656 // Left input is a pointer
657 const TypePtr *p1 = t1->isa_ptr();
658 // Right input is an int
659 const TypeX *p2 = t2->is_intptr_t();
660 // Add 'em
661 intptr_t p2offset = Type::OffsetBot;
662 if (p2->is_con()) { // Left input is an add of a constant?
663 p2offset = p2->get_con();
664 }
665 return p1->add_offset(p2offset);
666 }
667
668 //------------------------Ideal_base_and_offset--------------------------------
669 // Split an oop pointer into a base and offset.
670 // (The offset might be Type::OffsetBot in the case of an array.)
671 // Return the base, or null if failure.
672 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
673 // second return value:
674 intptr_t& offset) {
675 if (ptr->is_AddP()) {
676 Node* base = ptr->in(AddPNode::Base);
677 Node* addr = ptr->in(AddPNode::Address);
678 Node* offs = ptr->in(AddPNode::Offset);
679 if (base == addr || base->is_top()) {
680 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
681 if (offset != Type::OffsetBot) {
682 return addr;
683 }
684 }
|
625 }
626
627 return nullptr; // No progress
628 }
629
630 //------------------------------bottom_type------------------------------------
631 // Bottom-type is the pointer-type with unknown offset.
632 const Type *AddPNode::bottom_type() const {
633 if (in(Address) == nullptr) return TypePtr::BOTTOM;
634 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
635 if( !tp ) return Type::TOP; // TOP input means TOP output
636 assert( in(Offset)->Opcode() != Op_ConP, "" );
637 const Type *t = in(Offset)->bottom_type();
638 if( t == Type::TOP )
639 return tp->add_offset(Type::OffsetTop);
640 const TypeX *tx = t->is_intptr_t();
641 intptr_t txoffset = Type::OffsetBot;
642 if (tx->is_con()) { // Left input is an add of a constant?
643 txoffset = tx->get_con();
644 }
645 if (tp->isa_aryptr()) {
646 // In the case of a flat inline type array, each field has its
647 // own slice so we need to extract the field being accessed from
648 // the address computation
649 return tp->is_aryptr()->add_field_offset_and_offset(txoffset);
650 }
651 return tp->add_offset(txoffset);
652 }
653
654 //------------------------------Value------------------------------------------
655 const Type* AddPNode::Value(PhaseGVN* phase) const {
656 // Either input is TOP ==> the result is TOP
657 const Type *t1 = phase->type( in(Address) );
658 const Type *t2 = phase->type( in(Offset) );
659 if( t1 == Type::TOP ) return Type::TOP;
660 if( t2 == Type::TOP ) return Type::TOP;
661
662 // Left input is a pointer
663 const TypePtr *p1 = t1->isa_ptr();
664 // Right input is an int
665 const TypeX *p2 = t2->is_intptr_t();
666 // Add 'em
667 intptr_t p2offset = Type::OffsetBot;
668 if (p2->is_con()) { // Left input is an add of a constant?
669 p2offset = p2->get_con();
670 }
671 if (p1->isa_aryptr()) {
672 // In the case of a flat inline type array, each field has its
673 // own slice so we need to extract the field being accessed from
674 // the address computation
675 return p1->is_aryptr()->add_field_offset_and_offset(p2offset);
676 }
677 return p1->add_offset(p2offset);
678 }
679
680 //------------------------Ideal_base_and_offset--------------------------------
681 // Split an oop pointer into a base and offset.
682 // (The offset might be Type::OffsetBot in the case of an array.)
683 // Return the base, or null if failure.
684 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseValues* phase,
685 // second return value:
686 intptr_t& offset) {
687 if (ptr->is_AddP()) {
688 Node* base = ptr->in(AddPNode::Base);
689 Node* addr = ptr->in(AddPNode::Address);
690 Node* offs = ptr->in(AddPNode::Offset);
691 if (base == addr || base->is_top()) {
692 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
693 if (offset != Type::OffsetBot) {
694 return addr;
695 }
696 }
|