aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <[email protected]>2023-11-22 13:53:58 +0900
committerMITSUNARI Shigeo <[email protected]>2023-11-22 13:53:58 +0900
commitff01b1e20c76675f4cfe24d9c7a1becb0a76c9f0 (patch)
tree8ea3899ff8f9f02cbed0825c0f3435c4a2cc589b
parent25ceea2eff32e2ae79f7499c292041d2208e16d1 (diff)
downloadxbyak-ff01b1e20c76675f4cfe24d9c7a1becb0a76c9f0.tar.gz
xbyak-ff01b1e20c76675f4cfe24d9c7a1becb0a76c9f0.zip
setcc supports apx
-rw-r--r--gen/gen_code.cpp2
-rw-r--r--test/apx.cpp11
-rw-r--r--xbyak/xbyak.h8
-rw-r--r--xbyak/xbyak_mnemonic.h60
4 files changed, 48 insertions, 33 deletions
diff --git a/gen/gen_code.cpp b/gen/gen_code.cpp
index ba2f23e..8cce9a5 100644
--- a/gen/gen_code.cpp
+++ b/gen/gen_code.cpp
@@ -630,7 +630,7 @@ void put()
printf("void j%s(const Label& label, LabelType type = T_AUTO) { opJmp(label, type, 0x%02X, 0x%02X, 0x%02X); }%s\n", p->name, p->ext | 0x70, p->ext | 0x80, 0x0F, msg);
printf("void j%s(const char *label, LabelType type = T_AUTO) { j%s(std::string(label), type); }%s\n", p->name, p->name, msg);
printf("void j%s(const void *addr) { opJmpAbs(addr, T_NEAR, 0x%02X, 0x%02X, 0x%02X); }%s\n", p->name, p->ext | 0x70, p->ext | 0x80, 0x0F, msg);
- printf("void set%s(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | %d); }%s\n", p->name, p->ext, msg);
+ printf("void set%s(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | %d)) return; opRext(op, 8, 0, T_0F, 0x90 | %d); }%s\n", p->name, p->ext, p->ext, msg);
}
}
{
diff --git a/test/apx.cpp b/test/apx.cpp
index 64ee8f5..080dcc1 100644
--- a/test/apx.cpp
+++ b/test/apx.cpp
@@ -1069,6 +1069,11 @@ CYBOZU_TEST_AUTO(mov_misc)
cmovb(r8, r9, r10);
cmovb(r8d, r9d, r10d);
+
+ setb(r31b);
+ setb(r31b|T_zu);
+ setb(r15b|T_zu);
+ setb(ptr [r30]);
}
} c;
const uint8_t tbl[] = {
@@ -1091,6 +1096,12 @@ CYBOZU_TEST_AUTO(mov_misc)
// cmovb
0x62, 0x54, 0xbc, 0x18, 0x42, 0xca,
0x62, 0x54, 0x3c, 0x18, 0x42, 0xca,
+ // setb
+ 0x62, 0xdc, 0x7f, 0x08, 0x42, 0xc7,
+ 0x62, 0xdc, 0x7f, 0x18, 0x42, 0xc7,
+ 0x62, 0xd4, 0x7f, 0x18, 0x42, 0xc7,
+ 0x62, 0xdc, 0x7f, 0x08, 0x42, 0x06,
+
};
const size_t n = sizeof(tbl);
CYBOZU_TEST_EQUAL(c.getSize(), n);
diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h
index e02df10..48d9fad 100644
--- a/xbyak/xbyak.h
+++ b/xbyak/xbyak.h
@@ -1932,7 +1932,7 @@ private:
int X4 = x.isExtIdx2() ? 0 : 0x04;
int pp = (type & (T_F2|T_F3|T_66)) ? getPP(type) : (r.isBit(16) || v.isBit(16));
int V4 = !v.isExtIdx2();
- int ND = (type & T_ZU) ? r.getZU() : (type & T_ND1) ? 1 : (type & T_VEX) ? 0 : v.isREG();
+ int ND = (type & T_ZU) ? (r.getZU() || b.getZU()) : (type & T_ND1) ? 1 : (type & T_VEX) ? 0 : v.isREG();
int NF = r.getNF() | b.getNF() | x.getNF() | v.getNF();
int L = 0;
if ((type & T_NF) == 0 && NF) XBYAK_THROW(ERR_INVALID_NF)
@@ -2203,7 +2203,7 @@ private:
int opBit = op.getBit();
if (disableRex && opBit == 64) opBit = 32;
const Reg r(ext, Operand::REG, opBit);
- if ((type & T_VEX) && op.hasRex2NF() && opROO(d ? *d : Reg(0, Operand::REG, opBit), op, r, type, code)) return;
+ if ((type & T_VEX) && op.hasRex2NFZU() && opROO(d ? *d : Reg(0, Operand::REG, opBit), op, r, type, code)) return;
if (op.isMEM()) {
opMR(op.getAddress(), r, type, code, immSize);
} else if (op.isREG(bit)) {
@@ -3040,6 +3040,10 @@ public:
// set default encoding to select Vex or Evex
void setDefaultEncoding(PreferredEncoding encoding) { defaultEncoding_ = encoding; }
+ void setb2(const Operand& op)
+ {
+ opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x42);
+ }
/*
use single byte nop if useMultiByteNop = false
*/
diff --git a/xbyak/xbyak_mnemonic.h b/xbyak/xbyak_mnemonic.h
index 21277db..cbb8375 100644
--- a/xbyak/xbyak_mnemonic.h
+++ b/xbyak/xbyak_mnemonic.h
@@ -813,36 +813,36 @@ void scasb() { db(0xAE); }
void scasd() { db(0xAF); }
void scasw() { db(0x66); db(0xAF); }
void serialize() { db(0x0F); db(0x01); db(0xE8); }
-void seta(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 7); }//-V524
-void setae(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 3); }//-V524
-void setb(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 2); }//-V524
-void setbe(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 6); }//-V524
-void setc(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 2); }//-V524
-void sete(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 4); }//-V524
-void setg(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 15); }//-V524
-void setge(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 13); }//-V524
-void setl(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 12); }//-V524
-void setle(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 14); }//-V524
-void setna(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 6); }//-V524
-void setnae(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 2); }//-V524
-void setnb(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 3); }//-V524
-void setnbe(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 7); }//-V524
-void setnc(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 3); }//-V524
-void setne(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 5); }//-V524
-void setng(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 14); }//-V524
-void setnge(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 12); }//-V524
-void setnl(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 13); }//-V524
-void setnle(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 15); }//-V524
-void setno(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 1); }//-V524
-void setnp(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 11); }//-V524
-void setns(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 9); }//-V524
-void setnz(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 5); }//-V524
-void seto(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 0); }//-V524
-void setp(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 10); }//-V524
-void setpe(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 10); }//-V524
-void setpo(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 11); }//-V524
-void sets(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 8); }//-V524
-void setz(const Operand& op) { opRext(op, 8, 0, T_0F, 0x90 | 4); }//-V524
+void seta(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 7)) return; opRext(op, 8, 0, T_0F, 0x90 | 7); }//-V524
+void setae(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 3)) return; opRext(op, 8, 0, T_0F, 0x90 | 3); }//-V524
+void setb(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 2)) return; opRext(op, 8, 0, T_0F, 0x90 | 2); }//-V524
+void setbe(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 6)) return; opRext(op, 8, 0, T_0F, 0x90 | 6); }//-V524
+void setc(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 2)) return; opRext(op, 8, 0, T_0F, 0x90 | 2); }//-V524
+void sete(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 4)) return; opRext(op, 8, 0, T_0F, 0x90 | 4); }//-V524
+void setg(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 15)) return; opRext(op, 8, 0, T_0F, 0x90 | 15); }//-V524
+void setge(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 13)) return; opRext(op, 8, 0, T_0F, 0x90 | 13); }//-V524
+void setl(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 12)) return; opRext(op, 8, 0, T_0F, 0x90 | 12); }//-V524
+void setle(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 14)) return; opRext(op, 8, 0, T_0F, 0x90 | 14); }//-V524
+void setna(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 6)) return; opRext(op, 8, 0, T_0F, 0x90 | 6); }//-V524
+void setnae(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 2)) return; opRext(op, 8, 0, T_0F, 0x90 | 2); }//-V524
+void setnb(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 3)) return; opRext(op, 8, 0, T_0F, 0x90 | 3); }//-V524
+void setnbe(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 7)) return; opRext(op, 8, 0, T_0F, 0x90 | 7); }//-V524
+void setnc(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 3)) return; opRext(op, 8, 0, T_0F, 0x90 | 3); }//-V524
+void setne(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 5)) return; opRext(op, 8, 0, T_0F, 0x90 | 5); }//-V524
+void setng(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 14)) return; opRext(op, 8, 0, T_0F, 0x90 | 14); }//-V524
+void setnge(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 12)) return; opRext(op, 8, 0, T_0F, 0x90 | 12); }//-V524
+void setnl(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 13)) return; opRext(op, 8, 0, T_0F, 0x90 | 13); }//-V524
+void setnle(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 15)) return; opRext(op, 8, 0, T_0F, 0x90 | 15); }//-V524
+void setno(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 1)) return; opRext(op, 8, 0, T_0F, 0x90 | 1); }//-V524
+void setnp(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 11)) return; opRext(op, 8, 0, T_0F, 0x90 | 11); }//-V524
+void setns(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 9)) return; opRext(op, 8, 0, T_0F, 0x90 | 9); }//-V524
+void setnz(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 5)) return; opRext(op, 8, 0, T_0F, 0x90 | 5); }//-V524
+void seto(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 0)) return; opRext(op, 8, 0, T_0F, 0x90 | 0); }//-V524
+void setp(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 10)) return; opRext(op, 8, 0, T_0F, 0x90 | 10); }//-V524
+void setpe(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 10)) return; opRext(op, 8, 0, T_0F, 0x90 | 10); }//-V524
+void setpo(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 11)) return; opRext(op, 8, 0, T_0F, 0x90 | 11); }//-V524
+void sets(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 8)) return; opRext(op, 8, 0, T_0F, 0x90 | 8); }//-V524
+void setz(const Operand& op) { if (opROO(Reg(), op, Reg(), T_VEX|T_ZU|T_F2, 0x40 | 4)) return; opRext(op, 8, 0, T_0F, 0x90 | 4); }//-V524
void sfence() { db(0x0F); db(0xAE); db(0xF8); }
void sha1msg1(const Xmm& xmm, const Operand& op) { opSSE(xmm, op, T_0F38, 0xC9, isXMM_XMMorMEM, NONE); }
void sha1msg2(const Xmm& xmm, const Operand& op) { opSSE(xmm, op, T_0F38, 0xCA, isXMM_XMMorMEM, NONE); }