Mercurial > hg > truffle
comparison src/share/vm/adlc/output_h.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 89152779163c 78bbf4d43a14 |
children |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1998, 2014, 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. |
24 | 24 |
25 // output_h.cpp - Class HPP file output routines for architecture definition | 25 // output_h.cpp - Class HPP file output routines for architecture definition |
26 #include "adlc.hpp" | 26 #include "adlc.hpp" |
27 | 27 |
28 // The comment delimiter used in format statements after assembler instructions. | 28 // The comment delimiter used in format statements after assembler instructions. |
29 #if defined(PPC64) | |
30 #define commentSeperator "\t//" | |
31 #else | |
29 #define commentSeperator "!" | 32 #define commentSeperator "!" |
33 #endif | |
30 | 34 |
31 // Generate the #define that describes the number of registers. | 35 // Generate the #define that describes the number of registers. |
32 static void defineRegCount(FILE *fp, RegisterForm *registers) { | 36 static void defineRegCount(FILE *fp, RegisterForm *registers) { |
33 if (registers) { | 37 if (registers) { |
34 int regCount = AdlcVMDeps::Physical + registers->_rdefs.count(); | 38 int regCount = AdlcVMDeps::Physical + registers->_rdefs.count(); |
380 | 384 |
381 // Generate the format rule for condition codes | 385 // Generate the format rule for condition codes |
382 static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) { | 386 static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) { |
383 assert(oper != NULL, "what"); | 387 assert(oper != NULL, "what"); |
384 CondInterface* cond = oper->_interface->is_CondInterface(); | 388 CondInterface* cond = oper->_interface->is_CondInterface(); |
385 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format); | 389 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print_raw(\"%s\");\n",i,cond->_equal_format); |
386 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format); | 390 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print_raw(\"%s\");\n",i,cond->_not_equal_format); |
387 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format); | 391 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print_raw(\"%s\");\n",i,cond->_less_equal_format); |
388 fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format); | 392 fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print_raw(\"%s\");\n",i,cond->_greater_equal_format); |
389 fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format); | 393 fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print_raw(\"%s\");\n",i,cond->_less_format); |
390 fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format); | 394 fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print_raw(\"%s\");\n",i,cond->_greater_format); |
391 fprintf(fp, " else if( _c%d == BoolTest::overflow ) st->print(\"%s\");\n",i,cond->_overflow_format); | 395 fprintf(fp, " else if( _c%d == BoolTest::overflow ) st->print_raw(\"%s\");\n",i,cond->_overflow_format); |
392 fprintf(fp, " else if( _c%d == BoolTest::no_overflow ) st->print(\"%s\");\n",i,cond->_no_overflow_format); | 396 fprintf(fp, " else if( _c%d == BoolTest::no_overflow ) st->print_raw(\"%s\");\n",i,cond->_no_overflow_format); |
393 } | 397 } |
394 | 398 |
395 // Output code that dumps constant values, increment "i" if type is constant | 399 // Output code that dumps constant values, increment "i" if type is constant |
396 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) { | 400 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) { |
397 if (!strcmp(ideal_type, "ConI")) { | 401 if (!strcmp(ideal_type, "ConI")) { |
410 else if (!strcmp(ideal_type, "ConNKlass")) { | 414 else if (!strcmp(ideal_type, "ConNKlass")) { |
411 fprintf(fp," _c%d->dump_on(st);\n", i); | 415 fprintf(fp," _c%d->dump_on(st);\n", i); |
412 ++i; | 416 ++i; |
413 } | 417 } |
414 else if (!strcmp(ideal_type, "ConL")) { | 418 else if (!strcmp(ideal_type, "ConL")) { |
415 fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i); | 419 fprintf(fp," st->print(\"#\" INT64_FORMAT, (int64_t)_c%d);\n", i); |
416 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%d);\n", i); | 420 fprintf(fp," st->print(\"/\" PTR64_FORMAT, (uint64_t)_c%d);\n", i); |
417 ++i; | 421 ++i; |
418 } | 422 } |
419 else if (!strcmp(ideal_type, "ConF")) { | 423 else if (!strcmp(ideal_type, "ConF")) { |
420 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); | 424 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); |
421 fprintf(fp," jint _c%di = JavaValue(_c%d).get_jint();\n", i, i); | 425 fprintf(fp," jint _c%di = JavaValue(_c%d).get_jint();\n", i, i); |
423 ++i; | 427 ++i; |
424 } | 428 } |
425 else if (!strcmp(ideal_type, "ConD")) { | 429 else if (!strcmp(ideal_type, "ConD")) { |
426 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); | 430 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); |
427 fprintf(fp," jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i); | 431 fprintf(fp," jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i); |
428 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%dl);\n", i); | 432 fprintf(fp," st->print(\"/\" PTR64_FORMAT, (uint64_t)_c%dl);\n", i); |
429 ++i; | 433 ++i; |
430 } | 434 } |
431 else if (!strcmp(ideal_type, "Bool")) { | 435 else if (!strcmp(ideal_type, "Bool")) { |
432 defineCCodeDump(oper, fp,i); | 436 defineCCodeDump(oper, fp,i); |
433 ++i; | 437 ++i; |
465 | 469 |
466 // Check if this is a standard string or a replacement variable | 470 // Check if this is a standard string or a replacement variable |
467 if ( string != NameList::_signal ) { | 471 if ( string != NameList::_signal ) { |
468 // Normal string | 472 // Normal string |
469 // Pass through to st->print | 473 // Pass through to st->print |
470 fprintf(fp," st->print(\"%s\");\n", string); | 474 fprintf(fp," st->print_raw(\"%s\");\n", string); |
471 } else { | 475 } else { |
472 // Replacement variable | 476 // Replacement variable |
473 const char *rep_var = oper._format->_rep_vars.iter(); | 477 const char *rep_var = oper._format->_rep_vars.iter(); |
474 // Check that it is a local name, and an operand | 478 // Check that it is a local name, and an operand |
475 const Form* form = oper._localNames[rep_var]; | 479 const Form* form = oper._localNames[rep_var]; |
536 | 540 |
537 // Check if this is a standard string or a replacement variable | 541 // Check if this is a standard string or a replacement variable |
538 if ( string != NameList::_signal ) { | 542 if ( string != NameList::_signal ) { |
539 // Normal string | 543 // Normal string |
540 // Pass through to st->print | 544 // Pass through to st->print |
541 fprintf(fp," st->print(\"%s\");\n", string); | 545 fprintf(fp," st->print_raw(\"%s\");\n", string); |
542 } else { | 546 } else { |
543 // Replacement variable | 547 // Replacement variable |
544 const char *rep_var = oper._format->_rep_vars.iter(); | 548 const char *rep_var = oper._format->_rep_vars.iter(); |
545 // Check that it is a local name, and an operand | 549 // Check that it is a local name, and an operand |
546 const Form* form = oper._localNames[rep_var]; | 550 const Form* form = oper._localNames[rep_var]; |
663 assert( false, "ShouldNotReachHere()"); | 667 assert( false, "ShouldNotReachHere()"); |
664 } | 668 } |
665 } else if( string == NameList::_signal2 ) // Raw program text | 669 } else if( string == NameList::_signal2 ) // Raw program text |
666 fputs(inst._format->_strings.iter(), fp); | 670 fputs(inst._format->_strings.iter(), fp); |
667 else | 671 else |
668 fprintf(fp,"st->print(\"%s\");\n", string); | 672 fprintf(fp,"st->print_raw(\"%s\");\n", string); |
669 } // Done with all format strings | 673 } // Done with all format strings |
670 } // Done generating the user-defined portion of the format | 674 } // Done generating the user-defined portion of the format |
671 | 675 |
672 // Add call debug info automatically | 676 // Add call debug info automatically |
673 Form::CallType call_type = inst.is_ideal_call(); | 677 Form::CallType call_type = inst.is_ideal_call(); |
690 fprintf(fp," st->print(\" %%s\", _name);"); | 694 fprintf(fp," st->print(\" %%s\", _name);"); |
691 break; | 695 break; |
692 default: | 696 default: |
693 assert(0,"ShouldNotReachHere"); | 697 assert(0,"ShouldNotReachHere"); |
694 } | 698 } |
695 fprintf(fp, " st->print_cr(\"\");\n" ); | 699 fprintf(fp, " st->cr();\n" ); |
696 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); | 700 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); |
697 fprintf(fp, " st->print(\" # \");\n" ); | 701 fprintf(fp, " st->print(\" # \");\n" ); |
698 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); | 702 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); |
699 } | 703 } |
700 else if(inst.is_ideal_safepoint()) { | 704 else if(inst.is_ideal_safepoint()) { |
701 fprintf(fp, " st->print(\"\");\n" ); | 705 fprintf(fp, " st->print_raw(\"\");\n" ); |
702 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); | 706 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); |
703 fprintf(fp, " st->print(\" # \");\n" ); | 707 fprintf(fp, " st->print(\" # \");\n" ); |
704 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); | 708 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); |
705 } | 709 } |
706 else if( inst.is_ideal_if() ) { | 710 else if( inst.is_ideal_if() ) { |
1549 fprintf(fp,"private:\n"); | 1553 fprintf(fp,"private:\n"); |
1550 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() ); | 1554 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() ); |
1551 if ( instr->is_ideal_jump() ) { | 1555 if ( instr->is_ideal_jump() ) { |
1552 fprintf(fp, " GrowableArray<Label*> _index2label;\n"); | 1556 fprintf(fp, " GrowableArray<Label*> _index2label;\n"); |
1553 } | 1557 } |
1554 fprintf(fp,"public:\n"); | 1558 |
1559 fprintf(fp, "public:\n"); | |
1560 | |
1561 Attribute *att = instr->_attribs; | |
1562 // Fields of the node specified in the ad file. | |
1563 while (att != NULL) { | |
1564 if (strncmp(att->_ident, "ins_field_", 10) == 0) { | |
1565 const char *field_name = att->_ident+10; | |
1566 const char *field_type = att->_val; | |
1567 fprintf(fp, " %s _%s;\n", field_type, field_name); | |
1568 } | |
1569 att = (Attribute *)att->_next; | |
1570 } | |
1571 | |
1555 fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n"); | 1572 fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n"); |
1556 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n"); | 1573 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n"); |
1557 fprintf(fp," return _opnd_array[operand_index];\n"); | 1574 fprintf(fp," return _opnd_array[operand_index];\n"); |
1558 fprintf(fp," }\n"); | 1575 fprintf(fp," }\n"); |
1559 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n"); | 1576 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n"); |
1594 // virtual functions for attributes | 1611 // virtual functions for attributes |
1595 // | 1612 // |
1596 // Each instruction attribute results in a virtual call of same name. | 1613 // Each instruction attribute results in a virtual call of same name. |
1597 // The ins_cost is not handled here. | 1614 // The ins_cost is not handled here. |
1598 Attribute *attr = instr->_attribs; | 1615 Attribute *attr = instr->_attribs; |
1599 bool avoid_back_to_back = false; | 1616 Attribute *avoid_back_to_back_attr = NULL; |
1600 while (attr != NULL) { | 1617 while (attr != NULL) { |
1601 if (strcmp(attr->_ident,"ins_cost") && | 1618 if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0) { |
1602 strcmp(attr->_ident,"ins_short_branch")) { | 1619 fprintf(fp, " virtual bool is_TrapBasedCheckNode() const { return %s; }\n", attr->_val); |
1603 fprintf(fp," int %s() const { return %s; }\n", | 1620 } else if (strcmp (attr->_ident, "ins_cost") != 0 && |
1604 attr->_ident, attr->_val); | 1621 strncmp(attr->_ident, "ins_field_", 10) != 0 && |
1605 } | 1622 // Must match function in node.hpp: return type bool, no prefix "ins_". |
1606 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag | 1623 strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") != 0 && |
1607 if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0) | 1624 strcmp (attr->_ident, "ins_short_branch") != 0) { |
1608 avoid_back_to_back = true; | 1625 fprintf(fp, " virtual int %s() const { return %s; }\n", attr->_ident, attr->_val); |
1626 } | |
1627 if (strcmp(attr->_ident, "ins_avoid_back_to_back") == 0) { | |
1628 avoid_back_to_back_attr = attr; | |
1629 } | |
1609 attr = (Attribute *)attr->_next; | 1630 attr = (Attribute *)attr->_next; |
1610 } | 1631 } |
1611 | 1632 |
1612 // virtual functions for encode and format | 1633 // virtual functions for encode and format |
1613 | 1634 |
1617 } | 1638 } |
1618 | 1639 |
1619 // Output the opcode function and the encode function here using the | 1640 // Output the opcode function and the encode function here using the |
1620 // encoding class information in the _insencode slot. | 1641 // encoding class information in the _insencode slot. |
1621 if ( instr->_insencode ) { | 1642 if ( instr->_insencode ) { |
1622 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n"); | 1643 if (instr->postalloc_expands()) { |
1644 fprintf(fp," virtual bool requires_postalloc_expand() const { return true; }\n"); | |
1645 fprintf(fp," virtual void postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);\n"); | |
1646 } else { | |
1647 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n"); | |
1648 } | |
1623 } | 1649 } |
1624 | 1650 |
1625 // virtual function for getting the size of an instruction | 1651 // virtual function for getting the size of an instruction |
1626 if ( instr->_size ) { | 1652 if ( instr->_size ) { |
1627 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n"); | 1653 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n"); |
1632 // if the ideal_Opcode == Op_Node. | 1658 // if the ideal_Opcode == Op_Node. |
1633 if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 || | 1659 if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 || |
1634 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { | 1660 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { |
1635 fprintf(fp," virtual int ideal_Opcode() const { return Op_%s; }\n", | 1661 fprintf(fp," virtual int ideal_Opcode() const { return Op_%s; }\n", |
1636 instr->ideal_Opcode(_globalNames) ); | 1662 instr->ideal_Opcode(_globalNames) ); |
1663 } | |
1664 | |
1665 if (instr->needs_constant_base() && | |
1666 !instr->is_mach_constant()) { // These inherit the funcion from MachConstantNode. | |
1667 fprintf(fp," virtual uint mach_constant_base_node_input() const { "); | |
1668 if (instr->is_ideal_call() != Form::invalid_type && | |
1669 instr->is_ideal_call() != Form::JAVA_LEAF) { | |
1670 // MachConstantBase goes behind arguments, but before jvms. | |
1671 fprintf(fp,"assert(tf() && tf()->domain(), \"\"); return tf()->domain()->cnt();"); | |
1672 } else { | |
1673 fprintf(fp,"return req()-1;"); | |
1674 } | |
1675 fprintf(fp," }\n"); | |
1637 } | 1676 } |
1638 | 1677 |
1639 // Allow machine-independent optimization, invert the sense of the IF test | 1678 // Allow machine-independent optimization, invert the sense of the IF test |
1640 if( instr->is_ideal_if() ) { | 1679 if( instr->is_ideal_if() ) { |
1641 fprintf(fp," virtual void negate() { \n"); | 1680 fprintf(fp," virtual void negate() { \n"); |
1757 node_flags_set = true; | 1796 node_flags_set = true; |
1758 } | 1797 } |
1759 } | 1798 } |
1760 | 1799 |
1761 // flag: if this instruction should not be generated back to back. | 1800 // flag: if this instruction should not be generated back to back. |
1762 if ( avoid_back_to_back ) { | 1801 if (avoid_back_to_back_attr != NULL) { |
1763 if ( node_flags_set ) { | 1802 if (node_flags_set) { |
1764 fprintf(fp," | Flag_avoid_back_to_back"); | 1803 fprintf(fp," | (%s)", avoid_back_to_back_attr->_val); |
1765 } else { | 1804 } else { |
1766 fprintf(fp,"init_flags(Flag_avoid_back_to_back"); | 1805 fprintf(fp,"init_flags((%s)", avoid_back_to_back_attr->_val); |
1767 node_flags_set = true; | 1806 node_flags_set = true; |
1768 } | 1807 } |
1769 } | 1808 } |
1770 | 1809 |
1771 // Check if machine instructions that USE memory, but do not DEF memory, | 1810 // Check if machine instructions that USE memory, but do not DEF memory, |
1802 | 1841 |
1803 // Virtual methods which are only generated to override base class | 1842 // Virtual methods which are only generated to override base class |
1804 if( instr->expands() || instr->needs_projections() || | 1843 if( instr->expands() || instr->needs_projections() || |
1805 instr->has_temps() || | 1844 instr->has_temps() || |
1806 instr->is_mach_constant() || | 1845 instr->is_mach_constant() || |
1846 instr->needs_constant_base() || | |
1807 instr->_matrule != NULL && | 1847 instr->_matrule != NULL && |
1808 instr->num_opnds() != instr->num_unique_opnds() ) { | 1848 instr->num_opnds() != instr->num_unique_opnds() ) { |
1809 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n"); | 1849 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n"); |
1810 } | 1850 } |
1811 | 1851 |