summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
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
commit19247f36eac66acb171a1fb9cacc679a0ab886cb (patch)
treed14080e34f55da6689bf783c480d8ddc76938f2b /llvm/lib/Transforms/Utils
parent227816348c7422a7006851d92c231815128a429e (diff)
downloadbcm5719-llvm-19247f36eac66acb171a1fb9cacc679a0ab886cb.tar.gz
bcm5719-llvm-19247f36eac66acb171a1fb9cacc679a0ab886cb.zip
eliminate some ugly code, using ConstantExpr::getWithOperands instead.
llvm-svn: 29149
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp39
1 files changed, 4 insertions, 35 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index d4be6e47ef0..f8afabc75f7 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud