Revision: 9846
Author: [email protected]
Date: Mon Oct 31 06:06:26 2011
Log: Merge IR classes for different bitwise operations AND, OR and XOR
into one class.
Since we already have only one LIR class, it does not make much sense to
separate
them at the HIR level.
Review URL: http://codereview.chromium.org/8426005
http://code.google.com/p/v8/source/detail?r=9846
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-arm.h
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.h
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.h
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Thu Oct 20 03:26:45 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Mon Oct 31 06:06:26 2011
@@ -818,28 +818,6 @@
LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
return AssignEnvironment(new LDeoptimize);
}
-
-
-LInstruction* LChunkBuilder::DoBit(Token::Value op,
- HBitwiseBinaryOperation* instr) {
- if (instr->representation().IsInteger32()) {
- ASSERT(instr->left()->representation().IsInteger32());
- ASSERT(instr->right()->representation().IsInteger32());
-
- LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
- LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
- return DefineAsRegister(new LBitI(op, left, right));
- } else {
- ASSERT(instr->representation().IsTagged());
- ASSERT(instr->left()->representation().IsTagged());
- ASSERT(instr->right()->representation().IsTagged());
-
- LOperand* left = UseFixed(instr->left(), r1);
- LOperand* right = UseFixed(instr->right(), r0);
- LArithmeticT* result = new LArithmeticT(op, left, right);
- return MarkAsCall(DefineFixed(result, r0), instr);
- }
-}
LInstruction* LChunkBuilder::DoShift(Token::Value op,
@@ -1243,8 +1221,24 @@
}
-LInstruction* LChunkBuilder::DoBitAnd(HBitAnd* instr) {
- return DoBit(Token::BIT_AND, instr);
+LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
+ if (instr->representation().IsInteger32()) {
+ ASSERT(instr->left()->representation().IsInteger32());
+ ASSERT(instr->right()->representation().IsInteger32());
+
+ LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
+ LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
+ return DefineAsRegister(new LBitI(left, right));
+ } else {
+ ASSERT(instr->representation().IsTagged());
+ ASSERT(instr->left()->representation().IsTagged());
+ ASSERT(instr->right()->representation().IsTagged());
+
+ LOperand* left = UseFixed(instr->left(), r1);
+ LOperand* right = UseFixed(instr->right(), r0);
+ LArithmeticT* result = new LArithmeticT(instr->op(), left, right);
+ return MarkAsCall(DefineFixed(result, r0), instr);
+ }
}
@@ -1253,16 +1247,6 @@
ASSERT(instr->representation().IsInteger32());
return DefineAsRegister(new
LBitNotI(UseRegisterAtStart(instr->value())));
}
-
-
-LInstruction* LChunkBuilder::DoBitOr(HBitOr* instr) {
- return DoBit(Token::BIT_OR, instr);
-}
-
-
-LInstruction* LChunkBuilder::DoBitXor(HBitXor* instr) {
- return DoBit(Token::BIT_XOR, instr);
-}
LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Mon Oct 24 00:47:22 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Mon Oct 31 06:06:26 2011
@@ -796,18 +796,15 @@
class LBitI: public LTemplateInstruction<1, 2, 0> {
public:
- LBitI(Token::Value op, LOperand* left, LOperand* right)
- : op_(op) {
+ LBitI(LOperand* left, LOperand* right) {
inputs_[0] = left;
inputs_[1] = right;
}
- Token::Value op() const { return op_; }
+ Token::Value op() const { return hydrogen()->op(); }
DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
-
- private:
- Token::Value op_;
+ DECLARE_HYDROGEN_ACCESSOR(Bitwise)
};
@@ -2192,7 +2189,6 @@
void VisitInstruction(HInstruction* current);
void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
- LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
LInstruction* DoArithmeticD(Token::Value op,
HArithmeticBinaryOperation* instr);
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Oct 20
05:55:31 2011
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Mon Oct 31
06:06:26 2011
@@ -1252,32 +1252,21 @@
}
-Range* HBitAnd::InferRange() {
+Range* HBitwise::InferRange() {
+ if (op() == Token::BIT_XOR) return HValue::InferRange();
int32_t left_mask = (left()->range() != NULL)
? left()->range()->Mask()
: 0xffffffff;
int32_t right_mask = (right()->range() != NULL)
? right()->range()->Mask()
: 0xffffffff;
- int32_t result_mask = left_mask & right_mask;
+ int32_t result_mask = (op() == Token::BIT_AND)
+ ? left_mask & right_mask
+ : left_mask | right_mask;
return (result_mask >= 0)
? new Range(0, result_mask)
: HValue::InferRange();
}
-
-
-Range* HBitOr::InferRange() {
- int32_t left_mask = (left()->range() != NULL)
- ? left()->range()->Mask()
- : 0xffffffff;
- int32_t right_mask = (right()->range() != NULL)
- ? right()->range()->Mask()
- : 0xffffffff;
- int32_t result_mask = left_mask | right_mask;
- return (result_mask >= 0)
- ? new Range(0, result_mask)
- : HValue::InferRange();
-}
Range* HSar::InferRange() {
@@ -1783,21 +1772,6 @@
HType HAdd::CalculateInferredType() {
return HType::Tagged();
}
-
-
-HType HBitAnd::CalculateInferredType() {
- return HType::TaggedNumber();
-}
-
-
-HType HBitXor::CalculateInferredType() {
- return HType::TaggedNumber();
-}
-
-
-HType HBitOr::CalculateInferredType() {
- return HType::TaggedNumber();
-}
HType HBitNot::CalculateInferredType() {
@@ -1808,21 +1782,6 @@
HType HUnaryMathOperation::CalculateInferredType() {
return HType::TaggedNumber();
}
-
-
-HType HShl::CalculateInferredType() {
- return HType::TaggedNumber();
-}
-
-
-HType HShr::CalculateInferredType() {
- return HType::TaggedNumber();
-}
-
-
-HType HSar::CalculateInferredType() {
- return HType::TaggedNumber();
-}
HType HStringCharFromCode::CalculateInferredType() {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon Oct 24 00:47:22
2011
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Mon Oct 31 06:06:26
2011
@@ -67,10 +67,8 @@
V(ArgumentsLength) \
V(ArgumentsObject) \
V(ArrayLiteral) \
- V(BitAnd) \
+ V(Bitwise) \
V(BitNot) \
- V(BitOr) \
- V(BitXor) \
V(BlockEntry) \
V(BoundsCheck) \
V(Branch) \
@@ -3028,62 +3026,37 @@
};
-class HBitAnd: public HBitwiseBinaryOperation {
+class HBitwise: public HBitwiseBinaryOperation {
public:
- HBitAnd(HValue* context, HValue* left, HValue* right)
- : HBitwiseBinaryOperation(context, left, right) { }
+ HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right)
+ : HBitwiseBinaryOperation(context, left, right), op_(op) {
+ ASSERT(op == Token::BIT_AND ||
+ op == Token::BIT_OR ||
+ op == Token::BIT_XOR);
+ }
+
+ Token::Value op() const { return op_; }
virtual bool IsCommutative() const { return true; }
- virtual HType CalculateInferredType();
-
- DECLARE_CONCRETE_INSTRUCTION(BitAnd)
+
+ DECLARE_CONCRETE_INSTRUCTION(Bitwise)
protected:
virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange();
-};
-
-
-class HBitXor: public HBitwiseBinaryOperation {
- public:
- HBitXor(HValue* context, HValue* left, HValue* right)
- : HBitwiseBinaryOperation(context, left, right) { }
-
- virtual bool IsCommutative() const { return true; }
- virtual HType CalculateInferredType();
-
- DECLARE_CONCRETE_INSTRUCTION(BitXor)
-
- protected:
- virtual bool DataEquals(HValue* other) { return true; }
+
+ private:
+ Token::Value op_;
};
-class HBitOr: public HBitwiseBinaryOperation {
- public:
- HBitOr(HValue* context, HValue* left, HValue* right)
- : HBitwiseBinaryOperation(context, left, right) { }
-
- virtual bool IsCommutative() const { return true; }
- virtual HType CalculateInferredType();
-
- DECLARE_CONCRETE_INSTRUCTION(BitOr)
-
- protected:
- virtual bool DataEquals(HValue* other) { return true; }
-
- virtual Range* InferRange();
-};
-
-
class HShl: public HBitwiseBinaryOperation {
public:
HShl(HValue* context, HValue* left, HValue* right)
: HBitwiseBinaryOperation(context, left, right) { }
virtual Range* InferRange();
- virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(Shl)
@@ -3098,7 +3071,6 @@
: HBitwiseBinaryOperation(context, left, right) { }
virtual Range* InferRange();
- virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(Shr)
@@ -3113,7 +3085,6 @@
: HBitwiseBinaryOperation(context, left, right) { }
virtual Range* InferRange();
- virtual HType CalculateInferredType();
DECLARE_CONCRETE_INSTRUCTION(Sar)
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Mon Oct 31 04:11:26 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Mon Oct 31 06:06:26 2011
@@ -5619,13 +5619,9 @@
instr = new(zone()) HDiv(context, left, right);
break;
case Token::BIT_XOR:
- instr = new(zone()) HBitXor(context, left, right);
- break;
case Token::BIT_AND:
- instr = new(zone()) HBitAnd(context, left, right);
- break;
case Token::BIT_OR:
- instr = new(zone()) HBitOr(context, left, right);
+ instr = new(zone()) HBitwise(expr->op(), context, left, right);
break;
case Token::SAR:
instr = new(zone()) HSar(context, left, right);
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Oct 20 03:26:45
2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Mon Oct 31 06:06:26
2011
@@ -818,29 +818,6 @@
LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
return AssignEnvironment(new LDeoptimize);
}
-
-
-LInstruction* LChunkBuilder::DoBit(Token::Value op,
- HBitwiseBinaryOperation* instr) {
- if (instr->representation().IsInteger32()) {
- ASSERT(instr->left()->representation().IsInteger32());
- ASSERT(instr->right()->representation().IsInteger32());
-
- LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
- LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
- return DefineSameAsFirst(new LBitI(op, left, right));
- } else {
- ASSERT(instr->representation().IsTagged());
- ASSERT(instr->left()->representation().IsTagged());
- ASSERT(instr->right()->representation().IsTagged());
-
- LOperand* context = UseFixed(instr->context(), esi);
- LOperand* left = UseFixed(instr->left(), edx);
- LOperand* right = UseFixed(instr->right(), eax);
- LArithmeticT* result = new LArithmeticT(op, context, left, right);
- return MarkAsCall(DefineFixed(result, eax), instr);
- }
-}
LInstruction* LChunkBuilder::DoShift(Token::Value op,
@@ -1278,8 +1255,25 @@
}
-LInstruction* LChunkBuilder::DoBitAnd(HBitAnd* instr) {
- return DoBit(Token::BIT_AND, instr);
+LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
+ if (instr->representation().IsInteger32()) {
+ ASSERT(instr->left()->representation().IsInteger32());
+ ASSERT(instr->right()->representation().IsInteger32());
+
+ LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
+ LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
+ return DefineSameAsFirst(new LBitI(left, right));
+ } else {
+ ASSERT(instr->representation().IsTagged());
+ ASSERT(instr->left()->representation().IsTagged());
+ ASSERT(instr->right()->representation().IsTagged());
+
+ LOperand* context = UseFixed(instr->context(), esi);
+ LOperand* left = UseFixed(instr->left(), edx);
+ LOperand* right = UseFixed(instr->right(), eax);
+ LArithmeticT* result = new LArithmeticT(instr->op(), context, left,
right);
+ return MarkAsCall(DefineFixed(result, eax), instr);
+ }
}
@@ -1290,16 +1284,6 @@
LBitNotI* result = new LBitNotI(input);
return DefineSameAsFirst(result);
}
-
-
-LInstruction* LChunkBuilder::DoBitOr(HBitOr* instr) {
- return DoBit(Token::BIT_OR, instr);
-}
-
-
-LInstruction* LChunkBuilder::DoBitXor(HBitXor* instr) {
- return DoBit(Token::BIT_XOR, instr);
-}
LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Mon Oct 24 00:47:22 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Mon Oct 31 06:06:26 2011
@@ -799,18 +799,15 @@
class LBitI: public LTemplateInstruction<1, 2, 0> {
public:
- LBitI(Token::Value op, LOperand* left, LOperand* right)
- : op_(op) {
+ LBitI(LOperand* left, LOperand* right) {
inputs_[0] = left;
inputs_[1] = right;
}
- Token::Value op() const { return op_; }
+ Token::Value op() const { return hydrogen()->op(); }
DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
-
- private:
- Token::Value op_;
+ DECLARE_HYDROGEN_ACCESSOR(Bitwise)
};
@@ -2300,7 +2297,6 @@
void VisitInstruction(HInstruction* current);
void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
- LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
LInstruction* DoArithmeticD(Token::Value op,
HArithmeticBinaryOperation* instr);
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Thu Oct 20 03:26:45 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Mon Oct 31 06:06:26 2011
@@ -813,28 +813,6 @@
LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
return AssignEnvironment(new LDeoptimize);
}
-
-
-LInstruction* LChunkBuilder::DoBit(Token::Value op,
- HBitwiseBinaryOperation* instr) {
- if (instr->representation().IsInteger32()) {
- ASSERT(instr->left()->representation().IsInteger32());
- ASSERT(instr->right()->representation().IsInteger32());
-
- LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
- LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
- return DefineSameAsFirst(new LBitI(op, left, right));
- } else {
- ASSERT(instr->representation().IsTagged());
- ASSERT(instr->left()->representation().IsTagged());
- ASSERT(instr->right()->representation().IsTagged());
-
- LOperand* left = UseFixed(instr->left(), rdx);
- LOperand* right = UseFixed(instr->right(), rax);
- LArithmeticT* result = new LArithmeticT(op, left, right);
- return MarkAsCall(DefineFixed(result, rax), instr);
- }
-}
LInstruction* LChunkBuilder::DoShift(Token::Value op,
@@ -1239,8 +1217,24 @@
}
-LInstruction* LChunkBuilder::DoBitAnd(HBitAnd* instr) {
- return DoBit(Token::BIT_AND, instr);
+LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
+ if (instr->representation().IsInteger32()) {
+ ASSERT(instr->left()->representation().IsInteger32());
+ ASSERT(instr->right()->representation().IsInteger32());
+
+ LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
+ LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
+ return DefineSameAsFirst(new LBitI(left, right));
+ } else {
+ ASSERT(instr->representation().IsTagged());
+ ASSERT(instr->left()->representation().IsTagged());
+ ASSERT(instr->right()->representation().IsTagged());
+
+ LOperand* left = UseFixed(instr->left(), rdx);
+ LOperand* right = UseFixed(instr->right(), rax);
+ LArithmeticT* result = new LArithmeticT(instr->op(), left, right);
+ return MarkAsCall(DefineFixed(result, rax), instr);
+ }
}
@@ -1251,16 +1245,6 @@
LBitNotI* result = new LBitNotI(input);
return DefineSameAsFirst(result);
}
-
-
-LInstruction* LChunkBuilder::DoBitOr(HBitOr* instr) {
- return DoBit(Token::BIT_OR, instr);
-}
-
-
-LInstruction* LChunkBuilder::DoBitXor(HBitXor* instr) {
- return DoBit(Token::BIT_XOR, instr);
-}
LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h Mon Oct 24 00:47:22 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.h Mon Oct 31 06:06:26 2011
@@ -793,18 +793,15 @@
class LBitI: public LTemplateInstruction<1, 2, 0> {
public:
- LBitI(Token::Value op, LOperand* left, LOperand* right)
- : op_(op) {
+ LBitI(LOperand* left, LOperand* right) {
inputs_[0] = left;
inputs_[1] = right;
}
- Token::Value op() const { return op_; }
+ Token::Value op() const { return hydrogen()->op(); }
DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
-
- private:
- Token::Value op_;
+ DECLARE_HYDROGEN_ACCESSOR(Bitwise)
};
@@ -2181,7 +2178,6 @@
void VisitInstruction(HInstruction* current);
void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
- LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
LInstruction* DoArithmeticD(Token::Value op,
HArithmeticBinaryOperation* instr);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev