[cxx-mem-model] Consolidation 2 - the fetch ops.
Andrew MacLeod
amacleod@redhat.com
Thu Sep 15 02:28:00 GMT 2011
Here is the second part of the consolidation patch, the chunks handling
add, sub, and, xor, and or.
Along the way , I also discovered the old __sync routines also had a
NAND operation. It makes consolidation easier to just add the operation
to the __sync_mem routines as well, even though c++ won't need it.
There were actually 3 different rtl patterns which may be used to
implement an operation:
sync_op if the result is not used.
sync_fetch_and_op if returning the pre-operation value.
sync_op_and_fetch if returning the post-operation value.
There are now 3 new variations of those which take a memory model
parameter. sync_mem_op_fetch and sync_mem_fetch_op were already
implemented, but I also added 'sync_mem_op' in this patch.
The old expansion code has been assimilated in the new expander, and I
think its more manageable now. The new expansion routine consecutively
tries each of the 6 patterns in order from best match to worst, until it
either generates an instruction or falls through to a compare_and_swap loop.
A single new function 'maybe_emit_op' is a common entry point for
attempting each of the 6 patterns.
expand_builtin_sync_operation was being passed a superfluous 'ignore'
parameter to indicate the result is ignored. The expanders check if the
target is const0_rtx for that condition.
The 5 fetch_op testcases were expanded to test the new NAND variation as
well as all the variations with an ignored result.
Now in order to enable a port for memory model builtins, we don't need
to create yet another set of patterns. We only have to port the old sync
patterns (even partially if desired) to take an extra parameter and all
the old and new routines will still behave correctly. If we get to the
point where the old patterns have been converted on all ports, we can
actually remove internal support for the old patterns. (the old
built-ins will likely remain for compatibility, but simply map to the
new patterns)
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Andrew
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: newfetch2.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110915/ddb33101/attachment.ksh>
More information about the Gcc-patches
mailing list