mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-26 22:34:39 +00:00
Add support for constant expr shifts
llvm-svn: 9735
This commit is contained in:
parent
7fa3523f55
commit
352ad83271
@ -182,6 +182,8 @@ Constant *BytecodeParser::parseConstantValue(const unsigned char *&Buf,
|
||||
} else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr
|
||||
std::vector<Constant*> IdxList(ArgVec.begin()+1, ArgVec.end());
|
||||
return ConstantExpr::getGetElementPtr(ArgVec[0], IdxList);
|
||||
} else if (Opcode == Instruction::Shl || Opcode == Instruction::Shr) {
|
||||
return ConstantExpr::getShift(Opcode, ArgVec[0], ArgVec[1]);
|
||||
} else { // All other 2-operand expressions
|
||||
return ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]);
|
||||
}
|
||||
|
@ -493,6 +493,13 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
|
||||
} else if (getOpcode() == Instruction::Cast) {
|
||||
assert(getOperand(0) == From && "Cast only has one use!");
|
||||
Replacement = ConstantExpr::getCast(To, getType());
|
||||
} else if (getOpcode() == Instruction::Shl ||
|
||||
getOpcode() == Instruction::Shr) {
|
||||
Constant *C1 = getOperand(0);
|
||||
Constant *C2 = getOperand(1);
|
||||
if (C1 == From) C1 = To;
|
||||
if (C2 == From) C2 = To;
|
||||
Replacement = ConstantExpr::getShift(getOpcode(), C1, C2);
|
||||
} else if (getNumOperands() == 2) {
|
||||
Constant *C1 = getOperand(0);
|
||||
Constant *C2 = getOperand(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user