llvm.org GIT mirror llvm / 23f3a49
Implement "unsafe" replaceAllUsesWWith stuff for use during type resolution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8209 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 34 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
349349
350350 // TODO: Figure out how to test if a double can be cast to a float!
351351 case Type::FloatTyID:
352 /*
353 return (Val <= UINT8_MAX);
354 */
355352 case Type::DoubleTyID:
356353 return true; // This is the largest type...
357354 }
360357 //===----------------------------------------------------------------------===//
361358 // replaceUsesOfWithOnConstant implementations
362359
363 void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To) {
360 void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To,
361 bool DisableChecking) {
364362 assert(isa(To) && "Cannot make Constant refer to non-constant!");
365363
366364 std::vector Values;
375373 assert(Replacement != this && "I didn't contain From!");
376374
377375 // Everyone using this now uses the replacement...
378 replaceAllUsesWith(Replacement);
376 if (DisableChecking)
377 uncheckedReplaceAllUsesWith(Replacement);
378 else
379 replaceAllUsesWith(Replacement);
379380
380381 // Delete the old constant!
381382 destroyConstant();
382383 }
383384
384 void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To) {
385 void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To,
386 bool DisableChecking) {
385387 assert(isa(To) && "Cannot make Constant refer to non-constant!");
386388
387389 std::vector Values;
396398 assert(Replacement != this && "I didn't contain From!");
397399
398400 // Everyone using this now uses the replacement...
399 replaceAllUsesWith(Replacement);
401 if (DisableChecking)
402 uncheckedReplaceAllUsesWith(Replacement);
403 else
404 replaceAllUsesWith(Replacement);
400405
401406 // Delete the old constant!
402407 destroyConstant();
403408 }
404409
405 void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To) {
410 void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To,
411 bool DisableChecking) {
406412 if (isa(To)) {
407413 assert(From == getOperand(0) && "Doesn't contain from!");
408414 ConstantPointerRef *Replacement =
409415 ConstantPointerRef::get(cast(To));
410416
411417 // Everyone using this now uses the replacement...
412 replaceAllUsesWith(Replacement);
418 if (DisableChecking)
419 uncheckedReplaceAllUsesWith(Replacement);
420 else
421 replaceAllUsesWith(Replacement);
413422
414 // Delete the old constant!
415 destroyConstant();
416423 } else {
417424 // Just replace ourselves with the To value specified.
418 replaceAllUsesWith(To);
419
420 // Delete the old constant!
421 destroyConstant();
422 }
423 }
424
425 void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV) {
425 if (DisableChecking)
426 uncheckedReplaceAllUsesWith(To);
427 else
428 replaceAllUsesWith(To);
429 }
430
431 // Delete the old constant!
432 destroyConstant();
433 }
434
435 void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
436 bool DisableChecking) {
426437 assert(isa(ToV) && "Cannot make Constant refer to non-constant!");
427438 Constant *To = cast(ToV);
428439
456467 assert(Replacement != this && "I didn't contain From!");
457468
458469 // Everyone using this now uses the replacement...
459 replaceAllUsesWith(Replacement);
470 if (DisableChecking)
471 uncheckedReplaceAllUsesWith(Replacement);
472 else
473 replaceAllUsesWith(Replacement);
460474
461475 // Delete the old constant!
462476 destroyConstant();