1584 const Type* divisor_type = phase->type(divisor());
1585 if (dividend_type == Type::TOP || divisor_type == Type::TOP) {
1586 return phase->C->top();
1587 }
1588 const Type* constant_result = get_result_if_constant(dividend_type, divisor_type);
1589 if (constant_result != nullptr) {
1590 return make_tuple_of_input_state_and_constant_result(igvn, constant_result);
1591 }
1592 }
1593
1594 return CallLeafPureNode::Ideal(phase, can_reshape);
1595 }
1596
1597 /* Give a tuple node for ::Ideal to return, made of the input state (control to return addr)
1598 * and the given constant result. Idealization of projections will make sure to transparently
1599 * propagate the input state and replace the result by the said constant.
1600 */
1601 TupleNode* ModFloatingNode::make_tuple_of_input_state_and_constant_result(PhaseIterGVN* phase, const Type* con) const {
1602 Node* con_node = phase->makecon(con);
1603 TupleNode* tuple = TupleNode::make(
1604 tf()->range(),
1605 in(TypeFunc::Control),
1606 in(TypeFunc::I_O),
1607 in(TypeFunc::Memory),
1608 in(TypeFunc::FramePtr),
1609 in(TypeFunc::ReturnAdr),
1610 con_node);
1611
1612 return tuple;
1613 }
1614
1615 //=============================================================================
1616
1617 DivModNode::DivModNode( Node *c, Node *dividend, Node *divisor ) : MultiNode(3) {
1618 init_req(0, c);
1619 init_req(1, dividend);
1620 init_req(2, divisor);
1621 }
1622
1623 DivModNode* DivModNode::make(Node* div_or_mod, BasicType bt, bool is_unsigned) {
1624 assert(bt == T_INT || bt == T_LONG, "only int or long input pattern accepted");
1647 DivModINode* divmod = new DivModINode(n->in(0), n->in(1), n->in(2));
1648 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1649 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1650 return divmod;
1651 }
1652
1653 //------------------------------make------------------------------------------
1654 DivModLNode* DivModLNode::make(Node* div_or_mod) {
1655 Node* n = div_or_mod;
1656 assert(n->Opcode() == Op_DivL || n->Opcode() == Op_ModL,
1657 "only div or mod input pattern accepted");
1658
1659 DivModLNode* divmod = new DivModLNode(n->in(0), n->in(1), n->in(2));
1660 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1661 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1662 return divmod;
1663 }
1664
1665 //------------------------------match------------------------------------------
1666 // return result(s) along with their RegMask info
1667 Node *DivModINode::match( const ProjNode *proj, const Matcher *match ) {
1668 uint ideal_reg = proj->ideal_reg();
1669 RegMask rm;
1670 if (proj->_con == div_proj_num) {
1671 rm = match->divI_proj_mask();
1672 } else {
1673 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1674 rm = match->modI_proj_mask();
1675 }
1676 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1677 }
1678
1679
1680 //------------------------------match------------------------------------------
1681 // return result(s) along with their RegMask info
1682 Node *DivModLNode::match( const ProjNode *proj, const Matcher *match ) {
1683 uint ideal_reg = proj->ideal_reg();
1684 RegMask rm;
1685 if (proj->_con == div_proj_num) {
1686 rm = match->divL_proj_mask();
1687 } else {
1688 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1689 rm = match->modL_proj_mask();
1690 }
1691 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1692 }
1693
1694 //------------------------------make------------------------------------------
1695 UDivModINode* UDivModINode::make(Node* div_or_mod) {
1696 Node* n = div_or_mod;
1697 assert(n->Opcode() == Op_UDivI || n->Opcode() == Op_UModI,
1698 "only div or mod input pattern accepted");
1699
1700 UDivModINode* divmod = new UDivModINode(n->in(0), n->in(1), n->in(2));
1701 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1702 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1703 return divmod;
1704 }
1705
1706 //------------------------------make------------------------------------------
1707 UDivModLNode* UDivModLNode::make(Node* div_or_mod) {
1708 Node* n = div_or_mod;
1709 assert(n->Opcode() == Op_UDivL || n->Opcode() == Op_UModL,
1710 "only div or mod input pattern accepted");
1711
1712 UDivModLNode* divmod = new UDivModLNode(n->in(0), n->in(1), n->in(2));
1713 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1714 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1715 return divmod;
1716 }
1717
1718 //------------------------------match------------------------------------------
1719 // return result(s) along with their RegMask info
1720 Node* UDivModINode::match( const ProjNode *proj, const Matcher *match ) {
1721 uint ideal_reg = proj->ideal_reg();
1722 RegMask rm;
1723 if (proj->_con == div_proj_num) {
1724 rm = match->divI_proj_mask();
1725 } else {
1726 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1727 rm = match->modI_proj_mask();
1728 }
1729 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1730 }
1731
1732
1733 //------------------------------match------------------------------------------
1734 // return result(s) along with their RegMask info
1735 Node* UDivModLNode::match( const ProjNode *proj, const Matcher *match ) {
1736 uint ideal_reg = proj->ideal_reg();
1737 RegMask rm;
1738 if (proj->_con == div_proj_num) {
1739 rm = match->divL_proj_mask();
1740 } else {
1741 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1742 rm = match->modL_proj_mask();
1743 }
1744 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1745 }
|
1584 const Type* divisor_type = phase->type(divisor());
1585 if (dividend_type == Type::TOP || divisor_type == Type::TOP) {
1586 return phase->C->top();
1587 }
1588 const Type* constant_result = get_result_if_constant(dividend_type, divisor_type);
1589 if (constant_result != nullptr) {
1590 return make_tuple_of_input_state_and_constant_result(igvn, constant_result);
1591 }
1592 }
1593
1594 return CallLeafPureNode::Ideal(phase, can_reshape);
1595 }
1596
1597 /* Give a tuple node for ::Ideal to return, made of the input state (control to return addr)
1598 * and the given constant result. Idealization of projections will make sure to transparently
1599 * propagate the input state and replace the result by the said constant.
1600 */
1601 TupleNode* ModFloatingNode::make_tuple_of_input_state_and_constant_result(PhaseIterGVN* phase, const Type* con) const {
1602 Node* con_node = phase->makecon(con);
1603 TupleNode* tuple = TupleNode::make(
1604 tf()->range_cc(),
1605 in(TypeFunc::Control),
1606 in(TypeFunc::I_O),
1607 in(TypeFunc::Memory),
1608 in(TypeFunc::FramePtr),
1609 in(TypeFunc::ReturnAdr),
1610 con_node);
1611
1612 return tuple;
1613 }
1614
1615 //=============================================================================
1616
1617 DivModNode::DivModNode( Node *c, Node *dividend, Node *divisor ) : MultiNode(3) {
1618 init_req(0, c);
1619 init_req(1, dividend);
1620 init_req(2, divisor);
1621 }
1622
1623 DivModNode* DivModNode::make(Node* div_or_mod, BasicType bt, bool is_unsigned) {
1624 assert(bt == T_INT || bt == T_LONG, "only int or long input pattern accepted");
1647 DivModINode* divmod = new DivModINode(n->in(0), n->in(1), n->in(2));
1648 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1649 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1650 return divmod;
1651 }
1652
1653 //------------------------------make------------------------------------------
1654 DivModLNode* DivModLNode::make(Node* div_or_mod) {
1655 Node* n = div_or_mod;
1656 assert(n->Opcode() == Op_DivL || n->Opcode() == Op_ModL,
1657 "only div or mod input pattern accepted");
1658
1659 DivModLNode* divmod = new DivModLNode(n->in(0), n->in(1), n->in(2));
1660 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1661 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1662 return divmod;
1663 }
1664
1665 //------------------------------match------------------------------------------
1666 // return result(s) along with their RegMask info
1667 Node *DivModINode::match(const ProjNode *proj, const Matcher *match, const RegMask* mask) {
1668 uint ideal_reg = proj->ideal_reg();
1669 RegMask rm;
1670 if (proj->_con == div_proj_num) {
1671 rm = match->divI_proj_mask();
1672 } else {
1673 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1674 rm = match->modI_proj_mask();
1675 }
1676 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1677 }
1678
1679
1680 //------------------------------match------------------------------------------
1681 // return result(s) along with their RegMask info
1682 Node *DivModLNode::match(const ProjNode *proj, const Matcher *match, const RegMask* mask) {
1683 uint ideal_reg = proj->ideal_reg();
1684 RegMask rm;
1685 if (proj->_con == div_proj_num) {
1686 rm = match->divL_proj_mask();
1687 } else {
1688 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1689 rm = match->modL_proj_mask();
1690 }
1691 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1692 }
1693
1694 //------------------------------make------------------------------------------
1695 UDivModINode* UDivModINode::make(Node* div_or_mod) {
1696 Node* n = div_or_mod;
1697 assert(n->Opcode() == Op_UDivI || n->Opcode() == Op_UModI,
1698 "only div or mod input pattern accepted");
1699
1700 UDivModINode* divmod = new UDivModINode(n->in(0), n->in(1), n->in(2));
1701 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1702 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1703 return divmod;
1704 }
1705
1706 //------------------------------make------------------------------------------
1707 UDivModLNode* UDivModLNode::make(Node* div_or_mod) {
1708 Node* n = div_or_mod;
1709 assert(n->Opcode() == Op_UDivL || n->Opcode() == Op_UModL,
1710 "only div or mod input pattern accepted");
1711
1712 UDivModLNode* divmod = new UDivModLNode(n->in(0), n->in(1), n->in(2));
1713 Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num);
1714 Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num);
1715 return divmod;
1716 }
1717
1718 //------------------------------match------------------------------------------
1719 // return result(s) along with their RegMask info
1720 Node* UDivModINode::match(const ProjNode* proj, const Matcher* match, const RegMask* mask) {
1721 uint ideal_reg = proj->ideal_reg();
1722 RegMask rm;
1723 if (proj->_con == div_proj_num) {
1724 rm = match->divI_proj_mask();
1725 } else {
1726 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1727 rm = match->modI_proj_mask();
1728 }
1729 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1730 }
1731
1732
1733 //------------------------------match------------------------------------------
1734 // return result(s) along with their RegMask info
1735 Node* UDivModLNode::match( const ProjNode* proj, const Matcher* match, const RegMask* mask) {
1736 uint ideal_reg = proj->ideal_reg();
1737 RegMask rm;
1738 if (proj->_con == div_proj_num) {
1739 rm = match->divL_proj_mask();
1740 } else {
1741 assert(proj->_con == mod_proj_num, "must be div or mod projection");
1742 rm = match->modL_proj_mask();
1743 }
1744 return new MachProjNode(this, proj->_con, rm, ideal_reg);
1745 }
|