1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Added support for decomposing constant expressions containing shr and shl

instructions.
Review of this commit would be greatly appreciated.

llvm-svn: 21876
This commit is contained in:
John Criswell 2005-05-11 21:16:42 +00:00
parent 8f2d079b36
commit 38c97a63d4

View File

@ -146,6 +146,30 @@ static Instruction* DecomposeConstantExpr(ConstantExpr* CE,
return new SelectInst (C, S1, S2, "constantSelect", &insertBefore);
}
case Instruction::Shr: {
getArg1 = CE->getOperand(0);
if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg1))
getArg1 = DecomposeConstantExpr(CEarg, insertBefore);
getArg2 = CE->getOperand(1);
if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg2))
getArg2 = DecomposeConstantExpr(CEarg, insertBefore);
return new ShiftInst (static_cast<Instruction::OtherOps>(CE->getOpcode()),
getArg1, getArg2,
"constantShr:" + getArg1->getName(), &insertBefore);
}
case Instruction::Shl: {
getArg1 = CE->getOperand(0);
if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg1))
getArg1 = DecomposeConstantExpr(CEarg, insertBefore);
getArg2 = CE->getOperand(1);
if (ConstantExpr* CEarg = dyn_cast<ConstantExpr>(getArg2))
getArg2 = DecomposeConstantExpr(CEarg, insertBefore);
return new ShiftInst (static_cast<Instruction::OtherOps>(CE->getOpcode()),
getArg1, getArg2,
"constantShl:" + getArg1->getName(), &insertBefore);
}
default: // must be a binary operator
assert(CE->getOpcode() >= Instruction::BinaryOpsBegin &&
CE->getOpcode() < Instruction::BinaryOpsEnd &&