comparison src/share/vm/adlc/adlparse.cpp @ 628:7bb995fbd3c0

Merge
author trims
date Thu, 12 Mar 2009 18:16:36 -0700
parents 0fbdb4381b99 98cb887364d3
children c18cbe5936b8
comparison
equal deleted inserted replaced
580:ce2272390558 628:7bb995fbd3c0
296 // Check for commutative operations with tree operands. 296 // Check for commutative operations with tree operands.
297 int count = 0; 297 int count = 0;
298 rule->count_commutative_op(count); 298 rule->count_commutative_op(count);
299 if (count > 0) { 299 if (count > 0) {
300 // Clone match rule and swap commutative operation's operands. 300 // Clone match rule and swap commutative operation's operands.
301 rule->swap_commutative_op(instr_ident, count, match_rules_cnt); 301 rule->matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt);
302 } 302 }
303 } 303 }
304 304
305 //------------------------------adjust_set_rule-------------------------------- 305 //------------------------------adjust_set_rule--------------------------------
306 // Check for "Set" form of chain rule 306 // Check for "Set" form of chain rule
2584 // Check for a constraint 2584 // Check for a constraint
2585 skipws(); 2585 skipws();
2586 while( _curchar != ')' ) { 2586 while( _curchar != ')' ) {
2587 // Get information on the left instruction and its operand 2587 // Get information on the left instruction and its operand
2588 // left-instructions's number 2588 // left-instructions's number
2589 intptr_t left_inst = get_int(); 2589 int left_inst = get_int();
2590 // Left-instruction's operand 2590 // Left-instruction's operand
2591 skipws(); 2591 skipws();
2592 if( _curchar != '.' ) { 2592 if( _curchar != '.' ) {
2593 parse_err(SYNERR, "missing '.' in peepconstraint after instruction number.\n"); 2593 parse_err(SYNERR, "missing '.' in peepconstraint after instruction number.\n");
2594 return; 2594 return;
2600 // Collect relational operator 2600 // Collect relational operator
2601 char *relation = get_relation_dup(); 2601 char *relation = get_relation_dup();
2602 2602
2603 skipws(); 2603 skipws();
2604 // Get information on the right instruction and its operand 2604 // Get information on the right instruction and its operand
2605 intptr_t right_inst; // Right-instructions's number 2605 int right_inst; // Right-instructions's number
2606 if( isdigit(_curchar) ) { 2606 if( isdigit(_curchar) ) {
2607 right_inst = get_int(); 2607 right_inst = get_int();
2608 // Right-instruction's operand 2608 // Right-instruction's operand
2609 skipws(); 2609 skipws();
2610 if( _curchar != '.' ) { 2610 if( _curchar != '.' ) {
3495 skipws(); 3495 skipws();
3496 while ( (_curchar != '%') && (*(_ptr+1) != '}') ) { 3496 while ( (_curchar != '%') && (*(_ptr+1) != '}') ) {
3497 3497
3498 // (1) 3498 // (1)
3499 // Check if there is a string to pass through to output 3499 // Check if there is a string to pass through to output
3500 char *start = _ptr; // Record start of the next string 3500 {
3501 while ((_curchar != '$') && ((_curchar != '%') || (*(_ptr+1) != '}')) ) { 3501 char *start = _ptr; // Record start of the next string
3502 // If at the start of a comment, skip past it 3502 while ((_curchar != '$') && ((_curchar != '%') || (*(_ptr+1) != '}')) ) {
3503 if( (_curchar == '/') && ((*(_ptr+1) == '/') || (*(_ptr+1) == '*')) ) { 3503 // If at the start of a comment, skip past it
3504 skipws_no_preproc(); 3504 if( (_curchar == '/') && ((*(_ptr+1) == '/') || (*(_ptr+1) == '*')) ) {
3505 } else { 3505 skipws_no_preproc();
3506 // ELSE advance to the next character, or start of the next line 3506 } else {
3507 next_char_or_line(); 3507 // ELSE advance to the next character, or start of the next line
3508 } 3508 next_char_or_line();
3509 } 3509 }
3510 // If a string was found, terminate it and record in EncClass 3510 }
3511 if ( start != _ptr ) { 3511 // If a string was found, terminate it and record in EncClass
3512 *_ptr = '\0'; // Terminate the string 3512 if ( start != _ptr ) {
3513 // Add flag to _strings list indicating we should check _rep_vars 3513 *_ptr = '\0'; // Terminate the string
3514 format->_strings.addName(NameList::_signal2); 3514 // Add flag to _strings list indicating we should check _rep_vars
3515 format->_strings.addName(start); 3515 format->_strings.addName(NameList::_signal2);
3516 format->_strings.addName(start);
3517 }
3516 } 3518 }
3517 3519
3518 // (2) 3520 // (2)
3519 // If we are at a replacement variable, 3521 // If we are at a replacement variable,
3520 // copy it and record in EncClass 3522 // copy it and record in EncClass
3561 // (2) 3563 // (2)
3562 // If we are at a replacement variable, 3564 // If we are at a replacement variable,
3563 // copy it and record in FormatRule 3565 // copy it and record in FormatRule
3564 if ( _curchar == '$' ) { 3566 if ( _curchar == '$' ) {
3565 next_char(); // Move past the '$' 3567 next_char(); // Move past the '$'
3566 char* rep_var = get_ident(); // Nil terminate the variable name 3568 char* next_rep_var = get_ident(); // Nil terminate the variable name
3567 rep_var = strdup(rep_var);// Copy the string 3569 next_rep_var = strdup(next_rep_var);// Copy the string
3568 *_ptr = _curchar; // and replace Nil with original character 3570 *_ptr = _curchar; // and replace Nil with original character
3569 format->_rep_vars.addName(rep_var); 3571 format->_rep_vars.addName(next_rep_var);
3570 // Add flag to _strings list indicating we should check _rep_vars 3572 // Add flag to _strings list indicating we should check _rep_vars
3571 format->_strings.addName(NameList::_signal); 3573 format->_strings.addName(NameList::_signal);
3572 } 3574 }
3573 3575
3574 // (3) 3576 // (3)
3712 skipws(); 3714 skipws();
3713 if (ident2 == NULL) { 3715 if (ident2 == NULL) {
3714 parse_err(SYNERR, "identifier expected at %c\n", _curchar); 3716 parse_err(SYNERR, "identifier expected at %c\n", _curchar);
3715 continue; 3717 continue;
3716 } // Check that you have a valid operand 3718 } // Check that you have a valid operand
3717 const Form *form = instr->_localNames[ident2]; 3719 const Form *form2 = instr->_localNames[ident2];
3718 if (!form) { 3720 if (!form2) {
3719 parse_err(SYNERR, "operand name expected at %s\n", ident2); 3721 parse_err(SYNERR, "operand name expected at %s\n", ident2);
3720 continue; 3722 continue;
3721 } 3723 }
3722 oper = form->is_operand(); 3724 oper = form2->is_operand();
3723 if (oper == NULL && !form->is_opclass()) { 3725 if (oper == NULL && !form2->is_opclass()) {
3724 parse_err(SYNERR, "operand name expected at %s\n", ident2); 3726 parse_err(SYNERR, "operand name expected at %s\n", ident2);
3725 continue; 3727 continue;
3726 } // Add operand to list 3728 } // Add operand to list
3727 instr_and_operands->add_entry(ident2); 3729 instr_and_operands->add_entry(ident2);
3728 } while(_curchar == ','); 3730 } while(_curchar == ',');
4269 char *start; // Pointer to start of token 4271 char *start; // Pointer to start of token
4270 char *end; // Pointer to end of token 4272 char *end; // Pointer to end of token
4271 int result; // Storage for integer result 4273 int result; // Storage for integer result
4272 4274
4273 if( _curline == NULL ) // Return NULL at EOF. 4275 if( _curline == NULL ) // Return NULL at EOF.
4274 return NULL; 4276 return 0;
4275 4277
4276 skipws(); // Skip whitespace before identifier 4278 skipws(); // Skip whitespace before identifier
4277 start = end = _ptr; // Start points at first character 4279 start = end = _ptr; // Start points at first character
4278 c = *end; // Grab character to test 4280 c = *end; // Grab character to test
4279 while ((c >= '0') && (c <= '9') 4281 while ((c >= '0') && (c <= '9')
4551 } 4553 }
4552 } 4554 }
4553 4555
4554 //---------------------------ensure_start_of_line------------------------------ 4556 //---------------------------ensure_start_of_line------------------------------
4555 // A preprocessor directive has been encountered. Be sure it has fallen at 4557 // A preprocessor directive has been encountered. Be sure it has fallen at
4556 // the begining of a line, or else report an error. 4558 // the beginning of a line, or else report an error.
4557 void ADLParser::ensure_start_of_line(void) { 4559 void ADLParser::ensure_start_of_line(void) {
4558 if (_curchar == '\n') { next_line(); return; } 4560 if (_curchar == '\n') { next_line(); return; }
4559 assert( _ptr >= _curline && _ptr < _curline+strlen(_curline), 4561 assert( _ptr >= _curline && _ptr < _curline+strlen(_curline),
4560 "Must be able to find which line we are in" ); 4562 "Must be able to find which line we are in" );
4561 4563