2012-02-14 11:02:21 +01:00
|
|
|
/* TILE atomics.
|
2017-01-01 13:07:43 +01:00
|
|
|
Copyright (C) 2011-2017 Free Software Foundation, Inc.
|
2012-02-14 11:02:21 +01:00
|
|
|
Contributed by Walter Lee (walt@tilera.com)
|
|
|
|
|
|
|
|
This file is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation; either version 3, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
This file is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
2014-01-25 21:37:01 +01:00
|
|
|
#include "tconfig.h"
|
2012-02-14 11:02:21 +01:00
|
|
|
#include "coretypes.h"
|
|
|
|
#include "atomic.h"
|
|
|
|
|
2014-01-25 21:37:01 +01:00
|
|
|
#define bool unsigned char
|
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
/* This code should be inlined by the compiler, but for now support
|
|
|
|
it as out-of-line methods in libgcc. */
|
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
static inline void
|
2012-02-14 11:02:21 +01:00
|
|
|
pre_atomic_barrier (int model)
|
|
|
|
{
|
Move MEMMODEL_* from coretypes.h to memmodel.h
2016-10-13 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
* coretypes.h: Move MEMMODEL_* macros and enum memmodel definition
into ...
* memmodel.h: This file.
* alias.c, asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c,
caller-save.c, calls.c, ccmp.c, cfgbuild.c, cfgcleanup.c,
cfgexpand.c, cfgloopanal.c, cfgrtl.c, cilk-common.c, combine.c,
combine-stack-adj.c, common/config/aarch64/aarch64-common.c,
common/config/arm/arm-common.c, common/config/bfin/bfin-common.c,
common/config/c6x/c6x-common.c, common/config/i386/i386-common.c,
common/config/ia64/ia64-common.c, common/config/nvptx/nvptx-common.c,
compare-elim.c, config/aarch64/aarch64-builtins.c,
config/aarch64/aarch64-c.c, config/aarch64/cortex-a57-fma-steering.c,
config/arc/arc.c, config/arc/arc-c.c, config/arm/arm-builtins.c,
config/arm/arm-c.c, config/avr/avr.c, config/avr/avr-c.c,
config/avr/avr-log.c, config/bfin/bfin.c, config/c6x/c6x.c,
config/cr16/cr16.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/epiphany/epiphany.c,
config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/fr30/fr30.c,
config/frv/frv.c, config/ft32/ft32.c, config/h8300/h8300.c,
config/i386/i386-c.c, config/i386/winnt.c, config/iq2000/iq2000.c,
config/lm32/lm32.c, config/m32c/m32c.c, config/m32r/m32r.c,
config/m68k/m68k.c, config/mcore/mcore.c,
config/microblaze/microblaze.c, config/mmix/mmix.c,
config/mn10300/mn10300.c, config/moxie/moxie.c,
config/msp430/msp430.c, config/nds32/nds32-cost.c,
config/nds32/nds32-intrinsic.c, config/nds32/nds32-md-auxiliary.c,
config/nds32/nds32-memory-manipulation.c,
config/nds32/nds32-predicates.c, config/nds32/nds32.c,
config/nios2/nios2.c, config/nvptx/nvptx.c, config/pa/pa.c,
config/pdp11/pdp11.c, config/rl78/rl78.c, config/rs6000/rs6000-c.c,
config/rx/rx.c, config/s390/s390-c.c, config/s390/s390.c,
config/sh/sh.c, config/sh/sh-c.c, config/sh/sh-mem.cc,
config/sh/sh_treg_combine.cc, config/sol2.c, config/spu/spu.c,
config/stormy16/stormy16.c, config/tilegx/tilegx.c,
config/tilepro/tilepro.c, config/v850/v850.c, config/vax/vax.c,
config/visium/visium.c, config/vms/vms-c.c, config/xtensa/xtensa.c,
coverage.c, cppbuiltin.c, cprop.c, cse.c, cselib.c, dbxout.c, dce.c,
df-core.c, df-problems.c, df-scan.c, dojump.c, dse.c, dwarf2asm.c,
dwarf2cfi.c, dwarf2out.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, fold-const.c, function.c, fwprop.c, gcse.c,
ggc-page.c, haifa-sched.c, hsa-brig.c, hsa-gen.c, hw-doloop.c,
ifcvt.c, init-regs.c, internal-fn.c, ira-build.c, ira-color.c,
ira-conflicts.c, ira-costs.c, ira-emit.c, ira-lives.c, ira.c, jump.c,
loop-doloop.c, loop-invariant.c, loop-iv.c, loop-unroll.c,
lower-subreg.c, lra.c, lra-assigns.c, lra-coalesce.c,
lra-constraints.c, lra-eliminations.c, lra-lives.c, lra-remat.c,
lra-spills.c, mode-switching.c, modulo-sched.c, omp-low.c, passes.c,
postreload-gcse.c, postreload.c, predict.c, print-rtl-function.c,
recog.c, ree.c, reg-stack.c, regcprop.c, reginfo.c, regrename.c,
reload.c, reload1.c, reorg.c, resource.c, rtl-chkp.c, rtl-tests.c,
rtlanal.c, rtlhooks.c, sched-deps.c, sched-rgn.c, sdbout.c,
sel-sched-ir.c, sel-sched.c, shrink-wrap.c, simplify-rtx.c,
stack-ptr-mod.c, stmt.c, stor-layout.c, target-globals.c,
targhooks.c, toplev.c, tree-nested.c, tree-outof-ssa.c,
tree-profile.c, tree-ssa-coalesce.c, tree-ssa-ifcombine.c,
tree-ssa-loop-ivopts.c, tree-ssa-loop.c, tree-ssa-reassoc.c,
tree-ssa-sccvn.c, tree-vect-data-refs.c, ubsan.c, valtrack.c,
var-tracking.c, varasm.c: Include memmodel.h.
* genattrtab.c (write_header): Include memmodel.h in generated file.
* genautomata.c (main): Likewise.
* gengtype.c (open_base_files): Likewise.
* genopinit.c (main): Likewise.
* genconditions.c (write_header): Include memmodel.h earlier in
generated file.
* genemit.c (main): Likewise.
* genoutput.c (output_prologue): Likewise.
* genpeep.c (main): Likewise.
* genpreds.c (write_insn_preds_c): Likewise.
* genrecog.c (write_header): Likewise.
* Makefile.in (PLUGIN_HEADERS): Include memmodel.h
gcc/ada/
* gcc-interface/utils2.c: Include memmodel.h.
gcc/c-family/
* c-cppbuiltin.c: Include memmodel.h.
* c-opts.c: Likewise.
* c-pragma.c: Likewise.
* c-warn.c: Likewise.
gcc/c/
* c-typeck.c: Include memmodel.h.
gcc/cp/
* decl2.c: Include memmodel.h.
* rtti.c: Likewise.
gcc/fortran/
* trans-intrinsic.c: Include memmodel.h.
gcc/go/
* go-backend.c: Include memmodel.h.
libgcc/
* libgcov-profiler.c: Replace MEMMODEL_* macros by their __ATOMIC_*
equivalent.
* config/tilepro/atomic.c: Likewise and stop casting model to
enum memmodel.
From-SVN: r241121
2016-10-13 16:17:52 +02:00
|
|
|
switch (model)
|
2012-02-14 11:02:21 +01:00
|
|
|
{
|
Move MEMMODEL_* from coretypes.h to memmodel.h
2016-10-13 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
* coretypes.h: Move MEMMODEL_* macros and enum memmodel definition
into ...
* memmodel.h: This file.
* alias.c, asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c,
caller-save.c, calls.c, ccmp.c, cfgbuild.c, cfgcleanup.c,
cfgexpand.c, cfgloopanal.c, cfgrtl.c, cilk-common.c, combine.c,
combine-stack-adj.c, common/config/aarch64/aarch64-common.c,
common/config/arm/arm-common.c, common/config/bfin/bfin-common.c,
common/config/c6x/c6x-common.c, common/config/i386/i386-common.c,
common/config/ia64/ia64-common.c, common/config/nvptx/nvptx-common.c,
compare-elim.c, config/aarch64/aarch64-builtins.c,
config/aarch64/aarch64-c.c, config/aarch64/cortex-a57-fma-steering.c,
config/arc/arc.c, config/arc/arc-c.c, config/arm/arm-builtins.c,
config/arm/arm-c.c, config/avr/avr.c, config/avr/avr-c.c,
config/avr/avr-log.c, config/bfin/bfin.c, config/c6x/c6x.c,
config/cr16/cr16.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/epiphany/epiphany.c,
config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/fr30/fr30.c,
config/frv/frv.c, config/ft32/ft32.c, config/h8300/h8300.c,
config/i386/i386-c.c, config/i386/winnt.c, config/iq2000/iq2000.c,
config/lm32/lm32.c, config/m32c/m32c.c, config/m32r/m32r.c,
config/m68k/m68k.c, config/mcore/mcore.c,
config/microblaze/microblaze.c, config/mmix/mmix.c,
config/mn10300/mn10300.c, config/moxie/moxie.c,
config/msp430/msp430.c, config/nds32/nds32-cost.c,
config/nds32/nds32-intrinsic.c, config/nds32/nds32-md-auxiliary.c,
config/nds32/nds32-memory-manipulation.c,
config/nds32/nds32-predicates.c, config/nds32/nds32.c,
config/nios2/nios2.c, config/nvptx/nvptx.c, config/pa/pa.c,
config/pdp11/pdp11.c, config/rl78/rl78.c, config/rs6000/rs6000-c.c,
config/rx/rx.c, config/s390/s390-c.c, config/s390/s390.c,
config/sh/sh.c, config/sh/sh-c.c, config/sh/sh-mem.cc,
config/sh/sh_treg_combine.cc, config/sol2.c, config/spu/spu.c,
config/stormy16/stormy16.c, config/tilegx/tilegx.c,
config/tilepro/tilepro.c, config/v850/v850.c, config/vax/vax.c,
config/visium/visium.c, config/vms/vms-c.c, config/xtensa/xtensa.c,
coverage.c, cppbuiltin.c, cprop.c, cse.c, cselib.c, dbxout.c, dce.c,
df-core.c, df-problems.c, df-scan.c, dojump.c, dse.c, dwarf2asm.c,
dwarf2cfi.c, dwarf2out.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, fold-const.c, function.c, fwprop.c, gcse.c,
ggc-page.c, haifa-sched.c, hsa-brig.c, hsa-gen.c, hw-doloop.c,
ifcvt.c, init-regs.c, internal-fn.c, ira-build.c, ira-color.c,
ira-conflicts.c, ira-costs.c, ira-emit.c, ira-lives.c, ira.c, jump.c,
loop-doloop.c, loop-invariant.c, loop-iv.c, loop-unroll.c,
lower-subreg.c, lra.c, lra-assigns.c, lra-coalesce.c,
lra-constraints.c, lra-eliminations.c, lra-lives.c, lra-remat.c,
lra-spills.c, mode-switching.c, modulo-sched.c, omp-low.c, passes.c,
postreload-gcse.c, postreload.c, predict.c, print-rtl-function.c,
recog.c, ree.c, reg-stack.c, regcprop.c, reginfo.c, regrename.c,
reload.c, reload1.c, reorg.c, resource.c, rtl-chkp.c, rtl-tests.c,
rtlanal.c, rtlhooks.c, sched-deps.c, sched-rgn.c, sdbout.c,
sel-sched-ir.c, sel-sched.c, shrink-wrap.c, simplify-rtx.c,
stack-ptr-mod.c, stmt.c, stor-layout.c, target-globals.c,
targhooks.c, toplev.c, tree-nested.c, tree-outof-ssa.c,
tree-profile.c, tree-ssa-coalesce.c, tree-ssa-ifcombine.c,
tree-ssa-loop-ivopts.c, tree-ssa-loop.c, tree-ssa-reassoc.c,
tree-ssa-sccvn.c, tree-vect-data-refs.c, ubsan.c, valtrack.c,
var-tracking.c, varasm.c: Include memmodel.h.
* genattrtab.c (write_header): Include memmodel.h in generated file.
* genautomata.c (main): Likewise.
* gengtype.c (open_base_files): Likewise.
* genopinit.c (main): Likewise.
* genconditions.c (write_header): Include memmodel.h earlier in
generated file.
* genemit.c (main): Likewise.
* genoutput.c (output_prologue): Likewise.
* genpeep.c (main): Likewise.
* genpreds.c (write_insn_preds_c): Likewise.
* genrecog.c (write_header): Likewise.
* Makefile.in (PLUGIN_HEADERS): Include memmodel.h
gcc/ada/
* gcc-interface/utils2.c: Include memmodel.h.
gcc/c-family/
* c-cppbuiltin.c: Include memmodel.h.
* c-opts.c: Likewise.
* c-pragma.c: Likewise.
* c-warn.c: Likewise.
gcc/c/
* c-typeck.c: Include memmodel.h.
gcc/cp/
* decl2.c: Include memmodel.h.
* rtti.c: Likewise.
gcc/fortran/
* trans-intrinsic.c: Include memmodel.h.
gcc/go/
* go-backend.c: Include memmodel.h.
libgcc/
* libgcov-profiler.c: Replace MEMMODEL_* macros by their __ATOMIC_*
equivalent.
* config/tilepro/atomic.c: Likewise and stop casting model to
enum memmodel.
From-SVN: r241121
2016-10-13 16:17:52 +02:00
|
|
|
case __ATOMIC_RELEASE:
|
|
|
|
case __ATOMIC_ACQ_REL:
|
|
|
|
case __ATOMIC_SEQ_CST:
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_thread_fence (model);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
static inline void
|
2012-02-14 11:02:21 +01:00
|
|
|
post_atomic_barrier (int model)
|
|
|
|
{
|
Move MEMMODEL_* from coretypes.h to memmodel.h
2016-10-13 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
* coretypes.h: Move MEMMODEL_* macros and enum memmodel definition
into ...
* memmodel.h: This file.
* alias.c, asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c,
caller-save.c, calls.c, ccmp.c, cfgbuild.c, cfgcleanup.c,
cfgexpand.c, cfgloopanal.c, cfgrtl.c, cilk-common.c, combine.c,
combine-stack-adj.c, common/config/aarch64/aarch64-common.c,
common/config/arm/arm-common.c, common/config/bfin/bfin-common.c,
common/config/c6x/c6x-common.c, common/config/i386/i386-common.c,
common/config/ia64/ia64-common.c, common/config/nvptx/nvptx-common.c,
compare-elim.c, config/aarch64/aarch64-builtins.c,
config/aarch64/aarch64-c.c, config/aarch64/cortex-a57-fma-steering.c,
config/arc/arc.c, config/arc/arc-c.c, config/arm/arm-builtins.c,
config/arm/arm-c.c, config/avr/avr.c, config/avr/avr-c.c,
config/avr/avr-log.c, config/bfin/bfin.c, config/c6x/c6x.c,
config/cr16/cr16.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/epiphany/epiphany.c,
config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/fr30/fr30.c,
config/frv/frv.c, config/ft32/ft32.c, config/h8300/h8300.c,
config/i386/i386-c.c, config/i386/winnt.c, config/iq2000/iq2000.c,
config/lm32/lm32.c, config/m32c/m32c.c, config/m32r/m32r.c,
config/m68k/m68k.c, config/mcore/mcore.c,
config/microblaze/microblaze.c, config/mmix/mmix.c,
config/mn10300/mn10300.c, config/moxie/moxie.c,
config/msp430/msp430.c, config/nds32/nds32-cost.c,
config/nds32/nds32-intrinsic.c, config/nds32/nds32-md-auxiliary.c,
config/nds32/nds32-memory-manipulation.c,
config/nds32/nds32-predicates.c, config/nds32/nds32.c,
config/nios2/nios2.c, config/nvptx/nvptx.c, config/pa/pa.c,
config/pdp11/pdp11.c, config/rl78/rl78.c, config/rs6000/rs6000-c.c,
config/rx/rx.c, config/s390/s390-c.c, config/s390/s390.c,
config/sh/sh.c, config/sh/sh-c.c, config/sh/sh-mem.cc,
config/sh/sh_treg_combine.cc, config/sol2.c, config/spu/spu.c,
config/stormy16/stormy16.c, config/tilegx/tilegx.c,
config/tilepro/tilepro.c, config/v850/v850.c, config/vax/vax.c,
config/visium/visium.c, config/vms/vms-c.c, config/xtensa/xtensa.c,
coverage.c, cppbuiltin.c, cprop.c, cse.c, cselib.c, dbxout.c, dce.c,
df-core.c, df-problems.c, df-scan.c, dojump.c, dse.c, dwarf2asm.c,
dwarf2cfi.c, dwarf2out.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, fold-const.c, function.c, fwprop.c, gcse.c,
ggc-page.c, haifa-sched.c, hsa-brig.c, hsa-gen.c, hw-doloop.c,
ifcvt.c, init-regs.c, internal-fn.c, ira-build.c, ira-color.c,
ira-conflicts.c, ira-costs.c, ira-emit.c, ira-lives.c, ira.c, jump.c,
loop-doloop.c, loop-invariant.c, loop-iv.c, loop-unroll.c,
lower-subreg.c, lra.c, lra-assigns.c, lra-coalesce.c,
lra-constraints.c, lra-eliminations.c, lra-lives.c, lra-remat.c,
lra-spills.c, mode-switching.c, modulo-sched.c, omp-low.c, passes.c,
postreload-gcse.c, postreload.c, predict.c, print-rtl-function.c,
recog.c, ree.c, reg-stack.c, regcprop.c, reginfo.c, regrename.c,
reload.c, reload1.c, reorg.c, resource.c, rtl-chkp.c, rtl-tests.c,
rtlanal.c, rtlhooks.c, sched-deps.c, sched-rgn.c, sdbout.c,
sel-sched-ir.c, sel-sched.c, shrink-wrap.c, simplify-rtx.c,
stack-ptr-mod.c, stmt.c, stor-layout.c, target-globals.c,
targhooks.c, toplev.c, tree-nested.c, tree-outof-ssa.c,
tree-profile.c, tree-ssa-coalesce.c, tree-ssa-ifcombine.c,
tree-ssa-loop-ivopts.c, tree-ssa-loop.c, tree-ssa-reassoc.c,
tree-ssa-sccvn.c, tree-vect-data-refs.c, ubsan.c, valtrack.c,
var-tracking.c, varasm.c: Include memmodel.h.
* genattrtab.c (write_header): Include memmodel.h in generated file.
* genautomata.c (main): Likewise.
* gengtype.c (open_base_files): Likewise.
* genopinit.c (main): Likewise.
* genconditions.c (write_header): Include memmodel.h earlier in
generated file.
* genemit.c (main): Likewise.
* genoutput.c (output_prologue): Likewise.
* genpeep.c (main): Likewise.
* genpreds.c (write_insn_preds_c): Likewise.
* genrecog.c (write_header): Likewise.
* Makefile.in (PLUGIN_HEADERS): Include memmodel.h
gcc/ada/
* gcc-interface/utils2.c: Include memmodel.h.
gcc/c-family/
* c-cppbuiltin.c: Include memmodel.h.
* c-opts.c: Likewise.
* c-pragma.c: Likewise.
* c-warn.c: Likewise.
gcc/c/
* c-typeck.c: Include memmodel.h.
gcc/cp/
* decl2.c: Include memmodel.h.
* rtti.c: Likewise.
gcc/fortran/
* trans-intrinsic.c: Include memmodel.h.
gcc/go/
* go-backend.c: Include memmodel.h.
libgcc/
* libgcov-profiler.c: Replace MEMMODEL_* macros by their __ATOMIC_*
equivalent.
* config/tilepro/atomic.c: Likewise and stop casting model to
enum memmodel.
From-SVN: r241121
2016-10-13 16:17:52 +02:00
|
|
|
switch (model)
|
2012-02-14 11:02:21 +01:00
|
|
|
{
|
Move MEMMODEL_* from coretypes.h to memmodel.h
2016-10-13 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
* coretypes.h: Move MEMMODEL_* macros and enum memmodel definition
into ...
* memmodel.h: This file.
* alias.c, asan.c, auto-inc-dec.c, bb-reorder.c, bt-load.c,
caller-save.c, calls.c, ccmp.c, cfgbuild.c, cfgcleanup.c,
cfgexpand.c, cfgloopanal.c, cfgrtl.c, cilk-common.c, combine.c,
combine-stack-adj.c, common/config/aarch64/aarch64-common.c,
common/config/arm/arm-common.c, common/config/bfin/bfin-common.c,
common/config/c6x/c6x-common.c, common/config/i386/i386-common.c,
common/config/ia64/ia64-common.c, common/config/nvptx/nvptx-common.c,
compare-elim.c, config/aarch64/aarch64-builtins.c,
config/aarch64/aarch64-c.c, config/aarch64/cortex-a57-fma-steering.c,
config/arc/arc.c, config/arc/arc-c.c, config/arm/arm-builtins.c,
config/arm/arm-c.c, config/avr/avr.c, config/avr/avr-c.c,
config/avr/avr-log.c, config/bfin/bfin.c, config/c6x/c6x.c,
config/cr16/cr16.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/epiphany/epiphany.c,
config/epiphany/mode-switch-use.c,
config/epiphany/resolve-sw-modes.c, config/fr30/fr30.c,
config/frv/frv.c, config/ft32/ft32.c, config/h8300/h8300.c,
config/i386/i386-c.c, config/i386/winnt.c, config/iq2000/iq2000.c,
config/lm32/lm32.c, config/m32c/m32c.c, config/m32r/m32r.c,
config/m68k/m68k.c, config/mcore/mcore.c,
config/microblaze/microblaze.c, config/mmix/mmix.c,
config/mn10300/mn10300.c, config/moxie/moxie.c,
config/msp430/msp430.c, config/nds32/nds32-cost.c,
config/nds32/nds32-intrinsic.c, config/nds32/nds32-md-auxiliary.c,
config/nds32/nds32-memory-manipulation.c,
config/nds32/nds32-predicates.c, config/nds32/nds32.c,
config/nios2/nios2.c, config/nvptx/nvptx.c, config/pa/pa.c,
config/pdp11/pdp11.c, config/rl78/rl78.c, config/rs6000/rs6000-c.c,
config/rx/rx.c, config/s390/s390-c.c, config/s390/s390.c,
config/sh/sh.c, config/sh/sh-c.c, config/sh/sh-mem.cc,
config/sh/sh_treg_combine.cc, config/sol2.c, config/spu/spu.c,
config/stormy16/stormy16.c, config/tilegx/tilegx.c,
config/tilepro/tilepro.c, config/v850/v850.c, config/vax/vax.c,
config/visium/visium.c, config/vms/vms-c.c, config/xtensa/xtensa.c,
coverage.c, cppbuiltin.c, cprop.c, cse.c, cselib.c, dbxout.c, dce.c,
df-core.c, df-problems.c, df-scan.c, dojump.c, dse.c, dwarf2asm.c,
dwarf2cfi.c, dwarf2out.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, fold-const.c, function.c, fwprop.c, gcse.c,
ggc-page.c, haifa-sched.c, hsa-brig.c, hsa-gen.c, hw-doloop.c,
ifcvt.c, init-regs.c, internal-fn.c, ira-build.c, ira-color.c,
ira-conflicts.c, ira-costs.c, ira-emit.c, ira-lives.c, ira.c, jump.c,
loop-doloop.c, loop-invariant.c, loop-iv.c, loop-unroll.c,
lower-subreg.c, lra.c, lra-assigns.c, lra-coalesce.c,
lra-constraints.c, lra-eliminations.c, lra-lives.c, lra-remat.c,
lra-spills.c, mode-switching.c, modulo-sched.c, omp-low.c, passes.c,
postreload-gcse.c, postreload.c, predict.c, print-rtl-function.c,
recog.c, ree.c, reg-stack.c, regcprop.c, reginfo.c, regrename.c,
reload.c, reload1.c, reorg.c, resource.c, rtl-chkp.c, rtl-tests.c,
rtlanal.c, rtlhooks.c, sched-deps.c, sched-rgn.c, sdbout.c,
sel-sched-ir.c, sel-sched.c, shrink-wrap.c, simplify-rtx.c,
stack-ptr-mod.c, stmt.c, stor-layout.c, target-globals.c,
targhooks.c, toplev.c, tree-nested.c, tree-outof-ssa.c,
tree-profile.c, tree-ssa-coalesce.c, tree-ssa-ifcombine.c,
tree-ssa-loop-ivopts.c, tree-ssa-loop.c, tree-ssa-reassoc.c,
tree-ssa-sccvn.c, tree-vect-data-refs.c, ubsan.c, valtrack.c,
var-tracking.c, varasm.c: Include memmodel.h.
* genattrtab.c (write_header): Include memmodel.h in generated file.
* genautomata.c (main): Likewise.
* gengtype.c (open_base_files): Likewise.
* genopinit.c (main): Likewise.
* genconditions.c (write_header): Include memmodel.h earlier in
generated file.
* genemit.c (main): Likewise.
* genoutput.c (output_prologue): Likewise.
* genpeep.c (main): Likewise.
* genpreds.c (write_insn_preds_c): Likewise.
* genrecog.c (write_header): Likewise.
* Makefile.in (PLUGIN_HEADERS): Include memmodel.h
gcc/ada/
* gcc-interface/utils2.c: Include memmodel.h.
gcc/c-family/
* c-cppbuiltin.c: Include memmodel.h.
* c-opts.c: Likewise.
* c-pragma.c: Likewise.
* c-warn.c: Likewise.
gcc/c/
* c-typeck.c: Include memmodel.h.
gcc/cp/
* decl2.c: Include memmodel.h.
* rtti.c: Likewise.
gcc/fortran/
* trans-intrinsic.c: Include memmodel.h.
gcc/go/
* go-backend.c: Include memmodel.h.
libgcc/
* libgcov-profiler.c: Replace MEMMODEL_* macros by their __ATOMIC_*
equivalent.
* config/tilepro/atomic.c: Likewise and stop casting model to
enum memmodel.
From-SVN: r241121
2016-10-13 16:17:52 +02:00
|
|
|
case __ATOMIC_ACQUIRE:
|
|
|
|
case __ATOMIC_ACQ_REL:
|
|
|
|
case __ATOMIC_SEQ_CST:
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_thread_fence (model);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define __unused __attribute__((unused))
|
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __fetch_and_do(proto, type, size, opname, top, bottom) \
|
|
|
|
proto \
|
2012-02-14 11:02:21 +01:00
|
|
|
{ \
|
2014-01-25 21:35:56 +01:00
|
|
|
top; \
|
2012-03-07 21:05:52 +01:00
|
|
|
type rv = arch_atomic_##opname(p, i); \
|
2014-01-25 21:35:56 +01:00
|
|
|
bottom; \
|
2012-02-14 11:02:21 +01:00
|
|
|
return rv; \
|
|
|
|
}
|
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __atomic_fetch_and_do(type, size, opname) \
|
|
|
|
__fetch_and_do(type __atomic_fetch_##opname##_##size(type* p, type i, int model), \
|
|
|
|
type, size, opname, \
|
|
|
|
pre_atomic_barrier(model), \
|
|
|
|
post_atomic_barrier(model)) \
|
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_fetch_and_do (int, 4, add)
|
|
|
|
__atomic_fetch_and_do (int, 4, sub)
|
|
|
|
__atomic_fetch_and_do (int, 4, or)
|
|
|
|
__atomic_fetch_and_do (int, 4, and)
|
|
|
|
__atomic_fetch_and_do (int, 4, xor)
|
|
|
|
__atomic_fetch_and_do (int, 4, nand)
|
|
|
|
__atomic_fetch_and_do (long long, 8, add)
|
|
|
|
__atomic_fetch_and_do (long long, 8, sub)
|
|
|
|
__atomic_fetch_and_do (long long, 8, or)
|
|
|
|
__atomic_fetch_and_do (long long, 8, and)
|
|
|
|
__atomic_fetch_and_do (long long, 8, xor)
|
|
|
|
__atomic_fetch_and_do (long long, 8, nand)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __sync_fetch_and_do(type, size, opname) \
|
|
|
|
__fetch_and_do(type __sync_fetch_and_##opname##_##size(type* p, type i), \
|
|
|
|
type, size, opname, \
|
|
|
|
arch_atomic_write_barrier(), \
|
|
|
|
arch_atomic_read_barrier())
|
|
|
|
|
|
|
|
__sync_fetch_and_do (int, 4, add)
|
|
|
|
__sync_fetch_and_do (int, 4, sub)
|
|
|
|
__sync_fetch_and_do (int, 4, or)
|
|
|
|
__sync_fetch_and_do (int, 4, and)
|
|
|
|
__sync_fetch_and_do (int, 4, xor)
|
|
|
|
__sync_fetch_and_do (int, 4, nand)
|
|
|
|
__sync_fetch_and_do (long long, 8, add)
|
|
|
|
__sync_fetch_and_do (long long, 8, sub)
|
|
|
|
__sync_fetch_and_do (long long, 8, or)
|
|
|
|
__sync_fetch_and_do (long long, 8, and)
|
|
|
|
__sync_fetch_and_do (long long, 8, xor)
|
|
|
|
__sync_fetch_and_do (long long, 8, nand)
|
|
|
|
|
|
|
|
#define __do_and_fetch(proto, type, size, opname, op, op2, top, bottom) \
|
|
|
|
proto \
|
|
|
|
{ \
|
|
|
|
top; \
|
|
|
|
type rv = op2 (arch_atomic_##opname(p, i) op i); \
|
|
|
|
bottom; \
|
|
|
|
return rv; \
|
2012-02-14 11:02:21 +01:00
|
|
|
}
|
2014-01-25 21:35:56 +01:00
|
|
|
|
|
|
|
#define __atomic_do_and_fetch(type, size, opname, op, op2) \
|
|
|
|
__do_and_fetch(type __atomic_##opname##_fetch_##size(type* p, type i, int model), \
|
|
|
|
type, size, opname, op, op2, \
|
|
|
|
pre_atomic_barrier(model), \
|
|
|
|
post_atomic_barrier(model)) \
|
|
|
|
|
2014-01-25 21:33:28 +01:00
|
|
|
__atomic_do_and_fetch (int, 4, add, +, )
|
|
|
|
__atomic_do_and_fetch (int, 4, sub, -, )
|
|
|
|
__atomic_do_and_fetch (int, 4, or, |, )
|
|
|
|
__atomic_do_and_fetch (int, 4, and, &, )
|
|
|
|
__atomic_do_and_fetch (int, 4, xor, |, )
|
|
|
|
__atomic_do_and_fetch (int, 4, nand, &, ~)
|
|
|
|
__atomic_do_and_fetch (long long, 8, add, +, )
|
|
|
|
__atomic_do_and_fetch (long long, 8, sub, -, )
|
|
|
|
__atomic_do_and_fetch (long long, 8, or, |, )
|
|
|
|
__atomic_do_and_fetch (long long, 8, and, &, )
|
|
|
|
__atomic_do_and_fetch (long long, 8, xor, |, )
|
|
|
|
__atomic_do_and_fetch (long long, 8, nand, &, ~)
|
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __sync_do_and_fetch(type, size, opname, op, op2) \
|
|
|
|
__do_and_fetch(type __sync_##opname##_and_fetch_##size(type* p, type i), \
|
|
|
|
type, size, opname, op, op2, \
|
|
|
|
arch_atomic_write_barrier(), \
|
|
|
|
arch_atomic_read_barrier()) \
|
|
|
|
|
|
|
|
__sync_do_and_fetch (int, 4, add, +, )
|
|
|
|
__sync_do_and_fetch (int, 4, sub, -, )
|
|
|
|
__sync_do_and_fetch (int, 4, or, |, )
|
|
|
|
__sync_do_and_fetch (int, 4, and, &, )
|
|
|
|
__sync_do_and_fetch (int, 4, xor, |, )
|
|
|
|
__sync_do_and_fetch (int, 4, nand, &, ~)
|
|
|
|
__sync_do_and_fetch (long long, 8, add, +, )
|
|
|
|
__sync_do_and_fetch (long long, 8, sub, -, )
|
|
|
|
__sync_do_and_fetch (long long, 8, or, |, )
|
|
|
|
__sync_do_and_fetch (long long, 8, and, &, )
|
|
|
|
__sync_do_and_fetch (long long, 8, xor, |, )
|
|
|
|
__sync_do_and_fetch (long long, 8, nand, &, ~)
|
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
#define __atomic_exchange_methods(type, size) \
|
|
|
|
bool \
|
|
|
|
__atomic_compare_exchange_##size(volatile type* ptr, type* oldvalp, \
|
|
|
|
type newval, bool weak __unused, \
|
|
|
|
int models, int modelf __unused) \
|
|
|
|
{ \
|
|
|
|
type oldval = *oldvalp; \
|
|
|
|
pre_atomic_barrier(models); \
|
2012-03-07 21:05:52 +01:00
|
|
|
type retval = arch_atomic_val_compare_and_exchange(ptr, oldval, newval); \
|
2012-02-14 11:02:21 +01:00
|
|
|
post_atomic_barrier(models); \
|
|
|
|
bool success = (retval == oldval); \
|
|
|
|
*oldvalp = retval; \
|
|
|
|
return success; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
type \
|
|
|
|
__atomic_exchange_##size(volatile type* ptr, type val, int model) \
|
|
|
|
{ \
|
|
|
|
pre_atomic_barrier(model); \
|
2012-03-07 21:05:52 +01:00
|
|
|
type retval = arch_atomic_exchange(ptr, val); \
|
2012-02-14 11:02:21 +01:00
|
|
|
post_atomic_barrier(model); \
|
|
|
|
return retval; \
|
|
|
|
}
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_exchange_methods (int, 4)
|
|
|
|
__atomic_exchange_methods (long long, 8)
|
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __sync_exchange_methods(type, size) \
|
|
|
|
type \
|
|
|
|
__sync_val_compare_and_swap_##size(type* ptr, type oldval, type newval) \
|
|
|
|
{ \
|
|
|
|
arch_atomic_write_barrier(); \
|
|
|
|
type retval = arch_atomic_val_compare_and_exchange(ptr, oldval, newval); \
|
|
|
|
arch_atomic_read_barrier(); \
|
|
|
|
return retval; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
bool \
|
|
|
|
__sync_bool_compare_and_swap_##size(type* ptr, type oldval, type newval) \
|
|
|
|
{ \
|
|
|
|
arch_atomic_write_barrier(); \
|
|
|
|
bool retval = arch_atomic_bool_compare_and_exchange(ptr, oldval, newval); \
|
|
|
|
arch_atomic_read_barrier(); \
|
|
|
|
return retval; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
type \
|
|
|
|
__sync_lock_test_and_set_##size(type* ptr, type val) \
|
|
|
|
{ \
|
|
|
|
type retval = arch_atomic_exchange(ptr, val); \
|
|
|
|
arch_atomic_acquire_barrier_value(retval); \
|
|
|
|
return retval; \
|
|
|
|
}
|
|
|
|
|
|
|
|
__sync_exchange_methods (int, 4)
|
|
|
|
__sync_exchange_methods (long long, 8)
|
|
|
|
|
2014-01-25 21:34:42 +01:00
|
|
|
#ifdef __LITTLE_ENDIAN__
|
|
|
|
#define BIT_OFFSET(n, type) ((n) * 8)
|
|
|
|
#else
|
|
|
|
#define BIT_OFFSET(n, type) ((4 - sizeof(type) - (n)) * 8)
|
|
|
|
#endif
|
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
/* Subword methods require the same approach for both TILEPro and
|
|
|
|
TILE-Gx. We load the background data for the word, insert the
|
|
|
|
desired subword piece, then compare-and-exchange it into place. */
|
|
|
|
#define u8 unsigned char
|
|
|
|
#define u16 unsigned short
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __subword_cmpxchg_body(type, size, ptr, guess, val) \
|
|
|
|
({ \
|
|
|
|
unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \
|
|
|
|
const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type); \
|
|
|
|
const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1; \
|
|
|
|
const unsigned int bgmask = ~(valmask << shift); \
|
|
|
|
unsigned int oldword = *p; \
|
|
|
|
type oldval = (oldword >> shift) & valmask; \
|
|
|
|
if (__builtin_expect((oldval == guess), 1)) { \
|
|
|
|
unsigned int word = (oldword & bgmask) | ((val & valmask) << shift); \
|
|
|
|
oldword = arch_atomic_val_compare_and_exchange(p, oldword, word); \
|
|
|
|
oldval = (oldword >> shift) & valmask; \
|
|
|
|
} \
|
|
|
|
oldval; \
|
|
|
|
}) \
|
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
#define __atomic_subword_cmpxchg(type, size) \
|
|
|
|
\
|
|
|
|
bool \
|
2014-01-25 21:35:56 +01:00
|
|
|
__atomic_compare_exchange_##size(volatile type* ptr, type* guess_ptr, \
|
2012-02-14 11:02:21 +01:00
|
|
|
type val, bool weak __unused, int models, \
|
|
|
|
int modelf __unused) \
|
|
|
|
{ \
|
|
|
|
pre_atomic_barrier(models); \
|
2014-01-25 21:35:56 +01:00
|
|
|
type guess = *guess_ptr; \
|
|
|
|
type oldval = __subword_cmpxchg_body(type, size, ptr, guess, val); \
|
2012-02-14 11:02:21 +01:00
|
|
|
post_atomic_barrier(models); \
|
2014-01-25 21:35:56 +01:00
|
|
|
bool success = (oldval == guess); \
|
|
|
|
*guess_ptr = oldval; \
|
2012-02-14 11:02:21 +01:00
|
|
|
return success; \
|
|
|
|
}
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_subword_cmpxchg (u8, 1)
|
|
|
|
__atomic_subword_cmpxchg (u16, 2)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __sync_subword_cmpxchg(type, size) \
|
|
|
|
\
|
|
|
|
type \
|
|
|
|
__sync_val_compare_and_swap_##size(type* ptr, type guess, type val) \
|
|
|
|
{ \
|
|
|
|
arch_atomic_write_barrier(); \
|
|
|
|
type oldval = __subword_cmpxchg_body(type, size, ptr, guess, val); \
|
|
|
|
arch_atomic_read_barrier(); \
|
|
|
|
return oldval; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
bool \
|
|
|
|
__sync_bool_compare_and_swap_##size(type* ptr, type guess, type val) \
|
|
|
|
{ \
|
|
|
|
type oldval = __sync_val_compare_and_swap_##size(ptr, guess, val); \
|
|
|
|
return oldval == guess; \
|
|
|
|
}
|
|
|
|
|
|
|
|
__sync_subword_cmpxchg (u8, 1)
|
|
|
|
__sync_subword_cmpxchg (u16, 2)
|
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
/* For the atomic-update subword methods, we use the same approach as
|
|
|
|
above, but we retry until we succeed if the compare-and-exchange
|
|
|
|
fails. */
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __subword(type, proto, top, expr, bottom) \
|
2012-02-14 11:02:21 +01:00
|
|
|
proto \
|
|
|
|
{ \
|
|
|
|
top \
|
|
|
|
unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \
|
2014-01-25 21:34:42 +01:00
|
|
|
const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type); \
|
2012-02-14 11:02:21 +01:00
|
|
|
const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1; \
|
|
|
|
const unsigned int bgmask = ~(valmask << shift); \
|
|
|
|
unsigned int oldword, xword = *p; \
|
|
|
|
type val, oldval; \
|
|
|
|
do { \
|
|
|
|
oldword = xword; \
|
|
|
|
oldval = (oldword >> shift) & valmask; \
|
|
|
|
val = expr; \
|
|
|
|
unsigned int word = (oldword & bgmask) | ((val & valmask) << shift); \
|
2012-03-07 21:05:52 +01:00
|
|
|
xword = arch_atomic_val_compare_and_exchange(p, oldword, word); \
|
2012-02-14 11:02:21 +01:00
|
|
|
} while (__builtin_expect(xword != oldword, 0)); \
|
|
|
|
bottom \
|
|
|
|
}
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
#define __atomic_subword_fetch(type, funcname, expr, retval) \
|
2014-01-25 21:35:56 +01:00
|
|
|
__subword(type, \
|
|
|
|
type __atomic_ ## funcname(volatile type *ptr, type i, int model), \
|
|
|
|
pre_atomic_barrier(model);, \
|
|
|
|
expr, \
|
|
|
|
post_atomic_barrier(model); return retval;)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_subword_fetch (u8, fetch_add_1, oldval + i, oldval)
|
|
|
|
__atomic_subword_fetch (u8, fetch_sub_1, oldval - i, oldval)
|
|
|
|
__atomic_subword_fetch (u8, fetch_or_1, oldval | i, oldval)
|
|
|
|
__atomic_subword_fetch (u8, fetch_and_1, oldval & i, oldval)
|
|
|
|
__atomic_subword_fetch (u8, fetch_xor_1, oldval ^ i, oldval)
|
|
|
|
__atomic_subword_fetch (u8, fetch_nand_1, ~(oldval & i), oldval)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_subword_fetch (u16, fetch_add_2, oldval + i, oldval)
|
|
|
|
__atomic_subword_fetch (u16, fetch_sub_2, oldval - i, oldval)
|
|
|
|
__atomic_subword_fetch (u16, fetch_or_2, oldval | i, oldval)
|
|
|
|
__atomic_subword_fetch (u16, fetch_and_2, oldval & i, oldval)
|
|
|
|
__atomic_subword_fetch (u16, fetch_xor_2, oldval ^ i, oldval)
|
|
|
|
__atomic_subword_fetch (u16, fetch_nand_2, ~(oldval & i), oldval)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_subword_fetch (u8, add_fetch_1, oldval + i, val)
|
|
|
|
__atomic_subword_fetch (u8, sub_fetch_1, oldval - i, val)
|
|
|
|
__atomic_subword_fetch (u8, or_fetch_1, oldval | i, val)
|
|
|
|
__atomic_subword_fetch (u8, and_fetch_1, oldval & i, val)
|
|
|
|
__atomic_subword_fetch (u8, xor_fetch_1, oldval ^ i, val)
|
|
|
|
__atomic_subword_fetch (u8, nand_fetch_1, ~(oldval & i), val)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_subword_fetch (u16, add_fetch_2, oldval + i, val)
|
|
|
|
__atomic_subword_fetch (u16, sub_fetch_2, oldval - i, val)
|
|
|
|
__atomic_subword_fetch (u16, or_fetch_2, oldval | i, val)
|
|
|
|
__atomic_subword_fetch (u16, and_fetch_2, oldval & i, val)
|
|
|
|
__atomic_subword_fetch (u16, xor_fetch_2, oldval ^ i, val)
|
|
|
|
__atomic_subword_fetch (u16, nand_fetch_2, ~(oldval & i), val)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2014-01-25 21:35:56 +01:00
|
|
|
#define __sync_subword_fetch(type, funcname, expr, retval) \
|
|
|
|
__subword(type, \
|
|
|
|
type __sync_ ## funcname(type *ptr, type i), \
|
|
|
|
arch_atomic_read_barrier();, \
|
|
|
|
expr, \
|
|
|
|
arch_atomic_write_barrier(); return retval;)
|
|
|
|
|
|
|
|
__sync_subword_fetch (u8, fetch_and_add_1, oldval + i, oldval)
|
|
|
|
__sync_subword_fetch (u8, fetch_and_sub_1, oldval - i, oldval)
|
|
|
|
__sync_subword_fetch (u8, fetch_and_or_1, oldval | i, oldval)
|
|
|
|
__sync_subword_fetch (u8, fetch_and_and_1, oldval & i, oldval)
|
|
|
|
__sync_subword_fetch (u8, fetch_and_xor_1, oldval ^ i, oldval)
|
|
|
|
__sync_subword_fetch (u8, fetch_and_nand_1, ~(oldval & i), oldval)
|
|
|
|
|
|
|
|
__sync_subword_fetch (u16, fetch_and_add_2, oldval + i, oldval)
|
|
|
|
__sync_subword_fetch (u16, fetch_and_sub_2, oldval - i, oldval)
|
|
|
|
__sync_subword_fetch (u16, fetch_and_or_2, oldval | i, oldval)
|
|
|
|
__sync_subword_fetch (u16, fetch_and_and_2, oldval & i, oldval)
|
|
|
|
__sync_subword_fetch (u16, fetch_and_xor_2, oldval ^ i, oldval)
|
|
|
|
__sync_subword_fetch (u16, fetch_and_nand_2, ~(oldval & i), oldval)
|
|
|
|
|
|
|
|
__sync_subword_fetch (u8, add_and_fetch_1, oldval + i, val)
|
|
|
|
__sync_subword_fetch (u8, sub_and_fetch_1, oldval - i, val)
|
|
|
|
__sync_subword_fetch (u8, or_and_fetch_1, oldval | i, val)
|
|
|
|
__sync_subword_fetch (u8, and_and_fetch_1, oldval & i, val)
|
|
|
|
__sync_subword_fetch (u8, xor_and_fetch_1, oldval ^ i, val)
|
|
|
|
__sync_subword_fetch (u8, nand_and_fetch_1, ~(oldval & i), val)
|
|
|
|
|
|
|
|
__sync_subword_fetch (u16, add_and_fetch_2, oldval + i, val)
|
|
|
|
__sync_subword_fetch (u16, sub_and_fetch_2, oldval - i, val)
|
|
|
|
__sync_subword_fetch (u16, or_and_fetch_2, oldval | i, val)
|
|
|
|
__sync_subword_fetch (u16, and_and_fetch_2, oldval & i, val)
|
|
|
|
__sync_subword_fetch (u16, xor_and_fetch_2, oldval ^ i, val)
|
|
|
|
__sync_subword_fetch (u16, nand_and_fetch_2, ~(oldval & i), val)
|
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
#define __atomic_subword_lock(type, size) \
|
2014-01-25 21:35:56 +01:00
|
|
|
__subword(type, \
|
|
|
|
type __atomic_exchange_##size(volatile type* ptr, type nval, int model), \
|
|
|
|
pre_atomic_barrier(model);, \
|
|
|
|
nval, \
|
|
|
|
post_atomic_barrier(model); return oldval;)
|
2014-01-25 21:33:28 +01:00
|
|
|
|
2012-02-14 11:02:21 +01:00
|
|
|
__atomic_subword_lock (u8, 1)
|
|
|
|
__atomic_subword_lock (u16, 2)
|
2014-01-25 21:35:56 +01:00
|
|
|
|
|
|
|
#define __sync_subword_lock(type, size) \
|
|
|
|
__subword(type, \
|
|
|
|
type __sync_lock_test_and_set_##size(type* ptr, type nval), \
|
|
|
|
, \
|
|
|
|
nval, \
|
|
|
|
arch_atomic_acquire_barrier_value(oldval); return oldval;)
|
|
|
|
|
|
|
|
__sync_subword_lock (u8, 1)
|
|
|
|
__sync_subword_lock (u16, 2)
|