Skip to content

Commit

Permalink
Re-enable float select
Browse files Browse the repository at this point in the history
Signed-off-by: Zoltan Herczeg [email protected]
  • Loading branch information
Zoltan Herczeg committed Nov 21, 2023
1 parent ed6d35d commit dac2c27
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/interpreter/ByteCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1132,21 +1132,20 @@ class JumpIfFalse : public ByteCode {

class Select : public ByteCode {
public:
Select(ByteCodeStackOffset condOffset, uint16_t size, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset dst)
Select(ByteCodeStackOffset condOffset, uint16_t size, bool isFloat, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset dst)
: ByteCode(Opcode::SelectOpcode)
, m_condOffset(condOffset)
, m_valueSize(size)
, m_isFloat(isFloat)
, m_src0Offset(src0)
, m_src1Offset(src1)
, m_dstOffset(dst)
{
}

ByteCodeStackOffset condOffset() const { return m_condOffset; }
uint16_t valueSize() const
{
return m_valueSize;
}
uint16_t valueSize() const { return m_valueSize; }
bool isFloat() const { return m_isFloat != 0; }
ByteCodeStackOffset src0Offset() const { return m_src0Offset; }
ByteCodeStackOffset src1Offset() const { return m_src1Offset; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }
Expand All @@ -1164,7 +1163,8 @@ class Select : public ByteCode {

protected:
ByteCodeStackOffset m_condOffset;
uint16_t m_valueSize;
uint8_t m_valueSize;
uint8_t m_isFloat;
ByteCodeStackOffset m_src0Offset;
ByteCodeStackOffset m_src1Offset;
ByteCodeStackOffset m_dstOffset;
Expand Down
6 changes: 4 additions & 2 deletions src/jit/IntMath32Inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -860,11 +860,13 @@ void emitSelect(sljit_compiler* compiler, Instruction* instr, sljit_s32 type)
JITArg cond;
ASSERT(instr->opcode() == ByteCode::SelectOpcode && instr->paramCount() == 3);

if (false) {
Select* select = reinterpret_cast<Select*>(instr->byteCode());

if (select->isFloat()) {
return emitFloatSelect(compiler, instr, type);
}

if (reinterpret_cast<Select*>(instr->byteCode())->valueSize() == 4) {
if (select->valueSize() == 4) {
JITArg args[3] = { operands, operands + 1, operands + 3 };

if (type == -1) {
Expand Down
6 changes: 4 additions & 2 deletions src/jit/IntMath64Inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,13 @@ void emitSelect(sljit_compiler* compiler, Instruction* instr, sljit_s32 type)
Operand* operands = instr->operands();
assert(instr->opcode() == ByteCode::SelectOpcode && instr->paramCount() == 3);

if (false) {
Select* select = reinterpret_cast<Select*>(instr->byteCode());

if (select->isFloat()) {
return emitFloatSelect(compiler, instr, type);
}

bool is32 = reinterpret_cast<Select*>(instr->byteCode())->valueSize() == 4;
bool is32 = select->valueSize() == 4;
sljit_s32 movOpcode = is32 ? SLJIT_MOV32 : SLJIT_MOV;
JITArg args[3] = { operands, operands + 1, operands + 3 };

Expand Down
3 changes: 2 additions & 1 deletion src/parser/WASMParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,8 @@ class WASMBinaryReader : public wabt::WASMBinaryReaderDelegate {
auto src1 = popVMStack();
auto src0 = popVMStack();
auto dst = computeExprResultPosition(type);
pushByteCode(Walrus::Select(stackPos, Walrus::valueSize(type), src0, src1, dst), WASMOpcode::SelectOpcode);
bool isFloat = type == Walrus::Value::F32 || type == Walrus::Value::F64;
pushByteCode(Walrus::Select(stackPos, Walrus::valueSize(type), isFloat, src0, src1, dst), WASMOpcode::SelectOpcode);
}

virtual void OnThrowExpr(Index tagIndex) override
Expand Down

0 comments on commit dac2c27

Please sign in to comment.