Skip to content

Commit

Permalink
unify getMap and getMMM
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Dec 27, 2023
1 parent 0750873 commit e186464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion gen/avx_type_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@
static const uint64_t T_F2 = 1ull << 37; // pp = 3
// T_66 = 1, T_F3 = 2, T_F2 = 3
static inline uint32_t getPP(uint64_t type) { return (type & T_66) ? 1 : (type & T_F3) ? 2 : (type & T_F2) ? 3 : 0; }
static inline uint32_t getMMM(uint64_t type) { return (type & T_0F) ? 1 : (type & T_0F38) ? 2 : (type & T_0F3A) ? 3 : 0; }
// @@@end of avx_type_def.h
15 changes: 4 additions & 11 deletions xbyak/xbyak.h
Original file line number Diff line number Diff line change
Expand Up @@ -1832,8 +1832,8 @@ class CodeGenerator : public CodeArray {
static const uint64_t T_F2 = 1ull << 37; // pp = 3
// T_66 = 1, T_F3 = 2, T_F2 = 3
static inline uint32_t getPP(uint64_t type) { return (type & T_66) ? 1 : (type & T_F3) ? 2 : (type & T_F2) ? 3 : 0; }
static inline uint32_t getMMM(uint64_t type) { return (type & T_0F) ? 1 : (type & T_0F38) ? 2 : (type & T_0F3A) ? 3 : 0; }
// @@@end of avx_type_def.h
static inline uint32_t getMap(uint64_t type) { return (type & T_0F) ? 1 : (type & T_0F38) ? 2 : (type & T_0F3A) ? 3 : 0; }
void vex(const Reg& reg, const Reg& base, const Operand *v, uint64_t type, int code, bool x = false)
{
int w = (type & T_W1) ? 1 : 0;
Expand All @@ -1847,7 +1847,7 @@ class CodeGenerator : public CodeArray {
if (!b && !x && !w && (type & T_0F)) {
db(0xC5); db((r ? 0 : 0x80) | vvvv);
} else {
uint32_t mmmm = getMMM(type);
uint32_t mmmm = getMap(type);
db(0xC4); db((r ? 0 : 0x80) | (x ? 0 : 0x40) | (b ? 0 : 0x20) | mmmm); db((w << 7) | vvvv);
}
db(code);
Expand All @@ -1874,7 +1874,7 @@ class CodeGenerator : public CodeArray {
{
if (!(type & (T_EVEX | T_MUST_EVEX))) XBYAK_THROW_RET(ERR_EVEX_IS_INVALID, 0)
int w = (type & T_EW1) ? 1 : 0;
uint32_t mmm = getMMM(type);
uint32_t mmm = getMap(type);
if (type & T_FP16) mmm |= 4;
uint32_t pp = getPP(type);
int idx = v ? v->getIdx() : 0;
Expand Down Expand Up @@ -1926,17 +1926,10 @@ class CodeGenerator : public CodeArray {
db(code);
return disp8N;
}
static inline int getMap(uint64_t type)
{
if (type & T_0F) return 1;
if (type & T_0F38) return 2;
if (type & T_0F3A) return 3;
return 4; // legacy
}
// evex of Legacy
void evexLeg(const Reg& r, const Reg& b, const Reg& x, const Reg& v, uint64_t type, int sc = NONE)
{
int M = getMap(type);
int M = getMap(type); if (M == 0) M = 4; // legacy
int R3 = !r.isExtIdx();
int X3 = !x.isExtIdx();
int B3 = b.isExtIdx() ? 0 : 0x20;
Expand Down

0 comments on commit e186464

Please sign in to comment.