3375 // If our left child exists, it is the left reduction
3376 if ( mnode->_lChild ) {
3377 leftStr = mnode->_lChild->_internalop ? mnode->_lChild->_internalop
3378 : mnode->_lChild->_opType;
3379 } else {
3380 // May be simple chain rule: (Set dst operand_form_source)
3381 if ( sets_result() ) {
3382 OperandForm *oper = globals[mnode->_opType]->is_operand();
3383 if( oper ) {
3384 leftStr = mnode->_opType;
3385 }
3386 }
3387 }
3388 return leftStr;
3389 }
3390
3391 //------------------------------count_instr_names------------------------------
3392 // Count occurrences of operands names in the leaves of the instruction
3393 // match rule.
3394 void MatchNode::count_instr_names( Dict &names ) {
3395 if( !this ) return;
3396 if( _lChild ) _lChild->count_instr_names(names);
3397 if( _rChild ) _rChild->count_instr_names(names);
3398 if( !_lChild && !_rChild ) {
3399 uintptr_t cnt = (uintptr_t)names[_name];
3400 cnt++; // One more name found
3401 names.Insert(_name,(void*)cnt);
3402 }
3403 }
3404
3405 //------------------------------build_instr_pred-------------------------------
3406 // Build a path to 'name' in buf. Actually only build if cnt is zero, so we
3407 // can skip some leading instances of 'name'.
3408 int MatchNode::build_instr_pred( char *buf, const char *name, int cnt ) {
3409 if( _lChild ) {
3410 if( !cnt ) strcpy( buf, "_kids[0]->" );
3411 cnt = _lChild->build_instr_pred( buf+strlen(buf), name, cnt );
3412 if( cnt < 0 ) return cnt; // Found it, all done
3413 }
3414 if( _rChild ) {
3415 if( !cnt ) strcpy( buf, "_kids[1]->" );
|
3375 // If our left child exists, it is the left reduction
3376 if ( mnode->_lChild ) {
3377 leftStr = mnode->_lChild->_internalop ? mnode->_lChild->_internalop
3378 : mnode->_lChild->_opType;
3379 } else {
3380 // May be simple chain rule: (Set dst operand_form_source)
3381 if ( sets_result() ) {
3382 OperandForm *oper = globals[mnode->_opType]->is_operand();
3383 if( oper ) {
3384 leftStr = mnode->_opType;
3385 }
3386 }
3387 }
3388 return leftStr;
3389 }
3390
3391 //------------------------------count_instr_names------------------------------
3392 // Count occurrences of operands names in the leaves of the instruction
3393 // match rule.
3394 void MatchNode::count_instr_names( Dict &names ) {
3395 if( this == NULL ) return;
3396 if( _lChild ) _lChild->count_instr_names(names);
3397 if( _rChild ) _rChild->count_instr_names(names);
3398 if( !_lChild && !_rChild ) {
3399 uintptr_t cnt = (uintptr_t)names[_name];
3400 cnt++; // One more name found
3401 names.Insert(_name,(void*)cnt);
3402 }
3403 }
3404
3405 //------------------------------build_instr_pred-------------------------------
3406 // Build a path to 'name' in buf. Actually only build if cnt is zero, so we
3407 // can skip some leading instances of 'name'.
3408 int MatchNode::build_instr_pred( char *buf, const char *name, int cnt ) {
3409 if( _lChild ) {
3410 if( !cnt ) strcpy( buf, "_kids[0]->" );
3411 cnt = _lChild->build_instr_pred( buf+strlen(buf), name, cnt );
3412 if( cnt < 0 ) return cnt; // Found it, all done
3413 }
3414 if( _rChild ) {
3415 if( !cnt ) strcpy( buf, "_kids[1]->" );
|