< prev index next >

src/hotspot/share/adlc/output_h.cpp

Print this page

   1 /*
   2  * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *

1614     // virtual function for getting the size of an instruction
1615     if ( instr->_size ) {
1616       fprintf(fp,"  virtual uint           size(PhaseRegAlloc *ra_) const;\n");
1617     }
1618 
1619     // Return the top-level ideal opcode.
1620     // Use MachNode::ideal_Opcode() for nodes based on MachNode class
1621     // if the ideal_Opcode == Op_Node.
1622     if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 ||
1623          strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1624       fprintf(fp,"  virtual int            ideal_Opcode() const { return Op_%s; }\n",
1625             instr->ideal_Opcode(_globalNames) );
1626     }
1627 
1628     if (instr->needs_constant_base() &&
1629         !instr->is_mach_constant()) {  // These inherit the function from MachConstantNode.
1630       fprintf(fp,"  virtual uint           mach_constant_base_node_input() const { ");
1631       if (instr->is_ideal_call() != Form::invalid_type &&
1632           instr->is_ideal_call() != Form::JAVA_LEAF) {
1633         // MachConstantBase goes behind arguments, but before jvms.
1634         fprintf(fp,"assert(tf() && tf()->domain(), \"\"); return tf()->domain()->cnt();");
1635       } else {
1636         fprintf(fp,"return req()-1;");
1637       }
1638       fprintf(fp," }\n");
1639     }
1640 
1641     // Allow machine-independent optimization, invert the sense of the IF test
1642     if( instr->is_ideal_if() ) {
1643       fprintf(fp,"  virtual void           negate() { \n");
1644       // Identify which operand contains the negate(able) ideal condition code
1645       int   idx = 0;
1646       instr->_components.reset();
1647       for( Component *comp; (comp = instr->_components.iter()) != nullptr; ) {
1648         // Check that component is an operand
1649         Form *form = (Form*)_globalNames[comp->_type];
1650         OperandForm *opForm = form ? form->is_operand() : nullptr;
1651         if( opForm == nullptr ) continue;
1652 
1653         // Lookup the position of the operand in the instruction.
1654         if( opForm->is_ideal_bool() ) {

   1 /*
   2  * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *

1614     // virtual function for getting the size of an instruction
1615     if ( instr->_size ) {
1616       fprintf(fp,"  virtual uint           size(PhaseRegAlloc *ra_) const;\n");
1617     }
1618 
1619     // Return the top-level ideal opcode.
1620     // Use MachNode::ideal_Opcode() for nodes based on MachNode class
1621     // if the ideal_Opcode == Op_Node.
1622     if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 ||
1623          strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1624       fprintf(fp,"  virtual int            ideal_Opcode() const { return Op_%s; }\n",
1625             instr->ideal_Opcode(_globalNames) );
1626     }
1627 
1628     if (instr->needs_constant_base() &&
1629         !instr->is_mach_constant()) {  // These inherit the function from MachConstantNode.
1630       fprintf(fp,"  virtual uint           mach_constant_base_node_input() const { ");
1631       if (instr->is_ideal_call() != Form::invalid_type &&
1632           instr->is_ideal_call() != Form::JAVA_LEAF) {
1633         // MachConstantBase goes behind arguments, but before jvms.
1634         fprintf(fp,"assert(tf() && tf()->domain_cc(), \"\"); return tf()->domain_cc()->cnt();");
1635       } else {
1636         fprintf(fp,"return req()-1;");
1637       }
1638       fprintf(fp," }\n");
1639     }
1640 
1641     // Allow machine-independent optimization, invert the sense of the IF test
1642     if( instr->is_ideal_if() ) {
1643       fprintf(fp,"  virtual void           negate() { \n");
1644       // Identify which operand contains the negate(able) ideal condition code
1645       int   idx = 0;
1646       instr->_components.reset();
1647       for( Component *comp; (comp = instr->_components.iter()) != nullptr; ) {
1648         // Check that component is an operand
1649         Form *form = (Form*)_globalNames[comp->_type];
1650         OperandForm *opForm = form ? form->is_operand() : nullptr;
1651         if( opForm == nullptr ) continue;
1652 
1653         // Lookup the position of the operand in the instruction.
1654         if( opForm->is_ideal_bool() ) {
< prev index next >