diff options
-rw-r--r-- | gcc/ChangeLog | 80 | ||||
-rw-r--r-- | gcc/Makefile.in | 7 | ||||
-rw-r--r-- | gcc/builtin-types.def | 6 | ||||
-rw-r--r-- | gcc/builtins.c | 16 | ||||
-rw-r--r-- | gcc/builtins.def | 194 | ||||
-rw-r--r-- | gcc/c-common.c | 255 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 4 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 4 | ||||
-rw-r--r-- | gcc/config/i386/sync.md | 139 | ||||
-rw-r--r-- | gcc/sync-builtins.def | 253 |
10 files changed, 578 insertions, 380 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2c592a262c3..9fb2051a084 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,47 @@ +2005-12-22 Jakub Jelinek <jakub@redhat.com> + Richard Henderson <rth@redhat.com> + + Merge from gomp-branch. + * builtins.def: Move all DEF_SYNC_BUILTIN to ... + * sync-builtins.def: ... new file. + (BUILT_IN_FETCH_AND_ADD_16, + BUILT_IN_FETCH_AND_SUB_16, BUILT_IN_FETCH_AND_OR_16, + BUILT_IN_FETCH_AND_AND_16, BUILT_IN_FETCH_AND_XOR_16, + BUILT_IN_FETCH_AND_NAND_16, BUILT_IN_ADD_AND_FETCH_16, + BUILT_IN_SUB_AND_FETCH_16, BUILT_IN_OR_AND_FETCH_16, + BUILT_IN_AND_AND_FETCH_16, BUILT_IN_XOR_AND_FETCH_16, + BUILT_IN_NAND_AND_FETCH_16, BUILT_IN_BOOL_COMPARE_AND_SWAP_16, + BUILT_IN_VAL_COMPARE_AND_SWAP_16, BUILT_IN_LOCK_TEST_AND_SET_16, + BUILT_IN_LOCK_RELEASE_16): New builtins. + * builtin-types.def (BT_I16, BT_FN_I16_VPTR_I16, + BT_FN_BOOL_VPTR_I16_I16, BT_FN_I16_VPTR_I16_I16): Add. + * builtins.c (expand_builtin): Handle sync BUILT_IN_*_16 builtins. + * c-common.c (enum c_builtin_type): Move to top-level from + c_common_nodes_and_builtins enum builtin_type. + (builtin_types): Move from c_common_nodes_and_builtins. + (def_fn_type): New. + (c_common_nodes_and_builtins): Use it. + (def_builtin_1): Check for error_mark_node. + (sync_resolve_size): Handle also 128 bit sync builtins. + * Makefile.in (BUILTINS_DEF): New. Use it instead of builtins.def. + + * config/i386/i386.h (x86_cmpxchg8b, x86_cmpxchg16b): New decls. + (TARGET_CMPXCHG8B, TARGET_CMPXCHG16B): Define. + * config/i386/i386.c (x86_cmpxchg8b, x86_cmpxchg16b): New variables. + * config/i386/sync.md (CASMODE, DCASMODE): New mode macros. + (doublemodesuffix, DCASHMODE): New mode attrs. + (sync_compare_and_swap<mode>): Change into expand, use CASMODE + instead of IMODE, if mode is wider than a word, expand into + sync_double_compare_and_swap*. + (*sync_compare_and_swap<mode>): New insn. + (sync_double_compare_and_swap<mode>): Likewise. + (*sync_double_compare_and_swapdi_pic): Likewise. + (sync_compare_and_swap_cc<mode>): Use CASMODE instead of IMODE, if + mode is wider than a word, expand into + sync_double_compare_and_swap_cc*. + (sync_double_compare_and_swap_cc<mode>): New insn. + (*sync_double_compare_and_swap_ccdi_pic): Likewise. + 2005-12-22 Richard Henderson <rth@redhat.com> * config/i386/mmintrin.h (_mm_add_si64): Only define for SSE2. @@ -186,8 +230,8 @@ Strip away all type conversions after simplifying the condition. - * tree-cfgcleanup.c (merge_phi_nodes): Allow merging in some - cases the forwarder block dominates the destination. + * tree-cfgcleanup.c (merge_phi_nodes): Allow merging in some + cases the forwarder block dominates the destination. 2005-12-19 DJ Delorie <dj@redhat.com> @@ -257,7 +301,7 @@ 2005-12-17 Kenneth Zadeck <zadeck@naturalbridge.com> - * flow.c (update_life_info, count_or_remove_death_notes): Fixed + * flow.c (update_life_info, count_or_remove_death_notes): Fixed latent bug that could happen if update_life_info was called with a blocks parameter and the call to cleanup_cfg actually deleted one of those blocks. @@ -1027,10 +1071,10 @@ 2005-12-15 Paolo Bonzini <bonzini@gnu.org> - * combine.c: Remove force_to_mode's fourth parameter. - (force_to_mode): Do not handle REG. - (canon_reg_for_combine): New. - (make_field_assignment): Use it where the removed argument was non-NULL. + * combine.c: Remove force_to_mode's fourth parameter. + (force_to_mode): Do not handle REG. + (canon_reg_for_combine): New. + (make_field_assignment): Use it where the removed argument was non-NULL. 2005-12-15 Alan Modra <amodra@bigpond.net.au> @@ -1206,8 +1250,8 @@ Back out this change: 2005-03-07 Kazu Hirata <kazu@cs.umass.edu> - * recog.c (verify_changes): Make it static. - * recog.h: Remove the corresponding prototype. + * recog.c (verify_changes): Make it static. + * recog.h: Remove the corresponding prototype. 2005-12-13 J"orn Rennecke <joern.rennecke@st.com> @@ -1504,7 +1548,7 @@ call_used_regs can't be used to save reg in another reg. 2005-12-08 Volker Reichelt <reichelt@igpm.rwth-aachen.de> - Christophe Jaillet <christophe.jaillet@wanadoo.fr> + Christophe Jaillet <christophe.jaillet@wanadoo.fr> * ipa-type-escape.c (analyze_variable): Use gcc_assert instead of abort. @@ -1544,7 +1588,7 @@ * tree.h (DECL_EXTERNAL): Clarify documentation. 2005-12-08 Andreas Krebbel <krebbel1@de.ibm.com> - Jakub Jelinek <jakub@redhat.com> + Jakub Jelinek <jakub@redhat.com> PR target/25268 * config/s390/s390.c (s390_decompose_shift_count): Remove BITS @@ -2340,11 +2384,11 @@ 2005-12-05 Paolo Bonzini <bonzini@gnu.org> - * config/rs6000/predicates.md (logical_const_operand): Split - out of logical_operand. - (logical_operand): Use it. - * config/rs6000/rs6000.md (cmp -> xor peephole2): Use - logical_const_operand. + * config/rs6000/predicates.md (logical_const_operand): Split + out of logical_operand. + (logical_operand): Use it. + * config/rs6000/rs6000.md (cmp -> xor peephole2): Use + logical_const_operand. 2005-12-05 Jan Beulich <jbeulich@novell.com> @@ -2715,7 +2759,7 @@ 2005-12-01 Ben Elliston <bje@au.ibm.com> - * mklibgcc.in: Parameterise the script to build soft float + * mklibgcc.in: Parameterise the script to build soft float functions by iterating over each type, rather than cloning the code for each type. @@ -2756,7 +2800,7 @@ (tree_expr_nonnegative_p): Likewise. 2005-11-30 Dale Johannesen <dalej@apple.com> - Andrew Pinski <pinskia@physics.uc.edu> + Andrew Pinski <pinskia@physics.uc.edu> * combine.c (find_split_point): Sign extend bitmask when changing bitfield assignment to IOR of AND. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index a94bf4497ca..7261a1e2b5f 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -736,7 +736,8 @@ RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H) reg-notes.def insn-notes.def \ input.h real.h statistics.h RTL_H = $(RTL_BASE_H) genrtl.h PARAMS_H = params.h params.def -TREE_H = tree.h tree.def $(MACHMODE_H) tree-check.h builtins.def \ +BUILTINS_DEF = builtins.def sync-builtins.def +TREE_H = tree.h tree.def $(MACHMODE_H) tree-check.h $(BUILTINS_DEF) \ input.h statistics.h vec.h treestruct.def BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h varray.h $(PARTITION_H) \ hard-reg-set.h cfghooks.h $(OBSTACK_H) @@ -1592,7 +1593,7 @@ c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(DIAGNOSTIC_H) gt-c-common.h langhooks.h $(VARRAY_H) $(RTL_H) \ $(TARGET_H) $(C_TREE_H) tree-iterator.h langhooks.h tree-mudflap.h \ intl.h opts.h real.h $(CPPLIB_H) tree-inline.h $(HASHTAB_H) \ - builtins.def + $(BUILTINS_DEF) c-pretty-print.o : c-pretty-print.c $(C_PRETTY_PRINT_H) \ $(C_TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) real.h \ @@ -2147,7 +2148,7 @@ builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ $(EXPR_H) $(OPTABS_H) insn-config.h $(RECOG_H) output.h typeclass.h \ hard-reg-set.h toplev.h hard-reg-set.h except.h $(TM_P_H) $(PREDICT_H) \ libfuncs.h real.h langhooks.h $(BASIC_BLOCK_H) tree-mudflap.h \ - builtins.def $(MACHMODE_H) + $(BUILTINS_DEF) $(MACHMODE_H) calls.o : calls.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ $(TREE_H) $(FLAGS_H) $(EXPR_H) $(OPTABS_H) langhooks.h $(TARGET_H) \ libfuncs.h $(REGS_H) toplev.h output.h function.h $(TIMEVAR_H) $(TM_P_H) \ diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index 2e3851a285f..9540f3a719f 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -112,6 +112,7 @@ DEF_PRIMITIVE_TYPE (BT_I1, builtin_type_for_size (BITS_PER_UNIT*1, 1)) DEF_PRIMITIVE_TYPE (BT_I2, builtin_type_for_size (BITS_PER_UNIT*2, 1)) DEF_PRIMITIVE_TYPE (BT_I4, builtin_type_for_size (BITS_PER_UNIT*4, 1)) DEF_PRIMITIVE_TYPE (BT_I8, builtin_type_for_size (BITS_PER_UNIT*8, 1)) +DEF_PRIMITIVE_TYPE (BT_I16, builtin_type_for_size (BITS_PER_UNIT*16, 1)) DEF_POINTER_TYPE (BT_PTR_CONST_STRING, BT_CONST_STRING) @@ -279,6 +280,7 @@ DEF_FUNCTION_TYPE_2 (BT_FN_I1_VPTR_I1, BT_I1, BT_VOLATILE_PTR, BT_I1) DEF_FUNCTION_TYPE_2 (BT_FN_I2_VPTR_I2, BT_I2, BT_VOLATILE_PTR, BT_I2) DEF_FUNCTION_TYPE_2 (BT_FN_I4_VPTR_I4, BT_I4, BT_VOLATILE_PTR, BT_I4) DEF_FUNCTION_TYPE_2 (BT_FN_I8_VPTR_I8, BT_I8, BT_VOLATILE_PTR, BT_I8) +DEF_FUNCTION_TYPE_2 (BT_FN_I16_VPTR_I16, BT_I16, BT_VOLATILE_PTR, BT_I16) DEF_FUNCTION_TYPE_3 (BT_FN_STRING_STRING_CONST_STRING_SIZE, BT_STRING, BT_STRING, BT_CONST_STRING, BT_SIZE) @@ -333,10 +335,14 @@ DEF_FUNCTION_TYPE_3 (BT_FN_BOOL_VPTR_I4_I4, BT_BOOL, BT_VOLATILE_PTR, BT_I4, BT_I4) DEF_FUNCTION_TYPE_3 (BT_FN_BOOL_VPTR_I8_I8, BT_BOOL, BT_VOLATILE_PTR, BT_I8, BT_I8) +DEF_FUNCTION_TYPE_3 (BT_FN_BOOL_VPTR_I16_I16, BT_BOOL, BT_VOLATILE_PTR, + BT_I16, BT_I16) DEF_FUNCTION_TYPE_3 (BT_FN_I1_VPTR_I1_I1, BT_I1, BT_VOLATILE_PTR, BT_I1, BT_I1) DEF_FUNCTION_TYPE_3 (BT_FN_I2_VPTR_I2_I2, BT_I2, BT_VOLATILE_PTR, BT_I2, BT_I2) DEF_FUNCTION_TYPE_3 (BT_FN_I4_VPTR_I4_I4, BT_I4, BT_VOLATILE_PTR, BT_I4, BT_I4) DEF_FUNCTION_TYPE_3 (BT_FN_I8_VPTR_I8_I8, BT_I8, BT_VOLATILE_PTR, BT_I8, BT_I8) +DEF_FUNCTION_TYPE_3 (BT_FN_I16_VPTR_I16_I16, BT_I16, BT_VOLATILE_PTR, + BT_I16, BT_I16) DEF_FUNCTION_TYPE_4 (BT_FN_SIZE_CONST_PTR_SIZE_SIZE_FILEPTR, BT_SIZE, BT_CONST_PTR, BT_SIZE, BT_SIZE, BT_FILEPTR) diff --git a/gcc/builtins.c b/gcc/builtins.c index 7c5711195b5..90cb02178d7 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -6073,6 +6073,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_FETCH_AND_ADD_2: case BUILT_IN_FETCH_AND_ADD_4: case BUILT_IN_FETCH_AND_ADD_8: + case BUILT_IN_FETCH_AND_ADD_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_FETCH_AND_ADD_1); target = expand_builtin_sync_operation (mode, arglist, PLUS, false, target, ignore); @@ -6084,6 +6085,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_FETCH_AND_SUB_2: case BUILT_IN_FETCH_AND_SUB_4: case BUILT_IN_FETCH_AND_SUB_8: + case BUILT_IN_FETCH_AND_SUB_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_FETCH_AND_SUB_1); target = expand_builtin_sync_operation (mode, arglist, MINUS, false, target, ignore); @@ -6095,6 +6097,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_FETCH_AND_OR_2: case BUILT_IN_FETCH_AND_OR_4: case BUILT_IN_FETCH_AND_OR_8: + case BUILT_IN_FETCH_AND_OR_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_FETCH_AND_OR_1); target = expand_builtin_sync_operation (mode, arglist, IOR, false, target, ignore); @@ -6106,6 +6109,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_FETCH_AND_AND_2: case BUILT_IN_FETCH_AND_AND_4: case BUILT_IN_FETCH_AND_AND_8: + case BUILT_IN_FETCH_AND_AND_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_FETCH_AND_AND_1); target = expand_builtin_sync_operation (mode, arglist, AND, false, target, ignore); @@ -6117,6 +6121,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_FETCH_AND_XOR_2: case BUILT_IN_FETCH_AND_XOR_4: case BUILT_IN_FETCH_AND_XOR_8: + case BUILT_IN_FETCH_AND_XOR_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_FETCH_AND_XOR_1); target = expand_builtin_sync_operation (mode, arglist, XOR, false, target, ignore); @@ -6128,6 +6133,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_FETCH_AND_NAND_2: case BUILT_IN_FETCH_AND_NAND_4: case BUILT_IN_FETCH_AND_NAND_8: + case BUILT_IN_FETCH_AND_NAND_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_FETCH_AND_NAND_1); target = expand_builtin_sync_operation (mode, arglist, NOT, false, target, ignore); @@ -6139,6 +6145,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_ADD_AND_FETCH_2: case BUILT_IN_ADD_AND_FETCH_4: case BUILT_IN_ADD_AND_FETCH_8: + case BUILT_IN_ADD_AND_FETCH_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_ADD_AND_FETCH_1); target = expand_builtin_sync_operation (mode, arglist, PLUS, true, target, ignore); @@ -6150,6 +6157,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_SUB_AND_FETCH_2: case BUILT_IN_SUB_AND_FETCH_4: case BUILT_IN_SUB_AND_FETCH_8: + case BUILT_IN_SUB_AND_FETCH_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_SUB_AND_FETCH_1); target = expand_builtin_sync_operation (mode, arglist, MINUS, true, target, ignore); @@ -6161,6 +6169,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_OR_AND_FETCH_2: case BUILT_IN_OR_AND_FETCH_4: case BUILT_IN_OR_AND_FETCH_8: + case BUILT_IN_OR_AND_FETCH_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_OR_AND_FETCH_1); target = expand_builtin_sync_operation (mode, arglist, IOR, true, target, ignore); @@ -6172,6 +6181,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_AND_AND_FETCH_2: case BUILT_IN_AND_AND_FETCH_4: case BUILT_IN_AND_AND_FETCH_8: + case BUILT_IN_AND_AND_FETCH_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_AND_AND_FETCH_1); target = expand_builtin_sync_operation (mode, arglist, AND, true, target, ignore); @@ -6183,6 +6193,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_XOR_AND_FETCH_2: case BUILT_IN_XOR_AND_FETCH_4: case BUILT_IN_XOR_AND_FETCH_8: + case BUILT_IN_XOR_AND_FETCH_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_XOR_AND_FETCH_1); target = expand_builtin_sync_operation (mode, arglist, XOR, true, target, ignore); @@ -6194,6 +6205,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_NAND_AND_FETCH_2: case BUILT_IN_NAND_AND_FETCH_4: case BUILT_IN_NAND_AND_FETCH_8: + case BUILT_IN_NAND_AND_FETCH_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_NAND_AND_FETCH_1); target = expand_builtin_sync_operation (mode, arglist, NOT, true, target, ignore); @@ -6205,6 +6217,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_BOOL_COMPARE_AND_SWAP_2: case BUILT_IN_BOOL_COMPARE_AND_SWAP_4: case BUILT_IN_BOOL_COMPARE_AND_SWAP_8: + case BUILT_IN_BOOL_COMPARE_AND_SWAP_16: if (mode == VOIDmode) mode = TYPE_MODE (boolean_type_node); if (!target || !register_operand (target, mode)) @@ -6220,6 +6233,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_VAL_COMPARE_AND_SWAP_2: case BUILT_IN_VAL_COMPARE_AND_SWAP_4: case BUILT_IN_VAL_COMPARE_AND_SWAP_8: + case BUILT_IN_VAL_COMPARE_AND_SWAP_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_VAL_COMPARE_AND_SWAP_1); target = expand_builtin_compare_and_swap (mode, arglist, false, target); if (target) @@ -6230,6 +6244,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_LOCK_TEST_AND_SET_2: case BUILT_IN_LOCK_TEST_AND_SET_4: case BUILT_IN_LOCK_TEST_AND_SET_8: + case BUILT_IN_LOCK_TEST_AND_SET_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_LOCK_TEST_AND_SET_1); target = expand_builtin_lock_test_and_set (mode, arglist, target); if (target) @@ -6240,6 +6255,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_LOCK_RELEASE_2: case BUILT_IN_LOCK_RELEASE_4: case BUILT_IN_LOCK_RELEASE_8: + case BUILT_IN_LOCK_RELEASE_16: mode = get_builtin_sync_mode (fcode - BUILT_IN_LOCK_RELEASE_1); expand_builtin_lock_release (mode, arglist); return const0_rtx; diff --git a/gcc/builtins.def b/gcc/builtins.def index 7788719d259..d3563612237 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -709,195 +709,5 @@ DEF_EXT_LIB_BUILTIN (BUILT_IN_VPRINTF_CHK, "__vprintf_chk", BT_FN_INT_INT_CON DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter") DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit") -/* Synchronization Primitives. The "_N" version is the one that the user - is supposed to be using. It's overloaded, and is resolved to one of the - "_1" through "_8" versions, plus some extra casts. */ - -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_N, "__sync_fetch_and_add", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_1, "__sync_fetch_and_add_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_2, "__sync_fetch_and_add_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_4, "__sync_fetch_and_add_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_8, "__sync_fetch_and_add_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_N, "__sync_fetch_and_sub", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_1, "__sync_fetch_and_sub_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_2, "__sync_fetch_and_sub_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_4, "__sync_fetch_and_sub_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_8, "__sync_fetch_and_sub_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_N, "__sync_fetch_and_or", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_1, "__sync_fetch_and_or_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_2, "__sync_fetch_and_or_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_4, "__sync_fetch_and_or_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_8, "__sync_fetch_and_or_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_N, "__sync_fetch_and_and", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_1, "__sync_fetch_and_and_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_2, "__sync_fetch_and_and_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_4, "__sync_fetch_and_and_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_8, "__sync_fetch_and_and_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_N, "__sync_fetch_and_xor", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_1, "__sync_fetch_and_xor_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_2, "__sync_fetch_and_xor_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_4, "__sync_fetch_and_xor_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_8, "__sync_fetch_and_xor_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_N, "__sync_fetch_and_nand", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_1, "__sync_fetch_and_nand_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_2, "__sync_fetch_and_nand_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_4, "__sync_fetch_and_nand_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_8, "__sync_fetch_and_nand_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_N, "__sync_add_and_fetch", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_1, "__sync_add_and_fetch_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_2, "__sync_add_and_fetch_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_4, "__sync_add_and_fetch_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_8, "__sync_add_and_fetch_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_N, "__sync_sub_and_fetch", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_1, "__sync_sub_and_fetch_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_2, "__sync_sub_and_fetch_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_4, "__sync_sub_and_fetch_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_8, "__sync_sub_and_fetch_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_N, "__sync_or_and_fetch", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_1, "__sync_or_and_fetch_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_2, "__sync_or_and_fetch_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_4, "__sync_or_and_fetch_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_8, "__sync_or_and_fetch_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_N, "__sync_and_and_fetch", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_1, "__sync_and_and_fetch_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_2, "__sync_and_and_fetch_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_4, "__sync_and_and_fetch_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_8, "__sync_and_and_fetch_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_N, "__sync_xor_and_fetch", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_1, "__sync_xor_and_fetch_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_2, "__sync_xor_and_fetch_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_4, "__sync_xor_and_fetch_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_8, "__sync_xor_and_fetch_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_N, "__sync_nand_and_fetch", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_1, "__sync_nand_and_fetch_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_2, "__sync_nand_and_fetch_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_4, "__sync_nand_and_fetch_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_8, "__sync_nand_and_fetch_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_N, - "__sync_bool_compare_and_swap", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_1, - "__sync_bool_compare_and_swap_1", - BT_FN_BOOL_VPTR_I1_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_2, - "__sync_bool_compare_and_swap_2", - BT_FN_BOOL_VPTR_I2_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_4, - "__sync_bool_compare_and_swap_4", - BT_FN_BOOL_VPTR_I4_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_8, - "__sync_bool_compare_and_swap_8", - BT_FN_BOOL_VPTR_I8_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_N, - "__sync_val_compare_and_swap", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_1, - "__sync_val_compare_and_swap_1", - BT_FN_I1_VPTR_I1_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_2, - "__sync_val_compare_and_swap_2", - BT_FN_I2_VPTR_I2_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_4, - "__sync_val_compare_and_swap_4", - BT_FN_I4_VPTR_I4_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_8, - "__sync_val_compare_and_swap_8", - BT_FN_I8_VPTR_I8_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_N, "__sync_lock_test_and_set", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_1, "__sync_lock_test_and_set_1", - BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_2, "__sync_lock_test_and_set_2", - BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_4, "__sync_lock_test_and_set_4", - BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_8, "__sync_lock_test_and_set_8", - BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_N, "__sync_lock_release", - BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_1, "__sync_lock_release_1", - BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_2, "__sync_lock_release_2", - BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_4, "__sync_lock_release_4", - BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) -DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_8, "__sync_lock_release_8", - BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) - -DEF_SYNC_BUILTIN (BUILT_IN_SYNCHRONIZE, "__sync_synchronize", - BT_FN_VOID, ATTR_NOTHROW_LIST) +/* Synchronization Primitives. */ +#include "sync-builtins.def" diff --git a/gcc/c-common.c b/gcc/c-common.c index 30a61c2d5a5..e50b7fef697 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2959,14 +2959,8 @@ static GTY(()) tree built_in_attributes[(int) ATTR_LAST]; static void c_init_attributes (void); -/* Build tree nodes and builtin functions common to both C and C++ language - frontends. */ - -void -c_common_nodes_and_builtins (void) +enum c_builtin_type { - enum builtin_type - { #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME, #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME, #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME, @@ -2974,8 +2968,8 @@ c_common_nodes_and_builtins (void) #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME, #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME, #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME, -#define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ - NAME, +#define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) NAME, +#define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) NAME, #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME, #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME, #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME, @@ -2993,6 +2987,7 @@ c_common_nodes_and_builtins (void) #undef DEF_FUNCTION_TYPE_4 #undef DEF_FUNCTION_TYPE_5 #undef DEF_FUNCTION_TYPE_6 +#undef DEF_FUNCTION_TYPE_7 #undef DEF_FUNCTION_TYPE_VAR_0 #undef DEF_FUNCTION_TYPE_VAR_1 #undef DEF_FUNCTION_TYPE_VAR_2 @@ -3000,12 +2995,61 @@ c_common_nodes_and_builtins (void) #undef DEF_FUNCTION_TYPE_VAR_4 #undef DEF_FUNCTION_TYPE_VAR_5 #undef DEF_POINTER_TYPE - BT_LAST - }; + BT_LAST +}; + +typedef enum c_builtin_type builtin_type; - typedef enum builtin_type builtin_type; +/* A temporary array for c_common_nodes_and_builtins. Used in + communication with def_fn_type. */ +static tree builtin_types[(int) BT_LAST + 1]; - tree builtin_types[(int) BT_LAST + 1]; +/* A helper function for c_common_nodes_and_builtins. Build function type + for DEF with return type RET and N arguments. If VAR is true, then the + function should be variadic after those N arguments. + + Takes special care not to ICE if any of the types involved are + error_mark_node, which indicates that said type is not in fact available + (see builtin_type_for_size). In which case the function type as a whole + should be error_mark_node. */ + +static void +def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...) +{ + tree args = NULL, t; + va_list list; + int i; + + va_start (list, n); + for (i = 0; i < n; ++i) + { + builtin_type a = va_arg (list, builtin_type); + t = builtin_types[a]; + if (t == error_mark_node) + goto egress; + args = tree_cons (NULL_TREE, t, args); + } + va_end (list); + + args = nreverse (args); + if (!var) + args = chainon (args, void_list_node); + + t = builtin_types[ret]; + if (t == error_mark_node) + goto egress; + t = build_function_type (t, args); + + egress: + builtin_types[def] = t; +} + +/* Build tree nodes and builtin functions common to both C and C++ language + frontends. */ + +void +c_common_nodes_and_builtins (void) +{ int wchar_type_size; tree array_domain_type; tree va_list_ref_type_node; @@ -3213,155 +3257,42 @@ c_common_nodes_and_builtins (void) } #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \ - builtin_types[(int) ENUM] = VALUE; -#define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \ - builtin_types[(int) ENUM] \ - = build_function_type (builtin_types[(int) RETURN], \ - void_list_node); -#define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \ - builtin_types[(int) ENUM] \ - = build_function_type (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - void_list_node)); -#define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - void_list_node))); -#define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG3], \ - void_list_node)))); -#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - tree_cons \ - (NULL_TREE, \ - builtin_types[(int) ARG3], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG4], \ - void_list_node))))); + builtin_types[ENUM] = VALUE; +#define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \ + def_fn_type (ENUM, RETURN, 0, 0); +#define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \ + def_fn_type (ENUM, RETURN, 0, 1, ARG1); +#define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \ + def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2); +#define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ + def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3); +#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ + def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4); #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - tree_cons \ - (NULL_TREE, \ - builtin_types[(int) ARG3], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG4], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG5],\ - void_list_node)))))); + def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5); #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ ARG6) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - tree_cons \ - (NULL_TREE, \ - builtin_types[(int) ARG3], \ - tree_cons \ - (NULL_TREE, \ - builtin_types[(int) ARG4], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG5], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG6],\ - void_list_node))))))); -#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \ - builtin_types[(int) ENUM] \ - = build_function_type (builtin_types[(int) RETURN], NULL_TREE); -#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \ - builtin_types[(int) ENUM] \ - = build_function_type (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - NULL_TREE)); - -#define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - NULL_TREE))); - -#define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG3], \ - NULL_TREE)))); - -#define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG3], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG4],\ - NULL_TREE))))); - -#define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, \ - ARG5) \ - builtin_types[(int) ENUM] \ - = build_function_type \ - (builtin_types[(int) RETURN], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG1], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG2], \ - tree_cons \ - (NULL_TREE, \ - builtin_types[(int) ARG3], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG4], \ - tree_cons (NULL_TREE, \ - builtin_types[(int) ARG5],\ - NULL_TREE)))))); - -#define DEF_POINTER_TYPE(ENUM, TYPE) \ - builtin_types[(int) ENUM] \ - = build_pointer_type (builtin_types[(int) TYPE]); + def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); +#define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ + ARG6, ARG7) \ + def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7); +#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \ + def_fn_type (ENUM, RETURN, 1, 0); +#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \ + def_fn_type (ENUM, RETURN, 1, 1, ARG1); +#define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \ + def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2); +#define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ + def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3); +#define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ + def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4); +#define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \ + def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5); +#define DEF_POINTER_TYPE(ENUM, TYPE) \ + builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]); + #include "builtin-types.def" + #undef DEF_PRIMITIVE_TYPE #undef DEF_FUNCTION_TYPE_1 #undef DEF_FUNCTION_TYPE_2 @@ -3403,6 +3334,9 @@ c_common_nodes_and_builtins (void) not shared. */ null_node = make_node (INTEGER_CST); TREE_TYPE (null_node) = c_common_type_for_size (POINTER_SIZE, 0); + + /* Since builtin_types isn't gc'ed, don't export these nodes. */ + memset (builtin_types, 0, sizeof (builtin_types)); } /* Look up the function in built_in_decls that corresponds to DECL @@ -3493,6 +3427,9 @@ def_builtin_1 (enum built_in_function fncode, tree decl; const char *libname; + if (fntype == error_mark_node) + return; + gcc_assert ((!both_p && !fallback_p) || !strncmp (name, "__builtin_", strlen ("__builtin_"))); @@ -6178,7 +6115,7 @@ sync_resolve_size (tree function, tree params) goto incompatible; size = tree_low_cst (TYPE_SIZE_UNIT (type), 1); - if (size == 1 || size == 2 || size == 4 || size == 8) + if (size == 1 || size == 2 || size == 4 || size == 8 || size == 16) return size; incompatible: diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 48e3a2a9293..cc609df3f8c 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -586,6 +586,10 @@ const int x86_schedule = m_PPRO | m_ATHLON_K8 | m_K6 | m_PENT; const int x86_use_bt = m_ATHLON_K8; /* Compare and exchange was added for 80486. */ const int x86_cmpxchg = ~m_386; +/* Compare and exchange 8 bytes was added for pentium. */ +const int x86_cmpxchg8b = ~(m_386 | m_486); +/* Compare and exchange 16 bytes was added for nocona. */ +const int x86_cmpxchg16b = m_NOCONA; /* Exchange and add was added for 80486. */ const int x86_xadd = ~m_386; diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index de29adbe948..2d81f0e045c 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -162,7 +162,7 @@ extern const int x86_sse_typeless_stores, x86_sse_load0_by_pxor; extern const int x86_use_ffreep; extern const int x86_inter_unit_moves, x86_schedule; extern const int x86_use_bt; -extern const int x86_cmpxchg, x86_xadd; +extern const int x86_cmpxchg, x86_cmpxchg8b, x86_cmpxchg16b, x86_xadd; extern int x86_prefetch_sse; #define TARGET_USE_LEAVE (x86_use_leave & TUNEMASK) @@ -229,6 +229,8 @@ extern int x86_prefetch_sse; #define TARGET_SUN_TLS (ix86_tls_dialect == TLS_DIALECT_SUN) #define TARGET_CMPXCHG (x86_cmpxchg & (1 << ix86_arch)) +#define TARGET_CMPXCHG8B (x86_cmpxchg8b & (1 << ix86_arch)) +#define TARGET_CMPXCHG16B (x86_cmpxchg16b & (1 << ix86_arch)) #define TARGET_XADD (x86_xadd & (1 << ix86_arch)) #ifndef TARGET_64BIT_DEFAULT diff --git a/gcc/config/i386/sync.md b/gcc/config/i386/sync.md index 03f87b072db..fb3976cc6bc 100644 --- a/gcc/config/i386/sync.md +++ b/gcc/config/i386/sync.md @@ -24,13 +24,54 @@ (define_mode_attr modeconstraint [(QI "q") (HI "r") (SI "r") (DI "r")]) (define_mode_attr immconstraint [(QI "i") (HI "i") (SI "i") (DI "e")]) +(define_mode_macro CASMODE [QI HI SI (DI "TARGET_64BIT || TARGET_CMPXCHG8B") + (TI "TARGET_64BIT && TARGET_CMPXCHG16B")]) +(define_mode_macro DCASMODE + [(DI "!TARGET_64BIT && TARGET_CMPXCHG8B && !flag_pic") + (TI "TARGET_64BIT && TARGET_CMPXCHG16B")]) +(define_mode_attr doublemodesuffix [(DI "8") (TI "16")]) +(define_mode_attr DCASHMODE [(DI "SI") (TI "DI")]) + ;; ??? It would be possible to use cmpxchg8b on pentium for DImode ;; changes. It's complicated because the insn uses ecx:ebx as the ;; new value; note that the registers are reversed from the order ;; that they'd be in with (reg:DI 2 ecx). Similarly for TImode ;; data in 64-bit mode. -(define_insn "sync_compare_and_swap<mode>" +(define_expand "sync_compare_and_swap<mode>" + [(parallel + [(set (match_operand:CASMODE 0 "register_operand" "") + (match_operand:CASMODE 1 "memory_operand" "")) + (set (match_dup 1) + (unspec_volatile:CASMODE + [(match_dup 1) + (match_operand:CASMODE 2 "register_operand" "") + (match_operand:CASMODE 3 "register_operand" "")] + UNSPECV_CMPXCHG_1)) + (clobber (reg:CC FLAGS_REG))])] + "TARGET_CMPXCHG" +{ + if ((<MODE>mode == DImode && !TARGET_64BIT) || <MODE>mode == TImode) + { + enum machine_mode hmode = <MODE>mode == DImode ? SImode : DImode; + rtx low = simplify_gen_subreg (hmode, operands[3], <MODE>mode, 0); + rtx high = simplify_gen_subreg (hmode, operands[3], <MODE>mode, + GET_MODE_SIZE (hmode)); + low = force_reg (hmode, low); + high = force_reg (hmode, high); + if (<MODE>mode == DImode) + emit_insn (gen_sync_double_compare_and_swapdi + (operands[0], operands[1], operands[2], low, high)); + else if (<MODE>mode == TImode) + emit_insn (gen_sync_double_compare_and_swapti + (operands[0], operands[1], operands[2], low, high)); + else + gcc_unreachable (); + DONE; + } +}) + +(define_insn "*sync_compare_and_swap<mode>" [(set (match_operand:IMODE 0 "register_operand" "=a") (match_operand:IMODE 1 "memory_operand" "+m")) (set (match_dup 1) @@ -43,19 +84,47 @@ "TARGET_CMPXCHG" "lock\;cmpxchg{<modesuffix>}\t{%3, %1|%1, %3}") +(define_insn "sync_double_compare_and_swap<mode>" + [(set (match_operand:DCASMODE 0 "register_operand" "=A") + (match_operand:DCASMODE 1 "memory_operand" "+m")) + (set (match_dup 1) + (unspec_volatile:DCASMODE + [(match_dup 1) + (match_operand:DCASMODE 2 "register_operand" "A") + (match_operand:<DCASHMODE> 3 "register_operand" "b") + (match_operand:<DCASHMODE> 4 "register_operand" "c")] + UNSPECV_CMPXCHG_1)) + (clobber (reg:CC FLAGS_REG))] + "" + "lock\;cmpxchg<doublemodesuffix>b\t%1") + +(define_insn "*sync_double_compare_and_swapdi_pic" + [(set (match_operand:DI 0 "register_operand" "=A") + (match_operand:DI 1 "memory_operand" "+m")) + (set (match_dup 1) + (unspec_volatile:DI + [(match_dup 1) + (match_operand:DI 2 "register_operand" "A") + (match_operand:SI 3 "register_operand" "r") + (match_operand:SI 4 "register_operand" "c")] + UNSPECV_CMPXCHG_1)) + (clobber (reg:CC FLAGS_REG))] + "!TARGET_64BIT && TARGET_CMPXCHG8B && flag_pic" + "xchg{l}\t%%ebx, %3\;lock\;cmpxchg8b\t%1\;xchg{l}\t%%ebx, %3") + (define_expand "sync_compare_and_swap_cc<mode>" [(parallel - [(set (match_operand:IMODE 0 "register_operand" "") - (match_operand:IMODE 1 "memory_operand" "")) + [(set (match_operand:CASMODE 0 "register_operand" "") + (match_operand:CASMODE 1 "memory_operand" "")) (set (match_dup 1) - (unspec_volatile:IMODE + (unspec_volatile:CASMODE [(match_dup 1) - (match_operand:IMODE 2 "register_operand" "") - (match_operand:IMODE 3 "register_operand" "")] + (match_operand:CASMODE 2 "register_operand" "") + (match_operand:CASMODE 3 "register_operand" "")] UNSPECV_CMPXCHG_1)) (set (match_dup 4) (compare:CCZ - (unspec_volatile:IMODE + (unspec_volatile:CASMODE [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPECV_CMPXCHG_2) (match_dup 2)))])] "TARGET_CMPXCHG" @@ -64,6 +133,24 @@ ix86_compare_op0 = operands[3]; ix86_compare_op1 = NULL; ix86_compare_emitted = operands[4]; + if ((<MODE>mode == DImode && !TARGET_64BIT) || <MODE>mode == TImode) + { + enum machine_mode hmode = <MODE>mode == DImode ? SImode : DImode; + rtx low = simplify_gen_subreg (hmode, operands[3], <MODE>mode, 0); + rtx high = simplify_gen_subreg (hmode, operands[3], <MODE>mode, + GET_MODE_SIZE (hmode)); + low = force_reg (hmode, low); + high = force_reg (hmode, high); + if (<MODE>mode == DImode) + emit_insn (gen_sync_double_compare_and_swap_ccdi + (operands[0], operands[1], operands[2], low, high)); + else if (<MODE>mode == TImode) + emit_insn (gen_sync_double_compare_and_swap_ccti + (operands[0], operands[1], operands[2], low, high)); + else + gcc_unreachable (); + DONE; + } }) (define_insn "*sync_compare_and_swap_cc<mode>" @@ -83,6 +170,44 @@ "TARGET_CMPXCHG" "lock\;cmpxchg{<modesuffix>}\t{%3, %1|%1, %3}") +(define_insn "sync_double_compare_and_swap_cc<mode>" + [(set (match_operand:DCASMODE 0 "register_operand" "=A") + (match_operand:DCASMODE 1 "memory_operand" "+m")) + (set (match_dup 1) + (unspec_volatile:DCASMODE + [(match_dup 1) + (match_operand:DCASMODE 2 "register_operand" "A") + (match_operand:<DCASHMODE> 3 "register_operand" "b") + (match_operand:<DCASHMODE> 4 "register_operand" "c")] + UNSPECV_CMPXCHG_1)) + (set (reg:CCZ FLAGS_REG) + (compare:CCZ + (unspec_volatile:DCASMODE + [(match_dup 1) (match_dup 2) (match_dup 3) (match_dup 4)] + UNSPECV_CMPXCHG_2) + (match_dup 2)))] + "" + "lock\;cmpxchg<doublemodesuffix>b\t%1") + +(define_insn "*sync_double_compare_and_swap_ccdi_pic" + [(set (match_operand:DI 0 "register_operand" "=A") + (match_operand:DI 1 "memory_operand" "+m")) + (set (match_dup 1) + (unspec_volatile:DI + [(match_dup 1) + (match_operand:DI 2 "register_operand" "A") + (match_operand:SI 3 "register_operand" "r") + (match_operand:SI 4 "register_operand" "c")] + UNSPECV_CMPXCHG_1)) + (set (reg:CCZ FLAGS_REG) + (compare:CCZ + (unspec_volatile:DI + [(match_dup 1) (match_dup 2) (match_dup 3) (match_dup 4)] + UNSPECV_CMPXCHG_2) + (match_dup 2)))] + "!TARGET_64BIT && TARGET_CMPXCHG8B && flag_pic" + "xchg{l}\t%%ebx, %3\;lock\;cmpxchg8b\t%1\;xchg{l}\t%%ebx, %3") + (define_insn "sync_old_add<mode>" [(set (match_operand:IMODE 0 "register_operand" "=<modeconstraint>") (unspec_volatile:IMODE diff --git a/gcc/sync-builtins.def b/gcc/sync-builtins.def new file mode 100644 index 00000000000..a619ecce073 --- /dev/null +++ b/gcc/sync-builtins.def @@ -0,0 +1,253 @@ +/* This file contains the definitions and documentation for the + synchronization builtins used in the GNU compiler. + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC 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 2, or (at your option) any later +version. + +GCC 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. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. */ + +/* Before including this file, you should define a macro: + + DEF_SYNC_BUILTIN (ENUM, NAME, TYPE, ATTRS) + + See builtins.def for details. */ + +/* Synchronization Primitives. The "_N" version is the one that the user + is supposed to be using. It's overloaded, and is resolved to one of the + "_1" through "_16" versions, plus some extra casts. */ + +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_N, "__sync_fetch_and_add", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_1, "__sync_fetch_and_add_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_2, "__sync_fetch_and_add_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_4, "__sync_fetch_and_add_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_8, "__sync_fetch_and_add_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_ADD_16, "__sync_fetch_and_add_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_N, "__sync_fetch_and_sub", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_1, "__sync_fetch_and_sub_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_2, "__sync_fetch_and_sub_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_4, "__sync_fetch_and_sub_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_8, "__sync_fetch_and_sub_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_SUB_16, "__sync_fetch_and_sub_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_N, "__sync_fetch_and_or", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_1, "__sync_fetch_and_or_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_2, "__sync_fetch_and_or_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_4, "__sync_fetch_and_or_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_8, "__sync_fetch_and_or_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_OR_16, "__sync_fetch_and_or_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_N, "__sync_fetch_and_and", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_1, "__sync_fetch_and_and_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_2, "__sync_fetch_and_and_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_4, "__sync_fetch_and_and_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_8, "__sync_fetch_and_and_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_AND_16, "__sync_fetch_and_and_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_N, "__sync_fetch_and_xor", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_1, "__sync_fetch_and_xor_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_2, "__sync_fetch_and_xor_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_4, "__sync_fetch_and_xor_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_8, "__sync_fetch_and_xor_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_XOR_16, "__sync_fetch_and_xor_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_N, "__sync_fetch_and_nand", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_1, "__sync_fetch_and_nand_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_2, "__sync_fetch_and_nand_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_4, "__sync_fetch_and_nand_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_8, "__sync_fetch_and_nand_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_FETCH_AND_NAND_16, "__sync_fetch_and_nand_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_N, "__sync_add_and_fetch", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_1, "__sync_add_and_fetch_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_2, "__sync_add_and_fetch_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_4, "__sync_add_and_fetch_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_8, "__sync_add_and_fetch_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_ADD_AND_FETCH_16, "__sync_add_and_fetch_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_N, "__sync_sub_and_fetch", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_1, "__sync_sub_and_fetch_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_2, "__sync_sub_and_fetch_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_4, "__sync_sub_and_fetch_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_8, "__sync_sub_and_fetch_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_SUB_AND_FETCH_16, "__sync_sub_and_fetch_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_N, "__sync_or_and_fetch", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_1, "__sync_or_and_fetch_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_2, "__sync_or_and_fetch_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_4, "__sync_or_and_fetch_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_8, "__sync_or_and_fetch_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_OR_AND_FETCH_16, "__sync_or_and_fetch_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_N, "__sync_and_and_fetch", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_1, "__sync_and_and_fetch_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_2, "__sync_and_and_fetch_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_4, "__sync_and_and_fetch_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_8, "__sync_and_and_fetch_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_AND_AND_FETCH_16, "__sync_and_and_fetch_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_N, "__sync_xor_and_fetch", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_1, "__sync_xor_and_fetch_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_2, "__sync_xor_and_fetch_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_4, "__sync_xor_and_fetch_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_8, "__sync_xor_and_fetch_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_XOR_AND_FETCH_16, "__sync_xor_and_fetch_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_N, "__sync_nand_and_fetch", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_1, "__sync_nand_and_fetch_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_2, "__sync_nand_and_fetch_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_4, "__sync_nand_and_fetch_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_8, "__sync_nand_and_fetch_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_NAND_AND_FETCH_16, "__sync_nand_and_fetch_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_N, + "__sync_bool_compare_and_swap", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_1, + "__sync_bool_compare_and_swap_1", + BT_FN_BOOL_VPTR_I1_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_2, + "__sync_bool_compare_and_swap_2", + BT_FN_BOOL_VPTR_I2_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_4, + "__sync_bool_compare_and_swap_4", + BT_FN_BOOL_VPTR_I4_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_8, + "__sync_bool_compare_and_swap_8", + BT_FN_BOOL_VPTR_I8_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_BOOL_COMPARE_AND_SWAP_16, + "__sync_bool_compare_and_swap_16", + BT_FN_BOOL_VPTR_I16_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_N, + "__sync_val_compare_and_swap", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_1, + "__sync_val_compare_and_swap_1", + BT_FN_I1_VPTR_I1_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_2, + "__sync_val_compare_and_swap_2", + BT_FN_I2_VPTR_I2_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_4, + "__sync_val_compare_and_swap_4", + BT_FN_I4_VPTR_I4_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_8, + "__sync_val_compare_and_swap_8", + BT_FN_I8_VPTR_I8_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_VAL_COMPARE_AND_SWAP_16, + "__sync_val_compare_and_swap_16", + BT_FN_I16_VPTR_I16_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_N, "__sync_lock_test_and_set", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_1, "__sync_lock_test_and_set_1", + BT_FN_I1_VPTR_I1, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_2, "__sync_lock_test_and_set_2", + BT_FN_I2_VPTR_I2, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_4, "__sync_lock_test_and_set_4", + BT_FN_I4_VPTR_I4, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_8, "__sync_lock_test_and_set_8", + BT_FN_I8_VPTR_I8, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_TEST_AND_SET_16, "__sync_lock_test_and_set_16", + BT_FN_I16_VPTR_I16, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_N, "__sync_lock_release", + BT_FN_VOID_VAR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_1, "__sync_lock_release_1", + BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_2, "__sync_lock_release_2", + BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_4, "__sync_lock_release_4", + BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_8, "__sync_lock_release_8", + BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) +DEF_SYNC_BUILTIN (BUILT_IN_LOCK_RELEASE_16, "__sync_lock_release_16", + BT_FN_VOID_VPTR, ATTR_NOTHROW_LIST) + +DEF_SYNC_BUILTIN (BUILT_IN_SYNCHRONIZE, "__sync_synchronize", + BT_FN_VOID, ATTR_NOTHROW_LIST) |