288 if (!RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1))) {
289 // the compiler cannot represent this method's calling sequence
290 C->record_method_not_compilable("must be able to represent all call arguments in reg mask");
291 }
292
293 if (C->failing()) return; // bailed out on incoming arg failure
294
295 // ---------------
296 // Collect roots of matcher trees. Every node for which
297 // _shared[_idx] is cleared is guaranteed to not be shared, and thus
298 // can be a valid interior of some tree.
299 find_shared( C->root() );
300 find_shared( C->top() );
301
302 C->print_method(PHASE_BEFORE_MATCHING);
303
304 // Create new ideal node ConP #NULL even if it does exist in old space
305 // to avoid false sharing if the corresponding mach node is not used.
306 // The corresponding mach node is only used in rare cases for derived
307 // pointers.
308 Node* new_ideal_null = ConNode::make(C, TypePtr::NULL_PTR);
309
310 // Swap out to old-space; emptying new-space
311 Arena *old = C->node_arena()->move_contents(C->old_arena());
312
313 // Save debug and profile information for nodes in old space:
314 _old_node_note_array = C->node_note_array();
315 if (_old_node_note_array != NULL) {
316 C->set_node_note_array(new(C->comp_arena()) GrowableArray<Node_Notes*>
317 (C->comp_arena(), _old_node_note_array->length(),
318 0, NULL));
319 }
320
321 // Pre-size the new_node table to avoid the need for range checks.
322 grow_new_node_array(C->unique());
323
324 // Reset node counter so MachNodes start with _idx at 0
325 int nodes = C->unique(); // save value
326 C->set_unique(0);
327 C->reset_dead_node_list();
328
1626 // The root of the Ideal match tree is always an instruction, so we enter
1627 // the recursion here. After building the MachNode, we need to recurse
1628 // the tree checking for these cases:
1629 // (1) Child is an instruction -
1630 // Build the instruction (recursively), add it as an edge.
1631 // Build a simple operand (register) to hold the result of the instruction.
1632 // (2) Child is an interior part of an instruction -
1633 // Skip over it (do nothing)
1634 // (3) Child is the start of a operand -
1635 // Build the operand, place it inside the instruction
1636 // Call ReduceOper.
1637 MachNode *Matcher::ReduceInst( State *s, int rule, Node *&mem ) {
1638 assert( rule >= NUM_OPERANDS, "called with operand rule" );
1639
1640 MachNode* shared_node = find_shared_node(s->_leaf, rule);
1641 if (shared_node != NULL) {
1642 return shared_node;
1643 }
1644
1645 // Build the object to represent this state & prepare for recursive calls
1646 MachNode *mach = s->MachNodeGenerator( rule, C );
1647 mach->_opnds[0] = s->MachOperGenerator( _reduceOp[rule], C );
1648 assert( mach->_opnds[0] != NULL, "Missing result operand" );
1649 Node *leaf = s->_leaf;
1650 // Check for instruction or instruction chain rule
1651 if( rule >= _END_INST_CHAIN_RULE || rule < _BEGIN_INST_CHAIN_RULE ) {
1652 assert(C->node_arena()->contains(s->_leaf) || !has_new_node(s->_leaf),
1653 "duplicating node that's already been matched");
1654 // Instruction
1655 mach->add_req( leaf->in(0) ); // Set initial control
1656 // Reduce interior of complex instruction
1657 ReduceInst_Interior( s, rule, mem, mach, 1 );
1658 } else {
1659 // Instruction chain rules are data-dependent on their inputs
1660 mach->add_req(0); // Set initial control to none
1661 ReduceInst_Chain_Rule( s, rule, mem, mach );
1662 }
1663
1664 // If a Memory was used, insert a Memory edge
1665 if( mem != (Node*)1 ) {
1666 mach->ins_req(MemNode::Memory,mem);
1667 #ifdef ASSERT
1739 return ex;
1740 }
1741
1742 void Matcher::ReduceInst_Chain_Rule( State *s, int rule, Node *&mem, MachNode *mach ) {
1743 // 'op' is what I am expecting to receive
1744 int op = _leftOp[rule];
1745 // Operand type to catch childs result
1746 // This is what my child will give me.
1747 int opnd_class_instance = s->_rule[op];
1748 // Choose between operand class or not.
1749 // This is what I will receive.
1750 int catch_op = (FIRST_OPERAND_CLASS <= op && op < NUM_OPERANDS) ? opnd_class_instance : op;
1751 // New rule for child. Chase operand classes to get the actual rule.
1752 int newrule = s->_rule[catch_op];
1753
1754 if( newrule < NUM_OPERANDS ) {
1755 // Chain from operand or operand class, may be output of shared node
1756 assert( 0 <= opnd_class_instance && opnd_class_instance < NUM_OPERANDS,
1757 "Bad AD file: Instruction chain rule must chain from operand");
1758 // Insert operand into array of operands for this instruction
1759 mach->_opnds[1] = s->MachOperGenerator( opnd_class_instance, C );
1760
1761 ReduceOper( s, newrule, mem, mach );
1762 } else {
1763 // Chain from the result of an instruction
1764 assert( newrule >= _LAST_MACH_OPER, "Do NOT chain from internal operand");
1765 mach->_opnds[1] = s->MachOperGenerator( _reduceOp[catch_op], C );
1766 Node *mem1 = (Node*)1;
1767 debug_only(Node *save_mem_node = _mem_node;)
1768 mach->add_req( ReduceInst(s, newrule, mem1) );
1769 debug_only(_mem_node = save_mem_node;)
1770 }
1771 return;
1772 }
1773
1774
1775 uint Matcher::ReduceInst_Interior( State *s, int rule, Node *&mem, MachNode *mach, uint num_opnds ) {
1776 if( s->_leaf->is_Load() ) {
1777 Node *mem2 = s->_leaf->in(MemNode::Memory);
1778 assert( mem == (Node*)1 || mem == mem2, "multiple Memories being matched at once?" );
1779 debug_only( if( mem == (Node*)1 ) _mem_node = s->_leaf;)
1780 mem = mem2;
1781 }
1782 if( s->_leaf->in(0) != NULL && s->_leaf->req() > 1) {
1783 if( mach->in(0) == NULL )
1784 mach->set_req(0, s->_leaf->in(0));
1785 }
1790 if( newstate == NULL ) break; // Might only have 1 child
1791 // 'op' is what I am expecting to receive
1792 int op;
1793 if( i == 0 ) {
1794 op = _leftOp[rule];
1795 } else {
1796 op = _rightOp[rule];
1797 }
1798 // Operand type to catch childs result
1799 // This is what my child will give me.
1800 int opnd_class_instance = newstate->_rule[op];
1801 // Choose between operand class or not.
1802 // This is what I will receive.
1803 int catch_op = (op >= FIRST_OPERAND_CLASS && op < NUM_OPERANDS) ? opnd_class_instance : op;
1804 // New rule for child. Chase operand classes to get the actual rule.
1805 int newrule = newstate->_rule[catch_op];
1806
1807 if( newrule < NUM_OPERANDS ) { // Operand/operandClass or internalOp/instruction?
1808 // Operand/operandClass
1809 // Insert operand into array of operands for this instruction
1810 mach->_opnds[num_opnds++] = newstate->MachOperGenerator( opnd_class_instance, C );
1811 ReduceOper( newstate, newrule, mem, mach );
1812
1813 } else { // Child is internal operand or new instruction
1814 if( newrule < _LAST_MACH_OPER ) { // internal operand or instruction?
1815 // internal operand --> call ReduceInst_Interior
1816 // Interior of complex instruction. Do nothing but recurse.
1817 num_opnds = ReduceInst_Interior( newstate, newrule, mem, mach, num_opnds );
1818 } else {
1819 // instruction --> call build operand( ) to catch result
1820 // --> ReduceInst( newrule )
1821 mach->_opnds[num_opnds++] = s->MachOperGenerator( _reduceOp[catch_op], C );
1822 Node *mem1 = (Node*)1;
1823 debug_only(Node *save_mem_node = _mem_node;)
1824 mach->add_req( ReduceInst( newstate, newrule, mem1 ) );
1825 debug_only(_mem_node = save_mem_node;)
1826 }
1827 }
1828 assert( mach->_opnds[num_opnds-1], "" );
1829 }
1830 return num_opnds;
1831 }
1832
1833 // This routine walks the interior of possible complex operands.
1834 // At each point we check our children in the match tree:
1835 // (1) No children -
1836 // We are a leaf; add _leaf field as an input to the MachNode
1837 // (2) Child is an internal operand -
1838 // Skip over it ( do nothing )
1839 // (3) Child is an instruction -
1840 // Call ReduceInst recursively and
1841 // and instruction as an input to the MachNode
|
288 if (!RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1))) {
289 // the compiler cannot represent this method's calling sequence
290 C->record_method_not_compilable("must be able to represent all call arguments in reg mask");
291 }
292
293 if (C->failing()) return; // bailed out on incoming arg failure
294
295 // ---------------
296 // Collect roots of matcher trees. Every node for which
297 // _shared[_idx] is cleared is guaranteed to not be shared, and thus
298 // can be a valid interior of some tree.
299 find_shared( C->root() );
300 find_shared( C->top() );
301
302 C->print_method(PHASE_BEFORE_MATCHING);
303
304 // Create new ideal node ConP #NULL even if it does exist in old space
305 // to avoid false sharing if the corresponding mach node is not used.
306 // The corresponding mach node is only used in rare cases for derived
307 // pointers.
308 Node* new_ideal_null = ConNode::make(TypePtr::NULL_PTR);
309
310 // Swap out to old-space; emptying new-space
311 Arena *old = C->node_arena()->move_contents(C->old_arena());
312
313 // Save debug and profile information for nodes in old space:
314 _old_node_note_array = C->node_note_array();
315 if (_old_node_note_array != NULL) {
316 C->set_node_note_array(new(C->comp_arena()) GrowableArray<Node_Notes*>
317 (C->comp_arena(), _old_node_note_array->length(),
318 0, NULL));
319 }
320
321 // Pre-size the new_node table to avoid the need for range checks.
322 grow_new_node_array(C->unique());
323
324 // Reset node counter so MachNodes start with _idx at 0
325 int nodes = C->unique(); // save value
326 C->set_unique(0);
327 C->reset_dead_node_list();
328
1626 // The root of the Ideal match tree is always an instruction, so we enter
1627 // the recursion here. After building the MachNode, we need to recurse
1628 // the tree checking for these cases:
1629 // (1) Child is an instruction -
1630 // Build the instruction (recursively), add it as an edge.
1631 // Build a simple operand (register) to hold the result of the instruction.
1632 // (2) Child is an interior part of an instruction -
1633 // Skip over it (do nothing)
1634 // (3) Child is the start of a operand -
1635 // Build the operand, place it inside the instruction
1636 // Call ReduceOper.
1637 MachNode *Matcher::ReduceInst( State *s, int rule, Node *&mem ) {
1638 assert( rule >= NUM_OPERANDS, "called with operand rule" );
1639
1640 MachNode* shared_node = find_shared_node(s->_leaf, rule);
1641 if (shared_node != NULL) {
1642 return shared_node;
1643 }
1644
1645 // Build the object to represent this state & prepare for recursive calls
1646 MachNode *mach = s->MachNodeGenerator( rule );
1647 mach->_opnds[0] = s->MachOperGenerator( _reduceOp[rule] );
1648 assert( mach->_opnds[0] != NULL, "Missing result operand" );
1649 Node *leaf = s->_leaf;
1650 // Check for instruction or instruction chain rule
1651 if( rule >= _END_INST_CHAIN_RULE || rule < _BEGIN_INST_CHAIN_RULE ) {
1652 assert(C->node_arena()->contains(s->_leaf) || !has_new_node(s->_leaf),
1653 "duplicating node that's already been matched");
1654 // Instruction
1655 mach->add_req( leaf->in(0) ); // Set initial control
1656 // Reduce interior of complex instruction
1657 ReduceInst_Interior( s, rule, mem, mach, 1 );
1658 } else {
1659 // Instruction chain rules are data-dependent on their inputs
1660 mach->add_req(0); // Set initial control to none
1661 ReduceInst_Chain_Rule( s, rule, mem, mach );
1662 }
1663
1664 // If a Memory was used, insert a Memory edge
1665 if( mem != (Node*)1 ) {
1666 mach->ins_req(MemNode::Memory,mem);
1667 #ifdef ASSERT
1739 return ex;
1740 }
1741
1742 void Matcher::ReduceInst_Chain_Rule( State *s, int rule, Node *&mem, MachNode *mach ) {
1743 // 'op' is what I am expecting to receive
1744 int op = _leftOp[rule];
1745 // Operand type to catch childs result
1746 // This is what my child will give me.
1747 int opnd_class_instance = s->_rule[op];
1748 // Choose between operand class or not.
1749 // This is what I will receive.
1750 int catch_op = (FIRST_OPERAND_CLASS <= op && op < NUM_OPERANDS) ? opnd_class_instance : op;
1751 // New rule for child. Chase operand classes to get the actual rule.
1752 int newrule = s->_rule[catch_op];
1753
1754 if( newrule < NUM_OPERANDS ) {
1755 // Chain from operand or operand class, may be output of shared node
1756 assert( 0 <= opnd_class_instance && opnd_class_instance < NUM_OPERANDS,
1757 "Bad AD file: Instruction chain rule must chain from operand");
1758 // Insert operand into array of operands for this instruction
1759 mach->_opnds[1] = s->MachOperGenerator( opnd_class_instance );
1760
1761 ReduceOper( s, newrule, mem, mach );
1762 } else {
1763 // Chain from the result of an instruction
1764 assert( newrule >= _LAST_MACH_OPER, "Do NOT chain from internal operand");
1765 mach->_opnds[1] = s->MachOperGenerator( _reduceOp[catch_op] );
1766 Node *mem1 = (Node*)1;
1767 debug_only(Node *save_mem_node = _mem_node;)
1768 mach->add_req( ReduceInst(s, newrule, mem1) );
1769 debug_only(_mem_node = save_mem_node;)
1770 }
1771 return;
1772 }
1773
1774
1775 uint Matcher::ReduceInst_Interior( State *s, int rule, Node *&mem, MachNode *mach, uint num_opnds ) {
1776 if( s->_leaf->is_Load() ) {
1777 Node *mem2 = s->_leaf->in(MemNode::Memory);
1778 assert( mem == (Node*)1 || mem == mem2, "multiple Memories being matched at once?" );
1779 debug_only( if( mem == (Node*)1 ) _mem_node = s->_leaf;)
1780 mem = mem2;
1781 }
1782 if( s->_leaf->in(0) != NULL && s->_leaf->req() > 1) {
1783 if( mach->in(0) == NULL )
1784 mach->set_req(0, s->_leaf->in(0));
1785 }
1790 if( newstate == NULL ) break; // Might only have 1 child
1791 // 'op' is what I am expecting to receive
1792 int op;
1793 if( i == 0 ) {
1794 op = _leftOp[rule];
1795 } else {
1796 op = _rightOp[rule];
1797 }
1798 // Operand type to catch childs result
1799 // This is what my child will give me.
1800 int opnd_class_instance = newstate->_rule[op];
1801 // Choose between operand class or not.
1802 // This is what I will receive.
1803 int catch_op = (op >= FIRST_OPERAND_CLASS && op < NUM_OPERANDS) ? opnd_class_instance : op;
1804 // New rule for child. Chase operand classes to get the actual rule.
1805 int newrule = newstate->_rule[catch_op];
1806
1807 if( newrule < NUM_OPERANDS ) { // Operand/operandClass or internalOp/instruction?
1808 // Operand/operandClass
1809 // Insert operand into array of operands for this instruction
1810 mach->_opnds[num_opnds++] = newstate->MachOperGenerator( opnd_class_instance );
1811 ReduceOper( newstate, newrule, mem, mach );
1812
1813 } else { // Child is internal operand or new instruction
1814 if( newrule < _LAST_MACH_OPER ) { // internal operand or instruction?
1815 // internal operand --> call ReduceInst_Interior
1816 // Interior of complex instruction. Do nothing but recurse.
1817 num_opnds = ReduceInst_Interior( newstate, newrule, mem, mach, num_opnds );
1818 } else {
1819 // instruction --> call build operand( ) to catch result
1820 // --> ReduceInst( newrule )
1821 mach->_opnds[num_opnds++] = s->MachOperGenerator( _reduceOp[catch_op] );
1822 Node *mem1 = (Node*)1;
1823 debug_only(Node *save_mem_node = _mem_node;)
1824 mach->add_req( ReduceInst( newstate, newrule, mem1 ) );
1825 debug_only(_mem_node = save_mem_node;)
1826 }
1827 }
1828 assert( mach->_opnds[num_opnds-1], "" );
1829 }
1830 return num_opnds;
1831 }
1832
1833 // This routine walks the interior of possible complex operands.
1834 // At each point we check our children in the match tree:
1835 // (1) No children -
1836 // We are a leaf; add _leaf field as an input to the MachNode
1837 // (2) Child is an internal operand -
1838 // Skip over it ( do nothing )
1839 // (3) Child is an instruction -
1840 // Call ReduceInst recursively and
1841 // and instruction as an input to the MachNode
|