mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-28 16:01:31 +00:00
Implement a CFG for the assembler to improve the soundness of the checks
This commit is contained in:
@@ -821,6 +821,21 @@ main :: proc() {
|
||||
}
|
||||
""")
|
||||
|
||||
strings.write_string(&sb, """
|
||||
bool is_self_zeroing_idiom(u16 m) const {
|
||||
switch (m) {
|
||||
case M_XOR:
|
||||
case M_SUB:
|
||||
case M_SUBW:
|
||||
case M_SLT:
|
||||
case M_SLTU:
|
||||
case M_ANDN:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
""")
|
||||
|
||||
strings.write_string(&sb, "\n};\n")
|
||||
|
||||
strings.write_string(&sb, "\n\n\n")
|
||||
|
||||
@@ -824,6 +824,45 @@ main :: proc() {
|
||||
}
|
||||
""")
|
||||
|
||||
strings.write_string(&sb, """
|
||||
bool is_self_zeroing_idiom(u16 m) const {
|
||||
switch (m) {
|
||||
// integer xor / sub: x ^ x == 0, x - x == 0
|
||||
case M_XOR:
|
||||
case M_SUB:
|
||||
|
||||
// SSE/AVX bitwise xor of a register with itself
|
||||
case M_PXOR:
|
||||
case M_XORPS:
|
||||
case M_XORPD:
|
||||
case M_VPXOR:
|
||||
case M_VXORPS:
|
||||
case M_VXORPD:
|
||||
|
||||
// packed integer subtract: psub x, x == 0
|
||||
case M_PSUBB:
|
||||
case M_PSUBW:
|
||||
case M_PSUBD:
|
||||
case M_PSUBQ:
|
||||
case M_VPSUBB:
|
||||
case M_VPSUBW:
|
||||
case M_VPSUBD:
|
||||
case M_VPSUBQ:
|
||||
|
||||
// andnot of a value with itself: (~x) & x == 0
|
||||
case M_ANDN: // BMI1 GPR: andn dst, a, a
|
||||
case M_ANDNPS:
|
||||
case M_ANDNPD:
|
||||
case M_PANDN:
|
||||
case M_VANDNPS:
|
||||
case M_VANDNPD:
|
||||
case M_VPANDN:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
""")
|
||||
|
||||
strings.write_string(&sb, "\n};\n")
|
||||
|
||||
strings.write_string(&sb, "\n\n\n")
|
||||
|
||||
Reference in New Issue
Block a user