Skip to content

Commit 6f37ed9

Browse files
committed
verify tmp not to destroy the values of dst/src
1 parent 9db7da1 commit 6f37ed9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

xbyak_aarch64/xbyak_aarch64_meta_mnemonic.h

+12
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ void and_imm(const WReg &dst, const WReg &src, uint32_t imm, const WReg &tmp) {
504504
if (isValidLogicalImm(imm, 32)) {
505505
and_(dst, src, imm);
506506
} else {
507+
if (dst.getIdx() == tmp.getIdx() || src.getIdx() == tmp.getIdx()) {
508+
throw Error(ERR_ILLEGAL_REG_IDX);
509+
}
507510
mov(tmp, imm);
508511
and_(dst, src, tmp);
509512
}
@@ -513,6 +516,9 @@ void ands_imm(const WReg &dst, const WReg &src, uint32_t imm, const WReg &tmp) {
513516
if (isValidLogicalImm(imm, 32)) {
514517
ands(dst, src, imm);
515518
} else {
519+
if (dst.getIdx() == tmp.getIdx() || src.getIdx() == tmp.getIdx()) {
520+
throw Error(ERR_ILLEGAL_REG_IDX);
521+
}
516522
mov(tmp, imm);
517523
ands(dst, src, tmp);
518524
}
@@ -522,6 +528,9 @@ void orr_imm(const WReg &dst, const WReg &src, uint32_t imm, const WReg &tmp) {
522528
if (isValidLogicalImm(imm, 32)) {
523529
orr(dst, src, imm);
524530
} else {
531+
if (dst.getIdx() == tmp.getIdx() || src.getIdx() == tmp.getIdx()) {
532+
throw Error(ERR_ILLEGAL_REG_IDX);
533+
}
525534
mov(tmp, imm);
526535
orr(dst, src, tmp);
527536
}
@@ -531,6 +540,9 @@ void eor_imm(const WReg &dst, const WReg &src, uint32_t imm, const WReg &tmp) {
531540
if (isValidLogicalImm(imm, 32)) {
532541
eor(dst, src, imm);
533542
} else {
543+
if (dst.getIdx() == tmp.getIdx() || src.getIdx() == tmp.getIdx()) {
544+
throw Error(ERR_ILLEGAL_REG_IDX);
545+
}
534546
mov(tmp, imm);
535547
eor(dst, src, tmp);
536548
}

0 commit comments

Comments
 (0)