[llvm-commits] [SignlessTypes] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Reid Spencer
reid at x10sys.com
Wed Oct 25 18:58:36 PDT 2006
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Execution.cpp updated: 1.139.6.4 -> 1.139.6.5
---
Log message:
Round 2 of DIV updates.
---
Diffs of the changes: (+48 -12)
Execution.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 48 insertions(+), 12 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.4 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.5
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.4 Mon Oct 23 13:13:26 2006
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Wed Oct 25 20:58:05 2006
@@ -42,8 +42,12 @@
const Type *Ty);
static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
-static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
- const Type *Ty);
+static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
+ const Type *Ty);
+static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
+ const Type *Ty);
+static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
+ const Type *Ty);
static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
const Type *Ty);
static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
@@ -90,11 +94,17 @@
getOperandValue(CE->getOperand(1), SF),
CE->getOperand(0)->getType());
case Instruction::SDiv:
+ return executeSDivInst(getOperandValue(CE->getOperand(0), SF),
+ getOperandValue(CE->getOperand(1), SF),
+ CE->getOperand(0)->getType());
case Instruction::UDiv:
+ return executeUDivInst(getOperandValue(CE->getOperand(0), SF),
+ getOperandValue(CE->getOperand(1), SF),
+ CE->getOperand(0)->getType());
case Instruction::FDiv:
- return executeDivInst(getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
+ return executeFDivInst(getOperandValue(CE->getOperand(0), SF),
+ getOperandValue(CE->getOperand(1), SF),
+ CE->getOperand(0)->getType());
case Instruction::URem:
case Instruction::SRem:
return executeRemInst(getOperandValue(CE->getOperand(0), SF),
@@ -245,18 +255,44 @@
return Dest;
}
-static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
+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(/, SByte);
IMPLEMENT_BINARY_OPERATOR(/, UShort);
- IMPLEMENT_BINARY_OPERATOR(/, Short);
IMPLEMENT_BINARY_OPERATOR(/, UInt);
- IMPLEMENT_BINARY_OPERATOR(/, Int);
IMPLEMENT_BINARY_OPERATOR(/, ULong);
+ default:
+ std::cout << "Unhandled type for UDiv instruction: " << *Ty << "\n";
+ abort();
+ }
+ return Dest;
+}
+
+static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
+ const Type *Ty) {
+ GenericValue Dest;
+ 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);
+ default:
+ std::cout << "Unhandled type for SDiv instruction: " << *Ty << "\n";
+ abort();
+ }
+ return Dest;
+}
+
+static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
+ const Type *Ty) {
+ GenericValue Dest;
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(/, Float);
IMPLEMENT_BINARY_OPERATOR(/, Double);
default:
@@ -510,9 +546,9 @@
case Instruction::URem:
case Instruction::SRem:
case Instruction::FRem: R = executeRemInst (Src1, Src2, Ty); break;
- case Instruction::SDiv:
- case Instruction::UDiv:
- case Instruction::FDiv: R = executeDivInst (Src1, Src2, Ty); break;
+ case Instruction::UDiv: R = executeUDivInst (Src1, Src2, Ty); break;
+ case Instruction::SDiv: R = executeSDivInst (Src1, Src2, Ty); break;
+ case Instruction::FDiv: R = executeFDivInst (Src1, Src2, Ty); break;
case Instruction::And: R = executeAndInst (Src1, Src2, Ty); break;
case Instruction::Or: R = executeOrInst (Src1, Src2, Ty); break;
case Instruction::Xor: R = executeXorInst (Src1, Src2, Ty); break;
More information about the llvm-commits
mailing list