It feels like Fidget opcodes are implemented in too many places.
For example, consider round. Here are the different places it's defined:
UnaryOpcode::eval (f64), used by Context::eval for constant folding and tree evaluation
declare_canonical_unary!(Context::round, |a| a.round()) (f32 and f64, for unit testing)
vm/mod.rs has implementations for all common types (f32, Interval, Grad), calling Grad::round and Interval::round where appropriate. This is dispatched from SsaOp::Round, rather than UnaryOpcode::Round
- WGPU has its own definitions in
{interval,grad,float}_ops.wgsl
- In the JIT compiler, we have both ARM64 and x86-64 assembly implementations for each common type
Binary operations are even more complex, because in some cases we want to handle immediates differently (e.g. when generating assembly).
Can we consolidate opcode implementations in some way?
It feels like Fidget opcodes are implemented in too many places.
For example, consider
round. Here are the different places it's defined:UnaryOpcode::eval(f64), used byContext::evalfor constant folding and tree evaluationdeclare_canonical_unary!(Context::round, |a| a.round())(f32 and f64, for unit testing)vm/mod.rshas implementations for all common types (f32,Interval,Grad), callingGrad::roundandInterval::roundwhere appropriate. This is dispatched fromSsaOp::Round, rather thanUnaryOpcode::Round{interval,grad,float}_ops.wgslBinary operations are even more complex, because in some cases we want to handle immediates differently (e.g. when generating assembly).
Can we consolidate opcode implementations in some way?