Commit be317823 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: [wasm] Implement wasm sign extension opcodes

Port 1abeb5a3

Original Commit Message:

     - Shift opcode numbers for asmjs-compat opcodes
     - Add --experimental-wasm-se flag to gate sign extension opccodes
     - Fix codegen for ia32 movsx instructions

R=gdeepti@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: I3af97112b40d159f9ffc4f465768fc7832485f20
Reviewed-on: https://chromium-review.googlesource.com/893703Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#50969}
parent 718883a9
......@@ -1118,6 +1118,16 @@ void InstructionSelector::VisitTruncateFloat64ToUint32(Node* node) {
VisitRR(this, kPPC_DoubleToUint32, node);
}
void InstructionSelector::VisitSignExtendWord8ToInt32(Node* node) {
// TODO(mbrandy): inspect input to see if nop is appropriate.
VisitRR(this, kPPC_ExtendSignWord8, node);
}
void InstructionSelector::VisitSignExtendWord16ToInt32(Node* node) {
// TODO(mbrandy): inspect input to see if nop is appropriate.
VisitRR(this, kPPC_ExtendSignWord16, node);
}
#if V8_TARGET_ARCH_PPC64
void InstructionSelector::VisitTryTruncateFloat32ToInt64(Node* node) {
VisitTryTruncateDouble(this, kPPC_DoubleToInt64, node);
......@@ -1144,6 +1154,20 @@ void InstructionSelector::VisitChangeInt32ToInt64(Node* node) {
VisitRR(this, kPPC_ExtendSignWord32, node);
}
void InstructionSelector::VisitSignExtendWord8ToInt64(Node* node) {
// TODO(mbrandy): inspect input to see if nop is appropriate.
VisitRR(this, kPPC_ExtendSignWord8, node);
}
void InstructionSelector::VisitSignExtendWord16ToInt64(Node* node) {
// TODO(mbrandy): inspect input to see if nop is appropriate.
VisitRR(this, kPPC_ExtendSignWord16, node);
}
void InstructionSelector::VisitSignExtendWord32ToInt64(Node* node) {
// TODO(mbrandy): inspect input to see if nop is appropriate.
VisitRR(this, kPPC_ExtendSignWord32, node);
}
void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
// TODO(mbrandy): inspect input to see if nop is appropriate.
......
......@@ -1925,15 +1925,21 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
break;
}
case kS390_ExtendSignWord8:
case kS390_SignExtendWord8ToInt32:
__ lbr(i.OutputRegister(), i.InputRegister(0));
CHECK_AND_ZERO_EXT_OUTPUT(1);
break;
case kS390_ExtendSignWord16:
case kS390_SignExtendWord16ToInt32:
__ lhr(i.OutputRegister(), i.InputRegister(0));
CHECK_AND_ZERO_EXT_OUTPUT(1);
break;
case kS390_ExtendSignWord32:
case kS390_SignExtendWord8ToInt64:
__ lgbr(i.OutputRegister(), i.InputRegister(0));
break;
case kS390_SignExtendWord16ToInt64:
__ lghr(i.OutputRegister(), i.InputRegister(0));
break;
case kS390_SignExtendWord32ToInt64:
__ lgfr(i.OutputRegister(), i.InputRegister(0));
break;
case kS390_Uint32ToUint64:
......
......@@ -99,9 +99,11 @@ namespace compiler {
V(S390_PushFrame) \
V(S390_StackClaim) \
V(S390_StoreToStackSlot) \
V(S390_ExtendSignWord8) \
V(S390_ExtendSignWord16) \
V(S390_ExtendSignWord32) \
V(S390_SignExtendWord8ToInt32) \
V(S390_SignExtendWord16ToInt32) \
V(S390_SignExtendWord8ToInt64) \
V(S390_SignExtendWord16ToInt64) \
V(S390_SignExtendWord32ToInt64) \
V(S390_Uint32ToUint64) \
V(S390_Int64ToInt32) \
V(S390_Int64ToFloat32) \
......
......@@ -96,9 +96,11 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kS390_CmpDouble:
case kS390_Tst32:
case kS390_Tst64:
case kS390_ExtendSignWord8:
case kS390_ExtendSignWord16:
case kS390_ExtendSignWord32:
case kS390_SignExtendWord8ToInt32:
case kS390_SignExtendWord16ToInt32:
case kS390_SignExtendWord8ToInt64:
case kS390_SignExtendWord16ToInt64:
case kS390_SignExtendWord32ToInt64:
case kS390_Uint32ToUint64:
case kS390_Int64ToInt32:
case kS390_Int64ToFloat32:
......
......@@ -329,6 +329,8 @@ ArchOpcode SelectLoadOpcode(Node* node) {
V(Word32Popcnt) \
V(Float64ExtractLowWord32) \
V(Float64ExtractHighWord32) \
V(SignExtendWord8ToInt32) \
V(SignExtendWord16ToInt32) \
/* Word32 bin op */ \
V(Int32Add) \
V(Int32Sub) \
......@@ -1019,7 +1021,7 @@ static inline bool TryMatchSignExtInt16OrInt8FromWord32Sar(
Int32BinopMatcher mleft(m.left().node());
if (mleft.right().Is(16) && m.right().Is(16)) {
bool canEliminateZeroExt = ProduceWord32Result(mleft.left().node());
selector->Emit(kS390_ExtendSignWord16,
selector->Emit(kS390_SignExtendWord16ToInt32,
canEliminateZeroExt ? g.DefineSameAsFirst(node)
: g.DefineAsRegister(node),
g.UseRegister(mleft.left().node()),
......@@ -1027,7 +1029,7 @@ static inline bool TryMatchSignExtInt16OrInt8FromWord32Sar(
return true;
} else if (mleft.right().Is(24) && m.right().Is(24)) {
bool canEliminateZeroExt = ProduceWord32Result(mleft.left().node());
selector->Emit(kS390_ExtendSignWord8,
selector->Emit(kS390_SignExtendWord8ToInt32,
canEliminateZeroExt ? g.DefineSameAsFirst(node)
: g.DefineAsRegister(node),
g.UseRegister(mleft.left().node()),
......@@ -1415,6 +1417,10 @@ static inline bool TryMatchDoubleConstructFromInsert(
null) \
V(Word32, ChangeUint32ToFloat64, kS390_Uint32ToDouble, OperandMode::kNone, \
null) \
V(Word32, SignExtendWord8ToInt32, kS390_SignExtendWord8ToInt32, \
OperandMode::kNone, null) \
V(Word32, SignExtendWord16ToInt32, kS390_SignExtendWord16ToInt32, \
OperandMode::kNone, null) \
V(Word32, BitcastInt32ToFloat32, kS390_BitcastInt32ToFloat32, \
OperandMode::kNone, null)
......@@ -1427,8 +1433,14 @@ static inline bool TryMatchDoubleConstructFromInsert(
OperandMode::kNone, null)
#define WORD32_UNARY_OP_LIST(V) \
WORD32_UNARY_OP_LIST_32(V) \
V(Word32, ChangeInt32ToInt64, kS390_ExtendSignWord32, OperandMode::kNone, \
null) \
V(Word32, ChangeInt32ToInt64, kS390_SignExtendWord32ToInt64, \
OperandMode::kNone, null) \
V(Word32, SignExtendWord8ToInt64, kS390_SignExtendWord8ToInt64, \
OperandMode::kNone, null) \
V(Word32, SignExtendWord16ToInt64, kS390_SignExtendWord16ToInt64, \
OperandMode::kNone, null) \
V(Word32, SignExtendWord32ToInt64, kS390_SignExtendWord32ToInt64, \
OperandMode::kNone, null) \
V(Word32, ChangeUint32ToUint64, kS390_Uint32ToUint64, OperandMode::kNone, \
[&]() -> bool { \
if (ProduceWord32Result(node->InputAt(0))) { \
......
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