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) {
}
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) {
LOperand* left = instr->left();
LOperand* right = instr->right();
......@@ -1896,18 +1907,12 @@ void LCodeGen::DoAddI(LAddI* instr) {
bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
if (!can_overflow) {
if (right->IsStackSlot()) {
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));
}
DCHECK(right->IsRegister());
__ Daddu(ToRegister(result), ToRegister(left), ToOperand(right));
} else { // can_overflow.
Register overflow = scratch0();
Register scratch = scratch1();
if (right->IsStackSlot() ||
right->IsConstantOperand()) {
if (right->IsConstantOperand()) {
Register right_reg = EmitLoadRegister(right, scratch);
__ AdduAndCheckForOverflow(ToRegister(result),
ToRegister(left),
......
......@@ -1593,7 +1593,7 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
DCHECK(instr->left()->representation().Equals(instr->representation()));
DCHECK(instr->right()->representation().Equals(instr->representation()));
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
LOperand* right = UseRegisterOrConstantAtStart(instr->BetterRightOperand());
LAddI* add = new(zone()) LAddI(left, right);
LInstruction* result = DefineAsRegister(add);
if (instr->CheckFlag(HValue::kCanOverflow)) {
......@@ -1605,10 +1605,8 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
DCHECK(instr->right()->representation().IsInteger32());
DCHECK(!instr->CheckFlag(HValue::kCanOverflow));
LOperand* left = UseRegisterAtStart(instr->left());
LOperand* right = UseOrConstantAtStart(instr->right());
LAddI* add = new(zone()) LAddI(left, right);
LInstruction* result = DefineAsRegister(add);
return result;
LOperand* right = UseRegisterOrConstantAtStart(instr->right());
return DefineAsRegister(new (zone()) LAddE(left, right));
} else if (instr->representation().IsDouble()) {
if (kArchVariant == kMips64r2) {
if (instr->left()->IsMul())
......
......@@ -20,6 +20,7 @@ class LCodeGen;
#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
V(AccessArgumentsAt) \
V(AddI) \
V(AddE) \
V(Allocate) \
V(AllocateBlockContext) \
V(ApplyArguments) \
......@@ -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> {
public:
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