Mercurial > hg > truffle
comparison src/share/vm/adlc/output_h.cpp @ 14521:29ccc4cbabca
Merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 12 Mar 2014 13:30:08 +0100 |
parents | abec000618bf |
children | 4ca6dc0799b6 17b2fbdb6637 |
comparison
equal
deleted
inserted
replaced
14520:f84115370178 | 14521:29ccc4cbabca |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1998, 2013, 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(); |
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"); |
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 bool avoid_back_to_back = false; |
1600 while (attr != NULL) { | 1617 while (attr != NULL) { |
1601 if (strcmp(attr->_ident,"ins_cost") && | 1618 if (strcmp (attr->_ident, "ins_cost") != 0 && |
1602 strcmp(attr->_ident,"ins_short_branch")) { | 1619 strncmp(attr->_ident, "ins_field_", 10) != 0 && |
1603 fprintf(fp," int %s() const { return %s; }\n", | 1620 // Must match function in node.hpp: return type bool, no prefix "ins_". |
1604 attr->_ident, attr->_val); | 1621 strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") != 0 && |
1622 strcmp (attr->_ident, "ins_short_branch") != 0) { | |
1623 fprintf(fp, " virtual int %s() const { return %s; }\n", attr->_ident, attr->_val); | |
1605 } | 1624 } |
1606 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag | 1625 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag |
1607 if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0) | 1626 if (!strcmp(attr->_ident, "ins_avoid_back_to_back") != 0 && attr->int_val(*this) != 0) |
1608 avoid_back_to_back = true; | 1627 avoid_back_to_back = true; |
1628 if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0) | |
1629 fprintf(fp, " virtual bool is_TrapBasedCheckNode() const { return %s; }\n", attr->_val); | |
1630 | |
1609 attr = (Attribute *)attr->_next; | 1631 attr = (Attribute *)attr->_next; |
1610 } | 1632 } |
1611 | 1633 |
1612 // virtual functions for encode and format | 1634 // virtual functions for encode and format |
1613 | 1635 |
1617 } | 1639 } |
1618 | 1640 |
1619 // Output the opcode function and the encode function here using the | 1641 // Output the opcode function and the encode function here using the |
1620 // encoding class information in the _insencode slot. | 1642 // encoding class information in the _insencode slot. |
1621 if ( instr->_insencode ) { | 1643 if ( instr->_insencode ) { |
1622 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n"); | 1644 if (instr->postalloc_expands()) { |
1645 fprintf(fp," virtual bool requires_postalloc_expand() const { return true; }\n"); | |
1646 fprintf(fp," virtual void postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);\n"); | |
1647 } else { | |
1648 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n"); | |
1649 } | |
1623 } | 1650 } |
1624 | 1651 |
1625 // virtual function for getting the size of an instruction | 1652 // virtual function for getting the size of an instruction |
1626 if ( instr->_size ) { | 1653 if ( instr->_size ) { |
1627 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n"); | 1654 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n"); |
1632 // if the ideal_Opcode == Op_Node. | 1659 // if the ideal_Opcode == Op_Node. |
1633 if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 || | 1660 if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 || |
1634 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { | 1661 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { |
1635 fprintf(fp," virtual int ideal_Opcode() const { return Op_%s; }\n", | 1662 fprintf(fp," virtual int ideal_Opcode() const { return Op_%s; }\n", |
1636 instr->ideal_Opcode(_globalNames) ); | 1663 instr->ideal_Opcode(_globalNames) ); |
1664 } | |
1665 | |
1666 if (instr->needs_constant_base() && | |
1667 !instr->is_mach_constant()) { // These inherit the funcion from MachConstantNode. | |
1668 fprintf(fp," virtual uint mach_constant_base_node_input() const { "); | |
1669 if (instr->is_ideal_call() != Form::invalid_type && | |
1670 instr->is_ideal_call() != Form::JAVA_LEAF) { | |
1671 // MachConstantBase goes behind arguments, but before jvms. | |
1672 fprintf(fp,"assert(tf() && tf()->domain(), \"\"); return tf()->domain()->cnt();"); | |
1673 } else { | |
1674 fprintf(fp,"return req()-1;"); | |
1675 } | |
1676 fprintf(fp," }\n"); | |
1637 } | 1677 } |
1638 | 1678 |
1639 // Allow machine-independent optimization, invert the sense of the IF test | 1679 // Allow machine-independent optimization, invert the sense of the IF test |
1640 if( instr->is_ideal_if() ) { | 1680 if( instr->is_ideal_if() ) { |
1641 fprintf(fp," virtual void negate() { \n"); | 1681 fprintf(fp," virtual void negate() { \n"); |
1802 | 1842 |
1803 // Virtual methods which are only generated to override base class | 1843 // Virtual methods which are only generated to override base class |
1804 if( instr->expands() || instr->needs_projections() || | 1844 if( instr->expands() || instr->needs_projections() || |
1805 instr->has_temps() || | 1845 instr->has_temps() || |
1806 instr->is_mach_constant() || | 1846 instr->is_mach_constant() || |
1847 instr->needs_constant_base() || | |
1807 instr->_matrule != NULL && | 1848 instr->_matrule != NULL && |
1808 instr->num_opnds() != instr->num_unique_opnds() ) { | 1849 instr->num_opnds() != instr->num_unique_opnds() ) { |
1809 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n"); | 1850 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n"); |
1810 } | 1851 } |
1811 | 1852 |