-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen_helpers.go
More file actions
32 lines (29 loc) · 1.36 KB
/
Copy pathcodegen_helpers.go
File metadata and controls
32 lines (29 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package compressor
// setNZCV32 sets the NZCV flags for a 32-bit subtract operation.
// Called from codegen as: { _v := uint32(rn) - uint32(imm); setNZCV32(_v, rn, &nz, &zz, &cz, &vz) }
// The second argument (rn) is the original uint64 register value.
// The result is the 32-bit subtraction result.
func setNZCV32(result uint32, rn uint64, nz, zz, cz, vz *bool) {
*nz = int32(result) < 0
*zz = result == 0
// For CMP (subtraction), carry = no borrow: rn >= subtracted value
// We can derive the subtracted value: sub = uint32(rn) - result
rnW := uint32(rn)
sub := rnW - result
*cz = rnW >= sub
// Overflow: sign of result differs from sign of rn, AND signs of operands differ
*vz = (int32(rnW) >= 0) != (int32(result) >= 0) && (int32(rnW) >= 0) != (int32(sub) >= 0)
}
// setNZCV64 sets the NZCV flags for a 64-bit subtract operation.
func setNZCV64(result uint64, rn uint64, nz, zz, cz, vz *bool) {
*nz = int64(result) < 0
*zz = result == 0
sub := rn - result
*cz = rn >= sub
*vz = (int64(rn) >= 0) != (int64(result) >= 0) && (int64(rn) >= 0) != (int64(sub) >= 0)
}
// fpExecSIMDCompiled delegates SIMD/FP load/store/compute to the interpreter.
func fpExecSIMDCompiled(x *[31]uint64, sp *uint64, vreg [][2]uint64, mem []byte, inst uint32) {
// SIMD execution stub removed for standalone generic release.
// Users must provide their own SIMD state tracking if needed.
}