Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SIMDExtractLane and SIMDReplaceLane classes #135

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 56 additions & 24 deletions src/interpreter/ByteCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,58 @@ class SIMDMemoryStore : public ByteCode {
ByteCodeStackOffset m_index;
};

// dummy ByteCode for simd extract lane operation
class SIMDExtractLane : public ByteCode {
public:
SIMDExtractLane(Opcode opcode, ByteCodeStackOffset index, ByteCodeStackOffset src, ByteCodeStackOffset dst)
: ByteCode(opcode)
, m_srcOffset(src)
, m_dstOffset(dst)
, m_index(index)
{
}

ByteCodeStackOffset index() const { return m_index; }
ByteCodeStackOffset srcOffset() const { return m_srcOffset; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }

#if !defined(NDEBUG)
void dump(size_t pos)
{
}
#endif
protected:
ByteCodeStackOffset m_srcOffset;
ByteCodeStackOffset m_dstOffset;
ByteCodeStackOffset m_index;
};

// dummy ByteCode for simd extract lane operation
class SIMDReplaceLane : public ByteCode {
public:
SIMDReplaceLane(Opcode opcode, ByteCodeStackOffset index, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset dst)
: ByteCode(opcode)
, m_srcOffsets{ src0, src1 }
, m_dstOffset(dst)
, m_index(index)
{
}

uint32_t index() const { return m_index; }
const ByteCodeStackOffset* srcOffsets() const { return m_srcOffsets; }
ByteCodeStackOffset dstOffset() const { return m_dstOffset; }

#if !defined(NDEBUG)
void dump(size_t pos)
{
}
#endif
protected:
ByteCodeStackOffset m_srcOffsets[2];
ByteCodeStackOffset m_dstOffset;
ByteCodeStackOffset m_index;
};

#if !defined(NDEBUG)
#define DEFINE_STORE_BYTECODE_DUMP(name) \
void dump(size_t pos) \
Expand Down Expand Up @@ -1565,23 +1617,13 @@ class SIMDMemoryStore : public ByteCode {
#endif

#define DEFINE_SIMD_EXTRACT_LANE_BYTECODE(name, ...) \
class name : public ByteCode { \
class name : public SIMDExtractLane { \
public: \
name(uint8_t index, ByteCodeStackOffset src, ByteCodeStackOffset dst) \
: ByteCode(Opcode::name##Opcode) \
, m_index(index) \
, m_srcOffset(src) \
, m_dstOffset(dst) \
: SIMDExtractLane(Opcode::name##Opcode, index, src, dst) \
{ \
} \
uint32_t index() const { return m_index; } \
ByteCodeStackOffset srcOffset() const { return m_srcOffset; } \
ByteCodeStackOffset dstOffset() const { return m_dstOffset; } \
DEFINE_SIMD_EXTRACT_LANE_BYTECODE_DUMP(name) \
protected: \
uint8_t m_index; \
ByteCodeStackOffset m_srcOffset; \
ByteCodeStackOffset m_dstOffset; \
};

#if !defined(NDEBUG)
Expand All @@ -1595,23 +1637,13 @@ class SIMDMemoryStore : public ByteCode {
#endif

#define DEFINE_SIMD_REPLACE_LANE_BYTECODE(name, ...) \
class name : public ByteCode { \
class name : public SIMDReplaceLane { \
public: \
name(uint8_t index, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset dst) \
: ByteCode(Opcode::name##Opcode) \
, m_index(index) \
, m_srcOffsets{ src0, src1 } \
, m_dstOffset(dst) \
: SIMDReplaceLane(Opcode::name##Opcode, index, src0, src1, dst) \
{ \
} \
uint32_t index() const { return m_index; } \
const ByteCodeStackOffset* srcOffsets() const { return m_srcOffsets; } \
ByteCodeStackOffset dstOffset() const { return m_dstOffset; } \
DEFINE_SIMD_REPLACE_LANE_BYTECODE_DUMP(name) \
protected: \
uint8_t m_index; \
ByteCodeStackOffset m_srcOffsets[2]; \
ByteCodeStackOffset m_dstOffset; \
};


Expand Down