aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/ValueMapper.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-14 22:21:31 +0000
committerChris Lattner <sabre@nondot.org>2006-07-14 22:21:31 +0000
commit27d672136a57519095a3ef20161697749cffb57c (patch)
tree71f1e15a65b625bc7344c58b79f1f24efb169927 /lib/Transforms/Utils/ValueMapper.cpp
parentb88a7fbdf6365a6d7a4ad334b8411462ae851924 (diff)
downloadexternal_llvm-27d672136a57519095a3ef20161697749cffb57c.zip
external_llvm-27d672136a57519095a3ef20161697749cffb57c.tar.gz
external_llvm-27d672136a57519095a3ef20161697749cffb57c.tar.bz2
eliminate some ugly code, using ConstantExpr::getWithOperands instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29149 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r--lib/Transforms/Utils/ValueMapper.cpp39
1 files changed, 4 insertions, 35 deletions
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp
index d4be6e4..f8afabc 100644
--- a/lib/Transforms/Utils/ValueMapper.cpp
+++ b/lib/Transforms/Utils/ValueMapper.cpp
@@ -71,41 +71,10 @@ Value *llvm::MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
return VMSlot = C;
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
- if (CE->getOpcode() == Instruction::Cast) {
- Constant *MV = cast<Constant>(MapValue(CE->getOperand(0), VM));
- return VMSlot = ConstantExpr::getCast(MV, CE->getType());
- } else if (CE->getOpcode() == Instruction::GetElementPtr) {
- std::vector<Constant*> Idx;
- Constant *MV = cast<Constant>(MapValue(CE->getOperand(0), VM));
- for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
- Idx.push_back(cast<Constant>(MapValue(CE->getOperand(i), VM)));
- return VMSlot = ConstantExpr::getGetElementPtr(MV, Idx);
- } else if (CE->getOpcode() == Instruction::Select) {
- Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
- Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
- Constant *MV3 = cast<Constant>(MapValue(CE->getOperand(2), VM));
- return VMSlot = ConstantExpr::getSelect(MV1, MV2, MV3);
- } else if (CE->getOpcode() == Instruction::InsertElement) {
- Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
- Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
- Constant *MV3 = cast<Constant>(MapValue(CE->getOperand(2), VM));
- return VMSlot = ConstantExpr::getInsertElement(MV1, MV2, MV3);
- } else if (CE->getOpcode() == Instruction::ExtractElement) {
- Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
- Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
- return VMSlot = ConstantExpr::getExtractElement(MV1, MV2);
- } else if (CE->getOpcode() == Instruction::ShuffleVector) {
- Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
- Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
- Constant *MV3 = cast<Constant>(CE->getOperand(2));
- return VMSlot = ConstantExpr::getShuffleVector(MV1, MV2, MV3);
- } else {
- assert(CE->getNumOperands() == 2 && "Must be binary operator?");
- Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
- Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
- return VMSlot = ConstantExpr::get(CE->getOpcode(), MV1, MV2);
- }
-
+ std::vector<Constant*> Ops;
+ for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i)
+ Ops.push_back(cast<Constant>(MapValue(CE->getOperand(i), VM)));
+ return VMSlot = CE->getWithOperands(Ops);
} else if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C)) {
for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i) {
Value *MV = MapValue(CP->getOperand(i), VM);