718 if( is_ideal_store() != Form::none ) {
719 fprintf(stderr, "Warning: cannot find memory opnd in instr.\n");
720 ((InstructForm*)this)->dump();
721 // pretend it has multiple defs and uses
722 return MANY_MEMORY_OPERANDS;
723 }
724 if( is_ideal_load() != Form::none ) {
725 fprintf(stderr, "Warning: cannot find memory opnd in instr.\n");
726 ((InstructForm*)this)->dump();
727 // pretend it has multiple uses and no defs
728 return MANY_MEMORY_OPERANDS;
729 }
730 }
731
732 return NO_MEMORY_OPERAND;
733 }
734
735
736 // This instruction captures the machine-independent bottom_type
737 // Expected use is for pointer vs oop determination for LoadP
738 bool InstructForm::captures_bottom_type() const {
739 if( _matrule && _matrule->_rChild &&
740 (!strcmp(_matrule->_rChild->_opType,"CastPP") || // new result type
741 !strcmp(_matrule->_rChild->_opType,"CastX2P") || // new result type
742 !strcmp(_matrule->_rChild->_opType,"DecodeN") ||
743 !strcmp(_matrule->_rChild->_opType,"EncodeP") ||
744 !strcmp(_matrule->_rChild->_opType,"LoadN") ||
745 !strcmp(_matrule->_rChild->_opType,"LoadNKlass") ||
746 !strcmp(_matrule->_rChild->_opType,"CreateEx") || // type of exception
747 !strcmp(_matrule->_rChild->_opType,"CheckCastPP")) ) return true;
748 else if ( is_ideal_load() == Form::idealP ) return true;
749 else if ( is_ideal_store() != Form::none ) return true;
750
751 return false;
752 }
753
754
755 // Access instr_cost attribute or return NULL.
756 const char* InstructForm::cost() {
757 for (Attribute* cur = _attribs; cur != NULL; cur = (Attribute*)cur->_next) {
758 if( strcmp(cur->_ident,AttributeForm::_ins_cost) == 0 ) {
759 return cur->_val;
760 }
761 }
762 return NULL;
763 }
764
765 // Return count of top-level operands.
766 uint InstructForm::num_opnds() {
767 int num_opnds = _components.num_operands();
768
769 // Need special handling for matching some ideal nodes
770 // i.e. Matching a return node
1044 result = "Universe";
1045 }
1046 return result;
1047 }
1048
1049 // Return the name of the operand on the right hand side of the binary match
1050 // Return NULL if there is no right hand side
1051 const char *InstructForm::reduce_right(FormDict &globals) const {
1052 if( _matrule == NULL ) return NULL;
1053 return _matrule->reduce_right(globals);
1054 }
1055
1056 // Similar for left
1057 const char *InstructForm::reduce_left(FormDict &globals) const {
1058 if( _matrule == NULL ) return NULL;
1059 return _matrule->reduce_left(globals);
1060 }
1061
1062
1063 // Base class for this instruction, MachNode except for calls
1064 const char *InstructForm::mach_base_class() const {
1065 if( is_ideal_call() == Form::JAVA_STATIC ) {
1066 return "MachCallStaticJavaNode";
1067 }
1068 else if( is_ideal_call() == Form::JAVA_DYNAMIC ) {
1069 return "MachCallDynamicJavaNode";
1070 }
1071 else if( is_ideal_call() == Form::JAVA_RUNTIME ) {
1072 return "MachCallRuntimeNode";
1073 }
1074 else if( is_ideal_call() == Form::JAVA_LEAF ) {
1075 return "MachCallLeafNode";
1076 }
1077 else if (is_ideal_return()) {
1078 return "MachReturnNode";
1079 }
1080 else if (is_ideal_halt()) {
1081 return "MachHaltNode";
1082 }
1083 else if (is_ideal_safepoint()) {
1084 return "MachSafePointNode";
1085 }
1086 else if (is_ideal_if()) {
1087 return "MachIfNode";
1088 }
1089 else if (is_ideal_fastlock()) {
1090 return "MachFastLockNode";
1091 }
1092 else if (is_ideal_nop()) {
1093 return "MachNopNode";
1094 }
1095 else if (captures_bottom_type()) {
1096 return "MachTypeNode";
1097 } else {
1098 return "MachNode";
1099 }
1100 assert( false, "ShouldNotReachHere()");
1101 return NULL;
1102 }
1103
1104 // Compare the instruction predicates for textual equality
1105 bool equivalent_predicates( const InstructForm *instr1, const InstructForm *instr2 ) {
1106 const Predicate *pred1 = instr1->_predicate;
1107 const Predicate *pred2 = instr2->_predicate;
1108 if( pred1 == NULL && pred2 == NULL ) {
1109 // no predicates means they are identical
1110 return true;
1111 }
1112 if( pred1 != NULL && pred2 != NULL ) {
1113 // compare the predicates
1114 if (ADLParser::equivalent_expressions(pred1->_pred, pred2->_pred)) {
1115 return true;
|
718 if( is_ideal_store() != Form::none ) {
719 fprintf(stderr, "Warning: cannot find memory opnd in instr.\n");
720 ((InstructForm*)this)->dump();
721 // pretend it has multiple defs and uses
722 return MANY_MEMORY_OPERANDS;
723 }
724 if( is_ideal_load() != Form::none ) {
725 fprintf(stderr, "Warning: cannot find memory opnd in instr.\n");
726 ((InstructForm*)this)->dump();
727 // pretend it has multiple uses and no defs
728 return MANY_MEMORY_OPERANDS;
729 }
730 }
731
732 return NO_MEMORY_OPERAND;
733 }
734
735
736 // This instruction captures the machine-independent bottom_type
737 // Expected use is for pointer vs oop determination for LoadP
738 bool InstructForm::captures_bottom_type(FormDict &globals) const {
739 if( _matrule && _matrule->_rChild &&
740 (!strcmp(_matrule->_rChild->_opType,"CastPP") || // new result type
741 !strcmp(_matrule->_rChild->_opType,"CastX2P") || // new result type
742 !strcmp(_matrule->_rChild->_opType,"DecodeN") ||
743 !strcmp(_matrule->_rChild->_opType,"EncodeP") ||
744 !strcmp(_matrule->_rChild->_opType,"LoadN") ||
745 !strcmp(_matrule->_rChild->_opType,"LoadNKlass") ||
746 !strcmp(_matrule->_rChild->_opType,"CreateEx") || // type of exception
747 !strcmp(_matrule->_rChild->_opType,"CheckCastPP")) ) return true;
748 else if ( is_ideal_load() == Form::idealP ) return true;
749 else if ( is_ideal_store() != Form::none ) return true;
750
751 if (needs_base_oop_edge(globals)) return true;
752
753 return false;
754 }
755
756
757 // Access instr_cost attribute or return NULL.
758 const char* InstructForm::cost() {
759 for (Attribute* cur = _attribs; cur != NULL; cur = (Attribute*)cur->_next) {
760 if( strcmp(cur->_ident,AttributeForm::_ins_cost) == 0 ) {
761 return cur->_val;
762 }
763 }
764 return NULL;
765 }
766
767 // Return count of top-level operands.
768 uint InstructForm::num_opnds() {
769 int num_opnds = _components.num_operands();
770
771 // Need special handling for matching some ideal nodes
772 // i.e. Matching a return node
1046 result = "Universe";
1047 }
1048 return result;
1049 }
1050
1051 // Return the name of the operand on the right hand side of the binary match
1052 // Return NULL if there is no right hand side
1053 const char *InstructForm::reduce_right(FormDict &globals) const {
1054 if( _matrule == NULL ) return NULL;
1055 return _matrule->reduce_right(globals);
1056 }
1057
1058 // Similar for left
1059 const char *InstructForm::reduce_left(FormDict &globals) const {
1060 if( _matrule == NULL ) return NULL;
1061 return _matrule->reduce_left(globals);
1062 }
1063
1064
1065 // Base class for this instruction, MachNode except for calls
1066 const char *InstructForm::mach_base_class(FormDict &globals) const {
1067 if( is_ideal_call() == Form::JAVA_STATIC ) {
1068 return "MachCallStaticJavaNode";
1069 }
1070 else if( is_ideal_call() == Form::JAVA_DYNAMIC ) {
1071 return "MachCallDynamicJavaNode";
1072 }
1073 else if( is_ideal_call() == Form::JAVA_RUNTIME ) {
1074 return "MachCallRuntimeNode";
1075 }
1076 else if( is_ideal_call() == Form::JAVA_LEAF ) {
1077 return "MachCallLeafNode";
1078 }
1079 else if (is_ideal_return()) {
1080 return "MachReturnNode";
1081 }
1082 else if (is_ideal_halt()) {
1083 return "MachHaltNode";
1084 }
1085 else if (is_ideal_safepoint()) {
1086 return "MachSafePointNode";
1087 }
1088 else if (is_ideal_if()) {
1089 return "MachIfNode";
1090 }
1091 else if (is_ideal_fastlock()) {
1092 return "MachFastLockNode";
1093 }
1094 else if (is_ideal_nop()) {
1095 return "MachNopNode";
1096 }
1097 else if (captures_bottom_type(globals)) {
1098 return "MachTypeNode";
1099 } else {
1100 return "MachNode";
1101 }
1102 assert( false, "ShouldNotReachHere()");
1103 return NULL;
1104 }
1105
1106 // Compare the instruction predicates for textual equality
1107 bool equivalent_predicates( const InstructForm *instr1, const InstructForm *instr2 ) {
1108 const Predicate *pred1 = instr1->_predicate;
1109 const Predicate *pred2 = instr2->_predicate;
1110 if( pred1 == NULL && pred2 == NULL ) {
1111 // no predicates means they are identical
1112 return true;
1113 }
1114 if( pred1 != NULL && pred2 != NULL ) {
1115 // compare the predicates
1116 if (ADLParser::equivalent_expressions(pred1->_pred, pred2->_pred)) {
1117 return true;
|