< prev index next >

src/share/vm/adlc/formssel.cpp

Print this page
rev 11179 : 8140594: Various minor code improvements (compiler)
Reviewed-by: thartmann


1482   }
1483   if (_exprule)   _exprule->output(fp);
1484   if (_rewrule)   _rewrule->output(fp);
1485   if (_format)    _format->output(fp);
1486   if (_peephole)  _peephole->output(fp);
1487 }
1488 
1489 void MachNodeForm::dump() {
1490   output(stderr);
1491 }
1492 
1493 void MachNodeForm::output(FILE *fp) {
1494   fprintf(fp,"\nMachNode: %s\n", (_ident?_ident:""));
1495 }
1496 
1497 //------------------------------build_predicate--------------------------------
1498 // Build instruction predicates.  If the user uses the same operand name
1499 // twice, we need to check that the operands are pointer-eequivalent in
1500 // the DFA during the labeling process.
1501 Predicate *InstructForm::build_predicate() {
1502   char buf[1024], *s=buf;

1503   Dict names(cmpstr,hashstr,Form::arena);       // Map Names to counts
1504 
1505   MatchNode *mnode =
1506     strcmp(_matrule->_opType, "Set") ? _matrule : _matrule->_rChild;
1507   mnode->count_instr_names(names);
1508 
1509   uint first = 1;
1510   // Start with the predicate supplied in the .ad file.
1511   if( _predicate ) {
1512     if( first ) first=0;
1513     strcpy(s,"("); s += strlen(s);
1514     strcpy(s,_predicate->_pred);
1515     s += strlen(s);
1516     strcpy(s,")"); s += strlen(s);
1517   }
1518   for( DictI i(&names); i.test(); ++i ) {
1519     uintptr_t cnt = (uintptr_t)i._value;
1520     if( cnt > 1 ) {             // Need a predicate at all?
1521       assert( cnt == 2, "Unimplemented" );
1522       // Handle many pairs
1523       if( first ) first=0;
1524       else {                    // All tests must pass, so use '&&'
1525         strcpy(s," && ");
1526         s += strlen(s);
1527       }
1528       // Add predicate to working buffer
1529       sprintf(s,"/*%s*/(",(char*)i._key);
1530       s += strlen(s);
1531       mnode->build_instr_pred(s,(char*)i._key,0);
1532       s += strlen(s);
1533       strcpy(s," == "); s += strlen(s);
1534       mnode->build_instr_pred(s,(char*)i._key,1);
1535       s += strlen(s);
1536       strcpy(s,")"); s += strlen(s);




1482   }
1483   if (_exprule)   _exprule->output(fp);
1484   if (_rewrule)   _rewrule->output(fp);
1485   if (_format)    _format->output(fp);
1486   if (_peephole)  _peephole->output(fp);
1487 }
1488 
1489 void MachNodeForm::dump() {
1490   output(stderr);
1491 }
1492 
1493 void MachNodeForm::output(FILE *fp) {
1494   fprintf(fp,"\nMachNode: %s\n", (_ident?_ident:""));
1495 }
1496 
1497 //------------------------------build_predicate--------------------------------
1498 // Build instruction predicates.  If the user uses the same operand name
1499 // twice, we need to check that the operands are pointer-eequivalent in
1500 // the DFA during the labeling process.
1501 Predicate *InstructForm::build_predicate() {
1502   const int buflen = 1024;
1503   char buf[buflen], *s=buf;
1504   Dict names(cmpstr,hashstr,Form::arena);       // Map Names to counts
1505 
1506   MatchNode *mnode =
1507     strcmp(_matrule->_opType, "Set") ? _matrule : _matrule->_rChild;
1508   mnode->count_instr_names(names);
1509 
1510   uint first = 1;
1511   // Start with the predicate supplied in the .ad file.
1512   if (_predicate) {
1513     if (first) first = 0;
1514     strcpy(s, "("); s += strlen(s);
1515     strncpy(s, _predicate->_pred, buflen - strlen(s) - 1);
1516     s += strlen(s);
1517     strcpy(s, ")"); s += strlen(s);
1518   }
1519   for( DictI i(&names); i.test(); ++i ) {
1520     uintptr_t cnt = (uintptr_t)i._value;
1521     if( cnt > 1 ) {             // Need a predicate at all?
1522       assert( cnt == 2, "Unimplemented" );
1523       // Handle many pairs
1524       if( first ) first=0;
1525       else {                    // All tests must pass, so use '&&'
1526         strcpy(s," && ");
1527         s += strlen(s);
1528       }
1529       // Add predicate to working buffer
1530       sprintf(s,"/*%s*/(",(char*)i._key);
1531       s += strlen(s);
1532       mnode->build_instr_pred(s,(char*)i._key,0);
1533       s += strlen(s);
1534       strcpy(s," == "); s += strlen(s);
1535       mnode->build_instr_pred(s,(char*)i._key,1);
1536       s += strlen(s);
1537       strcpy(s,")"); s += strlen(s);


< prev index next >