Closed tommymcm closed 10 months ago
Proposal for swap representations:
Add a swap operation to the IR, then represent the update with DefPHIs.
swap(s, i, j, k) ==> SWAP(s[k:k+j-i], s[i:j])
s' = DEF(s)
swap(sa, i, j, sb, i2) ==> SWAP(sa[i:j], sb[k:k+j-i])
sa' = DEF(sa)
sb' = DEF(sb)
Slice and concatenation operations require the compiler to identify and analyze diamond patterns that make engineering (and compilation time) expensive.
To remedy this, we need to encapsulate the most common of these operations in their own general-purpose operations.
Insert element.
s' = INS(s, [i] = v)
Insert range.s' = INS(s, [i], s_ins)
Remove element.
s' = RMV(s, [i])
Remove range.s' = RMV(s, [i:j])
Additionally, the semantics of slice will change to be a view:
s0 = s[i:j]
With this the mut2ssa transformations look as follows:
This issue exists to nail down details of the change and work out any kinks before implementation.