[Lldb-commits] [lldb] r192489 - Implemented TruncInst in the IRInterpreter.

Sean Callanan scallanan at apple.com
Fri Oct 11 12:45:01 PDT 2013


Author: spyffe
Date: Fri Oct 11 14:45:00 2013
New Revision: 192489

URL: http://llvm.org/viewvc/llvm-project?rev=192489&view=rev
Log:
Implemented TruncInst in the IRInterpreter.

<rdar://problem/15188389>

Modified:
    lldb/trunk/source/Expression/IRInterpreter.cpp

Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=192489&r1=192488&r2=192489&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Fri Oct 11 14:45:00 2013
@@ -524,6 +524,7 @@ IRInterpreter::CanInterpret (llvm::Modul
             case Instruction::SRem:
             case Instruction::Store:
             case Instruction::Sub:
+            case Instruction::Trunc:
             case Instruction::UDiv:
             case Instruction::URem:
             case Instruction::Xor:
@@ -1167,6 +1168,42 @@ IRInterpreter::Interpret (llvm::Module &
                     log->Printf("  Src : %s", frame.SummarizeValue(src_operand).c_str());
                     log->Printf("  =   : %s", frame.SummarizeValue(inst).c_str());
                 }
+            }
+                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:





More information about the lldb-commits mailing list