summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-11-01 03:41:05 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-11-01 03:41:05 +0000
commitf84930746ec85c5540695cb0d206553af812c37d (patch)
tree4ec94a93963d8d74f8c98019ffbb332e2d6932c1 /llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
parentf505a5a063ed63f76b3aaa45cd770ff857dd8115 (diff)
downloadbcm5719-llvm-f84930746ec85c5540695cb0d206553af812c37d.tar.gz
bcm5719-llvm-f84930746ec85c5540695cb0d206553af812c37d.zip
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. llvm-svn: 31338
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter/Execution.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Execution.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
index 41f07507d46..c10dbbd1236 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -254,16 +254,19 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
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 @@ static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
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();
OpenPOWER on IntegriCloud