hotspot/src/share/vm/adlc/formsopt.cpp
changeset 2129 e810a33b5c67
parent 1 489c9b5090e2
child 5547 f4b087cbb361
equal deleted inserted replaced
2128:c08c265de2f5 2129:e810a33b5c67
     1 /*
     1 /*
     2  * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
     2  * Copyright 1998-2009 Sun Microsystems, Inc.  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.
   271   int         word = 0;
   271   int         word = 0;
   272   const char *name;
   272   const char *name;
   273   for(_regDefs.reset(); (name = _regDefs.iter()) != NULL;) {
   273   for(_regDefs.reset(); (name = _regDefs.iter()) != NULL;) {
   274     int rnum = ((RegDef*)_regDef[name])->register_num();
   274     int rnum = ((RegDef*)_regDef[name])->register_num();
   275     if( (rnum >> 5) == wordnum )
   275     if( (rnum >> 5) == wordnum )
   276       word |= (1L<<(rnum&31));
   276       word |= (1 << (rnum & 31));
   277   }
   277   }
   278   if( stack_also ) {
   278   if( stack_also ) {
   279     // Now also collect stack bits
   279     // Now also collect stack bits
   280     for( int i = 0; i < 32; i++ )
   280     for( int i = 0; i < 32; i++ )
   281       if( wordnum*32+i >= RegisterForm::_reg_ctr )
   281       if( wordnum*32+i >= RegisterForm::_reg_ctr )
   282         word |= (1L<<i);
   282         word |= (1 << i);
   283   }
   283   }
   284 
   284 
   285   return word;
   285   return word;
   286 }
   286 }
   287 
   287 
   590 // Insert info into the match-rule
   590 // Insert info into the match-rule
   591 void  PeepMatch::add_instruction(int parent, int position, const char *name,
   591 void  PeepMatch::add_instruction(int parent, int position, const char *name,
   592                                  int input) {
   592                                  int input) {
   593   if( position > _max_position ) _max_position = position;
   593   if( position > _max_position ) _max_position = position;
   594 
   594 
   595   _parent.addName((char *)parent);
   595   _parent.addName((char*) (intptr_t) parent);
   596   _position.addName((char *)position);
   596   _position.addName((char*) (intptr_t) position);
   597   _instrs.addName(name);
   597   _instrs.addName(name);
   598   _input.addName((char *)input);
   598   _input.addName((char*) (intptr_t) input);
   599 }
   599 }
   600 
   600 
   601 // Access info about instructions in the peep-match rule
   601 // Access info about instructions in the peep-match rule
   602 int   PeepMatch::max_position() {
   602 int   PeepMatch::max_position() {
   603   return _max_position;
   603   return _max_position;
   604 }
   604 }
   605 
   605 
   606 const char *PeepMatch::instruction_name(intptr_t position) {
   606 const char *PeepMatch::instruction_name(int position) {
   607   return _instrs.name(position);
   607   return _instrs.name(position);
   608 }
   608 }
   609 
   609 
   610 // Iterate through all info on matched instructions
   610 // Iterate through all info on matched instructions
   611 void  PeepMatch::reset() {
   611 void  PeepMatch::reset() {
   613   _position.reset();
   613   _position.reset();
   614   _instrs.reset();
   614   _instrs.reset();
   615   _input.reset();
   615   _input.reset();
   616 }
   616 }
   617 
   617 
   618 void  PeepMatch::next_instruction( intptr_t &parent, intptr_t &position, const char * &name, intptr_t &input ){
   618 void  PeepMatch::next_instruction(int &parent, int &position, const char* &name, int &input) {
   619   parent   = (intptr_t)_parent.iter();
   619   parent   = (int) (intptr_t) _parent.iter();
   620   position = (intptr_t)_position.iter();
   620   position = (int) (intptr_t) _position.iter();
   621   name     = _instrs.iter();
   621   name     = _instrs.iter();
   622   input    = (intptr_t)_input.iter();
   622   input    = (int) (intptr_t) _input.iter();
   623 }
   623 }
   624 
   624 
   625 // 'true' if current position in iteration is a placeholder, not matched.
   625 // 'true' if current position in iteration is a placeholder, not matched.
   626 bool  PeepMatch::is_placeholder() {
   626 bool  PeepMatch::is_placeholder() {
   627   return _instrs.current_is_signal();
   627   return _instrs.current_is_signal();
   635 void PeepMatch::output(FILE *fp) {        // Write info to output files
   635 void PeepMatch::output(FILE *fp) {        // Write info to output files
   636   fprintf(fp,"PeepMatch:\n");
   636   fprintf(fp,"PeepMatch:\n");
   637 }
   637 }
   638 
   638 
   639 //------------------------------PeepConstraint---------------------------------
   639 //------------------------------PeepConstraint---------------------------------
   640 PeepConstraint::PeepConstraint(intptr_t  left_inst,  char *left_op, char *relation,
   640 PeepConstraint::PeepConstraint(int left_inst,  char* left_op, char* relation,
   641                                intptr_t  right_inst, char *right_op)
   641                                int right_inst, char* right_op)
   642   : _left_inst(left_inst), _left_op(left_op), _relation(relation),
   642   : _left_inst(left_inst), _left_op(left_op), _relation(relation),
   643     _right_inst(right_inst), _right_op(right_op), _next(NULL) {}
   643     _right_inst(right_inst), _right_op(right_op), _next(NULL) {}
   644 PeepConstraint::~PeepConstraint() {
   644 PeepConstraint::~PeepConstraint() {
   645 }
   645 }
   646 
   646 
   647 // Check if constraints use instruction at position
   647 // Check if constraints use instruction at position
   648 bool PeepConstraint::constrains_instruction(intptr_t position) {
   648 bool PeepConstraint::constrains_instruction(int position) {
   649   // Check local instruction constraints
   649   // Check local instruction constraints
   650   if( _left_inst  == position ) return true;
   650   if( _left_inst  == position ) return true;
   651   if( _right_inst == position ) return true;
   651   if( _right_inst == position ) return true;
   652 
   652 
   653   // Check remaining constraints in list
   653   // Check remaining constraints in list
   690   _operand_inst_num.add_signal();
   690   _operand_inst_num.add_signal();
   691   _operand_op_name.add_signal();
   691   _operand_op_name.add_signal();
   692 }
   692 }
   693 void  PeepReplace::add_operand( int inst_num, char *inst_operand ) {
   693 void  PeepReplace::add_operand( int inst_num, char *inst_operand ) {
   694   _instruction.add_signal();
   694   _instruction.add_signal();
   695   _operand_inst_num.addName((char*)inst_num);
   695   _operand_inst_num.addName((char*) (intptr_t) inst_num);
   696   _operand_op_name.addName(inst_operand);
   696   _operand_op_name.addName(inst_operand);
   697 }
   697 }
   698 
   698 
   699 // Access contents of peepreplace
   699 // Access contents of peepreplace
   700 void  PeepReplace::reset() {
   700 void  PeepReplace::reset() {
   701   _instruction.reset();
   701   _instruction.reset();
   702   _operand_inst_num.reset();
   702   _operand_inst_num.reset();
   703   _operand_op_name.reset();
   703   _operand_op_name.reset();
   704 }
   704 }
   705 void  PeepReplace::next_instruction(const char * &inst){
   705 void  PeepReplace::next_instruction(const char* &inst){
   706   inst                     = _instruction.iter();
   706   inst                     = _instruction.iter();
   707   intptr_t   inst_num      = (intptr_t)_operand_inst_num.iter();
   707   int         inst_num     = (int) (intptr_t) _operand_inst_num.iter();
   708   const char *inst_operand = _operand_op_name.iter();
   708   const char* inst_operand = _operand_op_name.iter();
   709 }
   709 }
   710 void  PeepReplace::next_operand( intptr_t &inst_num, const char * &inst_operand ) {
   710 void  PeepReplace::next_operand(int &inst_num, const char* &inst_operand) {
   711   const char *inst   = _instruction.iter();
   711   const char* inst = _instruction.iter();
   712   inst_num           = (intptr_t)_operand_inst_num.iter();
   712   inst_num         = (int) (intptr_t) _operand_inst_num.iter();
   713   inst_operand       = _operand_op_name.iter();
   713   inst_operand     = _operand_op_name.iter();
   714 }
   714 }
   715 
   715 
   716 
   716 
   717 
   717 
   718 void PeepReplace::dump() {
   718 void PeepReplace::dump() {