Mon Jul 23 09:44:07 EDT 2018
Fix emulation inefficiency
This boils down to splitting evaluation in two phases:
- Probe -> initial state, update function
Actually I don't see how to do this.
What should the function look like? It will always perform some kind
of computation on register values and constants, so it is basically
the same as the output of SeqTerm.hs
The output is a serial program.
So to implement: operations should return only register references,
Put it behind the (r,f) interface first, then change the implementation.
The core change is here:
styp = (fmap fst) . sints
sval = (fmap snd) . sints
val v = do SInt _ v' <- sval v ; return v'
sints (Val i@(SInt sz v)) = do
return $ (i, i)
sints (Reg r) = do
v <- asks $ \(_,regs) -> regs r
ts <- getTypes
let IntReg v0@(SInt sz _) = ts ! r
return $ (v0, SInt sz v)
The point is to compile this straight into a function to give the
implementation as much freedom as possible to reduce it. Is that
possible? Probably overkill.
Actually it seems easier to use an interpreter to implement SeqEmu.
Maybe take that approach directly?
Today is not a big insight day...
ANF nodes and registers are not the same thing (Val | Reg). But ANF
nodes need to be modeled becaues of fanout.
Here's an idea: use template haskell. Map it straight to a haskell