src/share/vm/adlc/formssel.cpp

changeset 1034
0ad1cb407fa1
parent 993
3b5ac9e7e6ea
child 1037
ed6404fac86b
equal deleted inserted replaced
1022:e57b6f22d1f3 1034:0ad1cb407fa1
1215 } 1215 }
1216 1216
1217 // Seach through operands to determine parameters unique positions. 1217 // Seach through operands to determine parameters unique positions.
1218 void InstructForm::set_unique_opnds() { 1218 void InstructForm::set_unique_opnds() {
1219 uint* uniq_idx = NULL; 1219 uint* uniq_idx = NULL;
1220 uint nopnds = num_opnds(); 1220 int nopnds = num_opnds();
1221 uint num_uniq = nopnds; 1221 uint num_uniq = nopnds;
1222 uint i; 1222 int i;
1223 _uniq_idx_length = 0;
1223 if ( nopnds > 0 ) { 1224 if ( nopnds > 0 ) {
1224 // Allocate index array with reserve. 1225 // Allocate index array. Worst case we're mapping from each
1225 uniq_idx = (uint*) malloc(sizeof(uint)*(nopnds + 2)); 1226 // component back to an index and any DEF always goes at 0 so the
1226 for( i = 0; i < nopnds+2; i++ ) { 1227 // length of the array has to be the number of components + 1.
1228 _uniq_idx_length = _components.count() + 1;
1229 uniq_idx = (uint*) malloc(sizeof(uint)*(_uniq_idx_length));
1230 for( i = 0; i < _uniq_idx_length; i++ ) {
1227 uniq_idx[i] = i; 1231 uniq_idx[i] = i;
1228 } 1232 }
1229 } 1233 }
1230 // Do it only if there is a match rule and no expand rule. With an 1234 // Do it only if there is a match rule and no expand rule. With an
1231 // expand rule it is done by creating new mach node in Expand() 1235 // expand rule it is done by creating new mach node in Expand()
1236 bool has_dupl_use = false; 1240 bool has_dupl_use = false;
1237 1241
1238 _parameters.reset(); 1242 _parameters.reset();
1239 while( (name = _parameters.iter()) != NULL ) { 1243 while( (name = _parameters.iter()) != NULL ) {
1240 count = 0; 1244 count = 0;
1241 uint position = 0; 1245 int position = 0;
1242 uint uniq_position = 0; 1246 int uniq_position = 0;
1243 _components.reset(); 1247 _components.reset();
1244 Component *comp = NULL; 1248 Component *comp = NULL;
1245 if( sets_result() ) { 1249 if( sets_result() ) {
1246 comp = _components.iter(); 1250 comp = _components.iter();
1247 position++; 1251 position++;
1253 if ( position==0 && (! comp->isa(Component::DEF)) ) { 1257 if ( position==0 && (! comp->isa(Component::DEF)) ) {
1254 ++position; 1258 ++position;
1255 } 1259 }
1256 if( strcmp(name, comp->_name)==0 ) { 1260 if( strcmp(name, comp->_name)==0 ) {
1257 if( ++count > 1 ) { 1261 if( ++count > 1 ) {
1262 assert(position < _uniq_idx_length, "out of bounds");
1258 uniq_idx[position] = uniq_position; 1263 uniq_idx[position] = uniq_position;
1259 has_dupl_use = true; 1264 has_dupl_use = true;
1260 } else { 1265 } else {
1261 uniq_position = position; 1266 uniq_position = position;
1262 } 1267 }

mercurial