< prev index next >

src/hotspot/share/adlc/output_c.cpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2019, 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  *


2360     }
2361     else if ( strcmp(rep_var,"$label") == 0 ) {
2362       fprintf(_fp,"->label()");
2363     }
2364     else if ( strcmp(rep_var,"$method") == 0 ) {
2365       fprintf(_fp,"->method()");
2366     }
2367     else {
2368       printf("emit_field: %s\n",rep_var);
2369       globalAD->syntax_err(_inst._linenum, "Unknown replacement variable %s in format statement of %s.",
2370                            rep_var, _inst._ident);
2371       assert( false, "UnImplemented()");
2372     }
2373   }
2374 
2375 
2376   void emit_rep_var(const char *rep_var) {
2377     _processing_noninput = false;
2378     // A replacement variable, originally '$'
2379     if ( Opcode::as_opcode_type(rep_var) != Opcode::NOT_AN_OPCODE ) {
2380       if ((_inst._opcode == NULL) || !_inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(rep_var) )) {
2381         // Missing opcode
2382         _AD.syntax_err( _inst._linenum,
2383                         "Missing $%s opcode definition in %s, used by encoding %s\n",
2384                         rep_var, _inst._ident, _encoding._name);
2385       }
2386     }
2387     else if (strcmp(rep_var, "constanttablebase") == 0) {
2388       fprintf(_fp, "as_Register(ra_->get_encode(in(mach_constant_base_node_input())))");
2389     }
2390     else if (strcmp(rep_var, "constantoffset") == 0) {
2391       fprintf(_fp, "constant_offset()");
2392     }
2393     else if (strcmp(rep_var, "constantaddress") == 0) {
2394       fprintf(_fp, "InternalAddress(__ code()->consts()->start() + constant_offset())");
2395     }
2396     else {
2397       // Lookup its position in parameter list
2398       int   param_no  = _encoding.rep_var_index(rep_var);
2399       if ( param_no == -1 ) {
2400         _AD.syntax_err( _encoding._linenum,


2416           // This operand isn't a normal input so printing it is done
2417           // specially.
2418           _processing_noninput = true;
2419         } else {
2420           // Output the emit code for this operand
2421           fprintf(_fp,"opnd_array(%d)",idx);
2422         }
2423         assert( _operand == opc->is_operand(),
2424                 "Previous emit $operand does not match current");
2425       }
2426       else if( ADLParser::is_literal_constant(inst_rep_var) ) {
2427         // else check if it is a constant expression
2428         // Removed following assert to allow primitive C types as arguments to encodings
2429         // assert( _constant_status == LITERAL_ACCESSED, "Must be processing a literal constant parameter");
2430         fprintf(_fp,"(%s)", inst_rep_var);
2431         _constant_status = LITERAL_OUTPUT;
2432       }
2433       else if( Opcode::as_opcode_type(inst_rep_var) != Opcode::NOT_AN_OPCODE ) {
2434         // else check if "primary", "secondary", "tertiary"
2435         assert( _constant_status == LITERAL_ACCESSED, "Must be processing a literal constant parameter");
2436         if ((_inst._opcode == NULL) || !_inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(inst_rep_var) )) {
2437           // Missing opcode
2438           _AD.syntax_err( _inst._linenum,
2439                           "Missing $%s opcode definition in %s\n",
2440                           rep_var, _inst._ident);
2441 
2442         }
2443         _constant_status = LITERAL_OUTPUT;
2444       }
2445       else if((_AD.get_registers() != NULL ) && (_AD.get_registers()->getRegDef(inst_rep_var) != NULL)) {
2446         // Instruction provided a literal register name for this parameter
2447         // Check that encoding specifies $$$reg to resolve.as register.
2448         assert( _reg_status == LITERAL_ACCESSED, "Must be processing a literal register parameter");
2449         fprintf(_fp,"(%s_enc)", inst_rep_var);
2450         _reg_status = LITERAL_OUTPUT;
2451       }
2452       else {
2453         // Check for unimplemented functionality before hard failure
2454         assert(opc != NULL && strcmp(opc->_ident, "label") == 0, "Unimplemented Label");
2455         assert(false, "ShouldNotReachHere()");
2456       }


   1 /*
   2  * Copyright (c) 1998, 2018, 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  *


2360     }
2361     else if ( strcmp(rep_var,"$label") == 0 ) {
2362       fprintf(_fp,"->label()");
2363     }
2364     else if ( strcmp(rep_var,"$method") == 0 ) {
2365       fprintf(_fp,"->method()");
2366     }
2367     else {
2368       printf("emit_field: %s\n",rep_var);
2369       globalAD->syntax_err(_inst._linenum, "Unknown replacement variable %s in format statement of %s.",
2370                            rep_var, _inst._ident);
2371       assert( false, "UnImplemented()");
2372     }
2373   }
2374 
2375 
2376   void emit_rep_var(const char *rep_var) {
2377     _processing_noninput = false;
2378     // A replacement variable, originally '$'
2379     if ( Opcode::as_opcode_type(rep_var) != Opcode::NOT_AN_OPCODE ) {
2380       if (!_inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(rep_var) )) {
2381         // Missing opcode
2382         _AD.syntax_err( _inst._linenum,
2383                         "Missing $%s opcode definition in %s, used by encoding %s\n",
2384                         rep_var, _inst._ident, _encoding._name);
2385       }
2386     }
2387     else if (strcmp(rep_var, "constanttablebase") == 0) {
2388       fprintf(_fp, "as_Register(ra_->get_encode(in(mach_constant_base_node_input())))");
2389     }
2390     else if (strcmp(rep_var, "constantoffset") == 0) {
2391       fprintf(_fp, "constant_offset()");
2392     }
2393     else if (strcmp(rep_var, "constantaddress") == 0) {
2394       fprintf(_fp, "InternalAddress(__ code()->consts()->start() + constant_offset())");
2395     }
2396     else {
2397       // Lookup its position in parameter list
2398       int   param_no  = _encoding.rep_var_index(rep_var);
2399       if ( param_no == -1 ) {
2400         _AD.syntax_err( _encoding._linenum,


2416           // This operand isn't a normal input so printing it is done
2417           // specially.
2418           _processing_noninput = true;
2419         } else {
2420           // Output the emit code for this operand
2421           fprintf(_fp,"opnd_array(%d)",idx);
2422         }
2423         assert( _operand == opc->is_operand(),
2424                 "Previous emit $operand does not match current");
2425       }
2426       else if( ADLParser::is_literal_constant(inst_rep_var) ) {
2427         // else check if it is a constant expression
2428         // Removed following assert to allow primitive C types as arguments to encodings
2429         // assert( _constant_status == LITERAL_ACCESSED, "Must be processing a literal constant parameter");
2430         fprintf(_fp,"(%s)", inst_rep_var);
2431         _constant_status = LITERAL_OUTPUT;
2432       }
2433       else if( Opcode::as_opcode_type(inst_rep_var) != Opcode::NOT_AN_OPCODE ) {
2434         // else check if "primary", "secondary", "tertiary"
2435         assert( _constant_status == LITERAL_ACCESSED, "Must be processing a literal constant parameter");
2436         if (!_inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(inst_rep_var) )) {
2437           // Missing opcode
2438           _AD.syntax_err( _inst._linenum,
2439                           "Missing $%s opcode definition in %s\n",
2440                           rep_var, _inst._ident);
2441 
2442         }
2443         _constant_status = LITERAL_OUTPUT;
2444       }
2445       else if((_AD.get_registers() != NULL ) && (_AD.get_registers()->getRegDef(inst_rep_var) != NULL)) {
2446         // Instruction provided a literal register name for this parameter
2447         // Check that encoding specifies $$$reg to resolve.as register.
2448         assert( _reg_status == LITERAL_ACCESSED, "Must be processing a literal register parameter");
2449         fprintf(_fp,"(%s_enc)", inst_rep_var);
2450         _reg_status = LITERAL_OUTPUT;
2451       }
2452       else {
2453         // Check for unimplemented functionality before hard failure
2454         assert(opc != NULL && strcmp(opc->_ident, "label") == 0, "Unimplemented Label");
2455         assert(false, "ShouldNotReachHere()");
2456       }


< prev index next >