#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cmath>
// Various Helper Functions
//===----------------------------------------------------------------------===//
-static inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
- // Determine if the value is signed or not
- bool isSigned = (Val & (1 << (ITy->getBitWidth()-1))) != 0;
- // If its signed, extend the sign bits
- if (isSigned)
- Val |= ~ITy->getBitMask();
- return Val;
-}
-
static void SetValue(Value *V, GenericValue Val, ExecutionContext &SF) {
SF.Values[V] = Val;
}
IMPLEMENT_BINARY_OPERATOR(+, Double);
default:
cerr << "Unhandled type for FAdd instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
IMPLEMENT_BINARY_OPERATOR(-, Double);
default:
cerr << "Unhandled type for FSub instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
IMPLEMENT_BINARY_OPERATOR(*, Double);
default:
cerr << "Unhandled type for FMul instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
IMPLEMENT_BINARY_OPERATOR(/, Double);
default:
cerr << "Unhandled type for FDiv instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
break;
default:
cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
IMPLEMENT_POINTER_ICMP(==);
default:
cerr << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(!=);
default:
cerr << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(<);
default:
cerr << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(<);
default:
cerr << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(>);
default:
cerr << "Unhandled type for ICMP_UGT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(>);
default:
cerr << "Unhandled type for ICMP_SGT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(<=);
default:
cerr << "Unhandled type for ICMP_ULE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(<=);
default:
cerr << "Unhandled type for ICMP_SLE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(>=);
default:
cerr << "Unhandled type for ICMP_UGE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_POINTER_ICMP(>=);
default:
cerr << "Unhandled type for ICMP_SGE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
case ICmpInst::ICMP_SGE: R = executeICMP_SGE(Src1, Src2, Ty); break;
default:
cerr << "Don't know how to handle this ICmp predicate!\n-->" << I;
- abort();
+ llvm_unreachable();
}
SetValue(&I, R, SF);
IMPLEMENT_FCMP(==, Double);
default:
cerr << "Unhandled type for FCmp EQ instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
default:
cerr << "Unhandled type for FCmp NE instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_FCMP(<=, Double);
default:
cerr << "Unhandled type for FCmp LE instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_FCMP(>=, Double);
default:
cerr << "Unhandled type for FCmp GE instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_FCMP(<, Double);
default:
cerr << "Unhandled type for FCmp LT instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
IMPLEMENT_FCMP(>, Double);
default:
cerr << "Unhandled type for FCmp GT instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
case FCmpInst::FCMP_OGE: R = executeFCMP_OGE(Src1, Src2, Ty); break;
default:
cerr << "Don't know how to handle this FCmp predicate!\n-->" << I;
- abort();
+ llvm_unreachable();
}
SetValue(&I, R, SF);
}
default:
cerr << "Unhandled Cmp predicate\n";
- abort();
+ llvm_unreachable();
}
}
case Instruction::Xor: R.IntVal = Src1.IntVal ^ Src2.IntVal; break;
default:
cerr << "Don't know how to handle this binary operator!\n-->" << I;
- abort();
+ llvm_unreachable();
}
SetValue(&I, R, SF);
do {
ECStack.pop_back ();
if (ECStack.empty ())
- abort ();
+ llvm_report_error("Empty stack during unwind!");
Inst = ECStack.back ().Caller.getInstruction ();
} while (!(Inst && isa<InvokeInst> (Inst)));
}
void Interpreter::visitUnreachableInst(UnreachableInst &I) {
- cerr << "ERROR: Program executed an 'unreachable' instruction!\n";
- abort();
+ llvm_report_error("ERROR: Program executed an 'unreachable' instruction!");
}
void Interpreter::visitBranchInst(BranchInst &I) {
} else if (SrcTy->isInteger()) {
Dest.IntVal = Src.IntVal;
} else
- assert(0 && "Invalid BitCast");
+ LLVM_UNREACHABLE("Invalid BitCast");
} else if (DstTy == Type::FloatTy) {
if (SrcTy->isInteger())
Dest.FloatVal = Src.IntVal.bitsToFloat();
else
Dest.DoubleVal = Src.DoubleVal;
} else
- assert(0 && "Invalid Bitcast");
+ LLVM_UNREACHABLE("Invalid Bitcast");
return Dest;
}
IMPLEMENT_VAARG(Double);
default:
cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
// Set the Value of this Instruction.
break;
default:
cerr << "Unhandled ConstantExpr: " << *CE << "\n";
- abort();
+ llvm_unreachable();
return GenericValue();
}
return Dest;
DOUT << " --> ";
const GenericValue &Val = SF.Values[&I];
switch (I.getType()->getTypeID()) {
- default: assert(0 && "Invalid GenericValue Type");
+ default: LLVM_UNREACHABLE("Invalid GenericValue Type");
case Type::VoidTyID: DOUT << "void"; break;
case Type::FloatTyID: DOUT << "float " << Val.FloatVal; break;
case Type::DoubleTyID: DOUT << "double " << Val.DoubleVal; break;