Index: source/Expression/IRInterpreter.cpp =================================================================== --- source/Expression/IRInterpreter.cpp +++ source/Expression/IRInterpreter.cpp @@ -217,7 +217,9 @@ lldb_private::Scalar cast_scalar; - if (!AssignToMatchType(cast_scalar, scalar.ULongLong(), value->getType())) + if (value->getType()->isDoubleTy()) + cast_scalar = scalar.Double(); + else if (!AssignToMatchType(cast_scalar, scalar.ULongLong(), value->getType())) return false; size_t value_byte_size = m_target_data.getTypeStoreSize(value->getType()); @@ -592,6 +594,8 @@ } break; case Instruction::And: case Instruction::AShr: + case Instruction::FCmp: + case Instruction::FPExt: case Instruction::IntToPtr: case Instruction::PtrToInt: case Instruction::Load: @@ -602,12 +606,14 @@ case Instruction::SDiv: case Instruction::SExt: case Instruction::Shl: + case Instruction::SIToFP: case Instruction::SRem: case Instruction::Store: case Instruction::Sub: case Instruction::Trunc: case Instruction::UDiv: case Instruction::URem: + case Instruction::UIToFP: case Instruction::Xor: case Instruction::ZExt: break; @@ -918,6 +924,51 @@ frame.AssignValue(inst, S, module); } break; + case Instruction::FPExt: + case Instruction::SIToFP: + case Instruction::UIToFP: { + const CastInst *cast_inst = dyn_cast(inst); + + if (!cast_inst) { + if (log) + log->Printf("Instruction is not a CastInst"); + 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; + } + + lldb_private::Scalar result; + double result_double; + + switch (inst->getOpcode()) { + default: + break; + case Instruction::FPExt: + result_double = static_cast(S.Float()); + break; + case Instruction::SIToFP: + result_double = static_cast(S.SInt()); + break; + case Instruction::UIToFP: + result_double = static_cast(S.UInt()); + break; + } + + lldb_private::Scalar Scalar_Double(result_double); + frame.AssignValue(inst, Scalar_Double, module); + } break; case Instruction::SExt: { const CastInst *cast_inst = dyn_cast(inst); @@ -1104,20 +1155,38 @@ log->Printf(" Poffset : %s", frame.SummarizeValue(inst).c_str()); } } break; + case Instruction::FCmp: case Instruction::ICmp: { - const ICmpInst *icmp_inst = dyn_cast(inst); + CmpInst::Predicate predicate; - if (!icmp_inst) { - if (log) + char cmp_type = 0; + if (inst->getOpcode() == Instruction::FCmp) { + const FCmpInst *fcmp_inst = dyn_cast(inst); + + if (fcmp_inst) { + predicate = fcmp_inst->getPredicate(); + cmp_type = 'F'; + } + } else { + const ICmpInst *icmp_inst = dyn_cast(inst); + + if (icmp_inst) { + predicate = icmp_inst->getPredicate(); + cmp_type = 'I'; + } + } + + if (! cmp_type) { + if (log) { log->Printf( - "getOpcode() returns ICmp, but instruction is not an ICmpInst"); + "getOpcode() returns %cCmp, but instruction is not an %cCmpInst", + cmp_type, cmp_type); + } error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; } - CmpInst::Predicate predicate = icmp_inst->getPredicate(); - Value *lhs = inst->getOperand(0); Value *rhs = inst->getOperand(1); @@ -1145,47 +1214,57 @@ switch (predicate) { default: return false; + case CmpInst::FCMP_OEQ: case CmpInst::ICMP_EQ: result = (L == R); break; + case CmpInst::FCMP_ONE: case CmpInst::ICMP_NE: result = (L != R); break; + case CmpInst::FCMP_UGT: case CmpInst::ICMP_UGT: L.MakeUnsigned(); R.MakeUnsigned(); result = (L > R); break; + case CmpInst::FCMP_UGE: case CmpInst::ICMP_UGE: L.MakeUnsigned(); R.MakeUnsigned(); result = (L >= R); break; + case CmpInst::FCMP_ULT: case CmpInst::ICMP_ULT: L.MakeUnsigned(); R.MakeUnsigned(); result = (L < R); break; + case CmpInst::FCMP_ULE: case CmpInst::ICMP_ULE: L.MakeUnsigned(); R.MakeUnsigned(); result = (L <= R); break; + case CmpInst::FCMP_OGT: case CmpInst::ICMP_SGT: L.MakeSigned(); R.MakeSigned(); result = (L > R); break; + case CmpInst::FCMP_OGE: case CmpInst::ICMP_SGE: L.MakeSigned(); R.MakeSigned(); result = (L >= R); break; + case CmpInst::FCMP_OLT: case CmpInst::ICMP_SLT: L.MakeSigned(); R.MakeSigned(); result = (L < R); break; + case CmpInst::FCMP_OLE: case CmpInst::ICMP_SLE: L.MakeSigned(); R.MakeSigned(); @@ -1196,7 +1275,7 @@ frame.AssignValue(inst, result, module); if (log) { - log->Printf("Interpreted an ICmpInst"); + log->Printf("Interpreted an %cCmpInst", cmp_type); log->Printf(" L : %s", frame.SummarizeValue(lhs).c_str()); log->Printf(" R : %s", frame.SummarizeValue(rhs).c_str()); log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());