643 if( _matrule == NULL ) return false; 644 if( !_matrule->_opType ) return false; 645 646 if( strcmp(_matrule->_opType,"MemBarRelease") == 0 ) return true; 647 if( strcmp(_matrule->_opType,"MemBarAcquire") == 0 ) return true; 648 if( strcmp(_matrule->_opType,"MemBarReleaseLock") == 0 ) return true; 649 if( strcmp(_matrule->_opType,"MemBarAcquireLock") == 0 ) return true; 650 if( strcmp(_matrule->_opType,"MemBarStoreStore") == 0 ) return true; 651 if( strcmp(_matrule->_opType,"StoreFence") == 0 ) return true; 652 if( strcmp(_matrule->_opType,"LoadFence") == 0 ) return true; 653 654 return false; 655 } 656 657 int InstructForm::memory_operand(FormDict &globals) const { 658 // Machine independent loads must be checked for anti-dependences 659 // Check if instruction has a USE of a memory operand class, or a def. 660 int USE_of_memory = 0; 661 int DEF_of_memory = 0; 662 const char* last_memory_DEF = NULL; // to test DEF/USE pairing in asserts 663 Component *unique = NULL; 664 Component *comp = NULL; 665 ComponentList &components = (ComponentList &)_components; 666 667 components.reset(); 668 while( (comp = components.iter()) != NULL ) { 669 const Form *form = globals[comp->_type]; 670 if( !form ) continue; 671 OpClassForm *op = form->is_opclass(); 672 if( !op ) continue; 673 if( op->stack_slots_only(globals) ) continue; 674 if( form->interface_type(globals) == Form::memory_interface ) { 675 if( comp->isa(Component::DEF) ) { 676 last_memory_DEF = comp->_name; 677 DEF_of_memory++; 678 unique = comp; 679 } else if( comp->isa(Component::USE) ) { 680 if( last_memory_DEF != NULL ) { 681 assert(0 == strcmp(last_memory_DEF, comp->_name), "every memory DEF is followed by a USE of the same name"); 682 last_memory_DEF = NULL; 683 } 684 USE_of_memory++; 685 if (DEF_of_memory == 0) // defs take precedence 686 unique = comp; 687 } else { 688 assert(last_memory_DEF == NULL, "unpaired memory DEF"); 689 } 690 } 691 } 692 assert(last_memory_DEF == NULL, "unpaired memory DEF"); 693 assert(USE_of_memory >= DEF_of_memory, "unpaired memory DEF"); 694 USE_of_memory -= DEF_of_memory; // treat paired DEF/USE as one occurrence 695 if( (USE_of_memory + DEF_of_memory) > 0 ) { 696 if( is_simple_chain_rule(globals) ) { 697 //fprintf(stderr, "Warning: chain rule is not really a memory user.\n"); 698 //((InstructForm*)this)->dump(); 699 // Preceding code prints nothing on sparc and these insns on intel: 700 // leaP8 leaP32 leaPIdxOff leaPIdxScale leaPIdxScaleOff leaP8 leaP32 701 // leaPIdxOff leaPIdxScale leaPIdxScaleOff 702 return NO_MEMORY_OPERAND; 703 } 704 | 643 if( _matrule == NULL ) return false; 644 if( !_matrule->_opType ) return false; 645 646 if( strcmp(_matrule->_opType,"MemBarRelease") == 0 ) return true; 647 if( strcmp(_matrule->_opType,"MemBarAcquire") == 0 ) return true; 648 if( strcmp(_matrule->_opType,"MemBarReleaseLock") == 0 ) return true; 649 if( strcmp(_matrule->_opType,"MemBarAcquireLock") == 0 ) return true; 650 if( strcmp(_matrule->_opType,"MemBarStoreStore") == 0 ) return true; 651 if( strcmp(_matrule->_opType,"StoreFence") == 0 ) return true; 652 if( strcmp(_matrule->_opType,"LoadFence") == 0 ) return true; 653 654 return false; 655 } 656 657 int InstructForm::memory_operand(FormDict &globals) const { 658 // Machine independent loads must be checked for anti-dependences 659 // Check if instruction has a USE of a memory operand class, or a def. 660 int USE_of_memory = 0; 661 int DEF_of_memory = 0; 662 const char* last_memory_DEF = NULL; // to test DEF/USE pairing in asserts 663 const char* last_memory_USE = NULL; 664 Component *unique = NULL; 665 Component *comp = NULL; 666 ComponentList &components = (ComponentList &)_components; 667 668 components.reset(); 669 while( (comp = components.iter()) != NULL ) { 670 const Form *form = globals[comp->_type]; 671 if( !form ) continue; 672 OpClassForm *op = form->is_opclass(); 673 if( !op ) continue; 674 if( op->stack_slots_only(globals) ) continue; 675 if( form->interface_type(globals) == Form::memory_interface ) { 676 if( comp->isa(Component::DEF) ) { 677 last_memory_DEF = comp->_name; 678 DEF_of_memory++; 679 unique = comp; 680 } else if( comp->isa(Component::USE) ) { 681 if( last_memory_DEF != NULL ) { 682 assert(0 == strcmp(last_memory_DEF, comp->_name), "every memory DEF is followed by a USE of the same name"); 683 last_memory_DEF = NULL; 684 } 685 // Handles same memory being used multiple times in the case of BMI1 instructions. 686 if (last_memory_USE != NULL) { 687 if (strcmp(comp->_name, last_memory_USE) != 0) { 688 USE_of_memory++; 689 } 690 } else { 691 USE_of_memory++; 692 } 693 last_memory_USE = comp->_name; 694 695 if (DEF_of_memory == 0) // defs take precedence 696 unique = comp; 697 } else { 698 assert(last_memory_DEF == NULL, "unpaired memory DEF"); 699 } 700 } 701 } 702 assert(last_memory_DEF == NULL, "unpaired memory DEF"); 703 assert(USE_of_memory >= DEF_of_memory, "unpaired memory DEF"); 704 USE_of_memory -= DEF_of_memory; // treat paired DEF/USE as one occurrence 705 if( (USE_of_memory + DEF_of_memory) > 0 ) { 706 if( is_simple_chain_rule(globals) ) { 707 //fprintf(stderr, "Warning: chain rule is not really a memory user.\n"); 708 //((InstructForm*)this)->dump(); 709 // Preceding code prints nothing on sparc and these insns on intel: 710 // leaP8 leaP32 leaPIdxOff leaPIdxScale leaPIdxScaleOff leaP8 leaP32 711 // leaPIdxOff leaPIdxScale leaPIdxScaleOff 712 return NO_MEMORY_OPERAND; 713 } 714 |