[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Reid Spencer
reid at x10sys.com
Tue Oct 31 19:41:19 PST 2006
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Execution.cpp updated: 1.141 -> 1.142
---
Log message:
Fix a bug in the interpreter where divides of unmatched signed operands
would fail. E.g. udiv sint X, Y or sdiv uint X, Y would fail to find a
type match in the switch statement and fail the operation.
---
Diffs of the changes: (+11 -8)
Execution.cpp | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.141 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.142
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.141 Thu Oct 26 01:15:43 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Tue Oct 31 21:41:05 2006
@@ -254,16 +254,19 @@
return Dest;
}
+#define IMPLEMENT_SIGNLESS_BINOP(OP, TY1, TY2) \
+ case Type::TY2##TyID: IMPLEMENT_BINARY_OPERATOR(OP, TY1)
+
static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
if (Ty->isSigned())
Ty = Ty->getUnsignedVersion();
switch (Ty->getTypeID()) {
- IMPLEMENT_BINARY_OPERATOR(/, UByte);
- IMPLEMENT_BINARY_OPERATOR(/, UShort);
- IMPLEMENT_BINARY_OPERATOR(/, UInt);
- IMPLEMENT_BINARY_OPERATOR(/, ULong);
+ IMPLEMENT_SIGNLESS_BINOP(/, UByte, SByte);
+ IMPLEMENT_SIGNLESS_BINOP(/, UShort, Short);
+ IMPLEMENT_SIGNLESS_BINOP(/, UInt, Int);
+ IMPLEMENT_SIGNLESS_BINOP(/, ULong, Long);
default:
std::cout << "Unhandled type for UDiv instruction: " << *Ty << "\n";
abort();
@@ -277,10 +280,10 @@
if (Ty->isUnsigned())
Ty = Ty->getSignedVersion();
switch (Ty->getTypeID()) {
- IMPLEMENT_BINARY_OPERATOR(/, SByte);
- IMPLEMENT_BINARY_OPERATOR(/, Short);
- IMPLEMENT_BINARY_OPERATOR(/, Int);
- IMPLEMENT_BINARY_OPERATOR(/, Long);
+ IMPLEMENT_SIGNLESS_BINOP(/, SByte, UByte);
+ IMPLEMENT_SIGNLESS_BINOP(/, Short, UShort);
+ IMPLEMENT_SIGNLESS_BINOP(/, Int, UInt);
+ IMPLEMENT_SIGNLESS_BINOP(/, Long, ULong);
default:
std::cout << "Unhandled type for SDiv instruction: " << *Ty << "\n";
abort();
More information about the llvm-commits
mailing list