Implemented TruncInst in the IRInterpreter.

<rdar://problem/15188389>

llvm-svn: 192489
This commit is contained in:
Sean Callanan 2013-10-11 19:45:00 +00:00
parent 00dec20f7d
commit 8c46baca65
1 changed files with 37 additions and 0 deletions

View File

@ -524,6 +524,7 @@ IRInterpreter::CanInterpret (llvm::Module &module,
case Instruction::SRem:
case Instruction::Store:
case Instruction::Sub:
case Instruction::Trunc:
case Instruction::UDiv:
case Instruction::URem:
case Instruction::Xor:
@ -1169,6 +1170,42 @@ IRInterpreter::Interpret (llvm::Module &module,
}
}
break;
case Instruction::Trunc:
{
const TruncInst *trunc_inst = dyn_cast<TruncInst>(inst);
if (!trunc_inst)
{
if (log)
log->Printf("getOpcode() returns Trunc, but instruction is not a TruncInst");
error.SetErrorToGenericError();
error.SetErrorString(interpreter_internal_error);
return false;
}
Value *src_operand = trunc_inst->getOperand(0);
lldb_private::Scalar I;
if (!frame.EvaluateValue(I, src_operand, module))
{
if (log)
log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str());
error.SetErrorToGenericError();
error.SetErrorString(bad_value_error);
return false;
}
frame.AssignValue(inst, I, module);
if (log)
{
log->Printf("Interpreted a Trunc");
log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str());
log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());
}
}
break;
case Instruction::Load:
{
const LoadInst *load_inst = dyn_cast<LoadInst>(inst);