1519 // Declare Node::methods that set operand Label's contents
1520 int label_position = instr->label_position();
1521 if( label_position != -1 ) {
1522 // Set the label, stored in labelOper::_branch_label
1523 fprintf(fp," virtual void label_set( Label* label, uint block_num );\n");
1524 }
1525
1526 // If this instruction contains a methodOper
1527 // Declare Node::methods that set operand method's contents
1528 int method_position = instr->method_position();
1529 if( method_position != -1 ) {
1530 // Set the address method, stored in methodOper::_method
1531 fprintf(fp," virtual void method_set( intptr_t method );\n");
1532 }
1533
1534 // virtual functions for attributes
1535 //
1536 // Each instruction attribute results in a virtual call of same name.
1537 // The ins_cost is not handled here.
1538 Attribute *attr = instr->_attribs;
1539 bool is_pc_relative = false;
1540 while (attr != NULL) {
1541 if (strcmp(attr->_ident,"ins_cost") &&
1542 strcmp(attr->_ident,"ins_pc_relative")) {
1543 fprintf(fp," int %s() const { return %s; }\n",
1544 attr->_ident, attr->_val);
1545 }
1546 // Check value for ins_pc_relative, and if it is true (1), set the flag
1547 if (!strcmp(attr->_ident,"ins_pc_relative") && attr->int_val(*this) != 0)
1548 is_pc_relative = true;
1549 attr = (Attribute *)attr->_next;
1550 }
1551
1552 // virtual functions for encode and format
1553
1554 // Virtual function for evaluating the constant.
1555 if (instr->is_mach_constant()) {
1556 fprintf(fp," virtual void eval_constant(Compile* C);\n");
1557 }
1558
1559 // Output the opcode function and the encode function here using the
1560 // encoding class information in the _insencode slot.
1561 if ( instr->_insencode ) {
1562 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
1563 }
1564
1565 // virtual function for getting the size of an instruction
1566 if ( instr->_size ) {
1567 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n");
1568 }
1640 fprintf(fp," virtual uint oper_input_base() const { return %d; }\n",
1641 instr->oper_input_base(_globalNames));
1642 }
1643
1644 // Make the constructor and following methods 'public:'
1645 fprintf(fp,"public:\n");
1646
1647 // Constructor
1648 if ( instr->is_ideal_jump() ) {
1649 fprintf(fp," %sNode() : _index2label(MinJumpTableSize*2) { ", instr->_ident);
1650 } else {
1651 fprintf(fp," %sNode() { ", instr->_ident);
1652 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
1653 fprintf(fp,"_cisc_RegMask = NULL; ");
1654 }
1655 }
1656
1657 fprintf(fp," _num_opnds = %d; _opnds = _opnd_array; ", instr->num_opnds());
1658
1659 bool node_flags_set = false;
1660 // flag: if this instruction matches an ideal 'Goto' node
1661 if ( instr->is_ideal_goto() ) {
1662 fprintf(fp,"init_flags(Flag_is_Goto");
1663 node_flags_set = true;
1664 }
1665
1666 // flag: if this instruction matches an ideal 'Copy*' node
1667 if ( instr->is_ideal_copy() != 0 ) {
1668 if ( node_flags_set ) {
1669 fprintf(fp," | Flag_is_Copy");
1670 } else {
1671 fprintf(fp,"init_flags(Flag_is_Copy");
1672 node_flags_set = true;
1673 }
1674 }
1675
1676 // Is an instruction is a constant? If so, get its type
1677 Form::DataType data_type;
1678 const char *opType = NULL;
1679 const char *result = NULL;
1680 data_type = instr->is_chain_of_constant(_globalNames, opType, result);
1681 // Check if this instruction is a constant
1682 if ( data_type != Form::none ) {
1683 if ( node_flags_set ) {
1684 fprintf(fp," | Flag_is_Con");
1685 } else {
1686 fprintf(fp,"init_flags(Flag_is_Con");
1687 node_flags_set = true;
1688 }
1689 }
1690
1691 // flag: if instruction matches 'If' | 'Goto' | 'CountedLoopEnd | 'Jump'
1692 if ( instr->is_ideal_branch() ) {
1693 if ( node_flags_set ) {
1694 fprintf(fp," | Flag_is_Branch");
1695 } else {
1696 fprintf(fp,"init_flags(Flag_is_Branch");
1697 node_flags_set = true;
1698 }
1699 }
1700
1701 // flag: if this instruction is cisc alternate
1702 if ( can_cisc_spill() && instr->is_cisc_alternate() ) {
1703 if ( node_flags_set ) {
1704 fprintf(fp," | Flag_is_cisc_alternate");
1705 } else {
1706 fprintf(fp,"init_flags(Flag_is_cisc_alternate");
1707 node_flags_set = true;
1708 }
1709 }
1710
1711 // flag: if this instruction is pc relative
1712 if ( is_pc_relative ) {
1713 if ( node_flags_set ) {
1714 fprintf(fp," | Flag_is_pc_relative");
1715 } else {
1716 fprintf(fp,"init_flags(Flag_is_pc_relative");
1717 node_flags_set = true;
1718 }
1719 }
1720
1721 // flag: if this instruction has short branch form
1722 if ( instr->has_short_branch_form() ) {
1723 if ( node_flags_set ) {
1724 fprintf(fp," | Flag_may_be_short_branch");
1725 } else {
1726 fprintf(fp,"init_flags(Flag_may_be_short_branch");
1727 node_flags_set = true;
1728 }
1729 }
1730
1731 // Check if machine instructions that USE memory, but do not DEF memory,
1732 // depend upon a node that defines memory in machine-independent graph.
1733 if ( instr->needs_anti_dependence_check(_globalNames) ) {
1734 if ( node_flags_set ) {
1735 fprintf(fp," | Flag_needs_anti_dependence_check");
1736 } else {
1737 fprintf(fp,"init_flags(Flag_needs_anti_dependence_check");
1738 node_flags_set = true;
1739 }
1740 }
1741
1742 if ( node_flags_set ) {
1743 fprintf(fp,"); ");
1744 }
1745
1746 if (instr->is_ideal_unlock() || instr->is_ideal_call_leaf()) {
1747 fprintf(fp,"clear_flag(Flag_is_safepoint_node); ");
1748 }
1749
1750 fprintf(fp,"}\n");
1751
1752 // size_of, used by base class's clone to obtain the correct size.
1753 fprintf(fp," virtual uint size_of() const {");
1754 fprintf(fp, " return sizeof(%sNode);", instr->_ident);
1755 fprintf(fp, " }\n");
1756
1757 // Virtual methods which are only generated to override base class
1758 if( instr->expands() || instr->needs_projections() ||
1759 instr->has_temps() ||
1760 instr->is_mach_constant() ||
1761 instr->_matrule != NULL &&
1762 instr->num_opnds() != instr->num_unique_opnds() ) {
1763 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n");
1764 }
1765
1766 if (instr->is_pinned(_globalNames)) {
1767 fprintf(fp," virtual bool pinned() const { return ");
1768 if (instr->is_parm(_globalNames)) {
1769 fprintf(fp,"_in[0]->pinned();");
|
1519 // Declare Node::methods that set operand Label's contents
1520 int label_position = instr->label_position();
1521 if( label_position != -1 ) {
1522 // Set the label, stored in labelOper::_branch_label
1523 fprintf(fp," virtual void label_set( Label* label, uint block_num );\n");
1524 }
1525
1526 // If this instruction contains a methodOper
1527 // Declare Node::methods that set operand method's contents
1528 int method_position = instr->method_position();
1529 if( method_position != -1 ) {
1530 // Set the address method, stored in methodOper::_method
1531 fprintf(fp," virtual void method_set( intptr_t method );\n");
1532 }
1533
1534 // virtual functions for attributes
1535 //
1536 // Each instruction attribute results in a virtual call of same name.
1537 // The ins_cost is not handled here.
1538 Attribute *attr = instr->_attribs;
1539 while (attr != NULL) {
1540 if (strcmp(attr->_ident,"ins_cost") &&
1541 strcmp(attr->_ident,"ins_short_branch")) {
1542 fprintf(fp," int %s() const { return %s; }\n",
1543 attr->_ident, attr->_val);
1544 }
1545 attr = (Attribute *)attr->_next;
1546 }
1547
1548 // virtual functions for encode and format
1549
1550 // Virtual function for evaluating the constant.
1551 if (instr->is_mach_constant()) {
1552 fprintf(fp," virtual void eval_constant(Compile* C);\n");
1553 }
1554
1555 // Output the opcode function and the encode function here using the
1556 // encoding class information in the _insencode slot.
1557 if ( instr->_insencode ) {
1558 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
1559 }
1560
1561 // virtual function for getting the size of an instruction
1562 if ( instr->_size ) {
1563 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n");
1564 }
1636 fprintf(fp," virtual uint oper_input_base() const { return %d; }\n",
1637 instr->oper_input_base(_globalNames));
1638 }
1639
1640 // Make the constructor and following methods 'public:'
1641 fprintf(fp,"public:\n");
1642
1643 // Constructor
1644 if ( instr->is_ideal_jump() ) {
1645 fprintf(fp," %sNode() : _index2label(MinJumpTableSize*2) { ", instr->_ident);
1646 } else {
1647 fprintf(fp," %sNode() { ", instr->_ident);
1648 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
1649 fprintf(fp,"_cisc_RegMask = NULL; ");
1650 }
1651 }
1652
1653 fprintf(fp," _num_opnds = %d; _opnds = _opnd_array; ", instr->num_opnds());
1654
1655 bool node_flags_set = false;
1656 // flag: if this instruction matches an ideal 'Copy*' node
1657 if ( instr->is_ideal_copy() != 0 ) {
1658 fprintf(fp,"init_flags(Flag_is_Copy");
1659 node_flags_set = true;
1660 }
1661
1662 // Is an instruction is a constant? If so, get its type
1663 Form::DataType data_type;
1664 const char *opType = NULL;
1665 const char *result = NULL;
1666 data_type = instr->is_chain_of_constant(_globalNames, opType, result);
1667 // Check if this instruction is a constant
1668 if ( data_type != Form::none ) {
1669 if ( node_flags_set ) {
1670 fprintf(fp," | Flag_is_Con");
1671 } else {
1672 fprintf(fp,"init_flags(Flag_is_Con");
1673 node_flags_set = true;
1674 }
1675 }
1676
1677 // flag: if instruction matches 'If' | 'Goto' | 'CountedLoopEnd | 'Jump'
1678 if ( instr->is_ideal_branch() ) {
1679 if ( node_flags_set ) {
1680 fprintf(fp," | Flag_is_Branch");
1681 } else {
1682 fprintf(fp,"init_flags(Flag_is_Branch");
1683 node_flags_set = true;
1684 }
1685 }
1686
1687 // flag: if this instruction is cisc alternate
1688 if ( can_cisc_spill() && instr->is_cisc_alternate() ) {
1689 if ( node_flags_set ) {
1690 fprintf(fp," | Flag_is_cisc_alternate");
1691 } else {
1692 fprintf(fp,"init_flags(Flag_is_cisc_alternate");
1693 node_flags_set = true;
1694 }
1695 }
1696
1697 // flag: if this instruction has short branch form
1698 if ( instr->has_short_branch_form() ) {
1699 if ( node_flags_set ) {
1700 fprintf(fp," | Flag_may_be_short_branch");
1701 } else {
1702 fprintf(fp,"init_flags(Flag_may_be_short_branch");
1703 node_flags_set = true;
1704 }
1705 }
1706
1707 // Check if machine instructions that USE memory, but do not DEF memory,
1708 // depend upon a node that defines memory in machine-independent graph.
1709 if ( instr->needs_anti_dependence_check(_globalNames) ) {
1710 if ( node_flags_set ) {
1711 fprintf(fp," | Flag_needs_anti_dependence_check");
1712 } else {
1713 fprintf(fp,"init_flags(Flag_needs_anti_dependence_check");
1714 node_flags_set = true;
1715 }
1716 }
1717
1718 if ( node_flags_set ) {
1719 fprintf(fp,"); ");
1720 }
1721
1722 fprintf(fp,"}\n");
1723
1724 // size_of, used by base class's clone to obtain the correct size.
1725 fprintf(fp," virtual uint size_of() const {");
1726 fprintf(fp, " return sizeof(%sNode);", instr->_ident);
1727 fprintf(fp, " }\n");
1728
1729 // Virtual methods which are only generated to override base class
1730 if( instr->expands() || instr->needs_projections() ||
1731 instr->has_temps() ||
1732 instr->is_mach_constant() ||
1733 instr->_matrule != NULL &&
1734 instr->num_opnds() != instr->num_unique_opnds() ) {
1735 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n");
1736 }
1737
1738 if (instr->is_pinned(_globalNames)) {
1739 fprintf(fp," virtual bool pinned() const { return ");
1740 if (instr->is_parm(_globalNames)) {
1741 fprintf(fp,"_in[0]->pinned();");
|