diff options
author | Sean Callanan <scallanan@apple.com> | 2013-06-05 22:07:06 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2013-06-05 22:07:06 +0000 |
commit | 415422ce76eed799fd80ca4f6afb49bce6137f75 (patch) | |
tree | 8b8d417d23fd394fb7e7aaf3a17016807f33cdfc /lldb/source/Expression/IRInterpreter.cpp | |
parent | dec18752075e45531d8ff69a8ac5f40ff98fc0d7 (diff) | |
download | bcm5719-llvm-415422ce76eed799fd80ca4f6afb49bce6137f75.tar.gz bcm5719-llvm-415422ce76eed799fd80ca4f6afb49bce6137f75.zip |
Fixes for the IR interpreter:
- Implemented the SExt instruction, and
- eliminated redundant codepaths for constant
handling.
Added test cases.
<rdar://problem/13244258>
<rdar://problem/13955820>
llvm-svn: 183344
Diffstat (limited to 'lldb/source/Expression/IRInterpreter.cpp')
-rw-r--r-- | lldb/source/Expression/IRInterpreter.cpp | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 122d337ddcc..9cb7bc0a29a 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -151,14 +151,12 @@ public: if (constant) { - if (isa<ConstantPointerNull>(constant)) - { - return AssignToMatchType(scalar, 0, value->getType()); - } - else if (const ConstantInt *constant_int = dyn_cast<ConstantInt>(constant)) - { - return AssignToMatchType(scalar, constant_int->getLimitedValue(), value->getType()); - } + APInt value_apint; + + if (!ResolveConstantValue(value_apint, constant)) + return false; + + return AssignToMatchType(scalar, value_apint.getLimitedValue(), value->getType()); } else { @@ -500,6 +498,7 @@ IRInterpreter::CanInterpret (llvm::Module &module, case Instruction::Or: case Instruction::Ret: case Instruction::SDiv: + case Instruction::SExt: case Instruction::Shl: case Instruction::SRem: case Instruction::Store: @@ -821,6 +820,39 @@ IRInterpreter::Interpret (llvm::Module &module, frame.AssignValue(inst, S, module); } break; + case Instruction::SExt: + { + const CastInst *cast_inst = dyn_cast<CastInst>(inst); + + if (!cast_inst) + { + if (log) + log->Printf("getOpcode() returns %s, but instruction is not a BitCastInst", cast_inst->getOpcodeName()); + error.SetErrorToGenericError(); + error.SetErrorString(interpreter_internal_error); + return false; + } + + Value *source = cast_inst->getOperand(0); + + lldb_private::Scalar S; + + if (!frame.EvaluateValue(S, source, module)) + { + if (log) + log->Printf("Couldn't evaluate %s", PrintValue(source).c_str()); + error.SetErrorToGenericError(); + error.SetErrorString(bad_value_error); + return false; + } + + S.MakeSigned(); + + lldb_private::Scalar S_signextend(S.SLongLong()); + + frame.AssignValue(inst, S_signextend, module); + } + break; case Instruction::Br: { const BranchInst *br_inst = dyn_cast<BranchInst>(inst); |