diff options
author | Kirill Yukhin <kirill.yukhin@intel.com> | 2012-05-02 15:32:01 +0000 |
---|---|---|
committer | Kirill Yukhin <kyukhin@gcc.gnu.org> | 2012-05-02 15:32:01 +0000 |
commit | 5dcfdccd32b5b06a29caf45469203c67da526b41 (patch) | |
tree | 646070e1ed039d18a1ce731130e83a8dc29bb3f1 /gcc/builtins.c | |
parent | 68e7284038237a5ed0f4a7bdf2cf16b6f8e55c7e (diff) | |
download | gcc-5dcfdccd32b5b06a29caf45469203c67da526b41.zip gcc-5dcfdccd32b5b06a29caf45469203c67da526b41.tar.gz gcc-5dcfdccd32b5b06a29caf45469203c67da526b41.tar.bz2 |
ChangeLog entry:
* coretypes (MEMMODEL_MASK): New.
* builtins.c (get_memmodel): Add val. Call target.memmodel_check
and return new variable.
(expand_builtin_atomic_exchange): Mask memmodel values.
(expand_builtin_atomic_compare_exchange): Ditto.
(expand_builtin_atomic_load): Ditto.
(expand_builtin_atomic_store): Ditto.
(expand_builtin_atomic_clear): Ditto.
* doc/extend.texi: Mention port-dependent memory model flags.
* config/i386/cpuid.h (bit_HLE): New.
* config/i386/driver-i386.c (host_detect_local_cpu): Detect
HLE support.
* config/i386/i386-protos.h (ix86_generate_hle_prefix): New.
* config/i386/i386-c.c (ix86_target_macros_internal): Set
HLE defines.
(ix86_target_string)<-mhle>: New.
(ix86_valid_target_attribute_inner_p)<OPT_mhle>: Ditto.
* config/i386/i386.c (ix86_target_string)<OPTION_MASK_ISA_HLE>:
New.
(ix86_valid_target_attribute_inner_p)<OPT_mhle>: Ditto.
(ix86_option_override_internal)<PTA_HLE>: New switch, set it
enabled for generic, generic64 and core-avx2.
(ix86_print_operand): Generate HLE lock prefixes.
(ix86_memmodel_check): New.
(TARGET_MEMMODEL_CHECK): Ditto.
* config/i386/i386.h (OPTION_ISA_HLE): Ditto.
(IX86_HLE_ACQUIRE): Ditto.
(IX86_HLE_RELEASE): Ditto.
* config/i386/i386.h (ix86_generate_hle_prefix): Ditto.
* config/i386/i386.opt (mhle): Ditto.
* config/i386/sync.md(atomic_compare_and_swap<mode>): Pass
success model to instruction emitter.
(atomic_fetch_add<mode>): Ditto.
(atomic_exchange<mode>): Ditto.
(atomic_add<mode>): Ditto.
(atomic_sub<mode>): Ditto.
(atomic_<code><mode>): Ditto.
(*atomic_compare_and_swap_doubledi_pic): Ditto.
(atomic_compare_and_swap_single<mode>): Define and use argument
for success model.
(atomic_compare_and_swap_double<mode>): Ditto.
* configure.ac: Check if assembler support HLE prefixes.
* configure: Regenerate.
* config.in: Ditto.
testsuite/ChangeLog entry:
* gcc.target/i386/hle-cmpxchg-acq-1.c: New.
* gcc.target/i386/hle-cmpxchg-rel-1.c: Ditto.
* gcc.target/i386/hle-add-acq-1.c: Ditto.
* gcc.target/i386/hle-add-rel-1.c: Ditto.
* gcc.target/i386/hle-and-acq-1.c: Ditto.
* gcc.target/i386/hle-and-rel-1.c: Ditto.
* gcc.target/i386/hle-or-acq-1.c: Ditto.
* gcc.target/i386/hle-or-rel-1.c: Ditto.
* gcc.target/i386/hle-sub-acq-1.c: Ditto.
* gcc.target/i386/hle-sub-rel-1.c: Ditto.
* gcc.target/i386/hle-xadd-acq-1.c: Ditto.
* gcc.target/i386/hle-xadd-rel-1.c: Ditto.
* gcc.target/i386/hle-xchg-acq-1.c: Ditto.
* gcc.target/i386/hle-xchg-rel-1.c: Ditto.
* gcc.target/i386/hle-xor-acq-1.c: Ditto.
* gcc.target/i386/hle-xor-rel-1.c: Ditto.
Co-Authored-By: Andi Kleen <ak@linux.intel.com>
From-SVN: r187051
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 41a052b..72e2591 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5338,6 +5338,7 @@ static enum memmodel get_memmodel (tree exp) { rtx op; + unsigned HOST_WIDE_INT val; /* If the parameter is not a constant, it's a run time value so we'll just convert it to MEMMODEL_SEQ_CST to avoid annoying runtime checking. */ @@ -5345,13 +5346,25 @@ get_memmodel (tree exp) return MEMMODEL_SEQ_CST; op = expand_normal (exp); - if (INTVAL (op) < 0 || INTVAL (op) >= MEMMODEL_LAST) + + val = INTVAL (op); + if (targetm.memmodel_check) + val = targetm.memmodel_check (val); + else if (val & ~MEMMODEL_MASK) + { + warning (OPT_Winvalid_memory_model, + "Unknown architecture specifier in memory model to builtin."); + return MEMMODEL_SEQ_CST; + } + + if ((INTVAL(op) & MEMMODEL_MASK) >= MEMMODEL_LAST) { warning (OPT_Winvalid_memory_model, "invalid memory model argument to builtin"); return MEMMODEL_SEQ_CST; } - return (enum memmodel) INTVAL (op); + + return (enum memmodel) val; } /* Expand the __atomic_exchange intrinsic: @@ -5366,7 +5379,7 @@ expand_builtin_atomic_exchange (enum machine_mode mode, tree exp, rtx target) enum memmodel model; model = get_memmodel (CALL_EXPR_ARG (exp, 2)); - if (model == MEMMODEL_CONSUME) + if ((model & MEMMODEL_MASK) == MEMMODEL_CONSUME) { error ("invalid memory model for %<__atomic_exchange%>"); return NULL_RTX; @@ -5402,7 +5415,8 @@ expand_builtin_atomic_compare_exchange (enum machine_mode mode, tree exp, success = get_memmodel (CALL_EXPR_ARG (exp, 4)); failure = get_memmodel (CALL_EXPR_ARG (exp, 5)); - if (failure == MEMMODEL_RELEASE || failure == MEMMODEL_ACQ_REL) + if ((failure & MEMMODEL_MASK) == MEMMODEL_RELEASE + || (failure & MEMMODEL_MASK) == MEMMODEL_ACQ_REL) { error ("invalid failure memory model for %<__atomic_compare_exchange%>"); return NULL_RTX; @@ -5453,8 +5467,8 @@ expand_builtin_atomic_load (enum machine_mode mode, tree exp, rtx target) enum memmodel model; model = get_memmodel (CALL_EXPR_ARG (exp, 1)); - if (model == MEMMODEL_RELEASE - || model == MEMMODEL_ACQ_REL) + if ((model & MEMMODEL_MASK) == MEMMODEL_RELEASE + || (model & MEMMODEL_MASK) == MEMMODEL_ACQ_REL) { error ("invalid memory model for %<__atomic_load%>"); return NULL_RTX; @@ -5482,9 +5496,9 @@ expand_builtin_atomic_store (enum machine_mode mode, tree exp) enum memmodel model; model = get_memmodel (CALL_EXPR_ARG (exp, 2)); - if (model != MEMMODEL_RELAXED - && model != MEMMODEL_SEQ_CST - && model != MEMMODEL_RELEASE) + if ((model & MEMMODEL_MASK) != MEMMODEL_RELAXED + && (model & MEMMODEL_MASK) != MEMMODEL_SEQ_CST + && (model & MEMMODEL_MASK) != MEMMODEL_RELEASE) { error ("invalid memory model for %<__atomic_store%>"); return NULL_RTX; @@ -5590,7 +5604,8 @@ expand_builtin_atomic_clear (tree exp) mem = get_builtin_sync_mem (CALL_EXPR_ARG (exp, 0), mode); model = get_memmodel (CALL_EXPR_ARG (exp, 1)); - if (model == MEMMODEL_ACQUIRE || model == MEMMODEL_ACQ_REL) + if ((model & MEMMODEL_MASK) == MEMMODEL_ACQUIRE + || (model & MEMMODEL_MASK) == MEMMODEL_ACQ_REL) { error ("invalid memory model for %<__atomic_store%>"); return const0_rtx; |