[macruby-changes] [1860] MacRuby/branches/fp-optimized-experimental/compiler.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 15 14:31:15 PDT 2009
Revision: 1860
http://trac.macosforge.org/projects/ruby/changeset/1860
Author: pthomson at apple.com
Date: 2009-06-15 14:31:14 -0700 (Mon, 15 Jun 2009)
Log Message:
-----------
Fixed comparisons to return true and false rather than numeric values.
Modified Paths:
--------------
MacRuby/branches/fp-optimized-experimental/compiler.cpp
Modified: MacRuby/branches/fp-optimized-experimental/compiler.cpp
===================================================================
--- MacRuby/branches/fp-optimized-experimental/compiler.cpp 2009-06-15 21:14:43 UTC (rev 1859)
+++ MacRuby/branches/fp-optimized-experimental/compiler.cpp 2009-06-15 21:31:14 UTC (rev 1860)
@@ -1882,7 +1882,8 @@
BasicBlock *redefBB = BasicBlock::Create("op_not_redefined", f);
BasicBlock *toDblBB = BasicBlock::Create("op_floating_cast", f);
- BasicBlock *toIntBB = BasicBlock::Create("op_integral_cast", f);
+ BasicBlock *onDblBB = BasicBlock::Create("op_optimize_floating", f);
+ BasicBlock *toIntBB = BasicBlock::Create("op_optimize_integral", f);
BasicBlock *elseBB = BasicBlock::Create("op_dispatch", f);
BasicBlock *mergeBB = BasicBlock::Create("op_merge", f);
@@ -1908,7 +1909,9 @@
Value *unmaskedRight = BinaryOperator::CreateXor(rightVal, threeVal, "", bb);
leftAsDouble = new BitCastInst(unmaskedLeft, Type::DoubleTy, "", bb);
rightAsDouble = new BitCastInst(unmaskedRight, Type::DoubleTy, "", bb);
+ BranchInst::Create(onDblBB, toDblBB);
+ bb = onDblBB;
bool result_is_bool = false;
if (sel == selPLUS) {
opVal = BinaryOperator::CreateAdd(leftAsDouble, rightAsDouble, "", bb);
@@ -1953,9 +1956,14 @@
opVal = SelectInst::Create(opVal, trueVal, falseVal, "", bb);
}
- Value *castedResult = new BitCastInst(opVal, IntTy, "", bb);
- Value *dblReturnResult = BinaryOperator::CreateOr(castedResult, threeVal, "", bb);
- BranchInst::Create(mergeBB, toDblBB);
+ Value *dblReturnResult;
+ if (result_is_bool) {
+ dblReturnResult = opVal;
+ } else {
+ Value *castedResult = new BitCastInst(opVal, IntTy, "", bb);
+ dblReturnResult = BinaryOperator::CreateOr(castedResult, threeVal, "", bb);
+ }
+ BranchInst::Create(mergeBB, onDblBB);
bb = toIntBB;
leftAsInt = BinaryOperator::CreateAShr(leftVal, twoVal, "", bb);
@@ -2004,8 +2012,14 @@
opVal = SelectInst::Create(opVal, trueVal, falseVal, "", bb);
}
- Value *shiftedResult = BinaryOperator::CreateShl(opVal, twoVal, "", bb);
- Value *intReturnResult = BinaryOperator::CreateOr(shiftedResult, oneVal, "", bb);
+ Value *intReturnResult = NULL;
+ if(result_is_bool) {
+ intReturnResult = opVal;
+ }
+ else {
+ Value *shiftedResult = BinaryOperator::CreateShl(opVal, twoVal, "", bb);
+ intReturnResult = BinaryOperator::CreateOr(shiftedResult, oneVal, "", bb);
+ }
BranchInst::Create(mergeBB, toIntBB);
bb = elseBB;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090615/a24e411b/attachment-0001.html>
More information about the macruby-changes
mailing list