Repository navigation
feat(#547): machine fences and ordered atomics state their effect.Order - #558
Merged
Merged
Conversation
effect.Order gains by, the orderings whose operand's value, when it meets a masked bit pattern, joins its kinds to the order, as risc-v fence's pred and succ, the aq and rl bits and aarch64 dmb's option. effect.order resolves them against operand values and effect.joined is the union of two orders, as a block of both.
footprint.of resolves the row's order by its operand values into Footprint.order, and the inline block footprint carries the union of its instructions' orders, so a consumer sees an inline fence or atomic orders.
gen.order reads an order fact's kinds and the field whose bits decide it, resolves it against a row's fixed bits or an operand's value and emits the effect.Order, so each set reads its order from the encoding.
fence, fence.tso and pause read their order from pred and succ, fence.i orders every access, and the amos, lr, sc, ssamoswap and zalasr's ordered loads and stores read theirs from aq and rl. an ordered line names the rows that must state an order.
dmb and dsb read their order from CRm's type, dsb nXS and isb order every access, and the atomic, compare and swap, exclusive, load-acquire and store-release groups read theirs from A and R, L and o0, L, or opc. an order or ordered line names an instruction or a group by its last name.
…ng rows every _LOCK form reads its order from the lock prefix, xchg with memory and cmpccxadd are implicitly locked, and mfence, lfence, sfence, serialize and cpuid state theirs. every locked row must state an order.
every atomic access, wait, notify and atomic.fence is sequentially consistent, so each orders every access around it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Machine fences and ordered atomics state how they order the memory accesses around them, so mirl cannot move an access across an inline
dmb,fence rw,rw,mfenceor a locked op.effect.Ordergainsby: Orderings. Aneffect.Ordering{operand, mask, value, before, after}says that when the operand's value meets the bit pattern, its kinds join the order. This is how a row states an order its encoding carries in an operand's field: riscv fencepred/succ, the A extension'saq/rl, aarch64dmb/dsb'sCRm.effect.order(e, values)resolves the orderings against operand values.effect.joinedtakes the union of two orders.footprint.ofresolves the row's order intoFootprint.order. The inline block footprint (inline.effects) carries the union of its instructions' orders.gen/src/order.machreads order facts ([before=<kinds>] [after=<kinds>] [field=<field> bits=<pattern>], kinds as letters ofrwio) and resolves them against a row. Where the row fixes the field's bits the fact holds or not when gen runs. Where an operand holds them it becomes anOrdering. The order is read from the encoding fields wherever they carry it, through the generators, and no code holds a mnemonic list.orderandorderedlines. gen refuses a row anorderedline names that states no order, and anorderororderedline that names no row.effects.txt): fence, fence.tso and pause frompred/succ, read bit by bit. fence.i orders every access. amo*, lr.*, sc.*, ssamoswap.* and the zalasrl*.aq/s*.rlfromaq/rl.effects.txt): an order line keys an instruction, or a model group by its last name. dmb and dsb fromCRm<1:0>(LD, ST, full, and reserved values as full). dsb nXS and isb are full. memop, memop_128, memop_unpriv, comswap*, rcwcomswap* fromA/R. ldstexclr/ldstexclp/ldstexclr_unpriv fromL:o0. ldstord, ldapstl_writeback, ldiappstilp fromL. ldapstl_unscaled and ldapstl_simd fromopc. LDAP1/STL1 lane forms.effects.txt): every_LOCKiclass from thelockfield (whether f0 is there), xchg with memory, cmpccxadd, mfence, lfence (before=r after=rw), sfence (before=w after=w), serialize, cpuid. Every LOCKED row must state an order.access.txt): every threads instruction (0xfe 0x00-0x4e: atomics, wait, notify, atomic.fence) is seq_cst,before=rw after=rw.gen/src/registry.mach(last commit).Decisions
beforestays before it, and one after it of a kind inafterstays after it. Acquire statesafter=rw, releasebefore=rw, a full fence both. Theeffect.Orderdoc says so.Orderingentries, not rules. A masked-value test per operand covers the hardest members: riscv's two 4-bit sets, aq/rl as two bits of one operand, and aarch64 CRm, wherexx00reserved means full and is not a bitwise union. The orderings name operands by index plus one, as the rest ofOrderdoes.joinedors the kinds and zeroes semantics, failure, scope and execution, since those name another instruction's operands. The result orders at least what each instruction did.orderedlines name riscv mnemonic patterns, aarch64 groups or instructions, x86 iclasses and wasm ranges. x86 also requires it of every LOCKED row, read from XED's pattern.rw,rw. TSO'sw→rrelaxation is not stated. aarch64 LDLAR/STLLR (LOAcquire/LORelease) read as acquire and release. fence.i and isb order every access, since no kind names instruction fetch or context synchronization. lfence isbefore=r after=rw. aarch64 domain (CRm<3:2>) is not stated as scope, so scope 0 (all agents) stands.Consumer changes (what mirl reads)
effect.Effect.orderis now filled for machine rows. Read it throughfootprint.of(Footprint.order), which has already resolved everyOrderingagainst the operand values, or calleffect.order(e, values). An order that depends on an operand with no known value makesfootprint.ofundecided (open).inline.effectsfillsFootprint.orderwith the union of the block's orders. A non-emptybeforeoraftermeans no access of those kinds may move across the block.effect.ordered(o)is true for an order with orderings even before they resolve.Notes
machd check .and gen run to regenerate. No unit tests, tool comparison, qemu or validator runs, per the v7 rules.Closes #547