1 /* |
1 /* |
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
1511 char buf[buflen], *s=buf; |
1511 char buf[buflen], *s=buf; |
1512 Dict names(cmpstr,hashstr,Form::arena); // Map Names to counts |
1512 Dict names(cmpstr,hashstr,Form::arena); // Map Names to counts |
1513 |
1513 |
1514 MatchNode *mnode = |
1514 MatchNode *mnode = |
1515 strcmp(_matrule->_opType, "Set") ? _matrule : _matrule->_rChild; |
1515 strcmp(_matrule->_opType, "Set") ? _matrule : _matrule->_rChild; |
1516 mnode->count_instr_names(names); |
1516 if (mnode != NULL) mnode->count_instr_names(names); |
1517 |
1517 |
1518 uint first = 1; |
1518 uint first = 1; |
1519 // Start with the predicate supplied in the .ad file. |
1519 // Start with the predicate supplied in the .ad file. |
1520 if (_predicate) { |
1520 if (_predicate) { |
1521 if (first) first = 0; |
1521 if (first) first = 0; |
1724 bool Opcode::print_opcode(FILE *fp, Opcode::opcode_type desired_opcode) { |
1724 bool Opcode::print_opcode(FILE *fp, Opcode::opcode_type desired_opcode) { |
1725 // Default values previously provided by MachNode::primary()... |
1725 // Default values previously provided by MachNode::primary()... |
1726 const char *description = NULL; |
1726 const char *description = NULL; |
1727 const char *value = NULL; |
1727 const char *value = NULL; |
1728 // Check if user provided any opcode definitions |
1728 // Check if user provided any opcode definitions |
1729 if( this != NULL ) { |
1729 // Update 'value' if user provided a definition in the instruction |
1730 // Update 'value' if user provided a definition in the instruction |
1730 switch (desired_opcode) { |
1731 switch (desired_opcode) { |
1731 case PRIMARY: |
1732 case PRIMARY: |
1732 description = "primary()"; |
1733 description = "primary()"; |
1733 if( _primary != NULL) { value = _primary; } |
1734 if( _primary != NULL) { value = _primary; } |
1734 break; |
1735 break; |
1735 case SECONDARY: |
1736 case SECONDARY: |
1736 description = "secondary()"; |
1737 description = "secondary()"; |
1737 if( _secondary != NULL ) { value = _secondary; } |
1738 if( _secondary != NULL ) { value = _secondary; } |
1738 break; |
1739 break; |
1739 case TERTIARY: |
1740 case TERTIARY: |
1740 description = "tertiary()"; |
1741 description = "tertiary()"; |
1741 if( _tertiary != NULL ) { value = _tertiary; } |
1742 if( _tertiary != NULL ) { value = _tertiary; } |
1742 break; |
1743 break; |
1743 default: |
1744 default: |
1744 assert( false, "ShouldNotReachHere();"); |
1745 assert( false, "ShouldNotReachHere();"); |
1745 break; |
1746 break; |
1746 } |
1747 } |
1747 |
1748 } |
|
1749 if (value != NULL) { |
1748 if (value != NULL) { |
1750 fprintf(fp, "(%s /*%s*/)", value, description); |
1749 fprintf(fp, "(%s /*%s*/)", value, description); |
1751 } |
1750 } |
1752 return value != NULL; |
1751 return value != NULL; |
1753 } |
1752 } |
3411 |
3410 |
3412 //------------------------------count_instr_names------------------------------ |
3411 //------------------------------count_instr_names------------------------------ |
3413 // Count occurrences of operands names in the leaves of the instruction |
3412 // Count occurrences of operands names in the leaves of the instruction |
3414 // match rule. |
3413 // match rule. |
3415 void MatchNode::count_instr_names( Dict &names ) { |
3414 void MatchNode::count_instr_names( Dict &names ) { |
3416 if( this == NULL ) return; |
|
3417 if( _lChild ) _lChild->count_instr_names(names); |
3415 if( _lChild ) _lChild->count_instr_names(names); |
3418 if( _rChild ) _rChild->count_instr_names(names); |
3416 if( _rChild ) _rChild->count_instr_names(names); |
3419 if( !_lChild && !_rChild ) { |
3417 if( !_lChild && !_rChild ) { |
3420 uintptr_t cnt = (uintptr_t)names[_name]; |
3418 uintptr_t cnt = (uintptr_t)names[_name]; |
3421 cnt++; // One more name found |
3419 cnt++; // One more name found |