52 lines
2.5 KiB
Markdown
52 lines
2.5 KiB
Markdown
# FUN_18002f980 (giant) — recursive FFT plan/permuation generator
|
|
|
|
Signature: `ulonglong *FUN_18002f980(plan*, log2, src, flags, depth, uVar2, scratch)`
|
|
|
|
Role: builds the FFT stage plan (bit-reverse ordering + sign-flip masks),
|
|
NOT a numeric executor (no FP math inside; all integer indexing).
|
|
|
|
## Factor split (top)
|
|
```
|
|
iVar2 = DAT_181c5e0fc[log2] // per-log2 factor (4/8/9/13... from static table)
|
|
iVar19 = log2 - iVar2 // reduced log2 for subproblem
|
|
if iVar19 < 0x12: pu = FUN_18002e360(iVar19, scr) // small-plan path (radix2/3 generator)
|
|
else: pu = FUN_18002f980(plan, iVar19, scr, ..., depth+1) // recurse
|
|
*(plan + 0x78 + depth*8) = pu // store sub-plan ptr per depth
|
|
*(plan + 0x38) = param_6 // (entry stores callback/context)
|
|
*(plan + 0x1c) = (1<<iVar19)*0x10 + 0x3f & ~0x3f // size budget
|
|
```
|
|
|
|
## Stage iteration
|
|
```
|
|
iVar25 = 1 << iVar19
|
|
uVar3 = DAT_181c5e15c[log2] // 2nd factor table (stage exponent bundle)
|
|
iVar33 = 1 << (uVar3 - iVar2) // butterfly count/base
|
|
loop groups:
|
|
for (uVar26=1; ...) {
|
|
iVar44 = 1 << (iVar16+2); iVar32 = 1 << (iVar16+2 + dirflag)
|
|
if (iVar12 == log2) -> radix-8 permute block
|
|
local_900[k]=src[±idx*8] (and ^= DAT_181c5e1e0 for negative/reflected)
|
|
processed 16 qwords = 8 complex pairs; groups x butterflies
|
|
next stage: uVar26 <<= 2; iVar16 -= 2 // radix-4 sweep
|
|
else branch radix-3: uVar26 <<= 3; iVar16 -= 3
|
|
...
|
|
}
|
|
while (iVar12 < log2)
|
|
outer while (uVar24 < (iVar25-1+iVar33)/iVar33)
|
|
```
|
|
|
|
## Key masive consts
|
|
- DAT_181c5e1e0 = sign-flip XOR mask (bit for im part) applied to mirrored indices.
|
|
- DAT_181c5e0fc / 181c5e15c / 181c5e3fc = per-log2 factor tables (read as int, index log2).
|
|
- Base small planner FUN_18002e360: iVar6=1<<log2; if <9 return; else select radix2/3
|
|
for log2==4 || >10 -> 2 else 3; loops similarly, returns param_4 (plan tail).
|
|
- Return: puVar10 + (1<<log2)*2 (aligned plan tail after current stage block).
|
|
|
|
## Notes for reimplementation
|
|
- Exact ordering must be transcribed from the index algebra (the branches accumulate a
|
|
combination of ± vs complemented indices; XOR selects conjugate/negate for 2x recalc).
|
|
- The 7 giants are per-(data type, direct/inverse, maybe r2c/c2r) variants (identical
|
|
structure; different base-call FUN_18002e360 vs FUN_180023860).
|
|
- Stage kernels executed at runtime are the dispatched vector kernels (see roadmap),
|
|
driven from this plan's ordering; the transform itself therefore reproduces a
|
|
specific FFT: split-radix 2/4/8-style in-place butterflies with fused reorder. |