Starting on some unary xmm opcodes.
This commit is contained in:
parent
234aa4f543
commit
c828e5416e
|
@ -1454,11 +1454,21 @@ table->AddSequence(OPCODE_MUL_SUB, [](X64Emitter& e, Instr*& i) {
|
|||
|
||||
table->AddSequence(OPCODE_NEG, [](X64Emitter& e, Instr*& i) {
|
||||
if (IsIntType(i->dest->type)) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
IntUnaryOp(e, i, [](X64Emitter& e, Instr& i, const Reg& dest_src) {
|
||||
e.neg(dest_src);
|
||||
});
|
||||
} else if (IsFloatType(i->dest->type)) {
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
if (i.src1.value->type == FLOAT32_TYPE) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
} else {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
}
|
||||
});
|
||||
} else if (IsVecType(i->dest->type)) {
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
});
|
||||
} else {
|
||||
ASSERT_INVALID_TYPE();
|
||||
}
|
||||
|
@ -1470,9 +1480,17 @@ table->AddSequence(OPCODE_ABS, [](X64Emitter& e, Instr*& i) {
|
|||
if (IsIntType(i->dest->type)) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
} else if (IsFloatType(i->dest->type)) {
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
if (i.src1.value->type == FLOAT32_TYPE) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
} else {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
}
|
||||
});
|
||||
} else if (IsVecType(i->dest->type)) {
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
});
|
||||
} else {
|
||||
ASSERT_INVALID_TYPE();
|
||||
}
|
||||
|
@ -1482,9 +1500,17 @@ table->AddSequence(OPCODE_ABS, [](X64Emitter& e, Instr*& i) {
|
|||
|
||||
table->AddSequence(OPCODE_SQRT, [](X64Emitter& e, Instr*& i) {
|
||||
if (IsFloatType(i->dest->type)) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
if (i.dest->type == FLOAT32_TYPE) {
|
||||
e.sqrtss(dest_src, dest_src);
|
||||
} else {
|
||||
e.sqrtsd(dest_src, dest_src);
|
||||
}
|
||||
});
|
||||
} else if (IsVecType(i->dest->type)) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
e.sqrtps(dest_src, dest_src);
|
||||
});
|
||||
} else {
|
||||
ASSERT_INVALID_TYPE();
|
||||
}
|
||||
|
@ -1494,9 +1520,19 @@ table->AddSequence(OPCODE_SQRT, [](X64Emitter& e, Instr*& i) {
|
|||
|
||||
table->AddSequence(OPCODE_RSQRT, [](X64Emitter& e, Instr*& i) {
|
||||
if (IsFloatType(i->dest->type)) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
if (i.dest->type == FLOAT32_TYPE) {
|
||||
e.rsqrtss(dest_src, dest_src);
|
||||
} else {
|
||||
e.cvtsd2ss(dest_src, dest_src);
|
||||
e.rsqrtss(dest_src, dest_src);
|
||||
e.cvtss2sd(dest_src, dest_src);
|
||||
}
|
||||
});
|
||||
} else if (IsVecType(i->dest->type)) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
e.rsqrtps(dest_src, dest_src);
|
||||
});
|
||||
} else {
|
||||
ASSERT_INVALID_TYPE();
|
||||
}
|
||||
|
@ -1602,7 +1638,11 @@ table->AddSequence(OPCODE_NOT, [](X64Emitter& e, Instr*& i) {
|
|||
e.not(dest_src);
|
||||
});
|
||||
} else if (IsVecType(i->dest->type)) {
|
||||
UNIMPLEMENTED_SEQ();
|
||||
XmmUnaryOp(e, i, i->flags, [](X64Emitter& e, Instr& i, const Xmm& dest_src) {
|
||||
// dest_src ^= 0xFFFF...
|
||||
e.cmpeqps(e.xmm0, e.xmm0);
|
||||
e.pxor(dest_src, e.xmm0);
|
||||
});
|
||||
} else {
|
||||
ASSERT_INVALID_TYPE();
|
||||
}
|
||||
|
|
|
@ -697,6 +697,47 @@ void IntTernaryOp(X64Emitter& e, Instr*& i, vvv_fn vvv_fn, vvc_fn vvc_fn, vcv_fn
|
|||
}
|
||||
}
|
||||
|
||||
typedef void(xmm_v_fn)(X64Emitter& e, Instr& i, const Xmm& dest_src);
|
||||
template<typename T>
|
||||
void XmmUnaryOpV(X64Emitter& e, Instr*& i, xmm_v_fn v_fn,
|
||||
T& dest, T& src1) {
|
||||
e.BeginOp(i->dest, dest, REG_DEST,
|
||||
i->src1.value, src1, 0);
|
||||
if (dest == src1) {
|
||||
v_fn(e, *i, dest);
|
||||
} else {
|
||||
e.movaps(dest, src1);
|
||||
v_fn(e, *i, dest);
|
||||
}
|
||||
e.EndOp(dest, src1);
|
||||
}
|
||||
template<typename CT, typename T>
|
||||
void XmmUnaryOpC(X64Emitter& e, Instr*& i, xmm_v_fn v_fn,
|
||||
T& dest, Value* src1) {
|
||||
e.BeginOp(i->dest, dest, REG_DEST);
|
||||
//e.mov(dest, (uint64_t)src1->get_constant(CT()));
|
||||
v_fn(e, *i, dest);
|
||||
e.EndOp(dest);
|
||||
}
|
||||
void XmmUnaryOp(X64Emitter& e, Instr*& i, uint32_t flags, xmm_v_fn v_fn) {
|
||||
if (IsFloatType(i->src1.value->type)) {
|
||||
//
|
||||
} else if (IsVecType(i->src1.value->type)) {
|
||||
//
|
||||
} else {
|
||||
ASSERT_INVALID_TYPE();
|
||||
}
|
||||
if (i->Match(SIG_TYPE_I8, SIG_TYPE_I8)) {
|
||||
Xmm dest, src1;
|
||||
XmmUnaryOpV(e, i, v_fn, dest, src1);
|
||||
} else if (i->Match(SIG_TYPE_I8, SIG_TYPE_I8C)) {
|
||||
Xmm dest, src1;
|
||||
XmmUnaryOpC<int8_t>(e, i, v_fn, dest, i->src1.value);
|
||||
} else {
|
||||
ASSERT_INVALID_TYPE();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // ALLOY_BACKEND_X64_X64_LOWERING_OP_UTILS_INL_
|
||||
|
|
Loading…
Reference in New Issue