aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-20 11:40:37 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-20 11:40:37 -0800
commit5d45c0152fcfbdcc2acc37047069f024eb61a2f4 (patch)
tree687da9415bc7c63f8b30764e6b53bc18d1240794
parentc8c548f4a626f9a313b43bcae6037806be3ae894 (diff)
fix lshr on <32 bits
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 51ee969d8b..588b54e907 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -833,14 +833,15 @@ std::string JSWriter::generateInstruction(const Instruction *I) {
text += Shifted;
break;
}
- case Instruction::AShr: {
+ case Instruction::AShr:
+ case Instruction::LShr: {
std::string Input = getValueAsStr(I->getOperand(0));
if (I->getType()->getIntegerBitWidth() < 32) {
- Input = getParenCast(Input, I->getType(), ASM_SIGNED); // fill in high bits, as shift needs those and is done in 32-bit
+ Input = getParenCast(Input, I->getType(), opcode == Instruction::AShr ? ASM_SIGNED : ASM_UNSIGNED); // fill in high bits, as shift needs those and is done in 32-bit
}
- text += Input + " >> " + getValueAsStr(I->getOperand(1)); break;
+ text += Input + (opcode == Instruction::AShr ? " >> " : " >>> ") + getValueAsStr(I->getOperand(1));
+ break;
}
- case Instruction::LShr: text += getValueAsStr(I->getOperand(0)) + " >>> " + getValueAsStr(I->getOperand(1)); break;
case Instruction::FAdd: text += getValueAsStr(I->getOperand(0)) + " + " + getValueAsStr(I->getOperand(1)); break; // TODO: ensurefloat here
case Instruction::FSub: text += getValueAsStr(I->getOperand(0)) + " - " + getValueAsStr(I->getOperand(1)); break;
case Instruction::FMul: text += getValueAsStr(I->getOperand(0)) + " * " + getValueAsStr(I->getOperand(1)); break;