diff options
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 90cb021..01d16dd 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5348,6 +5348,27 @@ get_builtin_sync_mode (int fcode_diff) return mode_for_size (BITS_PER_UNIT << fcode_diff, MODE_INT, 0); } +/* Expand the memory expression LOC and return the appropriate memory operand + for the builtin_sync operations. */ + +static rtx +get_builtin_sync_mem (tree loc, enum machine_mode mode) +{ + rtx addr, mem; + + addr = expand_expr (loc, NULL, Pmode, EXPAND_SUM); + + /* Note that we explicitly do not want any alias information for this + memory, so that we kill all other live memories. Otherwise we don't + satisfy the full barrier semantics of the intrinsic. */ + mem = validize_mem (gen_rtx_MEM (mode, addr)); + + set_mem_align (mem, get_pointer_alignment (loc, BIGGEST_ALIGNMENT)); + MEM_VOLATILE_P (mem) = 1; + + return mem; +} + /* Expand the __sync_xxx_and_fetch and __sync_fetch_and_xxx intrinsics. ARGLIST is the operands list to the function. CODE is the rtx code that corresponds to the arithmetic or logical operation from the name; @@ -5361,20 +5382,14 @@ expand_builtin_sync_operation (enum machine_mode mode, tree arglist, enum rtx_code code, bool after, rtx target, bool ignore) { - rtx addr, val, mem; + rtx val, mem; /* Expand the operands. */ - addr = expand_expr (TREE_VALUE (arglist), NULL, Pmode, EXPAND_SUM); + mem = get_builtin_sync_mem (TREE_VALUE (arglist), mode); arglist = TREE_CHAIN (arglist); val = expand_expr (TREE_VALUE (arglist), NULL, mode, EXPAND_NORMAL); - /* Note that we explicitly do not want any alias information for this - memory, so that we kill all other live memories. Otherwise we don't - satisfy the full barrier semantics of the intrinsic. */ - mem = validize_mem (gen_rtx_MEM (mode, addr)); - MEM_VOLATILE_P (mem) = 1; - if (ignore) return expand_sync_operation (mem, val, code); else @@ -5390,10 +5405,10 @@ static rtx expand_builtin_compare_and_swap (enum machine_mode mode, tree arglist, bool is_bool, rtx target) { - rtx addr, old_val, new_val, mem; + rtx old_val, new_val, mem; /* Expand the operands. */ - addr = expand_expr (TREE_VALUE (arglist), NULL, Pmode, EXPAND_SUM); + mem = get_builtin_sync_mem (TREE_VALUE (arglist), mode); arglist = TREE_CHAIN (arglist); old_val = expand_expr (TREE_VALUE (arglist), NULL, mode, EXPAND_NORMAL); @@ -5401,12 +5416,6 @@ expand_builtin_compare_and_swap (enum machine_mode mode, tree arglist, arglist = TREE_CHAIN (arglist); new_val = expand_expr (TREE_VALUE (arglist), NULL, mode, EXPAND_NORMAL); - /* Note that we explicitly do not want any alias information for this - memory, so that we kill all other live memories. Otherwise we don't - satisfy the full barrier semantics of the intrinsic. */ - mem = validize_mem (gen_rtx_MEM (mode, addr)); - MEM_VOLATILE_P (mem) = 1; - if (is_bool) return expand_bool_compare_and_swap (mem, old_val, new_val, target); else @@ -5423,20 +5432,14 @@ static rtx expand_builtin_lock_test_and_set (enum machine_mode mode, tree arglist, rtx target) { - rtx addr, val, mem; + rtx val, mem; /* Expand the operands. */ - addr = expand_expr (TREE_VALUE (arglist), NULL, Pmode, EXPAND_NORMAL); + mem = get_builtin_sync_mem (TREE_VALUE (arglist), mode); arglist = TREE_CHAIN (arglist); val = expand_expr (TREE_VALUE (arglist), NULL, mode, EXPAND_NORMAL); - /* Note that we explicitly do not want any alias information for this - memory, so that we kill all other live memories. Otherwise we don't - satisfy the barrier semantics of the intrinsic. */ - mem = validize_mem (gen_rtx_MEM (mode, addr)); - MEM_VOLATILE_P (mem) = 1; - return expand_sync_lock_test_and_set (mem, val, target); } @@ -5470,17 +5473,11 @@ static void expand_builtin_lock_release (enum machine_mode mode, tree arglist) { enum insn_code icode; - rtx addr, mem, insn; + rtx mem, insn; rtx val = const0_rtx; /* Expand the operands. */ - addr = expand_expr (TREE_VALUE (arglist), NULL, Pmode, EXPAND_NORMAL); - - /* Note that we explicitly do not want any alias information for this - memory, so that we kill all other live memories. Otherwise we don't - satisfy the barrier semantics of the intrinsic. */ - mem = validize_mem (gen_rtx_MEM (mode, addr)); - MEM_VOLATILE_P (mem) = 1; + mem = get_builtin_sync_mem (TREE_VALUE (arglist), mode); /* If there is an explicit operation in the md file, use it. */ icode = sync_lock_release[mode]; |