Skip to content

Commit

Permalink
remove space
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Nov 9, 2023
1 parent 6fa1b4a commit 9b21727
Show file tree
Hide file tree
Showing 6 changed files with 917 additions and 936 deletions.
116 changes: 44 additions & 72 deletions gen/avx_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

const int NONE = 256; // same as Xbyak::CodeGenerator::NONE

std::string type2String(int type)
std::string type2String(uint64_t type)
{
if (type == 0) return "T_NONE";
std::string str;
int low = type & T_NX_MASK;
if (0 < low && low < 7) {
Expand All @@ -15,132 +16,103 @@ std::string type2String(int type)
str = tbl[low - 1];
}
if (type & T_N_VL) {
if (!str.empty()) str += " | ";
str += "T_N_VL";
str += "|T_N_VL";
}
if (type & T_VEX) {
if (!str.empty()) str += " | ";
str += "T_VEX";
str += "|T_VEX";
}
if ((type & T_NX_MASK) == T_DUP) {
if (!str.empty()) str += " | ";
str += "T_DUP";
}
if (type & T_F2) {
if (!str.empty()) str += " | ";
switch (type & T_F2) {
case T_66: str += "T_66"; break;
case T_F3: str += "T_F3"; break;
case T_F2: str += "T_F2"; break;
default: break;
}
str += "|T_DUP";
}
switch (type & T_F2) { // T_F2 = T_66|T_F3
case T_66: str += "|T_66"; break;
case T_F3: str += "|T_F3"; break;
case T_F2: str += "|T_F2"; break;
default: break;
}
if (type & T_0F) {
if (!str.empty()) str += " | ";
if (type & T_FP16) {
str += "T_MAP5";
str += "|T_MAP5";
} else {
str += "T_0F";
str += "|T_0F";
}
}
if (type & T_0F38) {
if (!str.empty()) str += " | ";
if (type & T_FP16) {
str += "T_MAP6";
str += "|T_MAP6";
} else {
str += "T_0F38";
str += "|T_0F38";
}
}
if (type & T_0F3A) {
if (!str.empty()) str += " | ";
str += "T_0F3A";
str += "|T_0F3A";
}
if (type & T_L0) {
if (!str.empty()) str += " | ";
str += "VEZ_L0";
str += "|T_L0";
}
if (type & T_L1) {
if (!str.empty()) str += " | ";
str += "VEZ_L1";
str += "|T_L1";
}
if (type & T_W0) {
if (!str.empty()) str += " | ";
str += "T_W0";
str += "|T_W0";
}
if (type & T_W1) {
if (!str.empty()) str += " | ";
str += "T_W1";
str += "|T_W1";
}
if (type & T_EW0) {
if (!str.empty()) str += " | ";
str += "T_EW0";
str += "|T_EW0";
}
if (type & T_EW1) {
if (!str.empty()) str += " | ";
str += "T_EW1";
str += "|T_EW1";
}
if (type & T_YMM) {
if (!str.empty()) str += " | ";
str += "T_YMM";
str += "|T_YMM";
}
if (type & T_EVEX) {
if (!str.empty()) str += " | ";
str += "T_EVEX";
str += "|T_EVEX";
}
if (type & T_ER_X) {
if (!str.empty()) str += " | ";
str += "T_ER_X";
str += "|T_ER_X";
}
if (type & T_ER_Y) {
if (!str.empty()) str += " | ";
str += "T_ER_Y";
str += "|T_ER_Y";
}
if (type & T_ER_Z) {
if (!str.empty()) str += " | ";
str += "T_ER_Z";
str += "|T_ER_Z";
}
if (type & T_ER_R) {
if (!str.empty()) str += " | ";
str += "T_ER_R";
str += "|T_ER_R";
}
if (type & T_SAE_X) {
if (!str.empty()) str += " | ";
str += "T_SAE_X";
str += "|T_SAE_X";
}
if (type & T_SAE_Y) {
if (!str.empty()) str += " | ";
str += "T_SAE_Y";
str += "|T_SAE_Y";
}
if (type & T_SAE_Z) {
if (!str.empty()) str += " | ";
str += "T_SAE_Z";
str += "|T_SAE_Z";
}
if (type & T_MUST_EVEX) {
if (!str.empty()) str += " | ";
str += "T_MUST_EVEX";
str += "|T_MUST_EVEX";
}
if (type & T_B32) {
if (!str.empty()) str += " | ";
if (type & T_B64) {
str += "T_B16"; // T_B16 = T_B32 | T_B64
} else {
str += "T_B32";
}
} else if (type & T_B64) {
if (!str.empty()) str += " | ";
str += "T_B64";
switch (type & T_B16) { // T_B16 = T_B32 | T_B64
case T_B16: str += "|T_B16"; break;
case T_B32: str += "|T_B32"; break;
case T_B64: str += "|T_B64"; break;
default: break;
}
if (type & T_M_K) {
if (!str.empty()) str += " | ";
str += "T_M_K";
str += "|T_M_K";
}
if (type & T_VSIB) {
if (!str.empty()) str += " | ";
str += "T_VSIB";
str += "|T_VSIB";
}
if (type & T_MEM_EVEX) {
if (!str.empty()) str += " | ";
str += "T_MEM_EVEX";
str += "|T_MEM_EVEX";
}
if (type & T_NF) {
str += "|T_NF";
}
if (str[0] == '|') str = str.substr(1);
return str;
}
8 changes: 5 additions & 3 deletions gen/avx_type_def.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @@@begin of avx_type_def.h
enum AVXtype {
T_NONE = 0,
// low 3 bit
T_N1 = 1,
T_N2 = 2,
Expand Down Expand Up @@ -38,12 +39,13 @@
T_B16 = T_B32 | T_B64, // m16bcst (Be careful)
T_M_K = 1 << 28, // mem{k}
T_VSIB = 1 << 29,
T_MEM_EVEX = 1 << 30, // use evex if mem
T_FP16 = 1 << 31, // avx512-fp16
T_MEM_EVEX = 1u << 30, // use evex if mem
T_FP16 = 1u << 31, // avx512-fp16
T_MAP5 = T_FP16 | T_0F,
T_MAP6 = T_FP16 | T_0F38,
T_NF = 1ull << 32, // T_nf
T_XXX
};
// T_66 = 1, T_F3 = 2, T_F2 = 3
static inline uint32_t getPP(int type) { return (type >> 5) & 3; }
static inline uint32_t getPP(uint64_t type) { return (type >> 5) & 3; }
// @@@end of avx_type_def.h
34 changes: 17 additions & 17 deletions gen/gen_avx512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void putVcmp()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
bool hasIMM;
} tbl[] = {
{ 0xC2, "vcmppd", T_0F | T_MUST_EVEX | T_EW1 | T_SAE_Z | T_YMM | T_66 | T_B64, true },
Expand Down Expand Up @@ -173,7 +173,7 @@ void putX_XM()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
} tbl[] = {
{ 0x6F, "vmovdqa32", T_66 | T_0F | T_MUST_EVEX | T_YMM | T_EW0 | T_ER_X | T_ER_Y | T_ER_Z },
{ 0x6F, "vmovdqa64", T_66 | T_0F | T_MUST_EVEX | T_YMM | T_EW1 | T_ER_X | T_ER_Y | T_ER_Z },
Expand Down Expand Up @@ -229,7 +229,7 @@ void putM_X()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
} tbl[] = {
{ 0x7F, "vmovdqa32", T_66 | T_0F | T_MUST_EVEX | T_YMM | T_EW0 | T_ER_X | T_ER_Y | T_ER_Z | T_M_K },
{ 0x7F, "vmovdqa64", T_66 | T_0F | T_MUST_EVEX | T_YMM | T_EW1 | T_ER_X | T_ER_Y | T_ER_Z | T_M_K },
Expand All @@ -252,7 +252,7 @@ void putXM_X()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
} tbl[] = {
{ 0x8A, "vcompresspd", T_66 | T_0F38 | T_MUST_EVEX | T_YMM | T_EW1 | T_N8 },
{ 0x8A, "vcompressps", T_66 | T_0F38 | T_MUST_EVEX | T_YMM | T_EW0 | T_N4 },
Expand All @@ -275,7 +275,7 @@ void putX_X_XM_IMM()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
bool hasIMM;
} tbl[] = {
{ 0x03, "valignd", T_MUST_EVEX | T_66 | T_0F3A | T_EW0 | T_YMM, true },
Expand Down Expand Up @@ -425,7 +425,7 @@ void putShift()
const char *name;
uint8_t code;
int idx;
int type;
uint64_t type;
} tbl[] = {
{ "vpsraq", 0x72, 4, T_0F | T_66 | T_YMM | T_MUST_EVEX |T_EW1 | T_B64 },
{ "vprold", 0x72, 1, T_66 | T_0F | T_YMM | T_MUST_EVEX | T_EW0 | T_B32 },
Expand All @@ -446,7 +446,7 @@ void putExtractInsert()
const struct Tbl {
const char *name;
uint8_t code;
int type;
uint64_t type;
bool isZMM;
} tbl[] = {
{ "vextractf32x4", 0x19, T_66 | T_0F3A | T_MUST_EVEX | T_EW0 | T_YMM | T_N16, false },
Expand All @@ -470,7 +470,7 @@ void putExtractInsert()
const struct Tbl {
const char *name;
uint8_t code;
int type;
uint64_t type;
bool isZMM;
} tbl[] = {
{ "vinsertf32x4", 0x18, T_66 | T_0F3A | T_MUST_EVEX | T_EW0 | T_YMM | T_N16, false },
Expand Down Expand Up @@ -501,7 +501,7 @@ void putBroadcast(bool only64bit)
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
int reg;
} tbl[] = {
{ 0x7A, "vpbroadcastb", T_66 | T_0F38 | T_YMM | T_MUST_EVEX | T_EW0, 8 },
Expand Down Expand Up @@ -536,7 +536,7 @@ void putCvt()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
int ptn;
} tbl[] = {
{ 0x79, "vcvtsd2usi", T_F2 | T_0F | T_MUST_EVEX | T_N8 | T_ER_X, 0 },
Expand Down Expand Up @@ -586,7 +586,7 @@ void putCvt()
std::string type = type2String(p.type);
switch (p.ptn) {
case 0:
printf("void %s(const Reg32e& r, const Operand& op) { int type = (%s) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x%02X); }\n", p.name, type.c_str(), p.code);
printf("void %s(const Reg32e& r, const Operand& op) { uint64_t type = (%s) | (r.isREG(64) ? T_EW1 : T_EW0); opVex(r, &xm0, op, type, 0x%02X); }\n", p.name, type.c_str(), p.code);
break;
case 1:
printf("void %s(const Xmm& x, const Operand& op) { checkCvt1(x, op); opVex(x, 0, op, %s, 0x%02X); }\n", p.name, type.c_str(), p.code);
Expand All @@ -604,7 +604,7 @@ void putCvt()
printf("void %s(const Xmm& x, const Operand& op) { opCvt5(x, op, %s, 0x%02X); }\n", p.name, type.c_str(), p.code);
break;
case 6:
printf("void %s(const Xmm& x1, const Xmm& x2, const Operand& op) { if (!(x1.isXMM() && x2.isXMM() && op.isBit(32|64))) XBYAK_THROW(ERR_BAD_COMBINATION) int type = (%s) | (op.isBit(32) ? (T_EW0 | T_N4) : (T_EW1 | T_N8)); opVex(x1, &x2, op, type, 0x%02X); }\n", p.name, type.c_str(), p.code);
printf("void %s(const Xmm& x1, const Xmm& x2, const Operand& op) { if (!(x1.isXMM() && x2.isXMM() && op.isBit(32|64))) XBYAK_THROW(ERR_BAD_COMBINATION) uint64_t type = (%s) | (op.isBit(32) ? (T_EW0 | T_N4) : (T_EW1 | T_N8)); opVex(x1, &x2, op, type, 0x%02X); }\n", p.name, type.c_str(), p.code);
break;
}
}
Expand All @@ -621,7 +621,7 @@ void putGather()
{
const struct Tbl {
const char *name;
int type;
uint64_t type;
uint8_t code;
int mode;
} tbl[] = {
Expand All @@ -644,7 +644,7 @@ void putScatter()
{
const struct Tbl {
const char *name;
int type;
uint64_t type;
uint8_t code;
int mode; // reverse of gather
} tbl[] = {
Expand Down Expand Up @@ -689,7 +689,7 @@ void putMov()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
int mode;
} tbl[] = {
{ 0x32, "vpmovqb", T_F3 | T_0F38 | T_MUST_EVEX | T_YMM | T_EW0 | T_N2 | T_N_VL | T_M_K, false },
Expand Down Expand Up @@ -729,7 +729,7 @@ void putX_XM_IMM()
const struct Tbl {
uint8_t code;
const char *name;
int type;
uint64_t type;
bool hasIMM;
} tbl[] = {
{ 0x26, "vgetmantpd", T_66 | T_0F3A | T_YMM | T_MUST_EVEX | T_EW1 | T_B64 | T_SAE_Z, true },
Expand Down Expand Up @@ -784,7 +784,7 @@ void putMisc()
const struct Tbl {
const char *name;
int zm;
int type;
uint64_t type;
uint8_t code;
bool isZmm;
} tbl[] = {
Expand Down
Loading

0 comments on commit 9b21727

Please sign in to comment.