Commit d2f5702c authored by dusan.milosavljevic's avatar dusan.milosavljevic Committed by Commit bot

MIPS64: Implement AddE lithium instruction to separate integer and address arithmetic.

This is required to have sign-extended int32 arithmetic operations by re-landing:
https://codereview.chromium.org/1161713003

TEST=cctest/test-api/ArrayBuffer_JSInternalToExternal
BUG=

Review URL: https://codereview.chromium.org/1153263012

Cr-Commit-Position: refs/heads/master@{#28845}
parent ab3caa73
...@@ -1889,6 +1889,17 @@ void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { ...@@ -1889,6 +1889,17 @@ void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
} }
void LCodeGen::DoAddE(LAddE* instr) {
LOperand* result = instr->result();
LOperand* left = instr->left();
LOperand* right = instr->right();
DCHECK(!instr->hydrogen()->CheckFlag(HValue::kCanOverflow));
DCHECK(right->IsRegister() || right->IsConstantOperand());
__ Daddu(ToRegister(result), ToRegister(left), ToOperand(right));
}
void LCodeGen::DoAddI(LAddI* instr) { void LCodeGen::DoAddI(LAddI* instr) {
LOperand* left = instr->left(); LOperand* left = instr->left();
LOperand* right = instr->right(); LOperand* right = instr->right();
...@@ -1896,18 +1907,12 @@ void LCodeGen::DoAddI(LAddI* instr) { ...@@ -1896,18 +1907,12 @@ void LCodeGen::DoAddI(LAddI* instr) {
bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
if (!can_overflow) { if (!can_overflow) {
if (right->IsStackSlot()) { DCHECK(right->IsRegister());
Register right_reg = EmitLoadRegister(right, at);
__ Daddu(ToRegister(result), ToRegister(left), Operand(right_reg));
} else {
DCHECK(right->IsRegister() || right->IsConstantOperand());
__ Daddu(ToRegister(result), ToRegister(left), ToOperand(right)); __ Daddu(ToRegister(result), ToRegister(left), ToOperand(right));
}
} else { // can_overflow. } else { // can_overflow.
Register overflow = scratch0(); Register overflow = scratch0();
Register scratch = scratch1(); Register scratch = scratch1();
if (right->IsStackSlot() || if (right->IsConstantOperand()) {
right->IsConstantOperand()) {
Register right_reg = EmitLoadRegister(right, scratch); Register right_reg = EmitLoadRegister(right, scratch);
__ AdduAndCheckForOverflow(ToRegister(result), __ AdduAndCheckForOverflow(ToRegister(result),
ToRegister(left), ToRegister(left),
......
...@@ -1593,7 +1593,7 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { ...@@ -1593,7 +1593,7 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
DCHECK(instr->left()->representation().Equals(instr->representation())); DCHECK(instr->left()->representation().Equals(instr->representation()));
DCHECK(instr->right()->representation().Equals(instr->representation())); DCHECK(instr->right()->representation().Equals(instr->representation()));
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); LOperand* right = UseRegisterOrConstantAtStart(instr->BetterRightOperand());
LAddI* add = new(zone()) LAddI(left, right); LAddI* add = new(zone()) LAddI(left, right);
LInstruction* result = DefineAsRegister(add); LInstruction* result = DefineAsRegister(add);
if (instr->CheckFlag(HValue::kCanOverflow)) { if (instr->CheckFlag(HValue::kCanOverflow)) {
...@@ -1605,10 +1605,8 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { ...@@ -1605,10 +1605,8 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
DCHECK(instr->right()->representation().IsInteger32()); DCHECK(instr->right()->representation().IsInteger32());
DCHECK(!instr->CheckFlag(HValue::kCanOverflow)); DCHECK(!instr->CheckFlag(HValue::kCanOverflow));
LOperand* left = UseRegisterAtStart(instr->left()); LOperand* left = UseRegisterAtStart(instr->left());
LOperand* right = UseOrConstantAtStart(instr->right()); LOperand* right = UseRegisterOrConstantAtStart(instr->right());
LAddI* add = new(zone()) LAddI(left, right); return DefineAsRegister(new (zone()) LAddE(left, right));
LInstruction* result = DefineAsRegister(add);
return result;
} else if (instr->representation().IsDouble()) { } else if (instr->representation().IsDouble()) {
if (kArchVariant == kMips64r2) { if (kArchVariant == kMips64r2) {
if (instr->left()->IsMul()) if (instr->left()->IsMul())
......
...@@ -20,6 +20,7 @@ class LCodeGen; ...@@ -20,6 +20,7 @@ class LCodeGen;
#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
V(AccessArgumentsAt) \ V(AccessArgumentsAt) \
V(AddI) \ V(AddI) \
V(AddE) \
V(Allocate) \ V(Allocate) \
V(AllocateBlockContext) \ V(AllocateBlockContext) \
V(ApplyArguments) \ V(ApplyArguments) \
...@@ -1421,6 +1422,21 @@ class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> { ...@@ -1421,6 +1422,21 @@ class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
}; };
class LAddE final : public LTemplateInstruction<1, 2, 0> {
public:
LAddE(LOperand* left, LOperand* right) {
inputs_[0] = left;
inputs_[1] = right;
}
LOperand* left() { return inputs_[0]; }
LOperand* right() { return inputs_[1]; }
DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e")
DECLARE_HYDROGEN_ACCESSOR(Add)
};
class LAddI final : public LTemplateInstruction<1, 2, 0> { class LAddI final : public LTemplateInstruction<1, 2, 0> {
public: public:
LAddI(LOperand* left, LOperand* right) { LAddI(LOperand* left, LOperand* right) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment