
| So why are Hoopl's rewrite functions specialized to UniqSM monad? My | understanding so far was that this is precisely because we need access to Uniq | supply to generate new labels and registers during rewriting. I'm guessing that | nobody intended that these newly generated things will be added as facts? Correct. | complicated_expr, I rewrite a store to a stack location with | | newReg1 = complicated_expr | I32[(old + 4)] = newReg1 Yes, as Simon says, you need a deterministic name for newReg1. An obvious choice would be reg_L3_7 if this was the 7th instruction of a block whose label was L3. Then the register name would be unaffected by any other rewrites, in any other block, or earlier in this block. But that's not altogether easy, since LocalRegs are identified by a Unique, not a string. One possibility is to do this transformation once and for all, *before* the constant-prop pass, since it is not dependent on the facts generated by the pass. Simon