diff --git a/src/baseline/ppc/baseline-assembler-ppc-inl.h b/src/baseline/ppc/baseline-assembler-ppc-inl.h index a952192196..026dd36900 100644 --- a/src/baseline/ppc/baseline-assembler-ppc-inl.h +++ b/src/baseline/ppc/baseline-assembler-ppc-inl.h @@ -49,31 +49,6 @@ class BaselineAssembler::ScratchRegisterScope { int registers_used_; }; -inline bool IsSignedCondition(Condition cond) { - switch (cond) { - case kEqual: - case kNotEqual: - case kLessThan: - case kGreaterThan: - case kLessThanEqual: - case kGreaterThanEqual: - case kOverflow: - case kNoOverflow: - case kZero: - case kNotZero: - return true; - - case kUnsignedLessThan: - case kUnsignedGreaterThan: - case kUnsignedLessThanEqual: - case kUnsignedGreaterThanEqual: - return false; - - default: - UNREACHABLE(); - } -} - #define __ assm-> // ppc helper template @@ -82,19 +57,19 @@ static void JumpIfHelper(MacroAssembler* assm, Condition cc, Register lhs, static_assert(width == 64 || width == 32, "only support 64 and 32 bit compare"); if (width == 64) { - if (IsSignedCondition(cc)) { + if (is_signed(cc)) { __ CmpS64(lhs, rhs); } else { __ CmpU64(lhs, rhs); } } else { - if (IsSignedCondition(cc)) { + if (is_signed(cc)) { __ CmpS32(lhs, rhs); } else { __ CmpU32(lhs, rhs); } } - __ b(check_condition(cc), target); + __ b(to_condition(cc), target); } #undef __ @@ -160,18 +135,18 @@ void BaselineAssembler::TestAndBranch(Register value, int mask, Condition cc, Label* target, Label::Distance) { ASM_CODE_COMMENT(masm_); __ AndU64(r0, value, Operand(mask), ip, SetRC); - __ b(check_condition(cc), target, cr0); + __ b(to_condition(cc), target, cr0); } void BaselineAssembler::JumpIf(Condition cc, Register lhs, const Operand& rhs, Label* target, Label::Distance) { ASM_CODE_COMMENT(masm_); - if (IsSignedCondition(cc)) { + if (is_signed(cc)) { __ CmpS64(lhs, rhs, r0); } else { __ CmpU64(lhs, rhs, r0); } - __ b(check_condition(cc), target); + __ b(to_condition(cc), target); } void BaselineAssembler::JumpIfObjectType(Condition cc, Register object, diff --git a/src/baseline/s390/baseline-assembler-s390-inl.h b/src/baseline/s390/baseline-assembler-s390-inl.h index b183fda183..bb60ecb44b 100644 --- a/src/baseline/s390/baseline-assembler-s390-inl.h +++ b/src/baseline/s390/baseline-assembler-s390-inl.h @@ -48,31 +48,6 @@ class BaselineAssembler::ScratchRegisterScope { int registers_used_; }; -inline bool IsSignedCondition(Condition cond) { - switch (cond) { - case kEqual: - case kNotEqual: - case kLessThan: - case kGreaterThan: - case kLessThanEqual: - case kGreaterThanEqual: - case kOverflow: - case kNoOverflow: - case kZero: - case kNotZero: - return true; - - case kUnsignedLessThan: - case kUnsignedGreaterThan: - case kUnsignedLessThanEqual: - case kUnsignedGreaterThanEqual: - return false; - - default: - UNREACHABLE(); - } -} - #define __ assm-> // s390x helper template @@ -81,19 +56,19 @@ static void JumpIfHelper(MacroAssembler* assm, Condition cc, Register lhs, static_assert(width == 64 || width == 32, "only support 64 and 32 bit compare"); if (width == 64) { - if (IsSignedCondition(cc)) { + if (is_signed(cc)) { __ CmpS64(lhs, rhs); } else { __ CmpU64(lhs, rhs); } } else { - if (IsSignedCondition(cc)) { + if (is_signed(cc)) { __ CmpS32(lhs, rhs); } else { __ CmpU32(lhs, rhs); } } - __ b(check_condition(cc), target); + __ b(to_condition(cc), target); } #undef __ @@ -159,18 +134,18 @@ void BaselineAssembler::TestAndBranch(Register value, int mask, Condition cc, Label* target, Label::Distance) { ASM_CODE_COMMENT(masm_); __ AndP(r0, value, Operand(mask)); - __ b(check_condition(cc), target); + __ b(to_condition(cc), target); } void BaselineAssembler::JumpIf(Condition cc, Register lhs, const Operand& rhs, Label* target, Label::Distance) { ASM_CODE_COMMENT(masm_); - if (IsSignedCondition(cc)) { + if (is_signed(cc)) { __ CmpS64(lhs, rhs); } else { __ CmpU64(lhs, rhs); } - __ b(check_condition(cc), target); + __ b(to_condition(cc), target); } void BaselineAssembler::JumpIfObjectType(Condition cc, Register object, diff --git a/src/codegen/ppc/constants-ppc.h b/src/codegen/ppc/constants-ppc.h index 8d00d36570..19878b502b 100644 --- a/src/codegen/ppc/constants-ppc.h +++ b/src/codegen/ppc/constants-ppc.h @@ -151,7 +151,7 @@ enum Condition { kNotZero = 16, }; -inline Condition check_condition(Condition cond) { +inline Condition to_condition(Condition cond) { switch (cond) { case kUnsignedLessThan: return lt; @@ -171,6 +171,31 @@ inline Condition check_condition(Condition cond) { return cond; } +inline bool is_signed(Condition cond) { + switch (cond) { + case kEqual: + case kNotEqual: + case kLessThan: + case kGreaterThan: + case kLessThanEqual: + case kGreaterThanEqual: + case kOverflow: + case kNoOverflow: + case kZero: + case kNotZero: + return true; + + case kUnsignedLessThan: + case kUnsignedGreaterThan: + case kUnsignedLessThanEqual: + case kUnsignedGreaterThanEqual: + return false; + + default: + UNREACHABLE(); + } +} + inline Condition NegateCondition(Condition cond) { DCHECK(cond != al); return static_cast(cond ^ ne); diff --git a/src/codegen/s390/constants-s390.h b/src/codegen/s390/constants-s390.h index 8bade7b2ab..c8d1121a91 100644 --- a/src/codegen/s390/constants-s390.h +++ b/src/codegen/s390/constants-s390.h @@ -123,7 +123,7 @@ enum Condition { kNotZero = 21, }; -inline Condition check_condition(Condition cond) { +inline Condition to_condition(Condition cond) { switch (cond) { case kUnsignedLessThan: return lt; @@ -143,6 +143,31 @@ inline Condition check_condition(Condition cond) { return cond; } +inline bool is_signed(Condition cond) { + switch (cond) { + case kEqual: + case kNotEqual: + case kLessThan: + case kGreaterThan: + case kLessThanEqual: + case kGreaterThanEqual: + case kOverflow: + case kNoOverflow: + case kZero: + case kNotZero: + return true; + + case kUnsignedLessThan: + case kUnsignedGreaterThan: + case kUnsignedLessThanEqual: + case kUnsignedGreaterThanEqual: + return false; + + default: + UNREACHABLE(); + } +} + inline Condition NegateCondition(Condition cond) { DCHECK(cond != al); switch (cond) { diff --git a/src/wasm/baseline/ppc/liftoff-assembler-ppc.h b/src/wasm/baseline/ppc/liftoff-assembler-ppc.h index d9888a9b4f..ace45df1bd 100644 --- a/src/wasm/baseline/ppc/liftoff-assembler-ppc.h +++ b/src/wasm/baseline/ppc/liftoff-assembler-ppc.h @@ -62,26 +62,6 @@ inline MemOperand GetStackSlot(uint32_t offset) { inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } -inline constexpr bool UseSignedOp(Condition cond) { - switch (cond) { - case kEqual: - case kNotEqual: - case kLessThan: - case kLessThanEqual: - case kGreaterThan: - case kGreaterThanEqual: - return true; - case kUnsignedLessThan: - case kUnsignedLessThanEqual: - case kUnsignedGreaterThan: - case kUnsignedGreaterThanEqual: - return false; - default: - UNREACHABLE(); - } - return false; -} - } // namespace liftoff int LiftoffAssembler::PrepareStackFrame() { @@ -1641,7 +1621,7 @@ void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, ValueKind kind, Register lhs, Register rhs, const FreezeCacheState& frozen) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (rhs != no_reg) { switch (kind) { @@ -1686,19 +1666,19 @@ void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, CmpS32(lhs, Operand::Zero(), r0); } - b(cond, label); + b(to_condition(cond), label); } void LiftoffAssembler::emit_i32_cond_jumpi(Condition cond, Label* label, Register lhs, int32_t imm, const FreezeCacheState& frozen) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (use_signed) { CmpS32(lhs, Operand(imm), r0); } else { CmpU32(lhs, Operand(imm), r0); } - b(cond, label); + b(to_condition(cond), label); } void LiftoffAssembler::emit_i32_subi_jump_negative( @@ -1719,7 +1699,7 @@ void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) { void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, Register lhs, Register rhs) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (use_signed) { CmpS32(lhs, rhs); } else { @@ -1727,7 +1707,7 @@ void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, } Label done; mov(dst, Operand(1)); - b(liftoff::ToCondition(cond), &done); + b(to_condition(to_condition(cond)), &done); mov(dst, Operand::Zero()); bind(&done); } @@ -1744,7 +1724,7 @@ void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { void LiftoffAssembler::emit_i64_set_cond(Condition cond, Register dst, LiftoffRegister lhs, LiftoffRegister rhs) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (use_signed) { CmpS64(lhs.gp(), rhs.gp()); } else { @@ -1752,7 +1732,7 @@ void LiftoffAssembler::emit_i64_set_cond(Condition cond, Register dst, } Label done; mov(dst, Operand(1)); - b(liftoff::ToCondition(cond), &done); + b(to_condition(to_condition(cond)), &done); mov(dst, Operand::Zero()); bind(&done); } @@ -1764,7 +1744,7 @@ void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst, Label nan, done; bunordered(&nan, cr0); mov(dst, Operand::Zero()); - b(NegateCondition(liftoff::ToCondition(cond)), &done, cr0); + b(NegateCondition(to_condition(to_condition(cond))), &done, cr0); mov(dst, Operand(1)); b(&done); bind(&nan); @@ -1779,7 +1759,7 @@ void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst, void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, DoubleRegister lhs, DoubleRegister rhs) { - emit_f32_set_cond(cond, dst, lhs, rhs); + emit_f32_set_cond(to_condition(cond), dst, lhs, rhs); } bool LiftoffAssembler::emit_select(LiftoffRegister dst, Register condition, diff --git a/src/wasm/baseline/s390/liftoff-assembler-s390.h b/src/wasm/baseline/s390/liftoff-assembler-s390.h index 0b3312eb0b..b7b7e281a0 100644 --- a/src/wasm/baseline/s390/liftoff-assembler-s390.h +++ b/src/wasm/baseline/s390/liftoff-assembler-s390.h @@ -18,26 +18,6 @@ namespace wasm { namespace liftoff { -inline constexpr bool UseSignedOp(Condition cond) { - switch (cond) { - case kEqual: - case kNotEqual: - case kLessThan: - case kLessThanEqual: - case kGreaterThan: - case kGreaterThanEqual: - return true; - case kUnsignedLessThan: - case kUnsignedLessThanEqual: - case kUnsignedGreaterThan: - case kUnsignedGreaterThanEqual: - return false; - default: - UNREACHABLE(); - } - return false; -} - // half // slot Frame // -----+--------------------+--------------------------- @@ -2106,7 +2086,7 @@ void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, ValueKind kind, Register lhs, Register rhs, const FreezeCacheState& frozen) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (rhs != no_reg) { switch (kind) { @@ -2151,19 +2131,19 @@ void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, CmpS32(lhs, Operand::Zero()); } - b(cond, label); + b(to_condition(cond), label); } void LiftoffAssembler::emit_i32_cond_jumpi(Condition cond, Label* label, Register lhs, int32_t imm, const FreezeCacheState& frozen) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (use_signed) { CmpS32(lhs, Operand(imm)); } else { CmpU32(lhs, Operand(imm)); } - b(cond, label); + b(to_condition(cond), label); } #define EMIT_EQZ(test, src) \ @@ -2198,14 +2178,14 @@ void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) { void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, Register lhs, Register rhs) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (use_signed) { CmpS32(lhs, rhs); } else { CmpU32(lhs, rhs); } - EMIT_SET_CONDITION(dst, cond); + EMIT_SET_CONDITION(dst, to_condition(cond)); } void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { @@ -2215,28 +2195,28 @@ void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { void LiftoffAssembler::emit_i64_set_cond(Condition cond, Register dst, LiftoffRegister lhs, LiftoffRegister rhs) { - bool use_signed = liftoff::UseSignedOp(cond); + bool use_signed = is_signed(cond); if (use_signed) { CmpS64(lhs.gp(), rhs.gp()); } else { CmpU64(lhs.gp(), rhs.gp()); } - EMIT_SET_CONDITION(dst, cond); + EMIT_SET_CONDITION(dst, to_condition(cond)); } void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst, DoubleRegister lhs, DoubleRegister rhs) { cebr(lhs, rhs); - EMIT_SET_CONDITION(dst, cond); + EMIT_SET_CONDITION(dst, to_condition(cond)); } void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, DoubleRegister lhs, DoubleRegister rhs) { cdbr(lhs, rhs); - EMIT_SET_CONDITION(dst, cond); + EMIT_SET_CONDITION(dst, to_condition(cond)); } bool LiftoffAssembler::emit_select(LiftoffRegister dst, Register condition,