Skip to content

Consolidate opcode implementations #451

Description

@mkeeter

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions