1522 declare_pipe_classes(fp);
1523
1524 // Generate Machine Classes for each instruction defined in AD file
1525 fprintf(fp,"\n");
1526 fprintf(fp,"//----------------------------Declare classes derived from MachNode----------\n");
1527 _instructions.reset();
1528 InstructForm *instr;
1529 for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) {
1530 // Ensure this is a machine-world instruction
1531 if ( instr->ideal_only() ) continue;
1532
1533 // Build class definition for this instruction
1534 fprintf(fp,"\n");
1535 fprintf(fp,"class %sNode : public %s { \n",
1536 instr->_ident, instr->mach_base_class(_globalNames) );
1537 fprintf(fp,"private:\n");
1538 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() );
1539 if ( instr->is_ideal_jump() ) {
1540 fprintf(fp, " GrowableArray<Label*> _index2label;\n");
1541 }
1542 fprintf(fp,"public:\n");
1543 fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n");
1544 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
1545 fprintf(fp," return _opnd_array[operand_index];\n");
1546 fprintf(fp," }\n");
1547 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n");
1548 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
1549 fprintf(fp," _opnd_array[operand_index] = operand;\n");
1550 fprintf(fp," }\n");
1551 fprintf(fp,"private:\n");
1552 if ( instr->is_ideal_jump() ) {
1553 fprintf(fp," virtual void add_case_label(int index_num, Label* blockLabel) {\n");
1554 fprintf(fp," _index2label.at_put_grow(index_num, blockLabel);\n");
1555 fprintf(fp," }\n");
1556 }
1557 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
1558 fprintf(fp," const RegMask *_cisc_RegMask;\n");
1559 }
1560
1561 out_RegMask(fp); // output register mask
1562 fprintf(fp," virtual uint rule() const { return %s_rule; }\n",
1569 // Set/Save the label, stored in labelOper::_branch_label
1570 fprintf(fp," virtual void label_set( Label* label, uint block_num );\n");
1571 fprintf(fp," virtual void save_label( Label** label, uint* block_num );\n");
1572 }
1573
1574 // If this instruction contains a methodOper
1575 // Declare Node::methods that set operand method's contents
1576 int method_position = instr->method_position();
1577 if( method_position != -1 ) {
1578 // Set the address method, stored in methodOper::_method
1579 fprintf(fp," virtual void method_set( intptr_t method );\n");
1580 }
1581
1582 // virtual functions for attributes
1583 //
1584 // Each instruction attribute results in a virtual call of same name.
1585 // The ins_cost is not handled here.
1586 Attribute *attr = instr->_attribs;
1587 bool avoid_back_to_back = false;
1588 while (attr != NULL) {
1589 if (strcmp(attr->_ident,"ins_cost") &&
1590 strcmp(attr->_ident,"ins_short_branch")) {
1591 fprintf(fp," int %s() const { return %s; }\n",
1592 attr->_ident, attr->_val);
1593 }
1594 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag
1595 if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0)
1596 avoid_back_to_back = true;
1597 attr = (Attribute *)attr->_next;
1598 }
1599
1600 // virtual functions for encode and format
1601
1602 // Virtual function for evaluating the constant.
1603 if (instr->is_mach_constant()) {
1604 fprintf(fp," virtual void eval_constant(Compile* C);\n");
1605 }
1606
1607 // Output the opcode function and the encode function here using the
1608 // encoding class information in the _insencode slot.
1609 if ( instr->_insencode ) {
1610 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
|
1522 declare_pipe_classes(fp);
1523
1524 // Generate Machine Classes for each instruction defined in AD file
1525 fprintf(fp,"\n");
1526 fprintf(fp,"//----------------------------Declare classes derived from MachNode----------\n");
1527 _instructions.reset();
1528 InstructForm *instr;
1529 for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) {
1530 // Ensure this is a machine-world instruction
1531 if ( instr->ideal_only() ) continue;
1532
1533 // Build class definition for this instruction
1534 fprintf(fp,"\n");
1535 fprintf(fp,"class %sNode : public %s { \n",
1536 instr->_ident, instr->mach_base_class(_globalNames) );
1537 fprintf(fp,"private:\n");
1538 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() );
1539 if ( instr->is_ideal_jump() ) {
1540 fprintf(fp, " GrowableArray<Label*> _index2label;\n");
1541 }
1542
1543 fprintf(fp, "public:\n");
1544
1545 Attribute *att = instr->_attribs;
1546 // Fields of the node specified in the ad file.
1547 while (att != NULL) {
1548 if (strncmp(att->_ident, "ins_field_", 10) == 0) {
1549 const char *field_name = att->_ident+10;
1550 const char *field_type = att->_val;
1551 fprintf(fp, " %s _%s;\n", field_type, field_name);
1552 }
1553 att = (Attribute *)att->_next;
1554 }
1555
1556 fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n");
1557 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
1558 fprintf(fp," return _opnd_array[operand_index];\n");
1559 fprintf(fp," }\n");
1560 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n");
1561 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
1562 fprintf(fp," _opnd_array[operand_index] = operand;\n");
1563 fprintf(fp," }\n");
1564 fprintf(fp,"private:\n");
1565 if ( instr->is_ideal_jump() ) {
1566 fprintf(fp," virtual void add_case_label(int index_num, Label* blockLabel) {\n");
1567 fprintf(fp," _index2label.at_put_grow(index_num, blockLabel);\n");
1568 fprintf(fp," }\n");
1569 }
1570 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
1571 fprintf(fp," const RegMask *_cisc_RegMask;\n");
1572 }
1573
1574 out_RegMask(fp); // output register mask
1575 fprintf(fp," virtual uint rule() const { return %s_rule; }\n",
1582 // Set/Save the label, stored in labelOper::_branch_label
1583 fprintf(fp," virtual void label_set( Label* label, uint block_num );\n");
1584 fprintf(fp," virtual void save_label( Label** label, uint* block_num );\n");
1585 }
1586
1587 // If this instruction contains a methodOper
1588 // Declare Node::methods that set operand method's contents
1589 int method_position = instr->method_position();
1590 if( method_position != -1 ) {
1591 // Set the address method, stored in methodOper::_method
1592 fprintf(fp," virtual void method_set( intptr_t method );\n");
1593 }
1594
1595 // virtual functions for attributes
1596 //
1597 // Each instruction attribute results in a virtual call of same name.
1598 // The ins_cost is not handled here.
1599 Attribute *attr = instr->_attribs;
1600 bool avoid_back_to_back = false;
1601 while (attr != NULL) {
1602 if (strcmp (attr->_ident,"ins_cost") &&
1603 strncmp(attr->_ident,"ins_field_", 10) != 0 &&
1604 strcmp (attr->_ident,"ins_short_branch")) {
1605 fprintf(fp," int %s() const { return %s; }\n",
1606 attr->_ident, attr->_val);
1607 }
1608 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag
1609 if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0)
1610 avoid_back_to_back = true;
1611 attr = (Attribute *)attr->_next;
1612 }
1613
1614 // virtual functions for encode and format
1615
1616 // Virtual function for evaluating the constant.
1617 if (instr->is_mach_constant()) {
1618 fprintf(fp," virtual void eval_constant(Compile* C);\n");
1619 }
1620
1621 // Output the opcode function and the encode function here using the
1622 // encoding class information in the _insencode slot.
1623 if ( instr->_insencode ) {
1624 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
|