Mercurial > hg > graal-jvmci-8
comparison src/share/vm/adlc/adlparse.cpp @ 6850:d336b3173277
8000592: Improve adlc usability
Summary: several changes to adlc to improve its usability
Reviewed-by: kvn
Contributed-by: goetz.lindenmaier@sap.com
author | kvn |
---|---|
date | Tue, 09 Oct 2012 16:09:31 -0700 |
parents | 8c92982cbbc4 |
children | 39901f2f1abe |
comparison
equal
deleted
inserted
replaced
6849:f6badecb7ea7 | 6850:d336b3173277 |
---|---|
1390 machnode->_machnode_pipe = pipe_class; | 1390 machnode->_machnode_pipe = pipe_class; |
1391 | 1391 |
1392 _AD.addForm(machnode); | 1392 _AD.addForm(machnode); |
1393 } | 1393 } |
1394 else if (!strcmp(ident, "attributes")) { | 1394 else if (!strcmp(ident, "attributes")) { |
1395 bool vsi_seen = false, bhds_seen = false; | 1395 bool vsi_seen = false; |
1396 | 1396 |
1397 skipws(); | 1397 skipws(); |
1398 if ( (_curchar != '%') | 1398 if ( (_curchar != '%') |
1399 || ( next_char(), (_curchar != '{')) ) { | 1399 || ( next_char(), (_curchar != '{')) ) { |
1400 parse_err(SYNERR, "expected '%{'\n"); | 1400 parse_err(SYNERR, "expected '%{'\n"); |
1434 if (_curchar == ';') { | 1434 if (_curchar == ';') { |
1435 next_char(); skipws(); | 1435 next_char(); skipws(); |
1436 } | 1436 } |
1437 | 1437 |
1438 pipeline->_branchHasDelaySlot = true; | 1438 pipeline->_branchHasDelaySlot = true; |
1439 bhds_seen = true; | |
1440 continue; | 1439 continue; |
1441 } | 1440 } |
1442 | 1441 |
1443 if (!strcmp(ident, "max_instructions_per_bundle")) { | 1442 if (!strcmp(ident, "max_instructions_per_bundle")) { |
1444 skipws(); | 1443 skipws(); |
1636 } | 1635 } |
1637 | 1636 |
1638 do { | 1637 do { |
1639 next_char(); // Skip "(" or "," | 1638 next_char(); // Skip "(" or "," |
1640 ident = get_ident(); // Grab next identifier | 1639 ident = get_ident(); // Grab next identifier |
1640 | |
1641 if (_AD._adl_debug > 1) { | |
1642 if (ident != NULL) { | |
1643 fprintf(stderr, "resource_parse: identifier: %s\n", ident); | |
1644 } | |
1645 } | |
1641 | 1646 |
1642 if (ident == NULL) { | 1647 if (ident == NULL) { |
1643 parse_err(SYNERR, "keyword identifier expected at \"%c\"\n", _curchar); | 1648 parse_err(SYNERR, "keyword identifier expected at \"%c\"\n", _curchar); |
1644 return; | 1649 return; |
1645 } | 1650 } |
2425 InstructForm *ADLParser::peep_match_child_parse(PeepMatch &match, int parent, int &position, int input){ | 2430 InstructForm *ADLParser::peep_match_child_parse(PeepMatch &match, int parent, int &position, int input){ |
2426 char *token = NULL; | 2431 char *token = NULL; |
2427 int lparen = 0; // keep track of parenthesis nesting depth | 2432 int lparen = 0; // keep track of parenthesis nesting depth |
2428 int rparen = 0; // position of instruction at this depth | 2433 int rparen = 0; // position of instruction at this depth |
2429 InstructForm *inst_seen = NULL; | 2434 InstructForm *inst_seen = NULL; |
2430 InstructForm *child_seen = NULL; | |
2431 | 2435 |
2432 // Walk the match tree, | 2436 // Walk the match tree, |
2433 // Record <parent, position, instruction name, input position> | 2437 // Record <parent, position, instruction name, input position> |
2434 while ( lparen >= rparen ) { | 2438 while ( lparen >= rparen ) { |
2435 skipws(); | 2439 skipws(); |
2436 // Left paren signals start of an input, collect with recursive call | 2440 // Left paren signals start of an input, collect with recursive call |
2437 if (_curchar == '(') { | 2441 if (_curchar == '(') { |
2438 ++lparen; | 2442 ++lparen; |
2439 next_char(); | 2443 next_char(); |
2440 child_seen = peep_match_child_parse(match, parent, position, rparen); | 2444 ( void ) peep_match_child_parse(match, parent, position, rparen); |
2441 } | 2445 } |
2442 // Right paren signals end of an input, may be more | 2446 // Right paren signals end of an input, may be more |
2443 else if (_curchar == ')') { | 2447 else if (_curchar == ')') { |
2444 ++rparen; | 2448 ++rparen; |
2445 if( rparen == lparen ) { // IF rparen matches an lparen I've seen | 2449 if( rparen == lparen ) { // IF rparen matches an lparen I've seen |
3152 if (_AD._adl_debug > 1) fprintf(stderr, "EncodingClass Form: %s\n", ec_name); | 3156 if (_AD._adl_debug > 1) fprintf(stderr, "EncodingClass Form: %s\n", ec_name); |
3153 } | 3157 } |
3154 | 3158 |
3155 | 3159 |
3156 //------------------------------size_parse----------------------------------- | 3160 //------------------------------size_parse----------------------------------- |
3161 // Parse a 'size(<expr>)' attribute which specifies the size of the | |
3162 // emitted instructions in bytes. <expr> can be a C++ expression, | |
3163 // e.g. a constant. | |
3157 char* ADLParser::size_parse(InstructForm *instr) { | 3164 char* ADLParser::size_parse(InstructForm *instr) { |
3158 char* sizeOfInstr = NULL; | 3165 char* sizeOfInstr = NULL; |
3159 | 3166 |
3160 // Get value of the instruction's size | 3167 // Get value of the instruction's size |
3161 skipws(); | 3168 skipws(); |
4272 c = *end; // Grab character to test | 4279 c = *end; // Grab character to test |
4273 } while ( ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) | 4280 } while ( ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) |
4274 || ((c >= '0') && (c <= '9')) | 4281 || ((c >= '0') && (c <= '9')) |
4275 || ((c == '_')) || ((c == ':')) || ((c == '#')) ); | 4282 || ((c == '_')) || ((c == ':')) || ((c == '#')) ); |
4276 if (start == end) { // We popped out on the first try | 4283 if (start == end) { // We popped out on the first try |
4277 parse_err(SYNERR, "identifier expected at %c\n", c); | 4284 // It can occur that `start' contains the rest of the input file. |
4285 // In this case the output should be truncated. | |
4286 if (strlen(start) > 24) { | |
4287 char buf[32]; | |
4288 strncpy(buf, start, 20); | |
4289 buf[20] = '\0'; | |
4290 strcat(buf, "[...]"); | |
4291 parse_err(SYNERR, "Identifier expected, but found '%s'.", buf); | |
4292 } else { | |
4293 parse_err(SYNERR, "Identifier expected, but found '%s'.", start); | |
4294 } | |
4278 start = NULL; | 4295 start = NULL; |
4279 } | 4296 } |
4280 else { | 4297 else { |
4281 _curchar = c; // Save the first character of next token | 4298 _curchar = c; // Save the first character of next token |
4282 *end = '\0'; // NULL terminate the string in place | 4299 *end = '\0'; // NULL terminate the string in place |