[MLton] inferring getAndSet via an Atomic{Begin,End} optimization
Stephen Weeks
sweeks at sweeks.com
Thu Aug 31 13:31:40 PDT 2006
I was thinking about the suggestion to add a getAndSet primitive to
MLton and came up with the following idea.
Atomic{Begin,End} are MLton primitives that are implemented in the
ssaToRssa pass. Limit-check insertion runs near the beginning of the
Rssa optimizer right after this pass. Rather than add a primitive
that gets implemented somewhere after limit-check insertion, why not
leave Atomic{Begin,End} around as primitives until after limit-check
insertion, and have an optimization that runs immediately after
limit-limit check insertion and removes Atomic{Begin,End} pairs that
are unnecessary, e.g. because they are in the same basic block. Then,
immediately after this optimization, one can implement
Atomic{Begin,End} in terms of lower level memory ops.
This seems like a win because it applies to getAndSet as well as other
situations. It also means that we don't have to add a new primitive
figure out how it interacts with all MLton's optimizations.
Thoughts?
More information about the MLton
mailing list