[Midnightbsd-cvs] src [10405] trunk/contrib: move gcc
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Mon Jun 4 13:30:22 EDT 2018
Revision: 10405
http://svnweb.midnightbsd.org/src/?rev=10405
Author: laffer1
Date: 2018-06-04 13:30:21 -0400 (Mon, 04 Jun 2018)
Log Message:
-----------
move gcc
Modified Paths:
--------------
trunk/contrib/gcc/Makefile.in
trunk/contrib/gcc/attribs.c
trunk/contrib/gcc/builtin-types.def
trunk/contrib/gcc/builtins.c
trunk/contrib/gcc/builtins.def
trunk/contrib/gcc/c-common.c
trunk/contrib/gcc/c-common.h
trunk/contrib/gcc/c-convert.c
trunk/contrib/gcc/c-cppbuiltin.c
trunk/contrib/gcc/c-decl.c
trunk/contrib/gcc/c-incpath.c
trunk/contrib/gcc/c-objc-common.h
trunk/contrib/gcc/c-opts.c
trunk/contrib/gcc/c-parser.c
trunk/contrib/gcc/c-ppoutput.c
trunk/contrib/gcc/c-pretty-print.c
trunk/contrib/gcc/c-pretty-print.h
trunk/contrib/gcc/c-tree.h
trunk/contrib/gcc/c-typeck.c
trunk/contrib/gcc/c.opt
trunk/contrib/gcc/calls.c
trunk/contrib/gcc/cfg.c
trunk/contrib/gcc/cfgexpand.c
trunk/contrib/gcc/cgraph.h
trunk/contrib/gcc/cgraphunit.c
trunk/contrib/gcc/collect2.c
trunk/contrib/gcc/combine.c
trunk/contrib/gcc/common.opt
trunk/contrib/gcc/config/arm/arm.c
trunk/contrib/gcc/config/arm/arm.h
trunk/contrib/gcc/config/arm/arm.md
trunk/contrib/gcc/config/arm/freebsd.h
trunk/contrib/gcc/config/arm/ieee754-df.S
trunk/contrib/gcc/config/arm/lib1funcs.asm
trunk/contrib/gcc/config/arm/libunwind.S
trunk/contrib/gcc/config/arm/unwind-arm.c
trunk/contrib/gcc/config/arm/unwind-arm.h
trunk/contrib/gcc/config/darwin.c
trunk/contrib/gcc/config/darwin.h
trunk/contrib/gcc/config/freebsd.h
trunk/contrib/gcc/config/i386/athlon.md
trunk/contrib/gcc/config/i386/beos-elf.h
trunk/contrib/gcc/config/i386/cygwin.h
trunk/contrib/gcc/config/i386/driver-i386.c
trunk/contrib/gcc/config/i386/emmintrin.h
trunk/contrib/gcc/config/i386/freebsd.h
trunk/contrib/gcc/config/i386/freebsd64.h
trunk/contrib/gcc/config/i386/i386.c
trunk/contrib/gcc/config/i386/i386.h
trunk/contrib/gcc/config/i386/i386.md
trunk/contrib/gcc/config/i386/i386.opt
trunk/contrib/gcc/config/i386/nto.h
trunk/contrib/gcc/config/i386/pmmintrin.h
trunk/contrib/gcc/config/i386/sse.md
trunk/contrib/gcc/config/i386/x86-64.h
trunk/contrib/gcc/config/i386/xmmintrin.h
trunk/contrib/gcc/config/ia64/hpux.h
trunk/contrib/gcc/config/ia64/ia64.c
trunk/contrib/gcc/config/ia64/unwind-ia64.h
trunk/contrib/gcc/config/mips/mips.c
trunk/contrib/gcc/config/mips/mips.h
trunk/contrib/gcc/config/mips/mips.md
trunk/contrib/gcc/config/mips/predicates.md
trunk/contrib/gcc/config/rs6000/aix.h
trunk/contrib/gcc/config/rs6000/altivec.h
trunk/contrib/gcc/config/rs6000/crtsavres.asm
trunk/contrib/gcc/config/rs6000/freebsd.h
trunk/contrib/gcc/config/rs6000/rs6000-c.c
trunk/contrib/gcc/config/rs6000/rs6000.c
trunk/contrib/gcc/config/rs6000/rs6000.md
trunk/contrib/gcc/config/rs6000/sysv4.h
trunk/contrib/gcc/config/rs6000/tramp.asm
trunk/contrib/gcc/config/s390/s390.md
trunk/contrib/gcc/config/sparc/freebsd.h
trunk/contrib/gcc/config/svr4.h
trunk/contrib/gcc/config.gcc
trunk/contrib/gcc/configure
trunk/contrib/gcc/configure.ac
trunk/contrib/gcc/convert.c
trunk/contrib/gcc/convert.h
trunk/contrib/gcc/coverage.c
trunk/contrib/gcc/cp/Make-lang.in
trunk/contrib/gcc/cp/call.c
trunk/contrib/gcc/cp/class.c
trunk/contrib/gcc/cp/cp-gimplify.c
trunk/contrib/gcc/cp/cp-lang.c
trunk/contrib/gcc/cp/cp-objcp-common.c
trunk/contrib/gcc/cp/cp-objcp-common.h
trunk/contrib/gcc/cp/cp-tree.def
trunk/contrib/gcc/cp/cp-tree.h
trunk/contrib/gcc/cp/cvt.c
trunk/contrib/gcc/cp/decl.c
trunk/contrib/gcc/cp/decl.h
trunk/contrib/gcc/cp/decl2.c
trunk/contrib/gcc/cp/dump.c
trunk/contrib/gcc/cp/error.c
trunk/contrib/gcc/cp/init.c
trunk/contrib/gcc/cp/mangle.c
trunk/contrib/gcc/cp/method.c
trunk/contrib/gcc/cp/name-lookup.c
trunk/contrib/gcc/cp/name-lookup.h
trunk/contrib/gcc/cp/parser.c
trunk/contrib/gcc/cp/pt.c
trunk/contrib/gcc/cp/ptree.c
trunk/contrib/gcc/cp/rtti.c
trunk/contrib/gcc/cp/semantics.c
trunk/contrib/gcc/cp/tree.c
trunk/contrib/gcc/cp/typeck.c
trunk/contrib/gcc/cppdefault.c
trunk/contrib/gcc/dbxout.c
trunk/contrib/gcc/doc/cpp.texi
trunk/contrib/gcc/doc/cppopts.texi
trunk/contrib/gcc/doc/extend.texi
trunk/contrib/gcc/doc/gcc.1
trunk/contrib/gcc/doc/invoke.texi
trunk/contrib/gcc/doc/libgcc.texi
trunk/contrib/gcc/doc/rtl.texi
trunk/contrib/gcc/doc/tm.texi
trunk/contrib/gcc/dwarf2.h
trunk/contrib/gcc/dwarf2out.c
trunk/contrib/gcc/emit-rtl.c
trunk/contrib/gcc/expmed.c
trunk/contrib/gcc/expr.c
trunk/contrib/gcc/final.c
trunk/contrib/gcc/flags.h
trunk/contrib/gcc/fold-const.c
trunk/contrib/gcc/function.c
trunk/contrib/gcc/function.h
trunk/contrib/gcc/gcc.c
trunk/contrib/gcc/gcov.c
trunk/contrib/gcc/genattrtab.c
trunk/contrib/gcc/genopinit.c
trunk/contrib/gcc/ggc-common.c
trunk/contrib/gcc/ggc.h
trunk/contrib/gcc/gimplify.c
trunk/contrib/gcc/ginclude/stdarg.h
trunk/contrib/gcc/ginclude/stddef.h
trunk/contrib/gcc/gthr-posix.h
trunk/contrib/gcc/gthr-posix95.h
trunk/contrib/gcc/langhooks-def.h
trunk/contrib/gcc/langhooks.c
trunk/contrib/gcc/langhooks.h
trunk/contrib/gcc/libgcc-std.ver
trunk/contrib/gcc/longlong.h
trunk/contrib/gcc/mips-tdump.c
trunk/contrib/gcc/mips-tfile.c
trunk/contrib/gcc/mklibgcc.in
trunk/contrib/gcc/optabs.c
trunk/contrib/gcc/optabs.h
trunk/contrib/gcc/opth-gen.awk
trunk/contrib/gcc/opts.c
trunk/contrib/gcc/postreload-gcse.c
trunk/contrib/gcc/print-rtl.c
trunk/contrib/gcc/print-tree.c
trunk/contrib/gcc/regs.h
trunk/contrib/gcc/reload1.c
trunk/contrib/gcc/rtl.def
trunk/contrib/gcc/rtl.h
trunk/contrib/gcc/rtlanal.c
trunk/contrib/gcc/sched-vis.c
trunk/contrib/gcc/simplify-rtx.c
trunk/contrib/gcc/stmt.c
trunk/contrib/gcc/stor-layout.c
trunk/contrib/gcc/stub-objc.c
trunk/contrib/gcc/target-def.h
trunk/contrib/gcc/target.h
trunk/contrib/gcc/targhooks.c
trunk/contrib/gcc/tlink.c
trunk/contrib/gcc/toplev.c
trunk/contrib/gcc/toplev.h
trunk/contrib/gcc/tree-cfg.c
trunk/contrib/gcc/tree-dump.c
trunk/contrib/gcc/tree-flow.h
trunk/contrib/gcc/tree-gimple.h
trunk/contrib/gcc/tree-nested.c
trunk/contrib/gcc/tree-ssa-alias.c
trunk/contrib/gcc/tree-ssa-propagate.c
trunk/contrib/gcc/tree-vrp.c
trunk/contrib/gcc/tree.c
trunk/contrib/gcc/tree.def
trunk/contrib/gcc/tree.h
trunk/contrib/gcc/unwind-dw2.c
trunk/contrib/gcc/varasm.c
Added Paths:
-----------
trunk/contrib/gcc/
trunk/contrib/gcc/ChangeLog.apple
trunk/contrib/gcc/ChangeLog.gcc43
trunk/contrib/gcc/config/i386/ammintrin.h
trunk/contrib/gcc/cp/ChangeLog.apple
trunk/contrib/gcc/cp/ChangeLog.gcc43
trunk/contrib/gcc/tree-ssa-alias-warnings.c
Removed Paths:
-------------
trunk/contrib/gcc4/
Added: trunk/contrib/gcc/ChangeLog.apple
===================================================================
--- trunk/contrib/gcc/ChangeLog.apple (rev 0)
+++ trunk/contrib/gcc/ChangeLog.apple 2018-06-04 17:30:21 UTC (rev 10405)
@@ -0,0 +1,951 @@
+2010-03-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7760213
+ * c-common.h (HasByrefArray): New decl.
+ * c-common.c (HasByrefArray): New definition.
+ * c-typeck.c (build_external_ref): Diagnose access of
+ __block array.
+
+2010-03-12 Jim Grosbach <grosbach at apple.com>
+
+ Radar 7744816
+
+ * expmed.c (synth_mult): Remove incorrect special case handling for
+ 0xffffffff.
+
+2010-03-12 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7735196
+ * c-parser.c (build_block_struct_initlist):
+ Set BLOCK_USE_STRET flag in block descriptor for
+ blocks which return their aggregate value in memory.
+ * c-common.h (BLOCK_USE_STRET): New flag.
+
+2010-03-05 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7721728
+ * c-typeck.c (build_external_ref): Diagnose
+ importation of copied-in variables.
+
+2009-03-12 Caroline Tice <ctice at apple.com>
+
+ Radar 6144634
+ * c-parser.c (c_parser_statement_after_labels): When
+ re-setting the expression location at the end, use the input
+ location for Block pointer assignments.
+
+2009-02-11 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6573923
+ * c-decl.c (synth_block_byref_id_object_copy_func,
+ synth_block_byref_id_object_dispose_func): Set BLOCK_BYREF_CALLER
+ flag in call to copy/dispose helper functions.
+ * c-common.h (BLOCK_BYREF_CALLER): New flag.
+
+2008-12-21 Caroline Tice <ctice at apple.com>
+
+ Radar 6455678
+ * cp/typeck.c (original_type): Stop if the type
+ and its DECL_ORIGINAL_TYPE are the same.
+
+2008-12-18 Bill Wendling <wendling at apple.com>
+
+ Radar 6457359
+ * c-parser.c (build_block_struct_initlist): Changed type.
+ * cp/parser.c (build_block_struct_initlist): Ditto.
+
+2008-12-02 Caroline Tice <ctice at apple.com>
+
+ Radar 6386976
+ * objcp/objcp-decl.h (TYPE_HAS_OBJCXX_INFO): New macro.
+ * objcp/objcp-lang.c (objcp-decl.h): New include statement, with
+ required define.
+ (LANG_HOOKS_IS_RUNTIME_SPECIFIC_TYPE): Redefine for
+ obj-c++.
+ (objcxx_is_runtime_type): New function.
+
+2008-12-02 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6411649
+ * funciton.h: Added new field.
+ * c-common.c (build_block_helper_name): Produce a unique
+ block number per each enclosing function when building
+ the block helper function name.
+
+2008-11-18 Stuart Hastings <stuart at apple.com>
+
+ Radar 6353006
+ * tree.c (generic_block_literal_struct_type): Fix APPLE LOCAL.
+ * langhooks-def.h (lhd_build_generic_block_struct_type): Fix
+ APPLE LOCAL.
+
+2008-11-07 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5847976
+ * c-decl.c (synth_block_byref_id_object_copy_func): Takes a new
+ 'flag' argument and generates the much simplified API.
+ (synth_block_byref_id_object_dispose_func): Ditto.
+ (new_block_byref_decl): Hack to prevent issuing bogus warning
+ on a field declared as __weak.
+ (init_byref_decl): Takes an additional 'flag' argument
+ and passes it down to synth_block_byref_id_object_copy_func and
+ synth_block_byref_id_object_dispose_func.
+ (finish_decl): Computes the flag for the block variable declaration.
+ * c-common.c (build_block_byref_release_decl,
+ build_block_byref_assign_copy_decl): Removed.
+ (build_block_byref_release_exp): Use the new API.
+ (build_block_object_assign_decl, build_block_object_assign_call_exp,
+ build_block_object_dispose_decl, build_block_object_dispose_call_exp): New.
+ (build_indirect_object_id_exp): Fixed a code gen bug which was exposed in
+ c/c++ mode, but not in ObjC/ObjC++ mode.
+ * c-common.h (build_block_object_assign_call_exp,
+ build_block_object_dispose_call_exp,
+ objc_is_gcable_type): New decls.
+ Declaration of several new flags.
+ (cast_to_pointer_to_id): Removed.
+ * stub-objc.c (objc_is_gcable_type): New
+ (copy_in_object, retain_block_component, release_block_component): Removed.
+ (cast_to_pointer_to_id): Removed.
+ * c-parser.c (build_block_struct_initlist): Remove call to copy_in_object.
+ (synth_copy_helper_block_func): Generates much simplified API.
+ (synth_destroy_helper_block_func): Ditto.
+ (block_object_dispose): Removed.
+ * config/darwin-c.c (darwin_cpp_builtins): Define __weak even when
+ -fobjc-gc is off.
+
+2008-10-31 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6175959
+ * stub-objc.c (block_requires_copying): Object pointers with
+ NSObject attribute also require copy/release API.
+ * c-parser.c (synth_copy_helper_block_func): Use the new API
+ _Block_object_assign for ObjC object copying.
+ (block_object_dispose): New
+ (synth_destroy_helper_block_func): Call block_object_dispose
+ to use new _Block_object_dispose API for ObjC object release.
+
+2008-10-27 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6231433
+ * c-typeck.c (objc_compare_types, objc_have_common_type):
+ Take an extra argument for better diagnostics.
+ * c-common.c (objc_compare_types, objc_have_common_type):
+ Take extra argument.
+ * stub-objc.c: Ditto
+
+2008-10-24 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6305545
+ * cgraph.h (lower_if_nested_functions): New decl.
+ * tree-gimple.h (lower_nested_functions): Takes one more arg.
+ * cgraphunit.c (lower_if_nested_functions): New
+ * tree-nested.c (lower_nested_functions): Skip structors.
+
+2008-10-24 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5847213 (minor tweak)
+ * c-decl.c (build_block_descriptor_type):
+ Make descriptor_ptr_type and descriptor_ptr_type_with_copydispose
+ visible to pch.
+
+2008-10-23 Caroline Tice <ctice at apple.com>
+
+ Radar 6300081
+ * tree.c(build_block_pointer_type): Add call to
+ build_generic_block_struct_type to initialize
+ generic_block_literal_struct_type if necessary.
+ * cp/parser.c (build_generic_block_struct_type): Update comments.
+ (build_block_struct_type): Remove call to
+ build_generic_block_struct_type.
+ (make_block_pointer_declarator): Likewise.
+ * c-decl.c (make_block_pointer_declarator): Likewise.
+ * c-parser.c (build_block_struct_type): Likewise.
+ (build_generic_block_struct_type): Update comments.
+
+2008-10-22 Caroline Tice <ctice at apple.com>
+
+ Radar 6300081 & Radar 6163705
+ * tree.h (generic_block_literal_struct_type): Extern global variable
+ decl.
+ (build_generic_block_struct_type): New extern function decl.
+ * cp/parser (build_generic_block_struct_type): New function.
+ (build_block_struct_type): Call build_generic_block_struct_type
+ to initialize generic_block_literal_struct_type.
+ (make_block_pointer_declarator): Likewise.
+ (declare_block_prologue_local_vars): Temporarily set input_location
+ to 1 before the start of the block function; re-set input_location at
+ the end of this function.
+ * dwarf2out.c (add_type_attribute): If the type is a
+ BLOCK_POINTER_TYPE, assign it to be a pointer to a
+ generic_block_literal_struct_type.
+ * c-decl.c (make_block_pointer_declarator): Call
+ build_generic_block_struct_type to initialize
+ generic_block_literal_struct_type.
+ * c-common.c (generic_block_literal_struct_type): New global variable.
+ * c-parser.c (build_generic_block_struct_type): New function.
+ (build_block_struct_type): Call build_generic_block_struct_type
+ to initialize generic_block_literal_struct_type.
+ * testsuite/gcc.apple/block-debug-1.c: Fix test to work with new
+ compiler modifications.
+ * testsuite/gcc.apple/block-debug-2.c: Likewise.
+ * testsuite/g++.apple/block-debug-1.C: Likewise.
+ * testsuite/g++.apple/block-debug-2.C: Likewise.
+
+2008-10-10 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5847213 - New Block ABI
+ * dwarf2out.c (add_type_attribute): Unusuable code
+ for radar 5811943 is removed.
+ * c-decl.c (build_block_byref_decl): Removed unneeded
+ build of block_original_byref_decl_list.
+ (build_block_internal_types): Removed.
+ (build_block_descriptor_type): New routine to build the descriptor type.
+ (make_block_pointer_declarator): Unused code is removed.
+ * c-typeck.c (build_block_call): New code gen for block calls.
+ * c-common.c (invoke_impl_ptr_type): Removed.
+ * c-common.h (block_original_byref_decl_list, build_block_internal_types): Removed
+ (build_block_descriptor_type, BLOCK_HAS_DESCRIPTOR): Decls added.
+ * c-parser.c (build_block_struct_type): Block literal expression internal type
+ is redeclared into its new layout.
+ (build_block_struct_initlist): Initializer list for above type is redone.
+ (build_descriptor_block_decl): New routine to declare the descriptor variable
+ (build_block_literal_tmp): Modified for the new type and initiazation.
+
+2008-10-06 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6268817
+ * c-decl.c (check_for_loop_decls): Block helper function
+ is OK if declared in a for-loop main statement block.
+
+2008-10-02 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6246527
+ * attribs.c (decl_attributes): Added support for adding attributes
+ on block pointer variable declarations.
+ * c-common.c (block_delta_format_args): Add
+ (any_recognized_block_attribute): Add
+ * c-common.h (any_recognized_block_attribute): New decl.
+ * c-parser.c (c_parser_block_literal_expr): Call to do the delta
+ on printf attribute.
+
+2008-09-30 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6225809
+ * c-decl.c (build_block_byref_decl): Add __block vaiables
+ to intervening blocks.
+
+2008-09-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6237713
+ * c-common.c (handle_noreturn_attribute): Add 'noreturn'
+ attribute to block pointer decls.
+ * c-parser.c (c_parser_block_literal_expr): Parse and set
+ attributes on block literals.
+
+2008-09-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6244520 - minor addition
+ * c-common.c (build_indirect_object_id_exp): offset needs
+ be updated to accomodate addition of the new field.
+
+2008-09-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6214617
+ * c-common: New flag BLOCK_HAS_CXX_OBJ replaces BLOCK_NO_COPY.
+ (BlockImportsCxxObjects): New field replaces BlockHasByrefVar.
+ * c-parser.c (build_block_struct_type): Remove setting of
+ BLOCK_NO_COPY flag.
+
+2008-09-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6217257
+ * c-common.c (handle_blocks_attribute): Diagnose
+ vla __block declarations.
+
+2008-09-12 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6212722 (tweak)
+ * c-decl.c (build_block_ref_decl): Use array_to_pointer_conversion
+ and function_to_pointer_conversion.
+ * c-typeck.c (array_to_pointer_conversion, function_to_pointer_conversion):
+ Made them global.
+ * c-common.h (array_to_pointer_conversion, function_to_pointer_conversion):
+ Declare.
+
+2008-09-09 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6169580
+ * c-commmon.c (build_block_helper_name): Fix bug in
+ block helper function name mangling.
+
+2008-09-03 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6185344
+ * c-typeck.c (c_finish_return): Don't do block specific
+ stuff when block has a return type.
+ * c-common.h (block_sema_info): block_has_return_type is
+ a new field.
+ * c-parser.c (c_parser_direct_declarator): Terminate type
+ parsing for block return types.
+ (c_parser_block_literal_expr): Added support to parse and
+ handle explicit return type for blocks.
+
+2008-08-28 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6160536
+ * c-commmon.c (build_block_helper_name): New
+ * c-common.h (build_block_helper_name): New decl.
+ * c-parser.c (c_parser_block_literal_expr): Call
+ build_block_helper_name to build pretty helper function
+ name.
+
+2008-08-28 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6180456
+ * c-decl.c (synth_block_byref_id_object_copy_func): Different
+ API for copying __block declared objects in c.
+ (synth_block_byref_id_object_dispose_func): Different API
+ for releasing __block declared objects in c.
+ * c-common.c (block_byref_assign_copy_decl): New
+ (build_indirect_object_id_exp): Cast to 'id *' in objective-c
+ mode only.
+ * c-common.h (build_block_byref_assign_copy_decl): New decl.
+ * c-parser.c (synth_copy_helper_block_func): Refactored code
+ to call build_block_byref_assign_copy_decl().
+
+2008-08-24 Caroline Tice <ctice at apple.com>
+
+ Radars 6144664, 6145471, 6144634
+ c-decl.c (build_block_byref_decl): Assign the source
+ location for each byref decl to the source location of
+ the helper function decl.
+ (build_block_ref_decl): Ditto for ref decls.
+
+2008-08-14 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5822844
+ * c-typeck.c (digest_init): Handler block as initializer.
+ (c_finish_return): check for completed block before
+ analyzing block's return expression.
+ * varasm.c (output_constant): Allow outputting block data.
+ * c-common.h (BLOCK_IS_GLOBAL): New flag.
+ (block_is_complete): New field in block data structure.
+ * c-parser.c (build_block_struct_initlist): New initializer and
+ flag for global block data.
+ (build_block_literal_tmp): Temporary data for global block is
+ declared as global static.
+ (c_parser_block_literal_expr): Removed diagnostics for global blocks.
+ Moved fixing helper function type earlier before its tree is built.
+
+2008-08-06 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6014138
+ * c-decl.c (build_block_byref_decl): In the presence of nested "{"
+ move up the scope chain until reaching the main function body's scope.
+
+2008-08-04 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305 - work in progress.
+ * c-decl.c (build_indirect_object_id_exp): Removed.
+ * c-common.c (build_indirect_object_id_exp): Added
+ * c-common.h (build_indirect_object_id_exp): New decl.
+ * config/darwin-c.c (darwin_cpp_builtins): Define __byref
+ in c++ mode as well.
+
+2008-07-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6083129 - twiked
+ * c-decl.c (release_all_local_byrefs_at_return): Do not release
+ imported __byref variables in the block.
+ * c-parser.c (gen_block_byref_release_exp): Do not release __byref
+ variables outside of the block when returning from the block.
+
+2008-07-15 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5988451
+ * c-decl.c (build_block_ref_decl): Insert copied in variable
+ in each enclosing block which does not use it.
+ (begin_block): Remove setting of "the_scope" field of the block.
+ (in_imm_block): Fix effect of changing the "the_scope" field.
+ (lookup_name_in_block): Do not skip over copied-in variables when
+ looking up a variable in the block.
+ * c-parser.c (c_parser_block_literal_expr): Set block's "the_scope" field
+ to the helper function's outer-most body scope.
+
+2008-07-08 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6048570
+ * c-typeck.c (c_finish_return): Error on returning a block on the stack.
+
+2008-06-05 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5988995
+ * c-typeck.c (types_are_closure_compatible): Nested block pointer
+ types must be considered when matching block types.
+
+2008-06-05 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5982990
+ * c-parser.c (c_parser_objc_synch_compound_statement): New
+ (c_parser_objc_synchronized_statement): Call
+ c_parser_objc_synch_compound_statement.
+
+2008-06-04 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5985368
+ * c-parser.c (c_parser_declaration_or_fndef): Better diagnostics for
+ a bad block definition.
+
+2008-05-23 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5925781
+ * c-common.c (handle_nonnull_attribute): Support block pointer
+ just like a pointer for nonnull attribute.
+ (check_nonnull_arg): Ditto.
+
+2008-05-20 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5932809 - minor change for runtime delight.
+ * c-parser.c (build_closure_struct_type): Add strcutor fields
+ for __byref 'id' object blocks as well.
+ (build_closure_struct_initlist): And their initializers.
+
+2008-04-30 Caroline Tice <ctice at apple.com>
+
+ Radar 5811961
+ * c-decl.c: (declare_closure_prologue_local_vars): Set the source
+ location for the new decl expr statement to be the source location of
+ the decl tree.
+
+2008-04-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5803005 (tweaked)
+ * c-typeck.c (build_external_ref): Refactored global decl checks.
+
+2008-04-24 Caroline Tice <ctice at apple.com>
+
+ Radar 5811943
+ * tree.h (TYPE_CLOSURE_IMPL_STRUCT): New macro.
+ (lang_flag_2): Use previously unused field in tree_type to indicate
+ closure structs.
+ * dwarf2out.c (c-common.h): New include statement.
+ (dwarf_attr_name): Add case for DW_AT_APPLE_closure.
+ (gen_variable_die): Give pointers to closures the
+ invoke_impl_ptr_type.
+ (gen_struct_or_union_type_die): Add DW_AT_APPLE_closure
+ to structs that define closures.
+ * dwarf2.h (DW_AT_APPLE_closure): New Dwarf attribute.
+ * c-typeck.c (invoke_impl_ptr_type): Move declaration from here to
+ c-common.c
+ (build_closure_internal_types): Set TYPE_CLOSURE_IMPL_STRUCT
+ flag for closure structs.
+ * c-common.c (invoke_impl_ptr_type): Move declaration to here from
+ c-typeck.c.
+
+2008-04-23 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5882266
+ * c-typeck.c (types_are_closure_compatible): Check for underlying
+ pointer types as well.
+
+2008-04-15 Stuart Hastings <stuart at apple.com>
+
+ Radar 5862465
+ * tree.h (PTR_OR_REF_CHECK, POINTER_TYPE_P): Add
+ CLOSURE_POINTER_TYPE.
+ * fold-const.c (fold_convert): Add CLOSURE_POINTER_TYPE.
+ * testsuite/gcc.apple/closure-5862465.c: New.
+
+2008-03-31 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5831855
+ * c-typeck.c (convert_for_assignment): Block and 'id' types
+ are interchangeable.
+
+2008-03-28 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5809099
+ * convert.c (convert_to_pointer): Allow typecast of closure
+ pointer to 'id'.
+ (convert_to_closure_pointer): Allow typecast of 'id'
+ of a closure pointer expression.
+
+2008-03-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5811887 (minor change)
+ * c-opts.c (c_common_post_options): Remove conditional check
+ of pedantic when setting flag_blocks.
+
+2008-03-24 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5811887
+ * c-cppbuiltin.c: flag_closures renamed to flag_blocks
+ * c-parser.c: Ditto.
+ * c.opt: flag_closures renamed to flag_blocks. flag_blocks
+ defaulted to -1.
+ * c-opts.c (c_common_post_options): All flavors of c99, blocks are off by
+ default unless requested via -fblocks.
+
+2008-03-24 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5814025
+ * c-tree.h (make_closure_pointer_declarator): Takes
+ additional argument.
+ * c-decl.c (grokdeclarator): Get 'const'-ness of closure
+ pointer.
+ (make_closure_pointer_declarator): Takes additional argument for
+ const/volatile.
+ * c-parser.c (c_parser_declarator): Pass down attribute info.
+ to make_closure_pointer_declarator.
+
+2008-03-20 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5802025
+ * c-common.h (objc_build_property_getter_func_call): New decl.
+ * stub-objc.c (objc_build_property_getter_func_call): New stub.
+
+2008-03-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5803600
+ * c-decl.c (add_closure_global_byref_list,
+ in_closure_global_byref_list): New defs.
+ * c-common.h (add_closure_global_byref_list,
+ in_closure_global_byref_list): New decls.
+ * c-typeck.c (build_external_ref): global variables
+ declared as 'byref' are enterred in their own list
+ of such declarations per each closure.
+ * c-parser.c (c_parser_postfix_expression): Remove previous fix.
+ (c_parser_closure_byref_declaration): Check for global
+ 'byref' by calling in_closure_global_byref_list.
+
+2008-03-13 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5795493
+ * c-typeck.c: Renamed typesAreClosureCompatible to
+ types_are_closure_compatible.
+
+2008-03-11 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5732232 (Related to change of command option/macro)
+ * c-cppbuiltin.c: __CLOSURES__ macro rename __BLOCKS__
+ * c.opt: -fclosures change to -fblocks.
+
+2008-03-10 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5782740 - part 2 (bug fix).
+ * c-parser.c (synth_copy_helper_closure,
+ synth_destroy_helper_closure): set DECL_ARG_TYPE field of input
+ arguments for the two synthesized helper functions.
+
+2008-02-21 Caroline Tice <ctice at apple.com>
+
+ Radar 5741070
+ * objc/objc-act.c (objc_finish_message_expr): Find
+ the record-type tree from the class interface, and mark the record
+ type as used, for emitting debug info.
+ * cp/cp-objcp-common.c (c_return_interface_record_type): New function.
+ * cp/cp-tree.h (c_return_interface_record_type): New extern function
+ declaration.
+ * c-tree.h (c_return_interface_record_type): Likewise
+ * c-decl.c (c_return_interface_record_type): New function.
+
+2007-08-22 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4947311
+ * c-common.h (objc_declare_protocols, objc_start_protocol): Decl changed.
+ * stub-objc.c (objc_declare_protocols, objc_start_protocol): Changed.
+ * c-parser.c (c_parser_external_declaration): Call to
+ c_parser_objc_protocol_definition takes additional argument.
+ (c_parser_declaration_or_fndef): Protocols with attributes are processed
+ here by passing it to c_parser_objc_protocol_definition.
+ (c_parser_objc_protocol_definition): Takes additional argument and passes
+ it to objc_declare_protocols or objc_start_protocol.
+
+2007-07-13 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5277239
+ * c-parser.c (c_parser_next_token_starts_declspecs): Exclude
+ objc2's property dot-syntax as a declarator.
+ (c_parser_postfix_expression): Convert property dot-syntax on
+ class objects into a property reference expression.
+
+2007-07-10 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5285911
+ * tree.h (CALL_EXPR_OBJC_PROPERTY_GETTER): Macro removed.
+ * c-typeck.c (build_component_ref): Call
+ objc_build_property_reference_expr instead of objc_build_getter_call.
+ (build_modify_expr): Call objc_property_reference_expr instead of
+ objc_property_call.
+ * c-common.h (objc_build_getter_call, objc_property_call): Decl removed.
+ (objc_build_property_reference_expr, objc_property_reference_expr): Decl.
+ added.
+ * stub-objc.c (objc_build_getter_call, objc_property_call): Stub removed.
+ (objc_build_property_reference_expr, objc_property_reference_expr):
+ Stub added.
+
+2007-06-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5276085
+ * c-parser.c (c_parser_binary_expression) : objc_generate_weak_read
+ replaced with call to objc_build_weak_reference_tree
+ * c-typeck.c (build_modify_expr, c_objc_common_truthvalue_conversion):
+ objc_remove_weak_read replaced with call to objc_weak_reference_expr.
+ * c-common.h (objc_weak_reference_expr,
+ objc_build_weak_reference_tree) : New decl.
+ (objc_generate_weak_read, objc_remove_weak_read): remove.
+ * stub-objc.c (objc_weak_reference_expr,
+ objc_build_weak_reference_tree): New stub.
+ (objc_generate_weak_read, objc_remove_weak_read): remove.
+
+2007-05-23 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5195402
+ * c-format.c (handle_format_arg_attribute): Check for NSString *
+ and CFStringRef as valid formatting types.
+ (check_format_string): Ditto.
+ * c-common.h (objc_check_format_nsstring,
+ objc_check_cfstringref_type): New decls.
+ * stub-objc.c (objc_check_nsstring_pointer_type): New stub.
+ * config/darwin-c.c (objc_check_cfstringref_type): New
+ (objc_check_format_cfstring): Call objc_check_cfstringref_type
+ for valid CFStringRef argument type.
+ * config/darwin-protos.h (objc_check_cfstringref_type): New decl.
+ * config/darwin.h (CFSTRING_TYPE_CHECK): New macro.
+
+2007-05-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5202926
+ * c-common.h (objc_anonymous_local_objc_name): New decl.
+ * config/darwin-protos.h (objc_anonymous_local_objc_name): Decl.
+ * stub-objc.c (objc_anonymous_local_objc_name): New stub.
+ * config/darwin.h (ASM_OUTPUT_LABELREF) Call
+ objc_anonymous_local_objc_name.
+
+2007-05-07 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4157812
+ * c-common.h (objc_build_keyword_decl): Takes a new argument.
+ * stub-objc.c (objc_build_keyword_decl): Ditto.
+ * c-parser.c (c_parser_objc_method_decl): Recognize optional
+ method's argument attribute.
+ (c_parser_objc_method_decl): Handle errornous selector.
+
+2007-05-02 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4502186
+ * c-typeck.c (convert_for_assignment): Remove synthesized 'volatile'
+ type before doing type comparison.
+
+2007-03-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4564694
+ * c-parse.c (c_parser_objc_class_instance_variables): Add @package
+ support to syntax.
+ * c-common.h (RID_AT_PACKAGE): Add
+
+2007-03-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4947014 - objc atomic property
+ * c-common.h (RID_NONATOMIC): Add
+ * c-parse.c (c_parser_objc_property_attribute) : Recognize 'nonatomic'
+ as new property.
+
+2007-03-23 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4985544
+ * c-format.c (enum format_type): New entry for NSString format.
+ (format_typ): Has a new entry for NSString format.
+ (decode_format_attr): Error on use of NSString format on a
+ non-objective-c program.
+ (objc_check_nsformat_arg): New.
+ (check_format_info): Call back for NSString is objc_check_nsformat_arg
+ (handle_format_attribute): Use objc_check_format_nsstring for
+ NSString format.
+ * c-common.h (objc_NSString_format): New decl.
+ (objc_check_format_nsstring): New decl.
+ * stub-objc.c (objc_NSString_format, objc_check_format_nsstring): New
+ stubs.
+ * config/darwin-protos.h (darwin_cfstring_type_node): New decl.
+ * config/darwin.c (darwin_cfstring_type_node): New
+ * config/darwin.h (TARGET_CFSTRING_P): New macro
+
+2007-03-23 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4985544
+ * c-format.c (enum format_type): New entry for NSString format.
+ (format_typ): Has a new entry for NSString format.
+ (decode_format_attr): Error on use of NSString format on a
+ non-objective-c program.
+ (objc_check_nsformat_arg): New.
+ (check_format_info): Call back for NSString is objc_check_nsformat_arg
+ (handle_format_attribute): Use objc_check_format_nsstring for
+ NSString format.
+ * c-common.h (objc_NSString_format): New decl.
+ (objc_check_format_nsstring): New decl.
+ * stub-objc.c (objc_NSString_format, objc_check_format_nsstring): New
+ stubs.
+ * config/darwin-protos.h (darwin_cfstring_type_node): New decl.
+ * config/darwin.c (darwin_cfstring_type_node): New
+ * config/darwin.h (TARGET_CFSTRING_P): New macro
+
+2007-03-22 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4965989
+ * c-parser.c (c_parser_objc_class_definition): Add supprt for anonymous
+ category syntax.
+
+2007-03-21 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 2848255
+ * c-parser.c (c_parser_objc_try_catch_statement): Parse @catch(...).
+ * c.opt: Add -fobjc-zerocost-exceptions option.
+ * c-opts.c (c_common_post_options): Set the flags for
+ -fobjc-zerocost-exceptions.
+ * c-common.h: Add some declarations.
+ * stub-objc.c (objc2_valid_objc_catch_type, objc2_build_throw_call):
+ New stubs.
+ * config/darwin.h (OBJC_FLAG_OBJC_ABI): Check for proper
+ use of -fobjc-zerocost-exceptions option.
+
+2006-11-06 Fariborz Jahanian <fjahania at apple.com>
+
+ Radar 4781080 (part 2)
+ * targhooks.c (default_objc_fpreturn_msgcall): Takes 2nd argument.
+ * targhooks.h (default_objc_fpreturn_msgcall): Changed Decl.
+ * target.h (objc_fpreturn_msgcall): Changed Decl.
+ * config/i386/i386.h (OBJC_FPRETURN_MSGCALL): Changed Decl.
+ * config/i386/i386-protos.h (ix86_objc_fpreturn_msgcall): Changed Decl.
+ * config/i386/i386.c (ix86_objc_fpreturn_msgcall): Changed definition.
+2006-09-15 Fariborz Jahanian <fjahania at apple.com>
+
+ Radar 4727659
+ * c-common.c (handle_noreturn_attribute): Handle method_decl
+ nodes as well.
+
+2006-09-01 Fariborz Jahanian <fjahania at apple.com>
+
+ Radar 4712269
+ * c-common.h (objc_build_incr_decr_setter_call): New decl.
+ * stub-objc.c (objc_build_incr_decr_setter_call): New stub.
+ * c-typeck.c (build_unary_op): Call objc_build_incr_decr_setter_call
+ for potential ince/decr pre/post expressions involving properties.
+
+2006-08-31 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4697411
+ * c-common.h (objc_volatilize_component_ref): New decl.
+ * c-typeck.c (build_component_ref): Call objc_volatilize_component_ref.
+ * stub-objc.c (objc_volatilize_component_ref): New stub.
+
+2006-07-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4592503
+ * c-decl.c (finish_struct): Check on illegal use of __weak
+ on struct fields.
+ * decl.c (start_decl): Check on illegal use of __weak on
+ variable declarations.
+ * stub-objc.c (objc_checkon_weak_attribute): New stub.
+ * c-common.h (objc_checkon_weak_attribute): New decl.
+
+2006-06-26 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4591909
+ * c-parse.in: New/modified grammar for new attributes in
+ properties.
+ (yylexname): Change to recognize new attribute terminals.
+ * c-common.h (RID_DYNAMIC): New enum declaration.
+
+2006-07-14 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4621020
+ * c-parse.in: Added 'weak' attribute keyword for @property.
+ * c-common.h: 'weak' related declarations.
+
+2006-05-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4548636 (objc attributes on class)
+ * c-parse.in: Add attribute non-terminal before
+ AT_INTERFACE.
+ * c-common.h (objc_start_class_interface): New argument added.
+ * stub-objc.c (objc_start_class_interface): Ditto.
+
+2006-05-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4547045
+ * c-gimplify.c (obj_reuse_bc_block): Removed.
+ (objc_pop_label, objc_push_label): New.
+ (gimplify_c_loop): Fix up foreach's innerloop break label.
+
+2006-04-26 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 3803157 (method attributes)
+ * c-parse.in: Add grammar support for declaring
+ attribute for objc methods.
+ * c-common.c (handle_deprecated_attribute): Recognize
+ objc methods as valid declarations.
+ (handle_unavailable_attribute): Ditto.
+ * c-common.h: Bunch of new extern declarations.
+ * stub-objc.c (objc_add_method_declaration, objc_start_method_definition):
+ Added new argument.
+ (objc_method_decl): New stub.
+
+2006-04-12 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4507230
+ * c-common.h (objc_type_valid_for_messaging): Declare.
+ * stub-objc.c (objc_type_valid_for_messaging): New stub.
+
+2006-04-06 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4436866
+ (Missing copies attribute)
+ * c-parse.in: Add grammer for 'copies' attribute.
+ * c-common.h (RID_COPIES): New enumerator.
+
+2006-03-27 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4133425
+ * c-common.h (objc_diagnose_private_ivar): New decl.
+ * stub-objc.c (objc_diagnose_private_ivar): New stub.
+ * c-decl.c (undeclared_variable): Issue disnostic on
+ private 'ivar' access.
+
+2006-03-27 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4491608
+ * c-typeck.c (convert_arguments): function name must come from 'selector'
+ when diagnosing 'too many arguments'.
+
+2006-03-23 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4193359
+ * c-typeck.c (convert_for_assignment): Remove Objective-C EH machinery
+ 'volatile' qualifier before doing type comparison.
+
+2006-02-28 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4441049
+ * c-common.h (objc_v2_bitfield_ivar_bitpos): New decl.
+ * expr.h (objc_v2_bitfield_ivar_bitpos): New decl.
+ * stub-objc.c (objc_v2_bitfield_ivar_bitpos): New stub.
+ * expr.c (get_inner_reference): Compute ivar's bitfield bit offset.
+
+2006-02-15 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4445586
+ * c-common.def (DO_STMT): Takes an extra argument.
+
+2006-02-02 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4426814
+ * c-parse.in (cast_expr): generate objc_read_weak call on
+ each __weak object in the expession.
+ * c-typeck.c (build_modify_expr): Undo the call to objc_read_weak
+ on LHS expression.
+ * c-objc-common.c (c_objc_common_truthvalue_conversion): Generate
+ objc_read_weak call before generating tree for !exp, etc.
+ * c-common.h (objc_generate_weak_read, objc_remove_weak_read): New decl.
+ * stub-objc.c (objc_generate_weak_read, objc_remove_weak_read): New stubs.
+
+2005-12-15 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4229905
+ * c-typeck.c (build_conditional_expr): Call objc_have_common_type when
+ looking for objective-c common pointer types.
+ * c-common.h objc_have_common_type): New declaration.
+ * stub-objc.c (objc_have_common_type): New stub.
+
+2005-12-05 Mike Stump <mrs at apple.com>
+
+ Radar 4357979
+ * doc/invoke.texi (C Dialect Options): Improve -fnested-functions wording.
+ * doc/extend.texi (Nested Functions): Note that on darwin nested
+ functions are off by default.
+
+2005-11-08 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4330422
+
+ * c-common.h (objc_non_volatilized_type): New declaration
+ * stub-objc.c (objc_non_volatilized_type): New stub.
+
+2005-10-12 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4291785
+
+ * c-common.h (objc_get_interface_ivars): New declaration
+ (objc_detect_field_duplicates): Ditto.
+ * c-decl.c (finish_struct): Check for duplicate among
+ flattened fields if objective-c.
+ * stub-objc.c (objc_get_interface_ivars): New stub.
+ (objc_detect_field_duplicates): Ditto.
+
+2005-09-28 Devang Patel <dpatel at apple.com>
+
+ Radar 4258406
+ * c-parse.in (nested_function): Report an error, instead of a warning.
+ (nontype_nested_function): Same.
+ * c.opt (Wnested-funcs): Remove.
+ * doc/invoke.texi: Remove Wnested-funcs documentations.
+
+2005-08-03 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4188876
+ * c-typeck.c (pop_init_level): Issue diagnostic on non-constant
+ vector initializers.
+
+2005-06-22 Ziemowit Laski <zlaski at apple.com>
+
+ Radar 4154928
+ * c-common.h (objc_common_type): New prototype.
+ * c-typeck.c (build_conditional_expr): For two ObjC pointer types,
+ use their ObjC common type.
+ * stub-objc.c (objc_common_type): New stub.
+
+/* APPLE LOCAL merge marger */
+/* Stuff under is in fsf mainline, but not in the 4.2 branch */
+
+2007-08-02 Geoffrey Keating <geoffk at apple.com>
+
+ Radar 3274130, 5295549
+ * c-parser.c (c_parser_while_statement): Handle attributes.
+ (c_parser_do_statement): Handle attributes.
+ (c_parser_for_statement): Handle attributes.
+ * c-common.c (handle_unused_attribute): Warn if a statement
+ is marked as unused.
+ * c-tree.h (c_finish_loop): Add extra parameter.
+ * c-typeck.c (c_finish_loop): Handle attributes.
+ * doc/extend.texi (Attribute Syntax): Document statement attributes.
+ (Label Attributes): Explain how they apply to statements.
+ * tree-cfg.c (cleanup_dead_labels): Preserve labels with
+ user-specified alignment or attributes.
+ * stmt.c (expand_label): Update and correct documentation.
+
+ * c-common.c (handle_aligned_attribute): Handle LABEL_DECL.
+ * rtl.def (CODE_LABEL): Add 8th operand.
+ * rtl.h (LABEL_ALIGN_LOG): New.
+ (LABEL_MAX_SKIP): New.
+ (SET_LABEL_ALIGN): New.
+ * emit-rtl.c (gen_label_rtx): Adjust.
+ * print-rtl.c (print_rtx): Print LABEL_ALIGN_LOG.
+ * stmt.c (label_rtx): Set CODE_LABEL's alignment from DECL_ALIGN.
+ (expand_label): Update documentation.
+ * final.c (struct label_alignment): Delete.
+ (label_align): Delete.
+ (min_labelno): Delete.
+ (max_labelno): Delete.
+ (LABEL_TO_ALIGNMENT): Delete.
+ (LABEL_TO_MAX_SKIP): Delete.
+ (label_to_alignment): Adjust for LABEL_ALIGN_LOG.
+ (align_fuzz): Likewise.
+ (compute_alignments): Likewise.
+ (shorten_branches): Remove code to set up label_align.
+ Adjust for LABEL_ALIGN_LOG.
+ (final_scan_insn): Adjust for LABEL_ALIGN_LOG.
+ * doc/extend.texi (C Extensions): Add 'Label Attributes' to menu.
+ (Attribute Syntax): Move label content to Label Attributes.
+ (Function Attributes): Mention label attributes.
+ (Variable Attributes): Mention label attributes.
+ (Type Attributes): Mention label attributes.
+ (Label Attributes): New.
Added: trunk/contrib/gcc/ChangeLog.gcc43
===================================================================
--- trunk/contrib/gcc/ChangeLog.gcc43 (rev 0)
+++ trunk/contrib/gcc/ChangeLog.gcc43 2018-06-04 17:30:21 UTC (rev 10405)
@@ -0,0 +1,824 @@
+2007-08-08 Andrew Haley <aph at redhat.com> (r128087)
+
+ * config/arm/libunwind.S (UNWIND_WRAPPER _Unwind_Backtrace): New.
+ * config/arm/unwind-arm.h (__gnu_Unwind_Backtrace): New.
+ * config/arm/unwind-arm.c (__gnu_Unwind_Backtrace): New.
+
+2007-07-12 Geoffrey Keating <geoffk at apple.com> (r126588)
+
+ * builtins.c (get_pointer_alignment): Honor DECL_ALIGN on a
+ FUNCTION_DECL.
+ * tree.c (build_decl_stat): Move code from here...
+ (make_node_stat): ... to here. Don't uselessly clear DECL_USER_ALIGN.
+ (expr_align): Honor DECL_ALIGN on a FUNCTION_DECL. Add comment
+ about using DECL_ALIGN of LABEL_DECL and CONST_DECL.
+ * tree.h (DECL_USER_ALIGN): Fix misplaced comment.
+ * varasm.c (assemble_start_function): Use DECL_ALIGN instead of
+ FUNCTION_BOUNDARY.
+
+2007-07-09 Geoffrey Keating <geoffk at apple.com> (r126529)
+
+ PR 32617
+ * c-common.c (c_alignof_expr): Look at DECL_ALIGN of
+ FUNCTION_DECLs.
+ (handle_aligned_attribute): Allow use on FUNCTION_DECLs.
+ * varasm.c (assemble_start_function): Honor DECL_ALIGN
+ for FUNCTION_DECLs. Don't use align_functions_log if
+ DECL_USER_ALIGN.
+ * print-tree.c (print_node): Print DECL_ALIGN and DECL_USER_ALIGN
+ even for FUNCTION_DECLs.
+ * c-decl.c (merge_decls): Propagate DECL_ALIGN even for
+ FUNCTION_DECLs.
+ * tree.h (DECL_ALIGN): Update for new location of 'align'.
+ (DECL_FUNCTION_CODE): Update for new location and name of
+ 'function_code'.
+ (DECL_OFFSET_ALIGN): Update for new location of 'off_align'.
+ (struct tree_decl_common): Move 'align' and 'off_align' out
+ of union, ensure they're still on a 32-bit boundary. Remove
+ other fields in union 'u1'.
+ (struct tree_function_decl): Add field 'function_code' replacing
+ 'u1.f' in tree_decl_common.
+ * tree.c (build_decl_stat): Set initial value of DECL_ALIGN.
+ * doc/extend.texi (Function Attributes): Add 'aligned' attribute.
+ (Variable Attributes): Cross-reference 'aligned' attribute
+ to Function Attributes.
+ * flags.h (force_align_functions_log): Delete.
+ * toplev.c (force_align_functions_log): Delete.
+
+2007-07-06 Josh Conner <jconner at apple.com> (r126422)
+
+ PR middle-end/32602
+ PR middle-end/32603
+ * calls.c (store_one_arg): Handle arguments which are partially
+ on the stack when detecting argument overlap.
+
+2007-07-03 Eric Christopher <echristo at apple.com> (r126278)
+
+ * doc/cppopts.texi: Add conflicting option note to -dM.
+ * doc/invoke.texi: Add note about possible conflicts with
+ -E for -dCHARS and note that -dM will not produce
+ any results if there is no machine dependent reorg.
+
+2007-06-28 Geoffrey Keating <geoffk at apple.com> (r126088)
+
+ * doc/invoke.texi (C++ Dialect Options): Document
+ fvisibility-ms-compat.
+ * c.opt (fvisibility-ms-compat): New.
+
+2007-06-23 Richard Earnshaw <rearnsha at arm.com> (r125973)
+
+ PR target/31152
+ * arm.md (negscc): Match the correct operand for optimized LT0 test.
+ Remove optimization for GT.
+
+2007-06-05 Joerg Wunsch <j.gnu at uriah.heep.sax.de> (r125346)
+
+ PR preprocessor/23479
+ * doc/extend.texi: Document the 0b-prefixed binary integer
+ constant extension.
+
+2007-05-31 Eric Christopher <echristo at apple.com> (r125246)
+
+ * expr.c (convert_move): Assert that we don't have a BLKmode
+ operand.
+ (store_expr): Handle BLKmode moves by calling emit_block_move.
+
+2007-05-31 Daniel Berlin <dberlin at dberlin.org> (r125239)
+
+ * c-typeck.c (build_indirect_ref): Include type in error message.
+ (build_binary_op): Pass types to binary_op_error.
+ * c-common.c (binary_op_error): Take two type arguments, print out
+ types with error.
+ * c-common.h (binary_op_error): Update prototype.
+
+2007-05-27 Eric Christopher <echristo at apple.com> (r125116)
+
+ * config/rs6000/rs6000.c (rs6000_emit_prologue): Update
+ sp_offset depending on stack size. Save r12 depending
+ on registers we're saving later.
+ (rs6000_emit_epilogue): Update sp_offset depending only
+ on stack size.
+
+2007-05-24 Richard Sandiford <rsandifo at nildram.co.uk> (r125037)
+
+ * postreload-gcse.c (reg_changed_after_insn_p): New function.
+ (oprs_unchanged_p): Use it to check all registers in a REG.
+ (record_opr_changes): Look for clobbers in CALL_INSN_FUNCTION_USAGE.
+ (reg_set_between_after_reload_p): Delete.
+ (reg_used_between_after_reload_p): Likewise.
+ (reg_set_or_used_since_bb_start): Likewise.
+ (eliminate_partially_redundant_load): Use reg_changed_after_insn_p
+ and reg_used_between_p instead of reg_set_or_used_since_bb_start.
+ Use reg_set_between_p instead of reg_set_between_after_reload_p.
+ * rtlanal.c (reg_set_p): Check whether REG overlaps
+ regs_invalidated_by_call, rather than just checking the
+ membership of REGNO (REG).
+
+2007-05-18 Geoffrey Keating <geoffk at apple.com> (r124839)
+
+ * dwarf2out.c (print_die): Use '%ld' not '%lu' to print a 'long'.
+ (output_die): Use 'unsigned long' with %x.
+ * sched-vis.c (print_value): Use 'unsigned HOST_WIDE_INT' and
+ HOST_WIDE_INT_PRINT_HEX to print HOST_WIDE_INT.
+ * tree-dump.c (dump_pointer): Use 'unsigned long' for %lx.
+
+2007-05-16 Eric Christopher <echristo at apple.com> (r124763)
+
+ * config/rs6000/rs6000.c (rs6000_emit_prologue): Move altivec register
+ saving after stack push. Set sp_offset whenever we push.
+ (rs6000_emit_epilogue): Move altivec register restore before stack push.
+
+2007-05-03 Ian Lance Taylor <iant at google.com> (r124381)
+
+ * config/rs6000/rs6000.c (rs6000_override_options): Don't set
+ MASK_PPC_GFXOPT for 8540 or 8548.
+
+2007-05-01 Dwarakanath Rajagopal <dwarak.rajagopal at amd.com> (r124341)
+
+ * doc/invoke.texi: Fix typo, 'AMD Family 10h core' instead of
+ 'AMD Family 10 core'.
+
+2007-05-01 Dwarakanath Rajagopal <dwarak.rajagopal at amd.com> (r124339)
+
+ * config/i386/i386.c (override_options): Accept k8-sse3, opteron-sse3
+ and athlon64-sse3 as improved versions of k8, opteron and athlon64
+ with SSE3 instruction set support.
+ * doc/invoke.texi: Likewise.
+
+2007-05-01 Dwarakanath Rajagopal <dwarak.rajagopal at amd.com> (r124330)
+
+ * config/i386/i386.c (override_options): Tuning 32-byte loop
+ alignment for amdfam10 architecture. Increasing the max loop
+ alignment to 24 bytes.
+
+2007-04-24 Hui-May Chang <hm.chang at apple.com> (r124115)
+
+ * reload1.c (merge_assigned_reloads) : Do not merge a RELOAD_OTHER
+ instruction with a RELOAD_FOR_OPERAND_ADDRESS instruction.
+
+2007-04-16 Lawrence Crowl <crowl at google.com> (r123909)
+
+ * doc/invoke.texi (Debugging Options): Add documentation for the
+ -femit-struct-debug options -femit-struct-debug-baseonly,
+ -femit-struct-debug-reduced, and
+ -femit-struct-debug-detailed[=...].
+
+ * c-opts.c (c_common_handle_option): Add
+ OPT_femit_struct_debug_baseonly, OPT_femit_struct_debug_reduced,
+ and OPT_femit_struct_debug_detailed_.
+ * c.opt: Add specifications for
+ -femit-struct-debug-baseonly, -femit-struct-debug-reduced,
+ and -femit-struct-debug-detailed[=...].
+ * opts.c (set_struct_debug_option): Parse the
+ -femit-struct-debug-... options.
+ * opts.c (matches_main_base, main_input_basename,
+ main_input_baselength, base_of_path, matches_main_base): Add
+ variables and functions to compare header base name to compilation
+ unit base name.
+ * opts.c (should_emit_struct_debug): Add to determine to emit a
+ structure based on the option.
+ (dump_struct_debug) Also disabled function to debug this
+ function.
+ * opts.c (handle_options): Save the base name of the
+ compilation unit.
+
+ * langhooks-def.h (LANG_HOOKS_GENERIC_TYPE_P): Define.
+ (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add.
+ This hook indicates if a type is generic. Set it by default
+ to "never generic".
+ * langhooks.h (struct lang_hooks_for_types): Add a new hook
+ to determine if a struct type is generic or not.
+ * cp/cp-tree.h (class_tmpl_impl_spec_p): Declare a C++ hook.
+ * cp/tree.c (class_tmpl_impl_spec_p): Implement the C++ hook.
+ * cp/cp-lang.c (LANG_HOOKS_GENERIC_TYPE_P): Override null C hook
+ with live C++ hook.
+
+ * flags.h (enum debug_info_usage): Add an enumeration to describe
+ a program's use of a structure type.
+ * dwarf2out.c (gen_struct_or_union_type_die): Add a new parameter
+ to indicate the program's usage of the type. Filter structs based
+ on the -femit-struct-debug-... specification.
+ (gen_type_die): Split into two routines, gen_type_die and
+ gen_type_die_with_usage. gen_type_die is now a wrapper
+ that assumes direct usage.
+ (gen_type_die_with_usage): Replace calls to gen_type_die
+ with gen_type_die_with_usage adding the program usage of
+ the referenced type.
+ (dwarf2out_imported_module_or_decl): Suppress struct debug
+ information using should_emit_struct_debug when appropriate.
+
+2007-04-16 Ian Lance Taylor <iant at google.com> (r123906)
+
+ * tree-ssa-propagate.c (cfg_blocks_add): Insert blocks with fewer
+ predecessors at head rather than tail.
+
+
+2007-04-12 Richard Guenther <rguenther at suse.de> (r123736)
+
+ PR tree-optimization/24689
+ PR tree-optimization/31307
+ * fold-const.c (operand_equal_p): Compare INTEGER_CST array
+ indices by value.
+ * gimplify.c (canonicalize_addr_expr): To be consistent with
+ gimplify_compound_lval only set operands two and three of
+ ARRAY_REFs if they are not gimple_min_invariant. This makes
+ it never at this place.
+ * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
+
+2007-04-07 H.J. Lu <hongjiu.lu at intel.com> (r123639)
+
+ * config/i386/i386.c (ix86_handle_option): Handle SSSE3.
+
+2007-03-28 Dwarakanath Rajagopal <dwarak.rajagopal at amd.com> (r123313)
+
+ * config.gcc: Accept barcelona as a variant of amdfam10.
+ * config/i386/i386.c (override_options): Likewise.
+ * doc/invoke.texi: Likewise.
+
+2007-03-12 Seongbae Park <seongbae.park at gmail.com> (r122851)
+
+ * c-decl.c (warn_variable_length_array): New function.
+ Refactored from grokdeclarator to handle warn_vla
+ and handle unnamed array case.
+ (grokdeclarator): Refactored VLA warning case.
+ * c.opt (Wvla): New flag.
+
+2007-03-11 Ian Lance Taylor <iant at google.com> (r122831 - partial)
+
+ * tree-vrp.c (vrp_int_const_binop): Handle PLUS_EXPR and
+ the *_DIV_EXPR codes correctly with overflow infinities.
+
+2007-02-09 Dwarakanath Rajagopal <dwarak.rajagopal at amd.com> (r121763)
+
+ * config/i386/driver-i386.c: Turn on -mtune=native for AMDFAM10.
+ (bit_SSE4a): New.
+
+2007-02-08 Harsha Jagasia <harsha.jagasia at amd.com> (r121726)
+
+ * config/i386/xmmintrin.h: Make inclusion of emmintrin.h
+ conditional to __SSE2__.
+ (Entries below should have been added to first ChangeLog
+ entry for amdfam10 dated 2007-02-05)
+ * config/i386/emmintrin.h: Generate #error if __SSE2__ is not
+ defined.
+ * config/i386/pmmintrin.h: Generate #error if __SSE3__ is not
+ defined.
+ * config/i386/tmmintrin.h: Generate #error if __SSSE3__ is not
+ defined.
+
+2007-02-07 Jakub Jelinek <jakub at redhat.com> (r121687)
+
+ * config/i386/i386.c (override_options): Set PTA_SSSE3 for core2.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/athlon.md (athlon_fldxf_k8, athlon_fld_k8,
+ athlon_fstxf_k8, athlon_fst_k8, athlon_fist, athlon_fmov,
+ athlon_fadd_load, athlon_fadd_load_k8, athlon_fadd, athlon_fmul,
+ athlon_fmul_load, athlon_fmul_load_k8, athlon_fsgn,
+ athlon_fdiv_load, athlon_fdiv_load_k8, athlon_fdiv_k8,
+ athlon_fpspc_load, athlon_fpspc, athlon_fcmov_load,
+ athlon_fcmov_load_k8, athlon_fcmov_k8, athlon_fcomi_load_k8,
+ athlon_fcomi, athlon_fcom_load_k8, athlon_fcom): Added amdfam10.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/i386.md (x86_sahf_1, cmpfp_i_mixed, cmpfp_i_sse,
+ cmpfp_i_i387, cmpfp_iu_mixed, cmpfp_iu_sse, cmpfp_iu_387,
+ swapsi, swaphi_1, swapqi_1, swapdi_rex64, fix_truncsfdi_sse,
+ fix_truncdfdi_sse, fix_truncsfsi_sse, fix_truncdfsi_sse,
+ x86_fldcw_1, floatsisf2_mixed, floatsisf2_sse, floatdisf2_mixed,
+ floatdisf2_sse, floatsidf2_mixed, floatsidf2_sse,
+ floatdidf2_mixed, floatdidf2_sse, muldi3_1_rex64, mulsi3_1,
+ mulsi3_1_zext, mulhi3_1, mulqi3_1, umulqihi3_1, mulqihi3_insn,
+ umulditi3_insn, umulsidi3_insn, mulditi3_insn, mulsidi3_insn,
+ umuldi3_highpart_rex64, umulsi3_highpart_insn,
+ umulsi3_highpart_zext, smuldi3_highpart_rex64,
+ smulsi3_highpart_insn, smulsi3_highpart_zext, x86_64_shld,
+ x86_shld_1, x86_64_shrd, sqrtsf2_mixed, sqrtsf2_sse,
+ sqrtsf2_i387, sqrtdf2_mixed, sqrtdf2_sse, sqrtdf2_i387,
+ sqrtextendsfdf2_i387, sqrtxf2, sqrtextendsfxf2_i387,
+ sqrtextenddfxf2_i387): Added amdfam10_decode.
+
+ * config/i386/athlon.md (athlon_idirect_amdfam10,
+ athlon_ivector_amdfam10, athlon_idirect_load_amdfam10,
+ athlon_ivector_load_amdfam10, athlon_idirect_both_amdfam10,
+ athlon_ivector_both_amdfam10, athlon_idirect_store_amdfam10,
+ athlon_ivector_store_amdfam10): New define_insn_reservation.
+ (athlon_idirect_loadmov, athlon_idirect_movstore): Added
+ amdfam10.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/athlon.md (athlon_call_amdfam10,
+ athlon_pop_amdfam10, athlon_lea_amdfam10): New
+ define_insn_reservation.
+ (athlon_branch, athlon_push, athlon_leave_k8, athlon_imul_k8,
+ athlon_imul_k8_DI, athlon_imul_mem_k8, athlon_imul_mem_k8_DI,
+ athlon_idiv, athlon_idiv_mem, athlon_str): Added amdfam10.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/athlon.md (athlon_sseld_amdfam10,
+ athlon_mmxld_amdfam10, athlon_ssest_amdfam10,
+ athlon_mmxssest_short_amdfam10): New define_insn_reservation.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/athlon.md (athlon_sseins_amdfam10): New
+ define_insn_reservation.
+ * config/i386/i386.md (sseins): Added sseins to define_attr type
+ and define_attr unit.
+ * config/i386/sse.md: Set type attribute to sseins for insertq
+ and insertqi.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/athlon.md (sselog_load_amdfam10, sselog_amdfam10,
+ ssecmpvector_load_amdfam10, ssecmpvector_amdfam10,
+ ssecomi_load_amdfam10, ssecomi_amdfam10,
+ sseaddvector_load_amdfam10, sseaddvector_amdfam10): New
+ define_insn_reservation.
+ (ssecmp_load_k8, ssecmp, sseadd_load_k8, seadd): Added amdfam10.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/athlon.md (cvtss2sd_load_amdfam10,
+ cvtss2sd_amdfam10, cvtps2pd_load_amdfam10, cvtps2pd_amdfam10,
+ cvtsi2sd_load_amdfam10, cvtsi2ss_load_amdfam10,
+ cvtsi2sd_amdfam10, cvtsi2ss_amdfam10, cvtsd2ss_load_amdfam10,
+ cvtsd2ss_amdfam10, cvtpd2ps_load_amdfam10, cvtpd2ps_amdfam10,
+ cvtsX2si_load_amdfam10, cvtsX2si_amdfam10): New
+ define_insn_reservation.
+
+ * config/i386/sse.md (cvtsi2ss, cvtsi2ssq, cvtss2si,
+ cvtss2siq, cvttss2si, cvttss2siq, cvtsi2sd, cvtsi2sdq,
+ cvtsd2si, cvtsd2siq, cvttsd2si, cvttsd2siq,
+ cvtpd2dq, cvttpd2dq, cvtsd2ss, cvtss2sd,
+ cvtpd2ps, cvtps2pd): Added amdfam10_decode attribute.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/athlon.md (athlon_ssedivvector_amdfam10,
+ athlon_ssedivvector_load_amdfam10, athlon_ssemulvector_amdfam10,
+ athlon_ssemulvector_load_amdfam10): New define_insn_reservation.
+ (athlon_ssediv, athlon_ssediv_load_k8, athlon_ssemul,
+ athlon_ssemul_load_k8): Added amdfam10.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/i386.h (TARGET_SSE_UNALIGNED_MOVE_OPTIMAL): New macro.
+ (x86_sse_unaligned_move_optimal): New variable.
+
+ * config/i386/i386.c (x86_sse_unaligned_move_optimal): Enable for
+ m_AMDFAM10.
+ (ix86_expand_vector_move_misalign): Add code to generate movupd/movups
+ for unaligned vector SSE double/single precision loads for AMDFAM10.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/i386.h (TARGET_AMDFAM10): New macro.
+ (TARGET_CPU_CPP_BUILTINS): Add code for amdfam10.
+ Define TARGET_CPU_DEFAULT_amdfam10.
+ (TARGET_CPU_DEFAULT_NAMES): Add amdfam10.
+ (processor_type): Add PROCESSOR_AMDFAM10.
+
+ * config/i386/i386.md: Add amdfam10 as a new cpu attribute to match
+ processor_type in config/i386/i386.h.
+ Enable imul peepholes for TARGET_AMDFAM10.
+
+ * config.gcc: Add support for --with-cpu option for amdfam10.
+
+ * config/i386/i386.c (amdfam10_cost): New variable.
+ (m_AMDFAM10): New macro.
+ (m_ATHLON_K8_AMDFAM10): New macro.
+ (x86_use_leave, x86_push_memory, x86_movx, x86_unroll_strlen,
+ x86_cmove, x86_3dnow_a, x86_deep_branch, x86_use_simode_fiop,
+ x86_promote_QImode, x86_integer_DFmode_moves,
+ x86_partial_reg_dependency, x86_memory_mismatch_stall,
+ x86_accumulate_outgoing_args, x86_arch_always_fancy_math_387,
+ x86_sse_partial_reg_dependency, x86_sse_typeless_stores,
+ x86_use_ffreep, x86_use_incdec, x86_four_jump_limit,
+ x86_schedule, x86_use_bt, x86_cmpxchg16b, x86_pad_returns):
+ Enable/disable for amdfam10.
+ (override_options): Add amdfam10_cost to processor_target_table.
+ Set up PROCESSOR_AMDFAM10 for amdfam10 entry in
+ processor_alias_table.
+ (ix86_issue_rate): Add PROCESSOR_AMDFAM10.
+ (ix86_adjust_cost): Add code for amdfam10.
+
+2007-02-05 Harsha Jagasia <harsha.jagasia at amd.com> (r121625)
+
+ * config/i386/i386.opt: Add new Advanced Bit Manipulation (-mabm)
+ instruction set feature flag. Add new (-mpopcnt) flag for popcnt
+ instruction. Add new SSE4A (-msse4a) instruction set feature flag.
+ * config/i386/i386.h: Add builtin definition for SSE4A.
+ * config/i386/i386.md: Add support for ABM instructions
+ (popcnt and lzcnt).
+ * config/i386/sse.md: Add support for SSE4A instructions
+ (movntss, movntsd, extrq, insertq).
+ * config/i386/i386.c: Add support for ABM and SSE4A builtins.
+ Add -march=amdfam10 flag.
+ * config/i386/ammintrin.h: Add support for SSE4A intrinsics.
+ * doc/invoke.texi: Add documentation on flags for sse4a, abm, popcnt
+ and amdfam10.
+ * doc/extend.texi: Add documentation for SSE4A builtins.
+
+2007-01-24 Jakub Jelinek <jakub at redhat.com> (r121140)
+
+ * config/i386/i386.h (x86_cmpxchg16b): Remove const.
+ (TARGET_CMPXCHG16B): Define to x86_cmpxchg16b.
+ * config/i386/i386.c (x86_cmpxchg16b): Remove const.
+ (override_options): Add PTA_CX16 flag. Set x86_cmpxchg16b
+ for CPUs that have PTA_CX16 set.
+
+2007-01-18 Josh Conner <jconner at apple.com> (r120902)
+
+ PR target/30485
+ * config/rs6000/rs6000.c (rs6000_emit_vector_compare): Add
+ support for UNLE, UNLT, UNGE, and UNGT.
+
+2007-01-17 Eric Christopher <echristo at apple.com> (r120846)
+
+ * config.gcc: Support core2 processor.
+
+2007-01-11 Joseph Myers <joseph at codesourcery.com> (r120688)
+
+ * c-common.c (vector_types_convertible_p): Treat opaque types as
+ always convertible if they have the same size, but not otherwise.
+
+2007-01-08 Geoffrey Keating <geoffk at apple.com> (r120611)
+
+ * target.h (struct gcc_target): New field library_rtti_comdat.
+ * target-def.h (TARGET_CXX_LIBRARY_RTTI_COMDAT): New.
+ (TARGET_CXX): Add TARGET_CXX_LIBRARY_RTTI_COMDAT.
+ * doc/tm.texi (C++ ABI): Document TARGET_CXX_LIBRARY_RTTI_COMDAT.
+ * config/darwin.h (TARGET_CXX_LIBRARY_RTTI_COMDAT): Define.
+
+2007-01-08 Mark Shinwell <shinwell at codesourcery.com> (r120572)
+
+ * c.opt: Add -flax-vector-conversions.
+ * c-typeck.c (convert_for_assignment): Pass flag to
+ vector_types_convertible_p to allow emission of note.
+ (digest_init): Likewise.
+ * c-opts.c: Handle -flax-vector-conversions.
+ * c-common.c (flag_lax_vector_conversions): New.
+ (vector_types_convertible_p): Unless -flax-vector conversions
+ has been passed, disallow conversions between vectors with
+ differing numbers of subparts and/or element types. If such
+ a conversion is disallowed, possibly emit a note on the first
+ occasion only to inform the user of -flax-vector-conversions.
+ The new last argument specifies this.
+ * c-common.h (flag_lax_vector_conversions): New.
+ (vector_types_convertible_p): Add extra argument.
+ * config/i386/i386.c (ix86_init_mmx_sse_builtins): Use
+ char_type_node for V*QI type vectors.
+ * config/rs6000/rs6000-c.c (altivec_overloaded_builtins):
+ Update to satisfy new typechecking rules.
+ * config/rs6000/altivec.h (vec_cmple): Use vec_cmpge, for both
+ C and C++ variants.
+ * doc/invoke.texi (C Dialect Options): Document
+ -flax-vector-conversions.
+
+2007-01-05 Manuel Lopez-Ibanez <manu at gcc.gnu.org> (r120505)
+
+ PR c/19978
+ * tree.h (TREE_OVERFLOW_P): New.
+ * c-typeck.c (parser_build_unary_op): Warn only if result
+ overflowed and operands did not.
+ (parser_build_binary_op): Likewise.
+ (convert_for_assignment): Remove redundant overflow_warning.
+ * c-common.c (overflow_warning): Don't check or set TREE_OVERFLOW.
+
+2006-12-13 Ian Lance Taylor <iant at google.com> (r119855)
+
+ PR c++/19564
+ PR c++/19756
+ * c-typeck.c (parser_build_binary_op): Move parentheses warnings
+ to warn_about_parentheses in c-common.c.
+ * c-common.c (warn_about_parentheses): New function.
+ * c-common.h (warn_about_parentheses): Declare.
+ * doc/invoke.texi (Warning Options): Update -Wparentheses
+ description.
+
+2006-12-12 Geoffrey Keating <geoffk at apple.com> (r119820)
+
+ * mips-tdump.c: Replace CROSS_COMPILE with
+ CROSS_DIRECTORY_STRUCTURE.
+ * mips-tfile.c: Likewise.
+ * gcc.c: Likewise.
+ * configure.ac: Likewise.
+ * cppdefault.c: Likewise.
+ * Makefile.in: Likewise.
+ * config/alpha/osf.h: Likewise.
+ * config/i386/cygwin.h: Likewise.
+ * config/i386/beos-elf.h: Likewise.
+ * config/i386/nto.h: Likewise.
+ * config/svr4.h: Likewise.
+ * config/rs6000/aix.h: Likewise.
+ * config/rs6000/sysv4.h: Likewise.
+ * collect2.c: Likewise.
+ * configure: Regenerate.
+
+ * doc/tm.texi (Alignment Output): Document that ASM_OUTPUT_SKIP
+ actually takes an unsigned HOST_WIDE_INT for its second parameter.
+
+2006-12-02 H.J. Lu <hongjiu.lu at intel.com> (r119454 - partial)
+
+ PR target/30040
+ * config/i386/driver-i386.c (bit_SSSE3): New.
+
+2006-11-27 Uros Bizjak <ubizjak at gmail.com> (r119260)
+
+ * config/i386/i386.c (x86_ext_80387_constants): Add m_K8, m_CORE2
+ and m_GENERIC64.
+
+2006-11-18 Vladimir Makarov <vmakarov at redhat.com> (r118973)
+
+ * doc/invoke.texi (core2): Add item.
+
+ * config/i386/i386.h (TARGET_CORE2, TARGET_CPU_DEFAULT_core2): New
+ macros.
+ (TARGET_CPU_CPP_BUILTINS): Add code for core2.
+ (TARGET_CPU_DEFAULT_generic): Change value.
+ (TARGET_CPU_DEFAULT_NAMES): Add core2.
+ (processor_type): Add new constant PROCESSOR_CORE2.
+
+ * config/i386/i386.md (cpu): Add core2.
+
+ * config/i386/i386.c (core2_cost): New initialized variable.
+ (m_CORE2): New macro.
+ (x86_use_leave, x86_push_memory, x86_movx, x86_unroll_strlen,
+ x86_deep_branch, x86_partial_reg_stall, x86_use_simode_fiop,
+ x86_use_cltd, x86_promote_QImode, x86_sub_esp_4, x86_sub_esp_8,
+ x86_add_esp_4, x86_add_esp_8, x86_integer_DFmode_moves,
+ x86_partial_reg_dependency, x86_memory_mismatch_stall,
+ x86_accumulate_outgoing_args, x86_prologue_using_move,
+ x86_epilogue_using_move, x86_arch_always_fancy_math_387,
+ x86_sse_partial_reg_dependency, x86_rep_movl_optimal,
+ x86_use_incdec, x86_four_jump_limit, x86_schedule,
+ x86_pad_returns): Add m_CORE2.
+ (override_options): Add entries for Core2.
+ (ix86_issue_rate): Add case for Core2.
+
+2006-11-14 Caroline Tice <ctice at apple.com> (r118826)
+
+ * dwarf2out.c (debug_pubtypes_section): New static global variable.
+ (pubname_entry): Add DEF_VEC_O and DEF_VEC_ALLOC_O statements for
+ this type.
+ (pubname_table): Redefine as a vector.
+ (pubtype_table): New static global variable, defined as a vector.
+ (pubname_table_allocated): Remove static global variable.
+ (pubname_table_in_use): Remove static global variable.
+ (PUBNAME_TABLE_INCREMENT): Remove constant.
+ (size_of_pubnames): Add parameter to deal with either pubnames or
+ pubtypes, and change code to deal with table being a vector.
+ (add_pubname): Change to deal with table being a vector.
+ (add_pubtype): New function.
+ (output_pubnames): Add parameter to deal with either pubnames or
+ pubtypes, and change code to deal with table being a vector.
+ (gen_array_type_die): Add call to add_pubtype.
+ (gen_enumeration_type_die): Add call to add_pubtype.
+ (gen_struct_or_union_type_die): Add call to add_pubtype.
+ (gen_subroutine_type_die): Add call to add_pubtype.
+ (gen_typedef_die): Add call to add_pubtype.
+ (dwarf2out_init): Add code to initialize pubname_table and
+ pubtype_table vectors; also initialize debug_pubtypes_section.
+ (prune_unused_types): Change to deal with pubnames being a vector.
+ (dwarf2out_finish): Change to deal with pubnames being a vector; add
+ pubnames table to call to output_pubnames; Add code to output pubtypes
+ table if DEBUG_PUBTYPES_SECTION is defined.
+ * config/darwin.c (darwin_file_start): Add DEBUG_PUBTYPES_SECTION to
+ debugnames.
+ * config/darwin.h (DEBUG_PUBTYPES_SECTION): Define new global variable.
+
+2006-11-07 Eric Christopher <echristo at apple.com> (r118576)
+
+ * libgcc2.c (__bswapdi2): Rename from bswapDI2.
+ (__bswapsi2): Ditto.
+ * libgcc2.h: Remove transformation of bswap routines.
+ * config/i386/i386.md (bswapsi2): New.
+ (bswapdi2): Ditto.
+
+2006-11-03 Paul Brook <paul at codesourcery.com> (r118461)
+
+ gcc/
+ * config/arm/arm.c (arm_file_start): New function.
+ (TARGET_ASM_FILE_START): Define.
+ (arm_default_cpu): New variable.
+ (arm_override_options): Set arm_default_cpu.
+
+2006-10-31 Geoffrey Keating <geoffk at apple.com> (r118360)
+
+ * coverage.c (coverage_checksum_string): Update comment.
+ * dwarf2out.c (switch_to_eh_frame_section): Update for removal
+ of get_file_function_name.
+ * cgraphunit.c (cgraph_build_static_cdtor): Update for rename
+ of get_file_function_name_long.
+ * tree.c (get_file_function_name): Rename from
+ get_file_function_name_long; improve comment; handle 'I' and 'D'
+ specially when the target has ctor/dtor support; remove special
+ handling for 'F'.
+ (get_file_function_name): Remove.
+ * tree.h (get_file_function_name): Rename from
+ get_file_function_name_long.
+ (get_file_function_name): Remove prototype.
+
+2006-10-31 Geoffrey Keating <geoffk at apple.com> (r118356)
+
+ * c-decl.c (grokdeclarator): Don't set DECL_EXTERNAL on
+ inline static functions in c99 mode.
+
+ PR 16622
+ * doc/extend.texi (Inline): Update.
+ * c-tree.h (struct language_function): Remove field 'extern_inline'.
+ * c-decl.c (current_extern_inline): Delete.
+ (pop_scope): Adjust test for an undefined nested function.
+ Add warning about undeclared inline function.
+ (diagnose_mismatched_decls): Update comments. Disallow overriding
+ of inline functions in a translation unit in C99. Allow inline
+ declarations in C99 at any time.
+ (merge_decls): Boolize variables. Handle C99 'extern inline'
+ semantics.
+ (grokdeclarator): Set DECL_EXTERNAL here for functions. Handle
+ C99 inline semantics.
+ (start_function): Don't clear current_extern_inline. Don't set
+ DECL_EXTERNAL.
+ (c_push_function_context): Don't push current_extern_inline.
+ (c_pop_function_context): Don't restore current_extern_inline.
+
+ PR 11377
+ * c-typeck.c (build_external_ref): Warn about static variables
+ used in extern inline functions.
+ * c-decl.c (start_decl): Warn about static variables declared
+ in extern inline functions.
+
+2006-10-27 Vladimir Makarov <vmakarov at redhat.com> (r118090)
+
+ * config/i386/i386.h (TARGET_GEODE):
+ (TARGET_CPU_CPP_BUILTINS): Add code for geode.
+ (TARGET_CPU_DEFAULT_geode): New macro.
+ (TARGET_CPU_DEFAULT_k6, TARGET_CPU_DEFAULT_k6_2,
+ TARGET_CPU_DEFAULT_k6_3, TARGET_CPU_DEFAULT_athlon,
+ TARGET_CPU_DEFAULT_athlon_sse, TARGET_CPU_DEFAULT_k8,
+ TARGET_CPU_DEFAULT_pentium_m, TARGET_CPU_DEFAULT_prescott,
+ TARGET_CPU_DEFAULT_nocona, TARGET_CPU_DEFAULT_generic): Increase
+ the macro values.
+ (TARGET_CPU_DEFAULT_NAMES): Add geode.
+ (processor_type): Add PROCESSOR_GEODE.
+
+ * config/i386/i386.md: Include geode.md.
+ (cpu): Add geode.
+
+ * config/i386/i386.c (geode_cost): New initialized global
+ variable.
+ (m_GEODE, m_K6_GEODE): New macros.
+ (x86_use_leave, x86_push_memory, x86_deep_branch, x86_use_sahf,
+ x86_use_himode_fiop, x86_promote_QImode, x86_add_esp_4,
+ x86_add_esp_8, x86_rep_movl_optimal, x86_ext_80387_constants,
+ x86_schedule): Use m_K6_GEODE instead of m_K6.
+ (x86_movx, x86_cmove): Set up m_GEODE.
+ (x86_integer_DFmode_moves): Clear m_GEODE.
+ (processor_target_table): Add entry for geode.
+ (processor_alias_table): Ditto.
+
+ * config/i386/geode.md: New file.
+
+ * doc/invoke.texi: Add entry about geode processor.
+
+2006-10-24 Richard Guenther <rguenther at suse.de> (r118001)
+
+ PR middle-end/28796
+ * builtins.c (fold_builtin_classify): Use HONOR_INFINITIES
+ and HONOR_NANS instead of MODE_HAS_INFINITIES and MODE_HAS_NANS
+ for deciding optimizations in consistency with fold-const.c
+ (fold_builtin_unordered_cmp): Likewise.
+
+2006-10-22 H.J. Lu <hongjiu.lu at intel.com> (r117958)
+
+ * config.gcc (i[34567]86-*-*): Add tmmintrin.h to extra_headers.
+ (x86_64-*-*): Likewise.
+
+ * config/i386/i386.c (pta_flags): Add PTA_SSSE3.
+ (override_options): Check SSSE3.
+ (ix86_builtins): Add IX86_BUILTIN_PHADDW, IX86_BUILTIN_PHADDD,
+ IX86_BUILTIN_PHADDSW, IX86_BUILTIN_PHSUBW, IX86_BUILTIN_PHSUBD,
+ IX86_BUILTIN_PHSUBSW, IX86_BUILTIN_PMADDUBSW,
+ IX86_BUILTIN_PMULHRSW, IX86_BUILTIN_PSHUFB,
+ IX86_BUILTIN_PSIGNB, IX86_BUILTIN_PSIGNW, IX86_BUILTIN_PSIGND,
+ IX86_BUILTIN_PALIGNR, IX86_BUILTIN_PABSB, IX86_BUILTIN_PABSW,
+ IX86_BUILTIN_PABSD, IX86_BUILTIN_PHADDW128,
+ IX86_BUILTIN_PHADDD128, IX86_BUILTIN_PHADDSW128,
+ IX86_BUILTIN_PHSUBW128, IX86_BUILTIN_PHSUBD128,
+ IX86_BUILTIN_PHSUBSW128, IX86_BUILTIN_PMADDUBSW128,
+ IX86_BUILTIN_PMULHRSW128, IX86_BUILTIN_PSHUFB128,
+ IX86_BUILTIN_PSIGNB128, IX86_BUILTIN_PSIGNW128,
+ IX86_BUILTIN_PSIGND128, IX86_BUILTIN_PALIGNR128,
+ IX86_BUILTIN_PABSB128, IX86_BUILTIN_PABSW128 and
+ IX86_BUILTIN_PABSD128.
+ (bdesc_2arg): Add SSSE3.
+ (bdesc_1arg): Likewise.
+ (ix86_init_mmx_sse_builtins): Support SSSE3.
+ (ix86_expand_builtin): Likewise.
+ * config/i386/i386.h (TARGET_CPU_CPP_BUILTINS): Likewise.
+
+ * config/i386/i386.md (UNSPEC_PSHUFB): New.
+ (UNSPEC_PSIGN): Likewise.
+ (UNSPEC_PALIGNR): Likewise.
+ Include mmx.md before sse.md.
+
+ * config/i386/i386.opt: Add -mssse3.
+
+ * config/i386/sse.md (ssse3_phaddwv8hi3): New pattern for SSSE3.
+ (ssse3_phaddwv4hi3): Likewise.
+ (ssse3_phadddv4si3): Likewise.
+ (ssse3_phadddv2si3): Likewise.
+ (ssse3_phaddswv8hi3): Likewise.
+ (ssse3_phaddswv4hi3): Likewise.
+ (ssse3_phsubwv8hi3): Likewise.
+ (ssse3_phsubwv4hi3): Likewise.
+ (ssse3_phsubdv4si3): Likewise.
+ (ssse3_phsubdv2si3): Likewise.
+ (ssse3_phsubswv8hi3): Likewise.
+ (ssse3_phsubswv4hi3): Likewise.
+ (ssse3_pmaddubswv8hi3): Likewise.
+ (ssse3_pmaddubswv4hi3): Likewise.
+ (ssse3_pmulhrswv8hi3): Likewise.
+ (ssse3_pmulhrswv4hi3): Likewise.
+ (ssse3_pshufbv16qi3): Likewise.
+ (ssse3_pshufbv8qi3): Likewise.
+ (ssse3_psign<mode>3): Likewise.
+ (ssse3_psign<mode>3): Likewise.
+ (ssse3_palignrti): Likewise.
+ (ssse3_palignrdi): Likewise.
+ (abs<mode>2): Likewise.
+ (abs<mode>2): Likewise.
+
+ * config/i386/tmmintrin.h: New file.
+
+ * doc/extend.texi: Document SSSE3 built-in functions.
+
+ * doc/invoke.texi: Document -mssse3/-mno-ssse3 switches.
+
+2006-10-22 H.J. Lu <hongjiu.lu at intel.com> (r117959)
+
+ * config/i386/tmmintrin.h: Remove the duplicated content.
+
+2006-10-21 Richard Guenther <rguenther at suse.de> (r117932)
+
+ PR tree-optimization/3511
+ * tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that
+ got new invariant arguments during PHI translation.
+
+2006-10-21 Richard Guenther <rguenther at suse.de> (r117929)
+
+ * builtins.c (fold_builtin_classify): Fix typo.
+
+2006-09-07 Eric Christopher <echristo at apple.com> (r118361)
+ Falk Hueffner <falk at debian.org>
+
+ * doc/extend.texi (__builtin_bswap32): Document.
+ (__builtin_bswap64): Ditto.
+ * doc/libgcc.texi (bswapsi2): Document.
+ (bswapdi2): Ditto.
+ * doc/rtl.texi (bswap): Document.
+ * optabs.c (expand_unop): Don't widen a bswap.
+ (init_optabs): Init bswap. Set libfuncs explicitly
+ for bswapsi2 and bswapdi2.
+ * optabs.h (OTI_bswap): New.
+ (bswap_optab): Ditto.
+ * genopinit.c (optabs): Handle bswap_optab.
+ * tree.h (tree_index): Add TI_UINT32_TYPE and
+ TI_UINT64_TYPE.
+ (uint32_type_node): New.
+ (uint64_type_node): Ditto.
+ * tree.c (build_common_tree_nodes_2): Initialize
+ uint32_type_node and uint64_type_node.
+ * builtins.c (expand_builtin_bswap): New.
+ (expand_builtin): Call.
+ (fold_builtin_bswap): New.
+ (fold_builtin_1): Call.
+ * fold-const.c (tree_expr_nonnegative_p): Return true
+ for bswap.
+ * builtin-types.def (BT_UINT32): New.
+ (BT_UINT64): Ditto.
+ (BT_FN_UINT32_UINT32): Ditto.
+ (BT_FN_UINT64_UINT64): Ditto.
+ * builtins.def (BUILT_IN_BSWAP32): New.
+ (BUILT_IN_BSWAP64): Ditto.
+ * rtl.def (BSWAP): New.
+ * genattrtab.c (check_attr_value): New.
+ * libgcc2.c (__bswapSI2): New.
+ (__bswapDI2): Ditto.
+ * libgcc2.h (__bswapSI2): Declare.
+ (__bswapDI2): Ditto.
+ * mklibgcc.in (lib2funcs): Add _bswapsi2 and _bswapdi2.
+ * simplify-rtx.c (simplify_const_unary_operation): Return
+ 0 for BSWAP.
+ * libgcc-std.ver (__bwapsi2): Add.
+ (__bswapdi2): Ditto.
+ * reload1.c (eliminate_regs_1): Add bswap.
+ (elimination_effects): Ditto.
+ * config/i386/i386.h (x86_bswap): New.
+ (TARGET_BSWAP): Use.
+ * config/i386/i386.c (x86_bswap): Set.
Modified: trunk/contrib/gcc/Makefile.in
===================================================================
--- trunk/contrib/gcc4/Makefile.in 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/Makefile.in 2018-06-04 17:30:21 UTC (rev 10405)
@@ -238,7 +238,7 @@
FLEX = @FLEX@
FLEXFLAGS =
AR = @AR@
-AR_FLAGS = rc
+ARFLAGS = @ARFLAGS@
NM = @NM@
RANLIB = @RANLIB@
RANLIB_FLAGS = @ranlib_flags@
@@ -822,7 +822,8 @@
# IN_GCC distinguishes between code compiled into GCC itself and other
# programs built during a bootstrap.
-# autoconf inserts -DCROSS_COMPILE if we are building a cross compiler.
+# autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a
+# cross compiler which does not use the native headers and libraries.
INTERNAL_CFLAGS = -DIN_GCC @CROSS@
# This is the variable actually used when we compile. If you change this,
@@ -1303,7 +1304,7 @@
# This archive is strictly for the host.
libbackend.a: $(OBJS at onestep@)
-rm -rf libbackend.a
- $(AR) $(AR_FLAGS) libbackend.a $(OBJS at onestep@)
+ $(AR) $(ARFLAGS) libbackend.a $(OBJS at onestep@)
-$(RANLIB) $(RANLIB_FLAGS) libbackend.a
# We call this executable `xgcc' rather than `gcc'
Modified: trunk/contrib/gcc/attribs.c
===================================================================
--- trunk/contrib/gcc4/attribs.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/attribs.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -216,7 +216,8 @@
if (spec->function_type_required && TREE_CODE (*anode) != FUNCTION_TYPE
&& TREE_CODE (*anode) != METHOD_TYPE)
{
- if (TREE_CODE (*anode) == POINTER_TYPE
+ /* APPLE LOCAL radar 6246527 */
+ if ((TREE_CODE (*anode) == POINTER_TYPE || TREE_CODE (*anode) == BLOCK_POINTER_TYPE)
&& (TREE_CODE (TREE_TYPE (*anode)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (*anode)) == METHOD_TYPE))
{
@@ -323,6 +324,14 @@
if (fn_ptr_tmp)
{
+ /* APPLE LOCAL begin radar 6246527 */
+ if (DECL_P (*node) && TREE_TYPE (*node) &&
+ TREE_CODE (TREE_TYPE (*node)) == BLOCK_POINTER_TYPE)
+ /* Rebuild the block pointer type and put it in the
+ appropriate place. */
+ fn_ptr_tmp = build_block_pointer_type (fn_ptr_tmp);
+ else
+ /* APPLE LOCAL end radar 6246527 */
/* Rebuild the function pointer type and put it in the
appropriate place. */
fn_ptr_tmp = build_pointer_type (fn_ptr_tmp);
Modified: trunk/contrib/gcc/builtin-types.def
===================================================================
--- trunk/contrib/gcc4/builtin-types.def 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/builtin-types.def 2018-06-04 17:30:21 UTC (rev 10405)
@@ -75,6 +75,8 @@
DEF_PRIMITIVE_TYPE (BT_ULONGLONG, long_long_unsigned_type_node)
DEF_PRIMITIVE_TYPE (BT_INTMAX, intmax_type_node)
DEF_PRIMITIVE_TYPE (BT_UINTMAX, uintmax_type_node)
+DEF_PRIMITIVE_TYPE (BT_UINT32, uint32_type_node)
+DEF_PRIMITIVE_TYPE (BT_UINT64, uint64_type_node)
DEF_PRIMITIVE_TYPE (BT_WORD, (*lang_hooks.types.type_for_mode) (word_mode, 0))
DEF_PRIMITIVE_TYPE (BT_FLOAT, float_type_node)
DEF_PRIMITIVE_TYPE (BT_DOUBLE, double_type_node)
@@ -204,6 +206,10 @@
DEF_FUNCTION_TYPE_1 (BT_FN_VOID_VPTR, BT_VOID, BT_VOLATILE_PTR)
DEF_FUNCTION_TYPE_1 (BT_FN_VOID_PTRPTR, BT_VOID, BT_PTR_PTR)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT_UINT, BT_UINT, BT_UINT)
+DEF_FUNCTION_TYPE_1 (BT_FN_ULONG_ULONG, BT_ULONG, BT_ULONG)
+DEF_FUNCTION_TYPE_1 (BT_FN_ULONGLONG_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG)
+DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT32, BT_UINT32, BT_UINT32)
+DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_UINT64, BT_UINT64, BT_UINT64)
DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR, BT_FN_VOID_PTR)
@@ -435,4 +441,3 @@
DEF_POINTER_TYPE (BT_PTR_FN_VOID_VAR, BT_FN_VOID_VAR)
DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE,
BT_PTR, BT_PTR_FN_VOID_VAR, BT_PTR, BT_SIZE)
-
Modified: trunk/contrib/gcc/builtins.c
===================================================================
--- trunk/contrib/gcc4/builtins.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/builtins.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -315,9 +315,7 @@
else if (offset)
inner = MIN (inner, BITS_PER_UNIT);
}
- if (TREE_CODE (exp) == FUNCTION_DECL)
- align = FUNCTION_BOUNDARY;
- else if (DECL_P (exp))
+ if (DECL_P (exp))
align = MIN (inner, DECL_ALIGN (exp));
#ifdef CONSTANT_ALIGNMENT
else if (CONSTANT_CLASS_P (exp))
@@ -4589,6 +4587,30 @@
return result;
}
+/* Expand a call to a bswap builtin. The arguments are in ARGLIST. MODE
+ is the mode to expand with. */
+
+static rtx
+expand_builtin_bswap (tree arglist, rtx target, rtx subtarget)
+{
+ enum machine_mode mode;
+ tree arg;
+ rtx op0;
+
+ if (!validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE))
+ return 0;
+
+ arg = TREE_VALUE (arglist);
+ mode = TYPE_MODE (TREE_TYPE (arg));
+ op0 = expand_expr (arg, subtarget, VOIDmode, 0);
+
+ target = expand_unop (mode, bswap_optab, op0, target, 1);
+
+ gcc_assert (target);
+
+ return convert_to_mode (mode, target, 0);
+}
+
/* Expand a call to a unary builtin. The arguments are in ARGLIST.
Return 0 if a normal call should be emitted rather than expanding the
function in-line. If convenient, the result should be placed in TARGET.
@@ -5877,6 +5899,14 @@
expand_stack_restore (TREE_VALUE (arglist));
return const0_rtx;
+ case BUILT_IN_BSWAP32:
+ case BUILT_IN_BSWAP64:
+ target = expand_builtin_bswap (arglist, target, subtarget);
+
+ if (target)
+ return target;
+ break;
+
CASE_INT_FN (BUILT_IN_FFS):
case BUILT_IN_FFSIMAX:
target = expand_builtin_unop (target_mode, arglist, target,
@@ -7539,6 +7569,67 @@
return NULL_TREE;
}
+/* Fold function call to builtin_bswap and the long and long long
+ variants. Return NULL_TREE if no simplification can be made. */
+static tree
+fold_builtin_bswap (tree fndecl, tree arglist)
+{
+ tree arg;
+
+ if (! validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE))
+ return 0;
+
+ /* Optimize constant value. */
+ arg = TREE_VALUE (arglist);
+ if (TREE_CODE (arg) == INTEGER_CST && ! TREE_CONSTANT_OVERFLOW (arg))
+ {
+ HOST_WIDE_INT hi, width, r_hi = 0;
+ unsigned HOST_WIDE_INT lo, r_lo = 0;
+ tree type;
+
+ type = TREE_TYPE (arg);
+ width = TYPE_PRECISION (type);
+ lo = TREE_INT_CST_LOW (arg);
+ hi = TREE_INT_CST_HIGH (arg);
+
+ switch (DECL_FUNCTION_CODE (fndecl))
+ {
+ case BUILT_IN_BSWAP32:
+ case BUILT_IN_BSWAP64:
+ {
+ int s;
+
+ for (s = 0; s < width; s += 8)
+ {
+ int d = width - s - 8;
+ unsigned HOST_WIDE_INT byte;
+
+ if (s < HOST_BITS_PER_WIDE_INT)
+ byte = (lo >> s) & 0xff;
+ else
+ byte = (hi >> (s - HOST_BITS_PER_WIDE_INT)) & 0xff;
+
+ if (d < HOST_BITS_PER_WIDE_INT)
+ r_lo |= byte << d;
+ else
+ r_hi |= byte << (d - HOST_BITS_PER_WIDE_INT);
+ }
+ }
+
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
+
+ if (width < HOST_BITS_PER_WIDE_INT)
+ return build_int_cst (TREE_TYPE (TREE_TYPE (fndecl)), r_lo);
+ else
+ return build_int_cst_wide (TREE_TYPE (TREE_TYPE (fndecl)), r_lo, r_hi);
+ }
+
+ return NULL_TREE;
+}
/* Return true if EXPR is the real constant contained in VALUE. */
static bool
@@ -9053,6 +9144,10 @@
CASE_FLT_FN (BUILT_IN_LLRINT):
return fold_fixed_mathfn (fndecl, arglist);
+ case BUILT_IN_BSWAP32:
+ case BUILT_IN_BSWAP64:
+ return fold_builtin_bswap (fndecl, arglist);
+
CASE_INT_FN (BUILT_IN_FFS):
CASE_INT_FN (BUILT_IN_CLZ):
CASE_INT_FN (BUILT_IN_CTZ):
Modified: trunk/contrib/gcc/builtins.def
===================================================================
--- trunk/contrib/gcc4/builtins.def 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/builtins.def 2018-06-04 17:30:21 UTC (rev 10405)
@@ -594,6 +594,8 @@
DEF_GCC_BUILTIN (BUILT_IN_APPLY, "apply", BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_APPLY_ARGS, "apply_args", BT_FN_PTR_VAR, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_ARGS_INFO, "args_info", BT_FN_INT_INT, ATTR_NULL)
+DEF_GCC_BUILTIN (BUILT_IN_BSWAP32, "bswap32", BT_FN_UINT32_UINT32, ATTR_CONST_NOTHROW_LIST)
+DEF_GCC_BUILTIN (BUILT_IN_BSWAP64, "bswap64", BT_FN_UINT64_UINT64, ATTR_CONST_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_CALLOC, "calloc", BT_FN_PTR_SIZE_SIZE, ATTR_MALLOC_NOTHROW_LIST)
DEF_GCC_BUILTIN (BUILT_IN_CLASSIFY_TYPE, "classify_type", BT_FN_INT_VAR, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_CLZ, "clz", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST)
Modified: trunk/contrib/gcc/c-common.c
===================================================================
--- trunk/contrib/gcc4/c-common.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-common.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -254,6 +254,10 @@
int flag_short_wchar;
+/* Nonzero means allow implicit conversions between vectors with
+ differing numbers of subparts and/or differing element types. */
+int flag_lax_vector_conversions;
+
/* Nonzero means allow Microsoft extensions without warnings or errors. */
int flag_ms_extensions;
@@ -537,6 +541,9 @@
static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
static tree handle_deprecated_attribute (tree *, tree, tree, int,
bool *);
+/* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) --ilr */
+static tree handle_unavailable_attribute (tree *, tree, tree, int, bool *);
+/* APPLE LOCAL end "unavailable" attribute --ilr */
static tree handle_vector_size_attribute (tree *, tree, tree, int,
bool *);
static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
@@ -545,6 +552,8 @@
static tree handle_warn_unused_result_attribute (tree *, tree, tree, int,
bool *);
static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
+/* APPLE LOCAL radar 5932809 - copyable byref blocks */
+static tree handle_blocks_attribute (tree *, tree, tree, int, bool *);
static void check_function_nonnull (tree, tree);
static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
@@ -600,7 +609,8 @@
handle_section_attribute },
{ "aligned", 0, 1, false, false, false,
handle_aligned_attribute },
- { "weak", 0, 0, true, false, false,
+ /* APPLE LOCAL weak types 5954418 */
+ { "weak", 0, 0, false, false, false,
handle_weak_attribute },
{ "alias", 1, 1, true, false, false,
handle_alias_attribute },
@@ -622,6 +632,10 @@
handle_novops_attribute },
{ "deprecated", 0, 0, false, false, false,
handle_deprecated_attribute },
+ /* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) --ilr */
+ { "unavailable", 0, 0, false, false, false,
+ handle_unavailable_attribute },
+ /* APPLE LOCAL end "unavailable" attribute --ilr */
{ "vector_size", 1, 1, false, true, false,
handle_vector_size_attribute },
{ "visibility", 1, 1, false, false, false,
@@ -639,6 +653,8 @@
handle_warn_unused_result_attribute },
{ "sentinel", 0, 1, false, true, true,
handle_sentinel_attribute },
+ /* APPLE LOCAL radar 5932809 - copyable byref blocks */
+ { "blocks", 1, 1, true, false, false, handle_blocks_attribute },
{ NULL, 0, 0, false, false, false, NULL }
};
@@ -916,40 +932,46 @@
pedwarn ("overflow in constant expression");
}
-/* Print a warning if an expression had overflow in folding.
+/* Print a warning if an expression had overflow in folding and its
+ operands hadn't.
+
Invoke this function on every expression that
(1) appears in the source code, and
- (2) might be a constant expression that overflowed, and
+ (2) is a constant expression that overflowed, and
(3) is not already checked by convert_and_check;
- however, do not invoke this function on operands of explicit casts. */
+ however, do not invoke this function on operands of explicit casts
+ or when the expression is the result of an operator and any operand
+ already overflowed. */
void
overflow_warning (tree value)
{
- if ((TREE_CODE (value) == INTEGER_CST
- || (TREE_CODE (value) == COMPLEX_CST
- && TREE_CODE (TREE_REALPART (value)) == INTEGER_CST))
- && TREE_OVERFLOW (value))
+ if (skip_evaluation) return;
+
+ switch (TREE_CODE (value))
{
- TREE_OVERFLOW (value) = 0;
- if (skip_evaluation == 0)
- warning (OPT_Woverflow, "integer overflow in expression");
+ case INTEGER_CST:
+ warning (OPT_Woverflow, "integer overflow in expression");
+ break;
+
+ case REAL_CST:
+ warning (OPT_Woverflow, "floating point overflow in expression");
+ break;
+
+ case VECTOR_CST:
+ warning (OPT_Woverflow, "vector overflow in expression");
+ break;
+
+ case COMPLEX_CST:
+ if (TREE_CODE (TREE_REALPART (value)) == INTEGER_CST)
+ warning (OPT_Woverflow, "complex integer overflow in expression");
+ else if (TREE_CODE (TREE_REALPART (value)) == REAL_CST)
+ warning (OPT_Woverflow, "complex floating point overflow in expression");
+ break;
+
+ default:
+ break;
}
- else if ((TREE_CODE (value) == REAL_CST
- || (TREE_CODE (value) == COMPLEX_CST
- && TREE_CODE (TREE_REALPART (value)) == REAL_CST))
- && TREE_OVERFLOW (value))
- {
- TREE_OVERFLOW (value) = 0;
- if (skip_evaluation == 0)
- warning (OPT_Woverflow, "floating point overflow in expression");
- }
- else if (TREE_CODE (value) == VECTOR_CST && TREE_OVERFLOW (value))
- {
- TREE_OVERFLOW (value) = 0;
- if (skip_evaluation == 0)
- warning (OPT_Woverflow, "vector overflow in expression");
- }
}
/* Print a warning if a large constant is truncated to unsigned,
@@ -983,35 +1005,67 @@
strict aliasing mode is in effect. OTYPE is the original
TREE_TYPE of EXPR, and TYPE the type we're casting to. */
-void
+bool
strict_aliasing_warning (tree otype, tree type, tree expr)
{
- if (flag_strict_aliasing && warn_strict_aliasing
- && POINTER_TYPE_P (type) && POINTER_TYPE_P (otype)
- && TREE_CODE (expr) == ADDR_EXPR
+ if (!(flag_strict_aliasing && POINTER_TYPE_P (type)
+ && POINTER_TYPE_P (otype) && !VOID_TYPE_P (TREE_TYPE (type))))
+ return false;
+
+ if ((warn_strict_aliasing > 1) && TREE_CODE (expr) == ADDR_EXPR
&& (DECL_P (TREE_OPERAND (expr, 0))
- || handled_component_p (TREE_OPERAND (expr, 0)))
- && !VOID_TYPE_P (TREE_TYPE (type)))
+ || handled_component_p (TREE_OPERAND (expr, 0))))
{
/* Casting the address of an object to non void pointer. Warn
if the cast breaks type based aliasing. */
- if (!COMPLETE_TYPE_P (TREE_TYPE (type)))
- warning (OPT_Wstrict_aliasing, "type-punning to incomplete type "
- "might break strict-aliasing rules");
+ if (!COMPLETE_TYPE_P (TREE_TYPE (type)) && warn_strict_aliasing == 2)
+ {
+ warning (OPT_Wstrict_aliasing, "type-punning to incomplete type "
+ "might break strict-aliasing rules");
+ return true;
+ }
else
{
- HOST_WIDE_INT set1 = get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0)));
+ /* warn_strict_aliasing >= 3. This includes the default (3).
+ Only warn if the cast is dereferenced immediately. */
+ HOST_WIDE_INT set1 =
+ get_alias_set (TREE_TYPE (TREE_OPERAND (expr, 0)));
HOST_WIDE_INT set2 = get_alias_set (TREE_TYPE (type));
if (!alias_sets_conflict_p (set1, set2))
+ {
+ warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
+ "pointer will break strict-aliasing rules");
+ return true;
+ }
+ else if (warn_strict_aliasing == 2
+ && !alias_sets_might_conflict_p (set1, set2))
+ {
+ warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
+ "pointer might break strict-aliasing rules");
+ return true;
+ }
+ }
+ }
+ else
+ if ((warn_strict_aliasing == 1) && !VOID_TYPE_P (TREE_TYPE (otype)))
+ {
+ /* At this level, warn for any conversions, even if an address is
+ not taken in the same statement. This will likely produce many
+ false positives, but could be useful to pinpoint problems that
+ are not revealed at higher levels. */
+ HOST_WIDE_INT set1 = get_alias_set (TREE_TYPE (otype));
+ HOST_WIDE_INT set2 = get_alias_set (TREE_TYPE (type));
+ if (!COMPLETE_TYPE_P(type)
+ || !alias_sets_might_conflict_p (set1, set2))
+ {
warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
- "pointer will break strict-aliasing rules");
- else if (warn_strict_aliasing > 1
- && !alias_sets_might_conflict_p (set1, set2))
- warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
"pointer might break strict-aliasing rules");
- }
- }
+ return true;
+ }
+ }
+
+ return false;
}
@@ -1057,18 +1111,45 @@
return !TREE_OVERFLOW (c);
}
-/* Nonzero if vector types T1 and T2 can be converted to each other
- without an explicit cast. */
-int
-vector_types_convertible_p (tree t1, tree t2)
+
+/* True if vector types T1 and T2 can be converted to each other
+ without an explicit cast. If EMIT_LAX_NOTE is true, and T1 and T2
+ can only be converted with -flax-vector-conversions yet that is not
+ in effect, emit a note telling the user about that option if such
+ a note has not previously been emitted. */
+bool
+vector_types_convertible_p (tree t1, tree t2, bool emit_lax_note)
{
- return targetm.vector_opaque_p (t1)
- || targetm.vector_opaque_p (t2)
- || (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))
- && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE ||
- TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
- && INTEGRAL_TYPE_P (TREE_TYPE (t1))
- == INTEGRAL_TYPE_P (TREE_TYPE (t2)));
+ static bool emitted_lax_note = false;
+ bool convertible_lax;
+
+ if ((targetm.vector_opaque_p (t1) || targetm.vector_opaque_p (t2))
+ && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
+ return true;
+
+ convertible_lax =
+ (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))
+ && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE ||
+ TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
+ && (INTEGRAL_TYPE_P (TREE_TYPE (t1))
+ == INTEGRAL_TYPE_P (TREE_TYPE (t2))));
+
+ if (!convertible_lax || flag_lax_vector_conversions)
+ return convertible_lax;
+
+ if (TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2)
+ && comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
+ return true;
+
+ if (emit_lax_note && !emitted_lax_note)
+ {
+ emitted_lax_note = true;
+ inform ("use -flax-vector-conversions to permit "
+ "conversions between vectors with differing "
+ "element types or numbers of subparts");
+ }
+
+ return false;
}
/* Convert EXPR to TYPE, warning about conversion problems with constants.
@@ -1950,10 +2031,10 @@
}
/* Print an error message for invalid operands to arith operation
- CODE. */
+ CODE with TYPE0 for operand 0, and TYPE1 for operand 1. */
void
-binary_op_error (enum tree_code code)
+binary_op_error (enum tree_code code, tree type0, tree type1)
{
const char *opname;
@@ -2004,7 +2085,8 @@
default:
gcc_unreachable ();
}
- error ("invalid operands to binary %s", opname);
+ error ("invalid operands to binary %s (have %qT and %qT)", opname,
+ type0, type1);
}
/* Subroutine of build_binary_op, used for comparison operations.
@@ -2585,9 +2667,13 @@
break;
case MODIFY_EXPR:
- if (!TREE_NO_WARNING (expr))
- warning (OPT_Wparentheses,
- "suggest parentheses around assignment used as truth value");
+ if (!TREE_NO_WARNING (expr)
+ && warn_parentheses)
+ {
+ warning (OPT_Wparentheses,
+ "suggest parentheses around assignment used as truth value");
+ TREE_NO_WARNING (expr) = 1;
+ }
break;
default:
@@ -2953,9 +3039,9 @@
}
/* Implement the __alignof keyword: Return the minimum required
- alignment of EXPR, measured in bytes. For VAR_DECL's and
- FIELD_DECL's return DECL_ALIGN (which can be set from an
- "aligned" __attribute__ specification). */
+ alignment of EXPR, measured in bytes. For VAR_DECLs,
+ FUNCTION_DECLs and FIELD_DECLs return DECL_ALIGN (which can be set
+ from an "aligned" __attribute__ specification). */
tree
c_alignof_expr (tree expr)
@@ -2962,7 +3048,7 @@
{
tree t;
- if (TREE_CODE (expr) == VAR_DECL)
+ if (VAR_OR_FUNCTION_DECL_P (expr))
t = size_int (DECL_ALIGN_UNIT (expr));
else if (TREE_CODE (expr) == COMPONENT_REF
@@ -3104,6 +3190,85 @@
builtin_types[def] = t;
}
+/* Build builtin functions common to both C and C++ language
+ frontends. */
+
+static void
+c_define_builtins (tree va_list_ref_type_node, tree va_list_arg_type_node)
+{
+#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
+ 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) \
+ 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) \
+ 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
+#undef DEF_FUNCTION_TYPE_3
+#undef DEF_FUNCTION_TYPE_4
+#undef DEF_FUNCTION_TYPE_5
+#undef DEF_FUNCTION_TYPE_6
+#undef DEF_FUNCTION_TYPE_VAR_0
+#undef DEF_FUNCTION_TYPE_VAR_1
+#undef DEF_FUNCTION_TYPE_VAR_2
+#undef DEF_FUNCTION_TYPE_VAR_3
+#undef DEF_FUNCTION_TYPE_VAR_4
+#undef DEF_FUNCTION_TYPE_VAR_5
+#undef DEF_POINTER_TYPE
+ builtin_types[(int) BT_LAST] = NULL_TREE;
+
+ c_init_attributes ();
+
+#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \
+ NONANSI_P, ATTRS, IMPLICIT, COND) \
+ if (NAME && COND) \
+ def_builtin_1 (ENUM, NAME, CLASS, \
+ builtin_types[(int) TYPE], \
+ builtin_types[(int) LIBTYPE], \
+ BOTH_P, FALLBACK_P, NONANSI_P, \
+ built_in_attributes[(int) ATTRS], IMPLICIT);
+#include "builtins.def"
+#undef DEF_BUILTIN
+
+ build_common_builtin_nodes ();
+
+ targetm.init_builtins ();
+ if (flag_mudflap)
+ mudflap_init ();
+}
+
/* Build tree nodes and builtin functions common to both C and C++ language
frontends. */
@@ -3316,78 +3481,9 @@
va_list_ref_type_node = build_reference_type (va_list_type_node);
}
-#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
- 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) \
- 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) \
- 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]);
+ if (!flag_preprocess_only)
+ c_define_builtins (va_list_ref_type_node, va_list_arg_type_node);
-#include "builtin-types.def"
-
-#undef DEF_PRIMITIVE_TYPE
-#undef DEF_FUNCTION_TYPE_1
-#undef DEF_FUNCTION_TYPE_2
-#undef DEF_FUNCTION_TYPE_3
-#undef DEF_FUNCTION_TYPE_4
-#undef DEF_FUNCTION_TYPE_5
-#undef DEF_FUNCTION_TYPE_6
-#undef DEF_FUNCTION_TYPE_VAR_0
-#undef DEF_FUNCTION_TYPE_VAR_1
-#undef DEF_FUNCTION_TYPE_VAR_2
-#undef DEF_FUNCTION_TYPE_VAR_3
-#undef DEF_FUNCTION_TYPE_VAR_4
-#undef DEF_FUNCTION_TYPE_VAR_5
-#undef DEF_POINTER_TYPE
- builtin_types[(int) BT_LAST] = NULL_TREE;
-
- c_init_attributes ();
-
-#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \
- NONANSI_P, ATTRS, IMPLICIT, COND) \
- if (NAME && COND) \
- def_builtin_1 (ENUM, NAME, CLASS, \
- builtin_types[(int) TYPE], \
- builtin_types[(int) LIBTYPE], \
- BOTH_P, FALLBACK_P, NONANSI_P, \
- built_in_attributes[(int) ATTRS], IMPLICIT);
-#include "builtins.def"
-#undef DEF_BUILTIN
-
- build_common_builtin_nodes ();
-
- targetm.init_builtins ();
- if (flag_mudflap)
- mudflap_init ();
-
main_identifier_node = get_identifier ("main");
/* Create the built-in __null node. It is important that this is
@@ -4168,7 +4264,10 @@
tree type = TREE_TYPE (*node);
/* See FIXME comment in c_common_attribute_table. */
- if (TREE_CODE (*node) == FUNCTION_DECL)
+ /* APPLE LOCAL begin radar 4727659 */
+ if (TREE_CODE (*node) == FUNCTION_DECL
+ || objc_method_decl (TREE_CODE (*node)))
+ /* APPLE LOCAL end radar 4727659 */
TREE_THIS_VOLATILE (*node) = 1;
else if (TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
@@ -4176,6 +4275,14 @@
= build_pointer_type
(build_type_variant (TREE_TYPE (type),
TYPE_READONLY (TREE_TYPE (type)), 1));
+ /* APPLE LOCAL begin radar 6237713 */
+ else if (TREE_CODE (type) == BLOCK_POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
+ TREE_TYPE (*node)
+ = build_block_pointer_type
+ (build_type_variant (TREE_TYPE (type),
+ TYPE_READONLY (TREE_TYPE (type)), 1));
+ /* APPLE LOCAL end radar 6237713 */
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -4310,7 +4417,10 @@
if (TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL
- || TREE_CODE (decl) == LABEL_DECL
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ || (TREE_CODE (decl) == LABEL_DECL
+ && ! DECL_ARTIFICIAL (decl))
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
|| TREE_CODE (decl) == TYPE_DECL)
TREE_USED (decl) = 1;
else
@@ -4757,12 +4867,27 @@
TYPE_ALIGN (*type) = (1 << i) * BITS_PER_UNIT;
TYPE_USER_ALIGN (*type) = 1;
}
- else if (TREE_CODE (decl) != VAR_DECL
- && TREE_CODE (decl) != FIELD_DECL)
+ else if (! VAR_OR_FUNCTION_DECL_P (decl)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ && TREE_CODE (decl) != FIELD_DECL
+ && TREE_CODE (decl) != LABEL_DECL)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
{
error ("alignment may not be specified for %q+D", decl);
*no_add_attrs = true;
}
+ else if (TREE_CODE (decl) == FUNCTION_DECL
+ && DECL_ALIGN (decl) > (1 << i) * BITS_PER_UNIT)
+ {
+ if (DECL_USER_ALIGN (decl))
+ error ("alignment for %q+D was previously specified as %d "
+ "and may not be decreased", decl,
+ DECL_ALIGN (decl) / BITS_PER_UNIT);
+ else
+ error ("alignment for %q+D must be at least %d", decl,
+ DECL_ALIGN (decl) / BITS_PER_UNIT);
+ *no_add_attrs = true;
+ }
else
{
DECL_ALIGN (decl) = (1 << i) * BITS_PER_UNIT;
@@ -4784,6 +4909,23 @@
if (TREE_CODE (*node) == FUNCTION_DECL
|| TREE_CODE (*node) == VAR_DECL)
declare_weak (*node);
+ /* APPLE LOCAL begin weak types 5954418 */
+ else if (!DECL_P (*node)
+ /* If the weak flag can be associated with something else,
+ prefer that. */
+ && (flags & (ATTR_FLAG_FUNCTION_NEXT
+ |ATTR_FLAG_DECL_NEXT
+ |ATTR_FLAG_ARRAY_NEXT)))
+ {
+ *no_add_attrs = true;
+ return tree_cons (name, args, NULL_TREE);
+ }
+ else if (! targetm.cxx.class_data_always_comdat ()
+ && TREE_CODE (*node) == RECORD_TYPE)
+ {
+ /* Leave on the type for the C++ front end */
+ }
+ /* APPLE LOCAL end weak types 5954418 */
else
warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -5249,6 +5391,71 @@
return NULL_TREE;
}
+/* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) --ilr */
+/* Handle a "unavailable" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_unavailable_attribute (tree *node, tree name,
+ tree args ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED,
+ bool *no_add_attrs)
+{
+ tree type = NULL_TREE;
+ int warn = 0;
+ const char *what = NULL;
+
+ if (DECL_P (*node))
+ {
+ tree decl = *node;
+ type = TREE_TYPE (decl);
+
+ if (TREE_CODE (decl) == TYPE_DECL
+ || TREE_CODE (decl) == PARM_DECL
+ || TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == FUNCTION_DECL
+ /* APPLE LOCAL begin radar 3803157 - objc attribute */
+ || TREE_CODE (decl) == FIELD_DECL
+ || objc_method_decl (TREE_CODE (decl)))
+ /* APPLE LOCAL end radar 3803157 - objc attribute */
+ {
+ TREE_UNAVAILABLE (decl) = 1;
+ }
+ else
+ warn = 1;
+ }
+ else if (TYPE_P (*node))
+ {
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ *node = build_variant_type_copy (*node);
+ TREE_UNAVAILABLE (*node) = 1;
+ type = *node;
+ }
+ else
+ warn = 1;
+
+ if (warn)
+ {
+ *no_add_attrs = true;
+ if (type && TYPE_NAME (type))
+ {
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ what = IDENTIFIER_POINTER (TYPE_NAME (*node));
+ else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (type)))
+ what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
+ }
+ if (what)
+ warning (0, "`%s' attribute ignored for `%s'",
+ IDENTIFIER_POINTER (name), what);
+ else
+ warning (0, "`%s' attribute ignored", IDENTIFIER_POINTER (name));
+ }
+
+ return NULL_TREE;
+}
+/* APPLE LOCAL end "unavailable" attribute --ilr */
+
/* Handle a "vector_size" attribute; arguments as in
struct attribute_spec.handler. */
@@ -5386,7 +5593,10 @@
return NULL_TREE;
}
- if (TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE)
+ /* APPLE LOCAL begin blocks 5925781 */
+ if (TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE &&
+ TREE_CODE (TREE_VALUE (argument)) != BLOCK_POINTER_TYPE)
+ /* APPLE LOCAL end blocks 5925781 */
{
error ("nonnull argument references non-pointer operand (argument %lu, operand %lu)",
(unsigned long) attr_arg_num, (unsigned long) arg_num);
@@ -5533,8 +5743,11 @@
happen if the "nonnull" attribute was given without an operand
list (which means to check every pointer argument). */
- if (TREE_CODE (TREE_TYPE (param)) != POINTER_TYPE)
- return;
+ /* APPLE LOCAL begin blocks 5925781 */
+ if (TREE_CODE (TREE_TYPE (param)) != POINTER_TYPE &&
+ TREE_CODE (TREE_TYPE (param)) != BLOCK_POINTER_TYPE)
+ /* APPLE LOCAL end blocks 5925781 */
+ return;
if (integer_zerop (param))
warning (OPT_Wnonnull, "null argument where non-null required "
@@ -5637,6 +5850,168 @@
return NULL_TREE;
}
+/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
+/* Handle "blocks" attribute. */
+static tree
+handle_blocks_attribute (tree *node, tree name,
+ tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree arg_ident;
+ /* APPLE LOCAL radar 6217257 */
+ tree type;
+ *no_add_attrs = true;
+ if (!(*node) || TREE_CODE (*node) != VAR_DECL)
+ {
+ error ("__block attribute can be specified on variables only");
+ return NULL_TREE;
+ }
+ arg_ident = TREE_VALUE (args);
+ gcc_assert (TREE_CODE (arg_ident) == IDENTIFIER_NODE);
+ /* APPLE LOCAL radar 6096219 */
+ if (strcmp (IDENTIFIER_POINTER (arg_ident), "byref"))
+ {
+ /* APPLE LOCAL radar 6096219 */
+ warning (OPT_Wattributes, "Only \"byref\" is allowed - %qE attribute ignored",
+ name);
+ return NULL_TREE;
+ }
+ /* APPLE LOCAL begin radar 6217257 */
+ type = TREE_TYPE (*node);
+ if (TREE_CODE (type) == ERROR_MARK)
+ return NULL_TREE;
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ if (!TYPE_SIZE (type) || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
+ {
+ error ("__block not allowed on a variable length array declaration");
+ return NULL_TREE;
+ }
+ }
+ /* APPLE LOCAL end radar 6217257 */
+ COPYABLE_BYREF_LOCAL_VAR (*node) = 1;
+ COPYABLE_BYREF_LOCAL_NONPOD (*node) = block_requires_copying (*node);
+ return NULL_TREE;
+}
+/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+
+/* APPLE LOCAL begin blocks 6040305 */
+
+/* This routine builds:
+ *(void **)(EXP+20) expression which references the object pointer.
+*/
+tree
+build_indirect_object_id_exp (tree exp)
+{
+ tree dst_obj;
+ int int_size = int_cst_value (TYPE_SIZE_UNIT (unsigned_type_node));
+ int offset;
+ /* dst->object In thid case 'object' is the field
+ of the object passed offset by: void * + void* + int + int + void* + void *
+ This must match definition of Block_byref structs. */
+ /* APPLE LOCAL radar 6244520 */
+ offset = GET_MODE_SIZE (Pmode) + GET_MODE_SIZE (Pmode)
+ + int_size + int_size + GET_MODE_SIZE (Pmode) +
+ GET_MODE_SIZE (Pmode);
+ dst_obj = build2 (PLUS_EXPR, ptr_type_node, exp,
+ build_int_cst (NULL_TREE, offset));
+ /* APPLE LOCAL begin radar 6180456 */
+ /* Type case to: 'void **' */
+ dst_obj = build_c_cast (build_pointer_type (ptr_type_node), dst_obj);
+ dst_obj = build_indirect_ref (dst_obj, "unary *");
+ /* APPLE LOCAL end radar 6180456 */
+ return dst_obj;
+}
+
+/* This routine builds call to:
+ _Block_object_dispose(VAR_DECL.__forwarding, BLOCK_FIELD_IS_BYREF);
+ and adds it to the statement list.
+ */
+tree
+build_block_byref_release_exp (tree var_decl)
+{
+ tree exp = var_decl, call_exp;
+ tree type = TREE_TYPE (var_decl);
+ /* __block variables imported into Blocks are not _Block_object_dispose()
+ from within the Block statement itself; otherwise, each envokation of
+ the block causes a release. Make sure to release __block variables declared
+ and used locally in the block though. */
+ if (cur_block
+ && (BLOCK_DECL_COPIED (var_decl) || BLOCK_DECL_BYREF (var_decl)))
+ return NULL_TREE;
+ if (BLOCK_DECL_BYREF (var_decl)) {
+ /* This is a "struct Block_byref_X *" type. Get its pointee. */
+ gcc_assert (POINTER_TYPE_P (type));
+ type = TREE_TYPE (type);
+ exp = build_indirect_ref (exp, "unary *");
+ }
+ TREE_USED (var_decl) = 1;
+
+ /* Declare: _Block_object_dispose(void*, BLOCK_FIELD_IS_BYREF) if not done already. */
+ exp = build_component_ref (exp, get_identifier ("__forwarding"));
+ call_exp = build_block_object_dispose_call_exp (exp, BLOCK_FIELD_IS_BYREF);
+ return call_exp;
+}
+/* APPLE LOCAL end blocks 6040305 */
+/* APPLE LOCAL begin radar 5803600 */
+/** add_block_global_byref_list - Adds global variable decl to the list of
+ byref global declarations in the current block.
+*/
+void add_block_global_byref_list (tree decl)
+{
+ cur_block->block_byref_global_decl_list =
+ tree_cons (NULL_TREE, decl, cur_block->block_byref_global_decl_list);
+}
+
+/** in_block_global_byref_list - returns TRUE if global variable is
+ in the list of 'byref' declarations.
+*/
+bool in_block_global_byref_list (tree decl)
+{
+ tree chain;
+ if (TREE_STATIC (decl)) {
+ for (chain = cur_block->block_byref_global_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (TREE_VALUE (chain) == decl)
+ return true;
+ }
+ return false;
+}
+/* APPLE LOCAL end radar 5803600 */
+
+/* APPLE LOCAL begin radar 6160536 */
+tree
+build_block_helper_name (int unique_count)
+{
+ char *buf;
+ if (!current_function_decl)
+ {
+ /* APPLE LOCAL begin radar 6411649 */
+ static int global_count;
+ buf = (char *)alloca (32);
+ sprintf (buf, "__block_global_%d", ++global_count);
+ /* APPLE LOCAL end radar 6411649 */
+ }
+ else
+ {
+ tree outer_decl = current_function_decl;
+ /* APPLE LOCAL begin radar 6169580 */
+ while (outer_decl &&
+ DECL_CONTEXT (outer_decl) && TREE_CODE (DECL_CONTEXT (outer_decl)) == FUNCTION_DECL)
+ /* APPLE LOCAL end radar 6169580 */
+ outer_decl = DECL_CONTEXT (outer_decl);
+ /* APPLE LOCAL begin radar 6411649 */
+ if (!unique_count)
+ unique_count = ++DECL_STRUCT_FUNCTION(outer_decl)->unqiue_block_number;
+ /* APPLE LOCAL end radar 6411649 */
+ buf = (char *)alloca (IDENTIFIER_LENGTH (DECL_NAME (outer_decl)) + 32);
+ sprintf (buf, "__%s_block_invoke_%d",
+ IDENTIFIER_POINTER (DECL_NAME (outer_decl)), unique_count);
+ }
+ return get_identifier (buf);
+}
+/* APPLE LOCAL end radar 6160536 */
+
/* Handle a "sentinel" attribute. */
static tree
@@ -5918,11 +6293,11 @@
message = NULL;
}
else
- error (gmsgid);
+ error (gmsgid, "");
if (message)
{
- error (message);
+ error (message, "");
free (message);
}
#undef catenate_messages
@@ -6471,5 +6846,229 @@
warning (OPT_Wchar_subscripts, "array subscript has type %<char%>");
}
+/* Implement -Wparentheses for the unexpected C precedence rules, to
+ cover cases like x + y << z which readers are likely to
+ misinterpret. We have seen an expression in which CODE is a binary
+ operator used to combine expressions headed by CODE_LEFT and
+ CODE_RIGHT. CODE_LEFT and CODE_RIGHT may be ERROR_MARK, which
+ means that that side of the expression was not formed using a
+ binary operator, or it was enclosed in parentheses. */
+void
+warn_about_parentheses (enum tree_code code, enum tree_code code_left,
+ enum tree_code code_right)
+{
+ if (!warn_parentheses)
+ return;
+
+ if (code == LSHIFT_EXPR || code == RSHIFT_EXPR)
+ {
+ if (code_left == PLUS_EXPR || code_left == MINUS_EXPR
+ || code_right == PLUS_EXPR || code_right == MINUS_EXPR)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around + or - inside shift");
+ }
+
+ if (code == TRUTH_ORIF_EXPR)
+ {
+ if (code_left == TRUTH_ANDIF_EXPR
+ || code_right == TRUTH_ANDIF_EXPR)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around && within ||");
+ }
+
+ if (code == BIT_IOR_EXPR)
+ {
+ if (code_left == BIT_AND_EXPR || code_left == BIT_XOR_EXPR
+ || code_left == PLUS_EXPR || code_left == MINUS_EXPR
+ || code_right == BIT_AND_EXPR || code_right == BIT_XOR_EXPR
+ || code_right == PLUS_EXPR || code_right == MINUS_EXPR)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around arithmetic in operand of |");
+ /* Check cases like x|y==z */
+ if (TREE_CODE_CLASS (code_left) == tcc_comparison
+ || TREE_CODE_CLASS (code_right) == tcc_comparison)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around comparison in operand of |");
+ }
+
+ if (code == BIT_XOR_EXPR)
+ {
+ if (code_left == BIT_AND_EXPR
+ || code_left == PLUS_EXPR || code_left == MINUS_EXPR
+ || code_right == BIT_AND_EXPR
+ || code_right == PLUS_EXPR || code_right == MINUS_EXPR)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around arithmetic in operand of ^");
+ /* Check cases like x^y==z */
+ if (TREE_CODE_CLASS (code_left) == tcc_comparison
+ || TREE_CODE_CLASS (code_right) == tcc_comparison)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around comparison in operand of ^");
+ }
+
+ if (code == BIT_AND_EXPR)
+ {
+ if (code_left == PLUS_EXPR || code_left == MINUS_EXPR
+ || code_right == PLUS_EXPR || code_right == MINUS_EXPR)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around + or - in operand of &");
+ /* Check cases like x&y==z */
+ if (TREE_CODE_CLASS (code_left) == tcc_comparison
+ || TREE_CODE_CLASS (code_right) == tcc_comparison)
+ warning (OPT_Wparentheses,
+ "suggest parentheses around comparison in operand of &");
+ }
+
+ /* Similarly, check for cases like 1<=i<=10 that are probably errors. */
+ if (TREE_CODE_CLASS (code) == tcc_comparison
+ && (TREE_CODE_CLASS (code_left) == tcc_comparison
+ || TREE_CODE_CLASS (code_right) == tcc_comparison))
+ warning (OPT_Wparentheses, "comparisons like X<=Y<=Z do not "
+ "have their mathematical meaning");
+}
+
+/* APPLE LOCAL begin radar 6246527 */
+/* This routine is called for a "format" attribute. It adds the number of
+ hidden argument ('1') to the format's 2nd and 3rd argument to compensate
+ for these two arguments. This is to make rest of the "format" attribute
+ processing done in the middle-end to work seemlessly. */
+
+static void
+block_delta_format_args (tree format)
+{
+ tree format_num_expr, first_arg_num_expr;
+ int val;
+ tree args = TREE_VALUE (format);
+ gcc_assert (TREE_CHAIN (args) && TREE_CHAIN (TREE_CHAIN (args)));
+ format_num_expr = TREE_VALUE (TREE_CHAIN (args));
+ first_arg_num_expr = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args)));
+ if (format_num_expr && TREE_CODE (format_num_expr) == INTEGER_CST)
+ {
+ val = TREE_INT_CST_LOW (format_num_expr);
+ TREE_VALUE (TREE_CHAIN (args)) = build_int_cst (NULL_TREE, val+1);
+ }
+ if (first_arg_num_expr && TREE_CODE (first_arg_num_expr) == INTEGER_CST)
+ {
+ val = TREE_INT_CST_LOW (first_arg_num_expr);
+ if (val != 0)
+ TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args))) =
+ build_int_cst (NULL_TREE, val+1);
+ }
+}
+
+/* This routine recognizes legal block attributes. In case of block's "format"
+ attribute, it calls block_delta_format_args to compensate for hidden
+ argument _self getting passed to block's helper function. */
+bool
+any_recognized_block_attribute (tree attributes)
+{
+ tree chain;
+ bool res = false;
+ for (chain = attributes; chain; chain = TREE_CHAIN (chain))
+ {
+ if (is_attribute_p ("format", TREE_PURPOSE (chain)))
+ {
+ block_delta_format_args (chain);
+ res = true;
+ }
+ else if (is_attribute_p ("sentinel", TREE_PURPOSE (chain)))
+ res = true;
+ }
+ return res;
+}
+/* APPLE LOCAL end radar 6246527 */
+/* APPLE LOCAL begin radar 5847976 */
+static GTY(()) tree block_object_assign_decl;
+static GTY(()) tree block_object_dispose_func_decl;
+/* This routine declares:
+ void _Block_object_assign (void *, void *, int) or uses an
+ existing one.
+*/
+static tree
+build_block_object_assign_decl (void)
+{
+ tree func_type;
+ if (block_object_assign_decl)
+ return block_object_assign_decl;
+ block_object_assign_decl = lookup_name (get_identifier ("_Block_object_assign"));
+ if (block_object_assign_decl)
+ return block_object_assign_decl;
+ func_type =
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, integer_type_node, void_list_node))));
+
+ block_object_assign_decl = builtin_function ("_Block_object_assign", func_type,
+ 0, NOT_BUILT_IN, 0, NULL_TREE);
+ TREE_NOTHROW (block_object_assign_decl) = 0;
+ return block_object_assign_decl;
+}
+
+/* This routine builds:
+ _Block_object_assign(dest, src, flag)
+*/
+tree build_block_object_assign_call_exp (tree dst, tree src, int flag)
+{
+ tree func_params = tree_cons (NULL_TREE, dst,
+ tree_cons (NULL_TREE, src,
+ tree_cons (NULL_TREE,
+ build_int_cst (integer_type_node, flag),
+ NULL_TREE)));
+ return build_function_call (build_block_object_assign_decl (), func_params);
+}
+
+/* This routine declares:
+ void _Block_object_dispose (void *, int) or uses an
+ existing one.
+*/
+static tree
+build_block_object_dispose_decl (void)
+{
+ tree func_type;
+ if (block_object_dispose_func_decl)
+ return block_object_dispose_func_decl;
+ block_object_dispose_func_decl = lookup_name (get_identifier ("_Block_object_dispose"));
+ if (block_object_dispose_func_decl)
+ return block_object_dispose_func_decl;
+ func_type =
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, integer_type_node, void_list_node)));
+
+ block_object_dispose_func_decl = builtin_function ("_Block_object_dispose", func_type,
+ 0, NOT_BUILT_IN, 0, NULL_TREE);
+ TREE_NOTHROW (block_object_dispose_func_decl) = 0;
+ return block_object_dispose_func_decl;
+}
+
+/* This routine builds the call tree:
+ _Block_object_dispose(src, flag)
+*/
+tree build_block_object_dispose_call_exp (tree src, int flag)
+{
+ tree func_params = tree_cons (NULL_TREE, src,
+ tree_cons (NULL_TREE,
+ build_int_cst (integer_type_node, flag),
+ NULL_TREE));
+ return build_function_call (build_block_object_dispose_decl (), func_params);
+}
+/* APPLE LOCAL end radar 5847976 */
+/* APPLE LOCAL begin radar 7760213 */
+int HasByrefArray(tree byrefType)
+{
+ tree s1;
+ /* Check for possibility of an error condition. */
+ if (TREE_CODE(byrefType) != RECORD_TYPE)
+ return 0;
+
+ for (s1 = TYPE_FIELDS (byrefType); s1; s1 = TREE_CHAIN (s1))
+ {
+ if (TREE_CODE(TREE_TYPE(s1)) == ARRAY_TYPE)
+ return 1;
+ }
+ return 0;
+}
+/* APPLE LOCAL end radar 7760213 */
#include "gt-c-common.h"
Modified: trunk/contrib/gcc/c-common.h
===================================================================
--- trunk/contrib/gcc4/c-common.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-common.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -93,12 +93,20 @@
/* Objective-C */
RID_AT_ENCODE, RID_AT_END,
RID_AT_CLASS, RID_AT_ALIAS, RID_AT_DEFS,
- RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC,
+ /* APPLE LOCAL radar 4564694 */
+ RID_AT_PACKAGE, RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC,
RID_AT_PROTOCOL, RID_AT_SELECTOR,
RID_AT_THROW, RID_AT_TRY, RID_AT_CATCH,
RID_AT_FINALLY, RID_AT_SYNCHRONIZED,
RID_AT_INTERFACE,
+ /* APPLE LOCAL C* language */
+ RID_AT_OPTIONAL, RID_AT_REQUIRED,
+ /* APPLE LOCAL C* property (Radar 4436866) */
+ RID_AT_PROPERTY,
RID_AT_IMPLEMENTATION,
+ /* APPLE LOCAL C* property (Radar 4436866, 4591909, 4621020) */
+ RID_READONLY, RID_GETTER, RID_SETTER,
+ RID_NONATOMIC,
RID_MAX,
@@ -389,6 +397,10 @@
extern int flag_short_wchar;
+/* Nonzero means allow implicit conversions between vectors with
+ differing numbers of subparts and/or differing element types. */
+extern int flag_lax_vector_conversions;
+
/* Nonzero means allow Microsoft extensions without warnings or errors. */
extern int flag_ms_extensions;
@@ -650,11 +662,11 @@
extern tree c_alignof_expr (tree);
/* Print an error message for invalid operands to arith operation CODE.
NOP_EXPR is used as a special case (see truthvalue_conversion). */
-extern void binary_op_error (enum tree_code);
+extern void binary_op_error (enum tree_code, tree, tree);
extern tree fix_string_type (tree);
struct varray_head_tag;
extern void constant_expression_warning (tree);
-extern void strict_aliasing_warning(tree, tree, tree);
+extern bool strict_aliasing_warning (tree, tree, tree);
extern void empty_body_warning (tree, tree);
extern tree convert_and_check (tree, tree);
extern void overflow_warning (tree);
@@ -791,7 +803,7 @@
extern tree lookup_label (tree);
extern tree lookup_name (tree);
-extern int vector_types_convertible_p (tree t1, tree t2);
+extern bool vector_types_convertible_p (tree t1, tree t2, bool emit_lax_note);
extern rtx c_expand_expr (tree, rtx, enum machine_mode, int, rtx *);
@@ -850,7 +862,10 @@
extern tree builtin_type_for_size (int, bool);
extern void warn_array_subscript_with_type_char (tree);
+extern void warn_about_parentheses (enum tree_code, enum tree_code,
+ enum tree_code);
+
/* In c-gimplify.c */
extern void c_genericize (tree);
extern int c_gimplify_expr (tree *, tree *, tree *);
@@ -881,8 +896,23 @@
extern tree objc_is_class_name (tree);
extern tree objc_is_object_ptr (tree);
extern void objc_check_decl (tree);
+/* APPLE LOCAL radar 4281748 */
+extern void objc_check_global_decl (tree);
extern int objc_is_reserved_word (tree);
-extern bool objc_compare_types (tree, tree, int, tree);
+/* APPLE LOCAL 4154928 */
+extern tree objc_common_type (tree, tree);
+/* APPLE LOCAL 4330422 */
+extern tree objc_non_volatilized_type (tree);
+/* APPLE LOCAL radar 4697411 */
+extern void objc_volatilize_component_ref (tree, tree);
+/* APPLE LOCAL radar 6231433 */
+extern bool objc_compare_types (tree, tree, int, tree, const char *);
+/* APPLE LOCAL radar 4229905 - radar 6231433 */
+extern bool objc_have_common_type (tree, tree, int, tree, const char *);
+/* APPLE LOCAL radar 4133425 */
+extern bool objc_diagnose_private_ivar (tree);
+/* APPLE LOCAL radar 4507230 */
+bool objc_type_valid_for_messaging (tree);
extern void objc_volatilize_decl (tree);
extern bool objc_type_quals_match (tree, tree);
extern tree objc_rewrite_function_call (tree, tree);
@@ -893,7 +923,8 @@
extern tree objc_is_id (tree);
extern void objc_declare_alias (tree, tree);
extern void objc_declare_class (tree);
-extern void objc_declare_protocols (tree);
+/* APPLE LOCAL radar 4947311 - protocol attributes */
+extern void objc_declare_protocols (tree, tree);
extern tree objc_build_message_expr (tree);
extern tree objc_finish_message_expr (tree, tree, tree);
extern tree objc_build_selector_expr (tree);
@@ -903,23 +934,40 @@
extern tree objc_get_protocol_qualified_type (tree, tree);
extern tree objc_get_class_reference (tree);
extern tree objc_get_class_ivars (tree);
-extern void objc_start_class_interface (tree, tree, tree);
+/* APPLE LOCAL begin radar 4291785 */
+extern tree objc_get_interface_ivars (tree);
+extern void objc_detect_field_duplicates (tree);
+/* APPLE LOCAL end radar 4291785 */
+/* APPLE LOCAL radar 4548636 */
+extern void objc_start_class_interface (tree, tree, tree, tree);
extern void objc_start_category_interface (tree, tree, tree);
-extern void objc_start_protocol (tree, tree);
+/* APPLE LOCAL radar 4947311 - protocol attributes */
+extern void objc_start_protocol (tree, tree, tree);
extern void objc_continue_interface (void);
extern void objc_finish_interface (void);
extern void objc_start_class_implementation (tree, tree);
extern void objc_start_category_implementation (tree, tree);
+/* APPLE LOCAL radar 4592503 */
+extern void objc_checkon_weak_attribute (tree);
+/* APPLE LOCAL begin radar 5847976 */
+extern tree build_block_object_assign_call_exp (tree, tree, int);
+extern tree build_block_object_dispose_call_exp (tree, int);
+extern int objc_is_gcable_type (tree);
+/* APPLE LOCAL end radar 5847976 */
extern void objc_continue_implementation (void);
extern void objc_finish_implementation (void);
extern void objc_set_visibility (int);
extern void objc_set_method_type (enum tree_code);
extern tree objc_build_method_signature (tree, tree, tree, bool);
-extern void objc_add_method_declaration (tree);
-extern void objc_start_method_definition (tree);
+/* APPLE LOCAL begin radar 3803157 - objc attribute */
+extern bool objc_method_decl (enum tree_code);
+extern void objc_add_method_declaration (tree, tree);
+extern void objc_start_method_definition (tree, tree);
+/* APPLE LOCAL end radar 3803157 - objc attribute */
extern void objc_finish_method_definition (tree);
extern void objc_add_instance_variable (tree);
-extern tree objc_build_keyword_decl (tree, tree, tree);
+/* APPLE LOCAL radar 4157812 */
+extern tree objc_build_keyword_decl (tree, tree, tree, tree);
extern tree objc_build_throw_stmt (tree);
extern void objc_begin_try_stmt (location_t, tree);
extern tree objc_finish_try_stmt (void);
@@ -930,7 +978,53 @@
extern int objc_static_init_needed_p (void);
extern tree objc_generate_static_init_call (tree);
extern tree objc_generate_write_barrier (tree, enum tree_code, tree);
+/* APPLE LOCAL radar 5276085 */
+extern void objc_weak_reference_expr (tree*);
+/* APPLE LOCAL begin 5276085 */
+extern tree objc_build_weak_reference_tree (tree);
+/* APPLE LOCAL end 5276085 */
+/* APPLE LOCAL begin C* language */
+extern void objc_set_method_opt (int);
+void objc_finish_foreach_loop (location_t, tree, tree, tree, tree);
+tree objc_build_component_ref (tree, tree);
+tree objc_build_foreach_components (tree, tree*, tree*, tree*,
+ tree*, tree*, tree*);
+/* APPLE LOCAL end C* language */
+/* APPLE LOCAL begin C* property (Radar 4436866) */
+void objc_set_property_attr (int, tree);
+void objc_add_property_variable (tree);
+/* APPLE LOCAL begin radar 5285911 */
+tree objc_build_property_reference_expr (tree, tree);
+bool objc_property_reference_expr (tree);
+/* APPLE LOCAL end radar 5285911 */
+/* APPLE LOCAL radar 5802025 */
+tree objc_build_property_getter_func_call (tree);
+tree objc_build_setter_call (tree, tree);
+/* APPLE LOCAL end C* property (Radar 4436866) */
+/* APPLE LOCAL radar 4712269 */
+tree objc_build_incr_decr_setter_call (enum tree_code, tree, tree);
+
+/* APPLE LOCAL begin C* warnings to easy porting to new abi */
+void diagnose_selector_cast (tree cast_type, tree sel_exp);
+/* APPLE LOCAL end C* warnings to easy porting to new abi */
+
+/* APPLE LOCAL begin radar 4441049 */
+tree objc_v2_component_ref_field_offset (tree);
+tree objc_v2_bitfield_ivar_bitpos (tree);
+/* APPLE LOCAL end radar 4441049 */
+
+/* APPLE LOCAL begin 4985544 */
+bool objc_check_format_nsstring (tree, unsigned HOST_WIDE_INT, bool *);
+/* APPLE LOCAL end 4985544 */
+
+/* APPLE LOCAL radar 5202926 */
+bool objc_anonymous_local_objc_name (const char *);
+/* APPLE LOCAL begin radar 5195402 */
+bool objc_check_nsstring_pointer_type (tree);
+bool objc_check_cfstringref_type (tree);
+/* APPLE LOCAL end radar 5195402 */
+
/* The following are provided by the C and C++ front-ends, and called by
ObjC/ObjC++. */
extern void *objc_get_current_scope (void);
@@ -943,6 +1037,116 @@
extern void pp_dir_change (cpp_reader *, const char *);
extern bool check_missing_format_attribute (tree, tree);
+
+/* APPLE LOCAL begin radar 5847976 */
+/* Runtime support functions used by compiler when generating copy/dispose helpers */
+enum {
+ BLOCK_FIELD_IS_OBJECT = 3, /* id, NSObject, __attribute__((NSObject)), block, ... */
+ BLOCK_FIELD_IS_BLOCK = 7, /* a block variable */
+ BLOCK_FIELD_IS_BYREF = 8, /* the on stack structure holding the __block variable */
+ BLOCK_FIELD_IS_WEAK = 16, /* declared __weak, only used in byref copy helpers */
+ BLOCK_BYREF_CALLER = 128, /* called from __block (byref) copy/dispose support routines */
+ BLOCK_BYREF_CURRENT_MAX = 256
+};
+/* APPLE LOCAL end radar 5847976 */
+/* APPLE LOCAL begin radar 5732232 - blocks */
+enum {
+ BLOCK_NEEDS_FREE = (1 << 24),
+ BLOCK_HAS_COPY_DISPOSE = (1 << 25),
+ /* APPLE LOCAL radar 6214617 */
+ BLOCK_HAS_CXX_OBJ = (1 << 26),
+ BLOCK_IS_GC = (1 << 27),
+ /* APPLE LOCAL radar 5822844 */
+ BLOCK_IS_GLOBAL = (1 << 28),
+ /* APPLE LOCAL radar 7735196 */
+ BLOCK_USE_STRET = (1 << 29)
+};
+
+struct block_sema_info {
+ tree helper_func_decl;
+ tree copy_helper_func_decl;
+ tree destroy_helper_func_decl;
+ tree block_arg_ptr_type;
+ /* This is for C. */
+ struct c_arg_info * arg_info;
+ tree block_ref_decl_list;
+ tree block_byref_decl_list;
+ /* APPLE LOCAL radar 5803600 */
+ tree block_byref_global_decl_list;
+ tree block_original_ref_decl_list;
+ /* APPLE LOCAL radar 5847213 - tree block_original_byref_decl_list is removed. */
+ tree block_body;
+ bool BlockHasCopyDispose;
+ /* APPLE LOCAL radar 6214617 */
+ bool BlockImportsCxxObjects;
+ /* APPLE LOCAL radar 6185344 */
+ bool block_has_return_type; /* When true, block has a declared return type. */
+
+ /* the_scope - This is the scope for the block itself, which
+ contains arguments etc. Use only for C. */
+ struct c_scope *the_scope;
+ /* Same as the above, only for C++. */
+ struct cp_binding_level *cp_the_scope;
+
+ /* return_type - This will get set to block result type, by looking
+ at return types, if any, in the block body. */
+ tree return_type;
+
+ /* prev_block_info - If this is nested inside another block, this points
+ to the outer block. */
+ struct block_sema_info *prev_block_info;
+};
+
+extern struct block_sema_info *cur_block;
+extern tree build_helper_func_decl (tree, tree);
+extern tree build_block_byref_decl (tree, tree, tree);
+extern tree build_block_ref_decl (tree, tree);
+extern tree begin_block (void);
+extern struct block_sema_info *finish_block (tree);
+extern bool in_imm_block (void);
+extern bool lookup_name_in_block (tree, tree*);
+extern void push_to_top_level (void);
+extern void pop_from_top_level (void);
+extern void start_block_helper_function (tree func_decl);
+extern void block_build_prologue (struct block_sema_info *block_impl);
+extern tree c_finish_return (tree);
+extern bool block_requires_copying (tree);
+/* APPLE LOCAL begin radar 5803600 */
+extern void add_block_global_byref_list (tree);
+extern bool in_block_global_byref_list (tree);
+/* APPLE LOCAL end radar 5803600 */
+/* APPLE LOCAL end radar 5732232 - blocks */
+/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
+extern tree build_byref_local_var_access (tree, tree);
+extern tree do_digest_init (tree, tree);
+/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+/* APPLE LOCAL begin radar 6237713 */
+extern bool any_recognized_block_attribute (tree);
+/* APPLE LOCAL end radar 6237713 */
+
+/* APPLE LOCAL begin radar 5847213 */
+extern tree build_block_descriptor_type (bool);
+/* APPLE LOCAL end radar 5847213 */
+/* APPLE LOCAL begin radar 6083129 - byref escapes */
+extern tree build_block_byref_release_exp (tree);
+/* APPLE LOCAL end radar 6083129 - byref escapes */
+
+/* APPLE LOCAL radar 6040305 - blocks */
+extern tree build_indirect_object_id_exp (tree);
+/* APPLE LOCAL begin radar 6212722 */
+extern tree array_to_pointer_conversion (tree);
+extern tree function_to_pointer_conversion (tree);
+/* APPLE LOCAL end radar 6212722 */
+
+/* APPLE LOCAL radar 6160536 */
+extern tree build_block_helper_name (int);
+
+/* APPLE LOCAL radar 6353006 */
+extern tree c_build_generic_block_struct_type (void);
+
+/* APPLE LOCAL radar 7760213 */
+extern int HasByrefArray(tree);
+
/* In c-omp.c */
extern tree c_finish_omp_master (tree);
extern tree c_finish_omp_critical (tree, tree);
Modified: trunk/contrib/gcc/c-convert.c
===================================================================
--- trunk/contrib/gcc4/c-convert.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-convert.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -80,7 +80,7 @@
if ((invalid_conv_diag
= targetm.invalid_conversion (TREE_TYPE (expr), type)))
{
- error (invalid_conv_diag);
+ error (invalid_conv_diag, "");
return error_mark_node;
}
@@ -104,6 +104,10 @@
return fold_convert (type, c_objc_common_truthvalue_conversion (expr));
if (code == POINTER_TYPE || code == REFERENCE_TYPE)
return fold (convert_to_pointer (type, e));
+ /* APPLE LOCAL begin blocks (C++ ck) */
+ if (code == BLOCK_POINTER_TYPE)
+ return fold (convert_to_block_pointer (type, e));
+ /* APPLE LOCAL end blocks (C++ ck) */
if (code == REAL_TYPE)
return fold (convert_to_real (type, e));
if (code == COMPLEX_TYPE)
Modified: trunk/contrib/gcc/c-cppbuiltin.c
===================================================================
--- trunk/contrib/gcc4/c-cppbuiltin.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-cppbuiltin.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -501,6 +501,14 @@
/* Other target-independent built-ins determined by command-line
options. */
+ /* APPLE LOCAL begin blocks */
+ /* APPLE LOCAL radar 5868913 */
+ if (flag_blocks)
+ {
+ cpp_define (pfile, "__block=__attribute__((__blocks__(byref)))");
+ cpp_define (pfile, "__BLOCKS__=1");
+ }
+ /* APPLE LOCAL end blocks */
if (optimize_size)
cpp_define (pfile, "__OPTIMIZE_SIZE__");
if (optimize)
@@ -545,7 +553,9 @@
/* Make the choice of the stack protector runtime visible to source code.
The macro names and values here were chosen for compatibility with an
earlier implementation, i.e. ProPolice. */
- if (flag_stack_protect == 2)
+ if (flag_stack_protect == 3)
+ cpp_define (pfile, "__SSP_STRONG__=3");
+ else if (flag_stack_protect == 2)
cpp_define (pfile, "__SSP_ALL__=2");
else if (flag_stack_protect == 1)
cpp_define (pfile, "__SSP__=1");
Modified: trunk/contrib/gcc/c-decl.c
===================================================================
--- trunk/contrib/gcc4/c-decl.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-decl.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -19,7 +19,7 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/c-decl.c 261188 2014-01-26 19:49:54Z pfg $ */
/* Merged C99 inline changes from gcc trunk 122565 2007-03-05 */
/* Fixed problems with compiling inline-25.c and inline-26.c */
/* XXX still fails inline-29.c, inline-31.c, and inline-32.c */
@@ -71,6 +71,8 @@
enum decl_context
{ NORMAL, /* Ordinary declaration */
FUNCDEF, /* Function definition */
+ /* APPLE LOCAL blocks 6339747 */
+ BLOCKDEF, /* Block literal declaration */
PARM, /* Declaration of parm before function body */
FIELD, /* Declaration inside struct or union */
TYPENAME}; /* Typename (inside cast or sizeof) */
@@ -453,10 +455,17 @@
with __attribute__((deprecated)). An object declared as
__attribute__((deprecated)) suppresses warnings of uses of other
deprecated items. */
+/* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+/* Also add an __attribute__((unavailable)). An object declared as
+ __attribute__((unavailable)) suppresses any reports of being
+ declared with unavailable or deprecated items. */
+/* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
enum deprecated_states {
DEPRECATED_NORMAL,
DEPRECATED_SUPPRESS
+ /* APPLE LOCAL "unavailable" attribute (radar 2809697) */
+ , DEPRECATED_UNAVAILABLE_SUPPRESS
};
static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
@@ -1690,12 +1699,11 @@
DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
DECL_MODE (newdecl) = DECL_MODE (olddecl);
- if (TREE_CODE (olddecl) != FUNCTION_DECL)
- if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
- {
- DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
- DECL_USER_ALIGN (newdecl) |= DECL_ALIGN (olddecl);
- }
+ if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
+ {
+ DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
+ DECL_USER_ALIGN (newdecl) |= DECL_ALIGN (olddecl);
+ }
}
@@ -1710,6 +1718,12 @@
if (TREE_DEPRECATED (newdecl))
TREE_DEPRECATED (olddecl) = 1;
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ /* Merge unavailableness. */
+ if (TREE_UNAVAILABLE (newdecl))
+ TREE_UNAVAILABLE (olddecl) = 1;
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
+
/* Keep source location of definition rather than declaration and of
prototype rather than non-prototype unless that prototype is
built-in. */
@@ -3179,7 +3193,28 @@
= size_binop (PLUS_EXPR, DECL_SIZE_UNIT (decl), TYPE_SIZE_UNIT (type));
}
}
-
+
+/* APPLE LOCAL begin blocks 6339747 */
+/* Decode a block literal type, such as "int **", returning a ...FUNCTION_DECL node. */
+
+tree
+grokblockdecl (struct c_declspecs *specs, struct c_declarator *declarator)
+{
+ tree decl;
+ tree attrs = specs->attrs;
+
+ specs->attrs = NULL_TREE;
+
+ decl = grokdeclarator (declarator, specs, BLOCKDEF,
+ false, NULL);
+
+ /* Apply attributes. */
+ decl_attributes (&decl, attrs, 0);
+
+ return decl;
+}
+/* APPLE LOCAL end blocks 6339747 */
+
/* Decode a "typename", such as "int **", returning a ..._TYPE node. */
tree
@@ -3223,9 +3258,37 @@
/* An object declared as __attribute__((deprecated)) suppresses
warnings of uses of other deprecated items. */
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ /* An object declared as __attribute__((unavailable)) suppresses
+ any reports of being declared with unavailable or deprecated
+ items. An object declared as __attribute__((deprecated))
+ suppresses warnings of uses of other deprecated items. */
+#ifdef A_LESS_INEFFICENT_WAY /* which I really don't want to do! */
if (lookup_attribute ("deprecated", attributes))
deprecated_state = DEPRECATED_SUPPRESS;
+ else if (lookup_attribute ("unavailable", attributes))
+ deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS;
+#else /* a more efficient way doing what lookup_attribute would do */
+ tree a;
+ for (a = attributes; a; a = TREE_CHAIN (a))
+ {
+ tree name = TREE_PURPOSE (a);
+ if (TREE_CODE (name) == IDENTIFIER_NODE)
+ if (is_attribute_p ("deprecated", name))
+ {
+ deprecated_state = DEPRECATED_SUPPRESS;
+ break;
+ }
+ if (is_attribute_p ("unavailable", name))
+ {
+ deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS;
+ break;
+ }
+ }
+#endif
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
+
decl = grokdeclarator (declarator, declspecs,
NORMAL, initialized, NULL);
if (!decl)
@@ -3413,6 +3476,322 @@
using_eh_for_cleanups ();
}
+/* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ cr) */
+#define BLOCK_ALIGN_MAX 18
+static tree block_byref_id_object_copy[BLOCK_BYREF_CURRENT_MAX*(BLOCK_ALIGN_MAX+1)];
+static tree block_byref_id_object_dispose[BLOCK_BYREF_CURRENT_MAX*(BLOCK_ALIGN_MAX+1)];
+
+/**
+ This routine builds:
+
+ void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
+ struct Block_byref_id_object *src) {
+ _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
+ _Block_object_assign(&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // blocks
+ } */
+static void
+synth_block_byref_id_object_copy_func (int flag, int kind)
+{
+ tree stmt, fnbody;
+ tree dst_arg, src_arg;
+ tree dst_obj, src_obj;
+ struct c_arg_info * arg_info;
+ tree call_exp;
+ gcc_assert (block_byref_id_object_copy[kind]);
+ /* Set up: (void* _dest, void*_src) parameters. */
+ dst_arg = build_decl (PARM_DECL, get_identifier ("_dst"),
+ ptr_type_node);
+ TREE_USED (dst_arg) = 1;
+ DECL_ARG_TYPE (dst_arg) = ptr_type_node;
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ ptr_type_node);
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = ptr_type_node;
+ arg_info = xcalloc (1, sizeof (struct c_arg_info));
+ TREE_CHAIN (dst_arg) = src_arg;
+ arg_info->parms = dst_arg;
+ arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE,
+ ptr_type_node,
+ NULL_TREE));
+ /* function header synthesis. */
+ push_function_context ();
+ start_block_helper_function (block_byref_id_object_copy[kind]);
+ store_parm_decls_from (arg_info);
+
+ /* Body of the function. */
+ stmt = c_begin_compound_stmt (true);
+ /* Build dst->object */
+ dst_obj = build_indirect_object_id_exp (dst_arg);
+
+
+ /* src_obj is: _src->object. */
+ src_obj = build_indirect_object_id_exp (src_arg);
+
+ /* APPLE LOCAL begin radar 6180456 */
+ /* _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT) or :
+ _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK) */
+ /* APPLE LOCAL begin radar 6573923 */
+ /* Also add the new flag when calling _Block_object_dispose
+ from byref dispose helper. */
+ flag |= BLOCK_BYREF_CALLER;
+ /* APPLE LOCAL end radar 6573923 */
+ call_exp = build_block_object_assign_call_exp (build_fold_addr_expr (dst_obj), src_obj, flag);
+ add_stmt (call_exp);
+ /* APPLE LOCAL end radar 6180456 */
+
+ fnbody = c_end_compound_stmt (stmt, true);
+ add_stmt (fnbody);
+ finish_function ();
+ pop_function_context ();
+ free (arg_info);
+}
+
+/**
+ This routine builds:
+
+ void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
+ _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // object
+ _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // block
+ } */
+static void
+synth_block_byref_id_object_dispose_func (int flag, int kind)
+{
+ tree stmt, fnbody;
+ tree src_arg, src_obj, rel_exp;
+ struct c_arg_info * arg_info;
+ gcc_assert (block_byref_id_object_dispose[kind]);
+ /* Set up: (void *_src) parameter. */
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ ptr_type_node);
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = ptr_type_node;
+ arg_info = xcalloc (1, sizeof (struct c_arg_info));
+ arg_info->parms = src_arg;
+ arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
+ NULL_TREE);
+ /* function header synthesis. */
+ push_function_context ();
+ start_block_helper_function (block_byref_id_object_dispose[kind]);
+ store_parm_decls_from (arg_info);
+
+ /* Body of the function. */
+ stmt = c_begin_compound_stmt (true);
+ src_obj = build_indirect_object_id_exp (src_arg);
+
+ /* APPLE LOCAL begin radar 6180456 */
+ /* _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT) : or
+ _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK) */
+ /* APPLE LOCAL begin radar 6573923 */
+ /* Also add the new flag when calling _Block_object_dispose
+ from byref dispose helper. */
+ flag |= BLOCK_BYREF_CALLER;
+ /* APPLE LOCAL end radar 6573923 */
+ rel_exp = build_block_object_dispose_call_exp (src_obj, flag);
+ /* APPLE LOCAL end radar 6180456 */
+ add_stmt (rel_exp);
+
+ fnbody = c_end_compound_stmt (stmt, true);
+ add_stmt (fnbody);
+ finish_function ();
+ pop_function_context ();
+ free (arg_info);
+}
+
+/* new_block_byref_decl - This routine changes a 'typex x' declared variable into:
+
+ struct __Block_byref_x {
+ // APPLE LOCAL radar 6244520
+ void *__isa; // NULL for everything except __weak pointers
+ struct Block_byref_x *__forwarding;
+ int32_t __flags;
+ int32_t __size;
+ void *__ByrefKeepFuncPtr; // Only if variable is __block ObjC object
+ void *__ByrefDestroyFuncPtr; // Only if variable is __block ObjC object
+ typex x;
+ } x;
+*/
+
+static tree
+new_block_byref_decl (tree decl)
+{
+ static int unique_count;
+ /* APPLE LOCAL radar 5847976 */
+ int save_flag_objc_gc;
+ tree Block_byref_type;
+ tree field_decl_chain, field_decl;
+ const char *prefix = "__Block_byref_";
+ char *string = alloca (strlen (IDENTIFIER_POINTER (DECL_NAME (decl))) +
+ strlen (prefix) + 8 /* to hold the count */);
+
+ sprintf (string, "%s%d_%s", prefix, ++unique_count,
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+
+ push_to_top_level ();
+ Block_byref_type = start_struct (RECORD_TYPE, get_identifier (string));
+
+ /* APPLE LOCAL begin radar 6244520 */
+ /* void *__isa; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__isa"), ptr_type_node);
+ field_decl_chain = field_decl;
+ /* APPLE LOCAL end radar 6244520 */
+
+ /* struct Block_byref_x *__forwarding; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__forwarding"),
+ build_pointer_type (Block_byref_type));
+ /* APPLE LOCAL radar 6244520 */
+ chainon (field_decl_chain, field_decl);
+
+ /* int32_t __flags; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__flags"),
+ unsigned_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ /* int32_t __size; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__size"),
+ unsigned_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+ {
+ /* void *__ByrefKeepFuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__ByrefKeepFuncPtr"),
+ ptr_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ /* void *__ByrefDestroyFuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__ByrefDestroyFuncPtr"),
+ ptr_type_node);
+ chainon (field_decl_chain, field_decl);
+ }
+
+ /* typex x; */
+ field_decl = build_decl (FIELD_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ chainon (field_decl_chain, field_decl);
+
+ pop_from_top_level ();
+ /* APPLE LOCAL begin radar 5847976 */
+ /* Hack so we don't issue warning on a field_decl having __weak attribute */
+ save_flag_objc_gc = flag_objc_gc;
+ flag_objc_gc = 0;
+ finish_struct (Block_byref_type, field_decl_chain, NULL_TREE);
+ flag_objc_gc = save_flag_objc_gc;
+ /* APPLE LOCAL end radar 5847976 */
+
+ TREE_TYPE (decl) = Block_byref_type;
+ /* Force layout_decl to recompute these fields. */
+ DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = 0;
+ layout_decl (decl, 0);
+ return decl;
+}
+
+/* init_byref_decl - This routine builds the initializer for the __Block_byref_x
+ type in the form of:
+ { NULL, &x, 0, sizeof(struct __Block_byref_x), initializer-expr};
+
+ or:
+ { NULL, &x, 0, sizeof(struct __Block_byref_x)};
+ when INIT is NULL_TREE
+
+ For __block ObjC objects, it also adds "byref_keep" and "byref_destroy"
+ Funtion pointers. So the most general initializers would be:
+
+ { NULL, &x, 0, sizeof(struct __Block_byref_x), &byref_keep, &byref_destroy,
+ &initializer-expr};
+*/
+static tree
+/* APPLE LOCAL radar 5847976 */
+init_byref_decl (tree decl, tree init, int flag)
+{
+ tree initlist;
+ tree block_byref_type = TREE_TYPE (decl);
+ int size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (block_byref_type));
+ unsigned flags = 0;
+ tree fields;
+
+ if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+ flags = BLOCK_HAS_COPY_DISPOSE;
+
+ fields = TYPE_FIELDS (block_byref_type);
+ /* APPLE LOCAL begin radar 6244520 */
+ /* APPLE LOCAL begin radar 5847976 */
+ initlist = tree_cons (fields, fold_convert (ptr_type_node, ((flag & BLOCK_FIELD_IS_WEAK) != 0) ? integer_one_node
+ : integer_zero_node), 0);
+ /* APPLE LOCAL end radar 5847976 */
+ fields = TREE_CHAIN (fields);
+
+ initlist = tree_cons (fields,
+ build_unary_op (ADDR_EXPR, decl, 0), initlist);
+ /* APPLE LOCAL end radar 6244520 */
+ fields = TREE_CHAIN (fields);
+
+ initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), flags),
+ initlist);
+ fields = TREE_CHAIN (fields);
+ initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), size),
+ initlist);
+ fields = TREE_CHAIN (fields);
+
+ if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+ {
+ char name[64];
+ int align = exact_log2 ((DECL_ALIGN (decl)+TYPE_ALIGN (ptr_type_node)-1) / TYPE_ALIGN (ptr_type_node));
+ int kind;
+ if (align == -1 || align > BLOCK_ALIGN_MAX) {
+ error ("invalid alignment for __block variable");
+ kind = 0;
+ } else
+ kind = align*BLOCK_BYREF_CURRENT_MAX + flag;
+ /* Add &__Block_byref_id_object_copy, &__Block_byref_id_object_dispose
+ initializers. */
+ if (!block_byref_id_object_copy[kind])
+ {
+ /* Build a void __Block_byref_id_object_copy(void*, void*) type. */
+ tree func_type =
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node)));
+ sprintf (name, "__Block_byref_id_object_copy%d", kind);
+ block_byref_id_object_copy[kind] = build_helper_func_decl (get_identifier (name),
+ func_type);
+ /* Synthesize function definition. */
+ synth_block_byref_id_object_copy_func (flag, kind);
+ }
+ initlist = tree_cons (fields,
+ build_fold_addr_expr (block_byref_id_object_copy[kind]),
+ initlist);
+ fields = TREE_CHAIN (fields);
+
+ if (!block_byref_id_object_dispose[kind])
+ {
+ /* Synthesize void __Block_byref_id_object_dispose (void*) and
+ build &__Block_byref_id_object_dispose. */
+ tree func_type =
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node, void_list_node));
+ sprintf (name, "__Block_byref_id_object_dispose%d", kind);
+ block_byref_id_object_dispose[kind] = build_helper_func_decl (get_identifier (name),
+ func_type);
+ /* Synthesize function definition. */
+ synth_block_byref_id_object_dispose_func (flag, kind);
+ }
+ initlist = tree_cons (fields,
+ build_fold_addr_expr (block_byref_id_object_dispose[kind]),
+ initlist);
+ fields = TREE_CHAIN (fields);
+ }
+
+ if (init)
+ {
+ init = do_digest_init (TREE_TYPE (fields), init);
+ initlist = tree_cons (fields, init, initlist);
+ }
+ init = build_constructor_from_list (block_byref_type, nreverse (initlist));
+ return init;
+}
+/* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ cr) */
+
/* Finish processing of a declaration;
install its initial value.
If the length of an array type is not known before,
@@ -3439,6 +3818,45 @@
/* Don't crash if parm is initialized. */
if (TREE_CODE (decl) == PARM_DECL)
init = 0;
+ /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ cq) */
+ /* We build a new type for each local variable declared as __block
+ and initialize it to a list of initializers. */
+ else if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
+ {
+ if (DECL_EXTERNAL (decl) || TREE_STATIC (decl))
+ {
+ error ("__block attribute on %q+D not allowed, only allowed on local variables", decl);
+ COPYABLE_BYREF_LOCAL_VAR (decl) = 0;
+ COPYABLE_BYREF_LOCAL_NONPOD (decl) = 0;
+ }
+ else
+ {
+ int flag = 0;
+ if (objc_is_gcable_type (TREE_TYPE (decl)) == -1)
+ flag = BLOCK_FIELD_IS_WEAK;
+ if (block_requires_copying (decl))
+ {
+ if (TREE_CODE (TREE_TYPE (decl)) == BLOCK_POINTER_TYPE)
+ flag |= BLOCK_FIELD_IS_BLOCK;
+ else
+ flag |= BLOCK_FIELD_IS_OBJECT;
+ }
+ decl = new_block_byref_decl (decl);
+ /* APPLE LOCAL begin radar 6289031 */
+#if 0
+ if (! flag_objc_gc_only)
+#endif
+ {
+ push_cleanup (decl, build_block_byref_release_exp (decl), false);
+ }
+ /* APPLE LOCAL end radar 6289031 */
+ /* APPLE LOCAL begin radar 5847976 */
+ COPYABLE_WEAK_BLOCK (decl) = ((flag & BLOCK_FIELD_IS_WEAK) != 0);
+ init = init_byref_decl (decl, init, flag);
+ /* APPLE LOCAL end radar 5847976 */
+ }
+ }
+ /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ cq) */
if (init)
store_init_value (decl, init);
@@ -3931,6 +4349,61 @@
}
+
+/* Print warning about variable length array if necessary. */
+
+static void
+warn_variable_length_array (const char *name, tree size)
+{
+ int ped = !flag_isoc99 && pedantic && warn_vla != 0;
+ int const_size = TREE_CONSTANT (size);
+
+ if (ped)
+ {
+ if (const_size)
+ {
+ if (name)
+ pedwarn ("ISO C90 forbids array %qs whose size "
+ "can%'t be evaluated",
+ name);
+ else
+ pedwarn ("ISO C90 forbids array whose size "
+ "can%'t be evaluated");
+ }
+ else
+ {
+ if (name)
+ pedwarn ("ISO C90 forbids variable length array %qs",
+ name);
+ else
+ pedwarn ("ISO C90 forbids variable length array");
+ }
+ }
+ else if (warn_vla > 0)
+ {
+ if (const_size)
+ {
+ if (name)
+ warning (OPT_Wvla,
+ "the size of array %qs can"
+ "%'t be evaluated", name);
+ else
+ warning (OPT_Wvla,
+ "the size of array can %'t be evaluated");
+ }
+ else
+ {
+ if (name)
+ warning (OPT_Wvla,
+ "variable length array %qs is used",
+ name);
+ else
+ warning (OPT_Wvla,
+ "variable length array is used");
+ }
+ }
+}
+
/* Given declspecs and a declarator,
determine the name and type of the object declared
and construct a ..._DECL node for it.
@@ -4002,6 +4475,8 @@
case cdk_function:
case cdk_array:
case cdk_pointer:
+ /* APPLE LOCAL radar 5732232 - blocks */
+ case cdk_block_pointer:
funcdef_syntax = (decl->kind == cdk_function);
decl = decl->declarator;
break;
@@ -4033,6 +4508,11 @@
/* If this looks like a function definition, make it one,
even if it occurs where parms are expected.
Then store_parm_decls will reject it and not use it as a parm. */
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ if (declspecs->unavailable_p)
+ error_unavailable_use (declspecs->type);
+ else
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
if (decl_context == NORMAL && !funcdef_flag && current_scope->parm_flag)
decl_context = PARM;
@@ -4329,17 +4809,7 @@
nonconstant even if it is (eg) a const variable
with known value. */
size_varies = 1;
-
- if (!flag_isoc99 && pedantic)
- {
- if (TREE_CONSTANT (size))
- pedwarn ("ISO C90 forbids array %qs whose size "
- "can%'t be evaluated",
- name);
- else
- pedwarn ("ISO C90 forbids variable-size array %qs",
- name);
- }
+ warn_variable_length_array (orig_name, size);
if (warn_variable_decl)
warning (0, "variable-sized array %qs", name);
}
@@ -4615,6 +5085,30 @@
declarator = declarator->declarator;
break;
}
+
+
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ cj) */
+ case cdk_block_pointer:
+ {
+ if (TREE_CODE (type) != FUNCTION_TYPE)
+ {
+ error ("block pointer to non-function type is invalid");
+ type = error_mark_node;
+ }
+ else
+ {
+ type = build_block_pointer_type (type);
+ /* APPLE LOCAL begin radar 5814025 (C++ cj) */
+ /* Process type qualifiers (such as const or volatile)
+ that were given inside the `^'. */
+ type_quals = declarator->u.pointer_quals;
+ /* APPLE LOCAL end radar 5814025 (C++ cj) */
+ declarator = declarator->declarator;
+ }
+ break;
+ }
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ cj) */
+
default:
gcc_unreachable ();
}
@@ -4640,6 +5134,41 @@
type = error_mark_node;
}
+ /* APPLE LOCAL begin blocks 6339747 */
+ if (decl_context == BLOCKDEF)
+ {
+ tree decl;
+
+ if (type == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (type) != FUNCTION_TYPE)
+ {
+ tree arg_types;
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ error ("block declared as returning an array");
+ return error_mark_node;
+ }
+
+ arg_info = XOBNEW (&parser_obstack, struct c_arg_info);
+ arg_info->parms = 0;
+ arg_info->tags = 0;
+ arg_info->types = 0;
+ arg_info->others = 0;
+ arg_info->pending_sizes = 0;
+ arg_info->had_vla_unspec = 0;
+ arg_types = grokparms (arg_info, false);
+ type_quals = TYPE_UNQUALIFIED;
+ type = build_function_type (type, arg_types);
+ }
+ decl = build_decl (FUNCTION_DECL, NULL_TREE, type);
+ DECL_ARGUMENTS (decl) = arg_info ? arg_info->parms : NULL_TREE;
+ return decl;
+ }
+ /* APPLE LOCAL end blocks 6339747 */
+
/* If this is declaring a typedef name, return a TYPE_DECL. */
if (storage_class == csc_typedef)
@@ -6981,6 +7510,13 @@
error ("%<enum %E%> declared in %<for%> loop initial declaration",
id);
break;
+ /* APPLE LOCAL begin radar 6268817 */
+ case FUNCTION_DECL:
+ /* Block helper function can be declared in the statement block
+ for the for-loop declarations. */
+ if (BLOCK_SYNTHESIZED_FUNC (decl))
+ break;
+ /* APPLE LOCAL end radar 6268817 */
default:
error ("declaration of non-variable %q+D in %<for%> loop "
"initial declaration", decl);
@@ -7021,7 +7557,10 @@
{
struct language_function *p = f->language;
- if (DECL_STRUCT_FUNCTION (current_function_decl) == 0
+ /* APPLE LOCAL begin blocks 6040305 */
+ if (current_function_decl
+ && DECL_STRUCT_FUNCTION (current_function_decl) == 0
+ /* APPLE LOCAL end blocks 6040305 */
&& DECL_SAVED_TREE (current_function_decl) == NULL_TREE)
{
/* Stop pointing to the local nodes about to be freed. */
@@ -7204,6 +7743,536 @@
return ret;
}
+/* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ch) */
+/* build_byref_local_var_access - converts EXPR to:
+ EXPR.__forwarding-><decl-name>.
+*/
+tree
+build_byref_local_var_access (tree expr, tree decl_name)
+{
+ tree exp = build_component_ref (expr, get_identifier ("__forwarding"));
+ exp = build_indirect_ref (exp, "unary *");
+ exp = build_component_ref (exp, decl_name);
+ return exp;
+}
+/* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ch) */
+/* APPLE LOCAL begin radar 5732232 - blocks (C++ ch) */
+/**
+ build_block_byref_decl - This routine inserts a variable declared as a
+ 'byref' variable using the |...| syntax in helper function's outer-most scope.
+*/
+tree
+build_block_byref_decl (tree name, tree decl, tree exp)
+{
+ struct c_scope *scope = current_scope;
+ tree ptr_type, byref_decl;
+ /* APPLE LOCAL begin radar 6225809 */
+ if (cur_block->prev_block_info) {
+ /* Traverse enclosing blocks. Insert a __block variable in
+ each enclosing block which has no declaration of this
+ variable. This is to ensure that the current (inner) block
+ gets the __block version of the variable; */
+ struct block_sema_info *cb = cur_block->prev_block_info;
+ while (cb) {
+ struct c_binding *b = I_SYMBOL_BINDING (name);
+ /* Find the first declaration not in current block. */
+ while (b && b->decl
+ && (TREE_CODE (b->decl) == VAR_DECL
+ || TREE_CODE (b->decl) == PARM_DECL)
+ && b->depth >= cur_block->the_scope->depth)
+ b = b->shadowed;
+
+ /* Is the next declaration not in enclosing block? */
+ if (b && b->decl
+ && (TREE_CODE (b->decl) == VAR_DECL
+ || TREE_CODE (b->decl) == PARM_DECL)
+ && b->depth < cb->the_scope->depth) {
+ /* No declaration of variable seen in the block. Must insert one. */
+ struct c_scope *save_scope = current_scope;
+ struct block_sema_info *save_current_block = cur_block;
+ current_scope = cb->the_scope;
+ cur_block = cb;
+ decl = build_block_byref_decl (name, decl, exp);
+ cur_block = save_current_block;
+ current_scope = save_scope;
+ }
+ cb = cb->prev_block_info;
+ }
+ }
+ /* APPLE LOCAL end radar 6225809 */
+
+ /* If it is already a byref declaration, do not add the pointer type
+ because such declarations already have the pointer type
+ added. This happens when we have two nested byref declarations in
+ nested blocks. */
+ ptr_type = (TREE_CODE (decl) == VAR_DECL && BLOCK_DECL_BYREF (decl))
+ ? TREE_TYPE (decl) : build_pointer_type (TREE_TYPE (decl));
+ byref_decl = build_decl (VAR_DECL, name, ptr_type);
+ /* APPLE LOCAL begin radars 6144664 & 6145471 */
+ DECL_SOURCE_LOCATION (byref_decl) = DECL_SOURCE_LOCATION
+ (cur_block->helper_func_decl);
+ /* APPLE LOCAL end radars 6144664 & 6145471 */
+ BLOCK_DECL_BYREF (byref_decl) = 1;
+
+ /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ch) */
+ if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
+ {
+ COPYABLE_BYREF_LOCAL_VAR (byref_decl) = 1;
+ COPYABLE_BYREF_LOCAL_NONPOD (byref_decl) = COPYABLE_BYREF_LOCAL_NONPOD (decl);
+ /* APPLE LOCAL radar 5847976 */
+ COPYABLE_WEAK_BLOCK (byref_decl) = COPYABLE_WEAK_BLOCK (decl);
+ }
+ /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ch) */
+
+ /* In the presence of nested "{"
+ move up the scope chain until reaching the main function body's scope.
+ */
+ while (scope && !scope->function_body)
+ scope = scope->outer;
+ /* Current scope must be that of the main function body. */
+ gcc_assert (scope && scope->function_body);
+ bind (name, byref_decl,
+ scope, /*invisible=*/false, /*nested=*/false);
+ cur_block->block_byref_decl_list =
+ tree_cons (NULL_TREE, byref_decl, cur_block->block_byref_decl_list);
+ /* APPLE LOCAL radar 5847213 - building block_original_byref_decl_list list removed. */
+ /* APPLE LOCAL begin radar 6289031 */
+#if 0
+ if (! flag_objc_gc_only)
+#endif
+ push_cleanup (byref_decl, build_block_byref_release_exp (byref_decl), false);
+ /* APPLE LOCAL end radar 6289031 */
+
+ return byref_decl;
+}
+
+/**
+ build_block_ref_decl - This routine inserts a copied-in variable (a variable
+ referenced in the block but whose scope is outside the block) in helper
+ function's outer-most scope. It also sets its type to 'const' as such
+ variables are read-only.
+*/
+tree
+build_block_ref_decl (tree name, tree decl)
+{
+ struct c_scope *scope = current_scope;
+ tree ref_decl;
+ /* APPLE LOCAL radar 6212722 */
+ tree type, exp;
+ /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ ch) */
+ /* 'decl' was previously declared as __block. Simply, copy the value
+ embedded in the above variable. */
+ if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
+ decl = build_byref_local_var_access (decl, DECL_NAME (decl));
+ else {
+ /* APPLE LOCAL begin radar 5988451 (C++ ch) */
+ if (cur_block->prev_block_info) {
+ /* Traverse enclosing blocks. Insert a copied-in variable in
+ each enclosing block which has no declaration of this
+ variable. This is to ensure that the current (inner) block
+ has the 'frozen' value of the copied-in variable; which means
+ the value of the copied in variable is at the point of the
+ block declaration and *not* when the inner block is
+ invoked. */
+ struct block_sema_info *cb = cur_block->prev_block_info;
+ while (cb) {
+ struct c_binding *b = I_SYMBOL_BINDING (name);
+ /* Find the first declaration not in current block. */
+ while (b && b->decl
+ && (TREE_CODE (b->decl) == VAR_DECL
+ || TREE_CODE (b->decl) == PARM_DECL)
+ && b->depth >= cur_block->the_scope->depth)
+ b = b->shadowed;
+
+ /* Is the next declaration not in enclosing block? */
+ if (b && b->decl
+ && (TREE_CODE (b->decl) == VAR_DECL
+ || TREE_CODE (b->decl) == PARM_DECL)
+ && b->depth < cb->the_scope->depth) {
+ /* No declaration of variable seen in the block. Must insert one,
+ so it 'freezes' the variable in this block. */
+ struct c_scope *save_scope = current_scope;
+ struct block_sema_info *save_current_block = cur_block;
+ current_scope = cb->the_scope;
+ cur_block = cb;
+ decl = build_block_ref_decl (name, decl);
+ cur_block = save_current_block;
+ current_scope = save_scope;
+ }
+ cb = cb->prev_block_info;
+ }
+ }
+ /* APPLE LOCAL end radar 5988451 (C++ ch) */
+ }
+ /* APPLE LOCAL end radar 5932809 - copyable byref blocks (C++ ch) */
+ /* APPLE LOCAL begin radar 6212722 */
+ exp = decl;
+ type = TREE_TYPE (exp);
+ if (TREE_CODE (type) == ARRAY_TYPE) {
+ exp = array_to_pointer_conversion (decl);
+ type = TREE_TYPE (exp);
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE) {
+ exp = function_to_pointer_conversion (exp);
+ type = TREE_TYPE (exp);
+ }
+ ref_decl = build_decl (VAR_DECL, name,
+ build_qualified_type (type, TYPE_QUAL_CONST));
+ /* APPLE LOCAL end radar 6212722 */
+ /* APPLE LOCAL begin radars 6144664 & 6145471 */
+ DECL_SOURCE_LOCATION (ref_decl) = DECL_SOURCE_LOCATION
+ (cur_block->helper_func_decl);
+ /* APPLE LOCAL end radars 6144664 & 6145471 */
+ DECL_INITIAL (ref_decl) = error_mark_node;
+ /* APPLE LOCAL radar 5805175 - blocks (C++ ch) */
+ c_apply_type_quals_to_decl (TYPE_QUAL_CONST, ref_decl);
+ BLOCK_DECL_COPIED (ref_decl) = 1;
+
+ /* Find the scope for function body (outer-most scope) and insert
+ this variable in that scope. This is to avoid duplicate
+ declaration of the save variable. */
+ while (scope && !scope->function_body)
+ scope = scope->outer;
+ /* We are enterring the copied-in variable in helper function's
+ outer scope; that of its main body. */
+ gcc_assert (scope);
+ bind (name, ref_decl,
+ scope, /*invisible=*/false, /*nested=*/false);
+ cur_block->block_ref_decl_list =
+ tree_cons (NULL_TREE, ref_decl, cur_block->block_ref_decl_list);
+ cur_block->block_original_ref_decl_list =
+ /* APPLE LOCAL radar 6212722 */
+ tree_cons (NULL_TREE, exp, cur_block->block_original_ref_decl_list);
+ return ref_decl;
+}
+
+/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
+static GTY (()) tree descriptor_ptr_type;
+static GTY (()) tree descriptor_ptr_type_with_copydispose;
+/** build_block_descriptor_type - This routine builds following internal type:
+ struct __block_descriptor {
+ unsigned long int reserved; // NULL
+ unsigned long int Size; // sizeof(struct Block_literal_1)
+
+ // optional helper functions
+ void *CopyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE is set (withCopyDispose true)
+ void *DestroyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE is set (withCopyDispose true)
+} *descriptor_ptr_type;
+
+Objects of this type will always be static. This is one main component of abi change.
+*/
+tree
+build_block_descriptor_type (bool withCopyDispose)
+{
+ tree field_decl_chain, field_decl;
+ tree main_type;
+
+ if (withCopyDispose && descriptor_ptr_type_with_copydispose)
+ return descriptor_ptr_type_with_copydispose;
+ if (!withCopyDispose && descriptor_ptr_type)
+ return descriptor_ptr_type;
+
+ main_type =
+ withCopyDispose ?
+ start_struct (RECORD_TYPE, get_identifier ("__block_descriptor_withcopydispose"))
+ : start_struct (RECORD_TYPE, get_identifier ("__block_descriptor"));
+
+ /* unsigned long int reserved; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("reserved"), long_unsigned_type_node);
+ field_decl_chain = field_decl;
+
+ /* unsigned long int Size; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("Size"), long_unsigned_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ if (withCopyDispose)
+ {
+ /* void *CopyFuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("CopyFuncPtr"), ptr_type_node);
+ chainon (field_decl_chain, field_decl);
+ /* void *DestroyFuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("DestroyFuncPtr"), ptr_type_node);
+ chainon (field_decl_chain, field_decl);
+ }
+
+ /* Mark this struct as being a block struct rather than a 'normal'
+ struct. */
+ TYPE_BLOCK_IMPL_STRUCT (main_type) = 1;
+ finish_struct (main_type, field_decl_chain, NULL_TREE);
+
+ main_type = build_pointer_type (main_type);
+ if (withCopyDispose)
+ descriptor_ptr_type_with_copydispose = main_type;
+ else
+ descriptor_ptr_type = main_type;
+ return main_type;
+}
+/* APPLE LOCAL end radar 5847213 - radar 6329245 */
+
+/* APPLE LOCAL begin radar 5814025 (C++ ch) */
+struct c_declarator *
+make_block_pointer_declarator (struct c_declspecs *type_quals_attrs,
+ struct c_declarator *target)
+{
+ int quals = 0;
+ struct c_declarator *itarget = target;
+ struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
+
+ if (type_quals_attrs)
+ {
+ tree attrs = type_quals_attrs->attrs;
+ quals = quals_from_declspecs (type_quals_attrs);
+ if (attrs != NULL_TREE)
+ itarget = build_attrs_declarator (attrs, target);
+ }
+ ret->kind = cdk_block_pointer;
+ /* APPLE LOCAL radar 5882266 (C++ ch) */
+ ret->declarator = itarget;
+ ret->u.pointer_quals = quals;
+ return ret;
+}
+/* APPLE LOCAL end radar 5814025 (C++ ch) */
+
+tree
+begin_block (void)
+{
+ struct block_sema_info *csi;
+#if 0
+ push_scope ();
+#endif
+ csi = (struct block_sema_info*)xcalloc (1, sizeof (struct block_sema_info));
+ csi->prev_block_info = cur_block;
+ cur_block = csi;
+ return NULL_TREE;
+}
+
+struct block_sema_info *
+finish_block (tree block __attribute__ ((__unused__)))
+{
+ struct block_sema_info *csi = cur_block;
+ cur_block = cur_block->prev_block_info;
+#if 0
+ pop_scope ();
+#endif
+ return csi;
+}
+
+bool
+in_imm_block (void)
+{
+ /* APPLE LOCAL radar 5988451 (C++ ch) */
+ return (cur_block && cur_block->the_scope == current_scope);
+}
+
+/* This routine returns 'true' if 'name' has a declaration inside the
+ current block, 'false' otherwise. If 'name' has no declaration in
+ the current block, it returns in DECL the user declaration for
+ 'name' found in the enclosing scope. Note that if it is declared
+ in current declaration, it can be either a user declaration or a
+ byref/copied-in declaration added in current block's scope by the
+ compiler. */
+bool
+lookup_name_in_block (tree name, tree *decl)
+{
+ if (cur_block)
+ {
+ struct c_binding *b = I_SYMBOL_BINDING (name);
+ if (b->depth >= cur_block->the_scope->depth)
+ return true;
+
+ /* Check for common case of block nested inside a non-block. */
+ if (!cur_block->prev_block_info)
+ return false;
+ /* Check for less common case of nested blocks. */
+ /* Declaration not in current block. Find the first user
+ declaration of 'name' in outer scope. */
+ /* APPLE LOCAL begin radar 5988451 (C++ ch) */
+ /* Check for variables only, as we may have parameters, such as
+ 'self' */
+ /* Note that if a copied-in variable (BLOCK_DECL_COPIED) in the
+ enclosing block is found, it must be returned as this is
+ where the variable in current (nested block) will have to get
+ its value. */
+ while (b && b->decl
+ && (TREE_CODE (b->decl) == VAR_DECL)
+ && BLOCK_DECL_BYREF (b->decl))
+ b = b->shadowed;
+ /* APPLE LOCAL end radar 5988451 (C++ ch) */
+ if (b && b->decl)
+ *decl = b->decl;
+ }
+ return false;
+}
+
+static struct c_scope *save_current_scope;
+static tree save_current_function_decl;
+void
+push_to_top_level (void)
+{
+ save_current_scope = current_scope;
+ save_current_function_decl = current_function_decl;
+ current_scope = file_scope;
+ current_function_decl = NULL_TREE;
+}
+
+void
+pop_from_top_level (void)
+{
+ current_scope = save_current_scope;
+ current_function_decl = save_current_function_decl;
+}
+
+/**
+ build_helper_func_decl - This routine builds a FUNCTION_DECL for
+ a block helper function.
+*/
+tree
+build_helper_func_decl (tree ident, tree type)
+{
+ tree func_decl = build_decl (FUNCTION_DECL, ident, type);
+ DECL_EXTERNAL (func_decl) = 0;
+ TREE_PUBLIC (func_decl) = 0;
+ TREE_USED (func_decl) = 1;
+ TREE_NOTHROW (func_decl) = 0;
+ /* APPLE LOCAL radar 6172148 */
+ BLOCK_SYNTHESIZED_FUNC (func_decl) = 1;
+ return func_decl;
+}
+
+/**
+ start_block_helper_function - This is a light-weight version of start_function().
+ It has removed all the fuss in the start_function().
+ */
+void
+start_block_helper_function (tree decl1)
+{
+ struct c_label_context_se *nstack_se;
+ struct c_label_context_vm *nstack_vm;
+ tree restype, resdecl;
+
+ current_function_returns_value = 0; /* Assume, until we see it does. */
+ current_function_returns_null = 0;
+ current_function_returns_abnormally = 0;
+ warn_about_return_type = 0;
+ c_switch_stack = NULL;
+
+ nstack_se = XOBNEW (&parser_obstack, struct c_label_context_se);
+ nstack_se->labels_def = NULL;
+ nstack_se->labels_used = NULL;
+ nstack_se->next = label_context_stack_se;
+ label_context_stack_se = nstack_se;
+
+ nstack_vm = XOBNEW (&parser_obstack, struct c_label_context_vm);
+ nstack_vm->labels_def = NULL;
+ nstack_vm->labels_used = NULL;
+ nstack_vm->scope = 0;
+ nstack_vm->next = label_context_stack_vm;
+ label_context_stack_vm = nstack_vm;
+
+ /* Indicate no valid break/continue context by setting these variables
+ to some non-null, non-label value. We'll notice and emit the proper
+ error message in c_finish_bc_stmt. */
+ c_break_label = c_cont_label = size_zero_node;
+
+ announce_function (decl1);
+
+ /* Make the init_value nonzero so pushdecl knows this is not tentative.
+ error_mark_node is replaced below (in pop_scope) with the BLOCK. */
+ DECL_INITIAL (decl1) = error_mark_node;
+
+ current_function_prototype_locus = UNKNOWN_LOCATION;
+ current_function_prototype_built_in = false;
+ current_function_prototype_arg_types = NULL_TREE;
+
+ /* This function exists in static storage.
+ (This does not mean `static' in the C sense!) */
+ TREE_STATIC (decl1) = 1;
+ /* A helper function is not global */
+ TREE_PUBLIC (decl1) = 0;
+
+ /* This is the earliest point at which we might know the assembler
+ name of the function. Thus, if it's set before this, die horribly. */
+ gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl1));
+ current_function_decl = pushdecl (decl1);
+
+ push_scope ();
+ declare_parm_level ();
+
+ restype = TREE_TYPE (TREE_TYPE (current_function_decl));
+ resdecl = build_decl (RESULT_DECL, NULL_TREE, restype);
+ DECL_ARTIFICIAL (resdecl) = 1;
+ DECL_IGNORED_P (resdecl) = 1;
+ DECL_RESULT (current_function_decl) = resdecl;
+
+ start_fname_decls ();
+}
+
+/**
+ declare_block_prologue_local_vars - utility routine to do the actual
+ declaration and initialization for each referecned block variable.
+*/
+static void
+declare_block_prologue_local_vars (tree self_parm, tree component,
+ tree stmt)
+{
+ tree decl, block_component;
+ tree_stmt_iterator i;
+ tree decl_stmt;
+
+ decl = component;
+ block_component = build_component_ref (build_indirect_ref (self_parm, "->"),
+ DECL_NAME (component));
+ gcc_assert (block_component);
+ DECL_EXTERNAL (decl) = 0;
+ TREE_STATIC (decl) = 0;
+ TREE_USED (decl) = 1;
+ DECL_CONTEXT (decl) = current_function_decl;
+ DECL_ARTIFICIAL (decl) = 1;
+ DECL_INITIAL (decl) = block_component;
+ /* Prepend a DECL_EXPR statement to the statement list. */
+ i = tsi_start (stmt);
+ decl_stmt = build_stmt (DECL_EXPR, decl);
+ /* APPLE LOCAL Radar 5811961, Fix location of block prologue vars (C++ ch) */
+ SET_EXPR_LOCATION (decl_stmt, DECL_SOURCE_LOCATION (decl));
+ /* APPLE LOCAL begin radar 6163705, Blocks prologues */
+ /* Give the prologue statements a line number of one before the beginning of
+ the function, to make them easily identifiable later. */
+ EXPR_LINENO (decl_stmt) = DECL_SOURCE_LINE (decl) - 1;
+ /* APPLE LOCAL end radar 6163705, Blocks prologues */
+ tsi_link_before (&i, decl_stmt, TSI_SAME_STMT);
+}
+
+/**
+ block_build_prologue
+ - This routine builds the declarations for the
+ variables referenced in the block; as in:
+ int *y = .block_descriptor->y;
+ int x = .block_descriptor->x;
+
+ The decl_expr declaration for each initialization is enterred at the
+ beginning of the helper function's statement-list which is passed
+ in block_impl->block_body.
+*/
+void
+block_build_prologue (struct block_sema_info *block_impl)
+{
+ tree chain;
+ /* APPLE LOCAL radar 6404979 */
+ tree self_parm = lookup_name (get_identifier (".block_descriptor"));
+ gcc_assert (self_parm);
+
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ declare_block_prologue_local_vars (self_parm, TREE_VALUE (chain),
+ block_impl->block_body);
+
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ declare_block_prologue_local_vars (self_parm, TREE_VALUE (chain),
+ block_impl->block_body);
+}
+/* APPLE LOCAL end radar 5732232 - blocks (C++ ch) */
+
/* Return a pointer to a structure for an empty list of declaration
specifiers. */
@@ -7223,6 +8292,8 @@
ret->tag_defined_p = false;
ret->explicit_signed_p = false;
ret->deprecated_p = false;
+ /* APPLE LOCAL "unavailable" attribute (radar 2809697) */
+ ret->unavailable_p = false;
ret->default_int_p = false;
ret->long_p = false;
ret->long_long_p = false;
@@ -7286,6 +8357,11 @@
if (TREE_DEPRECATED (type))
specs->deprecated_p = true;
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ if (TREE_UNAVAILABLE (type))
+ specs->unavailable_p = true;
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
+
/* Handle type specifier keywords. */
if (TREE_CODE (type) == IDENTIFIER_NODE && C_IS_RESERVED_WORD (type))
{
@@ -8034,4 +9110,35 @@
ext_block = NULL;
}
+/* APPLE LOCAL begin radar 5741070 */
+
+/* Given an IDENTIFIER tree for a class interface, find (if possible) and
+ return the record type for the class interface. */
+
+tree
+c_return_interface_record_type (tree typename)
+{
+ enum tree_code_class class;
+ enum tree_code code;
+ tree retval = NULL;
+
+ if (typename == NULL)
+ return retval;
+
+ code = TREE_CODE (typename);
+ class = TREE_CODE_CLASS (code);
+
+ if (code != IDENTIFIER_NODE
+ || class != tcc_exceptional)
+ return retval;
+
+ retval = I_TAG_DECL (typename);
+
+ if (TREE_CODE (retval) != RECORD_TYPE)
+ retval = NULL;
+
+ return retval;
+}
+/* APPLE LOCAL end radar 5741070 */
+
#include "gt-c-decl.h"
Modified: trunk/contrib/gcc/c-incpath.c
===================================================================
--- trunk/contrib/gcc4/c-incpath.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-incpath.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -72,7 +72,7 @@
case REASON_DUP_SYS:
fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), path->name);
if (reason == REASON_DUP_SYS)
- fprintf (stderr,
+ fprintf (stderr, "%s",
_(" as it is a non-system directory that duplicates a system directory\n"));
break;
@@ -292,16 +292,16 @@
{
struct cpp_dir *p;
- fprintf (stderr, _("#include \"...\" search starts here:\n"));
+ fprintf (stderr, "%s", _("#include \"...\" search starts here:\n"));
for (p = heads[QUOTE];; p = p->next)
{
if (p == heads[BRACKET])
- fprintf (stderr, _("#include <...> search starts here:\n"));
+ fprintf (stderr, "%s", _("#include <...> search starts here:\n"));
if (!p)
break;
fprintf (stderr, " %s\n", p->name);
}
- fprintf (stderr, _("End of search list.\n"));
+ fprintf (stderr, "%s", _("End of search list.\n"));
}
}
Modified: trunk/contrib/gcc/c-objc-common.h
===================================================================
--- trunk/contrib/gcc4/c-objc-common.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-objc-common.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -140,4 +140,10 @@
#undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P
#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P c_vla_unspec_p
+/* APPLE LOCAL begin radar 6353006 */
+#undef LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE
+#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
+c_build_generic_block_struct_type
+/* APPLE LOCAL end radar 6353006 */
+
#endif /* GCC_C_OBJC_COMMON */
Modified: trunk/contrib/gcc/c-opts.c
===================================================================
--- trunk/contrib/gcc4/c-opts.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-opts.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -20,7 +20,7 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/c-opts.c 261188 2014-01-26 19:49:54Z pfg $ */
/* Merged C99 inline changes from gcc trunk 122565 2007-03-05 */
#include "config.h"
@@ -385,18 +385,23 @@
break;
case OPT_Wall:
+ /* APPLE LOCAL -Wmost */
+ case OPT_Wmost:
set_Wunused (value);
set_Wformat (value);
set_Wimplicit (value);
warn_char_subscripts = value;
warn_missing_braces = value;
- warn_parentheses = value;
+ /* APPLE LOCAL begin -Wmost --dpatel */
+ if (code != OPT_Wmost)
+ warn_parentheses = value;
+ /* APPLE LOCAL end -Wmost --dpatel */
warn_return_type = value;
warn_sequence_point = value; /* Was C only. */
if (c_dialect_cxx ())
warn_sign_compare = value;
warn_switch = value;
- warn_strict_aliasing = value;
+ set_warn_strict_aliasing (value);
warn_strict_overflow = value;
warn_address = value;
@@ -487,6 +492,12 @@
cpp_opts->warn_multichar = value;
break;
+ /* APPLE LOCAL begin -Wnewline-eof */
+ case OPT_Wnewline_eof:
+ cpp_opts->warn_newline_at_eof = value;
+ break;
+ /* APPLE LOCAL end -Wnewline-eof */
+
case OPT_Wnormalized_:
if (!value || (arg && strcasecmp (arg, "none") == 0))
cpp_opts->warn_normalize = normalized_none;
@@ -606,6 +617,10 @@
disable_builtin_function (arg);
break;
+ case OPT_fdirectives_only:
+ cpp_opts->directives_only = 1;
+ break;
+
case OPT_fdollars_in_identifiers:
cpp_opts->dollars_in_ident = value;
break;
@@ -706,6 +721,10 @@
flag_implicit_templates = value;
break;
+ case OPT_flax_vector_conversions:
+ flag_lax_vector_conversions = value;
+ break;
+
case OPT_fms_extensions:
flag_ms_extensions = value;
break;
@@ -818,6 +837,18 @@
flag_gen_declaration = 1;
break;
+ case OPT_femit_struct_debug_baseonly:
+ set_struct_debug_option ("base");
+ break;
+
+ case OPT_femit_struct_debug_reduced:
+ set_struct_debug_option ("dir:ord:sys,dir:gen:any,ind:base");
+ break;
+
+ case OPT_femit_struct_debug_detailed_:
+ set_struct_debug_option (arg);
+ break;
+
case OPT_idirafter:
add_path (xstrdup (arg), AFTER, 0, true);
break;
@@ -1009,6 +1040,13 @@
if (flag_inline_functions)
flag_inline_trees = 2;
+ /* APPLE LOCAL begin radar 5811887 - radar 6084601 */
+ /* In all flavors of c99, except for ObjC/ObjC++, blocks are off by default
+ unless requested via -fblocks. */
+ if (flag_blocks == -1 && flag_iso && !c_dialect_objc())
+ flag_blocks = 0;
+ /* APPLE LOCAL end radar 5811887 - radar 6084601 */
+
/* By default we use C99 inline semantics in GNU99 or C99 mode. C99
inline semantics are not supported in GNU89 or C89 mode. */
if (flag_gnu89_inline == -1)
@@ -1317,6 +1355,11 @@
if (flag_dump_macros == 'M')
flag_no_output = 1;
+ /* By default, -fdirectives-only implies -dD. This allows subsequent phases
+ to perform proper macro expansion. */
+ if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
+ flag_dump_macros = 'D';
+
/* Disable -dD, -dN and -dI if normal output is suppressed. Allow
-dM since at least glibc relies on -M -dM to work. */
/* Also, flag_no_output implies flag_no_line_commands, always. */
@@ -1347,6 +1390,14 @@
actually output the current directory? */
if (flag_working_directory == -1)
flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
+
+ if (cpp_opts->directives_only)
+ {
+ if (warn_unused_macros)
+ error ("-fdirectives-only is incompatible with -Wunused_macros");
+ if (cpp_opts->traditional)
+ error ("-fdirectives-only is incompatible with -traditional");
+ }
}
/* Add include path with a prefix at the front of its name. */
@@ -1430,6 +1481,8 @@
}
}
}
+ else if (cpp_opts->directives_only)
+ cpp_init_special_builtins (parse_in);
include_cursor = 0;
push_command_line_include ();
Modified: trunk/contrib/gcc/c-parser.c
===================================================================
--- trunk/contrib/gcc4/c-parser.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-parser.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -78,6 +78,17 @@
objc_need_raw_identifier = VAL; \
} while (0)
+/* APPLE LOCAL begin C* property (Radar 4436866) (in 4.2 d) */
+/* For checking property attribute keywords */
+static int objc_property_attr_context;
+/* APPLE LOCAL end C* property (Radar 4436866) (in 4.2 d) */
+/* APPLE LOCAL radar 3803157 - objc attribute (in 4.2 e) */
+static tree objc_method_attributes;
+/* APPLE LOCAL begin C* language (in 4.2 f) */
+/* For checking for 'foreach' context. */
+static int objc_foreach_context;
+/* APPLE LOCAL end C* language (in 4.2 f) */
+
/* The reserved keyword table. */
struct resword
{
@@ -179,6 +190,14 @@
{ "end", RID_AT_END, D_OBJC },
{ "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
{ "interface", RID_AT_INTERFACE, D_OBJC },
+ /* APPLE LOCAL begin C* language (in 4.2 j) */
+ { "optional", RID_AT_OPTIONAL, D_OBJC },
+ { "required", RID_AT_REQUIRED, D_OBJC },
+ /* APPLE LOCAL end C* language (in 4.2 j) */
+ /* APPLE LOCAL C* property (Radar 4436866) (in 4.2 k) */
+ { "property", RID_AT_PROPERTY, D_OBJC },
+ /* APPLE LOCAL radar 4564694 */
+ { "package", RID_AT_PACKAGE, D_OBJC },
{ "private", RID_AT_PRIVATE, D_OBJC },
{ "protected", RID_AT_PROTECTED, D_OBJC },
{ "protocol", RID_AT_PROTOCOL, D_OBJC },
@@ -197,6 +216,14 @@
{ "inout", RID_INOUT, D_OBJC },
{ "oneway", RID_ONEWAY, D_OBJC },
{ "out", RID_OUT, D_OBJC },
+ /* APPLE LOCAL begin C* property (Radar 4436866) (in 4.2 l) */
+ /* These are recognized inside a property attribute list */
+ { "readonly", RID_READONLY, D_OBJC },
+ { "getter", RID_GETTER, D_OBJC },
+ { "setter", RID_SETTER, D_OBJC },
+ /* APPLE LOCAL end C* property (Radar 4436866) (in 4.2 l) */
+ /* APPLE LOCAL radar 4947014 - objc atomic property */
+ { "nonatomic", RID_NONATOMIC, D_OBJC },
};
#define N_reswords (sizeof reswords / sizeof (struct resword))
@@ -325,11 +352,13 @@
static GTY (()) c_parser *the_parser;
+/* APPLE LOCAL C* language (in 4.2 ae) */
+static c_token * c_parser_peek_2nd_token (c_parser *);
/* Read in and lex a single token, storing it in *TOKEN. */
static void
-c_lex_one_token (c_token *token)
+c_lex_one_token (c_token *token, c_parser *parser)
{
timevar_push (TV_LEX);
@@ -363,6 +392,27 @@
token->keyword = rid_code;
break;
}
+ /* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
+ else if (objc_foreach_context && rid_code == RID_IN)
+ {
+ /* This is dangerous, we assume we don't need 3 input tokens look ahead. */
+ c_token *tk = c_parser_peek_2nd_token (parser);
+ if (tk->type == CPP_NAME
+ || tk->type == CPP_OPEN_PAREN
+ || tk->type == CPP_MULT
+ || tk->type == CPP_PLUS
+ || tk->type == CPP_PLUS_PLUS
+ || tk->type == CPP_MINUS
+ || tk->type == CPP_MINUS_MINUS
+ /* APPLE LOCAL radar 4529200 (in 4.2 af) */
+ || tk->type == CPP_OPEN_SQUARE)
+ {
+ token->type = CPP_KEYWORD;
+ token->keyword = rid_code;
+ break;
+ }
+ }
+ /* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
}
else
{
@@ -433,8 +483,11 @@
{
if (parser->tokens_avail == 0)
{
- c_lex_one_token (&parser->tokens[0]);
+ /* APPLE LOCAL begin switch these two */
parser->tokens_avail = 1;
+ /* APPLE LOCAL C* language (in 4.2 ae) */
+ c_lex_one_token (&parser->tokens[0], parser);
+ /* APPLE LOCAL end switch these two */
}
return &parser->tokens[0];
}
@@ -609,7 +662,13 @@
c_parser_next_token_starts_declspecs (c_parser *parser)
{
c_token *token = c_parser_peek_token (parser);
- return c_token_starts_declspecs (token);
+ /* APPLE LOCAL begin radar 5277239 */
+ /* Yes, we can have CLASS.method to mean property-style dot-syntax
+ notation to call a class method (equiv to [CLASS meth]). */
+ return c_token_starts_declspecs (token)
+ && (token->id_kind != C_ID_CLASSNAME
+ || c_parser_peek_2nd_token (parser)->type != CPP_DOT);
+ /* APPLE LOCAL end radar 5277239 */
}
/* Return a pointer to the next-but-one token from PARSER, reading it
@@ -623,8 +682,11 @@
gcc_assert (parser->tokens_avail == 1);
gcc_assert (parser->tokens[0].type != CPP_EOF);
gcc_assert (parser->tokens[0].type != CPP_PRAGMA_EOL);
- c_lex_one_token (&parser->tokens[1]);
+ /* APPLE LOCAL begin switch these two */
parser->tokens_avail = 2;
+ /* APPLE LOCAL C* language (in 4.2 ae) */
+ c_lex_one_token (&parser->tokens[1], parser);
+ /* APPLE LOCAL end switch these two */
return &parser->tokens[1];
}
@@ -965,6 +1027,10 @@
C_DTR_NORMAL,
/* An abstract declarator (maybe empty). */
C_DTR_ABSTRACT,
+ /* APPLE LOCAL begin blocks 6339747 */
+ /* A block declarator (maybe empty). */
+ C_DTR_BLOCK,
+ /* APPLE LOCAL end blocks 6339747 */
/* A parameter declarator: may be either, but after a type name does
not redeclare a typedef name as an identifier if it can
alternatively be interpreted as a typedef name; see DR#009,
@@ -980,7 +1046,8 @@
static void c_parser_external_declaration (c_parser *);
static void c_parser_asm_definition (c_parser *);
-static void c_parser_declaration_or_fndef (c_parser *, bool, bool, bool, bool);
+/* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+static void c_parser_declaration_or_fndef (c_parser *, bool, bool, bool, bool, tree*);
static void c_parser_declspecs (c_parser *, struct c_declspecs *, bool, bool,
bool);
static struct c_typespec c_parser_enum_specifier (c_parser *);
@@ -1015,6 +1082,9 @@
static void c_parser_do_statement (c_parser *);
static void c_parser_for_statement (c_parser *);
static tree c_parser_asm_statement (c_parser *);
+/* APPLE LOCAL begin radar 5732232 - blocks (C++ ca) */
+static tree c_parser_block_literal_expr (c_parser *);
+/* APPLE LOCAL end radar 5732232 - blocks (C++ ca) */
static tree c_parser_asm_operands (c_parser *, bool);
static tree c_parser_asm_clobbers (c_parser *);
static struct c_expr c_parser_expr_no_commas (c_parser *, struct c_expr *);
@@ -1043,14 +1113,19 @@
/* These Objective-C parser functions are only ever called when
compiling Objective-C. */
-static void c_parser_objc_class_definition (c_parser *);
+/* APPLE LOCAL radar 4548636 - class attributes. */
+static void c_parser_objc_class_definition (c_parser *, tree);
static void c_parser_objc_class_instance_variables (c_parser *);
static void c_parser_objc_class_declaration (c_parser *);
static void c_parser_objc_alias_declaration (c_parser *);
-static void c_parser_objc_protocol_definition (c_parser *);
+/* APPLE LOCAL radar 4947311 - protocol attributes */
+static void c_parser_objc_protocol_definition (c_parser *, tree);
static enum tree_code c_parser_objc_method_type (c_parser *);
static void c_parser_objc_method_definition (c_parser *);
-static void c_parser_objc_methodprotolist (c_parser *);
+/* APPLE LOCAL C* property (Radar 4436866) (in 4.2 b) */
+static void c_parser_objc_interfacedecllist (c_parser *);
+/* APPLE LOCAL C* property (Radar 4436866) (in 4.2 x) */
+static void c_parser_objc_property_declaration (c_parser *);
static void c_parser_objc_methodproto (c_parser *);
static tree c_parser_objc_method_decl (c_parser *);
static tree c_parser_objc_type_name (c_parser *);
@@ -1144,7 +1219,8 @@
case RID_AT_INTERFACE:
case RID_AT_IMPLEMENTATION:
gcc_assert (c_dialect_objc ());
- c_parser_objc_class_definition (parser);
+ /* APPLE LOCAL radar 4548636 - class attributes. */
+ c_parser_objc_class_definition (parser, NULL_TREE);
break;
case RID_AT_CLASS:
gcc_assert (c_dialect_objc ());
@@ -1156,8 +1232,15 @@
break;
case RID_AT_PROTOCOL:
gcc_assert (c_dialect_objc ());
- c_parser_objc_protocol_definition (parser);
+ /* APPLE LOCAL begin radar 4947311 - protocol attributes */
+ c_parser_objc_protocol_definition (parser, NULL_TREE);
break;
+ /* APPLE LOCAL end radar 4947311 - protocol attributes */
+ /* APPLE LOCAL begin C* property (Radar 4436866) (in 4.2 x) */
+ case RID_AT_PROPERTY:
+ c_parser_objc_property_declaration (parser);
+ break;
+ /* APPLE LOCAL end C* property (Radar 4436866) (in 4.2 x) */
case RID_AT_END:
gcc_assert (c_dialect_objc ());
c_parser_consume_token (parser);
@@ -1189,7 +1272,8 @@
/* A declaration or a function definition. We can only tell
which after parsing the declaration specifiers, if any, and
the first declarator. */
- c_parser_declaration_or_fndef (parser, true, true, false, true);
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ c_parser_declaration_or_fndef (parser, true, true, false, true, NULL);
break;
}
}
@@ -1254,7 +1338,8 @@
static void
c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
- bool nested, bool start_attr_ok)
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ bool nested, bool start_attr_ok, tree *foreach_elem)
{
struct c_declspecs *specs;
tree prefix_attrs;
@@ -1287,6 +1372,29 @@
c_parser_consume_token (parser);
return;
}
+ /* APPLE LOCAL begin radar 4548636 - class attributes. */
+ else if (c_parser_next_token_is_keyword (parser, RID_AT_INTERFACE)
+ || c_parser_next_token_is_keyword (parser, RID_AT_IMPLEMENTATION))
+ {
+ gcc_assert (c_dialect_objc ());
+ if (!specs->declspecs_seen_p || specs->attrs == NULL_TREE
+ || specs->type_seen_p || specs->non_sc_seen_p)
+ c_parser_error (parser, "no type or storage class may be specified here");
+ c_parser_objc_class_definition (parser, specs->attrs);
+ return;
+ }
+ /* APPLE LOCAL end radar 4548636 - class attributes. */
+ /* APPLE LOCAL begin radar 4947311 - protocol attributes */
+ else if (c_parser_next_token_is_keyword (parser, RID_AT_PROTOCOL))
+ {
+ gcc_assert (c_dialect_objc ());
+ if (!specs->declspecs_seen_p || specs->attrs == NULL_TREE
+ || specs->type_seen_p || specs->non_sc_seen_p)
+ c_parser_error (parser, "no type or storage class may be specified here");
+ c_parser_objc_protocol_definition (parser, specs->attrs);
+ return;
+ }
+ /* APPLE LOCAL end radar 4947311 - protocol attributes */
pending_xref_error ();
prefix_attrs = specs->attrs;
all_prefix_attrs = prefix_attrs;
@@ -1311,6 +1419,8 @@
|| c_parser_next_token_is (parser, CPP_COMMA)
|| c_parser_next_token_is (parser, CPP_SEMICOLON)
|| c_parser_next_token_is_keyword (parser, RID_ASM)
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ || c_parser_next_token_is_keyword (parser, RID_IN)
|| c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
{
tree asm_name = NULL_TREE;
@@ -1327,6 +1437,18 @@
asm_name = c_parser_simple_asm_expr (parser);
if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
postfix_attrs = c_parser_attributes (parser);
+ /* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
+ if (c_parser_next_token_is_keyword (parser, RID_IN))
+ {
+ gcc_assert (foreach_elem);
+ *foreach_elem = start_decl (declarator, specs, true,
+ chainon (postfix_attrs, all_prefix_attrs));
+ if (!*foreach_elem)
+ *foreach_elem = error_mark_node;
+ start_init (*foreach_elem, asm_name, global_bindings_p ());
+ return;
+ }
+ /* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
if (c_parser_next_token_is (parser, CPP_EQ))
{
tree d;
@@ -1387,8 +1509,17 @@
/* Function definition (nested or otherwise). */
if (nested)
{
- if (pedantic)
+ /* APPLE LOCAL begin radar 5985368 */
+ if (declarator->declarator && declarator->declarator->kind == cdk_block_pointer)
+ error ("bad definition of a block");
+ else if (pedantic)
+ /* APPLE LOCAL end radar 5985368 */
pedwarn ("ISO C forbids nested functions");
+ /* APPLE LOCAL begin nested functions 4258406 4357979 (in 4.2 m) */
+ else if (flag_nested_functions == 0)
+ error ("nested functions are disabled, use -fnested-functions to re-enable");
+ /* APPLE LOCAL end nested functions 4258406 4357979 (in 4.2 m) */
+
push_function_context ();
}
if (!start_function (specs, declarator, all_prefix_attrs))
@@ -1416,7 +1547,8 @@
function definitions either. */
while (c_parser_next_token_is_not (parser, CPP_EOF)
&& c_parser_next_token_is_not (parser, CPP_OPEN_BRACE))
- c_parser_declaration_or_fndef (parser, false, false, true, false);
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ c_parser_declaration_or_fndef (parser, false, false, true, false, NULL);
DECL_SOURCE_LOCATION (current_function_decl)
= c_parser_peek_token (parser)->location;
store_parm_decls ();
@@ -1438,6 +1570,23 @@
}
}
+static tree
+finish_parse_foreach_header (c_parser *parser, tree foreach_elem_selector)
+{
+ tree res;
+ int save_flag_isoc99 = flag_isoc99;
+ gcc_assert (foreach_elem_selector);
+ /* Consume 'in' keyword */
+ c_parser_consume_token (parser);
+ res = build_tree_list (foreach_elem_selector, c_parser_initializer (parser).value);
+ finish_init ();
+ flag_isoc99 = 1;
+ check_for_loop_decls ();
+ flag_isoc99 = save_flag_isoc99;
+ return res;
+}
+/* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
+
/* Parse an asm-definition (asm() outside a function body). This is a
GNU extension.
@@ -2251,6 +2400,18 @@
parameter-list ;
parameter-forward-declarations parameter-list ;
+ APPLE LOCAL begin blocks 6339747
+ block-declarator:
+ pointer
+ pointer[opt] direct-block-declarator
+
+ direct-block-declarator:
+ ( attributes[opt] block-declarator )
+ direct-block-declarator[opt] array-declarator
+ direct-block-declarator[opt]
+ ( parameter-type-list[opt] ) [opt]
+ APPLE LOCAL end blocks 6339747
+
The uses of attributes shown above are GNU extensions.
Some forms of array declarator are not included in C99 in the
@@ -2277,6 +2438,20 @@
else
return make_pointer_declarator (quals_attrs, inner);
}
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ cc) */
+ else if (flag_blocks && c_parser_next_token_is (parser, CPP_XOR)) {
+ struct c_declspecs *quals_attrs = build_null_declspecs ();
+ struct c_declarator *inner;
+ c_parser_consume_token (parser);
+ c_parser_declspecs (parser, quals_attrs, false, false, true);
+ inner = c_parser_declarator (parser, type_seen_p, kind, seen_id);
+ if (inner == NULL)
+ return NULL;
+ else
+ /* APPLE LOCAL radar 5814025 (C++ cc) */
+ return make_block_pointer_declarator (quals_attrs, inner);
+ }
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ cc) */
/* Now we have a direct declarator, direct abstract declarator or
nothing (which counts as a direct abstract declarator here). */
return c_parser_direct_declarator (parser, type_seen_p, kind, seen_id);
@@ -2323,10 +2498,14 @@
??? Also following the old parser, typedef names may be
redeclared in declarators, but not Objective-C class names. */
- if (kind != C_DTR_ABSTRACT
+ /* APPLE LOCAL blocks 6339747 */
+ if ((kind != C_DTR_ABSTRACT && kind != C_DTR_BLOCK)
&& c_parser_next_token_is (parser, CPP_NAME)
&& ((type_seen_p
- && c_parser_peek_token (parser)->id_kind == C_ID_TYPENAME)
+ /* APPLE LOCAL begin radar 4281748 */
+ && (c_parser_peek_token (parser)->id_kind == C_ID_TYPENAME
+ || c_parser_peek_token (parser)->id_kind == C_ID_CLASSNAME))
+ /* APPLE LOCAL end radar 4281748 */
|| c_parser_peek_token (parser)->id_kind == C_ID_ID))
{
struct c_declarator *inner
@@ -3379,6 +3558,8 @@
{
bool last_stmt = false;
bool last_label = false;
+ /* APPLE LOCAL radar 5732232 - blocks (not in C++) */
+ bool first_stmt = true;
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
{
c_parser_consume_token (parser);
@@ -3389,30 +3570,30 @@
/* Read zero or more forward-declarations for labels that nested
functions can jump to. */
while (c_parser_next_token_is_keyword (parser, RID_LABEL))
+ {
+ c_parser_consume_token (parser);
+ /* Any identifiers, including those declared as type names,
+ are OK here. */
+ while (true)
{
- c_parser_consume_token (parser);
- /* Any identifiers, including those declared as type names,
- are OK here. */
- while (true)
- {
- tree label;
- if (c_parser_next_token_is_not (parser, CPP_NAME))
+ tree label;
+ if (c_parser_next_token_is_not (parser, CPP_NAME))
{
- c_parser_error (parser, "expected identifier");
- break;
+ c_parser_error (parser, "expected identifier");
+ break;
}
- label
+ label
= declare_label (c_parser_peek_token (parser)->value);
- C_DECLARED_LABEL_FLAG (label) = 1;
- add_stmt (build_stmt (DECL_EXPR, label));
- c_parser_consume_token (parser);
- if (c_parser_next_token_is (parser, CPP_COMMA))
+ C_DECLARED_LABEL_FLAG (label) = 1;
+ add_stmt (build_stmt (DECL_EXPR, label));
c_parser_consume_token (parser);
- else
- break;
- }
- c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
+ if (c_parser_next_token_is (parser, CPP_COMMA))
+ c_parser_consume_token (parser);
+ else
+ break;
}
+ c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
+ }
/* ??? Locating this diagnostic on the token after the
declarations end follows the old parser, but it might be
better to locate it where the declarations start instead. */
@@ -3430,81 +3611,85 @@
{
location_t loc = c_parser_peek_token (parser)->location;
if (c_parser_next_token_is_keyword (parser, RID_CASE)
- || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
- || (c_parser_next_token_is (parser, CPP_NAME)
- && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
- {
- last_label = true;
- last_stmt = false;
- c_parser_label (parser);
- }
+ || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
+ || (c_parser_next_token_is (parser, CPP_NAME)
+ && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
+ {
+ last_label = true;
+ last_stmt = false;
+ c_parser_label (parser);
+ }
else if (!last_label
- && c_parser_next_token_starts_declspecs (parser))
- {
- last_label = false;
- c_parser_declaration_or_fndef (parser, true, true, true, true);
- if (last_stmt
- && ((pedantic && !flag_isoc99)
- || warn_declaration_after_statement))
- pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
- &loc);
- last_stmt = false;
- }
+ && c_parser_next_token_starts_declspecs (parser))
+ {
+ last_label = false;
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ c_parser_declaration_or_fndef (parser, true, true, true, true, NULL);
+ if (last_stmt
+ && ((pedantic && !flag_isoc99)
+ || warn_declaration_after_statement))
+ pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
+ &loc);
+ last_stmt = false;
+ }
else if (!last_label
- && c_parser_next_token_is_keyword (parser, RID_EXTENSION))
+ && c_parser_next_token_is_keyword (parser, RID_EXTENSION))
+ {
+ /* __extension__ can start a declaration, but is also an
+ unary operator that can start an expression. Consume all
+ but the last of a possible series of __extension__ to
+ determine which. */
+ while (c_parser_peek_2nd_token (parser)->type == CPP_KEYWORD
+ && (c_parser_peek_2nd_token (parser)->keyword
+ == RID_EXTENSION))
+ c_parser_consume_token (parser);
+ if (c_token_starts_declspecs (c_parser_peek_2nd_token (parser)))
{
- /* __extension__ can start a declaration, but is also an
- unary operator that can start an expression. Consume all
- but the last of a possible series of __extension__ to
- determine which. */
- while (c_parser_peek_2nd_token (parser)->type == CPP_KEYWORD
- && (c_parser_peek_2nd_token (parser)->keyword
- == RID_EXTENSION))
- c_parser_consume_token (parser);
- if (c_token_starts_declspecs (c_parser_peek_2nd_token (parser)))
- {
- int ext;
- ext = disable_extension_diagnostics ();
- c_parser_consume_token (parser);
- last_label = false;
- c_parser_declaration_or_fndef (parser, true, true, true, true);
- /* Following the old parser, __extension__ does not
+ int ext;
+ ext = disable_extension_diagnostics ();
+ c_parser_consume_token (parser);
+ last_label = false;
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ c_parser_declaration_or_fndef (parser, true, true, true, true, NULL);
+ /* Following the old parser, __extension__ does not
disable this diagnostic. */
- restore_extension_diagnostics (ext);
- if (last_stmt
- && ((pedantic && !flag_isoc99)
- || warn_declaration_after_statement))
- pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
- &loc);
- last_stmt = false;
- }
- else
- goto statement;
+ restore_extension_diagnostics (ext);
+ if (last_stmt
+ && ((pedantic && !flag_isoc99)
+ || warn_declaration_after_statement))
+ pedwarn_c90 ("%HISO C90 forbids mixed declarations and code",
+ &loc);
+ last_stmt = false;
}
+ else
+ goto statement;
+ }
else if (c_parser_next_token_is (parser, CPP_PRAGMA))
- {
- /* External pragmas, and some omp pragmas, are not associated
- with regular c code, and so are not to be considered statements
- syntactically. This ensures that the user doesn't put them
- places that would turn into syntax errors if the directive
- were ignored. */
- if (c_parser_pragma (parser, pragma_compound))
- last_label = false, last_stmt = true;
- }
+ {
+ /* External pragmas, and some omp pragmas, are not associated
+ with regular c code, and so are not to be considered statements
+ syntactically. This ensures that the user doesn't put them
+ places that would turn into syntax errors if the directive
+ were ignored. */
+ if (c_parser_pragma (parser, pragma_compound))
+ last_label = false, last_stmt = true;
+ }
else if (c_parser_next_token_is (parser, CPP_EOF))
- {
- c_parser_error (parser, "expected declaration or statement");
- return;
- }
+ {
+ c_parser_error (parser, "expected declaration or statement");
+ return;
+ }
else
- {
- statement:
- last_label = false;
- last_stmt = true;
- c_parser_statement_after_labels (parser);
- }
-
+ {
+ statement:
+ last_label = false;
+ last_stmt = true;
+ c_parser_statement_after_labels (parser);
+ }
+
parser->error = false;
+ /* APPLE LOCAL radar 5732232 - blocks (not in C++) */
+ first_stmt = false;
}
if (last_label)
error ("label at end of compound statement");
@@ -3720,6 +3905,10 @@
c_parser_for_statement (parser);
break;
case RID_GOTO:
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ cb) */
+ if (cur_block)
+ error ("goto not allowed in block literal");
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ cb) */
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_NAME))
{
@@ -3817,8 +4006,20 @@
(recursively) all of the component statements should already have
line numbers assigned. ??? Can we discard no-op statements
earlier? */
+ /* APPLE LOCAL begin Radar 6144634 */
+ /* Normal expr stmts, including modify exprs, get the location where
+ the statement began, i.e. 'loc'. Assignments of Blocks to Block
+ pointer variables get the location of the end of the Block definition,
+ i.e. 'input_location', which should already be set by this point. */
if (stmt && EXPR_P (stmt))
- SET_EXPR_LOCATION (stmt, loc);
+ {
+ if (TREE_CODE (stmt) == MODIFY_EXPR
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (stmt, 0))) == BLOCK_POINTER_TYPE)
+ SET_EXPR_LOCATION (stmt, input_location);
+ else
+ SET_EXPR_LOCATION (stmt, loc);
+ }
+ /* APPLE LOCAL end Radar 6144634 */
}
/* Parse a parenthesized condition from an if, do or while statement.
@@ -3940,16 +4141,25 @@
/* Parse a while statement (C90 6.6.5, C99 6.8.5).
while-statement:
- while (expression) statement
+ APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+ while attributes (expression) statement
+
+ The use of attributes is a GNU extension.
+ APPLE LOCAL end for-fsf-4_4 3274130 5295549
*/
static void
c_parser_while_statement (c_parser *parser)
{
- tree block, cond, body, save_break, save_cont;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tree block, cond, body, save_break, save_cont, attrs;
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
location_t loc;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE));
c_parser_consume_token (parser);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ attrs = c_parser_attributes (parser);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
block = c_begin_compound_stmt (flag_isoc99);
loc = c_parser_peek_token (parser)->location;
cond = c_parser_paren_condition (parser);
@@ -3958,7 +4168,10 @@
save_cont = c_cont_label;
c_cont_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
- c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, attrs,
+ true);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
add_stmt (c_end_compound_stmt (block, flag_isoc99));
c_break_label = save_break;
c_cont_label = save_cont;
@@ -3967,16 +4180,25 @@
/* Parse a do statement (C90 6.6.5, C99 6.8.5).
do-statement:
- do statement while ( expression ) ;
+ APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+ do attributes statement while ( expression ) ;
+
+ The use of attributes is a GNU extension.
+ APPLE LOCAL end for-fsf-4_4 3274130 5295549
*/
static void
c_parser_do_statement (c_parser *parser)
{
- tree block, cond, body, save_break, save_cont, new_break, new_cont;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tree block, cond, body, save_break, save_cont, new_break, new_cont, attrs;
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
location_t loc;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO));
c_parser_consume_token (parser);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ attrs = c_parser_attributes (parser);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
block = c_begin_compound_stmt (flag_isoc99);
loc = c_parser_peek_token (parser)->location;
save_break = c_break_label;
@@ -3992,7 +4214,9 @@
cond = c_parser_paren_condition (parser);
if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
c_parser_skip_to_end_of_block_or_statement (parser);
- c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ c_finish_loop (loc, cond, NULL, body, new_break, new_cont, attrs, false);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
add_stmt (c_end_compound_stmt (block, flag_isoc99));
}
@@ -3999,11 +4223,17 @@
/* Parse a for statement (C90 6.6.5, C99 6.8.5).
for-statement:
- for ( expression[opt] ; expression[opt] ; expression[opt] ) statement
- for ( nested-declaration expression[opt] ; expression[opt] ) statement
+ APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+ for attributes ( expression[opt] ; expression[opt] ; expression[opt] ) \
+ statement
+ for attributes ( nested-declaration expression[opt] ; expression[opt] ) \
+ statement
The form with a declaration is new in C99.
+ The use of attributes is a GNU extension.
+
+ APPLE LOCAL end for-fsf-4_4 3274130 5295549
??? In accordance with the old parser, the declaration may be a
nested function, which is then rejected in check_for_loop_decls,
but does it make any sense for this to be included in the grammar?
@@ -4015,11 +4245,18 @@
static void
c_parser_for_statement (c_parser *parser)
{
- tree block, cond, incr, save_break, save_cont, body;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tree block, cond, incr, save_break, save_cont, body, attrs;
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
location_t loc;
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ bool foreach_p = false;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR));
loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ attrs = c_parser_attributes (parser);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
block = c_begin_compound_stmt (flag_isoc99);
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
@@ -4031,8 +4268,18 @@
}
else if (c_parser_next_token_starts_declspecs (parser))
{
- c_parser_declaration_or_fndef (parser, true, true, true, true);
- check_for_loop_decls ();
+ /* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
+ cond = NULL_TREE;
+ c_parser_declaration_or_fndef (parser, true, true, true, true, &cond);
+ /* APPLE LOCAL radar 5925639 */
+ if (c_parser_next_token_is_keyword (parser, RID_IN) && cond)
+ {
+ cond = finish_parse_foreach_header (parser, cond);
+ foreach_p = true;
+ }
+ else
+ check_for_loop_decls ();
+ /* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
}
else if (c_parser_next_token_is_keyword (parser, RID_EXTENSION))
{
@@ -4049,9 +4296,19 @@
int ext;
ext = disable_extension_diagnostics ();
c_parser_consume_token (parser);
- c_parser_declaration_or_fndef (parser, true, true, true, true);
+ /* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
+ cond = NULL_TREE;
+ c_parser_declaration_or_fndef (parser, true, true, true, true, &cond);
restore_extension_diagnostics (ext);
- check_for_loop_decls ();
+ /* APPLE LOCAL radar 5925639 */
+ if (c_parser_next_token_is_keyword (parser, RID_IN) && cond)
+ {
+ cond = finish_parse_foreach_header (parser, cond);
+ foreach_p = true;
+ }
+ else
+ check_for_loop_decls ();
+ /* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
}
else
goto init_expr;
@@ -4059,9 +4316,22 @@
else
{
init_expr:
- c_finish_expr_stmt (c_parser_expression (parser).value);
- c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
+ /* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
+ cond = c_parser_expression (parser).value;
+ if (c_parser_next_token_is_keyword (parser, RID_IN))
+ {
+ c_parser_consume_token (parser); /* IN */
+ cond = build_tree_list (cond, c_parser_initializer (parser).value);
+ foreach_p = true;
+ }
+ else
+ {
+ c_finish_expr_stmt (cond);
+ c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
+ }
}
+ objc_foreach_context = 0;
+ /* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
/* Parse the loop condition. */
loc = c_parser_peek_token (parser)->location;
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
@@ -4069,6 +4339,10 @@
c_parser_consume_token (parser);
cond = NULL_TREE;
}
+ /* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
+ else if (foreach_p)
+ ;
+ /* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
else
{
tree ocond = c_parser_expression_conv (parser).value;
@@ -4094,7 +4368,10 @@
save_cont = c_cont_label;
c_cont_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
- c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, true);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, attrs,
+ true);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
add_stmt (c_end_compound_stmt (block, flag_isoc99));
c_break_label = save_break;
c_cont_label = save_cont;
@@ -4570,6 +4847,11 @@
} while (0)
gcc_assert (!after || c_dialect_objc ());
stack[0].expr = c_parser_cast_expression (parser, after);
+ /* APPLE LOCAL begin radar 4426814 */
+ if (c_dialect_objc() && flag_objc_gc)
+ /* APPLE LOCAL radar 5276085 */
+ stack[0].expr.value = objc_build_weak_reference_tree (stack[0].expr.value);
+ /* APPLE LOCAL end radar 4426814 */
stack[0].prec = PREC_NONE;
sp = 0;
while (true)
@@ -4681,6 +4963,11 @@
}
sp++;
stack[sp].expr = c_parser_cast_expression (parser, NULL);
+ /* APPLE LOCAL begin radar 4426814 */
+ if (c_dialect_objc() && flag_objc_gc)
+ /* APPLE LOCAL radar 5276085 */
+ stack[sp].expr.value = objc_build_weak_reference_tree (stack[sp].expr.value);
+ /* APPLE LOCAL end radar 4426814 */
stack[sp].prec = oprec;
stack[sp].op = ocode;
}
@@ -5017,6 +5304,8 @@
assignment-expression ,
assignment-expression )
__builtin_types_compatible_p ( type-name , type-name )
+ APPLE LOCAL blocks (C++ cf)
+ block-literal-expr
offsetof-member-designator:
identifier
@@ -5061,6 +5350,21 @@
c_parser_consume_token (parser);
break;
case CPP_NAME:
+ /* APPLE LOCAL begin radar 5277239 */
+ if (c_parser_peek_token (parser)->id_kind == C_ID_CLASSNAME
+ && c_parser_peek_2nd_token (parser)->type == CPP_DOT)
+ {
+ /* CLASS.class_method expression. */
+ tree receiver, component;
+ receiver = c_parser_objc_receiver (parser);
+ /* consume '.' operator */
+ c_parser_consume_token (parser);
+ component = c_parser_objc_message_args (parser);
+ expr.value = objc_build_property_reference_expr (receiver, component);
+ expr.original_code = ERROR_MARK;
+ break;
+ }
+ /* APPLE LOCAL end radar 5277239 */
if (c_parser_peek_token (parser)->id_kind != C_ID_ID)
{
c_parser_error (parser, "expected expression");
@@ -5075,6 +5379,34 @@
expr.value = build_external_ref (id,
(c_parser_peek_token (parser)->type
== CPP_OPEN_PAREN), loc);
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ cd) */
+ /* If a variabled declared as referenced variable, using |...| syntax,
+ is used in the block, it has to be derefrenced because this
+ variable holds address of the outside variable referenced in. */
+
+ /* APPLE LOCAL begin radar 5932809 - copyable byref blocks (C++ cd) */
+ if (TREE_CODE (expr.value) == VAR_DECL)
+ {
+ if (BLOCK_DECL_BYREF (expr.value))
+ {
+ tree orig_decl = expr.value;
+ expr.value = build_indirect_ref (expr.value, "unary *");
+ if (COPYABLE_BYREF_LOCAL_VAR (orig_decl)) {
+ /* What we have is an expression which is of type
+ struct __Block_byref_X. Must get to the value of the variable
+ embedded in this structure. It is at:
+ __Block_byref_X.__forwarding->x */
+ expr.value = build_byref_local_var_access (expr.value,
+ DECL_NAME (orig_decl));
+ }
+ }
+ else if (COPYABLE_BYREF_LOCAL_VAR (expr.value))
+ expr.value = build_byref_local_var_access (expr.value,
+ DECL_NAME (expr.value));
+ }
+ /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ cd) */
expr.original_code = ERROR_MARK;
}
break;
@@ -5410,6 +5742,18 @@
break;
}
break;
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ cf) */
+ case CPP_XOR:
+ if (flag_blocks) {
+ expr.value = c_parser_block_literal_expr (parser);
+ expr.original_code = ERROR_MARK;
+ break;
+ }
+ c_parser_error (parser, "expected expression");
+ expr.value = error_mark_node;
+ expr.original_code = ERROR_MARK;
+ break;
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ cf) */
case CPP_OPEN_SQUARE:
if (c_dialect_objc ())
{
@@ -5643,7 +5987,8 @@
objc-protocol-refs and objc-class-instance-variables are omitted. */
static void
-c_parser_objc_class_definition (c_parser *parser)
+/* APPLE LOCAL radar 4548636 - class attributes. */
+c_parser_objc_class_definition (c_parser *parser, tree prefix_attrs)
{
bool iface_p;
tree id1;
@@ -5651,40 +5996,60 @@
if (c_parser_next_token_is_keyword (parser, RID_AT_INTERFACE))
iface_p = true;
else if (c_parser_next_token_is_keyword (parser, RID_AT_IMPLEMENTATION))
- iface_p = false;
+ /* APPLE LOCAL begin radar 4548636 - class attributes. */
+ {
+ if (prefix_attrs)
+ {
+ error ("attributes may not be specified on an implementation");
+ prefix_attrs = NULL_TREE;
+ }
+ iface_p = false;
+ }
+ /* APPLE LOCAL end radar 4548636 - class attributes. */
else
gcc_unreachable ();
c_parser_consume_token (parser);
if (c_parser_next_token_is_not (parser, CPP_NAME))
{
- c_parser_error (parser, "expected identifier");
- return;
- }
- id1 = c_parser_peek_token (parser)->value;
- c_parser_consume_token (parser);
- if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
- {
- tree id2;
+ /* APPLE LOCAL radar 4965989 */
+ tree id2 = NULL_TREE;
tree proto = NULL_TREE;
c_parser_consume_token (parser);
- if (c_parser_next_token_is_not (parser, CPP_NAME))
+ /* APPLE LOCAL begin radar 4965989 */
+ if (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN))
{
- c_parser_error (parser, "expected identifier");
- c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
- return;
+ if (c_parser_next_token_is_not (parser, CPP_NAME))
+ {
+ c_parser_error (parser, "expected identifier");
+ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
+ return;
+ }
+ id2 = c_parser_peek_token (parser)->value;
+ c_parser_consume_token (parser);
}
- id2 = c_parser_peek_token (parser)->value;
- c_parser_consume_token (parser);
+ /* APPLE LOCAL end radar 4965989 */
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
if (!iface_p)
{
+ /* APPLE LOCAL begin radar 4965989 */
+ if (id2 == NULL_TREE)
+ {
+ error ("cannot implement anonymous category");
+ return;
+ }
+ /* APPLE LOCAL end radar 4965989 */
objc_start_category_implementation (id1, id2);
return;
}
if (c_parser_next_token_is (parser, CPP_LESS))
proto = c_parser_objc_protocol_refs (parser);
+ /* APPLE LOCAL begin radar 4548636 - class attributes. */
+ if (prefix_attrs)
+ error ("attributes may not be specified on a category");
+ /* APPLE LOCAL end radar 4548636 - class attributes. */
objc_start_category_interface (id1, id2, proto);
- c_parser_objc_methodprotolist (parser);
+ /* APPLE LOCAL C* property (Radar 4436866) (in 4.2 q) */
+ c_parser_objc_interfacedecllist (parser);
c_parser_require_keyword (parser, RID_AT_END, "expected %<@end%>");
objc_finish_interface ();
return;
@@ -5707,7 +6072,8 @@
tree proto = NULL_TREE;
if (c_parser_next_token_is (parser, CPP_LESS))
proto = c_parser_objc_protocol_refs (parser);
- objc_start_class_interface (id1, superclass, proto);
+ /* APPLE LOCAL radar 4548636 - class attributes. */
+ objc_start_class_interface (id1, superclass, proto, prefix_attrs);
}
else
objc_start_class_implementation (id1, superclass);
@@ -5716,7 +6082,8 @@
if (iface_p)
{
objc_continue_interface ();
- c_parser_objc_methodprotolist (parser);
+ /* APPLE LOCAL C* property (Radar 4436866) (in 4.2 q) */
+ c_parser_objc_interfacedecllist (parser);
c_parser_require_keyword (parser, RID_AT_END, "expected %<@end%>");
objc_finish_interface ();
}
@@ -5727,6 +6094,129 @@
}
}
+/* APPLE LOCAL begin C* property (Radar 4436866) (in 4.2 s) */
+static tree
+c_parser_objc_eq_identifier (c_parser *parser)
+{
+ tree id;
+ if (c_parser_next_token_is_not (parser, CPP_EQ))
+ {
+ c_parser_error (parser, "expected %<=%>");
+ return NULL_TREE;
+ }
+ /* Consume '=' */
+ c_parser_consume_token (parser);
+ if (c_parser_next_token_is_not (parser, CPP_NAME))
+ {
+ c_parser_error (parser, "expected identifier");
+ return NULL_TREE;
+ }
+ id = c_parser_peek_token (parser)->value;
+ c_parser_consume_token (parser);
+ return id;
+}
+
+/* Parse obj-property-attribute.
+*/
+static void
+c_parser_objc_property_attribute (c_parser *parser)
+{
+ tree id;
+ if (c_parser_peek_token (parser)->type != CPP_KEYWORD)
+ {
+ c_parser_error (parser, "expected a property attribute");
+ c_parser_consume_token (parser);
+ return;
+ }
+ switch (c_parser_peek_token (parser)->keyword)
+ {
+ case RID_READONLY:
+ c_parser_consume_token (parser);
+ objc_set_property_attr (1, NULL_TREE);
+ break;
+ case RID_GETTER:
+ c_parser_consume_token (parser);
+ id = c_parser_objc_eq_identifier (parser);
+ if (id)
+ objc_set_property_attr (2, id);
+ break;
+ case RID_SETTER:
+ c_parser_consume_token (parser);
+ id = c_parser_objc_eq_identifier (parser);
+ if (id)
+ objc_set_property_attr (3, id);
+ /* Consume the ':' which must always follow the setter name. */
+ if (c_parser_next_token_is (parser, CPP_COLON))
+ c_parser_consume_token (parser);
+ break;
+ /* APPLE LOCAL begin radar 4947014 - objc atomic property */
+ case RID_NONATOMIC:
+ c_parser_consume_token (parser);
+ objc_set_property_attr (13, NULL_TREE);
+ break;
+ /* APPLE LOCAL end radar 4947014 - objc atomic property */
+ default:
+ c_parser_error (parser, "expected a property attribute");
+ c_parser_consume_token (parser);
+ }
+}
+
+static void
+c_parser_objc_property_attrlist (c_parser *parser)
+{
+ while (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN)
+ && c_parser_next_token_is_not (parser, CPP_EOF))
+ {
+ c_parser_objc_property_attribute (parser);
+ /* APPLE LOCAL begin radar 6302949 */
+ if (c_parser_next_token_is_not (parser, CPP_COMMA)
+ && c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN)
+ && c_parser_next_token_is_not (parser, CPP_EOF))
+ warning (0, "property attributes must be separated by a comma");
+ /* APPLE LOCAL end radar 6302949 */
+ if (c_parser_next_token_is (parser, CPP_COMMA)
+ || c_parser_next_token_is (parser, CPP_NAME) /* error */)
+ c_parser_consume_token (parser);
+ }
+}
+
+static void
+c_parser_objc_property_attr_decl (c_parser *parser)
+{
+ if (!c_parser_next_token_is (parser, CPP_OPEN_PAREN))
+ return;
+ c_parser_consume_token (parser);
+ c_parser_objc_property_attrlist (parser);
+ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
+}
+
+static tree
+c_parser_component_decl (c_parser *parser)
+{
+ tree decl = c_parser_struct_declaration (parser);
+ return decl;
+}
+
+static void
+c_parser_objc_property_declaration (c_parser *parser)
+{
+ tree prop;
+ c_parser_require_keyword (parser, RID_AT_PROPERTY, "expected %<@property%>");
+ objc_property_attr_context = 1;
+ objc_set_property_attr (0, NULL_TREE);
+ c_parser_objc_property_attr_decl (parser);
+ objc_property_attr_context = 0;
+ prop = c_parser_component_decl (parser);
+ /* Comma-separated properties are chained together in
+ reverse order; add them one by one. */
+ prop = nreverse (prop);
+
+ for (; prop; prop = TREE_CHAIN (prop))
+ objc_add_property_variable (copy_node (prop));
+ c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
+}
+/* APPLE LOCAL end C* property (Radar 4436866) (in 4.2 s) */
+
/* Parse objc-class-instance-variables.
objc-class-instance-variables:
@@ -5790,6 +6280,14 @@
objc_set_visibility (1);
continue;
}
+ /* APPLE LOCAL begin radar 4564694 */
+ else if (c_parser_next_token_is_keyword (parser, RID_AT_PACKAGE))
+ {
+ c_parser_consume_token (parser);
+ objc_set_visibility (3);
+ continue;
+ }
+ /* APPLE LOCAL end radar 4564694 */
else if (c_parser_next_token_is (parser, CPP_PRAGMA))
{
c_parser_pragma (parser, pragma_external);
@@ -5887,7 +6385,8 @@
omitted. */
static void
-c_parser_objc_protocol_definition (c_parser *parser)
+/* APPLE LOCAL radar 4947311 - protocol attributes */
+c_parser_objc_protocol_definition (c_parser *parser, tree attributes)
{
gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_PROTOCOL));
c_parser_consume_token (parser);
@@ -5919,7 +6418,8 @@
break;
}
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
- objc_declare_protocols (list);
+ /* APPLE LOCAL radar 4947311 - protocol attributes */
+ objc_declare_protocols (list, attributes);
}
else
{
@@ -5929,8 +6429,10 @@
if (c_parser_next_token_is (parser, CPP_LESS))
proto = c_parser_objc_protocol_refs (parser);
objc_pq_context = 1;
- objc_start_protocol (id, proto);
- c_parser_objc_methodprotolist (parser);
+ /* APPLE LOCAL radar 4947311 - protocol attributes */
+ objc_start_protocol (id, proto, attributes);
+ /* APPLE LOCAL C* property (Radar 4436866) (in 4.2 r) */
+ c_parser_objc_interfacedecllist (parser);
c_parser_require_keyword (parser, RID_AT_END, "expected %<@end%>");
objc_pq_context = 0;
objc_finish_interface ();
@@ -5986,11 +6488,28 @@
return;
}
objc_pq_context = 0;
- objc_start_method_definition (decl);
+ /* APPLE LOCAL begin radar 3803157 - objc attribute (in 4.2 a) */
+ objc_start_method_definition (decl, objc_method_attributes);
+ objc_method_attributes = NULL_TREE;
+ /* APPLE LOCAL end radar 3803157 - objc attribute (in 4.2 a) */
add_stmt (c_parser_compound_statement (parser));
objc_finish_method_definition (current_function_decl);
}
+/* APPLE LOCAL begin C* language (in 4.2 w) */
+/* True iff the gioven TOKEN starts a methodproto. */
+
+static bool
+c_token_starts_methodproto (c_token *token)
+{
+ return token->type == CPP_PLUS
+ || token->type == CPP_MINUS
+ || (token->type == CPP_KEYWORD
+ && (token->keyword == RID_AT_REQUIRED
+ || token->keyword == RID_AT_OPTIONAL));
+}
+/* APPLE LOCAL end C* language (in 4.2 w) */
+
/* Parse an objc-methodprotolist.
objc-methodprotolist:
@@ -6006,10 +6525,29 @@
function. */
static void
-c_parser_objc_methodprotolist (c_parser *parser)
+/* APPLE LOCAL C* property (Radar 4436866) (in 4.2 b) */
+c_parser_objc_interfacedecllist (c_parser *parser)
{
while (true)
{
+ /* APPLE LOCAL begin C* property (Radar 4436866) (in 4.2 b) */
+ c_token *token;
+ token = c_parser_peek_token (parser);
+ if (token->type == CPP_KEYWORD
+ && token->keyword == RID_AT_PROPERTY)
+ {
+ c_parser_objc_property_declaration (parser);
+ continue;
+ }
+ /* APPLE LOCAL end C* property (Radar 4436866) (in 4.2 b) */
+ /* APPLE LOCAL begin C* language (in 4.2 w) */
+ if (c_token_starts_methodproto (token))
+ {
+ c_parser_objc_methodproto (parser);
+ continue;
+ }
+ /* APPLE LOCAL end C* language (in 4.2 w) */
+
/* The list is terminated by @end. */
switch (c_parser_peek_token (parser)->type)
{
@@ -6018,10 +6556,9 @@
pedwarn ("ISO C does not allow extra %<;%> outside of a function");
c_parser_consume_token (parser);
break;
- case CPP_PLUS:
- case CPP_MINUS:
- c_parser_objc_methodproto (parser);
- break;
+ /* APPLE LOCAL begin C* language (in 4.2 w) */
+ /* CPP_PLUS and CPP_MINUS deleted */
+ /* APPLE LOCAL end C* language (in 4.2 w) */
case CPP_PRAGMA:
c_parser_pragma (parser, pragma_external);
break;
@@ -6030,7 +6567,8 @@
default:
if (c_parser_next_token_is_keyword (parser, RID_AT_END))
return;
- c_parser_declaration_or_fndef (parser, false, true, false, true);
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ c_parser_declaration_or_fndef (parser, false, true, false, true, NULL);
break;
}
}
@@ -6045,8 +6583,25 @@
static void
c_parser_objc_methodproto (c_parser *parser)
{
- enum tree_code type = c_parser_objc_method_type (parser);
+ /* APPLE LOCAL C* language */
+ enum tree_code type;
tree decl;
+ /* APPLE LOCAL begin C* language */
+ if (c_parser_next_token_is_keyword (parser, RID_AT_REQUIRED))
+ {
+ objc_set_method_opt (0);
+ c_parser_consume_token (parser);
+ return;
+ }
+ if (c_parser_next_token_is_keyword (parser, RID_AT_OPTIONAL))
+ {
+ objc_set_method_opt (1);
+ c_parser_consume_token (parser);
+ return;
+ }
+ /* APPLE LOCAL begin C* language */
+ /* APPLE LOCAL C* language */
+ type = c_parser_objc_method_type (parser);
objc_set_method_type (type);
/* Remember protocol qualifiers in prototypes. */
objc_pq_context = 1;
@@ -6053,7 +6608,10 @@
decl = c_parser_objc_method_decl (parser);
/* Forget protocol qualifiers here. */
objc_pq_context = 0;
- objc_add_method_declaration (decl);
+ /* APPLE LOCAL begin radar 3803157 - objc attribute (in 4.2 c) */
+ objc_add_method_declaration (decl, objc_method_attributes);
+ objc_method_attributes = NULL_TREE;
+ /* APPLE LOCAL end radar 3803157 - objc attribute (in 4.2 c) */
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
@@ -6111,6 +6669,8 @@
tree list = NULL_TREE;
while (true)
{
+ /* APPLE LOCAL radar 4157812 */
+ tree attr = NULL_TREE;
tree atype = NULL_TREE, id, keyworddecl;
if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
break;
@@ -6121,6 +6681,10 @@
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
}
+ /* APPLE LOCAL begin radar 4157812 */
+ if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
+ attr = c_parser_attributes (parser);
+ /* APPLE LOCAL end radar 4157812 */
if (c_parser_next_token_is_not (parser, CPP_NAME))
{
c_parser_error (parser, "expected identifier");
@@ -6128,12 +6692,17 @@
}
id = c_parser_peek_token (parser)->value;
c_parser_consume_token (parser);
- keyworddecl = objc_build_keyword_decl (tsel, atype, id);
+ /* APPLE LOCAL radar 4157812 */
+ keyworddecl = objc_build_keyword_decl (tsel, atype, id, attr);
list = chainon (list, keyworddecl);
tsel = c_parser_objc_selector (parser);
if (!tsel && c_parser_next_token_is_not (parser, CPP_COLON))
break;
}
+ /* APPLE LOCAL begin radar 3803157 - objc attribute (in 4.2 y) */
+ if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
+ objc_method_attributes = c_parser_attributes (parser);
+ /* APPLE LOCAL end radar 3803157 - objc attribute (in 4.2 y) */
/* Parse the optional parameter list. Optional Objective-C
method parameters follow the C syntax, and may include '...'
to denote a variable number of arguments. */
@@ -6146,6 +6715,12 @@
{
ellipsis = true;
c_parser_consume_token (parser);
+ /* APPLE LOCAL end radar 3803157 - objc attribute (in 4.2 y) */
+ if (objc_method_attributes)
+ error ("method attributes must be specified at the end only");
+ if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
+ objc_method_attributes = c_parser_attributes (parser);
+ /* APPLE LOCAL end radar 3803157 - objc attribute (in 4.2 y) */
break;
}
parm = c_parser_parameter_declaration (parser, NULL_TREE);
@@ -6156,6 +6731,21 @@
}
sel = list;
}
+ /* APPLE LOCAL begin radar 3803157 - objc attribute (in 4.2 y) */
+ else
+ {
+ gcc_assert (objc_method_attributes == NULL_TREE);
+ if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
+ objc_method_attributes = c_parser_attributes (parser);
+ }
+ /* APPLE LOCAL end radar 3803157 - objc attribute (in 4.2 y) */
+ /* APPLE LOCAL begin radar 4157812 */
+ if (sel == NULL)
+ {
+ c_parser_error (parser, "objective-c method declaration is expected");
+ return error_mark_node;
+ }
+ /* APPLE LOCAL end radar 4157812 */
return objc_build_method_signature (type, sel, parms, ellipsis);
}
@@ -6190,7 +6780,8 @@
|| token->keyword == RID_BYREF
|| token->keyword == RID_ONEWAY))
{
- quals = chainon (quals, build_tree_list (NULL_TREE, token->value));
+ /* APPLE LOCAL radar 4301047 (in 4.2 z) */
+ quals = chainon (build_tree_list (NULL_TREE, token->value), quals);
c_parser_consume_token (parser);
}
else
@@ -6264,14 +6855,26 @@
c_parser_consume_token (parser);
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
break;
- parm = c_parser_parameter_declaration (parser, NULL_TREE);
- if (parm == NULL)
+ /* APPLE LOCAL begin radar 2848255 */
+ if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
{
- c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
- break;
+ /* @catch (...) */
+ c_parser_consume_token (parser);
+ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
+ objc_begin_catch_clause (NULL_TREE);
}
- c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
- objc_begin_catch_clause (grokparm (parm));
+ else
+ {
+ parm = c_parser_parameter_declaration (parser, NULL_TREE);
+ if (parm == NULL)
+ {
+ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
+ break;
+ }
+ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
+ objc_begin_catch_clause (grokparm (parm));
+ }
+ /* APPLE LOCAL end radar 2848255 */
if (c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
c_parser_compound_statement_nostart (parser);
objc_finish_catch_clause ();
@@ -6288,6 +6891,26 @@
objc_finish_try_stmt ();
}
+/* APPLE LOCAL begin radar 5982990 */
+/* This routine is called from c_parser_objc_synchronized_statement
+ and is identical to c_parser_compound_statement with
+ the addition of volatizing local variables seen in the scope
+ of @synchroniz block.
+*/
+static tree
+c_parser_objc_synch_compound_statement (c_parser *parser)
+{
+ tree stmt;
+ if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
+ return error_mark_node;
+ stmt = c_begin_compound_stmt (true);
+ c_parser_compound_statement_nostart (parser);
+ if (flag_objc_sjlj_exceptions)
+ objc_mark_locals_volatile (NULL);
+ return c_end_compound_stmt (stmt, true);
+}
+/* APPLE LOCAL end radar 5982990 */
+
/* Parse an objc-synchronized-statement.
objc-synchronized-statement:
@@ -6309,7 +6932,8 @@
}
else
expr = error_mark_node;
- stmt = c_parser_compound_statement (parser);
+ /* APPLE LOCAL radar 5982990 */
+ stmt = c_parser_objc_synch_compound_statement (parser);
objc_build_synchronized (loc, expr, stmt);
}
@@ -7396,7 +8020,8 @@
/* Parse the initialization declaration or expression. */
if (c_parser_next_token_starts_declspecs (parser))
{
- c_parser_declaration_or_fndef (parser, true, true, true, true);
+ /* APPLE LOCAL radar 4708210 (for_objc_collection in 4.2) */
+ c_parser_declaration_or_fndef (parser, true, true, true, true, NULL);
decl = check_for_loop_decls ();
if (decl == NULL)
goto error_init;
@@ -7865,4 +8490,980 @@
the_parser = NULL;
}
+/* APPLE LOCAL begin radar 5732232 - blocks (C++ ce) */
+
+/* APPLE LOCAL begin radar 6300081 */
+
+/* This function builds a "generic" block struct type, to be passed
+ into the debug information for blocks pointers, to allow gdb to
+ find the actual function pointer for the block. Any time the Blocks
+ structure layout changes, this may also need to change.
+
+ Currently a block pointer is a pointer to a __block_literal_n struct,
+ the third field of which is a pointer to a __block_descriptor struct,
+ whose third field is the function pointer. There are other fields as
+ well, but these are the ones gdb needs to know about to find the
+ function pointer. Therefore a generic block struct currently looks
+ like this:
+
+ struct __block_literal_generic
+ {
+ void * __isa;
+ int __flags;
+ int __reserved;
+ void (*__FuncPtr)(void *);
+ struct __block_descriptor
+ {
+ unsigned long int reserved;
+ unsigned long int Size;
+ } *__descriptor;
+ };
+
+ IF AT ANY TIME THE STRUCTURE OF A __BLOCK_LITERAL_N CHANGES, THIS
+ MUST BE CHANGED ALSO!!
+
+*/
+
+tree
+/* APPLE LOCAL radar 6353006 */
+c_build_generic_block_struct_type (void)
+{
+ tree field_decl_chain;
+ tree field_decl;
+ tree block_struct_type;
+
+ push_to_top_level ();
+ block_struct_type = start_struct (RECORD_TYPE,
+ get_identifier ("__block_literal_generic"));
+
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__isa"), ptr_type_node);
+ field_decl_chain = field_decl;
+
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__flags"),
+ integer_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__reserved"),
+ integer_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ /* void *__FuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__FuncPtr"), ptr_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__descriptor"),
+ build_block_descriptor_type (false));
+ chainon (field_decl_chain, field_decl);
+
+ TYPE_BLOCK_IMPL_STRUCT (block_struct_type) = 1;
+ finish_struct (block_struct_type, field_decl_chain, NULL_TREE);
+ pop_from_top_level ();
+ return block_struct_type;
+}
+/* APPLE LOCAL end radar 6300081 */
+
+/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
+/** build_block_struct_type -
+ struct __block_literal_n {
+ void *__isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
+ int __flags;
+ int __reserved;
+ void *__FuncPtr;
+ struct __block_descriptor {
+ unsigned long int reserved; // NULL
+ unsigned long int Size; // sizeof(struct __block_literal_n)
+
+ // optional helper functions
+ void *CopyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ void *DestroyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ } *__descriptor;
+
+ // imported variables
+ int x; // ref variable list ...
+ int *y; // byref variable list
+ };
+*/
+static tree
+build_block_struct_type (struct block_sema_info * block_impl)
+{
+ tree field_decl_chain, field_decl, chain;
+ char buffer[32];
+ static int unique_count;
+ tree block_struct_type;
+
+ /* Check and see if this block is required to have a Copy/Dispose
+ helper function. If yes, set BlockHasCopyDispose to TRUE. */
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (block_requires_copying (TREE_VALUE (chain)))
+ {
+ block_impl->BlockHasCopyDispose = TRUE;
+ break;
+ }
+
+ /* Further check to see that we have __block variables which require
+ Copy/Dispose helpers. */
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
+ {
+ block_impl->BlockHasCopyDispose = TRUE;
+ break;
+ }
+
+ sprintf(buffer, "__block_literal_%d", ++unique_count);
+ push_to_top_level ();
+ block_struct_type = start_struct (RECORD_TYPE, get_identifier (buffer));
+
+ /* void *__isa; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__isa"), ptr_type_node);
+ field_decl_chain = field_decl;
+
+ /* int __flags */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__flags"),
+ integer_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ /* int __reserved */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__reserved"),
+ integer_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ /* void *__FuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__FuncPtr"), ptr_type_node);
+ chainon (field_decl_chain, field_decl);
+
+ /* struct __block_descriptor *__descriptor */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("__descriptor"),
+ build_block_descriptor_type (block_impl->BlockHasCopyDispose));
+ chainon (field_decl_chain, field_decl);
+
+ if (block_impl->BlockHasCopyDispose)
+ {
+ /* If inner block of a nested block has BlockHasCopyDispose, so
+ does its outer block. */
+ if (block_impl->prev_block_info)
+ block_impl->prev_block_info->BlockHasCopyDispose = TRUE;
+ }
+
+ /* int x; // ref variable list ... */
+ for (chain = block_impl->block_ref_decl_list; chain; chain = TREE_CHAIN (chain))
+ {
+ tree p = TREE_VALUE (chain);
+ /* Note! const-ness of copied in variable must not be carried over to the
+ type of the synthesized struct field. It prevents to assign to this
+ field when copy constructor is synthesized. */
+ field_decl = build_decl (FIELD_DECL, DECL_NAME (p),
+ c_build_qualified_type (TREE_TYPE (p),
+ TYPE_UNQUALIFIED));
+ chainon (field_decl_chain, field_decl);
+ }
+
+ /* int *y; // byref variable list */
+ for (chain = block_impl->block_byref_decl_list; chain; chain = TREE_CHAIN (chain))
+ {
+ tree p = TREE_VALUE (chain);
+ field_decl = build_decl (FIELD_DECL, DECL_NAME (p),
+ TREE_TYPE (p));
+ chainon (field_decl_chain, field_decl);
+ }
+ pop_from_top_level ();
+ finish_struct (block_struct_type, field_decl_chain, NULL_TREE);
+ return block_struct_type;
+}
+
+/** build_descriptor_block_decl -
+ This routine builds a static block_descriptior variable of type:
+ struct __block_descriptor; and initializes it to:
+ {0, sizeof(struct literal_block_n),
+ copy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
+ destroy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
+ }
+*/
+static tree
+build_descriptor_block_decl (tree block_struct_type, struct block_sema_info *block_impl)
+{
+ extern tree create_tmp_var_raw (tree, const char *);
+ static int desc_unique_count;
+ int size;
+ tree helper_addr, fields;
+ tree decl, constructor, initlist;
+ tree exp, bind;
+ char name [32];
+ tree descriptor_type =
+ TREE_TYPE (build_block_descriptor_type (block_impl->BlockHasCopyDispose));
+
+ sprintf (name, "__block_descriptor_tmp_%d", ++desc_unique_count);
+ decl = create_tmp_var_raw (descriptor_type, name);
+ DECL_CONTEXT (decl) = NULL_TREE;
+ DECL_ARTIFICIAL (decl) = 1;
+
+ /* Initialize "reserved" field to 0 for now. */
+ fields = TYPE_FIELDS (descriptor_type);
+ initlist = build_tree_list (fields, build_int_cst (long_unsigned_type_node, 0));
+ fields = TREE_CHAIN (fields);
+
+ /* Initialize "Size" field. */
+ size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (block_struct_type));
+ initlist = tree_cons (fields,
+ build_int_cst (long_unsigned_type_node, size),
+ initlist);
+
+ if (block_impl->BlockHasCopyDispose)
+ {
+ /* Initialize "CopyFuncPtr" and "DestroyFuncPtr" fields. */
+ /* Helpers were previously generated completeley as a nested
+ function (and context was required for code gen.) But they are not,
+ so context must be set to NULL so initialization logic does not complain. */
+ DECL_CONTEXT (block_impl->copy_helper_func_decl) = NULL_TREE;
+ fields = TREE_CHAIN (fields);
+ helper_addr = build_fold_addr_expr (block_impl->copy_helper_func_decl);
+ helper_addr = convert (ptr_type_node, helper_addr);
+ initlist = tree_cons (fields, helper_addr, initlist);
+ DECL_CONTEXT (block_impl->destroy_helper_func_decl) = NULL_TREE;
+ fields = TREE_CHAIN (fields);
+ helper_addr = build_fold_addr_expr (block_impl->destroy_helper_func_decl);
+ helper_addr = convert (ptr_type_node, helper_addr);
+ initlist = tree_cons (fields, helper_addr, initlist);
+ }
+ constructor = build_constructor_from_list (descriptor_type,
+ nreverse (initlist));
+ TREE_CONSTANT (constructor) = 1;
+ TREE_STATIC (constructor) = 1;
+ TREE_READONLY (constructor) = 1;
+ DECL_INITIAL (decl) = constructor;
+ exp = build_stmt (DECL_EXPR, decl);
+ bind = build3 (BIND_EXPR, void_type_node, decl, exp, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+ TREE_PUBLIC (decl) = 0;
+ TREE_STATIC (decl) = 1;
+ finish_decl (decl, constructor, NULL_TREE);
+ return decl;
+}
+
+/**
+ build_block_struct_initlist - builds the initializer list:
+ { &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // __isa,
+ BLOCK_USE_STRET | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // __flags,
+ 0, // __reserved
+ &helper_1, // __FuncPtr,
+ &static_descriptor_variable // __descriptor,
+ x, // user variables.
+ &y
+ ...
+ }
+*/
+static tree
+build_block_struct_initlist (tree block_struct_type,
+ struct block_sema_info *block_impl)
+{
+ tree initlist, helper_addr;
+ tree chain, fields;
+ /* APPLE LOCAL radar 7735196 */
+ unsigned int flags = 0;
+ static tree NSConcreteStackBlock_decl = NULL_TREE;
+ static tree NSConcreteGlobalBlock_decl = NULL_TREE;
+ tree descriptor_block_decl = build_descriptor_block_decl (block_struct_type, block_impl);
+
+ if (block_impl->BlockHasCopyDispose)
+ /* Note! setting of this flag merely indicates to the runtime that
+ we have destroy_helper_block/copy_helper_block helper
+ routines. */
+ flags |= BLOCK_HAS_COPY_DISPOSE;
+ /* APPLE LOCAL begin radar 7735196 */
+ if (block_impl->return_type && aggregate_value_p(block_impl->return_type, 0))
+ flags |= BLOCK_USE_STRET;
+ /* APPLE LOCAL end 7735196 */
+
+ fields = TYPE_FIELDS (block_struct_type);
+ /* APPLE LOCAL begin radar 6230297 */
+ if (!current_function_decl ||
+ (block_impl->block_ref_decl_list == NULL_TREE &&
+ block_impl->block_byref_decl_list == NULL_TREE))
+ /* APPLE LOCAL end radar 6230297 */
+ {
+ /* This is a global block. */
+ /* Find an existing declaration for _NSConcreteGlobalBlock or declare
+ extern void *_NSConcreteGlobalBlock; */
+ if (NSConcreteGlobalBlock_decl == NULL_TREE)
+ {
+ tree name_id = get_identifier("_NSConcreteGlobalBlock");
+ NSConcreteGlobalBlock_decl = lookup_name (name_id);
+ if (!NSConcreteGlobalBlock_decl)
+ {
+ NSConcreteGlobalBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+ DECL_EXTERNAL (NSConcreteGlobalBlock_decl) = 1;
+ TREE_PUBLIC (NSConcreteGlobalBlock_decl) = 1;
+ pushdecl_top_level (NSConcreteGlobalBlock_decl);
+ rest_of_decl_compilation (NSConcreteGlobalBlock_decl, 0, 0);
+ }
+ }
+ /* APPLE LOCAL begin radar 6457359 */
+ initlist = build_tree_list (fields,
+ convert (ptr_type_node,
+ build_fold_addr_expr (NSConcreteGlobalBlock_decl)));
+ /* APPLE LOCAL end radar 6457359 */
+ flags |= BLOCK_IS_GLOBAL;
+ }
+ else
+ {
+ /* Find an existing declaration for _NSConcreteStackBlock or declare
+ extern void *_NSConcreteStackBlock; */
+ if (NSConcreteStackBlock_decl == NULL_TREE)
+ {
+ tree name_id = get_identifier("_NSConcreteStackBlock");
+ NSConcreteStackBlock_decl = lookup_name (name_id);
+ if (!NSConcreteStackBlock_decl)
+ {
+ NSConcreteStackBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+ DECL_EXTERNAL (NSConcreteStackBlock_decl) = 1;
+ TREE_PUBLIC (NSConcreteStackBlock_decl) = 1;
+ pushdecl_top_level (NSConcreteStackBlock_decl);
+ rest_of_decl_compilation (NSConcreteStackBlock_decl, 0, 0);
+ }
+ }
+ /* APPLE LOCAL begin radar 6457359 */
+ initlist = build_tree_list (fields,
+ convert (ptr_type_node,
+ build_fold_addr_expr (NSConcreteStackBlock_decl)));
+ /* APPLE LOCAL end radar 6457359 */
+ }
+ fields = TREE_CHAIN (fields);
+
+ /* __flags */
+ initlist = tree_cons (fields,
+ build_int_cst (integer_type_node, flags),
+ initlist);
+ fields = TREE_CHAIN (fields);
+
+ /* __reserved */
+ initlist = tree_cons (fields,
+ build_int_cst (integer_type_node, 0),
+ initlist);
+ fields = TREE_CHAIN (fields);
+
+ /* __FuncPtr */
+ helper_addr = build_fold_addr_expr (block_impl->helper_func_decl);
+ helper_addr = convert (ptr_type_node, helper_addr);
+ initlist = tree_cons (fields, helper_addr, initlist);
+ fields = TREE_CHAIN (fields);
+
+ /* __descriptor */
+ /* APPLE LOCAL begin radar 6457359 */
+ initlist = tree_cons (fields,
+ build_fold_addr_expr (descriptor_block_decl),
+ initlist);
+ /* APPLE LOCAL end radar 6457359 */
+ for (chain = block_impl->block_original_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ {
+ tree y = TREE_VALUE (chain);
+ TREE_USED (y) = 1;
+ fields = TREE_CHAIN (fields);
+ initlist = tree_cons (fields, y, initlist);
+ }
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ {
+ tree y = lookup_name (DECL_NAME (TREE_VALUE (chain)));
+ tree forwarding_expr;
+ gcc_assert (y);
+ TREE_USED (y) = 1;
+ if (COPYABLE_BYREF_LOCAL_VAR (y))
+ {
+ /* For variables declared __block, either the original one
+ at the point of declaration or the imported version (which is
+ initialized in the helper function's prologue) is used to
+ initilize the byref variable field in the temporary. */
+ if (TREE_CODE (TREE_TYPE (y)) != RECORD_TYPE)
+ y = build_indirect_ref (y, "unary *");
+ /* We will be using the __block_struct_variable.__forwarding as the
+ initializer. */
+ forwarding_expr = build_component_ref (y, get_identifier ("__forwarding"));
+ }
+ else
+ /* Global variable is always assumed passed by its address. */
+ forwarding_expr = build_fold_addr_expr (y);
+ fields = TREE_CHAIN (fields);
+ initlist = tree_cons (fields, forwarding_expr, initlist);
+ }
+ return initlist;
+}
+
+/**
+ build_block_literal_tmp - This routine:
+
+ 1) builds block type:
+ struct __block_literal_n {
+ void *__isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
+ int __flags;
+ int __reserved;
+ void *__FuncPtr
+ struct __block_descriptor {
+ unsigned long int reserved; // NULL
+ unsigned long int Size; // sizeof(struct Block_literal_1)
+
+ // optional helper functions
+ void *CopyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ void *DestroyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ } *__descriptor;
+
+ // imported variables
+ int x; // ref variable list ...
+ int *y; // byref variable list
+ };
+
+ 2) build function prototype:
+ double helper_1(struct __block_literal_n *ii, int z);
+
+ 3) build the temporary initialization:
+ struct __block_literal_n I = {
+ &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // __isa,
+ BLOCK_USE_STRET | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // __flags,
+ 0, // __reserved
+ &helper_1, // __FuncPtr
+ &static_descriptor_variable // __descriptor,
+ x, // user variables.
+ &y
+ ...
+ };
+It return the temporary.
+*/
+
+static tree
+build_block_literal_tmp (const char *name,
+ struct block_sema_info * block_impl)
+{
+ extern tree create_tmp_var_raw (tree, const char *);
+ tree block_holder_tmp_decl;
+ tree constructor, initlist;
+ tree exp, bind;
+ tree block_struct_type = TREE_TYPE (block_impl->block_arg_ptr_type);
+ /* APPLE LOCAL begin radar 6230297 */
+ bool staticBlockTmp = (block_impl->block_ref_decl_list == NULL_TREE &&
+ block_impl->block_byref_decl_list == NULL_TREE);
+
+
+ block_holder_tmp_decl = create_tmp_var_raw (block_struct_type, name);
+ /* Context will not be known until when the literal is synthesized.
+ This is more so in the case of nested block literal blocks. */
+ DECL_CONTEXT (block_holder_tmp_decl) = staticBlockTmp ? NULL_TREE
+ : current_function_decl;
+ /* In the new ABI, helper function decl. is the initializer for the
+ descriptor variable which is always declared static. So, it must
+ have no context; otherwise, gcc thinks that it requires trampoline! when
+ address of this function is used as initializer. */
+ DECL_CONTEXT (block_impl->helper_func_decl) = NULL_TREE;
+ /* APPLE LOCAL end radar 6230297 */
+ DECL_ARTIFICIAL (block_holder_tmp_decl) = 1;
+
+ initlist = build_block_struct_initlist (block_struct_type,
+ block_impl);
+ initlist = nreverse (initlist);
+ constructor = build_constructor_from_list (block_struct_type,
+ initlist);
+ TREE_CONSTANT (constructor) = 1;
+ TREE_STATIC (constructor) = 1;
+ TREE_READONLY (constructor) = 1;
+ DECL_INITIAL (block_holder_tmp_decl) = constructor;
+ exp = build_stmt (DECL_EXPR, block_holder_tmp_decl);
+ bind = build3 (BIND_EXPR, void_type_node, block_holder_tmp_decl, exp, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+ /* Temporary representing a global block is made global static. */
+ /* APPLE LOCAL radar 6230297 */
+ if (staticBlockTmp || global_bindings_p ()) {
+ TREE_PUBLIC (block_holder_tmp_decl) = 0;
+ TREE_STATIC (block_holder_tmp_decl) = 1;
+ finish_decl (block_holder_tmp_decl, constructor, NULL_TREE);
+ }
+ return block_holder_tmp_decl;
+}
+/* APPLE LOCAL end radar 5847213 - radar 6329245 */
+
+static tree
+clean_and_exit (tree block)
+{
+ pop_function_context ();
+ free (finish_block (block));
+ return error_mark_node;
+}
+
+/** synth_copy_helper_block_func - This function synthesizes
+ void copy_helper_block (struct block* _dest, struct block *_src) function.
+*/
+
+static void
+synth_copy_helper_block_func (struct block_sema_info * block_impl)
+{
+ tree stmt, chain, fnbody;
+ tree dst_arg, src_arg;
+ struct c_arg_info * arg_info;
+ /* Set up: (struct block* _dest, struct block *_src) parameters. */
+ dst_arg = build_decl (PARM_DECL, get_identifier ("_dst"),
+ block_impl->block_arg_ptr_type);
+ DECL_CONTEXT (dst_arg) = cur_block->copy_helper_func_decl;
+ TREE_USED (dst_arg) = 1;
+ DECL_ARG_TYPE (dst_arg) = block_impl->block_arg_ptr_type;
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ block_impl->block_arg_ptr_type);
+ /* APPLE LOCAL radar 5847213 */
+ DECL_CONTEXT (src_arg) = cur_block->copy_helper_func_decl;
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = block_impl->block_arg_ptr_type;
+ arg_info = xcalloc (1, sizeof (struct c_arg_info));
+ TREE_CHAIN (dst_arg) = src_arg;
+ arg_info->parms = dst_arg;
+ arg_info->types = tree_cons (NULL_TREE, block_impl->block_arg_ptr_type,
+ tree_cons (NULL_TREE,
+ block_impl->block_arg_ptr_type,
+ NULL_TREE));
+ /* function header synthesis. */
+ push_function_context ();
+ start_block_helper_function (cur_block->copy_helper_func_decl);
+ store_parm_decls_from (arg_info);
+
+ /* Body of the function. */
+ stmt = c_begin_compound_stmt (true);
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (block_requires_copying (TREE_VALUE (chain)))
+ {
+ /* APPLE LOCAL begin radar 6175959 */
+ int flag;
+ tree call_exp;
+ tree p = TREE_VALUE (chain);
+ tree dst_block_component, src_block_component;
+ dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
+ DECL_NAME (p));
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+
+ if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
+ /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_BLOCK) */
+ flag = BLOCK_FIELD_IS_BLOCK;
+ else
+ /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_OBJECT) */
+ flag = BLOCK_FIELD_IS_OBJECT;
+ dst_block_component = build_fold_addr_expr (dst_block_component);
+ call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
+ add_stmt (call_exp);
+ /* APPLE LOCAL end radar 6175959 */
+ }
+
+ /* For each __block declared variable must generate call to:
+ _Block_object_assign(&_dest->myImportedBlock, _src->myImportedBlock, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK])
+ */
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
+ {
+ int flag = BLOCK_FIELD_IS_BYREF;
+ tree call_exp;
+ tree p = TREE_VALUE (chain);
+ tree dst_block_component, src_block_component;
+ dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
+ DECL_NAME (p));
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+
+ /* _Block_object_assign(&_dest->myImportedClosure, _src->myImportedClosure, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK]) */
+ if (COPYABLE_WEAK_BLOCK (p))
+ flag |= BLOCK_FIELD_IS_WEAK;
+
+ dst_block_component = build_fold_addr_expr (dst_block_component);
+ call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
+ add_stmt (call_exp);
+ }
+
+ fnbody = c_end_compound_stmt (stmt, true);
+ add_stmt (fnbody);
+ finish_function ();
+ pop_function_context ();
+ free (arg_info);
+}
+
+static void
+synth_destroy_helper_block_func (struct block_sema_info * block_impl)
+{
+ tree stmt, chain, fnbody;
+ tree src_arg;
+ struct c_arg_info * arg_info;
+ /* Set up: (struct block *_src) parameter. */
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ block_impl->block_arg_ptr_type);
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = block_impl->block_arg_ptr_type;
+ arg_info = xcalloc (1, sizeof (struct c_arg_info));
+ arg_info->parms = src_arg;
+ arg_info->types = tree_cons (NULL_TREE, block_impl->block_arg_ptr_type,
+ NULL_TREE);
+
+ /* function header synthesis. */
+ push_function_context ();
+ start_block_helper_function (cur_block->destroy_helper_func_decl);
+ store_parm_decls_from (arg_info);
+
+ /* Body of the function. */
+ stmt = c_begin_compound_stmt (true);
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (block_requires_copying (TREE_VALUE (chain)))
+ {
+ int flag;
+ tree rel_exp;
+ tree p = TREE_VALUE (chain);
+ tree src_block_component;
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+
+ if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
+ /* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_BLOCK); */
+ flag = BLOCK_FIELD_IS_BLOCK;
+ else
+ /* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_OBJECT); */
+ flag = BLOCK_FIELD_IS_OBJECT;
+ rel_exp = build_block_object_dispose_call_exp (src_block_component, flag);
+ add_stmt (rel_exp);
+ }
+
+ /* For each __block declared variable must generate call to:
+ _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK])
+ */
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
+ {
+ tree call_exp;
+ int flag = BLOCK_FIELD_IS_BYREF;
+ tree p = TREE_VALUE (chain);
+ tree src_block_component;
+
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+ if (COPYABLE_WEAK_BLOCK (p))
+ flag |= BLOCK_FIELD_IS_WEAK;
+ /* _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK]) */
+ call_exp = build_block_object_dispose_call_exp (src_block_component, flag);
+ add_stmt (call_exp);
+ }
+
+ fnbody = c_end_compound_stmt (stmt, true);
+ add_stmt (fnbody);
+ finish_function ();
+ pop_function_context ();
+ free (arg_info);
+}
+
+/* Parse a block-id.
+
+ GNU Extension:
+
+ block-id:
+ specifier-qualifier-list block-declarator
+
+ Returns the DECL specified or implied. */
+
+static tree
+c_parser_block_id (c_parser* parser)
+{
+ struct c_declspecs *specs = build_null_declspecs ();
+ struct c_declarator *declarator;
+ bool dummy = false;
+
+ c_parser_declspecs (parser, specs, false, true, true);
+ if (!specs->declspecs_seen_p)
+ {
+ c_parser_error (parser, "expected specifier-qualifier-list");
+ return NULL;
+ }
+ pending_xref_error ();
+ finish_declspecs (specs);
+ declarator = c_parser_declarator (parser, specs->type_seen_p,
+ C_DTR_BLOCK, &dummy);
+ if (declarator == NULL)
+ return NULL;
+
+ return grokblockdecl (specs, declarator);
+}
+
+/* Parse a block-literal-expr.
+
+ GNU Extension:
+
+ block-literal-expr:
+ ^ parameter-declation-clause exception-specification [opt] compound-statement
+ ^ block-id compound-statement
+
+ It synthesizes the helper function for later generation and builds
+ the necessary data to represent the block literal where it is
+ declared. */
+static tree
+c_parser_block_literal_expr (c_parser* parser)
+{
+ char name [32];
+ static int global_unique_count;
+ int unique_count = ++global_unique_count;
+ tree block_helper_function_decl;
+ tree expr, body, type, arglist = void_list_node, ftype;
+ tree self_arg, stmt;
+ struct c_arg_info *args = NULL;
+ tree arg_type = void_list_node;
+ struct block_sema_info *block_impl;
+ tree tmp;
+ bool open_paren_seen = false;
+ tree restype;
+ tree fnbody, typelist;
+ tree helper_function_type;
+ tree block;
+ /* APPLE LOCAL radar 6185344 */
+ tree declared_block_return_type = NULL_TREE;
+ /* APPLE LOCAL radar 6237713 */
+ tree attributes = NULL_TREE;
+
+ c_parser_consume_token (parser); /* eat '^' */
+
+ /* APPLE LOCAL begin radar 6237713 */
+ if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
+ attributes = c_parser_attributes (parser);
+ /* APPLE LOCAL end radar 6237713 */
+
+ if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
+ {
+ /* Parse the optional argument list */
+ c_parser_consume_token (parser);
+ /* Open the scope to collect parameter decls */
+ push_scope ();
+ args = c_parser_parms_declarator (parser, true, NULL_TREE);
+ /* Check for args as it might be NULL due to error. */
+ if (args)
+ {
+ arglist = args->parms;
+ arg_type = args->types;
+ }
+ else
+ {
+ pop_scope ();
+ return error_mark_node;
+ }
+ open_paren_seen = true;
+ pop_scope ();
+ }
+ else if (c_parser_next_token_is_not (parser, CPP_OPEN_BRACE))
+ {
+ /* Parse user declared return type. */
+ tree decl;
+
+ /* APPLE LOCAL begin radar 6237713 */
+ if (attributes)
+ {
+ warning (0, "attributes before block type are ignored");
+ attributes = NULL_TREE;
+ }
+ /* APPLE LOCAL end radar 6237713 */
+
+ decl = c_parser_block_id (parser);
+
+ if (decl && decl != error_mark_node)
+ {
+ arg_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
+ arglist = DECL_ARGUMENTS (decl);
+ declared_block_return_type = TREE_TYPE (TREE_TYPE (decl));
+ }
+ }
+
+ block = begin_block ();
+
+ cur_block->arg_info = NULL;
+ if (declared_block_return_type)
+ {
+ cur_block->return_type = TYPE_MAIN_VARIANT (declared_block_return_type);
+ cur_block->block_has_return_type = true;
+ }
+ else
+ cur_block->return_type = NULL_TREE;
+
+ if (args)
+ cur_block->arg_info = args;
+ else
+ cur_block->arg_info = xcalloc (1, sizeof (struct c_arg_info));
+
+ if (declared_block_return_type)
+ {
+ cur_block->arg_info->parms = arglist;
+ cur_block->arg_info->types = arg_type;
+ }
+
+ /* Must also build hidden parameter .block_descriptor added to the helper
+ function, even though we do not know its type yet. */
+ /* APPLE LOCAL radar 6404979 */
+ self_arg = build_decl (PARM_DECL, get_identifier (".block_descriptor"),
+ ptr_type_node);
+ TREE_USED (self_arg) = 1; /* Prevent unused parameter '.block_descriptor' warning. */
+ TREE_CHAIN (self_arg) = cur_block->arg_info->parms;
+ cur_block->arg_info->types = tree_cons (NULL_TREE, ptr_type_node, arg_type);
+ cur_block->arg_info->parms = self_arg;
+
+ /* APPLE LOCAL begin radar 6185344 */
+ /* Build the declaration of the helper function (if we do not know its result
+ type yet, assume it is 'void'. If user provided it, use it).
+ Treat this as a nested function and use nested function infrastructure for
+ its generation. */
+
+ ftype = build_function_type ((!cur_block->block_has_return_type
+ ? void_type_node : cur_block->return_type),
+ cur_block->arg_info->types);
+ /* APPLE LOCAL end radar 6185344 */
+ /* APPLE LOCAL radar 6160536 - radar 6411649 */
+ block_helper_function_decl = build_helper_func_decl (build_block_helper_name (0),
+ ftype);
+ DECL_CONTEXT (block_helper_function_decl) = current_function_decl;
+ cur_block->helper_func_decl = block_helper_function_decl;
+
+ push_function_context ();
+ start_block_helper_function (cur_block->helper_func_decl);
+ /* Set block's scope to the scope of the helper function's main body.
+ This is primarily used when nested blocks are declared. */
+ /* FIXME: Name of objc_get_current_scope needs to get changed. */
+ cur_block->the_scope = (struct c_scope*)objc_get_current_scope ();
+
+ /* Enter parameter list to the scope of the helper function. */
+ store_parm_decls_from (cur_block->arg_info);
+
+ /* APPLE LOCAL begin radar 6237713 */
+ if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
+ attributes = c_parser_attributes (parser);
+ /* APPLE LOCAL radar 6246527 */
+ any_recognized_block_attribute (attributes);
+ decl_attributes (&cur_block->helper_func_decl, attributes, 0);
+ /* APPLE LOCAL end radar 6237713 */
+
+ /* Start parsing body or expression part of the block literal. */
+ if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) {
+ tree save_c_break_label = c_break_label;
+ tree save_c_cont_label = c_cont_label;
+ /* Indicate no valid break/continue context by setting these variables
+ to some non-null, non-label value. We'll notice and emit the proper
+ error message in c_finish_bc_stmt. */
+ c_break_label = c_cont_label = size_zero_node;
+ c_parser_consume_token (parser); /* Consure '{'. */
+ stmt = c_begin_compound_stmt (true);
+ c_parser_compound_statement_nostart (parser);
+ c_cont_label = save_c_cont_label;
+ c_break_label = save_c_break_label;
+ }
+ else
+ {
+ struct c_expr expr;
+ stmt = c_begin_compound_stmt (true);
+ error ("blocks require { }");
+ expr = c_parser_cast_expression (parser, NULL);
+ body = expr.value;
+ if (body == error_mark_node)
+ return clean_and_exit (block);
+
+ if (cur_block->return_type)
+ {
+ error ("return not allowed in block expression literal");
+ return clean_and_exit (block);
+ }
+ else if (!open_paren_seen)
+ {
+ error ("argument list is required for block expression literals");
+ return clean_and_exit (block);
+ }
+ else
+ {
+ tree restype = TYPE_MAIN_VARIANT (TREE_TYPE (body));
+
+ add_stmt (body);
+ TREE_TYPE (current_function_decl)
+ = build_function_type (restype,
+ TYPE_ARG_TYPES (TREE_TYPE (current_function_decl)));
+ TREE_TYPE (DECL_RESULT (current_function_decl)) = restype;
+ relayout_decl (DECL_RESULT (current_function_decl));
+ cur_block->return_type = restype;
+ }
+ }
+
+ cur_block->block_arg_ptr_type =
+ build_pointer_type (build_block_struct_type (cur_block));
+
+ restype = !cur_block->return_type ? void_type_node
+ : cur_block->return_type;
+ if (restype == error_mark_node)
+ return clean_and_exit (block);
+
+ /* Now that we know type of the hidden .block_descriptor argument, fix its type. */
+ TREE_TYPE (self_arg) = cur_block->block_arg_ptr_type;
+ DECL_ARG_TYPE (self_arg) = cur_block->block_arg_ptr_type;
+
+ /* The DECL_RESULT should already have the correct type by now. */
+ gcc_assert (TREE_TYPE (DECL_RESULT (current_function_decl))
+ == restype);
+
+ cur_block->block_body = stmt;
+ block_build_prologue (cur_block);
+
+ fnbody = c_end_compound_stmt (stmt, true);
+ add_stmt (fnbody);
+
+ /* We are done parsing of the block body. Return type of block is now known.
+ We also know all we need to know about the helper function. So, fix its
+ type here. */
+ /* We moved this here because for global blocks, helper function body is
+ not nested and is gimplified in call to finish_function() and return type
+ of the function must be correct. */
+ ftype = build_function_type (restype, arg_type);
+ /* Declare helper function; as in:
+ double helper_1(struct block_1 *ii, int z); */
+ typelist = TYPE_ARG_TYPES (ftype);
+ /* (struct block_1 *ii, int z, ...) */
+ typelist = tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
+ typelist);
+ helper_function_type = build_function_type (TREE_TYPE (ftype), typelist);
+ TREE_TYPE (cur_block->helper_func_decl) = helper_function_type;
+ finish_function ();
+ pop_function_context ();
+
+ /* Build the declaration for copy_helper_block and destroy_helper_block
+ helper functions for later use. */
+
+ if (cur_block->BlockHasCopyDispose)
+ {
+ /* void copy_helper_block (struct block*, struct block *); */
+ tree s_ftype = build_function_type (void_type_node,
+ tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
+ tree_cons (NULL_TREE,
+ cur_block->block_arg_ptr_type,
+ void_list_node)));
+ sprintf (name, "__copy_helper_block_%d", unique_count);
+ cur_block->copy_helper_func_decl =
+ build_helper_func_decl (get_identifier (name), s_ftype);
+ synth_copy_helper_block_func (cur_block);
+
+ /* void destroy_helper_block (struct block*); */
+ s_ftype = build_function_type (void_type_node,
+ tree_cons (NULL_TREE,
+ cur_block->block_arg_ptr_type, void_list_node));
+ sprintf (name, "__destroy_helper_block_%d", unique_count);
+ cur_block->destroy_helper_func_decl =
+ build_helper_func_decl (get_identifier (name), s_ftype);
+ synth_destroy_helper_block_func (cur_block);
+ }
+
+ block_impl = finish_block (block);
+
+ /* Build unqiue name of the temporary used in code gen. */
+ sprintf (name, "__block_holder_tmp_%d", unique_count);
+ tmp = build_block_literal_tmp (name, block_impl);
+ tmp = build_fold_addr_expr (tmp);
+ type = build_block_pointer_type (ftype);
+ expr = convert (type, convert (ptr_type_node, tmp));
+ free (block_impl);
+ return expr;
+}
+/* APPLE LOCAL end radar 5732232 - blocks (C++ ce) */
+
#include "gt-c-parser.h"
Modified: trunk/contrib/gcc/c-ppoutput.c
===================================================================
--- trunk/contrib/gcc4/c-ppoutput.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-ppoutput.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -41,6 +41,8 @@
/* General output routines. */
static void scan_translation_unit (cpp_reader *);
+static void print_lines_directives_only (int, const void *, size_t);
+static void scan_translation_unit_directives_only (cpp_reader *);
static void scan_translation_unit_trad (cpp_reader *);
static void account_for_newlines (const unsigned char *, size_t);
static int dump_macro (cpp_reader *, cpp_hashnode *, void *);
@@ -75,6 +77,9 @@
}
else if (cpp_get_options (pfile)->traditional)
scan_translation_unit_trad (pfile);
+ else if (cpp_get_options (pfile)->directives_only
+ && !cpp_get_options (pfile)->preprocessed)
+ scan_translation_unit_directives_only (pfile);
else
scan_translation_unit (pfile);
@@ -179,6 +184,26 @@
}
}
+static void
+print_lines_directives_only (int lines, const void *buf, size_t size)
+{
+ print.src_line += lines;
+ fwrite (buf, 1, size, print.outf);
+}
+
+/* Writes out the preprocessed file, handling spacing and paste
+ avoidance issues. */
+static void
+scan_translation_unit_directives_only (cpp_reader *pfile)
+{
+ struct _cpp_dir_only_callbacks cb;
+
+ cb.print_lines = print_lines_directives_only;
+ cb.maybe_print_line = maybe_print_line;
+
+ _cpp_preprocess_dir_only (pfile, &cb);
+}
+
/* Adjust print.src_line for newlines embedded in output. */
static void
account_for_newlines (const unsigned char *str, size_t len)
Modified: trunk/contrib/gcc/c-pretty-print.c
===================================================================
--- trunk/contrib/gcc4/c-pretty-print.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-pretty-print.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -137,7 +137,16 @@
pp_base (pp)->padding = pp_none;
}
+/* APPLE LOCAL begin blocks */
void
+pp_c_caret (c_pretty_printer *pp)
+{
+ pp_carret (pp);
+ pp_base (pp)->padding = pp_none;
+}
+/* APPLE LOCAL end blocks */
+
+void
pp_c_arrow (c_pretty_printer *pp)
{
pp_arrow (pp);
@@ -260,6 +269,12 @@
pp_c_ampersand (pp);
pp_c_type_qualifier_list (pp, t);
break;
+ /* APPLE LOCAL begin blocks */
+ case BLOCK_POINTER_TYPE:
+ pp_c_caret (pp);
+ pp_c_type_qualifier_list (pp, t);
+ break;
+ /* APPLE LOCAL end blocks */
/* ??? This node is now in GENERIC and so shouldn't be here. But
we'll fix that later. */
@@ -405,6 +420,8 @@
{
case REFERENCE_TYPE:
case POINTER_TYPE:
+ /* APPLE LOCAL blocks */
+ case BLOCK_POINTER_TYPE:
{
/* Get the types-specifier of this type. */
tree pointee = strip_pointer_operator (TREE_TYPE (t));
@@ -487,7 +504,10 @@
static void
pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
{
- if (TREE_CODE (t) == POINTER_TYPE)
+ /* APPLE LOCAL begin blocks */
+ if (TREE_CODE (t) == POINTER_TYPE ||
+ TREE_CODE (t) == BLOCK_POINTER_TYPE)
+ /* APPLE LOCAL end blocks */
{
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
|| TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
@@ -510,6 +530,8 @@
switch (TREE_CODE (t))
{
case POINTER_TYPE:
+ /* APPLE LOCAL blocks */
+ case BLOCK_POINTER_TYPE:
pp_abstract_declarator (pp, t);
break;
@@ -635,6 +657,8 @@
case ARRAY_TYPE:
case POINTER_TYPE:
+ /* APPLE LOCAL blocks */
+ case BLOCK_POINTER_TYPE:
pp_abstract_declarator (pp, TREE_TYPE (t));
break;
Modified: trunk/contrib/gcc/c-pretty-print.h
===================================================================
--- trunk/contrib/gcc4/c-pretty-print.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-pretty-print.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -167,6 +167,8 @@
void pp_c_dot (c_pretty_printer *);
void pp_c_ampersand (c_pretty_printer *);
void pp_c_star (c_pretty_printer *);
+/* APPLE LOCAL blocks */
+void pp_c_caret (c_pretty_printer *);
void pp_c_arrow (c_pretty_printer *);
void pp_c_semicolon (c_pretty_printer *);
void pp_c_complement (c_pretty_printer *);
Modified: trunk/contrib/gcc/c-tree.h
===================================================================
--- trunk/contrib/gcc4/c-tree.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-tree.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -257,6 +257,10 @@
BOOL_BITFIELD explicit_signed_p : 1;
/* Whether the specifiers include a deprecated typedef. */
BOOL_BITFIELD deprecated_p : 1;
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ /* Whether the specifiers include a unavailable typedef. */
+ BOOL_BITFIELD unavailable_p : 1;
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
/* Whether the type defaulted to "int" because there were no type
specifiers. */
BOOL_BITFIELD default_int_p;
@@ -294,6 +298,8 @@
cdk_array,
/* A pointer. */
cdk_pointer,
+ /* APPLE LOCAL blocks (C++ ch) */
+ cdk_block_pointer,
/* Parenthesized declarator with nested attributes. */
cdk_attrs
};
@@ -464,6 +470,8 @@
extern struct c_arg_info *get_parm_info (bool);
extern tree grokfield (struct c_declarator *, struct c_declspecs *, tree);
extern tree groktypename (struct c_type_name *);
+/* APPLE LOCAL blocks 6339747 */
+extern tree grokblockdecl (struct c_declspecs *, struct c_declarator *);
extern tree grokparm (const struct c_parm *);
extern tree implicitly_declare (tree);
extern void keep_next_level (void);
@@ -497,6 +505,10 @@
extern struct c_declarator *build_id_declarator (tree);
extern struct c_declarator *make_pointer_declarator (struct c_declspecs *,
struct c_declarator *);
+/* APPLE LOCAL begin radar 5814025 - blocks (C++ cg) */
+extern struct c_declarator *make_block_pointer_declarator (struct c_declspecs *,
+ struct c_declarator *);
+/* APPLE LOCAL end radar 5814025 - blocks (C++ cg) */
extern struct c_declspecs *build_null_declspecs (void);
extern struct c_declspecs *declspecs_add_qual (struct c_declspecs *, tree);
extern struct c_declspecs *declspecs_add_type (struct c_declspecs *,
@@ -573,7 +585,10 @@
extern tree c_begin_compound_stmt (bool);
extern tree c_end_compound_stmt (tree, bool);
extern void c_finish_if_stmt (location_t, tree, tree, tree, bool);
-extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, bool);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, tree,
+ bool);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
extern tree c_begin_stmt_expr (void);
extern tree c_finish_stmt_expr (tree);
extern tree c_process_expr_stmt (tree);
@@ -620,6 +635,8 @@
extern void c_finish_incomplete_decl (tree);
extern void c_write_global_declarations (void);
+/* APPLE LOCAL radar 5741070 */
+extern tree c_return_interface_record_type (tree);
/* In order for the format checking to accept the C frontend
diagnostic framework extensions, you must include this file before
toplev.h, not after. */
Modified: trunk/contrib/gcc/c-typeck.c
===================================================================
--- trunk/contrib/gcc4/c-typeck.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c-typeck.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -75,6 +75,10 @@
static int require_constant_value;
static int require_constant_elements;
+/* APPLE LOCAL begin radar 5732232 - blocks (C++ cm) */
+static bool types_are_block_compatible (tree lhptee, tree rhptee);
+static tree build_block_call (tree, tree, tree);
+/* APPLE LOCAL end radar 5732232 - blocks (C++ cm) */
static bool null_pointer_constant_p (tree);
static tree qualify_type (tree, tree);
static int tagged_types_tu_compatible_p (tree, tree);
@@ -542,8 +546,12 @@
if (t2 == error_mark_node)
return t1;
- gcc_assert (TREE_CODE (t1) == POINTER_TYPE
- && TREE_CODE (t2) == POINTER_TYPE);
+ /* APPLE LOCAL begin blocks 6065211 */
+ gcc_assert ((TREE_CODE (t1) == POINTER_TYPE
+ && TREE_CODE (t2) == POINTER_TYPE)
+ || (TREE_CODE (t1) == BLOCK_POINTER_TYPE
+ && TREE_CODE (t2) == BLOCK_POINTER_TYPE));
+ /* APPLE LOCAL end blocks 6065211 */
/* Merge the attributes. */
attributes = targetm.merge_type_attributes (t1, t2);
@@ -558,10 +566,15 @@
if (TREE_CODE (mv2) != ARRAY_TYPE)
mv2 = TYPE_MAIN_VARIANT (pointed_to_2);
target = composite_type (mv1, mv2);
- t1 = build_pointer_type (c_build_qualified_type
- (target,
- TYPE_QUALS (pointed_to_1) |
- TYPE_QUALS (pointed_to_2)));
+ /* APPLE LOCAL begin blocks 6065211 */
+ t1 = c_build_qualified_type (target,
+ TYPE_QUALS (pointed_to_1) |
+ TYPE_QUALS (pointed_to_2));
+ if (TREE_CODE (t2) == BLOCK_POINTER_TYPE)
+ t1 = build_block_pointer_type (t1);
+ else
+ t1 = build_pointer_type (t1);
+ /* APPLE LOCAL end blocks 6065211 */
return build_type_attribute_variant (t1, attributes);
}
@@ -845,6 +858,13 @@
switch (TREE_CODE (t1))
{
+ /* APPLE LOCAL begin radar 5795493 */
+ case BLOCK_POINTER_TYPE:
+ val = (TREE_CODE (t2) == BLOCK_POINTER_TYPE) &&
+ types_are_block_compatible (TREE_TYPE (t1), TREE_TYPE (t2));
+ break;
+
+ /* APPLE LOCAL end radar 5795493 */
case POINTER_TYPE:
/* Do not remove mode or aliasing information. */
if (TYPE_MODE (t1) != TYPE_MODE (t2)
@@ -937,6 +957,15 @@
int val;
tree mvl, mvr;
+ /* APPLE LOCAL begin blocks 6065211 */
+ if (TREE_CODE (ttl) == BLOCK_POINTER_TYPE
+ && TREE_CODE (ttr) == BLOCK_POINTER_TYPE)
+ return types_are_block_compatible (TREE_TYPE (ttl),
+ TREE_TYPE (ttr));
+ if (TREE_CODE (ttl) != TREE_CODE (ttr))
+ return 0;
+ /* APPLE LOCAL end blocks 6065211 */
+
/* Do not lose qualifiers on element types of array types that are
pointer targets by taking their TYPE_MAIN_VARIANT. */
mvl = TREE_TYPE (ttl);
@@ -1485,7 +1514,8 @@
}
/* Convert the array expression EXP to a pointer. */
-static tree
+/* APPLE LOCAL radar 6212722 */
+tree
array_to_pointer_conversion (tree exp)
{
tree orig_exp = exp;
@@ -1526,7 +1556,8 @@
}
/* Convert the function expression EXP to a pointer. */
-static tree
+/* APPLE LOCAL radar 6212722 */
+tree
function_to_pointer_conversion (tree exp)
{
tree orig_exp = exp;
@@ -1803,6 +1834,12 @@
if (!objc_is_public (datum, component))
return error_mark_node;
+ /* APPLE LOCAL begin C* property (Radar 4436866) */
+ /* APPLE LOCAL radar 5285911 */
+ if ((ref = objc_build_property_reference_expr (datum, component)))
+ return ref;
+ /* APPLE LOCAL end C* property (Radar 4436866) */
+
/* See if there is a field or component with name COMPONENT. */
if (code == RECORD_TYPE || code == UNION_TYPE)
@@ -1841,6 +1878,8 @@
ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
NULL_TREE);
+ /* APPLE LOCAL radar 4697411 */
+ objc_volatilize_component_ref (ref, TREE_TYPE (subdatum));
if (TREE_READONLY (datum) || TREE_READONLY (subdatum))
TREE_READONLY (ref) = 1;
if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (subdatum))
@@ -1849,6 +1888,11 @@
if (TREE_DEPRECATED (subdatum))
warn_deprecated_use (subdatum);
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ if (TREE_UNAVAILABLE (subdatum))
+ error_unavailable_use (subdatum);
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
+
datum = ref;
field = TREE_CHAIN (field);
@@ -1876,6 +1920,19 @@
if (TREE_CODE (type) == POINTER_TYPE)
{
+ if (TREE_CODE (pointer) == CONVERT_EXPR
+ || TREE_CODE (pointer) == NOP_EXPR
+ || TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
+ {
+ /* If a warning is issued, mark it to avoid duplicates from
+ the backend. This only needs to be done at
+ warn_strict_aliasing > 2. */
+ if (warn_strict_aliasing > 2)
+ if (strict_aliasing_warning (TREE_TYPE (TREE_OPERAND (pointer, 0)),
+ type, TREE_OPERAND (pointer, 0)))
+ TREE_NO_WARNING (pointer) = 1;
+ }
+
if (TREE_CODE (pointer) == ADDR_EXPR
&& (TREE_TYPE (TREE_OPERAND (pointer, 0))
== TREE_TYPE (type)))
@@ -1910,7 +1967,7 @@
}
}
else if (TREE_CODE (pointer) != ERROR_MARK)
- error ("invalid type argument of %qs", errorstring);
+ error ("invalid type argument of %qs (have %qT)", errorstring, type);
return error_mark_node;
}
@@ -2055,9 +2112,62 @@
/* In Objective-C, an instance variable (ivar) may be preferred to
whatever lookup_name() found. */
decl = objc_lookup_ivar (decl, id);
-
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ ci) */
if (decl && decl != error_mark_node)
- ref = decl;
+ {
+ if (cur_block
+ && (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL)
+ && !lookup_name_in_block (id, &decl))
+ {
+ /* APPLE LOCAL begin radar 5803005 (C++ ci) */
+ bool gdecl;
+ /* We are referencing a variable inside a block whose declaration
+ is outside. */
+ gcc_assert (decl &&
+ (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL));
+ gdecl = (TREE_CODE (decl) == VAR_DECL &&
+ /* APPLE LOCAL radar 6177162 */
+ (DECL_EXTERNAL (decl) || TREE_STATIC (decl)));
+ /* Treat all 'global' variables as 'byref' by default. */
+ /* APPLE LOCAL begin radar 6014138 (C++ ci) */
+ if (gdecl || (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl)))
+ /* APPLE LOCAL end radar 6014138 (C++ ci) */
+ {
+ /* APPLE LOCAL begin radar 5803600 (C++ ci) */
+ /* byref globals are directly accessed. */
+ /* APPLE LOCAL begin radar 7760213 */
+ if (!gdecl) {
+ if (HasByrefArray(TREE_TYPE (decl)))
+ error ("cannot access __block variable of array type inside block");
+ /* build a decl for the byref variable. */
+ decl = build_block_byref_decl (id, decl, decl);
+ }
+ /* APPLE LOCAL end radar 7760213 */
+ else
+ add_block_global_byref_list (decl);
+ }
+ else
+ {
+ /* 'byref' globals are never copied-in. So, do not add
+ them to the copied-in list. */
+ if (!in_block_global_byref_list (decl)) {
+ /* APPLE LOCAL begin radar 7721728 */
+ if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ error ("cannot access copied-in variable of array type inside block");
+ /* APPLE LOCAL end radar 7721728 */
+ /* build a new decl node. set its type to 'const' type
+ of the old decl. */
+ decl = build_block_ref_decl (id, decl);
+ }
+ /* APPLE LOCAL end radar 5803600 (C++ ci) */
+ /* APPLE LOCAL end radar 5803005 (C++ ci) */
+ }
+ }
+ ref = decl;
+ }
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ ci) */
else if (fun)
/* Implicit function declaration. */
ref = implicitly_declare (id);
@@ -2077,6 +2187,11 @@
if (TREE_DEPRECATED (ref))
warn_deprecated_use (ref);
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ if (TREE_UNAVAILABLE (ref))
+ error_unavailable_use (ref);
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
+
if (!skip_evaluation)
assemble_external (ref);
TREE_USED (ref) = 1;
@@ -2262,8 +2377,10 @@
if (TREE_CODE (fntype) == ERROR_MARK)
return error_mark_node;
-
- if (!(TREE_CODE (fntype) == POINTER_TYPE
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ if (!((TREE_CODE (fntype) == POINTER_TYPE
+ || TREE_CODE (fntype) == BLOCK_POINTER_TYPE)
+ /* APPLE LOCAL end radar 5732232 - blocks */
&& TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
{
error ("called object %qE is not a function", function);
@@ -2330,6 +2447,11 @@
check_function_arguments (TYPE_ATTRIBUTES (fntype), coerced_params,
TYPE_ARG_TYPES (fntype));
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
+ result = build_block_call (fntype, function, coerced_params);
+ else
+ /* APPLE LOCAL end radar 5732232 - blocks */
if (require_constant_value)
{
result = fold_build3_initializer (CALL_EXPR, TREE_TYPE (fntype),
@@ -2401,7 +2523,17 @@
if (type == void_type_node)
{
- error ("too many arguments to function %qE", function);
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
+ {
+ error ("too many arguments to block call");
+ break;
+ }
+ /* APPLE LOCAL end radar 5732232 - blocks */
+ /* APPLE LOCAL begin radar 4491608 */
+ error ("too many arguments to function %qE", selector ? selector
+ : function);
+ /* APPLE LOCAL end radar 4491608 */
break;
}
@@ -2571,7 +2703,7 @@
else if ((invalid_func_diag =
targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
{
- error (invalid_func_diag);
+ error (invalid_func_diag, "");
return error_mark_node;
}
else
@@ -2584,7 +2716,12 @@
if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
{
- error ("too few arguments to function %qE", function);
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
+ error ("too few arguments to block %qE", function);
+ else
+ error ("too few arguments to function %qE", function);
+ /* APPLE LOCAL end radar 5732232 - blocks */
return error_mark_node;
}
@@ -2603,7 +2740,10 @@
result.original_code = ERROR_MARK;
result.value = build_unary_op (code, arg.value, 0);
- overflow_warning (result.value);
+
+ if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
+ overflow_warning (result.value);
+
return result;
}
@@ -2631,74 +2771,8 @@
/* Check for cases such as x+y<<z which users are likely
to misinterpret. */
if (warn_parentheses)
- {
- if (code == LSHIFT_EXPR || code == RSHIFT_EXPR)
- {
- if (code1 == PLUS_EXPR || code1 == MINUS_EXPR
- || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
- warning (OPT_Wparentheses,
- "suggest parentheses around + or - inside shift");
- }
+ warn_about_parentheses (code, code1, code2);
- if (code == TRUTH_ORIF_EXPR)
- {
- if (code1 == TRUTH_ANDIF_EXPR
- || code2 == TRUTH_ANDIF_EXPR)
- warning (OPT_Wparentheses,
- "suggest parentheses around && within ||");
- }
-
- if (code == BIT_IOR_EXPR)
- {
- if (code1 == BIT_AND_EXPR || code1 == BIT_XOR_EXPR
- || code1 == PLUS_EXPR || code1 == MINUS_EXPR
- || code2 == BIT_AND_EXPR || code2 == BIT_XOR_EXPR
- || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
- warning (OPT_Wparentheses,
- "suggest parentheses around arithmetic in operand of |");
- /* Check cases like x|y==z */
- if (TREE_CODE_CLASS (code1) == tcc_comparison
- || TREE_CODE_CLASS (code2) == tcc_comparison)
- warning (OPT_Wparentheses,
- "suggest parentheses around comparison in operand of |");
- }
-
- if (code == BIT_XOR_EXPR)
- {
- if (code1 == BIT_AND_EXPR
- || code1 == PLUS_EXPR || code1 == MINUS_EXPR
- || code2 == BIT_AND_EXPR
- || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
- warning (OPT_Wparentheses,
- "suggest parentheses around arithmetic in operand of ^");
- /* Check cases like x^y==z */
- if (TREE_CODE_CLASS (code1) == tcc_comparison
- || TREE_CODE_CLASS (code2) == tcc_comparison)
- warning (OPT_Wparentheses,
- "suggest parentheses around comparison in operand of ^");
- }
-
- if (code == BIT_AND_EXPR)
- {
- if (code1 == PLUS_EXPR || code1 == MINUS_EXPR
- || code2 == PLUS_EXPR || code2 == MINUS_EXPR)
- warning (OPT_Wparentheses,
- "suggest parentheses around + or - in operand of &");
- /* Check cases like x&y==z */
- if (TREE_CODE_CLASS (code1) == tcc_comparison
- || TREE_CODE_CLASS (code2) == tcc_comparison)
- warning (OPT_Wparentheses,
- "suggest parentheses around comparison in operand of &");
- }
- /* Similarly, check for cases like 1<=i<=10 that are probably errors. */
- if (TREE_CODE_CLASS (code) == tcc_comparison
- && (TREE_CODE_CLASS (code1) == tcc_comparison
- || TREE_CODE_CLASS (code2) == tcc_comparison))
- warning (OPT_Wparentheses, "comparisons like X<=Y<=Z do not "
- "have their mathematical meaning");
-
- }
-
/* Warn about comparisons against string literals, with the exception
of testing for equality or inequality of a string literal with NULL. */
if (code == EQ_EXPR || code == NE_EXPR)
@@ -2713,7 +2787,10 @@
warning (OPT_Waddress,
"comparison with string literal results in unspecified behaviour");
- overflow_warning (result.value);
+ if (TREE_OVERFLOW_P (result.value)
+ && !TREE_OVERFLOW_P (arg1.value)
+ && !TREE_OVERFLOW_P (arg2.value))
+ overflow_warning (result.value);
return result;
}
@@ -2828,7 +2905,7 @@
if ((invalid_op_diag
= targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
{
- error (invalid_op_diag);
+ error (invalid_op_diag, "");
return error_mark_node;
}
@@ -2907,6 +2984,8 @@
case TRUTH_NOT_EXPR:
if (typecode != INTEGER_TYPE
+ /* APPLE LOCAL radar 5732232 - blocks */
+ && typecode != BLOCK_POINTER_TYPE
&& typecode != REAL_TYPE && typecode != POINTER_TYPE
&& typecode != COMPLEX_TYPE)
{
@@ -3358,7 +3437,12 @@
pedwarn ("ISO C forbids conditional expr with only one void side");
result_type = void_type_node;
}
- else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
+ /* APPLE LOCAL begin blocks 6065211 */
+ else if ((code1 == POINTER_TYPE
+ || code1 == BLOCK_POINTER_TYPE)
+ && (code2 == POINTER_TYPE
+ || code2 == BLOCK_POINTER_TYPE))
+ /* APPLE LOCAL end blocks 6065211 */
{
if (comp_target_types (type1, type2))
result_type = common_pointer_type (type1, type2);
@@ -3366,6 +3450,14 @@
result_type = qualify_type (type2, type1);
else if (null_pointer_constant_p (orig_op2))
result_type = qualify_type (type1, type2);
+ /* APPLE LOCAL begin blocks 6065211 */
+ else if (code2 == BLOCK_POINTER_TYPE
+ && VOID_TYPE_P (TREE_TYPE (type1)))
+ result_type = type2;
+ else if (code1 == BLOCK_POINTER_TYPE
+ && VOID_TYPE_P (TREE_TYPE (type2)))
+ result_type = type1;
+ /* APPLE LOCAL end blocks 6065211 */
else if (VOID_TYPE_P (TREE_TYPE (type1)))
{
if (pedantic && TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
@@ -3408,7 +3500,31 @@
}
result_type = type2;
}
-
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ co) */
+ /* APPLE LOCAL radar 5957801 */
+ else if (code1 == BLOCK_POINTER_TYPE && code2 == INTEGER_TYPE)
+ {
+ if (!null_pointer_constant_p (orig_op2))
+ error ("block pointer/integer type mismatch in conditional expression");
+ else
+ {
+ op2 = convert (type1, null_pointer_node);
+ }
+ result_type = type1;
+ }
+ /* APPLE LOCAL radar 5957801 */
+ else if (code2 == BLOCK_POINTER_TYPE && code1 == INTEGER_TYPE)
+ {
+ if (!null_pointer_constant_p (orig_op1))
+ error ("block pointer/integer type mismatch in conditional expression");
+ else
+ {
+ op1 = convert (type2, null_pointer_node);
+ }
+ result_type = type2;
+ }
+
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ co) */
if (!result_type)
{
if (flag_cond_mismatch)
@@ -3547,6 +3663,12 @@
otype = TREE_TYPE (value);
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ if (TREE_CODE (otype) == BLOCK_POINTER_TYPE &&
+ TREE_CODE (type) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type)))
+ return build1 (NOP_EXPR, type, value);
+ /* APPLE LOCAL end radar 5732232 - blocks */
+
/* Optionally warn about potentially worrisome casts. */
if (warn_cast_qual
@@ -3628,7 +3750,8 @@
warning (OPT_Wint_to_pointer_cast, "cast to pointer from integer "
"of different size");
- strict_aliasing_warning (otype, type, expr);
+ if (warn_strict_aliasing <= 2)
+ strict_aliasing_warning (otype, type, expr);
/* If pedantic, warn for conversions between function and object
pointer types, except for converting a null pointer constant
@@ -3649,6 +3772,13 @@
pedwarn ("ISO C forbids conversion of object pointer to function pointer type");
ovalue = value;
+ /* APPLE LOCAL begin don't sign-extend pointers cast to integers */
+ if (TREE_CODE (type) == INTEGER_TYPE
+ && TREE_CODE (otype) == POINTER_TYPE
+ && TYPE_PRECISION (type) > TYPE_PRECISION (otype)
+ && TYPE_UNSIGNED (type))
+ value = convert (c_common_type_for_size (POINTER_SIZE, 1), value);
+ /* APPLE LOCAL end don't sign-extend pointers cast to integers */
value = convert (type, value);
/* Ignore any integer overflow caused by the cast. */
@@ -3677,6 +3807,78 @@
return value;
}
+/* APPLE LOCAL begin radar 5732232 - blocks (C++ cm) */
+static bool
+functiontypes_are_block_compatible (tree f1, tree f2)
+{
+ tree arg1, arg2;
+ if (!types_are_block_compatible (TREE_TYPE (f1), TREE_TYPE (f2)))
+ return false;
+ arg1 = TYPE_ARG_TYPES (f1);
+ arg2 = TYPE_ARG_TYPES (f2);
+ /* APPLE LOCAL radar 6246965, 6196572 */
+ return (!arg1) || (type_lists_compatible_p (arg1, arg2) == 1);
+}
+
+static bool
+types_are_block_compatible (tree lhptee, tree rhptee)
+{
+ if (TYPE_MAIN_VARIANT (lhptee) == TYPE_MAIN_VARIANT (rhptee))
+ return true;
+ if (TREE_CODE (lhptee) == FUNCTION_TYPE && TREE_CODE (rhptee) == FUNCTION_TYPE)
+ return functiontypes_are_block_compatible (lhptee, rhptee);
+ /* APPLE LOCAL begin radar 5882266 (C++ cm) */
+ if (TREE_CODE (lhptee) == POINTER_TYPE && TREE_CODE (rhptee) == POINTER_TYPE)
+ return types_are_block_compatible (TREE_TYPE (lhptee), TREE_TYPE (rhptee));
+ /* APPLE LOCAL end radar 5882266 (C++ cm) */
+ /* APPLE LOCAL begin radar 5988995 (C++ cm) */
+ if (TREE_CODE (lhptee) == BLOCK_POINTER_TYPE
+ && TREE_CODE (rhptee) == BLOCK_POINTER_TYPE)
+ return types_are_block_compatible (TREE_TYPE (lhptee), TREE_TYPE (rhptee));
+ /* APPLE LOCAL end radar 5988995 (C++ cm) */
+ return false;
+}
+
+/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
+/**
+ build_block_call - Routine to build a block call; as in:
+ ((double(*)(void *, int))(BLOCK_PTR_EXP->__FuncPtr))(I, 42);
+ FNTYPE is the original function type derived from the syntax.
+ BLOCK_PTR_EXP is the block pointer variable.
+ PARAMS is the parameter list.
+*/
+static tree
+build_block_call (tree fntype, tree block_ptr_exp, tree params)
+{
+ tree function_ptr_exp;
+ tree typelist;
+ bool block_ptr_exp_side_effect = TREE_SIDE_EFFECTS (block_ptr_exp);
+
+ /* First convert BLOCK_PTR_EXP to 'void *'. */
+ block_ptr_exp = convert (ptr_type_node, block_ptr_exp);
+ gcc_assert (generic_block_literal_struct_type);
+ block_ptr_exp = convert (build_pointer_type (generic_block_literal_struct_type),
+ block_ptr_exp);
+ if (block_ptr_exp_side_effect)
+ block_ptr_exp = save_expr (block_ptr_exp);
+
+ /* BLOCK_PTR_VAR->__FuncPtr */
+ function_ptr_exp = build_component_ref (build_indirect_ref (block_ptr_exp, "->"),
+ get_identifier ("__FuncPtr"));
+ gcc_assert (function_ptr_exp);
+
+ /* Build: result_type(*)(void *, function-arg-type-list) */
+ typelist = TYPE_ARG_TYPES (fntype);
+ typelist = tree_cons (NULL_TREE, ptr_type_node, typelist);
+ fntype = build_function_type (TREE_TYPE (fntype), typelist);
+ function_ptr_exp = convert (build_pointer_type (fntype), function_ptr_exp);
+ params = tree_cons (NULL_TREE, block_ptr_exp, params);
+ return fold_build3 (CALL_EXPR, TREE_TYPE (fntype),
+ function_ptr_exp, params, NULL_TREE);
+}
+/* APPLE LOCAL end radar 5847213 - radar 6329245 */
+/* APPLE LOCAL end radar 5732232 - blocks (C++ cm) */
+
/* Interpret a cast of expression EXPR to type TYPE. */
tree
c_cast_expr (struct c_type_name *type_name, tree expr)
@@ -3706,7 +3908,19 @@
tree newrhs;
tree lhstype = TREE_TYPE (lhs);
tree olhstype = lhstype;
+ /* APPLE LOCAL __block assign sequence point 6639533 */
+ bool insert_sequence_point = false;
+ /* APPLE LOCAL begin radar 4426814 */
+ if (c_dialect_objc () && flag_objc_gc)
+ {
+ /* APPLE LOCAL radar 5276085 */
+ objc_weak_reference_expr (&lhs);
+ lhstype = TREE_TYPE (lhs);
+ olhstype = lhstype;
+ }
+ /* APPLE LOCAL end radar 4426814 */
+
/* Types that aren't fully specified cannot be used in assignments. */
lhs = require_complete_type (lhs);
@@ -3714,11 +3928,46 @@
if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
return error_mark_node;
+ /* APPLE LOCAL radar 5285911 */
if (!lvalue_or_else (lhs, lv_assign))
return error_mark_node;
STRIP_TYPE_NOPS (rhs);
+ /* APPLE LOCAL begin __block assign sequence point 6639533 */
+ /* For byref = x;, we have to transform this into {( typeof(x) x' =
+ x; byref = x`; )} to ensure there is a sequence point before the
+ evaluation of the byref, inorder to ensure that the access
+ expression for byref doesn't start running before x is evaluated,
+ as it will access the __forwarding pointer and that must be done
+ after x is evaluated. */
+ /* First we check to see if lhs is a byref... byrefs look like:
+ __Block_byref_X.__forwarding->x */
+ if (TREE_CODE (lhs) == COMPONENT_REF)
+ {
+ tree inner = TREE_OPERAND (lhs, 0);
+ /* now check for -> */
+ if (TREE_CODE (inner) == INDIRECT_REF)
+ {
+ inner = TREE_OPERAND (inner, 0);
+ if (TREE_CODE (inner) == COMPONENT_REF)
+ {
+ inner = TREE_OPERAND (inner, 0);
+ if (TREE_CODE (inner) == VAR_DECL
+ && COPYABLE_BYREF_LOCAL_VAR (inner))
+ {
+ tree old_rhs = rhs;
+ /* then we save the rhs. */
+ rhs = save_expr (rhs);
+ if (rhs != old_rhs)
+ /* And arrange for the sequence point to be inserted. */
+ insert_sequence_point = true;
+ }
+ }
+ }
+ }
+ /* APPLE LOCAL end __block assign sequence point 6639533 */
+
newrhs = rhs;
/* If a binary op has been requested, combine the old LHS value with the RHS
@@ -3730,6 +3979,21 @@
newrhs = build_binary_op (modifycode, lhs, rhs, 1);
}
+ /* APPLE LOCAL begin C* property (Radar 4436866) */
+ if (c_dialect_objc ())
+ {
+ result = objc_build_setter_call (lhs, newrhs);
+ if (result)
+ /* APPLE LOCAL begin __block assign sequence point 6639533 */
+ {
+ if (insert_sequence_point)
+ result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build1 (NOP_EXPR, void_type_node, rhs), result);
+ return result;
+ }
+ /* APPLE LOCAL end __block assign sequence point 6639533 */
+ }
+ /* APPLE LOCAL end C* property (Radar 4436866) */
+
/* Give an error for storing in something that is 'const'. */
if (TREE_READONLY (lhs) || TYPE_READONLY (lhstype)
@@ -3774,7 +4038,13 @@
{
result = objc_generate_write_barrier (lhs, modifycode, newrhs);
if (result)
- return result;
+ /* APPLE LOCAL begin __block assign sequence point 6639533 */
+ {
+ if (insert_sequence_point)
+ result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build1 (NOP_EXPR, void_type_node, rhs), result);
+ return result;
+ }
+ /* APPLE LOCAL end __block assign sequence point 6639533 */
}
/* Scan operands. */
@@ -3782,6 +4052,11 @@
result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
TREE_SIDE_EFFECTS (result) = 1;
+ /* APPLE LOCAL begin __block assign sequence point 6639533 */
+ if (insert_sequence_point)
+ result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build1 (NOP_EXPR, void_type_node, rhs), result);
+ /* APPLE LOCAL end __block assign sequence point 6639533 */
+
/* If we got the LHS in a different type for storing in,
convert the result back to the nominal type of LHS
so that the value we return always has the same type
@@ -3895,14 +4170,12 @@
break;
}
- objc_ok = objc_compare_types (type, rhstype, parmno, rname);
+ /* APPLE LOCAL radar 6231433 */
+ objc_ok = objc_compare_types (type, rhstype, parmno, rname, "comparison");
}
if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
- {
- overflow_warning (rhs);
- return rhs;
- }
+ return rhs;
if (coder == VOID_TYPE)
{
@@ -3918,7 +4191,10 @@
This code doesn't fully support references, it's just for the
special case of va_start and va_copy. */
if (codel == REFERENCE_TYPE
- && comptypes (TREE_TYPE (type), TREE_TYPE (rhs)) == 1)
+ /* APPLE LOCAL begin radar 4502186 */
+ && comptypes (objc_non_volatilized_type (TREE_TYPE (type)),
+ objc_non_volatilized_type (TREE_TYPE (rhs))) == 1)
+ /* APPLE LOCAL end radar 4502186 */
{
if (!lvalue_p (rhs))
{
@@ -3942,7 +4218,7 @@
}
/* Some types can interconvert without explicit casts. */
else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
- && vector_types_convertible_p (type, TREE_TYPE (rhs)))
+ && vector_types_convertible_p (type, TREE_TYPE (rhs), true))
return convert (type, rhs);
/* Arithmetic types all interconvert, and enum is treated like int. */
else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
@@ -4069,8 +4345,13 @@
else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
&& (coder == codel))
{
- tree ttl = TREE_TYPE (type);
- tree ttr = TREE_TYPE (rhstype);
+ /* APPLE LOCAL begin radar 4193359 */
+ /* Types differing only by the presence of the 'volatile'
+ qualifier are acceptable if the 'volatile' has been added
+ in by the Objective-C EH machinery. */
+ tree ttl = objc_non_volatilized_type (TREE_TYPE (type));
+ tree ttr = objc_non_volatilized_type (TREE_TYPE (rhstype));
+ /* APPLE LOCAL end radar 4193359 */
tree mvl = ttl;
tree mvr = ttr;
bool is_opaque_pointer;
@@ -4162,10 +4443,7 @@
{
if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
{
- /* Types differing only by the presence of the 'volatile'
- qualifier are acceptable if the 'volatile' has been added
- in by the Objective-C EH machinery. */
- if (!objc_type_quals_match (ttl, ttr))
+ /* APPLE LOCAL begin radar 4193359 */
WARN_FOR_ASSIGNMENT (G_("passing argument %d of %qE discards "
"qualifiers from pointer target type"),
G_("assignment discards qualifiers "
@@ -4246,6 +4524,43 @@
return convert (type, rhs);
}
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ else if (codel == BLOCK_POINTER_TYPE && coder == INTEGER_TYPE)
+ {
+ if (!null_pointer_constant_p (rhs))
+ {
+ error("invalid conversion %s integer 'int', expected block pointer",
+ errtype == ic_assign ? "assigning" : "initializing");
+ return error_mark_node;
+ }
+ return build_int_cst (type, 0);
+ }
+ else if (codel == BLOCK_POINTER_TYPE && coder == codel)
+ {
+ tree lhptee = TREE_TYPE (type);
+ tree rhptee = TREE_TYPE(rhstype);
+ if (lhptee == rhptee)
+ return rhs;
+ if (!types_are_block_compatible (lhptee, rhptee))
+ {
+ error ("incompatible block pointer types %s %qT, expected %qT",
+ errtype == ic_assign ? "assigning" : "initializing",
+ rhstype, type);
+ return error_mark_node;
+ }
+ return rhs;
+ }
+ /* APPLE LOCAL begin radar 5831855 */
+ /* APPLE LOCAL radar 5878380 */
+ else if (codel == BLOCK_POINTER_TYPE && POINTER_TYPE_P (rhstype) &&
+ (VOID_TYPE_P (TREE_TYPE (rhstype)) || objc_is_id (rhstype)))
+ return convert (type, rhs);
+ /* APPLE LOCAL radar 5878380 */
+ else if (coder == BLOCK_POINTER_TYPE && POINTER_TYPE_P (type) &&
+ (VOID_TYPE_P (TREE_TYPE (type)) || objc_is_id (type)))
+ /* APPLE LOCAL end radar 5831855 */
+ return convert (type, rhs);
+ /* APPLE LOCAL end radar 5732232 - blocks */
else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
{
WARN_FOR_ASSIGNMENT (G_("passing argument %d of %qE makes integer "
@@ -4267,7 +4582,7 @@
case ic_argpass_nonproto:
/* ??? This should not be an error when inlining calls to
unprototyped functions. */
- error ("incompatible type for argument %d of %qE", parmnum, rname);
+ error ("convert_for_assignment: incompatible type for argument %d of %qE", parmnum, rname);
break;
case ic_assign:
error ("incompatible types in assignment");
@@ -4580,6 +4895,13 @@
pedwarn_init ("array initialized from parenthesized string constant");
}
+/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
+tree do_digest_init (tree type, tree init)
+{
+ return digest_init (type, init, true, false);
+}
+/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+
/* Digest the parser output INIT as an initializer for type TYPE.
Return a C expression of type TYPE to represent the initial value.
@@ -4678,7 +5000,7 @@
below and handle as a constructor. */
if (code == VECTOR_TYPE
&& TREE_CODE (TREE_TYPE (inside_init)) == VECTOR_TYPE
- && vector_types_convertible_p (TREE_TYPE (inside_init), type)
+ && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
&& TREE_CONSTANT (inside_init))
{
if (TREE_CODE (inside_init) == VECTOR_CST
@@ -4789,7 +5111,10 @@
}
/* Added to enable additional -Wmissing-format-attribute warnings. */
- if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
+ /* APPLE LOCAL begin radar 5822844 */
+ if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE ||
+ TREE_CODE (TREE_TYPE (inside_init)) == BLOCK_POINTER_TYPE)
+ /* APPLE LOCAL end radar 5822844 */
inside_init = convert_for_assignment (type, inside_init, ic_init, NULL_TREE,
NULL_TREE, 0);
return inside_init;
@@ -4798,6 +5123,8 @@
/* Handle scalar types, including conversions. */
if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
+ /* APPLE LOCAL radar 5732232 - blocks */
+ || code == BLOCK_POINTER_TYPE
|| code == ENUMERAL_TYPE || code == BOOLEAN_TYPE || code == COMPLEX_TYPE
|| code == VECTOR_TYPE)
{
@@ -5514,6 +5841,16 @@
{
if (constructor_erroneous)
ret.value = error_mark_node;
+ /* APPLE LOCAL begin radar 4188876 */
+ else if (!constructor_constant
+ && TREE_CODE (constructor_type) == VECTOR_TYPE && constructor_decl
+ && (TREE_CODE (TREE_TYPE (constructor_decl)) == RECORD_TYPE
+ || TREE_CODE (TREE_TYPE (constructor_decl)) == UNION_TYPE))
+ {
+ error ("Initializer is a non-const vector type");
+ ret.value = error_mark_node;
+ }
+ /* APPLE LOCAL end radar 4188876 */
else
{
ret.value = build_constructor (constructor_type,
@@ -5704,6 +6041,7 @@
void
set_init_label (tree fieldname)
{
+ tree anon = NULL_TREE;
tree tail;
if (set_designator (0))
@@ -5721,6 +6059,15 @@
for (tail = TYPE_FIELDS (constructor_type); tail;
tail = TREE_CHAIN (tail))
{
+ if (DECL_NAME (tail) == NULL_TREE
+ && (TREE_CODE (TREE_TYPE (tail)) == RECORD_TYPE
+ || TREE_CODE (TREE_TYPE (tail)) == UNION_TYPE))
+ {
+ anon = lookup_field (tail, fieldname);
+ if (anon)
+ break;
+ }
+
if (DECL_NAME (tail) == fieldname)
break;
}
@@ -5727,7 +6074,8 @@
if (tail == 0)
error ("unknown field %qE specified in initializer", fieldname);
- else
+
+ while (tail)
{
constructor_fields = tail;
designator_depth++;
@@ -5734,6 +6082,16 @@
designator_erroneous = 0;
if (constructor_range_stack)
push_range_stack (NULL_TREE);
+
+ if (anon)
+ {
+ if (set_designator (0))
+ return;
+ tail = TREE_VALUE(anon);
+ anon = TREE_CHAIN(anon);
+ }
+ else
+ tail = NULL_TREE;
}
}
@@ -6982,6 +7340,65 @@
return add_stmt (build1 (GOTO_EXPR, void_type_node, expr));
}
+/* APPLE LOCAL begin radar 5732232 - blocks (C++ cm) */
+/** c_finish_block_return_stmt - Utilty routine to figure out block's return
+ type.
+ */
+static tree
+c_finish_block_return_stmt (tree retval)
+{
+ tree valtype;
+ /* If this is the first return we've seen in the block, infer the type of
+ the block from it. */
+ if (cur_block->return_type == NULL_TREE)
+ {
+ tree restype;
+ if (retval)
+ {
+ restype = TYPE_MAIN_VARIANT (TREE_TYPE (retval));
+ TREE_TYPE (current_function_decl)
+ = build_function_type (restype,
+ TYPE_ARG_TYPES (TREE_TYPE (current_function_decl)));
+ TREE_TYPE (DECL_RESULT (current_function_decl)) = restype;
+ relayout_decl (DECL_RESULT (current_function_decl));
+ }
+ else
+ restype = void_type_node;
+
+ cur_block->return_type = restype;
+ }
+
+ /* Verify that this result type matches the previous one. We are
+ pickier with blocks than for normal functions because this is a
+ new feature and we set the rules. */
+ if (TREE_CODE (cur_block->return_type) == VOID_TYPE)
+ {
+ if (retval)
+ {
+ error ("void block should not return a value");
+ retval = NULL_TREE;
+ }
+ return retval;
+ }
+
+ if (!retval)
+ {
+ error ("non-void block should return a value");
+ return error_mark_node;
+ }
+
+ /* We have a non-void block with an expression, continue checking. */
+ valtype = TREE_TYPE (retval);
+
+ /* For now, restrict multiple return statements in a block to have
+ strict compatible types only. */
+ if (!types_are_block_compatible (cur_block->return_type, valtype))
+ error ("incompatible type returning %qT, expected %qT",
+ valtype, cur_block->return_type);
+ return retval;
+}
+/* APPLE LOCAL end radar 5732232 - blocks (C++ cm) */
+
/* Generate a C `return' statement. RETVAL is the expression for what
to return, or a null pointer for `return;' with no value. */
@@ -6988,8 +7405,20 @@
tree
c_finish_return (tree retval)
{
- tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ tree valtype, ret_stmt;
bool no_warning = false;
+
+ /* APPLE LOCAL radar 5822844 - radar 6185344 */
+ if (cur_block && !cur_block->block_has_return_type)
+ {
+ retval = c_finish_block_return_stmt (retval);
+ if (retval == error_mark_node)
+ return NULL_TREE;
+ }
+
+ valtype = TREE_TYPE (TREE_TYPE (current_function_decl));
+ /* APPLE LOCAL end radar 5732232 - blocks */
if (TREE_THIS_VOLATILE (current_function_decl))
warning (0, "function declared %<noreturn%> has a %<return%> statement");
@@ -7066,7 +7495,15 @@
&& !DECL_EXTERNAL (inner)
&& !TREE_STATIC (inner)
&& DECL_CONTEXT (inner) == current_function_decl)
- warning (0, "function returns address of local variable");
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ cn) */
+ {
+ if (TREE_CODE (valtype) == BLOCK_POINTER_TYPE)
+ /* APPLE LOCAL radar 6048570 */
+ error ("returning block that lives on the local stack");
+ else
+ warning (0, "function returns address of local variable");
+ }
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ cn) */
break;
default:
@@ -7296,15 +7733,22 @@
add_stmt (stmt);
}
-/* Emit a general-purpose loop construct. START_LOCUS is the location of
- the beginning of the loop. COND is the loop condition. COND_IS_FIRST
- is false for DO loops. INCR is the FOR increment expression. BODY is
- the statement controlled by the loop. BLAB is the break label. CLAB is
- the continue label. Everything is allowed to be NULL. */
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+/* Emit a general-purpose loop construct. START_LOCUS is the location
+ of the beginning of the loop. COND is the loop condition.
+ COND_IS_FIRST is false for DO loops. INCR is the FOR increment
+ expression. BODY is the statement controlled by the loop. BLAB is
+ the break label. CLAB is the continue label. ATTRS is the
+ attributes associated with the loop, which at present are
+ associated with the topmost label. Everything is allowed to be
+ NULL. */
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
void
c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
- tree blab, tree clab, bool cond_is_first)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tree blab, tree clab, tree attrs, bool cond_is_first)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
{
tree entry = NULL, exit = NULL, t;
@@ -7327,6 +7771,11 @@
then we just build a jump back to the top. */
exit = build_and_jump (&LABEL_EXPR_LABEL (top));
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ /* Add the attributes to the 'top' label. */
+ decl_attributes (&LABEL_EXPR_LABEL (top), attrs, 0);
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
if (cond && !integer_nonzerop (cond))
{
/* Canonicalize the loop condition to the end. This means
@@ -7868,11 +8317,11 @@
if ((invalid_op_diag
= targetm.invalid_binary_op (code, type0, type1)))
{
- error (invalid_op_diag);
+ error (invalid_op_diag, "");
return error_mark_node;
}
- objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
+ objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE, "comparison");
switch (code)
{
@@ -7973,8 +8422,12 @@
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
+ /* APPLE LOCAL radar 5928316 */
+ || code0 == BLOCK_POINTER_TYPE
|| code0 == REAL_TYPE || code0 == COMPLEX_TYPE)
&& (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
+ /* APPLE LOCAL radar 5928316 */
+ || code1 == BLOCK_POINTER_TYPE
|| code1 == REAL_TYPE || code1 == COMPLEX_TYPE))
{
/* Result of these operations is always an int,
@@ -8055,7 +8508,10 @@
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
|| code1 == COMPLEX_TYPE))
short_compare = 1;
- else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+ /* APPLE LOCAL begin blocks 6065211 */
+ else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE)
+ && (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
+ /* APPLE LOCAL end blocks 6065211 */
{
tree tt0 = TREE_TYPE (type0);
tree tt1 = TREE_TYPE (type1);
@@ -8064,6 +8520,12 @@
and both must be object or both incomplete. */
if (comp_target_types (type0, type1))
result_type = common_pointer_type (type0, type1);
+ /* APPLE LOCAL begin blocks 6065211 */
+ else if (code1 == BLOCK_POINTER_TYPE && VOID_TYPE_P (tt0))
+ ;
+ else if (code0 == BLOCK_POINTER_TYPE && VOID_TYPE_P (tt1))
+ ;
+ /* APPLE LOCAL end blocks 6065211 */
else if (VOID_TYPE_P (tt0))
{
/* op0 != orig_op0 detects the case of something
@@ -8083,7 +8545,14 @@
else
/* Avoid warning about the volatile ObjC EH puts on decls. */
if (!objc_ok)
- pedwarn ("comparison of distinct pointer types lacks a cast");
+ /* APPLE LOCAL begin blocks 6065211 */
+ {
+ if (code0 == BLOCK_POINTER_TYPE || code1 == BLOCK_POINTER_TYPE)
+ pedwarn ("comparison of distinct block types lacks a cast");
+ else
+ pedwarn ("comparison of distinct pointer types lacks a cast");
+ }
+ /* APPLE LOCAL end blocks 6065211 */
if (result_type == NULL_TREE)
result_type = ptr_type_node;
@@ -8120,6 +8589,12 @@
result_type = type1;
pedwarn ("comparison between pointer and integer");
}
+ /* APPLE LOCAL begin radar 5732232 - blocks (C++ cl) */
+ else if (code0 == BLOCK_POINTER_TYPE && null_pointer_constant_p (orig_op1))
+ result_type = type0;
+ else if (code1 == BLOCK_POINTER_TYPE && null_pointer_constant_p (orig_op0))
+ result_type = type1;
+ /* APPLE LOCAL end radar 5732232 - blocks (C++ cl) */
break;
case LE_EXPR:
@@ -8184,7 +8659,7 @@
|| !same_scalar_type_ignoring_signedness (TREE_TYPE (type0),
TREE_TYPE (type1))))
{
- binary_op_error (code);
+ binary_op_error (code, type0, type1);
return error_mark_node;
}
@@ -8480,7 +8955,7 @@
if (!result_type)
{
- binary_op_error (code);
+ binary_op_error (code, TREE_TYPE (op0), TREE_TYPE (op1));
return error_mark_node;
}
Modified: trunk/contrib/gcc/c.opt
===================================================================
--- trunk/contrib/gcc4/c.opt 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/c.opt 2018-06-04 17:30:21 UTC (rev 10405)
@@ -20,7 +20,7 @@
; See the GCC internals manual for a description of this file's format.
-; $MidnightBSD$
+; $FreeBSD: stable/10/contrib/gcc/c.opt 261306 2014-01-31 03:30:09Z pfg $
; Please try to keep this file in ASCII collating order.
Language
@@ -280,10 +280,18 @@
C ObjC C++ ObjC++
Warn about user-specified include directories that do not exist
+; APPLE LOCAL begin warn missing prototype 6261539
Wmissing-prototypes
-C ObjC Var(warn_missing_prototypes)
+C ObjC C++ ObjC++ Var(warn_missing_prototypes)
Warn about global functions without prototypes
+; APPLE LOCAL end warn missing prototype 6261539
+; APPLE LOCAL begin -Wmost
+Wmost
+C ObjC C++ ObjC++
+Like -Wall but without -Wparentheses
+; APPLE LOCAL end -Wmost
+
Wmultichar
C ObjC C++ ObjC++
Warn about use of multi-character character constants
@@ -292,6 +300,12 @@
C ObjC Var(warn_nested_externs)
Warn about \"extern\" declarations not at file scope
+; APPLE LOCAL begin -Wnewline-eof
+Wnewline-eof
+C ObjC C++ ObjC++
+Warn about files missing a newline at the end of the file
+; APPLE LOCAL end -Wnewline-eof
+
Wnon-template-friend
C++ ObjC++ Var(warn_nontemplate_friend) Init(1)
Warn when non-templatized friend functions are declared within a template
@@ -432,6 +446,10 @@
C ObjC C++ ObjC++
Do not warn about using variadic macros when -pedantic
+Wvla
+C ObjC C++ ObjC++ Var(warn_vla) Init(-1) Warning
+Warn if a variable length array is used
+
Wwrite-strings
C ObjC C++ ObjC++ Var(warn_write_strings)
In C++, nonzero means warn about deprecated conversion from string literals to `char *'. In C, similar warning, except that the conversion is of course not deprecated by the ISO C standard.
@@ -490,6 +508,10 @@
C++ ObjC++
Inline member functions by default
+fdirectives-only
+C ObjC C++ ObjC++
+Preprocess directives only.
+
fdollars-in-identifiers
C ObjC C++ ObjC++
Permit '$' as an identifier character
@@ -576,6 +598,10 @@
flabels-ok
C++ ObjC++
+flax-vector-conversions
+C ObjC C++ ObjC++
+Allow implicit conversions between vectors with differing numbers of subparts and/or differing element types.
+
fms-extensions
C ObjC C++ ObjC++
Don't warn about uses of Microsoft extensions
@@ -586,6 +612,12 @@
fnew-abi
C++ ObjC++
+; APPLE LOCAL begin nested functions 4258406 4357979
+fnested-functions
+C ObjC Var(flag_nested_functions)
+Allow nested functions.
+; APPLE LOCAL end nested functions 4258406 4357979
+
fnext-runtime
ObjC ObjC++
Generate code for NeXT (Apple Mac OS X) runtime environment
@@ -620,6 +652,12 @@
ObjC ObjC++ Var(flag_objc_gc)
Enable garbage collection (GC) in Objective-C/Objective-C++ programs
+; APPLE LOCAL begin radar 5811887 - blocks
+fblocks
+C ObjC C++ ObjC++ Var(flag_blocks) Init(-1)
+Program supports c/objc extension blocks
+; APPLE LOCAL end radar 5811887 - blocks
+
; Nonzero means that we generate NeXT setjmp based exceptions.
fobjc-sjlj-exceptions
ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1)
@@ -729,6 +767,10 @@
C++ ObjC++
Marks all inlined methods as having hidden visibility
+fvisibility-ms-compat
+C++ ObjC++ Var(flag_visibility_ms_compat)
+Changes visibility to match Microsoft Visual Studio by default
+
fvtable-gc
C++ ObjC++
Discard unused virtual functions
@@ -761,6 +803,18 @@
ObjC ObjC++
Dump declarations to a .decl file
+femit-struct-debug-baseonly
+C ObjC C++ ObjC++
+-femit-struct-debug-baseonly Aggressive reduced debug info for structs
+
+femit-struct-debug-reduced
+C ObjC C++ ObjC++
+-femit-struct-debug-reduced Conservative reduced debug info for structs
+
+femit-struct-debug-detailed=
+C ObjC C++ ObjC++ Joined
+-femit-struct-debug-detailed=<spec-list> Detailed reduced debug info for structs
+
idirafter
C ObjC C++ ObjC++ Joined Separate
-idirafter <dir> Add <dir> to the end of the system include path
Modified: trunk/contrib/gcc/calls.c
===================================================================
--- trunk/contrib/gcc4/calls.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/calls.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2051,7 +2051,8 @@
/* Operand 0 is a pointer-to-function; get the type of the function. */
funtype = TREE_TYPE (addr);
- gcc_assert (POINTER_TYPE_P (funtype));
+ /* APPLE LOCAL blocks */
+ gcc_assert (POINTER_TYPE_P (funtype) || TREE_CODE (funtype) == BLOCK_POINTER_TYPE);
funtype = TREE_TYPE (funtype);
/* Munge the tree to split complex arguments into their imaginary
@@ -4297,6 +4298,7 @@
/* expand_call should ensure this. */
gcc_assert (!arg->locate.offset.var
+ && arg->locate.size.var == 0
&& GET_CODE (size_rtx) == CONST_INT);
if (arg->locate.offset.constant > i)
@@ -4306,9 +4308,23 @@
}
else if (arg->locate.offset.constant < i)
{
- if (i < arg->locate.offset.constant + INTVAL (size_rtx))
+ /* Use arg->locate.size.constant instead of size_rtx
+ because we only care about the part of the argument
+ on the stack. */
+ if (i < (arg->locate.offset.constant
+ + arg->locate.size.constant))
sibcall_failure = 1;
}
+ else
+ {
+ /* Even though they appear to be at the same location,
+ if part of the outgoing argument is in registers,
+ they aren't really at the same location. Check for
+ this by making sure that the incoming size is the
+ same as the outgoing size. */
+ if (arg->locate.size.constant != INTVAL (size_rtx))
+ sibcall_failure = 1;
+ }
}
}
Modified: trunk/contrib/gcc/cfg.c
===================================================================
--- trunk/contrib/gcc4/cfg.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cfg.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -830,7 +830,7 @@
else
fprintf (file, ", ");
first = false;
- fputs (bb_bitnames[i], file);
+ fprintf (file, "%s", bb_bitnames[i]);
}
if (!first)
fprintf (file, ")");
Modified: trunk/contrib/gcc/cfgexpand.c
===================================================================
--- trunk/contrib/gcc4/cfgexpand.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cfgexpand.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -810,6 +810,12 @@
clear_tree_used (t);
}
+enum {
+ SPCT_FLAG_DEFAULT = 1,
+ SPCT_FLAG_ALL = 2,
+ SPCT_FLAG_STRONG = 3
+};
+
/* Examine TYPE and determine a bit mask of the following features. */
#define SPCT_HAS_LARGE_CHAR_ARRAY 1
@@ -879,7 +885,8 @@
if (bits & SPCT_HAS_SMALL_CHAR_ARRAY)
has_short_buffer = true;
- if (flag_stack_protect == 2)
+ if (flag_stack_protect == SPCT_FLAG_ALL
+ || flag_stack_protect == SPCT_FLAG_STRONG)
{
if ((bits & (SPCT_HAS_SMALL_CHAR_ARRAY | SPCT_HAS_LARGE_CHAR_ARRAY))
&& !(bits & SPCT_HAS_AGGREGATE))
@@ -947,6 +954,29 @@
cfun->stack_protect_guard = guard;
}
+/* Helper routine to check if a record or union contains an array field. */
+
+static int
+record_or_union_type_has_array_p (tree tree_type)
+{
+ tree fields = TYPE_FIELDS (tree_type);
+ tree f;
+
+ for (f = fields; f; f = TREE_CHAIN (f))
+ if (TREE_CODE (f) == FIELD_DECL)
+ {
+ tree field_type = TREE_TYPE (f);
+ if ((TREE_CODE (field_type) == RECORD_TYPE
+ || TREE_CODE (field_type) == UNION_TYPE
+ || TREE_CODE (field_type) == QUAL_UNION_TYPE)
+ && record_or_union_type_has_array_p (field_type))
+ return 1;
+ if (TREE_CODE (field_type) == ARRAY_TYPE)
+ return 1;
+ }
+ return 0;
+}
+
/* Expand all variables used in the function. */
static void
@@ -953,6 +983,7 @@
expand_used_vars (void)
{
tree t, outer_block = DECL_INITIAL (current_function_decl);
+ bool gen_stack_protect_signal = false;
/* Compute the phase of the stack frame for this function. */
{
@@ -972,6 +1003,29 @@
has_protected_decls = false;
has_short_buffer = false;
+ if (flag_stack_protect == SPCT_FLAG_STRONG)
+ for (t = cfun->unexpanded_var_list; t; t = TREE_CHAIN (t))
+ {
+ tree var = TREE_VALUE (t);
+ if (!is_global_var (var))
+ {
+ tree var_type = TREE_TYPE (var);
+ /* Examine local referenced variables that have their addresses
+ * taken, contain an array, or are arrays. */
+ if (TREE_CODE (var) == VAR_DECL
+ && (TREE_CODE (var_type) == ARRAY_TYPE
+ || TREE_ADDRESSABLE (var)
+ || ((TREE_CODE (var_type) == RECORD_TYPE
+ || TREE_CODE (var_type) == UNION_TYPE
+ || TREE_CODE (var_type) == QUAL_UNION_TYPE)
+ && record_or_union_type_has_array_p (var_type))))
+ {
+ gen_stack_protect_signal = true;
+ break;
+ }
+ }
+ }
+
/* At this point all variables on the unexpanded_var_list with TREE_USED
set are not associated with any block scope. Lay them out. */
for (t = cfun->unexpanded_var_list; t; t = TREE_CHAIN (t))
@@ -1032,13 +1086,27 @@
dump_stack_var_partition ();
}
- /* There are several conditions under which we should create a
- stack guard: protect-all, alloca used, protected decls present. */
- if (flag_stack_protect == 2
- || (flag_stack_protect
- && (current_function_calls_alloca || has_protected_decls)))
- create_stack_guard ();
+ switch (flag_stack_protect)
+ {
+ case SPCT_FLAG_ALL:
+ create_stack_guard ();
+ break;
+ case SPCT_FLAG_STRONG:
+ if (gen_stack_protect_signal
+ || current_function_calls_alloca || has_protected_decls)
+ create_stack_guard ();
+ break;
+
+ case SPCT_FLAG_DEFAULT:
+ if (current_function_calls_alloca || has_protected_decls)
+ create_stack_guard();
+ break;
+
+ default:
+ ;
+ }
+
/* Assign rtl to each variable based on these partitions. */
if (stack_vars_num > 0)
{
Modified: trunk/contrib/gcc/cgraph.h
===================================================================
--- trunk/contrib/gcc4/cgraph.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cgraph.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -302,6 +302,8 @@
void cgraph_add_new_function (tree);
/* In cgraphunit.c */
+/* APPLE LOCAL radar 6305545 */
+void lower_if_nested_functions (tree);
bool cgraph_assemble_pending_functions (void);
bool cgraph_varpool_assemble_pending_decls (void);
void cgraph_finalize_function (tree, bool);
Modified: trunk/contrib/gcc/cgraphunit.c
===================================================================
--- trunk/contrib/gcc4/cgraphunit.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cgraphunit.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -458,6 +458,19 @@
node->lowered = true;
}
+/* APPLE LOCAL begin radar 6305545 */
+/** lower_if_nested_functions - This routine is called from cplus side only.
+ Its purpose is to lower block helper (or any other nested function)
+ which may have been nested in a constructor or destructor. We have to
+ do this because structors are cloned and are not lowered themselves (which
+ is the only way to lower the nested functions). */
+void
+lower_if_nested_functions (tree decl)
+{
+ lower_nested_functions (decl, true);
+}
+/* APPLE LOCAL end radar 6305545 */
+
/* DECL has been parsed. Take it, queue it, compile it at the whim of the
logic in effect. If NESTED is true, then our caller cannot stand to have
the garbage collector run at the moment. We would need to either create
@@ -476,7 +489,8 @@
node->local.finalized = true;
node->lowered = DECL_STRUCT_FUNCTION (decl)->cfg != NULL;
if (node->nested)
- lower_nested_functions (decl);
+ /* APPLE LOCAL radar 6305545 */
+ lower_nested_functions (decl, false);
gcc_assert (!node->nested);
/* If not unit at a time, then we need to create the call graph
@@ -1676,7 +1690,7 @@
tree decl, name, resdecl;
sprintf (which_buf, "%c_%d", which, counter++);
- name = get_file_function_name_long (which_buf);
+ name = get_file_function_name (which_buf);
decl = build_decl (FUNCTION_DECL, name,
build_function_type (void_type_node, void_list_node));
Modified: trunk/contrib/gcc/collect2.c
===================================================================
--- trunk/contrib/gcc4/collect2.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/collect2.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -53,7 +53,7 @@
the utilities are not correct for a cross-compiler; we have to hope that
cross-versions are in the proper directories. */
-#ifdef CROSS_COMPILE
+#ifdef CROSS_DIRECTORY_STRUCTURE
#undef OBJECT_FORMAT_COFF
#undef MD_EXEC_PREFIX
#undef REAL_LD_FILE_NAME
@@ -553,7 +553,7 @@
static struct path_prefix cpath, path;
-#ifdef CROSS_COMPILE
+#ifdef CROSS_DIRECTORY_STRUCTURE
/* This is the name of the target machine. We use it to form the name
of the files to execute. */
@@ -746,7 +746,7 @@
static const char *const strip_suffix = "strip";
static const char *const gstrip_suffix = "gstrip";
-#ifdef CROSS_COMPILE
+#ifdef CROSS_DIRECTORY_STRUCTURE
/* If we look for a program in the compiler directories, we just use
the short name, since these directories are already system-specific.
But it we look for a program in the system directories, we need to
@@ -775,7 +775,7 @@
#endif
const char *const full_strip_suffix = strip_suffix;
const char *const full_gstrip_suffix = gstrip_suffix;
-#endif /* CROSS_COMPILE */
+#endif /* CROSS_DIRECTORY_STRUCTURE */
const char *arg;
FILE *outf;
@@ -957,7 +957,7 @@
c_file_name = getenv ("COLLECT_GCC");
if (c_file_name == 0)
{
-#ifdef CROSS_COMPILE
+#ifdef CROSS_DIRECTORY_STRUCTURE
c_file_name = concat (target_machine, "-gcc", NULL);
#else
c_file_name = "gcc";
@@ -1562,10 +1562,10 @@
if (err != 0)
{
errno = err;
- fatal_perror (errmsg);
+ fatal_perror ("%s", errmsg);
}
else
- fatal (errmsg);
+ fatal ("%s", errmsg);
}
return pex;
@@ -2050,10 +2050,10 @@
if (err != 0)
{
errno = err;
- fatal_perror (errmsg);
+ fatal_perror ("%s", errmsg);
}
else
- fatal (errmsg);
+ fatal ("%s", errmsg);
}
int_handler = (void (*) (int)) signal (SIGINT, SIG_IGN);
Modified: trunk/contrib/gcc/combine.c
===================================================================
--- trunk/contrib/gcc4/combine.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/combine.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2370,12 +2370,17 @@
if (i1 && GET_CODE (newpat) != CLOBBER)
{
- /* Before we can do this substitution, we must redo the test done
- above (see detailed comments there) that ensures that I1DEST
- isn't mentioned in any SETs in NEWPAT that are field assignments. */
-
- if (! combinable_i3pat (NULL_RTX, &newpat, i1dest, NULL_RTX,
- 0, (rtx*) 0))
+ /* Check that an autoincrement side-effect on I1 has not been lost.
+ This happens if I1DEST is mentioned in I2 and dies there, and
+ has disappeared from the new pattern. */
+ if ((FIND_REG_INC_NOTE (i1, NULL_RTX) != 0
+ && !i1_feeds_i3
+ && dead_or_set_p (i2, i1dest)
+ && !reg_overlap_mentioned_p (i1dest, newpat))
+ /* Before we can do this substitution, we must redo the test done
+ above (see detailed comments there) that ensures that I1DEST
+ isn't mentioned in any SETs in NEWPAT that are field assignments. */
+ || !combinable_i3pat (NULL_RTX, &newpat, i1dest, NULL_RTX, 0, 0))
{
undo_all ();
return 0;
Modified: trunk/contrib/gcc/common.opt
===================================================================
--- trunk/contrib/gcc4/common.opt 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/common.opt 2018-06-04 17:30:21 UTC (rev 10405)
@@ -95,8 +95,12 @@
Wlarger-than-
Common RejectNegative Joined UInteger
--Wlarger-than-<number> Warn if an object is larger than <number> bytes
+-Wlarger-than-<number> Warn if an object is larger than <number> bytes
+Wframe-larger-than-
+Common RejectNegative Joined UInteger
+-Wframe-larger-than-<number> Warn if the frame size of a function is larger than <number> bytes
+
Wunsafe-loop-optimizations
Common Var(warn_unsafe_loop_optimizations)
Warn if the loop cannot be optimized due to nontrivial assumptions.
@@ -537,6 +541,14 @@
Common Report Var(flag_instrument_function_entry_exit)
Instrument function entry and exit with profiling calls
+finstrument-functions-exclude-function-list=
+Common RejectNegative Joined
+-finstrument-functions-exclude-function-list=name,... Do not instrument listed functions
+
+finstrument-functions-exclude-file-list=
+Common RejectNegative Joined
+-finstrument-functions-exclude-file-list=filename,... Do not instrument functions listed in files
+
fipa-cp
Common Report Var(flag_ipa_cp)
Perform Interprocedural constant propagation
@@ -866,6 +878,10 @@
Common Report RejectNegative Var(flag_stack_protect, 2) VarExists
Use a stack protection method for every function
+fstack-protector-strong
+Common Report RejectNegative Var(flag_stack_protect, 3)
+Use a smart stack protection method for certain functions
+
fstrength-reduce
Common
Does nothing. Preserved for backward compatibility.
Modified: trunk/contrib/gcc/config/arm/arm.c
===================================================================
--- trunk/contrib/gcc4/config/arm/arm.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/arm.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -154,6 +154,7 @@
#endif
static void arm_file_end (void);
+static void arm_file_start (void);
#ifdef AOF_ASSEMBLER
static void aof_globalize_label (FILE *, const char *);
@@ -202,6 +203,9 @@
#undef TARGET_ATTRIBUTE_TABLE
#define TARGET_ATTRIBUTE_TABLE arm_attribute_table
+#undef TARGET_ASM_FILE_START
+#define TARGET_ASM_FILE_START arm_file_start
+
#undef TARGET_ASM_FILE_END
#define TARGET_ASM_FILE_END arm_file_end
@@ -390,6 +394,9 @@
/* The processor for which instructions should be scheduled. */
enum processor_type arm_tune = arm_none;
+/* The default processor used if not overriden by commandline. */
+static enum processor_type arm_default_cpu = arm_none;
+
/* Which floating point model to use. */
enum arm_fp_model arm_fp_model;
@@ -597,6 +604,8 @@
{"armv6k", mpcore, "6K", FL_CO_PROC | FL_FOR_ARCH6K, NULL},
{"armv6z", arm1176jzs, "6Z", FL_CO_PROC | FL_FOR_ARCH6Z, NULL},
{"armv6zk", arm1176jzs, "6ZK", FL_CO_PROC | FL_FOR_ARCH6ZK, NULL},
+ /* Clang compatibility... define __ARM_ARCH_7A__, but codegen is still 6ZK. */
+ {"armv7a", arm1176jzs, "7A", FL_CO_PROC | FL_FOR_ARCH6ZK, NULL},
{"ep9312", ep9312, "4T", FL_LDSCHED | FL_CIRRUS | FL_FOR_ARCH4, NULL},
{"iwmmxt", iwmmxt, "5TE", FL_LDSCHED | FL_STRONG | FL_FOR_ARCH5TE | FL_XSCALE | FL_IWMMXT , NULL},
{NULL, arm_none, NULL, 0 , NULL}
@@ -1020,8 +1029,9 @@
insn_flags = sel->flags;
}
sprintf (arm_arch_name, "__ARM_ARCH_%s__", sel->arch);
+ arm_default_cpu = (enum processor_type) (sel - all_cores);
if (arm_tune == arm_none)
- arm_tune = (enum processor_type) (sel - all_cores);
+ arm_tune = arm_default_cpu;
}
/* The processor for which we should tune should now have been
@@ -14458,6 +14468,105 @@
}
static void
+arm_file_start (void)
+{
+ int val;
+
+ if (TARGET_BPABI)
+ {
+ const char *fpu_name;
+ if (arm_select[0].string)
+ asm_fprintf (asm_out_file, "\t.cpu %s\n", arm_select[0].string);
+ else if (arm_select[1].string)
+ asm_fprintf (asm_out_file, "\t.arch %s\n", arm_select[1].string);
+ else
+ asm_fprintf (asm_out_file, "\t.cpu %s\n",
+ all_cores[arm_default_cpu].name);
+
+ if (TARGET_SOFT_FLOAT)
+ {
+ if (TARGET_VFP)
+ fpu_name = "softvfp";
+ else
+ fpu_name = "softfpa";
+ }
+ else
+ {
+ switch (arm_fpu_arch)
+ {
+ case FPUTYPE_FPA:
+ fpu_name = "fpa";
+ break;
+ case FPUTYPE_FPA_EMU2:
+ fpu_name = "fpe2";
+ break;
+ case FPUTYPE_FPA_EMU3:
+ fpu_name = "fpe3";
+ break;
+ case FPUTYPE_MAVERICK:
+ fpu_name = "maverick";
+ break;
+ case FPUTYPE_VFP:
+ if (TARGET_HARD_FLOAT)
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 27, 3\n");
+ if (TARGET_HARD_FLOAT_ABI)
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 28, 1\n");
+ fpu_name = "vfp";
+ break;
+ default:
+ abort();
+ }
+ }
+ asm_fprintf (asm_out_file, "\t.fpu %s\n", fpu_name);
+
+ /* Some of these attributes only apply when the corresponding features
+ are used. However we don't have any easy way of figuring this out.
+ Conservatively record the setting that would have been used. */
+
+ /* Tag_ABI_PCS_wchar_t. */
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 18, %d\n",
+ (int)WCHAR_TYPE_SIZE / BITS_PER_UNIT);
+
+ /* Tag_ABI_FP_rounding. */
+ if (flag_rounding_math)
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 19, 1\n");
+ if (!flag_unsafe_math_optimizations)
+ {
+ /* Tag_ABI_FP_denomal. */
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 20, 1\n");
+ /* Tag_ABI_FP_exceptions. */
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 21, 1\n");
+ }
+ /* Tag_ABI_FP_user_exceptions. */
+ if (flag_signaling_nans)
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 22, 1\n");
+ /* Tag_ABI_FP_number_model. */
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 23, %d\n",
+ flag_finite_math_only ? 1 : 3);
+
+ /* Tag_ABI_align8_needed. */
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 24, 1\n");
+ /* Tag_ABI_align8_preserved. */
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 25, 1\n");
+ /* Tag_ABI_enum_size. */
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 26, %d\n",
+ flag_short_enums ? 1 : 2);
+
+ /* Tag_ABI_optimization_goals. */
+ if (optimize_size)
+ val = 4;
+ else if (optimize >= 2)
+ val = 2;
+ else if (optimize)
+ val = 1;
+ else
+ val = 6;
+ asm_fprintf (asm_out_file, "\t.eabi_attribute 30, %d\n", val);
+ }
+ default_file_start();
+}
+
+static void
arm_file_end (void)
{
int regno;
Modified: trunk/contrib/gcc/config/arm/arm.h
===================================================================
--- trunk/contrib/gcc4/config/arm/arm.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/arm.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1866,8 +1866,10 @@
# define DTOR_LIST_BEGIN asm (ARM_EABI_DTORS_SECTION_OP)
# define DTOR_LIST_END /* empty */
# else /* !defined (__ARM_EABI__) */
+# ifndef __clang__
# define CTORS_SECTION_ASM_OP ARM_CTORS_SECTION_OP
# define DTORS_SECTION_ASM_OP ARM_DTORS_SECTION_OP
+# endif
# endif /* !defined (__ARM_EABI__) */
#endif /* !defined (IN_LIBCC2) */
Modified: trunk/contrib/gcc/config/arm/arm.md
===================================================================
--- trunk/contrib/gcc4/config/arm/arm.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/arm.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -8841,15 +8841,12 @@
(clobber (reg:CC CC_REGNUM))]
"TARGET_ARM"
"*
- if (GET_CODE (operands[3]) == LT && operands[3] == const0_rtx)
+ if (GET_CODE (operands[3]) == LT && operands[2] == const0_rtx)
return \"mov\\t%0, %1, asr #31\";
if (GET_CODE (operands[3]) == NE)
return \"subs\\t%0, %1, %2\;mvnne\\t%0, #0\";
- if (GET_CODE (operands[3]) == GT)
- return \"subs\\t%0, %1, %2\;mvnne\\t%0, %0, asr #31\";
-
output_asm_insn (\"cmp\\t%1, %2\", operands);
output_asm_insn (\"mov%D3\\t%0, #0\", operands);
return \"mvn%d3\\t%0, #0\";
Modified: trunk/contrib/gcc/config/arm/freebsd.h
===================================================================
--- trunk/contrib/gcc4/config/arm/freebsd.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/freebsd.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -29,8 +29,13 @@
{ "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }
#undef SUBTARGET_EXTRA_ASM_SPEC
+#ifdef TARGET_ARM_EABI
#define SUBTARGET_EXTRA_ASM_SPEC \
+ "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=4} %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
+#else
+#define SUBTARGET_EXTRA_ASM_SPEC \
"-matpcs %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
+#endif
/* Default to full FPA if -mhard-float is specified. */
#undef SUBTARGET_ASM_FLOAT_SPEC
@@ -50,18 +55,35 @@
%{rdynamic:-export-dynamic} \
%{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
%{static:-Bstatic}} \
+ %{!static:--hash-style=both --enable-new-dtags} \
%{symbolic:-Bsymbolic} \
-X %{mbig-endian:-EB} %{mlittle-endian:-EL}"
/************************[ Target stuff ]***********************************/
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (FreeBSD/StrongARM ELF)");
#ifndef TARGET_ENDIAN_DEFAULT
#define TARGET_ENDIAN_DEFAULT 0
#endif
+#ifdef TARGET_ARM_EABI
+/* We default to a soft-float ABI so that binaries can run on all
+ target hardware. */
+#undef TARGET_DEFAULT_FLOAT_ABI
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+
+#undef ARM_DEFAULT_ABI
+#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do \
+ { \
+ FBSD_TARGET_OS_CPP_BUILTINS(); \
+ TARGET_BPABI_CPP_BUILTINS(); \
+ } \
+ while (false)
+#else
/* Default it to use ATPCS with soft-VFP. */
#undef TARGET_DEFAULT
#define TARGET_DEFAULT \
@@ -71,6 +93,10 @@
#undef ARM_DEFAULT_ABI
#define ARM_DEFAULT_ABI ARM_ABI_ATPCS
+#undef FPUTYPE_DEFAULT
+#define FPUTYPE_DEFAULT FPUTYPE_VFP
+#endif
+
/* Define the actual types of some ANSI-mandated types.
Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c,
c-common.c, and config/<arch>/<arch>.h. */
@@ -86,8 +112,22 @@
/* We use the GCC defaults here. */
#undef WCHAR_TYPE
+#if defined(FREEBSD_ARCH_armv6)
#undef SUBTARGET_CPU_DEFAULT
-#define SUBTARGET_CPU_DEFAULT TARGET_CPU_strongarm
+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm1176jzs
+#undef FBSD_TARGET_CPU_CPP_BUILTINS
+#define FBSD_TARGET_CPU_CPP_BUILTINS() \
+ do { \
+ builtin_define ("__FreeBSD_ARCH_armv6__"); \
+ } while (0)
+#undef TARGET_VERSION
+#define TARGET_VERSION fprintf (stderr, " (FreeBSD/armv6 ELF)");
+#else
+#undef SUBTARGET_CPU_DEFAULT
+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9
+#undef TARGET_VERSION
+#define TARGET_VERSION fprintf (stderr, " (FreeBSD/StrongARM ELF)");
+#endif
/* FreeBSD does its profiling differently to the Acorn compiler. We
don't need a word following the mcount call; and to skip it
@@ -121,5 +161,3 @@
} \
while (0)
-#undef FPUTYPE_DEFAULT
-#define FPUTYPE_DEFAULT FPUTYPE_VFP
Modified: trunk/contrib/gcc/config/arm/ieee754-df.S
===================================================================
--- trunk/contrib/gcc4/config/arm/ieee754-df.S 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/ieee754-df.S 2018-06-04 17:30:21 UTC (rev 10405)
@@ -43,7 +43,7 @@
@ For FPA, float words are always big-endian.
@ For VFP, floats words follow the memory system mode.
-#if defined(__VFP_FP__) && !defined(__ARMEB__)
+#if (defined(__ARM_EABI__) || defined(__VFP_FP__)) && !defined(__ARMEB__)
#define xl r0
#define xh r1
#define yl r2
Modified: trunk/contrib/gcc/config/arm/lib1funcs.asm
===================================================================
--- trunk/contrib/gcc4/config/arm/lib1funcs.asm 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/lib1funcs.asm 2018-06-04 17:30:21 UTC (rev 10405)
@@ -980,8 +980,6 @@
RET
- FUNC_END aeabi_ldiv0
- FUNC_END aeabi_idiv0
FUNC_END div0
#endif /* L_divmodsi_tools */
Modified: trunk/contrib/gcc/config/arm/libunwind.S
===================================================================
--- trunk/contrib/gcc4/config/arm/libunwind.S 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/libunwind.S 2018-06-04 17:30:21 UTC (rev 10405)
@@ -26,6 +26,13 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
+#include <machine/acle-compat.h>
+
+/* Allow the use of VFP instructions */
+#if __ARM_ARCH >= 7
+.fpu vfp
+#endif
+
#ifndef __symbian__
#include "lib1funcs.asm"
@@ -66,7 +73,11 @@
ARM_FUNC_START gnu_Unwind_Restore_VFP
/* Use the generic coprocessor form so that gas doesn't complain
on soft-float targets. */
+#if __ARM_ARCH >= 7
+ fldmiax r0, {d0-d15}
+#else
ldc p11,cr0,[r0],{0x21} /* fldmiax r0, {d0-d15} */
+#endif
RET
/* Store VFR regsters d0-d15 to the address in r0. */
@@ -73,7 +84,11 @@
ARM_FUNC_START gnu_Unwind_Save_VFP
/* Use the generic coprocessor form so that gas doesn't complain
on soft-float targets. */
+#if __ARM_ARCH >= 7
+ fstmiax r0, {d0-d15}
+#else
stc p11,cr0,[r0],{0x21} /* fstmiax r0, {d0-d15} */
+#endif
RET
/* Wrappers to save core registers, then call the real routine. */
@@ -116,5 +131,6 @@
UNWIND_WRAPPER _Unwind_Resume 1
UNWIND_WRAPPER _Unwind_Resume_or_Rethrow 1
UNWIND_WRAPPER _Unwind_ForcedUnwind 3
+UNWIND_WRAPPER _Unwind_Backtrace 2
-#endif /* __symbian__ */
+#endif /* ndef __symbian__ */
Modified: trunk/contrib/gcc/config/arm/unwind-arm.c
===================================================================
--- trunk/contrib/gcc4/config/arm/unwind-arm.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/unwind-arm.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -747,6 +747,66 @@
}
+/* Perform stack backtrace through unwind data. */
+_Unwind_Reason_Code
+__gnu_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument,
+ phase2_vrs * entry_vrs);
+_Unwind_Reason_Code
+__gnu_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument,
+ phase2_vrs * entry_vrs)
+{
+ phase1_vrs saved_vrs;
+ _Unwind_Reason_Code code;
+
+ _Unwind_Control_Block ucb;
+ _Unwind_Control_Block *ucbp = &ucb;
+
+ /* Set the pc to the call site. */
+ entry_vrs->core.r[R_PC] = entry_vrs->core.r[R_LR];
+
+ /* Save the core registers. */
+ saved_vrs.core = entry_vrs->core;
+ /* Set demand-save flags. */
+ saved_vrs.demand_save_flags = ~(_uw) 0;
+
+ do
+ {
+ /* Find the entry for this routine. */
+ if (get_eit_entry (ucbp, saved_vrs.core.r[R_PC]) != _URC_OK)
+ {
+ code = _URC_FAILURE;
+ break;
+ }
+
+ /* The dwarf unwinder assumes the context structure holds things
+ like the function and LSDA pointers. The ARM implementation
+ caches these in the exception header (UCB). To avoid
+ rewriting everything we make the virtual IP register point at
+ the UCB. */
+ _Unwind_SetGR((_Unwind_Context *)&saved_vrs, 12, (_Unwind_Ptr) ucbp);
+
+ /* Call trace function. */
+ if ((*trace) ((_Unwind_Context *) &saved_vrs, trace_argument)
+ != _URC_NO_REASON)
+ {
+ code = _URC_FAILURE;
+ break;
+ }
+
+ /* Call the pr to decide what to do. */
+ code = ((personality_routine) UCB_PR_ADDR (ucbp))
+ (_US_VIRTUAL_UNWIND_FRAME | _US_FORCE_UNWIND,
+ ucbp, (void *) &saved_vrs);
+ }
+ while (code != _URC_END_OF_STACK
+ && code != _URC_FAILURE);
+
+ finish:
+ restore_non_core_regs (&saved_vrs);
+ return code;
+}
+
+
/* Common implementation for ARM ABI defined personality routines.
ID is the index of the personality routine, other arguments are as defined
by __aeabi_unwind_cpp_pr{0,1,2}. */
@@ -1014,3 +1074,19 @@
{
abort ();
}
+
+#ifdef __FreeBSD__
+/* FreeBSD expects these to be functions */
+_Unwind_Ptr
+_Unwind_GetIP (struct _Unwind_Context *context)
+{
+ return _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1;
+}
+
+_Unwind_Ptr
+_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
+{
+ *ip_before_insn = 0;
+ return _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1;
+}
+#endif
Modified: trunk/contrib/gcc/config/arm/unwind-arm.h
===================================================================
--- trunk/contrib/gcc4/config/arm/unwind-arm.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/arm/unwind-arm.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -87,7 +87,7 @@
struct _Unwind_Control_Block
{
- char exception_class[8];
+ unsigned exception_class __attribute__((__mode__(__DI__)));
void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
/* Unwinder cache, private fields for the unwinder's use */
struct
@@ -186,7 +186,7 @@
/* Support functions for the PR. */
#define _Unwind_Exception _Unwind_Control_Block
- typedef char _Unwind_Exception_Class[8];
+ typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
_Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
@@ -205,6 +205,13 @@
_Unwind_Control_Block *, struct _Unwind_Context *, void *);
_Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
_Unwind_Stop_Fn, void *);
+ /* @@@ Use unwind data to perform a stack backtrace. The trace callback
+ is called for every stack frame in the call chain, but no cleanup
+ actions are performed. */
+ typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (_Unwind_Context *, void *);
+ _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn,
+ void*);
+
_Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
void _Unwind_Complete(_Unwind_Control_Block *ucbp);
void _Unwind_DeleteException (_Unwind_Exception *);
@@ -225,7 +232,7 @@
if (!tmp)
return 0;
-#if defined(linux) || defined(__NetBSD__)
+#if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__)
/* Pc-relative indirect. */
tmp += ptr;
tmp = *(_Unwind_Word *) tmp;
@@ -246,6 +253,7 @@
return val;
}
+#ifndef __FreeBSD__
/* Return the address of the instruction, not the actual IP value. */
#define _Unwind_GetIP(context) \
(_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
@@ -252,6 +260,10 @@
#define _Unwind_GetIPInfo(context, ip_before_insn) \
(*ip_before_insn = 0, _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
+#else
+ _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
+ _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
+#endif
static inline void
_Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
Modified: trunk/contrib/gcc/config/darwin.c
===================================================================
--- trunk/contrib/gcc4/config/darwin.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/darwin.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1517,6 +1517,7 @@
DEBUG_LINE_SECTION,
DEBUG_LOC_SECTION,
DEBUG_PUBNAMES_SECTION,
+ DEBUG_PUBTYPES_SECTION,
DEBUG_STR_SECTION,
DEBUG_RANGES_SECTION
};
Modified: trunk/contrib/gcc/config/darwin.h
===================================================================
--- trunk/contrib/gcc4/config/darwin.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/darwin.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -401,6 +401,7 @@
#define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug"
#define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug"
#define DEBUG_PUBNAMES_SECTION "__DWARF,__debug_pubnames,regular,debug"
+#define DEBUG_PUBTYPES_SECTION "__DWARF,__debug_pubtypes,regular,debug"
#define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug"
#define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug"
@@ -467,6 +468,10 @@
with names, so it's safe to make the class data not comdat. */
#define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_false
+/* For efficiency, on Darwin the RTTI information that is always
+ emitted in the standard C++ library should not be COMDAT. */
+#define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_false
+
/* We make exception information linkonce. */
#undef TARGET_USES_WEAK_UNWIND_INFO
#define TARGET_USES_WEAK_UNWIND_INFO 1
@@ -868,7 +873,9 @@
#define DARWIN_REGISTER_TARGET_PRAGMAS() \
do { \
- c_register_pragma (0, "mark", darwin_pragma_ignore); \
+ /* APPLE LOCAL begin pragma mark 5614511 */ \
+ /* Removed mark. */ \
+ /* APPLE LOCAL end pragma mark 5614511 */ \
c_register_pragma (0, "options", darwin_pragma_options); \
c_register_pragma (0, "segment", darwin_pragma_ignore); \
c_register_pragma (0, "unused", darwin_pragma_unused); \
Modified: trunk/contrib/gcc/config/freebsd.h
===================================================================
--- trunk/contrib/gcc4/config/freebsd.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/freebsd.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -26,7 +26,7 @@
Further work by David O'Brien <obrien at FreeBSD.org> and
Loren J. Rittle <ljrittle at acm.org>. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/config/freebsd.h 229715 2012-01-06 18:37:49Z andreast $ */
/* In case we need to know. */
#define USING_CONFIG_FREEBSD 1
@@ -63,6 +63,7 @@
/* All FreeBSD Architectures support the ELF object file format. */
#undef OBJECT_FORMAT_ELF
#define OBJECT_FORMAT_ELF 1
+#undef TARGET_ELF
#define TARGET_ELF 1
/* Don't assume anything about the header files. */
Added: trunk/contrib/gcc/config/i386/ammintrin.h
===================================================================
--- trunk/contrib/gcc/config/i386/ammintrin.h (rev 0)
+++ trunk/contrib/gcc/config/i386/ammintrin.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -0,0 +1,73 @@
+/* Copyright (C) 2007 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. */
+
+/* As a special exception, if you include this header file into source
+ files compiled by GCC, this header file does not by itself cause
+ the resulting executable to be covered by the GNU General Public
+ License. This exception does not however invalidate any other
+ reasons why the executable file might be covered by the GNU General
+ Public License. */
+
+/* Implemented from the specification included in the AMD Programmers
+ Manual Update, version 2.x */
+
+#ifndef _AMMINTRIN_H_INCLUDED
+#define _AMMINTRIN_H_INCLUDED
+
+#ifndef __SSE4A__
+# error "SSE4A instruction set not enabled"
+#else
+
+/* We need definitions from the SSE3, SSE2 and SSE header files*/
+#include <pmmintrin.h>
+
+static __inline void __attribute__((__always_inline__))
+_mm_stream_sd (double * __P, __m128d __Y)
+{
+ __builtin_ia32_movntsd (__P, (__v2df) __Y);
+}
+
+static __inline void __attribute__((__always_inline__))
+_mm_stream_ss (float * __P, __m128 __Y)
+{
+ __builtin_ia32_movntss (__P, (__v4sf) __Y);
+}
+
+static __inline __m128i __attribute__((__always_inline__))
+_mm_extract_si64 (__m128i __X, __m128i __Y)
+{
+ return (__m128i) __builtin_ia32_extrq ((__v2di) __X, (__v16qi) __Y);
+}
+
+#define _mm_extracti_si64(X, I, L) \
+((__m128i) __builtin_ia32_extrqi ((__v2di)(X), I, L))
+
+static __inline __m128i __attribute__((__always_inline__))
+_mm_insert_si64 (__m128i __X,__m128i __Y)
+{
+ return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
+}
+
+#define _mm_inserti_si64(X, Y, I, L) \
+((__m128i) __builtin_ia32_insertqi ((__v2di)(X), (__v2di)(Y), I, L))
+
+
+#endif /* __SSE4A__ */
+
+#endif /* _AMMINTRIN_H_INCLUDED */
Property changes on: trunk/contrib/gcc/config/i386/ammintrin.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/contrib/gcc/config/i386/athlon.md
===================================================================
--- trunk/contrib/gcc4/config/i386/athlon.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/athlon.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -29,6 +29,8 @@
(const_string "vector")]
(const_string "direct")))
+(define_attr "amdfam10_decode" "direct,vector,double"
+ (const_string "direct"))
;;
;; decode0 decode1 decode2
;; \ | /
@@ -131,7 +133,7 @@
;; Jump instructions are executed in the branch unit completely transparent to us
(define_insn_reservation "athlon_branch" 0
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "ibr"))
"athlon-direct,athlon-ieu")
(define_insn_reservation "athlon_call" 0
@@ -138,11 +140,15 @@
(and (eq_attr "cpu" "athlon,k8,generic64")
(eq_attr "type" "call,callv"))
"athlon-vector,athlon-ieu")
+(define_insn_reservation "athlon_call_amdfam10" 0
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "call,callv"))
+ "athlon-double,athlon-ieu")
;; Latency of push operation is 3 cycles, but ESP value is available
;; earlier
(define_insn_reservation "athlon_push" 2
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "push"))
"athlon-direct,athlon-agu,athlon-store")
(define_insn_reservation "athlon_pop" 4
@@ -153,12 +159,16 @@
(and (eq_attr "cpu" "k8,generic64")
(eq_attr "type" "pop"))
"athlon-double,(athlon-ieu+athlon-load)")
+(define_insn_reservation "athlon_pop_amdfam10" 3
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "pop"))
+ "athlon-direct,(athlon-ieu+athlon-load)")
(define_insn_reservation "athlon_leave" 3
(and (eq_attr "cpu" "athlon")
(eq_attr "type" "leave"))
"athlon-vector,(athlon-ieu+athlon-load)")
(define_insn_reservation "athlon_leave_k8" 3
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(eq_attr "type" "leave"))
"athlon-double,(athlon-ieu+athlon-load)")
@@ -167,6 +177,11 @@
(and (eq_attr "cpu" "athlon,k8,generic64")
(eq_attr "type" "lea"))
"athlon-direct,athlon-agu,nothing")
+;; Lea executes in AGU unit with 1 cycle latency on AMDFAM10
+(define_insn_reservation "athlon_lea_amdfam10" 1
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "lea"))
+ "athlon-direct,athlon-agu,nothing")
;; Mul executes in special multiplier unit attached to IEU0
(define_insn_reservation "athlon_imul" 5
@@ -176,16 +191,22 @@
"athlon-vector,athlon-ieu0,athlon-mult,nothing,nothing,athlon-ieu0")
;; ??? Widening multiply is vector or double.
(define_insn_reservation "athlon_imul_k8_DI" 4
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "imul")
(and (eq_attr "mode" "DI")
(eq_attr "memory" "none,unknown"))))
"athlon-direct0,athlon-ieu0,athlon-mult,nothing,athlon-ieu0")
(define_insn_reservation "athlon_imul_k8" 3
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "imul")
(eq_attr "memory" "none,unknown")))
"athlon-direct0,athlon-ieu0,athlon-mult,athlon-ieu0")
+(define_insn_reservation "athlon_imul_amdfam10_HI" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "imul")
+ (and (eq_attr "mode" "HI")
+ (eq_attr "memory" "none,unknown"))))
+ "athlon-vector,athlon-ieu0,athlon-mult,nothing,athlon-ieu0")
(define_insn_reservation "athlon_imul_mem" 8
(and (eq_attr "cpu" "athlon")
(and (eq_attr "type" "imul")
@@ -192,13 +213,13 @@
(eq_attr "memory" "load,both")))
"athlon-vector,athlon-load,athlon-ieu,athlon-mult,nothing,nothing,athlon-ieu")
(define_insn_reservation "athlon_imul_mem_k8_DI" 7
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "imul")
(and (eq_attr "mode" "DI")
(eq_attr "memory" "load,both"))))
"athlon-vector,athlon-load,athlon-ieu,athlon-mult,nothing,athlon-ieu")
(define_insn_reservation "athlon_imul_mem_k8" 6
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "imul")
(eq_attr "memory" "load,both")))
"athlon-vector,athlon-load,athlon-ieu,athlon-mult,athlon-ieu")
@@ -209,21 +230,23 @@
;; other instructions.
;; ??? Experiments show that the idiv can overlap with roughly 6 cycles
;; of the other code
+;; Using the same heuristics for amdfam10 as K8 with idiv
(define_insn_reservation "athlon_idiv" 6
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "idiv")
(eq_attr "memory" "none,unknown")))
"athlon-vector,(athlon-ieu0*6+(athlon-fpsched,athlon-fvector))")
(define_insn_reservation "athlon_idiv_mem" 9
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "idiv")
(eq_attr "memory" "load,both")))
"athlon-vector,((athlon-load,athlon-ieu0*6)+(athlon-fpsched,athlon-fvector))")
;; The parallelism of string instructions is not documented. Model it same way
;; as idiv to create smaller automata. This probably does not matter much.
+;; Using the same heuristics for amdfam10 as K8 with idiv
(define_insn_reservation "athlon_str" 6
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "str")
(eq_attr "memory" "load,both,store")))
"athlon-vector,athlon-load,athlon-ieu0*6")
@@ -234,6 +257,12 @@
(and (eq_attr "unit" "integer,unknown")
(eq_attr "memory" "none,unknown"))))
"athlon-direct,athlon-ieu")
+(define_insn_reservation "athlon_idirect_amdfam10" 1
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "direct")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "none,unknown"))))
+ "athlon-direct,athlon-ieu")
(define_insn_reservation "athlon_ivector" 2
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "athlon_decode" "vector")
@@ -240,11 +269,19 @@
(and (eq_attr "unit" "integer,unknown")
(eq_attr "memory" "none,unknown"))))
"athlon-vector,athlon-ieu,athlon-ieu")
+(define_insn_reservation "athlon_ivector_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "none,unknown"))))
+ "athlon-vector,athlon-ieu,athlon-ieu")
+
(define_insn_reservation "athlon_idirect_loadmov" 3
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "imov")
(eq_attr "memory" "load")))
"athlon-direct,athlon-load")
+
(define_insn_reservation "athlon_idirect_load" 4
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "athlon_decode" "direct")
@@ -251,6 +288,12 @@
(and (eq_attr "unit" "integer,unknown")
(eq_attr "memory" "load"))))
"athlon-direct,athlon-load,athlon-ieu")
+(define_insn_reservation "athlon_idirect_load_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "direct")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "load"))))
+ "athlon-direct,athlon-load,athlon-ieu")
(define_insn_reservation "athlon_ivector_load" 6
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "athlon_decode" "vector")
@@ -257,11 +300,19 @@
(and (eq_attr "unit" "integer,unknown")
(eq_attr "memory" "load"))))
"athlon-vector,athlon-load,athlon-ieu,athlon-ieu")
+(define_insn_reservation "athlon_ivector_load_amdfam10" 6
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "load"))))
+ "athlon-vector,athlon-load,athlon-ieu,athlon-ieu")
+
(define_insn_reservation "athlon_idirect_movstore" 1
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "imov")
(eq_attr "memory" "store")))
"athlon-direct,athlon-agu,athlon-store")
+
(define_insn_reservation "athlon_idirect_both" 4
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "athlon_decode" "direct")
@@ -270,6 +321,15 @@
"athlon-direct,athlon-load,
athlon-ieu,athlon-store,
athlon-store")
+(define_insn_reservation "athlon_idirect_both_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "direct")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "both"))))
+ "athlon-direct,athlon-load,
+ athlon-ieu,athlon-store,
+ athlon-store")
+
(define_insn_reservation "athlon_ivector_both" 6
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "athlon_decode" "vector")
@@ -279,6 +339,16 @@
athlon-ieu,
athlon-ieu,
athlon-store")
+(define_insn_reservation "athlon_ivector_both_amdfam10" 6
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "both"))))
+ "athlon-vector,athlon-load,
+ athlon-ieu,
+ athlon-ieu,
+ athlon-store")
+
(define_insn_reservation "athlon_idirect_store" 1
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "athlon_decode" "direct")
@@ -286,6 +356,14 @@
(eq_attr "memory" "store"))))
"athlon-direct,(athlon-ieu+athlon-agu),
athlon-store")
+(define_insn_reservation "athlon_idirect_store_amdfam10" 1
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "direct")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "store"))))
+ "athlon-direct,(athlon-ieu+athlon-agu),
+ athlon-store")
+
(define_insn_reservation "athlon_ivector_store" 2
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "athlon_decode" "vector")
@@ -293,6 +371,13 @@
(eq_attr "memory" "store"))))
"athlon-vector,(athlon-ieu+athlon-agu),athlon-ieu,
athlon-store")
+(define_insn_reservation "athlon_ivector_store_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (and (eq_attr "unit" "integer,unknown")
+ (eq_attr "memory" "store"))))
+ "athlon-vector,(athlon-ieu+athlon-agu),athlon-ieu,
+ athlon-store")
;; Athlon floatin point unit
(define_insn_reservation "athlon_fldxf" 12
@@ -302,7 +387,7 @@
(eq_attr "mode" "XF"))))
"athlon-vector,athlon-fpload2,athlon-fvector*9")
(define_insn_reservation "athlon_fldxf_k8" 13
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fmov")
(and (eq_attr "memory" "load")
(eq_attr "mode" "XF"))))
@@ -314,7 +399,7 @@
(eq_attr "memory" "load")))
"athlon-direct,athlon-fpload,athlon-fany")
(define_insn_reservation "athlon_fld_k8" 2
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fmov")
(eq_attr "memory" "load")))
"athlon-direct,athlon-fploadk8,athlon-fstore")
@@ -326,7 +411,7 @@
(eq_attr "mode" "XF"))))
"athlon-vector,(athlon-fpsched+athlon-agu),(athlon-store2+(athlon-fvector*7))")
(define_insn_reservation "athlon_fstxf_k8" 8
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fmov")
(and (eq_attr "memory" "store,both")
(eq_attr "mode" "XF"))))
@@ -337,16 +422,16 @@
(eq_attr "memory" "store,both")))
"athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
(define_insn_reservation "athlon_fst_k8" 2
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fmov")
(eq_attr "memory" "store,both")))
"athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
(define_insn_reservation "athlon_fist" 4
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "fistp,fisttp"))
"athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
(define_insn_reservation "athlon_fmov" 2
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "fmov"))
"athlon-direct,athlon-fpsched,athlon-faddmul")
(define_insn_reservation "athlon_fadd_load" 4
@@ -355,12 +440,12 @@
(eq_attr "memory" "load")))
"athlon-direct,athlon-fpload,athlon-fadd")
(define_insn_reservation "athlon_fadd_load_k8" 6
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fop")
(eq_attr "memory" "load")))
"athlon-direct,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_fadd" 4
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "fop"))
"athlon-direct,athlon-fpsched,athlon-fadd")
(define_insn_reservation "athlon_fmul_load" 4
@@ -369,16 +454,16 @@
(eq_attr "memory" "load")))
"athlon-direct,athlon-fpload,athlon-fmul")
(define_insn_reservation "athlon_fmul_load_k8" 6
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fmul")
(eq_attr "memory" "load")))
"athlon-direct,athlon-fploadk8,athlon-fmul")
(define_insn_reservation "athlon_fmul" 4
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "fmul"))
"athlon-direct,athlon-fpsched,athlon-fmul")
(define_insn_reservation "athlon_fsgn" 2
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "fsgn"))
"athlon-direct,athlon-fpsched,athlon-fmul")
(define_insn_reservation "athlon_fdiv_load" 24
@@ -387,7 +472,7 @@
(eq_attr "memory" "load")))
"athlon-direct,athlon-fpload,athlon-fmul")
(define_insn_reservation "athlon_fdiv_load_k8" 13
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fdiv")
(eq_attr "memory" "load")))
"athlon-direct,athlon-fploadk8,athlon-fmul")
@@ -396,16 +481,16 @@
(eq_attr "type" "fdiv"))
"athlon-direct,athlon-fpsched,athlon-fmul")
(define_insn_reservation "athlon_fdiv_k8" 11
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(eq_attr "type" "fdiv"))
"athlon-direct,athlon-fpsched,athlon-fmul")
(define_insn_reservation "athlon_fpspc_load" 103
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "fpspc")
(eq_attr "memory" "load")))
"athlon-vector,athlon-fpload,athlon-fvector")
(define_insn_reservation "athlon_fpspc" 100
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "fpspc"))
"athlon-vector,athlon-fpsched,athlon-fvector")
(define_insn_reservation "athlon_fcmov_load" 7
@@ -418,12 +503,12 @@
(eq_attr "type" "fcmov"))
"athlon-vector,athlon-fpsched,athlon-fvector")
(define_insn_reservation "athlon_fcmov_load_k8" 17
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fcmov")
(eq_attr "memory" "load")))
"athlon-vector,athlon-fploadk8,athlon-fvector")
(define_insn_reservation "athlon_fcmov_k8" 15
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(eq_attr "type" "fcmov"))
"athlon-vector,athlon-fpsched,athlon-fvector")
;; fcomi is vector decoded by uses only one pipe.
@@ -434,13 +519,13 @@
(eq_attr "memory" "load"))))
"athlon-vector,athlon-fpload,athlon-fadd")
(define_insn_reservation "athlon_fcomi_load_k8" 5
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fcmp")
(and (eq_attr "athlon_decode" "vector")
(eq_attr "memory" "load"))))
"athlon-vector,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_fcomi" 3
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "athlon_decode" "vector")
(eq_attr "type" "fcmp")))
"athlon-vector,athlon-fpsched,athlon-fadd")
@@ -450,18 +535,18 @@
(eq_attr "memory" "load")))
"athlon-direct,athlon-fpload,athlon-fadd")
(define_insn_reservation "athlon_fcom_load_k8" 4
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "fcmp")
(eq_attr "memory" "load")))
"athlon-direct,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_fcom" 2
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(eq_attr "type" "fcmp"))
"athlon-direct,athlon-fpsched,athlon-fadd")
;; Never seen by the scheduler because we still don't do post reg-stack
;; scheduling.
;(define_insn_reservation "athlon_fxch" 2
-; (and (eq_attr "cpu" "athlon,k8,generic64")
+; (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
; (eq_attr "type" "fxch"))
; "athlon-direct,athlon-fpsched,athlon-fany")
@@ -516,6 +601,23 @@
(and (eq_attr "type" "mmxmov,ssemov")
(eq_attr "memory" "load")))
"athlon-direct,athlon-fploadk8,athlon-fstore")
+;; On AMDFAM10 all double, single and integer packed and scalar SSEx data
+;; loads generated are direct path, latency of 2 and do not use any FP
+;; executions units. No seperate entries for movlpx/movhpx loads, which
+;; are direct path, latency of 4 and use the FADD/FMUL FP execution units,
+;; as they will not be generated.
+(define_insn_reservation "athlon_sseld_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssemov")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8")
+;; On AMDFAM10 MMX data loads generated are direct path, latency of 4
+;; and can use any FP executions units
+(define_insn_reservation "athlon_mmxld_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "mmxmov")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8, athlon-fany")
(define_insn_reservation "athlon_mmxssest" 3
(and (eq_attr "cpu" "k8,generic64")
(and (eq_attr "type" "mmxmov,ssemov")
@@ -533,6 +635,25 @@
(and (eq_attr "type" "mmxmov,ssemov")
(eq_attr "memory" "store,both")))
"athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
+;; On AMDFAM10 all double, single and integer packed SSEx data stores
+;; generated are all double path, latency of 2 and use the FSTORE FP
+;; execution unit. No entries seperate for movupx/movdqu, which are
+;; vector path, latency of 3 and use the FSTORE*2 FP execution unit,
+;; as they will not be generated.
+(define_insn_reservation "athlon_ssest_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssemov")
+ (and (eq_attr "mode" "V4SF,V2DF,TI")
+ (eq_attr "memory" "store,both"))))
+ "athlon-double,(athlon-fpsched+athlon-agu),((athlon-fstore+athlon-store)*2)")
+;; On AMDFAM10 all double, single and integer scalar SSEx and MMX
+;; data stores generated are all direct path, latency of 2 and use
+;; the FSTORE FP execution unit
+(define_insn_reservation "athlon_mmxssest_short_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "mmxmov,ssemov")
+ (eq_attr "memory" "store,both")))
+ "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
(define_insn_reservation "athlon_movaps_k8" 2
(and (eq_attr "cpu" "k8,generic64")
(and (eq_attr "type" "ssemov")
@@ -578,6 +699,11 @@
(and (eq_attr "type" "sselog,sselog1")
(eq_attr "memory" "load")))
"athlon-double,athlon-fpload2k8,(athlon-fmul*2)")
+(define_insn_reservation "athlon_sselog_load_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sselog,sselog1")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8,(athlon-fadd|athlon-fmul)")
(define_insn_reservation "athlon_sselog" 3
(and (eq_attr "cpu" "athlon")
(eq_attr "type" "sselog,sselog1"))
@@ -586,6 +712,11 @@
(and (eq_attr "cpu" "k8,generic64")
(eq_attr "type" "sselog,sselog1"))
"athlon-double,athlon-fpsched,athlon-fmul")
+(define_insn_reservation "athlon_sselog_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "sselog,sselog1"))
+ "athlon-direct,athlon-fpsched,(athlon-fadd|athlon-fmul)")
+
;; ??? pcmp executes in addmul, probably not worthwhile to bother about that.
(define_insn_reservation "athlon_ssecmp_load" 2
(and (eq_attr "cpu" "athlon")
@@ -594,13 +725,13 @@
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fpload,athlon-fadd")
(define_insn_reservation "athlon_ssecmp_load_k8" 4
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "ssecmp")
(and (eq_attr "mode" "SF,DF,DI,TI")
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_ssecmp" 2
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "ssecmp")
(eq_attr "mode" "SF,DF,DI,TI")))
"athlon-direct,athlon-fpsched,athlon-fadd")
@@ -614,6 +745,11 @@
(and (eq_attr "type" "ssecmp")
(eq_attr "memory" "load")))
"athlon-double,athlon-fpload2k8,(athlon-fadd*2)")
+(define_insn_reservation "athlon_ssecmpvector_load_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecmp")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_ssecmpvector" 3
(and (eq_attr "cpu" "athlon")
(eq_attr "type" "ssecmp"))
@@ -622,6 +758,10 @@
(and (eq_attr "cpu" "k8,generic64")
(eq_attr "type" "ssecmp"))
"athlon-double,athlon-fpsched,(athlon-fadd*2)")
+(define_insn_reservation "athlon_ssecmpvector_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "ssecmp"))
+ "athlon-direct,athlon-fpsched,athlon-fadd")
(define_insn_reservation "athlon_ssecomi_load" 4
(and (eq_attr "cpu" "athlon")
(and (eq_attr "type" "ssecomi")
@@ -632,10 +772,20 @@
(and (eq_attr "type" "ssecomi")
(eq_attr "memory" "load")))
"athlon-vector,athlon-fploadk8,athlon-fadd")
+(define_insn_reservation "athlon_ssecomi_load_amdfam10" 5
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecomi")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_ssecomi" 4
(and (eq_attr "cpu" "athlon,k8,generic64")
(eq_attr "type" "ssecmp"))
"athlon-vector,athlon-fpsched,athlon-fadd")
+(define_insn_reservation "athlon_ssecomi_amdfam10" 3
+ (and (eq_attr "cpu" "amdfam10")
+;; It seems athlon_ssecomi has a bug in the attr_type, fixed for amdfam10
+ (eq_attr "type" "ssecomi"))
+ "athlon-direct,athlon-fpsched,athlon-fadd")
(define_insn_reservation "athlon_sseadd_load" 4
(and (eq_attr "cpu" "athlon")
(and (eq_attr "type" "sseadd")
@@ -643,13 +793,13 @@
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fpload,athlon-fadd")
(define_insn_reservation "athlon_sseadd_load_k8" 6
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "sseadd")
(and (eq_attr "mode" "SF,DF,DI")
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_sseadd" 4
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "sseadd")
(eq_attr "mode" "SF,DF,DI")))
"athlon-direct,athlon-fpsched,athlon-fadd")
@@ -663,6 +813,11 @@
(and (eq_attr "type" "sseadd")
(eq_attr "memory" "load")))
"athlon-double,athlon-fpload2k8,(athlon-fadd*2)")
+(define_insn_reservation "athlon_sseaddvector_load_amdfam10" 6
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseadd")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8,athlon-fadd")
(define_insn_reservation "athlon_sseaddvector" 5
(and (eq_attr "cpu" "athlon")
(eq_attr "type" "sseadd"))
@@ -671,6 +826,10 @@
(and (eq_attr "cpu" "k8,generic64")
(eq_attr "type" "sseadd"))
"athlon-double,athlon-fpsched,(athlon-fadd*2)")
+(define_insn_reservation "athlon_sseaddvector_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "sseadd"))
+ "athlon-direct,athlon-fpsched,athlon-fadd")
;; Conversions behaves very irregularly and the scheduling is critical here.
;; Take each instruction separately. Assume that the mode is always set to the
@@ -684,6 +843,13 @@
(and (eq_attr "mode" "DF")
(eq_attr "memory" "load")))))
"athlon-direct,athlon-fploadk8,athlon-fstore")
+(define_insn_reservation "athlon_ssecvt_cvtss2sd_load_amdfam10" 7
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "DF")
+ (eq_attr "memory" "load")))))
+ "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
(define_insn_reservation "athlon_ssecvt_cvtss2sd" 2
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "type" "ssecvt")
@@ -690,6 +856,12 @@
(and (eq_attr "athlon_decode" "direct")
(eq_attr "mode" "DF"))))
"athlon-direct,athlon-fpsched,athlon-fstore")
+(define_insn_reservation "athlon_ssecvt_cvtss2sd_amdfam10" 7
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (eq_attr "mode" "DF"))))
+ "athlon-vector,athlon-fpsched,athlon-faddmul,(athlon-fstore*2)")
;; cvtps2pd. Model same way the other double decoded FP conversions.
(define_insn_reservation "athlon_ssecvt_cvtps2pd_load_k8" 5
(and (eq_attr "cpu" "k8,athlon,generic64")
@@ -698,6 +870,13 @@
(and (eq_attr "mode" "V2DF,V4SF,TI")
(eq_attr "memory" "load")))))
"athlon-double,athlon-fpload2k8,(athlon-fstore*2)")
+(define_insn_reservation "athlon_ssecvt_cvtps2pd_load_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "direct")
+ (and (eq_attr "mode" "V2DF,V4SF,TI")
+ (eq_attr "memory" "load")))))
+ "athlon-direct,athlon-fploadk8,athlon-fstore")
(define_insn_reservation "athlon_ssecvt_cvtps2pd_k8" 3
(and (eq_attr "cpu" "k8,athlon,generic64")
(and (eq_attr "type" "ssecvt")
@@ -704,6 +883,12 @@
(and (eq_attr "athlon_decode" "double")
(eq_attr "mode" "V2DF,V4SF,TI"))))
"athlon-double,athlon-fpsched,athlon-fstore,athlon-fstore")
+(define_insn_reservation "athlon_ssecvt_cvtps2pd_amdfam10" 2
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "direct")
+ (eq_attr "mode" "V2DF,V4SF,TI"))))
+ "athlon-direct,athlon-fpsched,athlon-fstore")
;; cvtsi2sd mem,reg is directpath path (cvtsi2sd reg,reg is doublepath)
;; cvtsi2sd has troughput 1 and is executed in store unit with latency of 6
(define_insn_reservation "athlon_sseicvt_cvtsi2sd_load" 6
@@ -713,6 +898,13 @@
(and (eq_attr "mode" "SF,DF")
(eq_attr "memory" "load")))))
"athlon-direct,athlon-fploadk8,athlon-fstore")
+(define_insn_reservation "athlon_sseicvt_cvtsi2sd_load_amdfam10" 9
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "SF,DF")
+ (eq_attr "memory" "load")))))
+ "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
;; cvtsi2ss mem, reg is doublepath
(define_insn_reservation "athlon_sseicvt_cvtsi2ss_load" 9
(and (eq_attr "cpu" "athlon")
@@ -728,6 +920,13 @@
(and (eq_attr "mode" "SF,DF")
(eq_attr "memory" "load")))))
"athlon-double,athlon-fploadk8,(athlon-fstore*2)")
+(define_insn_reservation "athlon_sseicvt_cvtsi2ss_load_amdfam10" 9
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "SF,DF")
+ (eq_attr "memory" "load")))))
+ "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
;; cvtsi2sd reg,reg is double decoded (vector on Athlon)
(define_insn_reservation "athlon_sseicvt_cvtsi2sd_k8" 11
(and (eq_attr "cpu" "k8,athlon,generic64")
@@ -736,6 +935,13 @@
(and (eq_attr "mode" "SF,DF")
(eq_attr "memory" "none")))))
"athlon-double,athlon-fploadk8,athlon-fstore")
+(define_insn_reservation "athlon_sseicvt_cvtsi2sd_amdfam10" 14
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (and (eq_attr "mode" "SF,DF")
+ (eq_attr "memory" "none")))))
+ "athlon-vector,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
;; cvtsi2ss reg, reg is doublepath
(define_insn_reservation "athlon_sseicvt_cvtsi2ss" 14
(and (eq_attr "cpu" "athlon,k8,generic64")
@@ -744,6 +950,13 @@
(and (eq_attr "mode" "SF,DF")
(eq_attr "memory" "none")))))
"athlon-vector,athlon-fploadk8,(athlon-fvector*2)")
+(define_insn_reservation "athlon_sseicvt_cvtsi2ss_amdfam10" 14
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (and (eq_attr "mode" "SF,DF")
+ (eq_attr "memory" "none")))))
+ "athlon-vector,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
;; cvtsd2ss mem,reg is doublepath, troughput unknown, latency 9
(define_insn_reservation "athlon_ssecvt_cvtsd2ss_load_k8" 9
(and (eq_attr "cpu" "k8,athlon,generic64")
@@ -752,6 +965,13 @@
(and (eq_attr "mode" "SF")
(eq_attr "memory" "load")))))
"athlon-double,athlon-fploadk8,(athlon-fstore*3)")
+(define_insn_reservation "athlon_ssecvt_cvtsd2ss_load_amdfam10" 9
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "SF")
+ (eq_attr "memory" "load")))))
+ "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
;; cvtsd2ss reg,reg is vectorpath, troughput unknown, latency 12
(define_insn_reservation "athlon_ssecvt_cvtsd2ss" 12
(and (eq_attr "cpu" "athlon,k8,generic64")
@@ -760,6 +980,13 @@
(and (eq_attr "mode" "SF")
(eq_attr "memory" "none")))))
"athlon-vector,athlon-fpsched,(athlon-fvector*3)")
+(define_insn_reservation "athlon_ssecvt_cvtsd2ss_amdfam10" 8
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "vector")
+ (and (eq_attr "mode" "SF")
+ (eq_attr "memory" "none")))))
+ "athlon-vector,athlon-fpsched,athlon-faddmul,(athlon-fstore*2)")
(define_insn_reservation "athlon_ssecvt_cvtpd2ps_load_k8" 8
(and (eq_attr "cpu" "athlon,k8,generic64")
(and (eq_attr "type" "ssecvt")
@@ -767,6 +994,13 @@
(and (eq_attr "mode" "V4SF,V2DF,TI")
(eq_attr "memory" "load")))))
"athlon-double,athlon-fpload2k8,(athlon-fstore*3)")
+(define_insn_reservation "athlon_ssecvt_cvtpd2ps_load_amdfam10" 9
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "V4SF,V2DF,TI")
+ (eq_attr "memory" "load")))))
+ "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
;; cvtpd2ps mem,reg is vectorpath, troughput unknown, latency 10
;; ??? Why it is fater than cvtsd2ss?
(define_insn_reservation "athlon_ssecvt_cvtpd2ps" 8
@@ -776,6 +1010,13 @@
(and (eq_attr "mode" "V4SF,V2DF,TI")
(eq_attr "memory" "none")))))
"athlon-vector,athlon-fpsched,athlon-fvector*2")
+(define_insn_reservation "athlon_ssecvt_cvtpd2ps_amdfam10" 7
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "V4SF,V2DF,TI")
+ (eq_attr "memory" "none")))))
+ "athlon-double,athlon-fpsched,(athlon-faddmul+athlon-fstore)")
;; cvtsd2si mem,reg is doublepath, troughput 1, latency 9
(define_insn_reservation "athlon_secvt_cvtsX2si_load" 9
(and (eq_attr "cpu" "athlon,k8,generic64")
@@ -784,6 +1025,13 @@
(and (eq_attr "mode" "SI,DI")
(eq_attr "memory" "load")))))
"athlon-vector,athlon-fploadk8,athlon-fvector")
+(define_insn_reservation "athlon_secvt_cvtsX2si_load_amdfam10" 10
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "SI,DI")
+ (eq_attr "memory" "load")))))
+ "athlon-double,athlon-fploadk8,(athlon-fadd+athlon-fstore)")
;; cvtsd2si reg,reg is doublepath, troughput 1, latency 9
(define_insn_reservation "athlon_ssecvt_cvtsX2si" 9
(and (eq_attr "cpu" "athlon")
@@ -799,6 +1047,29 @@
(and (eq_attr "mode" "SI,DI")
(eq_attr "memory" "none")))))
"athlon-double,athlon-fpsched,athlon-fstore")
+(define_insn_reservation "athlon_ssecvt_cvtsX2si_amdfam10" 8
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "SI,DI")
+ (eq_attr "memory" "none")))))
+ "athlon-double,athlon-fpsched,(athlon-fadd+athlon-fstore)")
+;; cvtpd2dq reg,mem is doublepath, troughput 1, latency 9 on amdfam10
+(define_insn_reservation "athlon_sseicvt_cvtpd2dq_load_amdfam10" 9
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "TI")
+ (eq_attr "memory" "load")))))
+ "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
+;; cvtpd2dq reg,mem is doublepath, troughput 1, latency 7 on amdfam10
+(define_insn_reservation "athlon_sseicvt_cvtpd2dq_amdfam10" 7
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseicvt")
+ (and (eq_attr "amdfam10_decode" "double")
+ (and (eq_attr "mode" "TI")
+ (eq_attr "memory" "none")))))
+ "athlon-double,athlon-fpsched,(athlon-faddmul+athlon-fstore)")
(define_insn_reservation "athlon_ssemul_load" 4
@@ -808,13 +1079,13 @@
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fpload,athlon-fmul")
(define_insn_reservation "athlon_ssemul_load_k8" 6
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "ssemul")
(and (eq_attr "mode" "SF,DF")
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fploadk8,athlon-fmul")
(define_insn_reservation "athlon_ssemul" 4
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "ssemul")
(eq_attr "mode" "SF,DF")))
"athlon-direct,athlon-fpsched,athlon-fmul")
@@ -828,6 +1099,11 @@
(and (eq_attr "type" "ssemul")
(eq_attr "memory" "load")))
"athlon-double,athlon-fpload2k8,(athlon-fmul*2)")
+(define_insn_reservation "athlon_ssemulvector_load_amdfam10" 6
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssemul")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8,athlon-fmul")
(define_insn_reservation "athlon_ssemulvector" 5
(and (eq_attr "cpu" "athlon")
(eq_attr "type" "ssemul"))
@@ -836,6 +1112,10 @@
(and (eq_attr "cpu" "k8,generic64")
(eq_attr "type" "ssemul"))
"athlon-double,athlon-fpsched,(athlon-fmul*2)")
+(define_insn_reservation "athlon_ssemulvector_amdfam10" 4
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "ssemul"))
+ "athlon-direct,athlon-fpsched,athlon-fmul")
;; divsd timings. divss is faster
(define_insn_reservation "athlon_ssediv_load" 20
(and (eq_attr "cpu" "athlon")
@@ -844,13 +1124,13 @@
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fpload,athlon-fmul*17")
(define_insn_reservation "athlon_ssediv_load_k8" 22
- (and (eq_attr "cpu" "k8,generic64")
+ (and (eq_attr "cpu" "k8,generic64,amdfam10")
(and (eq_attr "type" "ssediv")
(and (eq_attr "mode" "SF,DF")
(eq_attr "memory" "load"))))
"athlon-direct,athlon-fploadk8,athlon-fmul*17")
(define_insn_reservation "athlon_ssediv" 20
- (and (eq_attr "cpu" "athlon,k8,generic64")
+ (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
(and (eq_attr "type" "ssediv")
(eq_attr "mode" "SF,DF")))
"athlon-direct,athlon-fpsched,athlon-fmul*17")
@@ -864,6 +1144,11 @@
(and (eq_attr "type" "ssediv")
(eq_attr "memory" "load")))
"athlon-double,athlon-fpload2k8,athlon-fmul*34")
+(define_insn_reservation "athlon_ssedivvector_load_amdfam10" 22
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "ssediv")
+ (eq_attr "memory" "load")))
+ "athlon-direct,athlon-fploadk8,athlon-fmul*17")
(define_insn_reservation "athlon_ssedivvector" 39
(and (eq_attr "cpu" "athlon")
(eq_attr "type" "ssediv"))
@@ -872,3 +1157,12 @@
(and (eq_attr "cpu" "k8,generic64")
(eq_attr "type" "ssediv"))
"athlon-double,athlon-fmul*34")
+(define_insn_reservation "athlon_ssedivvector_amdfam10" 20
+ (and (eq_attr "cpu" "amdfam10")
+ (eq_attr "type" "ssediv"))
+ "athlon-direct,athlon-fmul*17")
+(define_insn_reservation "athlon_sseins_amdfam10" 5
+ (and (eq_attr "cpu" "amdfam10")
+ (and (eq_attr "type" "sseins")
+ (eq_attr "mode" "TI")))
+ "athlon-vector,athlon-fpsched,athlon-faddmul")
Modified: trunk/contrib/gcc/config/i386/beos-elf.h
===================================================================
--- trunk/contrib/gcc4/config/i386/beos-elf.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/beos-elf.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -135,7 +135,7 @@
for the BeOS include files relative to TOOL_INCLUDE_DIR. Yes, we
use ANSI string concatenation here (FIXME) */
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#undef INCLUDE_DEFAULTS
#define INCLUDE_DEFAULTS \
{ \
@@ -177,7 +177,7 @@
{ "/boot/develop/headers", 0, 0, 0 }, \
{ 0, 0, 0, 0 } \
}
-#else /* CROSS_COMPILE */
+#else /* CROSS_DIRECTORY_STRUCTURE */
#undef INCLUDE_DEFAULTS
#define INCLUDE_DEFAULTS \
{ \
Modified: trunk/contrib/gcc/config/i386/cygwin.h
===================================================================
--- trunk/contrib/gcc4/config/i386/cygwin.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/cygwin.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -146,7 +146,7 @@
#undef TOOL_INCLUDE_DIR
#define TOOL_INCLUDE_DIR ((const char *) cygwin_tool_include_dir)
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR "/usr/include"
char cygwin_standard_include_dir[sizeof (STANDARD_INCLUDE_DIR) + 1
Modified: trunk/contrib/gcc/config/i386/driver-i386.c
===================================================================
--- trunk/contrib/gcc4/config/i386/driver-i386.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/driver-i386.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1,5 +1,5 @@
/* Subroutines for the gcc driver.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GCC.
@@ -40,6 +40,7 @@
#define bit_SSE3 (1 << 0)
#define bit_SSSE3 (1 << 9)
+#define bit_SSE4a (1 << 6)
#define bit_CMPXCHG16B (1 << 13)
#define bit_3DNOW (1 << 31)
@@ -68,7 +69,7 @@
unsigned int ext_level;
unsigned char has_mmx = 0, has_3dnow = 0, has_3dnowp = 0, has_sse = 0;
unsigned char has_sse2 = 0, has_sse3 = 0, has_ssse3 = 0, has_cmov = 0;
- unsigned char has_longmode = 0, has_cmpxchg8b = 0;
+ unsigned char has_longmode = 0, has_cmpxchg8b = 0, has_sse4a = 0;
unsigned char is_amd = 0;
unsigned int family = 0;
bool arch;
@@ -120,6 +121,7 @@
has_3dnow = !!(edx & bit_3DNOW);
has_3dnowp = !!(edx & bit_3DNOWP);
has_longmode = !!(edx & bit_LM);
+ has_sse4a = !!(ecx & bit_SSE4a);
}
is_amd = vendor == *(unsigned int*)"Auth";
@@ -132,6 +134,8 @@
processor = PROCESSOR_ATHLON;
if (has_sse2 || has_longmode)
processor = PROCESSOR_K8;
+ if (has_sse4a)
+ processor = PROCESSOR_AMDFAM10;
}
else
{
@@ -266,6 +270,9 @@
case PROCESSOR_NOCONA:
cpu = "nocona";
break;
+ case PROCESSOR_AMDFAM10:
+ cpu = "amdfam10";
+ break;
case PROCESSOR_GENERIC32:
case PROCESSOR_GENERIC64:
cpu = "generic";
Modified: trunk/contrib/gcc/config/i386/emmintrin.h
===================================================================
--- trunk/contrib/gcc4/config/i386/emmintrin.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/emmintrin.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -30,7 +30,11 @@
#ifndef _EMMINTRIN_H_INCLUDED
#define _EMMINTRIN_H_INCLUDED
-#ifdef __SSE2__
+#ifndef __SSE2__
+# error "SSE2 instruction set not enabled"
+#else
+
+/* We need definitions from the SSE header files*/
#include <xmmintrin.h>
/* SSE2 */
@@ -1122,9 +1126,9 @@
#define _mm_slli_epi16(__A, __B) \
((__m128i)__builtin_ia32_psllwi128 ((__v8hi)(__A), __B))
#define _mm_slli_epi32(__A, __B) \
- ((__m128i)__builtin_ia32_pslldi128 ((__v8hi)(__A), __B))
+ ((__m128i)__builtin_ia32_pslldi128 ((__v4si)(__A), __B))
#define _mm_slli_epi64(__A, __B) \
- ((__m128i)__builtin_ia32_psllqi128 ((__v8hi)(__A), __B))
+ ((__m128i)__builtin_ia32_psllqi128 ((__v2di)(__A), __B))
#endif
#if 0
@@ -1143,7 +1147,7 @@
#define _mm_srai_epi16(__A, __B) \
((__m128i)__builtin_ia32_psrawi128 ((__v8hi)(__A), __B))
#define _mm_srai_epi32(__A, __B) \
- ((__m128i)__builtin_ia32_psradi128 ((__v8hi)(__A), __B))
+ ((__m128i)__builtin_ia32_psradi128 ((__v4si)(__A), __B))
#endif
#if 0
@@ -1189,7 +1193,7 @@
#define _mm_srli_epi32(__A, __B) \
((__m128i)__builtin_ia32_psrldi128 ((__v4si)(__A), __B))
#define _mm_srli_epi64(__A, __B) \
- ((__m128i)__builtin_ia32_psrlqi128 ((__v4si)(__A), __B))
+ ((__m128i)__builtin_ia32_psrlqi128 ((__v2di)(__A), __B))
#endif
static __inline __m128i __attribute__((__always_inline__))
Modified: trunk/contrib/gcc/config/i386/freebsd.h
===================================================================
--- trunk/contrib/gcc4/config/i386/freebsd.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/freebsd.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -22,7 +22,7 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/config/i386/freebsd.h 238472 2012-07-15 10:54:10Z kib $ */
#undef CC1_SPEC
#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
Modified: trunk/contrib/gcc/config/i386/freebsd64.h
===================================================================
--- trunk/contrib/gcc4/config/i386/freebsd64.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/freebsd64.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -19,7 +19,7 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/config/i386/freebsd64.h 238472 2012-07-15 10:54:10Z kib $ */
#undef TARGET_VERSION
Modified: trunk/contrib/gcc/config/i386/i386.c
===================================================================
--- trunk/contrib/gcc4/config/i386/i386.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/i386.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -19,7 +19,7 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/config/i386/i386.c 265728 2014-05-09 01:30:15Z pfg $ */
#include "config.h"
#include "system.h"
@@ -548,6 +548,71 @@
COSTS_N_INSNS (35), /* cost of FSQRT instruction. */
};
+struct processor_costs amdfam10_cost = {
+ COSTS_N_INSNS (1), /* cost of an add instruction */
+ COSTS_N_INSNS (2), /* cost of a lea instruction */
+ COSTS_N_INSNS (1), /* variable shift costs */
+ COSTS_N_INSNS (1), /* constant shift costs */
+ {COSTS_N_INSNS (3), /* cost of starting multiply for QI */
+ COSTS_N_INSNS (4), /* HI */
+ COSTS_N_INSNS (3), /* SI */
+ COSTS_N_INSNS (4), /* DI */
+ COSTS_N_INSNS (5)}, /* other */
+ 0, /* cost of multiply per each bit set */
+ {COSTS_N_INSNS (19), /* cost of a divide/mod for QI */
+ COSTS_N_INSNS (35), /* HI */
+ COSTS_N_INSNS (51), /* SI */
+ COSTS_N_INSNS (83), /* DI */
+ COSTS_N_INSNS (83)}, /* other */
+ COSTS_N_INSNS (1), /* cost of movsx */
+ COSTS_N_INSNS (1), /* cost of movzx */
+ 8, /* "large" insn */
+ 9, /* MOVE_RATIO */
+ 4, /* cost for loading QImode using movzbl */
+ {3, 4, 3}, /* cost of loading integer registers
+ in QImode, HImode and SImode.
+ Relative to reg-reg move (2). */
+ {3, 4, 3}, /* cost of storing integer registers */
+ 4, /* cost of reg,reg fld/fst */
+ {4, 4, 12}, /* cost of loading fp registers
+ in SFmode, DFmode and XFmode */
+ {6, 6, 8}, /* cost of storing fp registers
+ in SFmode, DFmode and XFmode */
+ 2, /* cost of moving MMX register */
+ {3, 3}, /* cost of loading MMX registers
+ in SImode and DImode */
+ {4, 4}, /* cost of storing MMX registers
+ in SImode and DImode */
+ 2, /* cost of moving SSE register */
+ {4, 4, 3}, /* cost of loading SSE registers
+ in SImode, DImode and TImode */
+ {4, 4, 5}, /* cost of storing SSE registers
+ in SImode, DImode and TImode */
+ 3, /* MMX or SSE register to integer */
+ /* On K8
+ MOVD reg64, xmmreg Double FSTORE 4
+ MOVD reg32, xmmreg Double FSTORE 4
+ On AMDFAM10
+ MOVD reg64, xmmreg Double FADD 3
+ 1/1 1/1
+ MOVD reg32, xmmreg Double FADD 3
+ 1/1 1/1 */
+ 64, /* size of prefetch block */
+ /* New AMD processors never drop prefetches; if they cannot be performed
+ immediately, they are queued. We set number of simultaneous prefetches
+ to a large constant to reflect this (it probably is not a good idea not
+ to limit number of prefetches at all, as their execution also takes some
+ time). */
+ 100, /* number of parallel prefetches */
+ 5, /* Branch cost */
+ COSTS_N_INSNS (4), /* cost of FADD and FSUB insns. */
+ COSTS_N_INSNS (4), /* cost of FMUL instruction. */
+ COSTS_N_INSNS (19), /* cost of FDIV instruction. */
+ COSTS_N_INSNS (2), /* cost of FABS instruction. */
+ COSTS_N_INSNS (2), /* cost of FCHS instruction. */
+ COSTS_N_INSNS (35), /* cost of FSQRT instruction. */
+};
+
static const
struct processor_costs pentium4_cost = {
COSTS_N_INSNS (1), /* cost of an add instruction */
@@ -834,11 +899,13 @@
#define m_PENT4 (1<<PROCESSOR_PENTIUM4)
#define m_K8 (1<<PROCESSOR_K8)
#define m_ATHLON_K8 (m_K8 | m_ATHLON)
+#define m_AMDFAM10 (1<<PROCESSOR_AMDFAM10)
#define m_NOCONA (1<<PROCESSOR_NOCONA)
#define m_CORE2 (1<<PROCESSOR_CORE2)
#define m_GENERIC32 (1<<PROCESSOR_GENERIC32)
#define m_GENERIC64 (1<<PROCESSOR_GENERIC64)
#define m_GENERIC (m_GENERIC32 | m_GENERIC64)
+#define m_ATHLON_K8_AMDFAM10 (m_K8 | m_ATHLON | m_AMDFAM10)
/* Generic instruction choice should be common subset of supported CPUs
(PPro/PENT4/NOCONA/CORE2/Athlon/K8). */
@@ -846,22 +913,30 @@
/* Leave is not affecting Nocona SPEC2000 results negatively, so enabling for
Generic64 seems like good code size tradeoff. We can't enable it for 32bit
generic because it is not working well with PPro base chips. */
-const int x86_use_leave = m_386 | m_K6_GEODE | m_ATHLON_K8 | m_CORE2 | m_GENERIC64;
-const int x86_push_memory = m_386 | m_K6_GEODE | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
+const int x86_use_leave = m_386 | m_K6_GEODE | m_ATHLON_K8_AMDFAM10 | m_CORE2
+ | m_GENERIC64;
+const int x86_push_memory = m_386 | m_K6_GEODE | m_ATHLON_K8_AMDFAM10 | m_PENT4
+ | m_NOCONA | m_CORE2 | m_GENERIC;
const int x86_zero_extend_with_and = m_486 | m_PENT;
-const int x86_movx = m_ATHLON_K8 | m_PPRO | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC | m_GEODE /* m_386 | m_K6 */;
+/* Enable to zero extend integer registers to avoid partial dependencies */
+const int x86_movx = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_PENT4 | m_NOCONA
+ | m_CORE2 | m_GENERIC | m_GEODE /* m_386 | m_K6 */;
const int x86_double_with_add = ~m_386;
const int x86_use_bit_test = m_386;
-const int x86_unroll_strlen = m_486 | m_PENT | m_PPRO | m_ATHLON_K8 | m_K6 | m_CORE2 | m_GENERIC;
-const int x86_cmove = m_PPRO | m_GEODE | m_ATHLON_K8 | m_PENT4 | m_NOCONA;
-const int x86_3dnow_a = m_ATHLON_K8;
-const int x86_deep_branch = m_PPRO | m_K6_GEODE | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
+const int x86_unroll_strlen = m_486 | m_PENT | m_PPRO | m_ATHLON_K8_AMDFAM10
+ | m_K6 | m_CORE2 | m_GENERIC;
+const int x86_cmove = m_PPRO | m_GEODE | m_ATHLON_K8_AMDFAM10 | m_PENT4
+ | m_NOCONA;
+const int x86_3dnow_a = m_ATHLON_K8_AMDFAM10;
+const int x86_deep_branch = m_PPRO | m_K6_GEODE | m_ATHLON_K8_AMDFAM10
+ | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
/* Branch hints were put in P4 based on simulation result. But
after P4 was made, no performance benefit was observed with
branch hints. It also increases the code size. As the result,
icc never generates branch hints. */
const int x86_branch_hints = 0;
-const int x86_use_sahf = m_PPRO | m_K6_GEODE | m_PENT4 | m_NOCONA | m_GENERIC32; /*m_GENERIC | m_ATHLON_K8 ? */
+const int x86_use_sahf = m_PPRO | m_K6_GEODE | m_PENT4 | m_NOCONA | m_GENERIC32;
+ /*m_GENERIC | m_ATHLON_K8 ? */
/* We probably ought to watch for partial register stalls on Generic32
compilation setting as well. However in current implementation the
partial register stalls are not eliminated very well - they can
@@ -873,13 +948,16 @@
const int x86_partial_reg_stall = m_PPRO;
const int x86_partial_flag_reg_stall = m_CORE2 | m_GENERIC;
const int x86_use_himode_fiop = m_386 | m_486 | m_K6_GEODE;
-const int x86_use_simode_fiop = ~(m_PPRO | m_ATHLON_K8 | m_PENT | m_CORE2 | m_GENERIC);
+const int x86_use_simode_fiop = ~(m_PPRO | m_ATHLON_K8_AMDFAM10 | m_PENT
+ | m_CORE2 | m_GENERIC);
const int x86_use_mov0 = m_K6;
const int x86_use_cltd = ~(m_PENT | m_K6 | m_CORE2 | m_GENERIC);
const int x86_read_modify_write = ~m_PENT;
const int x86_read_modify = ~(m_PENT | m_PPRO);
const int x86_split_long_moves = m_PPRO;
-const int x86_promote_QImode = m_K6_GEODE | m_PENT | m_386 | m_486 | m_ATHLON_K8 | m_CORE2 | m_GENERIC; /* m_PENT4 ? */
+const int x86_promote_QImode = m_K6_GEODE | m_PENT | m_386 | m_486
+ | m_ATHLON_K8_AMDFAM10 | m_CORE2 | m_GENERIC;
+ /* m_PENT4 ? */
const int x86_fast_prefix = ~(m_PENT | m_486 | m_386);
const int x86_single_stringop = m_386 | m_PENT4 | m_NOCONA;
const int x86_qimode_math = ~(0);
@@ -889,18 +967,37 @@
if our scheme for avoiding partial stalls was more effective. */
const int x86_himode_math = ~(m_PPRO);
const int x86_promote_hi_regs = m_PPRO;
-const int x86_sub_esp_4 = m_ATHLON_K8 | m_PPRO | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
-const int x86_sub_esp_8 = m_ATHLON_K8 | m_PPRO | m_386 | m_486 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
-const int x86_add_esp_4 = m_ATHLON_K8 | m_K6_GEODE | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
-const int x86_add_esp_8 = m_ATHLON_K8 | m_PPRO | m_K6_GEODE | m_386 | m_486 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
-const int x86_integer_DFmode_moves = ~(m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_PPRO | m_CORE2 | m_GENERIC | m_GEODE);
-const int x86_partial_reg_dependency = m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
-const int x86_memory_mismatch_stall = m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
-const int x86_accumulate_outgoing_args = m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_PPRO | m_CORE2 | m_GENERIC;
+/* Enable if add/sub rsp is preferred over 1 or 2 push/pop */
+const int x86_sub_esp_4 = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_PENT4 | m_NOCONA
+ | m_CORE2 | m_GENERIC;
+const int x86_sub_esp_8 = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_386 | m_486
+ | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
+const int x86_add_esp_4 = m_ATHLON_K8_AMDFAM10 | m_K6_GEODE | m_PENT4 | m_NOCONA
+ | m_CORE2 | m_GENERIC;
+const int x86_add_esp_8 = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_K6_GEODE | m_386
+ | m_486 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
+/* Enable if integer moves are preferred for DFmode copies */
+const int x86_integer_DFmode_moves = ~(m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA
+ | m_PPRO | m_CORE2 | m_GENERIC | m_GEODE);
+const int x86_partial_reg_dependency = m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA
+ | m_CORE2 | m_GENERIC;
+const int x86_memory_mismatch_stall = m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA
+ | m_CORE2 | m_GENERIC;
+/* If ACCUMULATE_OUTGOING_ARGS is enabled, the maximum amount of space required
+ for outgoing arguments will be computed and placed into the variable
+ `current_function_outgoing_args_size'. No space will be pushed onto the stack
+ for each call; instead, the function prologue should increase the stack frame
+ size by this amount. Setting both PUSH_ARGS and ACCUMULATE_OUTGOING_ARGS is
+ not proper. */
+const int x86_accumulate_outgoing_args = m_ATHLON_K8_AMDFAM10 | m_PENT4
+ | m_NOCONA | m_PPRO | m_CORE2
+ | m_GENERIC;
const int x86_prologue_using_move = m_ATHLON_K8 | m_PPRO | m_CORE2 | m_GENERIC;
const int x86_epilogue_using_move = m_ATHLON_K8 | m_PPRO | m_CORE2 | m_GENERIC;
const int x86_shift1 = ~m_486;
-const int x86_arch_always_fancy_math_387 = m_PENT | m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
+const int x86_arch_always_fancy_math_387 = m_PENT | m_PPRO
+ | m_ATHLON_K8_AMDFAM10 | m_PENT4
+ | m_NOCONA | m_CORE2 | m_GENERIC;
/* In Generic model we have an conflict here in between PPro/Pentium4 based chips
that thread 128bit SSE registers as single units versus K8 based chips that
divide SSE registers to two 64bit halves.
@@ -910,15 +1007,66 @@
this option on P4 brings over 20% SPECfp regression, while enabling it on
K8 brings roughly 2.4% regression that can be partly masked by careful scheduling
of moves. */
-const int x86_sse_partial_reg_dependency = m_PENT4 | m_NOCONA | m_PPRO | m_CORE2 | m_GENERIC;
+const int x86_sse_partial_reg_dependency = m_PENT4 | m_NOCONA | m_PPRO | m_CORE2
+ | m_GENERIC | m_AMDFAM10;
/* Set for machines where the type and dependencies are resolved on SSE
register parts instead of whole registers, so we may maintain just
lower part of scalar values in proper format leaving the upper part
undefined. */
const int x86_sse_split_regs = m_ATHLON_K8;
-const int x86_sse_typeless_stores = m_ATHLON_K8;
+/* Code generation for scalar reg-reg moves of single and double precision data:
+ if (x86_sse_partial_reg_dependency == true | x86_sse_split_regs == true)
+ movaps reg, reg
+ else
+ movss reg, reg
+ if (x86_sse_partial_reg_dependency == true)
+ movapd reg, reg
+ else
+ movsd reg, reg
+
+ Code generation for scalar loads of double precision data:
+ if (x86_sse_split_regs == true)
+ movlpd mem, reg (gas syntax)
+ else
+ movsd mem, reg
+
+ Code generation for unaligned packed loads of single precision data
+ (x86_sse_unaligned_move_optimal overrides x86_sse_partial_reg_dependency):
+ if (x86_sse_unaligned_move_optimal)
+ movups mem, reg
+
+ if (x86_sse_partial_reg_dependency == true)
+ {
+ xorps reg, reg
+ movlps mem, reg
+ movhps mem+8, reg
+ }
+ else
+ {
+ movlps mem, reg
+ movhps mem+8, reg
+ }
+
+ Code generation for unaligned packed loads of double precision data
+ (x86_sse_unaligned_move_optimal overrides x86_sse_split_regs):
+ if (x86_sse_unaligned_move_optimal)
+ movupd mem, reg
+
+ if (x86_sse_split_regs == true)
+ {
+ movlpd mem, reg
+ movhpd mem+8, reg
+ }
+ else
+ {
+ movsd mem, reg
+ movhpd mem+8, reg
+ }
+ */
+const int x86_sse_unaligned_move_optimal = m_AMDFAM10;
+const int x86_sse_typeless_stores = m_ATHLON_K8_AMDFAM10;
const int x86_sse_load0_by_pxor = m_PPRO | m_PENT4 | m_NOCONA;
-const int x86_use_ffreep = m_ATHLON_K8;
+const int x86_use_ffreep = m_ATHLON_K8_AMDFAM10;
const int x86_rep_movl_optimal = m_386 | m_PENT | m_PPRO | m_K6_GEODE | m_CORE2;
const int x86_use_incdec = ~(m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC);
@@ -926,21 +1074,24 @@
integer data in xmm registers. Which results in pretty abysmal code. */
const int x86_inter_unit_moves = 0 /* ~(m_ATHLON_K8) */;
-const int x86_ext_80387_constants = m_K6_GEODE | m_ATHLON | m_PENT4 | m_NOCONA | m_CORE2 | m_PPRO | m_GENERIC32;
+const int x86_ext_80387_constants = m_K6_GEODE | m_ATHLON_K8 | m_PENT4
+ | m_NOCONA | m_PPRO | m_CORE2 | m_GENERIC;
/* Some CPU cores are not able to predict more than 4 branch instructions in
the 16 byte window. */
-const int x86_four_jump_limit = m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_CORE2 | m_GENERIC;
-const int x86_schedule = m_PPRO | m_ATHLON_K8 | m_K6_GEODE | m_PENT | m_CORE2 | m_GENERIC;
-const int x86_use_bt = m_ATHLON_K8;
+const int x86_four_jump_limit = m_PPRO | m_ATHLON_K8_AMDFAM10 | m_PENT4
+ | m_NOCONA | m_CORE2 | m_GENERIC;
+const int x86_schedule = m_PPRO | m_ATHLON_K8_AMDFAM10 | m_K6_GEODE | m_PENT
+ | m_CORE2 | m_GENERIC;
+const int x86_use_bt = m_ATHLON_K8_AMDFAM10;
/* 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 | m_CORE2;
/* Exchange and add was added for 80486. */
const int x86_xadd = ~m_386;
-const int x86_pad_returns = m_ATHLON_K8 | m_CORE2 | m_GENERIC;
+/* Byteswap was added for 80486. */
+const int x86_bswap = ~m_386;
+const int x86_pad_returns = m_ATHLON_K8_AMDFAM10 | m_CORE2 | m_GENERIC;
/* In case the average insn count for single function invocation is
lower than this constant, emit fast (but longer) prologue and
@@ -1157,6 +1308,9 @@
/* true if sse prefetch instruction is not NOOP. */
int x86_prefetch_sse;
+/* true if cmpxchg16b is supported. */
+int x86_cmpxchg16b;
+
/* ix86_regparm_string as a number */
static int ix86_regparm;
@@ -1511,8 +1665,8 @@
case OPT_msse:
if (!value)
{
- target_flags &= ~(MASK_SSE2 | MASK_SSE3 | MASK_SSSE3);
- target_flags_explicit |= MASK_SSE2 | MASK_SSE3 | MASK_SSSE3;
+ target_flags &= ~(MASK_SSE2 | MASK_SSE3 | MASK_SSSE3 | MASK_SSE4A);
+ target_flags_explicit |= MASK_SSE2 | MASK_SSE3 | MASK_SSSE3 | MASK_SSE4A;
}
return true;
@@ -1519,8 +1673,8 @@
case OPT_msse2:
if (!value)
{
- target_flags &= ~(MASK_SSE3 | MASK_SSSE3);
- target_flags_explicit |= MASK_SSE3 | MASK_SSSE3;
+ target_flags &= ~(MASK_SSE3 | MASK_SSSE3 | MASK_SSE4A);
+ target_flags_explicit |= MASK_SSE3 | MASK_SSSE3 | MASK_SSE4A;
}
return true;
@@ -1527,11 +1681,19 @@
case OPT_msse3:
if (!value)
{
- target_flags &= ~MASK_SSSE3;
- target_flags_explicit |= MASK_SSSE3;
+ target_flags &= ~(MASK_SSSE3 | MASK_SSE4A);
+ target_flags_explicit |= MASK_SSSE3 | MASK_SSE4A;
}
return true;
+ case OPT_maes:
+ if (!value)
+ {
+ target_flags &= ~MASK_AES;
+ target_flags_explicit |= MASK_AES;
+ }
+ return true;
+
default:
return true;
}
@@ -1580,7 +1742,8 @@
{&nocona_cost, 0, 0, 0, 0, 0, 0, 0},
{&core2_cost, 0, 0, 16, 7, 16, 7, 16},
{&generic32_cost, 0, 0, 16, 7, 16, 7, 16},
- {&generic64_cost, 0, 0, 16, 7, 16, 7, 16}
+ {&generic64_cost, 0, 0, 16, 7, 16, 7, 16},
+ {&amdfam10_cost, 0, 0, 32, 24, 32, 7, 32}
};
static const char * const cpu_names[] = TARGET_CPU_DEFAULT_NAMES;
@@ -1598,7 +1761,11 @@
PTA_3DNOW = 32,
PTA_3DNOW_A = 64,
PTA_64BIT = 128,
- PTA_SSSE3 = 256
+ PTA_SSSE3 = 256,
+ PTA_CX16 = 512,
+ PTA_POPCNT = 1024,
+ PTA_ABM = 2048,
+ PTA_SSE4A = 4096
} flags;
}
const processor_alias_table[] =
@@ -1625,10 +1792,10 @@
{"prescott", PROCESSOR_NOCONA, PTA_SSE | PTA_SSE2 | PTA_SSE3
| PTA_MMX | PTA_PREFETCH_SSE},
{"nocona", PROCESSOR_NOCONA, PTA_SSE | PTA_SSE2 | PTA_SSE3 | PTA_64BIT
- | PTA_MMX | PTA_PREFETCH_SSE},
+ | PTA_MMX | PTA_PREFETCH_SSE | PTA_CX16},
{"core2", PROCESSOR_CORE2, PTA_SSE | PTA_SSE2 | PTA_SSE3 | PTA_SSSE3
| PTA_64BIT | PTA_MMX
- | PTA_PREFETCH_SSE},
+ | PTA_PREFETCH_SSE | PTA_CX16},
{"geode", PROCESSOR_GEODE, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
| PTA_3DNOW_A},
{"k6", PROCESSOR_K6, PTA_MMX},
@@ -1663,6 +1830,14 @@
| PTA_SSE3 },
{"athlon-fx", PROCESSOR_K8, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW | PTA_64BIT
| PTA_3DNOW_A | PTA_SSE | PTA_SSE2},
+ {"amdfam10", PROCESSOR_AMDFAM10, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
+ | PTA_64BIT | PTA_3DNOW_A | PTA_SSE
+ | PTA_SSE2 | PTA_SSE3 | PTA_POPCNT
+ | PTA_ABM | PTA_SSE4A | PTA_CX16},
+ {"barcelona", PROCESSOR_AMDFAM10, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
+ | PTA_64BIT | PTA_3DNOW_A | PTA_SSE
+ | PTA_SSE2 | PTA_SSE3 | PTA_POPCNT
+ | PTA_ABM | PTA_SSE4A | PTA_CX16},
{"generic32", PROCESSOR_GENERIC32, 0 /* flags are only used for -march switch. */ },
{"generic64", PROCESSOR_GENERIC64, PTA_64BIT /* flags are only used for -march switch. */ },
};
@@ -1825,6 +2000,17 @@
target_flags |= MASK_SSSE3;
if (processor_alias_table[i].flags & PTA_PREFETCH_SSE)
x86_prefetch_sse = true;
+ if (processor_alias_table[i].flags & PTA_CX16)
+ x86_cmpxchg16b = true;
+ if (processor_alias_table[i].flags & PTA_POPCNT
+ && !(target_flags_explicit & MASK_POPCNT))
+ target_flags |= MASK_POPCNT;
+ if (processor_alias_table[i].flags & PTA_ABM
+ && !(target_flags_explicit & MASK_ABM))
+ target_flags |= MASK_ABM;
+ if (processor_alias_table[i].flags & PTA_SSE4A
+ && !(target_flags_explicit & MASK_SSE4A))
+ target_flags |= MASK_SSE4A;
if (TARGET_64BIT && !(processor_alias_table[i].flags & PTA_64BIT))
error ("CPU you selected does not support x86-64 "
"instruction set");
@@ -2003,10 +2189,18 @@
if (TARGET_SSSE3)
target_flags |= MASK_SSE3;
+ /* Turn on SSE3 builtins for -msse4a. */
+ if (TARGET_SSE4A)
+ target_flags |= MASK_SSE3;
+
/* Turn on SSE2 builtins for -msse3. */
if (TARGET_SSE3)
target_flags |= MASK_SSE2;
+ /* Turn on SSE2 builtins for -maes. */
+ if (TARGET_AES)
+ target_flags |= MASK_SSE2;
+
/* Turn on SSE builtins for -msse2. */
if (TARGET_SSE2)
target_flags |= MASK_SSE;
@@ -2022,6 +2216,10 @@
if (TARGET_3DNOW)
target_flags |= MASK_MMX;
+ /* Turn on POPCNT builtins for -mabm. */
+ if (TARGET_ABM)
+ target_flags |= MASK_POPCNT;
+
if (TARGET_64BIT)
{
if (TARGET_ALIGN_DOUBLE)
@@ -9247,9 +9445,17 @@
}
if (TARGET_SSE2 && mode == V2DFmode)
- {
- rtx zero;
+ {
+ rtx zero;
+ if (TARGET_SSE_UNALIGNED_MOVE_OPTIMAL)
+ {
+ op0 = gen_lowpart (V2DFmode, op0);
+ op1 = gen_lowpart (V2DFmode, op1);
+ emit_insn (gen_sse2_movupd (op0, op1));
+ return;
+ }
+
/* When SSE registers are split into halves, we can avoid
writing to the top half twice. */
if (TARGET_SSE_SPLIT_REGS)
@@ -9276,7 +9482,15 @@
emit_insn (gen_sse2_loadhpd (op0, op0, m));
}
else
- {
+ {
+ if (TARGET_SSE_UNALIGNED_MOVE_OPTIMAL)
+ {
+ op0 = gen_lowpart (V4SFmode, op0);
+ op1 = gen_lowpart (V4SFmode, op1);
+ emit_insn (gen_sse_movups (op0, op1));
+ return;
+ }
+
if (TARGET_SSE_PARTIAL_REG_DEPENDENCY)
emit_move_insn (op0, CONST0_RTX (mode));
else
@@ -13833,6 +14047,7 @@
case PROCESSOR_PENTIUM4:
case PROCESSOR_ATHLON:
case PROCESSOR_K8:
+ case PROCESSOR_AMDFAM10:
case PROCESSOR_NOCONA:
case PROCESSOR_GENERIC32:
case PROCESSOR_GENERIC64:
@@ -14031,6 +14246,7 @@
case PROCESSOR_ATHLON:
case PROCESSOR_K8:
+ case PROCESSOR_AMDFAM10:
case PROCESSOR_GENERIC32:
case PROCESSOR_GENERIC64:
memory = get_attr_memory (insn);
@@ -14192,7 +14408,7 @@
if (AGGREGATE_TYPE_P (type)
&& TYPE_SIZE (type)
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
- && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= 16
+ && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= 128
|| TREE_INT_CST_HIGH (TYPE_SIZE (type))) && align < 128)
return 128;
}
@@ -14744,6 +14960,14 @@
IX86_BUILTIN_PABSW128,
IX86_BUILTIN_PABSD128,
+ /* AMDFAM10 - SSE4A New Instructions. */
+ IX86_BUILTIN_MOVNTSD,
+ IX86_BUILTIN_MOVNTSS,
+ IX86_BUILTIN_EXTRQI,
+ IX86_BUILTIN_EXTRQ,
+ IX86_BUILTIN_INSERTQI,
+ IX86_BUILTIN_INSERTQ,
+
IX86_BUILTIN_VEC_INIT_V2SI,
IX86_BUILTIN_VEC_INIT_V4HI,
IX86_BUILTIN_VEC_INIT_V8QI,
@@ -15184,7 +15408,7 @@
const struct builtin_description * d;
size_t i;
- tree V16QI_type_node = build_vector_type_for_mode (intQI_type_node, V16QImode);
+ tree V16QI_type_node = build_vector_type_for_mode (char_type_node, V16QImode);
tree V2SI_type_node = build_vector_type_for_mode (intSI_type_node, V2SImode);
tree V2SF_type_node = build_vector_type_for_mode (float_type_node, V2SFmode);
tree V2DI_type_node
@@ -15193,7 +15417,7 @@
tree V4SF_type_node = build_vector_type_for_mode (float_type_node, V4SFmode);
tree V4SI_type_node = build_vector_type_for_mode (intSI_type_node, V4SImode);
tree V4HI_type_node = build_vector_type_for_mode (intHI_type_node, V4HImode);
- tree V8QI_type_node = build_vector_type_for_mode (intQI_type_node, V8QImode);
+ tree V8QI_type_node = build_vector_type_for_mode (char_type_node, V8QImode);
tree V8HI_type_node = build_vector_type_for_mode (intHI_type_node, V8HImode);
tree pchar_type_node = build_pointer_type (char_type_node);
@@ -15468,6 +15692,18 @@
= build_function_type_list (void_type_node,
pchar_type_node, V16QI_type_node, NULL_TREE);
+ tree v2di_ftype_v2di_unsigned_unsigned
+ = build_function_type_list (V2DI_type_node, V2DI_type_node,
+ unsigned_type_node, unsigned_type_node,
+ NULL_TREE);
+ tree v2di_ftype_v2di_v2di_unsigned_unsigned
+ = build_function_type_list (V2DI_type_node, V2DI_type_node, V2DI_type_node,
+ unsigned_type_node, unsigned_type_node,
+ NULL_TREE);
+ tree v2di_ftype_v2di_v16qi
+ = build_function_type_list (V2DI_type_node, V2DI_type_node, V16QI_type_node,
+ NULL_TREE);
+
tree float80_type;
tree float128_type;
tree ftype;
@@ -15804,6 +16040,20 @@
def_builtin (MASK_SSSE3, "__builtin_ia32_palignr", di_ftype_di_di_int,
IX86_BUILTIN_PALIGNR);
+ /* AMDFAM10 SSE4A New built-ins */
+ def_builtin (MASK_SSE4A, "__builtin_ia32_movntsd",
+ void_ftype_pdouble_v2df, IX86_BUILTIN_MOVNTSD);
+ def_builtin (MASK_SSE4A, "__builtin_ia32_movntss",
+ void_ftype_pfloat_v4sf, IX86_BUILTIN_MOVNTSS);
+ def_builtin (MASK_SSE4A, "__builtin_ia32_extrqi",
+ v2di_ftype_v2di_unsigned_unsigned, IX86_BUILTIN_EXTRQI);
+ def_builtin (MASK_SSE4A, "__builtin_ia32_extrq",
+ v2di_ftype_v2di_v16qi, IX86_BUILTIN_EXTRQ);
+ def_builtin (MASK_SSE4A, "__builtin_ia32_insertqi",
+ v2di_ftype_v2di_v2di_unsigned_unsigned, IX86_BUILTIN_INSERTQI);
+ def_builtin (MASK_SSE4A, "__builtin_ia32_insertq",
+ v2di_ftype_v2di_v2di, IX86_BUILTIN_INSERTQ);
+
/* Access to the vec_init patterns. */
ftype = build_function_type_list (V2SI_type_node, integer_type_node,
integer_type_node, NULL_TREE);
@@ -16300,9 +16550,9 @@
enum insn_code icode;
tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
tree arglist = TREE_OPERAND (exp, 1);
- tree arg0, arg1, arg2;
- rtx op0, op1, op2, pat;
- enum machine_mode tmode, mode0, mode1, mode2, mode3;
+ tree arg0, arg1, arg2, arg3;
+ rtx op0, op1, op2, op3, pat;
+ enum machine_mode tmode, mode0, mode1, mode2, mode3, mode4;
unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
switch (fcode)
@@ -16818,6 +17068,114 @@
emit_insn (pat);
return target;
+ case IX86_BUILTIN_MOVNTSD:
+ return ix86_expand_store_builtin (CODE_FOR_sse4a_vmmovntv2df, arglist);
+
+ case IX86_BUILTIN_MOVNTSS:
+ return ix86_expand_store_builtin (CODE_FOR_sse4a_vmmovntv4sf, arglist);
+
+ case IX86_BUILTIN_INSERTQ:
+ case IX86_BUILTIN_EXTRQ:
+ icode = (fcode == IX86_BUILTIN_EXTRQ
+ ? CODE_FOR_sse4a_extrq
+ : CODE_FOR_sse4a_insertq);
+ arg0 = TREE_VALUE (arglist);
+ arg1 = TREE_VALUE (TREE_CHAIN (arglist));
+ op0 = expand_normal (arg0);
+ op1 = expand_normal (arg1);
+ tmode = insn_data[icode].operand[0].mode;
+ mode1 = insn_data[icode].operand[1].mode;
+ mode2 = insn_data[icode].operand[2].mode;
+ if (! (*insn_data[icode].operand[1].predicate) (op0, mode1))
+ op0 = copy_to_mode_reg (mode1, op0);
+ if (! (*insn_data[icode].operand[2].predicate) (op1, mode2))
+ op1 = copy_to_mode_reg (mode2, op1);
+ if (optimize || target == 0
+ || GET_MODE (target) != tmode
+ || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
+ target = gen_reg_rtx (tmode);
+ pat = GEN_FCN (icode) (target, op0, op1);
+ if (! pat)
+ return NULL_RTX;
+ emit_insn (pat);
+ return target;
+
+ case IX86_BUILTIN_EXTRQI:
+ icode = CODE_FOR_sse4a_extrqi;
+ arg0 = TREE_VALUE (arglist);
+ arg1 = TREE_VALUE (TREE_CHAIN (arglist));
+ arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
+ op0 = expand_normal (arg0);
+ op1 = expand_normal (arg1);
+ op2 = expand_normal (arg2);
+ tmode = insn_data[icode].operand[0].mode;
+ mode1 = insn_data[icode].operand[1].mode;
+ mode2 = insn_data[icode].operand[2].mode;
+ mode3 = insn_data[icode].operand[3].mode;
+ if (! (*insn_data[icode].operand[1].predicate) (op0, mode1))
+ op0 = copy_to_mode_reg (mode1, op0);
+ if (! (*insn_data[icode].operand[2].predicate) (op1, mode2))
+ {
+ error ("index mask must be an immediate");
+ return gen_reg_rtx (tmode);
+ }
+ if (! (*insn_data[icode].operand[3].predicate) (op2, mode3))
+ {
+ error ("length mask must be an immediate");
+ return gen_reg_rtx (tmode);
+ }
+ if (optimize || target == 0
+ || GET_MODE (target) != tmode
+ || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
+ target = gen_reg_rtx (tmode);
+ pat = GEN_FCN (icode) (target, op0, op1, op2);
+ if (! pat)
+ return NULL_RTX;
+ emit_insn (pat);
+ return target;
+
+ case IX86_BUILTIN_INSERTQI:
+ icode = CODE_FOR_sse4a_insertqi;
+ arg0 = TREE_VALUE (arglist);
+ arg1 = TREE_VALUE (TREE_CHAIN (arglist));
+ arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
+ arg3 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (arglist))));
+ op0 = expand_normal (arg0);
+ op1 = expand_normal (arg1);
+ op2 = expand_normal (arg2);
+ op3 = expand_normal (arg3);
+ tmode = insn_data[icode].operand[0].mode;
+ mode1 = insn_data[icode].operand[1].mode;
+ mode2 = insn_data[icode].operand[2].mode;
+ mode3 = insn_data[icode].operand[3].mode;
+ mode4 = insn_data[icode].operand[4].mode;
+
+ if (! (*insn_data[icode].operand[1].predicate) (op0, mode1))
+ op0 = copy_to_mode_reg (mode1, op0);
+
+ if (! (*insn_data[icode].operand[2].predicate) (op1, mode2))
+ op1 = copy_to_mode_reg (mode2, op1);
+
+ if (! (*insn_data[icode].operand[3].predicate) (op2, mode3))
+ {
+ error ("index mask must be an immediate");
+ return gen_reg_rtx (tmode);
+ }
+ if (! (*insn_data[icode].operand[4].predicate) (op3, mode4))
+ {
+ error ("length mask must be an immediate");
+ return gen_reg_rtx (tmode);
+ }
+ if (optimize || target == 0
+ || GET_MODE (target) != tmode
+ || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
+ target = gen_reg_rtx (tmode);
+ pat = GEN_FCN (icode) (target, op0, op1, op2, op3);
+ if (! pat)
+ return NULL_RTX;
+ emit_insn (pat);
+ return target;
+
case IX86_BUILTIN_VEC_INIT_V2SI:
case IX86_BUILTIN_VEC_INIT_V4HI:
case IX86_BUILTIN_VEC_INIT_V8QI:
Modified: trunk/contrib/gcc/config/i386/i386.h
===================================================================
--- trunk/contrib/gcc4/config/i386/i386.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/i386.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -141,6 +141,7 @@
#define TARGET_GENERIC32 (ix86_tune == PROCESSOR_GENERIC32)
#define TARGET_GENERIC64 (ix86_tune == PROCESSOR_GENERIC64)
#define TARGET_GENERIC (TARGET_GENERIC32 || TARGET_GENERIC64)
+#define TARGET_AMDFAM10 (ix86_tune == PROCESSOR_AMDFAM10)
#define TUNEMASK (1 << ix86_tune)
extern const int x86_use_leave, x86_push_memory, x86_zero_extend_with_and;
@@ -159,15 +160,17 @@
extern const int x86_epilogue_using_move, x86_decompose_lea;
extern const int x86_arch_always_fancy_math_387, x86_shift1;
extern const int x86_sse_partial_reg_dependency, x86_sse_split_regs;
+extern const int x86_sse_unaligned_move_optimal;
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_cmpxchg8b, x86_cmpxchg16b, x86_xadd;
+extern const int x86_cmpxchg, x86_cmpxchg8b, x86_xadd;
extern const int x86_use_incdec;
extern const int x86_pad_returns;
+extern const int x86_bswap;
extern const int x86_partial_flag_reg_stall;
-extern int x86_prefetch_sse;
+extern int x86_prefetch_sse, x86_cmpxchg16b;
#define TARGET_USE_LEAVE (x86_use_leave & TUNEMASK)
#define TARGET_PUSH_MEMORY (x86_push_memory & TUNEMASK)
@@ -207,6 +210,8 @@
#define TARGET_PARTIAL_REG_DEPENDENCY (x86_partial_reg_dependency & TUNEMASK)
#define TARGET_SSE_PARTIAL_REG_DEPENDENCY \
(x86_sse_partial_reg_dependency & TUNEMASK)
+#define TARGET_SSE_UNALIGNED_MOVE_OPTIMAL \
+ (x86_sse_unaligned_move_optimal & TUNEMASK)
#define TARGET_SSE_SPLIT_REGS (x86_sse_split_regs & TUNEMASK)
#define TARGET_SSE_TYPELESS_STORES (x86_sse_typeless_stores & TUNEMASK)
#define TARGET_SSE_LOAD0_BY_PXOR (x86_sse_load0_by_pxor & TUNEMASK)
@@ -237,8 +242,9 @@
#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_CMPXCHG16B (x86_cmpxchg16b)
#define TARGET_XADD (x86_xadd & (1 << ix86_arch))
+#define TARGET_BSWAP (x86_bswap & (1 << ix86_arch))
#ifndef TARGET_64BIT_DEFAULT
#define TARGET_64BIT_DEFAULT 0
@@ -399,6 +405,8 @@
} \
else if (TARGET_K8) \
builtin_define ("__tune_k8__"); \
+ else if (TARGET_AMDFAM10) \
+ builtin_define ("__tune_amdfam10__"); \
else if (TARGET_PENTIUM4) \
builtin_define ("__tune_pentium4__"); \
else if (TARGET_NOCONA) \
@@ -420,6 +428,10 @@
builtin_define ("__SSE3__"); \
if (TARGET_SSSE3) \
builtin_define ("__SSSE3__"); \
+ if (TARGET_SSE4A) \
+ builtin_define ("__SSE4A__"); \
+ if (TARGET_AES) \
+ builtin_define ("__AES__"); \
if (TARGET_SSE_MATH && TARGET_SSE) \
builtin_define ("__SSE_MATH__"); \
if (TARGET_SSE_MATH && TARGET_SSE2) \
@@ -475,6 +487,11 @@
builtin_define ("__k8"); \
builtin_define ("__k8__"); \
} \
+ else if (ix86_arch == PROCESSOR_AMDFAM10) \
+ { \
+ builtin_define ("__amdfam10"); \
+ builtin_define ("__amdfam10__"); \
+ } \
else if (ix86_arch == PROCESSOR_PENTIUM4) \
{ \
builtin_define ("__pentium4"); \
@@ -513,6 +530,7 @@
#define TARGET_CPU_DEFAULT_nocona 17
#define TARGET_CPU_DEFAULT_core2 18
#define TARGET_CPU_DEFAULT_generic 19
+#define TARGET_CPU_DEFAULT_amdfam10 20
#define TARGET_CPU_DEFAULT_NAMES {"i386", "i486", "pentium", "pentium-mmx",\
"pentiumpro", "pentium2", "pentium3", \
@@ -519,7 +537,7 @@
"pentium4", "geode", "k6", "k6-2", "k6-3", \
"athlon", "athlon-4", "k8", \
"pentium-m", "prescott", "nocona", \
- "core2", "generic"}
+ "core2", "generic", "amdfam10"}
#ifndef CC1_SPEC
#define CC1_SPEC "%(cc1_cpu) "
@@ -2108,6 +2126,7 @@
PROCESSOR_CORE2,
PROCESSOR_GENERIC32,
PROCESSOR_GENERIC64,
+ PROCESSOR_AMDFAM10,
PROCESSOR_max
};
Modified: trunk/contrib/gcc/config/i386/i386.md
===================================================================
--- trunk/contrib/gcc4/config/i386/i386.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/i386.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -153,6 +153,12 @@
(UNSPEC_PSHUFB 120)
(UNSPEC_PSIGN 121)
(UNSPEC_PALIGNR 122)
+
+ ; For SSE4A support
+ (UNSPEC_EXTRQI 130)
+ (UNSPEC_EXTRQ 131)
+ (UNSPEC_INSERTQI 132)
+ (UNSPEC_INSERTQ 133)
])
(define_constants
@@ -192,7 +198,8 @@
;; Processor type. This attribute must exactly match the processor_type
;; enumeration in i386.h.
-(define_attr "cpu" "i386,i486,pentium,pentiumpro,geode,k6,athlon,pentium4,k8,nocona,core2,generic32,generic64"
+(define_attr "cpu" "i386,i486,pentium,pentiumpro,geode,k6,athlon,pentium4,k8,
+ nocona,core2,generic32,generic64,amdfam10"
(const (symbol_ref "ix86_tune")))
;; A basic instruction type. Refinements due to arguments to be
@@ -203,10 +210,10 @@
incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
icmp,test,ibr,setcc,icmov,
push,pop,call,callv,leave,
- str,cld,
+ str,bitmanip,cld,
fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
sselog,sselog1,sseiadd,sseishft,sseimul,
- sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,
+ sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,sseins,
mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
(const_string "other"))
@@ -220,7 +227,7 @@
(cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
(const_string "i387")
(eq_attr "type" "sselog,sselog1,sseiadd,sseishft,sseimul,
- sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv")
+ sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,sseins")
(const_string "sse")
(eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
(const_string "mmx")
@@ -230,7 +237,8 @@
;; The (bounding maximum) length of an instruction immediate.
(define_attr "length_immediate" ""
- (cond [(eq_attr "type" "incdec,setcc,icmov,str,cld,lea,other,multi,idiv,leave")
+ (cond [(eq_attr "type" "incdec,setcc,icmov,str,cld,lea,other,multi,idiv,leave,
+ bitmanip")
(const_int 0)
(eq_attr "unit" "i387,sse,mmx")
(const_int 0)
@@ -276,7 +284,7 @@
(const_int 0)))
;; Set when string REP prefix is used.
-(define_attr "prefix_rep" ""
+(define_attr "prefix_rep" ""
(if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
(const_int 1)
(const_int 0)))
@@ -283,8 +291,8 @@
;; Set when 0f opcode prefix is used.
(define_attr "prefix_0f" ""
- (if_then_else
- (ior (eq_attr "type" "imovx,setcc,icmov")
+ (if_then_else
+ (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
(eq_attr "unit" "sse,mmx"))
(const_int 1)
(const_int 0)))
@@ -413,7 +421,7 @@
(const_string "load")
(and (eq_attr "type"
"!alu1,negnot,ishift1,
- imov,imovx,icmp,test,
+ imov,imovx,icmp,test,bitmanip,
fmov,fcmp,fsgn,
sse,ssemov,ssecmp,ssecomi,ssecvt,sseicvt,sselog1,
mmx,mmxmov,mmxcmp,mmxcvt")
@@ -458,7 +466,7 @@
;; All x87 floating point modes
(define_mode_macro X87MODEF [SF DF XF])
-
+
;; All integer modes handled by x87 fisttp operator.
(define_mode_macro X87MODEI [HI SI DI])
@@ -467,7 +475,7 @@
;; All SSE floating point modes
(define_mode_macro SSEMODEF [SF DF])
-
+
;; All integer modes handled by SSE cvtts?2si* operators.
(define_mode_macro SSEMODEI24 [SI DI])
@@ -968,10 +976,11 @@
"sahf"
[(set_attr "length" "1")
(set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "direct")
(set_attr "mode" "SI")])
;; Pentium Pro can do steps 1 through 3 in one go.
-
+;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
(define_insn "*cmpfp_i_mixed"
[(set (reg:CCFP FLAGS_REG)
(compare:CCFP (match_operand 0 "register_operand" "f,x")
@@ -985,7 +994,8 @@
(if_then_else (match_operand:SF 1 "" "")
(const_string "SF")
(const_string "DF")))
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*cmpfp_i_sse"
[(set (reg:CCFP FLAGS_REG)
@@ -1000,7 +1010,8 @@
(if_then_else (match_operand:SF 1 "" "")
(const_string "SF")
(const_string "DF")))
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*cmpfp_i_i387"
[(set (reg:CCFP FLAGS_REG)
@@ -1019,7 +1030,8 @@
(const_string "DF")
]
(const_string "XF")))
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*cmpfp_iu_mixed"
[(set (reg:CCFPU FLAGS_REG)
@@ -1034,7 +1046,8 @@
(if_then_else (match_operand:SF 1 "" "")
(const_string "SF")
(const_string "DF")))
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*cmpfp_iu_sse"
[(set (reg:CCFPU FLAGS_REG)
@@ -1049,7 +1062,8 @@
(if_then_else (match_operand:SF 1 "" "")
(const_string "SF")
(const_string "DF")))
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*cmpfp_iu_387"
[(set (reg:CCFPU FLAGS_REG)
@@ -1068,7 +1082,8 @@
(const_string "DF")
]
(const_string "XF")))
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "direct")])
;; Move instructions.
@@ -1083,7 +1098,7 @@
;; Push/pop instructions. They are separate since autoinc/dec is not a
;; general_operand.
;;
-;; %%% We don't use a post-inc memory reference because x86 is not a
+;; %%% We don't use a post-inc memory reference because x86 is not a
;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
;; targets without our curiosities, and it is just as easy to represent
@@ -1145,7 +1160,7 @@
[(set_attr "type" "alu1")
(set_attr "mode" "SI")
(set_attr "length_immediate" "0")])
-
+
(define_insn "*movsi_or"
[(set (match_operand:SI 0 "register_operand" "=r")
(match_operand:SI 1 "immediate_operand" "i"))
@@ -1274,7 +1289,8 @@
[(set_attr "type" "imov")
(set_attr "mode" "SI")
(set_attr "pent_pair" "np")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "double")])
(define_expand "movhi"
[(set (match_operand:HI 0 "nonimmediate_operand" "")
@@ -1391,8 +1407,10 @@
[(set_attr "type" "imov")
(set_attr "mode" "SI")
(set_attr "pent_pair" "np")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "double")])
+;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
(define_insn "*swaphi_2"
[(set (match_operand:HI 0 "register_operand" "+r")
(match_operand:HI 1 "register_operand" "+r"))
@@ -1565,8 +1583,10 @@
[(set_attr "type" "imov")
(set_attr "mode" "SI")
(set_attr "pent_pair" "np")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "vector")])
+;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
(define_insn "*swapqi_2"
[(set (match_operand:QI 0 "register_operand" "+q")
(match_operand:QI 1 "register_operand" "+q"))
@@ -2120,7 +2140,8 @@
[(set_attr "type" "imov")
(set_attr "mode" "DI")
(set_attr "pent_pair" "np")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "double")])
(define_expand "movti"
[(set (match_operand:TI 0 "nonimmediate_operand" "")
@@ -2287,7 +2308,7 @@
&& (reload_in_progress || reload_completed
|| (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
|| GET_CODE (operands[1]) != CONST_DOUBLE
- || memory_operand (operands[0], SFmode))"
+ || memory_operand (operands[0], SFmode))"
{
switch (which_alternative)
{
@@ -2347,7 +2368,7 @@
(const_string "V4SF"))
/* For architectures resolving dependencies on
whole SSE registers use APS move to break dependency
- chains, otherwise use short move to avoid extra work.
+ chains, otherwise use short move to avoid extra work.
Do the same for architectures resolving dependencies on
the parts. While in DF mode it is better to always handle
@@ -2455,7 +2476,7 @@
&& (reload_in_progress || reload_completed
|| (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
|| GET_CODE (operands[1]) != CONST_DOUBLE
- || memory_operand (operands[0], DFmode))"
+ || memory_operand (operands[0], DFmode))"
{
switch (which_alternative)
{
@@ -2575,7 +2596,7 @@
&& (reload_in_progress || reload_completed
|| (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
|| GET_CODE (operands[1]) != CONST_DOUBLE
- || memory_operand (operands[0], DFmode))"
+ || memory_operand (operands[0], DFmode))"
{
switch (which_alternative)
{
@@ -2691,10 +2712,10 @@
(match_operand:DF 1 "general_operand" ""))]
"reload_completed
&& (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
- && ! (ANY_FP_REG_P (operands[0]) ||
+ && ! (ANY_FP_REG_P (operands[0]) ||
(GET_CODE (operands[0]) == SUBREG
&& ANY_FP_REG_P (SUBREG_REG (operands[0]))))
- && ! (ANY_FP_REG_P (operands[1]) ||
+ && ! (ANY_FP_REG_P (operands[1]) ||
(GET_CODE (operands[1]) == SUBREG
&& ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
[(const_int 0)]
@@ -2786,7 +2807,7 @@
&& (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
&& (reload_in_progress || reload_completed
|| GET_CODE (operands[1]) != CONST_DOUBLE
- || memory_operand (operands[0], XFmode))"
+ || memory_operand (operands[0], XFmode))"
{
switch (which_alternative)
{
@@ -2820,7 +2841,7 @@
&& (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
&& (reload_in_progress || reload_completed
|| GET_CODE (operands[1]) != CONST_DOUBLE
- || memory_operand (operands[0], XFmode))"
+ || memory_operand (operands[0], XFmode))"
{
switch (which_alternative)
{
@@ -2854,10 +2875,10 @@
"reload_completed
&& (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
&& GET_MODE (operands[0]) == XFmode
- && ! (ANY_FP_REG_P (operands[0]) ||
+ && ! (ANY_FP_REG_P (operands[0]) ||
(GET_CODE (operands[0]) == SUBREG
&& ANY_FP_REG_P (SUBREG_REG (operands[0]))))
- && ! (ANY_FP_REG_P (operands[1]) ||
+ && ! (ANY_FP_REG_P (operands[1]) ||
(GET_CODE (operands[1]) == SUBREG
&& ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
[(const_int 0)]
@@ -3052,7 +3073,7 @@
[(set (match_operand:HI 0 "register_operand" "")
(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
(clobber (reg:CC FLAGS_REG))]
- "reload_completed
+ "reload_completed
&& (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
&& (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
[(set (match_operand:HI 0 "register_operand" "")
@@ -3122,7 +3143,7 @@
[(set (match_operand:SI 0 "register_operand" "")
(zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
(clobber (reg:CC FLAGS_REG))]
- "reload_completed
+ "reload_completed
&& (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
&& (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
[(set (match_dup 0)
@@ -3199,7 +3220,7 @@
[(set (match_dup 4) (const_int 0))]
"split_di (&operands[0], 1, &operands[3], &operands[4]);")
-(define_split
+(define_split
[(set (match_operand:DI 0 "register_operand" "")
(zero_extend:DI (match_operand:SI 1 "register_operand" "")))
(clobber (reg:CC FLAGS_REG))]
@@ -3208,7 +3229,7 @@
[(set (match_dup 4) (const_int 0))]
"split_di (&operands[0], 1, &operands[3], &operands[4]);")
-(define_split
+(define_split
[(set (match_operand:DI 0 "nonimmediate_operand" "")
(zero_extend:DI (match_operand:SI 1 "general_operand" "")))
(clobber (reg:CC FLAGS_REG))]
@@ -3287,7 +3308,7 @@
(set_attr "mode" "DI")])
;; Extend to memory case when source register does die.
-(define_split
+(define_split
[(set (match_operand:DI 0 "memory_operand" "")
(sign_extend:DI (match_operand:SI 1 "register_operand" "")))
(clobber (reg:CC FLAGS_REG))
@@ -3302,7 +3323,7 @@
"split_di (&operands[0], 1, &operands[3], &operands[4]);")
;; Extend to memory case when source register does not die.
-(define_split
+(define_split
[(set (match_operand:DI 0 "memory_operand" "")
(sign_extend:DI (match_operand:SI 1 "register_operand" "")))
(clobber (reg:CC FLAGS_REG))
@@ -3332,7 +3353,7 @@
;; Extend to register case. Optimize case where source and destination
;; registers match and cases where we can use cltd.
-(define_split
+(define_split
[(set (match_operand:DI 0 "register_operand" "")
(sign_extend:DI (match_operand:SI 1 "register_operand" "")))
(clobber (reg:CC FLAGS_REG))
@@ -3461,7 +3482,7 @@
;; These are all no-ops in the model used for the 80387. So just
;; emit moves.
-;; %%% Kill these when call knows how to work out a DFmode push earlier.
+;; %%% Kill these when call knows how to work out a DFmode push earlier.
(define_insn "*dummy_extendsfdf2"
[(set (match_operand:DF 0 "push_operand" "=<")
(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))]
@@ -4150,7 +4171,8 @@
"cvttss2si{q}\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "SF")
- (set_attr "athlon_decode" "double,vector")])
+ (set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")])
(define_insn "fix_truncdfdi_sse"
[(set (match_operand:DI 0 "register_operand" "=r,r")
@@ -4159,7 +4181,8 @@
"cvttsd2si{q}\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "double,vector")])
+ (set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")])
(define_insn "fix_truncsfsi_sse"
[(set (match_operand:SI 0 "register_operand" "=r,r")
@@ -4168,7 +4191,8 @@
"cvttss2si\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "double,vector")])
+ (set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")])
(define_insn "fix_truncdfsi_sse"
[(set (match_operand:SI 0 "register_operand" "=r,r")
@@ -4177,7 +4201,8 @@
"cvttsd2si\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "double,vector")])
+ (set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")])
;; Avoid vector decoded forms of the instruction.
(define_peephole2
@@ -4340,7 +4365,7 @@
(set_attr "i387_cw" "trunc")
(set_attr "mode" "DI")])
-(define_split
+(define_split
[(set (match_operand:DI 0 "register_operand" "")
(fix:DI (match_operand 1 "register_operand" "")))
(use (match_operand:HI 2 "memory_operand" ""))
@@ -4355,7 +4380,7 @@
(set (match_dup 0) (match_dup 4))]
"")
-(define_split
+(define_split
[(set (match_operand:DI 0 "memory_operand" "")
(fix:DI (match_operand 1 "register_operand" "")))
(use (match_operand:HI 2 "memory_operand" ""))
@@ -4396,7 +4421,7 @@
(set_attr "i387_cw" "trunc")
(set_attr "mode" "<MODE>")])
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "register_operand" "")
(fix:X87MODEI12 (match_operand 1 "register_operand" "")))
(use (match_operand:HI 2 "memory_operand" ""))
@@ -4409,7 +4434,7 @@
(set (match_dup 0) (match_dup 4))]
"")
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "memory_operand" "")
(fix:X87MODEI12 (match_operand 1 "register_operand" "")))
(use (match_operand:HI 2 "memory_operand" ""))
@@ -4438,7 +4463,8 @@
[(set_attr "length" "2")
(set_attr "mode" "HI")
(set_attr "unit" "i387")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "vector")])
;; Conversion between fixed point and floating point.
@@ -4489,6 +4515,7 @@
(set_attr "mode" "SF")
(set_attr "unit" "*,i387,*,*")
(set_attr "athlon_decode" "*,*,vector,double")
+ (set_attr "amdfam10_decode" "*,*,vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatsisf2_sse"
@@ -4499,6 +4526,7 @@
[(set_attr "type" "sseicvt")
(set_attr "mode" "SF")
(set_attr "athlon_decode" "vector,double")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatsisf2_i387"
@@ -4532,6 +4560,7 @@
(set_attr "mode" "SF")
(set_attr "unit" "*,i387,*,*")
(set_attr "athlon_decode" "*,*,vector,double")
+ (set_attr "amdfam10_decode" "*,*,vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatdisf2_sse"
@@ -4542,6 +4571,7 @@
[(set_attr "type" "sseicvt")
(set_attr "mode" "SF")
(set_attr "athlon_decode" "vector,double")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatdisf2_i387"
@@ -4600,6 +4630,7 @@
(set_attr "mode" "DF")
(set_attr "unit" "*,i387,*,*")
(set_attr "athlon_decode" "*,*,double,direct")
+ (set_attr "amdfam10_decode" "*,*,vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatsidf2_sse"
@@ -4610,6 +4641,7 @@
[(set_attr "type" "sseicvt")
(set_attr "mode" "DF")
(set_attr "athlon_decode" "double,direct")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatsidf2_i387"
@@ -4643,6 +4675,7 @@
(set_attr "mode" "DF")
(set_attr "unit" "*,i387,*,*")
(set_attr "athlon_decode" "*,*,double,direct")
+ (set_attr "amdfam10_decode" "*,*,vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatdidf2_sse"
@@ -4653,6 +4686,7 @@
[(set_attr "type" "sseicvt")
(set_attr "mode" "DF")
(set_attr "athlon_decode" "double,direct")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "fp_int_src" "true")])
(define_insn "*floatdidf2_i387"
@@ -4879,7 +4913,7 @@
(define_insn "*addsi3_carry_zext"
[(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI
+ (zero_extend:DI
(plus:SI (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
(match_operand:SI 1 "nonimmediate_operand" "%0"))
(match_operand:SI 2 "general_operand" "rim"))))
@@ -5188,7 +5222,7 @@
(compare
(plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
(match_operand:DI 2 "x86_64_general_operand" "rme,re"))
- (const_int 0)))
+ (const_int 0)))
(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
(plus:DI (match_dup 1) (match_dup 2)))]
"TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
@@ -5335,7 +5369,7 @@
(compare
(plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
(match_operand:DI 2 "x86_64_general_operand" "rme"))
- (const_int 0)))
+ (const_int 0)))
(clobber (match_scratch:DI 0 "=r"))]
"TARGET_64BIT
&& ix86_match_ccmode (insn, CCGOCmode)
@@ -5534,7 +5568,7 @@
(compare
(plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
(match_operand:SI 2 "general_operand" "rmni,rni"))
- (const_int 0)))
+ (const_int 0)))
(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
(plus:SI (match_dup 1) (match_dup 2)))]
"ix86_match_ccmode (insn, CCGOCmode)
@@ -5582,7 +5616,7 @@
(compare
(plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
(match_operand:SI 2 "general_operand" "rmni"))
- (const_int 0)))
+ (const_int 0)))
(set (match_operand:DI 0 "register_operand" "=r")
(zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
"TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
@@ -5760,7 +5794,7 @@
(compare
(plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
(match_operand:SI 2 "general_operand" "rmni"))
- (const_int 0)))
+ (const_int 0)))
(clobber (match_scratch:SI 0 "=r"))]
"ix86_match_ccmode (insn, CCGOCmode)
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
@@ -5900,7 +5934,7 @@
(compare
(plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
(match_operand:HI 2 "general_operand" "rmni,rni"))
- (const_int 0)))
+ (const_int 0)))
(set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
(plus:HI (match_dup 1) (match_dup 2)))]
"ix86_match_ccmode (insn, CCGOCmode)
@@ -6020,7 +6054,7 @@
(compare
(plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
(match_operand:HI 2 "general_operand" "rmni"))
- (const_int 0)))
+ (const_int 0)))
(clobber (match_scratch:HI 0 "=r"))]
"ix86_match_ccmode (insn, CCGOCmode)
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
@@ -6860,6 +6894,14 @@
"TARGET_64BIT"
"")
+;; On AMDFAM10
+;; IMUL reg64, reg64, imm8 Direct
+;; IMUL reg64, mem64, imm8 VectorPath
+;; IMUL reg64, reg64, imm32 Direct
+;; IMUL reg64, mem64, imm32 VectorPath
+;; IMUL reg64, reg64 Direct
+;; IMUL reg64, mem64 Direct
+
(define_insn "*muldi3_1_rex64"
[(set (match_operand:DI 0 "register_operand" "=r,r,r")
(mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,rm,0")
@@ -6882,6 +6924,11 @@
(match_operand 1 "memory_operand" ""))
(const_string "vector")]
(const_string "direct")))
+ (set (attr "amdfam10_decode")
+ (cond [(and (eq_attr "alternative" "0,1")
+ (match_operand 1 "memory_operand" ""))
+ (const_string "vector")]
+ (const_string "direct")))
(set_attr "mode" "DI")])
(define_expand "mulsi3"
@@ -6892,6 +6939,14 @@
""
"")
+;; On AMDFAM10
+;; IMUL reg32, reg32, imm8 Direct
+;; IMUL reg32, mem32, imm8 VectorPath
+;; IMUL reg32, reg32, imm32 Direct
+;; IMUL reg32, mem32, imm32 VectorPath
+;; IMUL reg32, reg32 Direct
+;; IMUL reg32, mem32 Direct
+
(define_insn "*mulsi3_1"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,rm,0")
@@ -6913,6 +6968,11 @@
(match_operand 1 "memory_operand" ""))
(const_string "vector")]
(const_string "direct")))
+ (set (attr "amdfam10_decode")
+ (cond [(and (eq_attr "alternative" "0,1")
+ (match_operand 1 "memory_operand" ""))
+ (const_string "vector")]
+ (const_string "direct")))
(set_attr "mode" "SI")])
(define_insn "*mulsi3_1_zext"
@@ -6938,6 +6998,11 @@
(match_operand 1 "memory_operand" ""))
(const_string "vector")]
(const_string "direct")))
+ (set (attr "amdfam10_decode")
+ (cond [(and (eq_attr "alternative" "0,1")
+ (match_operand 1 "memory_operand" ""))
+ (const_string "vector")]
+ (const_string "direct")))
(set_attr "mode" "SI")])
(define_expand "mulhi3"
@@ -6948,6 +7013,13 @@
"TARGET_HIMODE_MATH"
"")
+;; On AMDFAM10
+;; IMUL reg16, reg16, imm8 VectorPath
+;; IMUL reg16, mem16, imm8 VectorPath
+;; IMUL reg16, reg16, imm16 VectorPath
+;; IMUL reg16, mem16, imm16 VectorPath
+;; IMUL reg16, reg16 Direct
+;; IMUL reg16, mem16 Direct
(define_insn "*mulhi3_1"
[(set (match_operand:HI 0 "register_operand" "=r,r,r")
(mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,rm,0")
@@ -6966,6 +7038,10 @@
(eq_attr "alternative" "1,2")
(const_string "vector")]
(const_string "direct")))
+ (set (attr "amdfam10_decode")
+ (cond [(eq_attr "alternative" "0,1")
+ (const_string "vector")]
+ (const_string "direct")))
(set_attr "mode" "HI")])
(define_expand "mulqi3"
@@ -6976,6 +7052,10 @@
"TARGET_QIMODE_MATH"
"")
+;;On AMDFAM10
+;; MUL reg8 Direct
+;; MUL mem8 Direct
+
(define_insn "*mulqi3_1"
[(set (match_operand:QI 0 "register_operand" "=a")
(mult:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
@@ -6990,6 +7070,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "direct")))
+ (set_attr "amdfam10_decode" "direct")
(set_attr "mode" "QI")])
(define_expand "umulqihi3"
@@ -7016,6 +7097,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "direct")))
+ (set_attr "amdfam10_decode" "direct")
(set_attr "mode" "QI")])
(define_expand "mulqihi3"
@@ -7040,6 +7122,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "direct")))
+ (set_attr "amdfam10_decode" "direct")
(set_attr "mode" "QI")])
(define_expand "umulditi3"
@@ -7066,6 +7149,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "DI")])
;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers
@@ -7093,6 +7177,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "SI")])
(define_expand "mulditi3"
@@ -7119,6 +7204,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "DI")])
(define_expand "mulsidi3"
@@ -7145,6 +7231,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "SI")])
(define_expand "umuldi3_highpart"
@@ -7181,6 +7268,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "DI")])
(define_expand "umulsi3_highpart"
@@ -7216,6 +7304,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "SI")])
(define_insn "*umulsi3_highpart_zext"
@@ -7238,6 +7327,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "SI")])
(define_expand "smuldi3_highpart"
@@ -7273,6 +7363,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "DI")])
(define_expand "smulsi3_highpart"
@@ -7307,6 +7398,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "SI")])
(define_insn "*smulsi3_highpart_zext"
@@ -7328,6 +7420,7 @@
(if_then_else (eq_attr "cpu" "athlon")
(const_string "vector")
(const_string "double")))
+ (set_attr "amdfam10_decode" "double")
(set_attr "mode" "SI")])
;; The patterns that match these are at the end of this file.
@@ -7390,7 +7483,7 @@
(match_operand:DF 2 "nonimmediate_operand" "")))]
"TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
"")
-
+
(define_expand "divsf3"
[(set (match_operand:SF 0 "register_operand" "")
(div:SF (match_operand:SF 1 "register_operand" "")
@@ -8068,7 +8161,7 @@
gcc_assert (INTVAL (operands[2]) == 0xffff);
mode = HImode;
}
-
+
operands[1] = gen_lowpart (mode, operands[1]);
if (mode == QImode)
return "movz{bq|x}\t{%1,%0|%0, %1}";
@@ -8133,7 +8226,7 @@
gcc_assert (INTVAL (operands[2]) == 0xffff);
mode = HImode;
}
-
+
operands[1] = gen_lowpart (mode, operands[1]);
if (mode == QImode)
return "movz{bl|x}\t{%1,%0|%0, %1}";
@@ -8177,7 +8270,7 @@
[(parallel [(set (zero_extract:SI (match_dup 0)
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI (match_dup 0)
(const_int 8)
(const_int 8))
@@ -8365,7 +8458,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (and:SI
+ (and:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -8394,7 +8487,7 @@
(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (and:SI
+ (and:SI
(zero_extract:SI
(match_dup 1)
(const_int 8)
@@ -8410,7 +8503,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (and:SI
+ (and:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -8428,7 +8521,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (and:SI
+ (and:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -8771,7 +8864,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (ior:SI
+ (ior:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -8788,7 +8881,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (ior:SI
+ (ior:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -8807,7 +8900,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (ior:SI
+ (ior:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -8826,7 +8919,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (ior:SI
+ (ior:SI
(zero_extract:SI (match_operand 1 "ext_register_operand" "0")
(const_int 8)
(const_int 8))
@@ -9109,7 +9202,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -9126,7 +9219,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -9145,7 +9238,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI
(match_operand 1 "ext_register_operand" "0")
(const_int 8)
@@ -9164,7 +9257,7 @@
[(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI (match_operand 1 "ext_register_operand" "0")
(const_int 8)
(const_int 8))
@@ -9232,7 +9325,7 @@
(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
(match_dup 2)))]
"!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
@@ -9253,7 +9346,7 @@
(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
(match_dup 2)))]
"TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
@@ -9275,7 +9368,7 @@
(set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
(const_int 8)
(const_int 8))
- (xor:SI
+ (xor:SI
(zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
(match_dup 2)))])]
""
@@ -9774,7 +9867,7 @@
enum machine_mode mode = GET_MODE (operands[0]);
enum machine_mode vmode = GET_MODE (operands[2]);
rtx tmp;
-
+
operands[0] = simplify_gen_subreg (vmode, operands[0], mode, 0);
operands[1] = simplify_gen_subreg (vmode, operands[1], mode, 0);
if (operands_match_p (operands[0], operands[2]))
@@ -9798,7 +9891,7 @@
"reload_completed"
[(parallel [(set (match_dup 0) (match_dup 1))
(clobber (reg:CC FLAGS_REG))])]
-{
+{
rtx tmp;
operands[0] = gen_lowpart (SImode, operands[0]);
if (GET_CODE (operands[1]) == ABS)
@@ -9905,7 +9998,7 @@
operands[1] = tmp;
})
-;; Conditionalize these after reload. If they match before reload, we
+;; Conditionalize these after reload. If they match before reload, we
;; lose the clobber and ability to use integer instructions.
(define_insn "*negsf2_1"
@@ -10309,7 +10402,8 @@
[(set_attr "type" "ishift")
(set_attr "prefix_0f" "1")
(set_attr "mode" "DI")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "vector")])
(define_expand "x86_64_shift_adj"
[(set (reg:CCZ FLAGS_REG)
@@ -10524,7 +10618,8 @@
(set_attr "prefix_0f" "1")
(set_attr "mode" "SI")
(set_attr "pent_pair" "np")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "vector")])
(define_expand "x86_shift_adj_1"
[(set (reg:CCZ FLAGS_REG)
@@ -11284,7 +11379,8 @@
[(set_attr "type" "ishift")
(set_attr "prefix_0f" "1")
(set_attr "mode" "DI")
- (set_attr "athlon_decode" "vector")])
+ (set_attr "athlon_decode" "vector")
+ (set_attr "amdfam10_decode" "vector")])
(define_expand "ashrdi3"
[(set (match_operand:DI 0 "shiftdi_operand" "")
@@ -11319,8 +11415,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"sar{q}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:DI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:DI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11352,8 +11448,8 @@
&& ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
"sar{q}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:DI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:DI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11532,8 +11628,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"sar{l}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11588,8 +11684,8 @@
&& ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
"sar{l}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11689,8 +11785,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"sar{w}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11722,8 +11818,8 @@
&& ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
"sar{w}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11792,8 +11888,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"sar{b}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11807,8 +11903,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"sar{b}\t%0"
[(set_attr "type" "ishift1")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11853,8 +11949,8 @@
&& ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
"sar{b}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -11946,7 +12042,7 @@
"#"
[(set_attr "type" "multi")])
-(define_split
+(define_split
[(set (match_operand:TI 0 "register_operand" "")
(lshiftrt:TI (match_operand:TI 1 "register_operand" "")
(match_operand:QI 2 "register_operand" "")))
@@ -11956,7 +12052,7 @@
[(const_int 0)]
"ix86_split_lshr (operands, operands[3], TImode); DONE;")
-(define_split
+(define_split
[(set (match_operand:TI 0 "register_operand" "")
(lshiftrt:TI (match_operand:TI 1 "register_operand" "")
(match_operand:QI 2 "immediate_operand" "")))
@@ -11981,8 +12077,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"shr{q}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:DI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:DI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12014,8 +12110,8 @@
&& ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
"shr{q}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:DI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:DI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12090,7 +12186,7 @@
[(const_int 0)]
"ix86_split_lshr (operands, operands[3], DImode); DONE;")
-(define_split
+(define_split
[(set (match_operand:DI 0 "register_operand" "")
(lshiftrt:DI (match_operand:DI 1 "register_operand" "")
(match_operand:QI 2 "nonmemory_operand" "")))
@@ -12117,8 +12213,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"shr{l}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12174,8 +12270,8 @@
&& ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
"shr{l}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12275,8 +12371,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"shr{w}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12308,8 +12404,8 @@
&& ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
"shr{w}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12378,8 +12474,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"shr{b}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12392,8 +12488,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"shr{b}\t%0"
[(set_attr "type" "ishift1")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12438,8 +12534,8 @@
&& ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
"shr{b}\t%0"
[(set_attr "type" "ishift")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12512,7 +12608,7 @@
})
;; Implement rotation using two double-precision shift instructions
-;; and a scratch register.
+;; and a scratch register.
(define_insn_and_split "ix86_rotldi3"
[(set (match_operand:DI 0 "register_operand" "=r")
(rotate:DI (match_operand:DI 1 "register_operand" "0")
@@ -12520,7 +12616,7 @@
(clobber (reg:CC FLAGS_REG))
(clobber (match_scratch:SI 3 "=&r"))]
"!TARGET_64BIT"
- ""
+ ""
"&& reload_completed"
[(set (match_dup 3) (match_dup 4))
(parallel
@@ -12536,7 +12632,7 @@
(minus:QI (const_int 32) (match_dup 2)))))
(clobber (reg:CC FLAGS_REG))])]
"split_di (operands, 1, operands + 4, operands + 5);")
-
+
(define_insn "*rotlsi3_1_one_bit_rex64"
[(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
(rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0")
@@ -12546,8 +12642,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"rol{q}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand:DI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:DI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12580,8 +12676,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"rol{l}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12639,8 +12735,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"rol{w}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12673,8 +12769,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"rol{b}\t%0"
[(set_attr "type" "rotate1")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12687,8 +12783,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"rol{b}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12734,9 +12830,9 @@
emit_insn (gen_ix86_rotrdi3 (operands[0], operands[1], operands[2]));
DONE;
})
-
+
;; Implement rotation using two double-precision shift instructions
-;; and a scratch register.
+;; and a scratch register.
(define_insn_and_split "ix86_rotrdi3"
[(set (match_operand:DI 0 "register_operand" "=r")
(rotatert:DI (match_operand:DI 1 "register_operand" "0")
@@ -12770,8 +12866,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"ror{q}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand:DI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:DI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12804,8 +12900,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"ror{l}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12819,8 +12915,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"ror{l}\t%k0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand:SI 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand:SI 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12866,8 +12962,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"ror{w}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12900,8 +12996,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"ror{b}\t%0"
[(set_attr "type" "rotate")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -12914,8 +13010,8 @@
&& (TARGET_SHIFT1 || optimize_size)"
"ror{b}\t%0"
[(set_attr "type" "rotate1")
- (set (attr "length")
- (if_then_else (match_operand 0 "register_operand" "")
+ (set (attr "length")
+ (if_then_else (match_operand 0 "register_operand" "")
(const_string "2")
(const_string "*")))])
@@ -13282,7 +13378,7 @@
(set_attr "mode" "QI")])
;; In general it is not safe to assume too much about CCmode registers,
-;; so simplify-rtx stops when it sees a second one. Under certain
+;; so simplify-rtx stops when it sees a second one. Under certain
;; conditions this is safe on x86, so help combine not create
;;
;; seta %al
@@ -13289,7 +13385,7 @@
;; testb %al, %al
;; sete %al
-(define_split
+(define_split
[(set (match_operand:QI 0 "nonimmediate_operand" "")
(ne:QI (match_operator 1 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
@@ -13300,7 +13396,7 @@
PUT_MODE (operands[1], QImode);
})
-(define_split
+(define_split
[(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
(ne:QI (match_operator 1 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
@@ -13311,7 +13407,7 @@
PUT_MODE (operands[1], QImode);
})
-(define_split
+(define_split
[(set (match_operand:QI 0 "nonimmediate_operand" "")
(eq:QI (match_operator 1 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
@@ -13331,7 +13427,7 @@
FAIL;
})
-(define_split
+(define_split
[(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
(eq:QI (match_operator 1 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
@@ -13563,7 +13659,7 @@
(const_int 6)))])
;; In general it is not safe to assume too much about CCmode registers,
-;; so simplify-rtx stops when it sees a second one. Under certain
+;; so simplify-rtx stops when it sees a second one. Under certain
;; conditions this is safe on x86, so help combine not create
;;
;; seta %al
@@ -13570,7 +13666,7 @@
;; testb %al, %al
;; je Lfoo
-(define_split
+(define_split
[(set (pc)
(if_then_else (ne (match_operator 0 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
@@ -13585,8 +13681,8 @@
{
PUT_MODE (operands[0], VOIDmode);
})
-
-(define_split
+
+(define_split
[(set (pc)
(if_then_else (eq (match_operator 0 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
@@ -14061,7 +14157,7 @@
return "call\t%P0";
}
[(set_attr "type" "call")])
-
+
(define_insn "*call_pop_1"
[(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
(match_operand:SI 1 "" ""))
@@ -14397,7 +14493,7 @@
})
(define_insn_and_split "eh_return_si"
- [(set (pc)
+ [(set (pc)
(unspec [(match_operand:SI 0 "register_operand" "c")]
UNSPEC_EH_RETURN))]
"!TARGET_64BIT"
@@ -14407,7 +14503,7 @@
"ix86_expand_epilogue (2); DONE;")
(define_insn_and_split "eh_return_di"
- [(set (pc)
+ [(set (pc)
(unspec [(match_operand:DI 0 "register_operand" "c")]
UNSPEC_EH_RETURN))]
"TARGET_64BIT"
@@ -14434,7 +14530,7 @@
(define_expand "ffssi2"
[(parallel
- [(set (match_operand:SI 0 "register_operand" "")
+ [(set (match_operand:SI 0 "register_operand" "")
(ffs:SI (match_operand:SI 1 "nonimmediate_operand" "")))
(clobber (match_scratch:SI 2 ""))
(clobber (reg:CC FLAGS_REG))])]
@@ -14442,7 +14538,7 @@
"")
(define_insn_and_split "*ffs_cmove"
- [(set (match_operand:SI 0 "register_operand" "=r")
+ [(set (match_operand:SI 0 "register_operand" "=r")
(ffs:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
(clobber (match_scratch:SI 2 "=&r"))
(clobber (reg:CC FLAGS_REG))]
@@ -14461,7 +14557,7 @@
"")
(define_insn_and_split "*ffs_no_cmove"
- [(set (match_operand:SI 0 "nonimmediate_operand" "=r")
+ [(set (match_operand:SI 0 "nonimmediate_operand" "=r")
(ffs:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
(clobber (match_scratch:SI 2 "=&q"))
(clobber (reg:CC FLAGS_REG))]
@@ -14495,7 +14591,7 @@
(define_expand "ffsdi2"
[(parallel
- [(set (match_operand:DI 0 "register_operand" "")
+ [(set (match_operand:DI 0 "register_operand" "")
(ffs:DI (match_operand:DI 1 "nonimmediate_operand" "")))
(clobber (match_scratch:DI 2 ""))
(clobber (reg:CC FLAGS_REG))])]
@@ -14503,7 +14599,7 @@
"")
(define_insn_and_split "*ffs_rex64"
- [(set (match_operand:DI 0 "register_operand" "=r")
+ [(set (match_operand:DI 0 "register_operand" "=r")
(ffs:DI (match_operand:DI 1 "nonimmediate_operand" "rm")))
(clobber (match_scratch:DI 2 "=&r"))
(clobber (reg:CC FLAGS_REG))]
@@ -14558,8 +14654,24 @@
[(set (match_dup 0) (xor:SI (match_dup 0) (const_int 31)))
(clobber (reg:CC FLAGS_REG))])]
""
- "")
+{
+ if (TARGET_ABM)
+ {
+ emit_insn (gen_clzsi2_abm (operands[0], operands[1]));
+ DONE;
+ }
+})
+(define_insn "clzsi2_abm"
+ [(set (match_operand:SI 0 "register_operand" "=r")
+ (clz:SI (match_operand:SI 1 "nonimmediate_operand" "")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_ABM"
+ "lzcnt{l}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "SI")])
+
(define_insn "*bsr"
[(set (match_operand:SI 0 "register_operand" "=r")
(minus:SI (const_int 31)
@@ -14567,8 +14679,63 @@
(clobber (reg:CC FLAGS_REG))]
""
"bsr{l}\t{%1, %0|%0, %1}"
- [(set_attr "prefix_0f" "1")])
+ [(set_attr "prefix_0f" "1")
+ (set_attr "mode" "SI")])
+(define_insn "popcountsi2"
+ [(set (match_operand:SI 0 "register_operand" "=r")
+ (popcount:SI (match_operand:SI 1 "nonimmediate_operand" "")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_POPCNT"
+ "popcnt{l}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "SI")])
+
+(define_insn "*popcountsi2_cmp"
+ [(set (reg FLAGS_REG)
+ (compare
+ (popcount:SI (match_operand:SI 1 "nonimmediate_operand" "rm"))
+ (const_int 0)))
+ (set (match_operand:SI 0 "register_operand" "=r")
+ (popcount:SI (match_dup 1)))]
+ "TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
+ "popcnt{l}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "SI")])
+
+(define_insn "*popcountsi2_cmp_zext"
+ [(set (reg FLAGS_REG)
+ (compare
+ (popcount:SI (match_operand:SI 1 "nonimmediate_operand" "rm"))
+ (const_int 0)))
+ (set (match_operand:DI 0 "register_operand" "=r")
+ (zero_extend:DI(popcount:SI (match_dup 1))))]
+ "TARGET_64BIT && TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
+ "popcnt{l}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "SI")])
+
+(define_insn "bswapsi2"
+ [(set (match_operand:SI 0 "register_operand" "=r")
+ (bswap:SI (match_operand:SI 1 "register_operand" "0")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_BSWAP"
+ "bswap\t%k0"
+ [(set_attr "prefix_0f" "1")
+ (set_attr "length" "2")])
+
+(define_insn "bswapdi2"
+ [(set (match_operand:DI 0 "register_operand" "=r")
+ (bswap:DI (match_operand:DI 1 "register_operand" "0")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_64BIT && TARGET_BSWAP"
+ "bswap\t%0"
+ [(set_attr "prefix_0f" "1")
+ (set_attr "length" "3")])
+
(define_expand "clzdi2"
[(parallel
[(set (match_operand:DI 0 "register_operand" "")
@@ -14579,8 +14746,24 @@
[(set (match_dup 0) (xor:DI (match_dup 0) (const_int 63)))
(clobber (reg:CC FLAGS_REG))])]
"TARGET_64BIT"
- "")
+{
+ if (TARGET_ABM)
+ {
+ emit_insn (gen_clzdi2_abm (operands[0], operands[1]));
+ DONE;
+ }
+})
+(define_insn "clzdi2_abm"
+ [(set (match_operand:DI 0 "register_operand" "=r")
+ (clz:DI (match_operand:DI 1 "nonimmediate_operand" "")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_64BIT && TARGET_ABM"
+ "lzcnt{q}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "DI")])
+
(define_insn "*bsr_rex64"
[(set (match_operand:DI 0 "register_operand" "=r")
(minus:DI (const_int 63)
@@ -14588,7 +14771,92 @@
(clobber (reg:CC FLAGS_REG))]
"TARGET_64BIT"
"bsr{q}\t{%1, %0|%0, %1}"
- [(set_attr "prefix_0f" "1")])
+ [(set_attr "prefix_0f" "1")
+ (set_attr "mode" "DI")])
+
+(define_insn "popcountdi2"
+ [(set (match_operand:DI 0 "register_operand" "=r")
+ (popcount:DI (match_operand:DI 1 "nonimmediate_operand" "")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_64BIT && TARGET_POPCNT"
+ "popcnt{q}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "DI")])
+
+(define_insn "*popcountdi2_cmp"
+ [(set (reg FLAGS_REG)
+ (compare
+ (popcount:DI (match_operand:DI 1 "nonimmediate_operand" "rm"))
+ (const_int 0)))
+ (set (match_operand:DI 0 "register_operand" "=r")
+ (popcount:DI (match_dup 1)))]
+ "TARGET_64BIT && TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
+ "popcnt{q}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "DI")])
+
+(define_expand "clzhi2"
+ [(parallel
+ [(set (match_operand:HI 0 "register_operand" "")
+ (minus:HI (const_int 15)
+ (clz:HI (match_operand:HI 1 "nonimmediate_operand" ""))))
+ (clobber (reg:CC FLAGS_REG))])
+ (parallel
+ [(set (match_dup 0) (xor:HI (match_dup 0) (const_int 15)))
+ (clobber (reg:CC FLAGS_REG))])]
+ ""
+{
+ if (TARGET_ABM)
+ {
+ emit_insn (gen_clzhi2_abm (operands[0], operands[1]));
+ DONE;
+ }
+})
+
+(define_insn "clzhi2_abm"
+ [(set (match_operand:HI 0 "register_operand" "=r")
+ (clz:HI (match_operand:HI 1 "nonimmediate_operand" "")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_ABM"
+ "lzcnt{w}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "HI")])
+
+(define_insn "*bsrhi"
+ [(set (match_operand:HI 0 "register_operand" "=r")
+ (minus:HI (const_int 15)
+ (clz:HI (match_operand:HI 1 "nonimmediate_operand" "rm"))))
+ (clobber (reg:CC FLAGS_REG))]
+ ""
+ "bsr{w}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_0f" "1")
+ (set_attr "mode" "HI")])
+
+(define_insn "popcounthi2"
+ [(set (match_operand:HI 0 "register_operand" "=r")
+ (popcount:HI (match_operand:HI 1 "nonimmediate_operand" "")))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_POPCNT"
+ "popcnt{w}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "HI")])
+
+(define_insn "*popcounthi2_cmp"
+ [(set (reg FLAGS_REG)
+ (compare
+ (popcount:HI (match_operand:HI 1 "nonimmediate_operand" "rm"))
+ (const_int 0)))
+ (set (match_operand:HI 0 "register_operand" "=r")
+ (popcount:HI (match_dup 1)))]
+ "TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
+ "popcnt{w}\t{%1, %0|%0, %1}"
+ [(set_attr "prefix_rep" "1")
+ (set_attr "type" "bitmanip")
+ (set_attr "mode" "HI")])
;; Thread-local storage patterns for ELF.
;;
@@ -14981,12 +15249,12 @@
&& COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
+ [(set (attr "type")
(if_then_else (eq_attr "alternative" "1")
- (if_then_else (match_operand:SF 3 "mult_operator" "")
+ (if_then_else (match_operand:SF 3 "mult_operator" "")
(const_string "ssemul")
(const_string "sseadd"))
- (if_then_else (match_operand:SF 3 "mult_operator" "")
+ (if_then_else (match_operand:SF 3 "mult_operator" "")
(const_string "fmul")
(const_string "fop"))))
(set_attr "mode" "SF")])
@@ -15000,8 +15268,8 @@
&& COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (if_then_else (match_operand:SF 3 "mult_operator" "")
+ [(set (attr "type")
+ (if_then_else (match_operand:SF 3 "mult_operator" "")
(const_string "ssemul")
(const_string "sseadd")))
(set_attr "mode" "SF")])
@@ -15015,8 +15283,8 @@
&& COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (if_then_else (match_operand:SF 3 "mult_operator" "")
+ [(set (attr "type")
+ (if_then_else (match_operand:SF 3 "mult_operator" "")
(const_string "fmul")
(const_string "fop")))
(set_attr "mode" "SF")])
@@ -15030,7 +15298,7 @@
&& !COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
+ [(set (attr "type")
(cond [(and (eq_attr "alternative" "2")
(match_operand:SF 3 "mult_operator" ""))
(const_string "ssemul")
@@ -15039,9 +15307,9 @@
(const_string "ssediv")
(eq_attr "alternative" "2")
(const_string "sseadd")
- (match_operand:SF 3 "mult_operator" "")
+ (match_operand:SF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:SF 3 "div_operator" "")
+ (match_operand:SF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15055,7 +15323,7 @@
"TARGET_SSE_MATH
&& !COMMUTATIVE_ARITH_P (operands[3])"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
+ [(set (attr "type")
(cond [(match_operand:SF 3 "mult_operator" "")
(const_string "ssemul")
(match_operand:SF 3 "div_operator" "")
@@ -15074,10 +15342,10 @@
&& !COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:SF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:SF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:SF 3 "div_operator" "")
+ (match_operand:SF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15091,10 +15359,10 @@
(match_operand:SF 2 "register_operand" "0,0")]))]
"TARGET_80387 && TARGET_USE_<MODE>MODE_FIOP && !TARGET_SSE_MATH"
"* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:SF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:SF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:SF 3 "div_operator" "")
+ (match_operand:SF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15108,10 +15376,10 @@
(float:SF (match_operand:X87MODEI12 2 "nonimmediate_operand" "m,?r"))]))]
"TARGET_80387 && TARGET_USE_<MODE>MODE_FIOP && !TARGET_SSE_MATH"
"* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:SF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:SF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:SF 3 "div_operator" "")
+ (match_operand:SF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15127,12 +15395,12 @@
&& COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
+ [(set (attr "type")
(if_then_else (eq_attr "alternative" "1")
- (if_then_else (match_operand:DF 3 "mult_operator" "")
+ (if_then_else (match_operand:DF 3 "mult_operator" "")
(const_string "ssemul")
(const_string "sseadd"))
- (if_then_else (match_operand:DF 3 "mult_operator" "")
+ (if_then_else (match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
(const_string "fop"))))
(set_attr "mode" "DF")])
@@ -15146,8 +15414,8 @@
&& COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (if_then_else (match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (if_then_else (match_operand:DF 3 "mult_operator" "")
(const_string "ssemul")
(const_string "sseadd")))
(set_attr "mode" "DF")])
@@ -15161,8 +15429,8 @@
&& COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (if_then_else (match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (if_then_else (match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
(const_string "fop")))
(set_attr "mode" "DF")])
@@ -15176,7 +15444,7 @@
&& !COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
+ [(set (attr "type")
(cond [(and (eq_attr "alternative" "2")
(match_operand:DF 3 "mult_operator" ""))
(const_string "ssemul")
@@ -15185,9 +15453,9 @@
(const_string "ssediv")
(eq_attr "alternative" "2")
(const_string "sseadd")
- (match_operand:DF 3 "mult_operator" "")
+ (match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:DF 3 "div_operator" "")
+ (match_operand:DF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15202,7 +15470,7 @@
&& !COMMUTATIVE_ARITH_P (operands[3])"
"* return output_387_binary_op (insn, operands);"
[(set_attr "mode" "DF")
- (set (attr "type")
+ (set (attr "type")
(cond [(match_operand:DF 3 "mult_operator" "")
(const_string "ssemul")
(match_operand:DF 3 "div_operator" "")
@@ -15220,8 +15488,8 @@
&& !COMMUTATIVE_ARITH_P (operands[3])
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
(match_operand:DF 3 "div_operator" "")
(const_string "fdiv")
@@ -15238,10 +15506,10 @@
"TARGET_80387 && TARGET_USE_<MODE>MODE_FIOP
&& !(TARGET_SSE2 && TARGET_SSE_MATH)"
"* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:DF 3 "div_operator" "")
+ (match_operand:DF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15256,10 +15524,10 @@
"TARGET_80387 && TARGET_USE_<MODE>MODE_FIOP
&& !(TARGET_SSE2 && TARGET_SSE_MATH)"
"* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:DF 3 "div_operator" "")
+ (match_operand:DF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15274,10 +15542,10 @@
"TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)
&& (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:DF 3 "div_operator" "")
+ (match_operand:DF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15291,10 +15559,10 @@
(match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
"TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:DF 3 "div_operator" "")
+ (match_operand:DF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15309,10 +15577,10 @@
(match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
"TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:DF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:DF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:DF 3 "div_operator" "")
+ (match_operand:DF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15326,8 +15594,8 @@
"TARGET_80387
&& COMMUTATIVE_ARITH_P (operands[3])"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (if_then_else (match_operand:XF 3 "mult_operator" "")
+ [(set (attr "type")
+ (if_then_else (match_operand:XF 3 "mult_operator" "")
(const_string "fmul")
(const_string "fop")))
(set_attr "mode" "XF")])
@@ -15340,10 +15608,10 @@
"TARGET_80387
&& !COMMUTATIVE_ARITH_P (operands[3])"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:XF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:XF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:XF 3 "div_operator" "")
+ (match_operand:XF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15356,10 +15624,10 @@
(match_operand:XF 2 "register_operand" "0,0")]))]
"TARGET_80387 && TARGET_USE_<MODE>MODE_FIOP"
"* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:XF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:XF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:XF 3 "div_operator" "")
+ (match_operand:XF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15373,10 +15641,10 @@
(float:XF (match_operand:X87MODEI12 2 "nonimmediate_operand" "m,?r"))]))]
"TARGET_80387 && TARGET_USE_<MODE>MODE_FIOP"
"* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:XF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:XF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:XF 3 "div_operator" "")
+ (match_operand:XF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15390,10 +15658,10 @@
(match_operand:XF 2 "register_operand" "0,f")]))]
"TARGET_80387"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:XF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:XF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:XF 3 "div_operator" "")
+ (match_operand:XF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15407,10 +15675,10 @@
(match_operand 2 "nonimmediate_operand" "fm,0"))]))]
"TARGET_80387"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:XF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:XF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:XF 3 "div_operator" "")
+ (match_operand:XF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15425,10 +15693,10 @@
(match_operand 2 "nonimmediate_operand" "fm,0"))]))]
"TARGET_80387"
"* return output_387_binary_op (insn, operands);"
- [(set (attr "type")
- (cond [(match_operand:XF 3 "mult_operator" "")
+ [(set (attr "type")
+ (cond [(match_operand:XF 3 "mult_operator" "")
(const_string "fmul")
- (match_operand:XF 3 "div_operator" "")
+ (match_operand:XF 3 "div_operator" "")
(const_string "fdiv")
]
(const_string "fop")))
@@ -15442,7 +15710,7 @@
"TARGET_80387 && reload_completed
&& FLOAT_MODE_P (GET_MODE (operands[0]))"
[(const_int 0)]
-{
+{
operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
emit_insn (gen_rtx_SET (VOIDmode, operands[0],
@@ -15494,7 +15762,8 @@
sqrtss\t{%1, %0|%0, %1}"
[(set_attr "type" "fpspc,sse")
(set_attr "mode" "SF,SF")
- (set_attr "athlon_decode" "direct,*")])
+ (set_attr "athlon_decode" "direct,*")
+ (set_attr "amdfam10_decode" "direct,*")])
(define_insn "*sqrtsf2_sse"
[(set (match_operand:SF 0 "register_operand" "=x")
@@ -15503,7 +15772,8 @@
"sqrtss\t{%1, %0|%0, %1}"
[(set_attr "type" "sse")
(set_attr "mode" "SF")
- (set_attr "athlon_decode" "*")])
+ (set_attr "athlon_decode" "*")
+ (set_attr "amdfam10_decode" "*")])
(define_insn "*sqrtsf2_i387"
[(set (match_operand:SF 0 "register_operand" "=f")
@@ -15512,7 +15782,8 @@
"fsqrt"
[(set_attr "type" "fpspc")
(set_attr "mode" "SF")
- (set_attr "athlon_decode" "direct")])
+ (set_attr "athlon_decode" "direct")
+ (set_attr "amdfam10_decode" "direct")])
(define_expand "sqrtdf2"
[(set (match_operand:DF 0 "register_operand" "")
@@ -15532,7 +15803,8 @@
sqrtsd\t{%1, %0|%0, %1}"
[(set_attr "type" "fpspc,sse")
(set_attr "mode" "DF,DF")
- (set_attr "athlon_decode" "direct,*")])
+ (set_attr "athlon_decode" "direct,*")
+ (set_attr "amdfam10_decode" "direct,*")])
(define_insn "*sqrtdf2_sse"
[(set (match_operand:DF 0 "register_operand" "=Y")
@@ -15541,7 +15813,8 @@
"sqrtsd\t{%1, %0|%0, %1}"
[(set_attr "type" "sse")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "*")])
+ (set_attr "athlon_decode" "*")
+ (set_attr "amdfam10_decode" "*")])
(define_insn "*sqrtdf2_i387"
[(set (match_operand:DF 0 "register_operand" "=f")
@@ -15550,7 +15823,8 @@
"fsqrt"
[(set_attr "type" "fpspc")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "direct")])
+ (set_attr "athlon_decode" "direct")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*sqrtextendsfdf2_i387"
[(set (match_operand:DF 0 "register_operand" "=f")
@@ -15561,7 +15835,8 @@
"fsqrt"
[(set_attr "type" "fpspc")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "direct")])
+ (set_attr "athlon_decode" "direct")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "sqrtxf2"
[(set (match_operand:XF 0 "register_operand" "=f")
@@ -15570,7 +15845,8 @@
"fsqrt"
[(set_attr "type" "fpspc")
(set_attr "mode" "XF")
- (set_attr "athlon_decode" "direct")])
+ (set_attr "athlon_decode" "direct")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*sqrtextendsfxf2_i387"
[(set (match_operand:XF 0 "register_operand" "=f")
@@ -15580,7 +15856,8 @@
"fsqrt"
[(set_attr "type" "fpspc")
(set_attr "mode" "XF")
- (set_attr "athlon_decode" "direct")])
+ (set_attr "athlon_decode" "direct")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "*sqrtextenddfxf2_i387"
[(set (match_operand:XF 0 "register_operand" "=f")
@@ -15590,7 +15867,8 @@
"fsqrt"
[(set_attr "type" "fpspc")
(set_attr "mode" "XF")
- (set_attr "athlon_decode" "direct")])
+ (set_attr "athlon_decode" "direct")
+ (set_attr "amdfam10_decode" "direct")])
(define_insn "fpremxf4"
[(set (match_operand:XF 0 "register_operand" "=f")
@@ -15845,7 +16123,7 @@
(set_attr "mode" "XF")])
;; With sincos pattern defined, sin and cos builtin function will be
-;; expanded to sincos pattern with one of its outputs left unused.
+;; expanded to sincos pattern with one of its outputs left unused.
;; Cse pass will detected, if two sincos patterns can be combined,
;; otherwise sincos pattern will be split back to sin or cos pattern,
;; depending on the unused output.
@@ -17247,7 +17525,7 @@
[(set_attr "type" "fpspc")
(set_attr "mode" "DI")])
-(define_split
+(define_split
[(set (match_operand:DI 0 "register_operand" "")
(unspec:DI [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST))
@@ -17259,7 +17537,7 @@
(set (match_dup 0) (match_dup 2))]
"")
-(define_split
+(define_split
[(set (match_operand:DI 0 "memory_operand" "")
(unspec:DI [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST))
@@ -17310,7 +17588,7 @@
[(set_attr "type" "fpspc")
(set_attr "mode" "<MODE>")])
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "register_operand" "")
(unspec:X87MODEI12 [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST))
@@ -17321,7 +17599,7 @@
(set (match_dup 0) (match_dup 2))]
"")
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "memory_operand" "")
(unspec:X87MODEI12 [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST))
@@ -17484,7 +17762,7 @@
(set_attr "i387_cw" "floor")
(set_attr "mode" "DI")])
-(define_split
+(define_split
[(set (match_operand:DI 0 "register_operand" "")
(unspec:DI [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_FLOOR))
@@ -17500,7 +17778,7 @@
(set (match_dup 0) (match_dup 4))]
"")
-(define_split
+(define_split
[(set (match_operand:DI 0 "memory_operand" "")
(unspec:DI [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_FLOOR))
@@ -17542,7 +17820,7 @@
(set_attr "i387_cw" "floor")
(set_attr "mode" "<MODE>")])
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "register_operand" "")
(unspec:X87MODEI12 [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_FLOOR))
@@ -17557,7 +17835,7 @@
(set (match_dup 0) (match_dup 4))]
"")
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "memory_operand" "")
(unspec:X87MODEI12 [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_FLOOR))
@@ -17725,7 +18003,7 @@
(set_attr "i387_cw" "ceil")
(set_attr "mode" "DI")])
-(define_split
+(define_split
[(set (match_operand:DI 0 "register_operand" "")
(unspec:DI [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_CEIL))
@@ -17741,7 +18019,7 @@
(set (match_dup 0) (match_dup 4))]
"")
-(define_split
+(define_split
[(set (match_operand:DI 0 "memory_operand" "")
(unspec:DI [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_CEIL))
@@ -17783,7 +18061,7 @@
(set_attr "i387_cw" "ceil")
(set_attr "mode" "<MODE>")])
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "register_operand" "")
(unspec:X87MODEI12 [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_CEIL))
@@ -17798,7 +18076,7 @@
(set (match_dup 0) (match_dup 4))]
"")
-(define_split
+(define_split
[(set (match_operand:X87MODEI12 0 "memory_operand" "")
(unspec:X87MODEI12 [(match_operand:XF 1 "register_operand" "")]
UNSPEC_FIST_CEIL))
@@ -18192,11 +18470,11 @@
(define_insn "*rep_movdi_rex64"
[(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
- (set (match_operand:DI 0 "register_operand" "=D")
+ (set (match_operand:DI 0 "register_operand" "=D")
(plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
(const_int 3))
(match_operand:DI 3 "register_operand" "0")))
- (set (match_operand:DI 1 "register_operand" "=S")
+ (set (match_operand:DI 1 "register_operand" "=S")
(plus:DI (ashift:DI (match_dup 5) (const_int 3))
(match_operand:DI 4 "register_operand" "1")))
(set (mem:BLK (match_dup 3))
@@ -18212,11 +18490,11 @@
(define_insn "*rep_movsi"
[(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
- (set (match_operand:SI 0 "register_operand" "=D")
+ (set (match_operand:SI 0 "register_operand" "=D")
(plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2")
(const_int 2))
(match_operand:SI 3 "register_operand" "0")))
- (set (match_operand:SI 1 "register_operand" "=S")
+ (set (match_operand:SI 1 "register_operand" "=S")
(plus:SI (ashift:SI (match_dup 5) (const_int 2))
(match_operand:SI 4 "register_operand" "1")))
(set (mem:BLK (match_dup 3))
@@ -18232,11 +18510,11 @@
(define_insn "*rep_movsi_rex64"
[(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
- (set (match_operand:DI 0 "register_operand" "=D")
+ (set (match_operand:DI 0 "register_operand" "=D")
(plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
(const_int 2))
(match_operand:DI 3 "register_operand" "0")))
- (set (match_operand:DI 1 "register_operand" "=S")
+ (set (match_operand:DI 1 "register_operand" "=S")
(plus:DI (ashift:DI (match_dup 5) (const_int 2))
(match_operand:DI 4 "register_operand" "1")))
(set (mem:BLK (match_dup 3))
@@ -18252,10 +18530,10 @@
(define_insn "*rep_movqi"
[(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
- (set (match_operand:SI 0 "register_operand" "=D")
+ (set (match_operand:SI 0 "register_operand" "=D")
(plus:SI (match_operand:SI 3 "register_operand" "0")
(match_operand:SI 5 "register_operand" "2")))
- (set (match_operand:SI 1 "register_operand" "=S")
+ (set (match_operand:SI 1 "register_operand" "=S")
(plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5)))
(set (mem:BLK (match_dup 3))
(mem:BLK (match_dup 4)))
@@ -18270,10 +18548,10 @@
(define_insn "*rep_movqi_rex64"
[(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
- (set (match_operand:DI 0 "register_operand" "=D")
+ (set (match_operand:DI 0 "register_operand" "=D")
(plus:DI (match_operand:DI 3 "register_operand" "0")
(match_operand:DI 5 "register_operand" "2")))
- (set (match_operand:DI 1 "register_operand" "=S")
+ (set (match_operand:DI 1 "register_operand" "=S")
(plus:DI (match_operand:DI 4 "register_operand" "1") (match_dup 5)))
(set (mem:BLK (match_dup 3))
(mem:BLK (match_dup 4)))
@@ -18460,7 +18738,7 @@
(define_insn "*rep_stosdi_rex64"
[(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
- (set (match_operand:DI 0 "register_operand" "=D")
+ (set (match_operand:DI 0 "register_operand" "=D")
(plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
(const_int 3))
(match_operand:DI 3 "register_operand" "0")))
@@ -18478,7 +18756,7 @@
(define_insn "*rep_stossi"
[(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
- (set (match_operand:SI 0 "register_operand" "=D")
+ (set (match_operand:SI 0 "register_operand" "=D")
(plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1")
(const_int 2))
(match_operand:SI 3 "register_operand" "0")))
@@ -18496,7 +18774,7 @@
(define_insn "*rep_stossi_rex64"
[(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
- (set (match_operand:DI 0 "register_operand" "=D")
+ (set (match_operand:DI 0 "register_operand" "=D")
(plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
(const_int 2))
(match_operand:DI 3 "register_operand" "0")))
@@ -18514,7 +18792,7 @@
(define_insn "*rep_stosqi"
[(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
- (set (match_operand:SI 0 "register_operand" "=D")
+ (set (match_operand:SI 0 "register_operand" "=D")
(plus:SI (match_operand:SI 3 "register_operand" "0")
(match_operand:SI 4 "register_operand" "1")))
(set (mem:BLK (match_dup 3))
@@ -18531,7 +18809,7 @@
(define_insn "*rep_stosqi_rex64"
[(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
- (set (match_operand:DI 0 "register_operand" "=D")
+ (set (match_operand:DI 0 "register_operand" "=D")
(plus:DI (match_operand:DI 3 "register_operand" "0")
(match_operand:DI 4 "register_operand" "1")))
(set (mem:BLK (match_dup 3))
@@ -18907,7 +19185,7 @@
(define_insn "*movdicc_c_rex64"
[(set (match_operand:DI 0 "register_operand" "=r,r")
- (if_then_else:DI (match_operator 1 "ix86_comparison_operator"
+ (if_then_else:DI (match_operator 1 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand:DI 2 "nonimmediate_operand" "rm,0")
(match_operand:DI 3 "nonimmediate_operand" "0,rm")))]
@@ -18950,7 +19228,7 @@
(define_insn "*movsicc_noc"
[(set (match_operand:SI 0 "register_operand" "=r,r")
- (if_then_else:SI (match_operator 1 "ix86_comparison_operator"
+ (if_then_else:SI (match_operator 1 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand:SI 2 "nonimmediate_operand" "rm,0")
(match_operand:SI 3 "nonimmediate_operand" "0,rm")))]
@@ -18972,7 +19250,7 @@
(define_insn "*movhicc_noc"
[(set (match_operand:HI 0 "register_operand" "=r,r")
- (if_then_else:HI (match_operator 1 "ix86_comparison_operator"
+ (if_then_else:HI (match_operator 1 "ix86_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand:HI 2 "nonimmediate_operand" "rm,0")
(match_operand:HI 3 "nonimmediate_operand" "0,rm")))]
@@ -18994,7 +19272,7 @@
(define_insn_and_split "*movqicc_noc"
[(set (match_operand:QI 0 "register_operand" "=r,r")
- (if_then_else:QI (match_operator 1 "ix86_comparison_operator"
+ (if_then_else:QI (match_operator 1 "ix86_comparison_operator"
[(match_operand 4 "flags_reg_operand" "")
(const_int 0)])
(match_operand:QI 2 "register_operand" "r,0")
@@ -19022,7 +19300,7 @@
(define_insn "*movsfcc_1_387"
[(set (match_operand:SF 0 "register_operand" "=f,f,r,r")
- (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
+ (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0")
(match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))]
@@ -19046,7 +19324,7 @@
(define_insn "*movdfcc_1"
[(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
- (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
+ (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
(match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
@@ -19062,7 +19340,7 @@
(define_insn "*movdfcc_1_rex64"
[(set (match_operand:DF 0 "register_operand" "=f,f,r,r")
- (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
+ (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
(match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
@@ -19078,7 +19356,7 @@
(define_split
[(set (match_operand:DF 0 "register_and_not_any_fp_reg_operand" "")
- (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
+ (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
[(match_operand 4 "flags_reg_operand" "")
(const_int 0)])
(match_operand:DF 2 "nonimmediate_operand" "")
@@ -19106,7 +19384,7 @@
(define_insn "*movxfcc_1"
[(set (match_operand:XF 0 "register_operand" "=f,f")
- (if_then_else:XF (match_operator 1 "fcmov_comparison_operator"
+ (if_then_else:XF (match_operator 1 "fcmov_comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand:XF 2 "register_operand" "f,0")
(match_operand:XF 3 "register_operand" "0,f")))]
@@ -19268,7 +19546,7 @@
;; This pattern exists to put a dependency on all ebp-based memory accesses.
;; Otherwise there will be nothing to keep
-;;
+;;
;; [(set (reg ebp) (reg esp))]
;; [(set (reg esp) (plus (reg esp) (const_int -160000)))
;; (clobber (eflags)]
@@ -19460,7 +19738,7 @@
&& INTVAL (operands[1]) < CHECK_STACK_LIMIT)
emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
operands[1]));
- else
+ else
#endif
emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
operands[1])));
@@ -19500,12 +19778,12 @@
(match_operand 2 "aligned_operand" "")]))
(clobber (reg:CC FLAGS_REG))]
"! TARGET_PARTIAL_REG_STALL && reload_completed
- && ((GET_MODE (operands[0]) == HImode
+ && ((GET_MODE (operands[0]) == HImode
&& ((!optimize_size && !TARGET_FAST_PREFIX)
/* ??? next two lines just !satisfies_constraint_K (...) */
|| GET_CODE (operands[2]) != CONST_INT
|| satisfies_constraint_K (operands[2])))
- || (GET_MODE (operands[0]) == QImode
+ || (GET_MODE (operands[0]) == QImode
&& (TARGET_PROMOTE_QImode || optimize_size)))"
[(parallel [(set (match_dup 0)
(match_op_dup 3 [(match_dup 1) (match_dup 2)]))
@@ -19578,7 +19856,7 @@
(clobber (reg:CC FLAGS_REG))]
"! TARGET_PARTIAL_REG_STALL && reload_completed
&& (GET_MODE (operands[0]) == HImode
- || (GET_MODE (operands[0]) == QImode
+ || (GET_MODE (operands[0]) == QImode
&& (TARGET_PROMOTE_QImode || optimize_size)))"
[(parallel [(set (match_dup 0)
(neg:SI (match_dup 1)))
@@ -19591,7 +19869,7 @@
(not (match_operand 1 "register_operand" "")))]
"! TARGET_PARTIAL_REG_STALL && reload_completed
&& (GET_MODE (operands[0]) == HImode
- || (GET_MODE (operands[0]) == QImode
+ || (GET_MODE (operands[0]) == QImode
&& (TARGET_PROMOTE_QImode || optimize_size)))"
[(set (match_dup 0)
(not:SI (match_dup 1)))]
@@ -19598,15 +19876,15 @@
"operands[0] = gen_lowpart (SImode, operands[0]);
operands[1] = gen_lowpart (SImode, operands[1]);")
-(define_split
+(define_split
[(set (match_operand 0 "register_operand" "")
- (if_then_else (match_operator 1 "comparison_operator"
+ (if_then_else (match_operator 1 "comparison_operator"
[(reg FLAGS_REG) (const_int 0)])
(match_operand 2 "register_operand" "")
(match_operand 3 "register_operand" "")))]
"! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE
&& (GET_MODE (operands[0]) == HImode
- || (GET_MODE (operands[0]) == QImode
+ || (GET_MODE (operands[0]) == QImode
&& (TARGET_PROMOTE_QImode || optimize_size)))"
[(set (match_dup 0)
(if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
@@ -19613,7 +19891,7 @@
"operands[0] = gen_lowpart (SImode, operands[0]);
operands[2] = gen_lowpart (SImode, operands[2]);
operands[3] = gen_lowpart (SImode, operands[3]);")
-
+
;; RTL Peephole optimizations, run before sched2. These primarily look to
;; transform a complex memory operation into two memory to register operations.
@@ -19758,7 +20036,7 @@
(set (match_dup 0) (match_op_dup 1 [(match_dup 3) (const_int 0)]))]
"")
-;; NOT is not pairable on Pentium, while XOR is, but one byte longer.
+;; NOT is not pairable on Pentium, while XOR is, but one byte longer.
;; Don't split NOTs with a displacement operand, because resulting XOR
;; will not be pairable anyway.
;;
@@ -19774,7 +20052,7 @@
(not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
"!optimize_size
&& peep2_regno_dead_p (0, FLAGS_REG)
- && ((TARGET_PENTIUM
+ && ((TARGET_PENTIUM
&& (GET_CODE (operands[0]) != MEM
|| !memory_displacement_operand (operands[0], SImode)))
|| (TARGET_K6 && long_memory_operand (operands[0], SImode)))"
@@ -19788,7 +20066,7 @@
(not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
"!optimize_size
&& peep2_regno_dead_p (0, FLAGS_REG)
- && ((TARGET_PENTIUM
+ && ((TARGET_PENTIUM
&& (GET_CODE (operands[0]) != MEM
|| !memory_displacement_operand (operands[0], HImode)))
|| (TARGET_K6 && long_memory_operand (operands[0], HImode)))"
@@ -19802,7 +20080,7 @@
(not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
"!optimize_size
&& peep2_regno_dead_p (0, FLAGS_REG)
- && ((TARGET_PENTIUM
+ && ((TARGET_PENTIUM
&& (GET_CODE (operands[0]) != MEM
|| !memory_displacement_operand (operands[0], QImode)))
|| (TARGET_K6 && long_memory_operand (operands[0], QImode)))"
@@ -19883,7 +20161,7 @@
(set (zero_extract:SI (match_dup 2)
(const_int 8)
(const_int 8))
- (and:SI
+ (and:SI
(zero_extract:SI
(match_dup 2)
(const_int 8)
@@ -19985,7 +20263,7 @@
[(set (match_operand 0 "register_operand" "")
(const_int -1))]
"(GET_MODE (operands[0]) == HImode
- || GET_MODE (operands[0]) == SImode
+ || GET_MODE (operands[0]) == SImode
|| (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
&& (optimize_size || TARGET_PENTIUM)
&& peep2_regno_dead_p (0, FLAGS_REG)"
@@ -20341,7 +20619,7 @@
(mult:SI (match_operand:SI 1 "nonimmediate_operand" "")
(match_operand:SI 2 "const_int_operand" "")))
(clobber (reg:CC FLAGS_REG))])]
- "!optimize_size
+ "!optimize_size
&& (INTVAL (operands[2]) == 3
|| INTVAL (operands[2]) == 5
|| INTVAL (operands[2]) == 9)"
@@ -20373,7 +20651,7 @@
(match_operand:DI 2 "const_int_operand" "")))
(clobber (reg:CC FLAGS_REG))])]
"TARGET_64BIT
- && !optimize_size
+ && !optimize_size
&& (INTVAL (operands[2]) == 3
|| INTVAL (operands[2]) == 5
|| INTVAL (operands[2]) == 9)"
@@ -20391,7 +20669,7 @@
(mult:DI (match_operand:DI 1 "memory_operand" "")
(match_operand:DI 2 "immediate_operand" "")))
(clobber (reg:CC FLAGS_REG))])]
- "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
+ "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
&& !satisfies_constraint_K (operands[2])"
[(set (match_dup 3) (match_dup 1))
(parallel [(set (match_dup 0) (mult:DI (match_dup 3) (match_dup 2)))
@@ -20404,7 +20682,7 @@
(mult:SI (match_operand:SI 1 "memory_operand" "")
(match_operand:SI 2 "immediate_operand" "")))
(clobber (reg:CC FLAGS_REG))])]
- "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
+ "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
&& !satisfies_constraint_K (operands[2])"
[(set (match_dup 3) (match_dup 1))
(parallel [(set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))
@@ -20418,7 +20696,7 @@
(mult:SI (match_operand:SI 1 "memory_operand" "")
(match_operand:SI 2 "immediate_operand" ""))))
(clobber (reg:CC FLAGS_REG))])]
- "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
+ "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
&& !satisfies_constraint_K (operands[2])"
[(set (match_dup 3) (match_dup 1))
(parallel [(set (match_dup 0) (zero_extend:DI (mult:SI (match_dup 3) (match_dup 2))))
@@ -20435,7 +20713,7 @@
(match_operand:DI 2 "const_int_operand" "")))
(clobber (reg:CC FLAGS_REG))])
(match_scratch:DI 3 "r")]
- "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
+ "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
&& satisfies_constraint_K (operands[2])"
[(set (match_dup 3) (match_dup 2))
(parallel [(set (match_dup 0) (mult:DI (match_dup 0) (match_dup 3)))
@@ -20451,7 +20729,7 @@
(match_operand:SI 2 "const_int_operand" "")))
(clobber (reg:CC FLAGS_REG))])
(match_scratch:SI 3 "r")]
- "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
+ "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
&& satisfies_constraint_K (operands[2])"
[(set (match_dup 3) (match_dup 2))
(parallel [(set (match_dup 0) (mult:SI (match_dup 0) (match_dup 3)))
@@ -20467,7 +20745,7 @@
(match_operand:HI 2 "immediate_operand" "")))
(clobber (reg:CC FLAGS_REG))])
(match_scratch:HI 3 "r")]
- "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size"
+ "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size"
[(set (match_dup 3) (match_dup 2))
(parallel [(set (match_dup 0) (mult:HI (match_dup 0) (match_dup 3)))
(clobber (reg:CC FLAGS_REG))])]
@@ -20504,7 +20782,7 @@
&& ((!TARGET_PARTIAL_REG_STALL
&& (GET_MODE (operands[0]) == QImode
|| GET_MODE (operands[0]) == HImode))
- || GET_MODE (operands[0]) == SImode
+ || GET_MODE (operands[0]) == SImode
|| (TARGET_64BIT && GET_MODE (operands[0]) == DImode))
/* We reorder load and the shift. */
&& !rtx_equal_p (operands[1], operands[3])
@@ -20653,7 +20931,7 @@
[(set_attr "type" "callv")])
;; We used to use "int $5", in honor of #BR which maps to interrupt vector 5.
-;; That, however, is usually mapped by the OS to SIGSEGV, which is often
+;; That, however, is usually mapped by the OS to SIGSEGV, which is often
;; caught for use by garbage collectors and the like. Using an insn that
;; maps to SIGILL makes it more likely the program will rightfully die.
;; Keeping with tradition, "6" is in honor of #UD.
@@ -20761,7 +21039,7 @@
int locality = INTVAL (operands[1]);
gcc_assert (locality >= 0 && locality <= 3);
- return patterns[locality];
+ return patterns[locality];
}
[(set_attr "type" "sse")
(set_attr "memory" "none")])
@@ -20779,7 +21057,7 @@
int locality = INTVAL (operands[1]);
gcc_assert (locality >= 0 && locality <= 3);
- return patterns[locality];
+ return patterns[locality];
}
[(set_attr "type" "sse")
(set_attr "memory" "none")])
Modified: trunk/contrib/gcc/config/i386/i386.opt
===================================================================
--- trunk/contrib/gcc4/config/i386/i386.opt 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/i386.opt 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1,6 +1,6 @@
; Options for the IA-32 and AMD64 ports of the compiler.
-; Copyright (C) 2005 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
;
; This file is part of GCC.
;
@@ -201,6 +201,26 @@
Target Report Mask(SSSE3)
Support MMX, SSE, SSE2, SSE3 and SSSE3 built-in functions and code generation
+msse4a
+Target Report Mask(SSE4A)
+Support MMX, SSE, SSE2, SSE3 and SSE4A built-in functions and code generation
+
+maes
+Target Report Mask(AES)
+Support AES built-in functions and code generation.
+
+mpopcnt
+Target Report Mask(POPCNT)
+Support code generation of popcount instruction for popcount built-ins
+namely __builtin_popcount, __builtin_popcountl and __builtin_popcountll
+
+mabm
+Target Report Mask(ABM)
+Support code generation of Advanced Bit Manipulation (ABM) instructions,
+which include popcnt and lzcnt instructions, for popcount and clz built-ins
+namely __builtin_popcount, __builtin_popcountl, __builtin_popcountll and
+__builtin_clz, __builtin_clzl, __builtin_clzll
+
msseregparm
Target RejectNegative Mask(SSEREGPARM)
Use SSE register passing conventions for SF and DF mode
Modified: trunk/contrib/gcc/config/i386/nto.h
===================================================================
--- trunk/contrib/gcc4/config/i386/nto.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/nto.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -43,7 +43,7 @@
#undef THREAD_MODEL_SPEC
#define THREAD_MODEL_SPEC "posix"
-#ifdef CROSS_COMPILE
+#ifdef CROSS_DIRECTORY_STRUCTURE
#define SYSROOT_SUFFIX_SPEC "x86"
#endif
Modified: trunk/contrib/gcc/config/i386/pmmintrin.h
===================================================================
--- trunk/contrib/gcc4/config/i386/pmmintrin.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/pmmintrin.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GCC.
@@ -30,7 +30,11 @@
#ifndef _PMMINTRIN_H_INCLUDED
#define _PMMINTRIN_H_INCLUDED
-#ifdef __SSE3__
+#ifndef __SSE3__
+# error "SSE3 instruction set not enabled"
+#else
+
+/* We need definitions from the SSE2 and SSE header files*/
#include <xmmintrin.h>
#include <emmintrin.h>
Modified: trunk/contrib/gcc/config/i386/sse.md
===================================================================
--- trunk/contrib/gcc4/config/i386/sse.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/sse.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1,5 +1,5 @@
;; GCC machine description for SSE instructions
-;; Copyright (C) 2005, 2006
+;; Copyright (C) 2005, 2006, 2007
;; Free Software Foundation, Inc.
;;
;; This file is part of GCC.
@@ -920,6 +920,7 @@
"cvtsi2ss\t{%2, %0|%0, %2}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "vector,double")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "mode" "SF")])
(define_insn "sse_cvtsi2ssq"
@@ -933,6 +934,7 @@
"cvtsi2ssq\t{%2, %0|%0, %2}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "vector,double")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "mode" "SF")])
(define_insn "sse_cvtss2si"
@@ -946,6 +948,7 @@
"cvtss2si\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")
(set_attr "mode" "SI")])
(define_insn "sse_cvtss2siq"
@@ -959,6 +962,7 @@
"cvtss2siq\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")
(set_attr "mode" "DI")])
(define_insn "sse_cvttss2si"
@@ -971,6 +975,7 @@
"cvttss2si\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")
(set_attr "mode" "SI")])
(define_insn "sse_cvttss2siq"
@@ -983,6 +988,7 @@
"cvttss2siq\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")
(set_attr "mode" "DI")])
(define_insn "sse2_cvtdq2ps"
@@ -1852,7 +1858,8 @@
"cvtsi2sd\t{%2, %0|%0, %2}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "double,direct")])
+ (set_attr "athlon_decode" "double,direct")
+ (set_attr "amdfam10_decode" "vector,double")])
(define_insn "sse2_cvtsi2sdq"
[(set (match_operand:V2DF 0 "register_operand" "=x,x")
@@ -1865,7 +1872,8 @@
"cvtsi2sdq\t{%2, %0|%0, %2}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "DF")
- (set_attr "athlon_decode" "double,direct")])
+ (set_attr "athlon_decode" "double,direct")
+ (set_attr "amdfam10_decode" "vector,double")])
(define_insn "sse2_cvtsd2si"
[(set (match_operand:SI 0 "register_operand" "=r,r")
@@ -1878,6 +1886,7 @@
"cvtsd2si\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")
(set_attr "mode" "SI")])
(define_insn "sse2_cvtsd2siq"
@@ -1891,6 +1900,7 @@
"cvtsd2siq\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")
(set_attr "mode" "DI")])
(define_insn "sse2_cvttsd2si"
@@ -1903,7 +1913,8 @@
"cvttsd2si\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "SI")
- (set_attr "athlon_decode" "double,vector")])
+ (set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")])
(define_insn "sse2_cvttsd2siq"
[(set (match_operand:DI 0 "register_operand" "=r,r")
@@ -1915,7 +1926,8 @@
"cvttsd2siq\t{%1, %0|%0, %1}"
[(set_attr "type" "sseicvt")
(set_attr "mode" "DI")
- (set_attr "athlon_decode" "double,vector")])
+ (set_attr "athlon_decode" "double,vector")
+ (set_attr "amdfam10_decode" "double,double")])
(define_insn "sse2_cvtdq2pd"
[(set (match_operand:V2DF 0 "register_operand" "=x")
@@ -1946,7 +1958,8 @@
"TARGET_SSE2"
"cvtpd2dq\t{%1, %0|%0, %1}"
[(set_attr "type" "ssecvt")
- (set_attr "mode" "TI")])
+ (set_attr "mode" "TI")
+ (set_attr "amdfam10_decode" "double")])
(define_expand "sse2_cvttpd2dq"
[(set (match_operand:V4SI 0 "register_operand" "")
@@ -1964,7 +1977,8 @@
"TARGET_SSE2"
"cvttpd2dq\t{%1, %0|%0, %1}"
[(set_attr "type" "ssecvt")
- (set_attr "mode" "TI")])
+ (set_attr "mode" "TI")
+ (set_attr "amdfam10_decode" "double")])
(define_insn "sse2_cvtsd2ss"
[(set (match_operand:V4SF 0 "register_operand" "=x,x")
@@ -1978,20 +1992,22 @@
"cvtsd2ss\t{%2, %0|%0, %2}"
[(set_attr "type" "ssecvt")
(set_attr "athlon_decode" "vector,double")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "mode" "SF")])
(define_insn "sse2_cvtss2sd"
- [(set (match_operand:V2DF 0 "register_operand" "=x")
+ [(set (match_operand:V2DF 0 "register_operand" "=x,x")
(vec_merge:V2DF
(float_extend:V2DF
(vec_select:V2SF
- (match_operand:V4SF 2 "nonimmediate_operand" "xm")
+ (match_operand:V4SF 2 "nonimmediate_operand" "x,m")
(parallel [(const_int 0) (const_int 1)])))
- (match_operand:V2DF 1 "register_operand" "0")
+ (match_operand:V2DF 1 "register_operand" "0,0")
(const_int 1)))]
"TARGET_SSE2"
"cvtss2sd\t{%2, %0|%0, %2}"
[(set_attr "type" "ssecvt")
+ (set_attr "amdfam10_decode" "vector,double")
(set_attr "mode" "DF")])
(define_expand "sse2_cvtpd2ps"
@@ -2012,7 +2028,8 @@
"TARGET_SSE2"
"cvtpd2ps\t{%1, %0|%0, %1}"
[(set_attr "type" "ssecvt")
- (set_attr "mode" "V4SF")])
+ (set_attr "mode" "V4SF")
+ (set_attr "amdfam10_decode" "double")])
(define_insn "sse2_cvtps2pd"
[(set (match_operand:V2DF 0 "register_operand" "=x")
@@ -2023,7 +2040,8 @@
"TARGET_SSE2"
"cvtps2pd\t{%1, %0|%0, %1}"
[(set_attr "type" "ssecvt")
- (set_attr "mode" "V2DF")])
+ (set_attr "mode" "V2DF")
+ (set_attr "amdfam10_decode" "direct")])
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@@ -4524,3 +4542,92 @@
"pabs<mmxvecsize>\t{%1, %0|%0, %1}";
[(set_attr "type" "sselog1")
(set_attr "mode" "DI")])
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; AMD SSE4A instructions
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define_insn "sse4a_vmmovntv2df"
+ [(set (match_operand:DF 0 "memory_operand" "=m")
+ (unspec:DF [(vec_select:DF
+ (match_operand:V2DF 1 "register_operand" "x")
+ (parallel [(const_int 0)]))]
+ UNSPEC_MOVNT))]
+ "TARGET_SSE4A"
+ "movntsd\t{%1, %0|%0, %1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "mode" "DF")])
+
+(define_insn "sse4a_movntdf"
+ [(set (match_operand:DF 0 "memory_operand" "=m")
+ (unspec:DF [(match_operand:DF 1 "register_operand" "x")]
+ UNSPEC_MOVNT))]
+ "TARGET_SSE4A"
+ "movntsd\t{%1, %0|%0, %1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "mode" "DF")])
+
+(define_insn "sse4a_vmmovntv4sf"
+ [(set (match_operand:SF 0 "memory_operand" "=m")
+ (unspec:SF [(vec_select:SF
+ (match_operand:V4SF 1 "register_operand" "x")
+ (parallel [(const_int 0)]))]
+ UNSPEC_MOVNT))]
+ "TARGET_SSE4A"
+ "movntss\t{%1, %0|%0, %1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "mode" "SF")])
+
+(define_insn "sse4a_movntsf"
+ [(set (match_operand:SF 0 "memory_operand" "=m")
+ (unspec:SF [(match_operand:SF 1 "register_operand" "x")]
+ UNSPEC_MOVNT))]
+ "TARGET_SSE4A"
+ "movntss\t{%1, %0|%0, %1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "mode" "SF")])
+
+(define_insn "sse4a_extrqi"
+ [(set (match_operand:V2DI 0 "register_operand" "=x")
+ (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+ (match_operand 2 "const_int_operand" "")
+ (match_operand 3 "const_int_operand" "")]
+ UNSPEC_EXTRQI))]
+ "TARGET_SSE4A"
+ "extrq\t{%3, %2, %0|%0, %2, %3}"
+ [(set_attr "type" "sse")
+ (set_attr "mode" "TI")])
+
+(define_insn "sse4a_extrq"
+ [(set (match_operand:V2DI 0 "register_operand" "=x")
+ (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+ (match_operand:V16QI 2 "register_operand" "x")]
+ UNSPEC_EXTRQ))]
+ "TARGET_SSE4A"
+ "extrq\t{%2, %0|%0, %2}"
+ [(set_attr "type" "sse")
+ (set_attr "mode" "TI")])
+
+(define_insn "sse4a_insertqi"
+ [(set (match_operand:V2DI 0 "register_operand" "=x")
+ (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+ (match_operand:V2DI 2 "register_operand" "x")
+ (match_operand 3 "const_int_operand" "")
+ (match_operand 4 "const_int_operand" "")]
+ UNSPEC_INSERTQI))]
+ "TARGET_SSE4A"
+ "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
+ [(set_attr "type" "sseins")
+ (set_attr "mode" "TI")])
+
+(define_insn "sse4a_insertq"
+ [(set (match_operand:V2DI 0 "register_operand" "=x")
+ (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+ (match_operand:V2DI 2 "register_operand" "x")]
+ UNSPEC_INSERTQ))]
+ "TARGET_SSE4A"
+ "insertq\t{%2, %0|%0, %2}"
+ [(set_attr "type" "sseins")
+ (set_attr "mode" "TI")])
Modified: trunk/contrib/gcc/config/i386/x86-64.h
===================================================================
--- trunk/contrib/gcc4/config/i386/x86-64.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/x86-64.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -19,7 +19,7 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/config/i386/x86-64.h 169699 2007-05-19 02:12:21Z kan $ */
#undef ASM_COMMENT_START
#define ASM_COMMENT_START "#"
Modified: trunk/contrib/gcc/config/i386/xmmintrin.h
===================================================================
--- trunk/contrib/gcc4/config/i386/xmmintrin.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/i386/xmmintrin.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -39,7 +39,9 @@
#include <mmintrin.h>
/* Get _mm_malloc () and _mm_free (). */
+#if __STDC_HOSTED__
#include <mm_malloc.h>
+#endif
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
Modified: trunk/contrib/gcc/config/ia64/hpux.h
===================================================================
--- trunk/contrib/gcc4/config/ia64/hpux.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/ia64/hpux.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -144,10 +144,6 @@
definitions, so do not use them in gthr-posix.h. */
#define GTHREAD_USE_WEAK 0
-/* Put out the needed function declarations at the end. */
-
-#define TARGET_ASM_FILE_END ia64_hpux_file_end
-
#undef CTORS_SECTION_ASM_OP
#define CTORS_SECTION_ASM_OP "\t.section\t.init_array,\t\"aw\",\"init_array\""
Modified: trunk/contrib/gcc/config/ia64/ia64.c
===================================================================
--- trunk/contrib/gcc4/config/ia64/ia64.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/ia64/ia64.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -250,10 +250,6 @@
static void ia64_output_dwarf_dtprel (FILE *, int, rtx)
ATTRIBUTE_UNUSED;
static unsigned int ia64_section_type_flags (tree, const char *, int);
-static void ia64_hpux_add_extern_decl (tree decl)
- ATTRIBUTE_UNUSED;
-static void ia64_hpux_file_end (void)
- ATTRIBUTE_UNUSED;
static void ia64_init_libfuncs (void)
ATTRIBUTE_UNUSED;
static void ia64_hpux_init_libfuncs (void)
@@ -5015,49 +5011,6 @@
}
-/* Emit text to declare externally defined variables and functions, because
- the Intel assembler does not support undefined externals. */
-
-void
-ia64_asm_output_external (FILE *file, tree decl, const char *name)
-{
- int save_referenced;
-
- /* GNU as does not need anything here, but the HP linker does need
- something for external functions. */
-
- if (TARGET_GNU_AS
- && (!TARGET_HPUX_LD
- || TREE_CODE (decl) != FUNCTION_DECL
- || strstr (name, "__builtin_") == name))
- return;
-
- /* ??? The Intel assembler creates a reference that needs to be satisfied by
- the linker when we do this, so we need to be careful not to do this for
- builtin functions which have no library equivalent. Unfortunately, we
- can't tell here whether or not a function will actually be called by
- expand_expr, so we pull in library functions even if we may not need
- them later. */
- if (! strcmp (name, "__builtin_next_arg")
- || ! strcmp (name, "alloca")
- || ! strcmp (name, "__builtin_constant_p")
- || ! strcmp (name, "__builtin_args_info"))
- return;
-
- if (TARGET_HPUX_LD)
- ia64_hpux_add_extern_decl (decl);
- else
- {
- /* assemble_name will set TREE_SYMBOL_REFERENCED, so we must save and
- restore it. */
- save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl));
- if (TREE_CODE (decl) == FUNCTION_DECL)
- ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
- (*targetm.asm_out.globalize_label) (file, name);
- TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) = save_referenced;
- }
-}
-
/* Parse the -mfixed-range= option string. */
static void
@@ -9223,55 +9176,33 @@
return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
}
-/* Linked list of all external functions that are to be emitted by GCC.
- We output the name if and only if TREE_SYMBOL_REFERENCED is set in
- order to avoid putting out names that are never really used. */
+/* Emit text to declare externally defined variables and functions, because
+ the Intel assembler does not support undefined externals. */
-struct extern_func_list GTY(())
+void
+ia64_asm_output_external (FILE *file, tree decl, const char *name)
{
- struct extern_func_list *next;
- tree decl;
-};
-
-static GTY(()) struct extern_func_list *extern_func_head;
-
-static void
-ia64_hpux_add_extern_decl (tree decl)
-{
- struct extern_func_list *p = ggc_alloc (sizeof (struct extern_func_list));
-
- p->decl = decl;
- p->next = extern_func_head;
- extern_func_head = p;
-}
-
-/* Print out the list of used global functions. */
-
-static void
-ia64_hpux_file_end (void)
-{
- struct extern_func_list *p;
-
- for (p = extern_func_head; p; p = p->next)
+ /* We output the name if and only if TREE_SYMBOL_REFERENCED is
+ set in order to avoid putting out names that are never really
+ used. */
+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
{
- tree decl = p->decl;
- tree id = DECL_ASSEMBLER_NAME (decl);
+ /* maybe_assemble_visibility will return 1 if the assembler
+ visibility directive is outputed. */
+ int need_visibility = ((*targetm.binds_local_p) (decl)
+ && maybe_assemble_visibility (decl));
- gcc_assert (id);
-
- if (!TREE_ASM_WRITTEN (decl) && TREE_SYMBOL_REFERENCED (id))
- {
- const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
-
- TREE_ASM_WRITTEN (decl) = 1;
- (*targetm.asm_out.globalize_label) (asm_out_file, name);
- fputs (TYPE_ASM_OP, asm_out_file);
- assemble_name (asm_out_file, name);
- fprintf (asm_out_file, "," TYPE_OPERAND_FMT "\n", "function");
- }
+ /* GNU as does not need anything here, but the HP linker does
+ need something for external functions. */
+ if ((TARGET_HPUX_LD || !TARGET_GNU_AS)
+ && TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
+ (*targetm.asm_out.globalize_label) (file, name);
+ }
+ else if (need_visibility && !TARGET_GNU_AS)
+ (*targetm.asm_out.globalize_label) (file, name);
}
-
- extern_func_head = 0;
}
/* Set SImode div/mod functions, init_integral_libfuncs only initializes
Modified: trunk/contrib/gcc/config/ia64/unwind-ia64.h
===================================================================
--- trunk/contrib/gcc4/config/ia64/unwind-ia64.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/ia64/unwind-ia64.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -19,6 +19,13 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
+#ifdef __FreeBSD__
+/* On FreeBSD, _Unwind_FindTableEntry is in libc, and must not be hidden here. */
+#define ATTRIBUTE_HIDDEN
+#else
+#define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
+#endif
+
struct unw_table_entry
{
unsigned long start_offset;
@@ -29,4 +36,4 @@
extern struct unw_table_entry *
_Unwind_FindTableEntry (void *pc, unsigned long *segment_base,
unsigned long *gp)
- __attribute__ ((__visibility__ ("hidden")));
+ ATTRIBUTE_HIDDEN;
Modified: trunk/contrib/gcc/config/mips/mips.c
===================================================================
--- trunk/contrib/gcc4/config/mips/mips.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/mips/mips.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -713,6 +713,7 @@
{ "mips32", PROCESSOR_4KC, 32 },
{ "mips32r2", PROCESSOR_M4K, 33 },
{ "mips64", PROCESSOR_5KC, 64 },
+ { "mips64r2", PROCESSOR_5KC, 65 },
/* MIPS I */
{ "r3000", PROCESSOR_R3000, 1 },
@@ -762,6 +763,9 @@
{ "sb1a", PROCESSOR_SB1A, 64 },
{ "sr71000", PROCESSOR_SR71000, 64 },
+ /* MIPS64R2 */
+ { "octeon", PROCESSOR_OCTEON, 65 },
+
/* End marker */
{ 0, 0, 0 }
};
@@ -1293,7 +1297,21 @@
*base = x;
}
+/* Classify symbolic expression X, given that it appears in context
+ CONTEXT. */
+static enum mips_symbol_type
+mips_classify_symbolic_expression (rtx x)
+{
+ HOST_WIDE_INT offset;
+
+ mips_split_const (x, &x, &offset);
+ if (UNSPEC_ADDRESS_P (x))
+ return UNSPEC_ADDRESS_TYPE (x);
+
+ return mips_classify_symbol (x);
+}
+
/* Return true if SYMBOL is a SYMBOL_REF and OFFSET + SYMBOL points
to the same object as SYMBOL, or to the same object_block. */
@@ -1530,8 +1548,17 @@
info->type = ADDRESS_LO_SUM;
info->reg = XEXP (x, 0);
info->offset = XEXP (x, 1);
+ /* We have to trust the creator of the LO_SUM to do something vaguely
+ sane. Target-independent code that creates a LO_SUM should also
+ create and verify the matching HIGH. Target-independent code that
+ adds an offset to a LO_SUM must prove that the offset will not
+ induce a carry. Failure to do either of these things would be
+ a bug, and we are not required to check for it here. The MIPS
+ backend itself should only create LO_SUMs for valid symbolic
+ constants, with the high part being either a HIGH or a copy
+ of _gp. */
+ info->symbol_type = mips_classify_symbolic_expression (info->offset);
return (mips_valid_base_register_p (info->reg, mode, strict)
- && mips_symbolic_constant_p (info->offset, &info->symbol_type)
&& mips_symbolic_address_p (info->symbol_type, mode)
&& mips_lo_relocs[info->symbol_type] != 0);
@@ -4829,7 +4856,7 @@
issue those instructions unless instructed to do so by
-mbranch-likely. */
if (ISA_HAS_BRANCHLIKELY
- && !(ISA_MIPS32 || ISA_MIPS32R2 || ISA_MIPS64)
+ && !(ISA_MIPS32 || ISA_MIPS32R2 || ISA_MIPS64 || ISA_MIPS64R2)
&& !(TUNE_MIPS5500 || TUNE_SB1))
target_flags |= MASK_BRANCHLIKELY;
else
@@ -5667,7 +5694,8 @@
rtx base;
HOST_WIDE_INT offset;
- if (!mips_symbolic_constant_p (op, &symbol_type) || relocs[symbol_type] == 0)
+ symbol_type = mips_classify_symbolic_expression (op);
+ if (relocs[symbol_type] == 0)
fatal_insn ("PRINT_OPERAND, invalid operand for relocation", op);
/* If OP uses an UNSPEC address, we want to print the inner symbol. */
@@ -9943,6 +9971,7 @@
case PROCESSOR_R5500:
case PROCESSOR_R7000:
case PROCESSOR_R9000:
+ case PROCESSOR_OCTEON:
return 2;
case PROCESSOR_SB1:
Modified: trunk/contrib/gcc/config/mips/mips.h
===================================================================
--- trunk/contrib/gcc4/config/mips/mips.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/mips/mips.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -41,6 +41,7 @@
PROCESSOR_24K,
PROCESSOR_24KX,
PROCESSOR_M4K,
+ PROCESSOR_OCTEON,
PROCESSOR_R3900,
PROCESSOR_R6000,
PROCESSOR_R4000,
@@ -199,6 +200,7 @@
#define ISA_MIPS32 (mips_isa == 32)
#define ISA_MIPS32R2 (mips_isa == 33)
#define ISA_MIPS64 (mips_isa == 64)
+#define ISA_MIPS64R2 (mips_isa == 65)
/* Architecture target defines. */
#define TARGET_MIPS3900 (mips_arch == PROCESSOR_R3900)
@@ -212,6 +214,7 @@
#define TARGET_SB1 (mips_arch == PROCESSOR_SB1 \
|| mips_arch == PROCESSOR_SB1A)
#define TARGET_SR71K (mips_arch == PROCESSOR_SR71000)
+#define TARGET_OCTEON (mips_arch == PROCESSOR_OCTEON)
/* Scheduling target defines. */
#define TUNE_MIPS3000 (mips_tune == PROCESSOR_R3000)
@@ -227,6 +230,7 @@
#define TUNE_MIPS9000 (mips_tune == PROCESSOR_R9000)
#define TUNE_SB1 (mips_tune == PROCESSOR_SB1 \
|| mips_tune == PROCESSOR_SB1A)
+#define TUNE_OCTEON (mips_tune == PROCESSOR_OCTEON)
/* True if the pre-reload scheduler should try to create chains of
multiply-add or multiply-subtract instructions. For example,
@@ -380,6 +384,12 @@
builtin_define ("__mips_isa_rev=1"); \
builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64"); \
} \
+ else if (ISA_MIPS64R2) \
+ { \
+ builtin_define ("__mips=64"); \
+ builtin_define ("__mips_isa_rev=2"); \
+ builtin_define ("_MIPS_ISA=_MIPS_ISA_MIPS64"); \
+ } \
\
if (TARGET_HARD_FLOAT) \
builtin_define ("__mips_hard_float"); \
@@ -501,7 +511,11 @@
# if MIPS_ISA_DEFAULT == 64
# define MULTILIB_ISA_DEFAULT "mips64"
# else
-# define MULTILIB_ISA_DEFAULT "mips1"
+# if MIPS_ISA_DEFAULT == 65
+# define MULTILIB_ISA_DEFAULT "mips64r2"
+# else
+# define MULTILIB_ISA_DEFAULT "mips1"
+# endif
# endif
# endif
# endif
@@ -562,7 +576,8 @@
|| TARGET_MAD \
|| ISA_MIPS32 \
|| ISA_MIPS32R2 \
- || ISA_MIPS64) \
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2) \
&& !TARGET_MIPS16)
/* Generate three-operand multiply instructions for DImode. */
@@ -584,7 +599,8 @@
/* ISA has instructions for managing 64 bit fp and gp regs (e.g. mips3). */
#define ISA_HAS_64BIT_REGS (ISA_MIPS3 \
|| ISA_MIPS4 \
- || ISA_MIPS64)
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2)
/* ISA has branch likely instructions (e.g. mips2). */
/* Disable branchlikely for tx39 until compare rewrite. They haven't
@@ -595,7 +611,8 @@
#define ISA_HAS_CONDMOVE ((ISA_MIPS4 \
|| ISA_MIPS32 \
|| ISA_MIPS32R2 \
- || ISA_MIPS64) \
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2) \
&& !TARGET_MIPS5500 \
&& !TARGET_MIPS16)
@@ -604,13 +621,15 @@
#define ISA_HAS_8CC (ISA_MIPS4 \
|| ISA_MIPS32 \
|| ISA_MIPS32R2 \
- || ISA_MIPS64)
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2)
/* This is a catch all for other mips4 instructions: indexed load, the
FP madd and msub instructions, and the FP recip and recip sqrt
instructions. */
#define ISA_HAS_FP4 ((ISA_MIPS4 \
- || ISA_MIPS64) \
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2) \
&& !TARGET_MIPS16)
/* ISA has conditional trap instructions. */
@@ -621,11 +640,13 @@
#define ISA_HAS_MADD_MSUB ((ISA_MIPS32 \
|| ISA_MIPS32R2 \
|| ISA_MIPS64 \
+ || ISA_MIPS64R2 \
) && !TARGET_MIPS16)
/* ISA has floating-point nmadd and nmsub instructions. */
#define ISA_HAS_NMADD_NMSUB ((ISA_MIPS4 \
- || ISA_MIPS64) \
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2) \
&& (!TARGET_MIPS5400 || TARGET_MAD) \
&& ! TARGET_MIPS16)
@@ -633,11 +654,13 @@
#define ISA_HAS_CLZ_CLO ((ISA_MIPS32 \
|| ISA_MIPS32R2 \
|| ISA_MIPS64 \
+ || ISA_MIPS64R2 \
) && !TARGET_MIPS16)
/* ISA has double-word count leading zeroes/ones instruction (not
implemented). */
#define ISA_HAS_DCLZ_DCLO (ISA_MIPS64 \
+ || ISA_MIPS64R2 \
&& !TARGET_MIPS16)
/* ISA has three operand multiply instructions that put
@@ -677,6 +700,7 @@
/* ISA has 32-bit rotate right instruction. */
#define ISA_HAS_ROTR_SI (!TARGET_MIPS16 \
&& (ISA_MIPS32R2 \
+ || ISA_MIPS64R2 \
|| TARGET_MIPS5400 \
|| TARGET_MIPS5500 \
|| TARGET_SR71K \
@@ -694,7 +718,8 @@
#define ISA_HAS_PREFETCH ((ISA_MIPS4 \
|| ISA_MIPS32 \
|| ISA_MIPS32R2 \
- || ISA_MIPS64) \
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2) \
&& !TARGET_MIPS16)
/* ISA has data indexed prefetch instructions. This controls use of
@@ -702,7 +727,8 @@
(prefx is a cop1x instruction, so can only be used if FP is
enabled.) */
#define ISA_HAS_PREFETCHX ((ISA_MIPS4 \
- || ISA_MIPS64) \
+ || ISA_MIPS64 \
+ || ISA_MIPS64R2) \
&& !TARGET_MIPS16)
/* True if trunc.w.s and trunc.w.d are real (not synthetic)
@@ -713,11 +739,13 @@
/* ISA includes the MIPS32r2 seb and seh instructions. */
#define ISA_HAS_SEB_SEH (!TARGET_MIPS16 \
&& (ISA_MIPS32R2 \
+ || ISA_MIPS64R2 \
))
/* ISA includes the MIPS32/64 rev 2 ext and ins instructions. */
#define ISA_HAS_EXT_INS (!TARGET_MIPS16 \
&& (ISA_MIPS32R2 \
+ || ISA_MIPS64R2 \
))
/* True if the result of a load is not available to the next instruction.
@@ -748,6 +776,7 @@
#define ISA_HAS_HILO_INTERLOCKS (ISA_MIPS32 \
|| ISA_MIPS32R2 \
|| ISA_MIPS64 \
+ || ISA_MIPS64R2 \
|| TARGET_MIPS5500)
/* Add -G xx support. */
Modified: trunk/contrib/gcc/config/mips/mips.md
===================================================================
--- trunk/contrib/gcc4/config/mips/mips.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/mips/mips.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1041,7 +1041,8 @@
|| TARGET_MIPS9000
|| ISA_MIPS32
|| ISA_MIPS32R2
- || ISA_MIPS64)
+ || ISA_MIPS64
+ || ISA_MIPS64R2)
return "mul\t%0,%1,%2";
return "mult\t%0,%1,%2";
}
Modified: trunk/contrib/gcc/config/mips/predicates.md
===================================================================
--- trunk/contrib/gcc4/config/mips/predicates.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/mips/predicates.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -116,7 +116,9 @@
/* If -mlong-calls, force all calls to use register addressing. Also,
if this function has the long_call attribute, we must use register
addressing. */
- return !TARGET_LONG_CALLS && !SYMBOL_REF_LONG_CALL_P (op);
+ return (!TARGET_LONG_CALLS
+ && !(GET_CODE (op) == SYMBOL_REF
+ && SYMBOL_REF_LONG_CALL_P (op)));
case SYMBOL_GOT_GLOBAL:
/* Without explicit relocs, there is no special syntax for
Modified: trunk/contrib/gcc/config/rs6000/aix.h
===================================================================
--- trunk/contrib/gcc4/config/rs6000/aix.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/aix.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -124,7 +124,7 @@
/* #define ASM_SPEC "-u %(asm_cpu)" */
/* Default location of syscalls.exp under AIX */
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#define LINK_SYSCALLS_SPEC "-bI:/lib/syscalls.exp"
#else
#define LINK_SYSCALLS_SPEC ""
@@ -131,7 +131,7 @@
#endif
/* Default location of libg.exp under AIX */
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#define LINK_LIBG_SPEC "-bexport:/usr/lib/libg.exp"
#else
#define LINK_LIBG_SPEC ""
Modified: trunk/contrib/gcc/config/rs6000/altivec.h
===================================================================
--- trunk/contrib/gcc4/config/rs6000/altivec.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/altivec.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -332,7 +332,7 @@
__altivec_binary_pred(vec_cmplt,
__builtin_vec_cmpgt (a2, a1))
__altivec_binary_pred(vec_cmple,
- __builtin_altivec_cmpge (a2, a1))
+ __builtin_vec_cmpge (a2, a1))
__altivec_scalar_pred(vec_all_in,
__builtin_altivec_vcmpbfp_p (__CR6_EQ, a1, a2))
@@ -402,7 +402,7 @@
#undef __altivec_binary_pred
#else
#define vec_cmplt(a1, a2) __builtin_vec_cmpgt ((a2), (a1))
-#define vec_cmple(a1, a2) __builtin_altivec_vcmpgefp ((a2), (a1))
+#define vec_cmple(a1, a2) __builtin_vec_cmpge ((a2), (a1))
#define vec_all_in(a1, a2) __builtin_altivec_vcmpbfp_p (__CR6_EQ, (a1), (a2))
#define vec_any_out(a1, a2) __builtin_altivec_vcmpbfp_p (__CR6_EQ_REV, (a1), (a2))
Modified: trunk/contrib/gcc/config/rs6000/crtsavres.asm
===================================================================
--- trunk/contrib/gcc4/config/rs6000/crtsavres.asm 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/crtsavres.asm 2018-06-04 17:30:21 UTC (rev 10405)
@@ -305,3 +305,5 @@
FUNC_END(_restgpr_14_x)
#endif
+
+ .section .note.GNU-stack,"",%progbits
Modified: trunk/contrib/gcc/config/rs6000/freebsd.h
===================================================================
--- trunk/contrib/gcc4/config/rs6000/freebsd.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/freebsd.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -21,14 +21,94 @@
/* Override the defaults, which exist to force the proper definition. */
-#undef CPP_OS_DEFAULT_SPEC
-#define CPP_OS_DEFAULT_SPEC "%(cpp_os_freebsd)"
+#ifdef IN_LIBGCC2
+#undef TARGET_64BIT
+#ifdef __powerpc64__
+#define TARGET_64BIT 1
+#else
+#define TARGET_64BIT 0
+#endif
+#endif
-#undef CPP_OS_FREEBSD_SPEC
-#define CPP_OS_FREEBSD_SPEC "\
- -D__PPC__ -D__ppc__ -D__PowerPC__ -D__powerpc__ \
- -Acpu=powerpc -Amachine=powerpc "
+/* On 64-bit systems, use the AIX ABI like Linux and NetBSD */
+#undef DEFAULT_ABI
+#define DEFAULT_ABI (TARGET_64BIT ? ABI_AIX : ABI_V4)
+#undef TARGET_AIX
+#define TARGET_AIX TARGET_64BIT
+
+#ifdef HAVE_LD_NO_DOT_SYMS
+/* New ABI uses a local sym for the function entry point. */
+extern int dot_symbols;
+#undef DOT_SYMBOLS
+#define DOT_SYMBOLS dot_symbols
+#endif
+
+#undef FBSD_TARGET_CPU_CPP_BUILTINS
+#define FBSD_TARGET_CPU_CPP_BUILTINS() \
+ do \
+ { \
+ builtin_define ("__PPC__"); \
+ builtin_define ("__ppc__"); \
+ builtin_define ("__PowerPC__"); \
+ builtin_define ("__powerpc__"); \
+ if (TARGET_64BIT) \
+ { \
+ builtin_define ("__LP64__"); \
+ builtin_define ("__ppc64__"); \
+ builtin_define ("__powerpc64__"); \
+ builtin_define ("__arch64__"); \
+ builtin_assert ("cpu=powerpc64"); \
+ builtin_assert ("machine=powerpc64"); \
+ } else { \
+ builtin_assert ("cpu=powerpc"); \
+ builtin_assert ("machine=powerpc"); \
+ } \
+ } \
+ while (0)
+
+#define INVALID_64BIT "-m%s not supported in this configuration"
+#define INVALID_32BIT INVALID_64BIT
+
+#undef SUBSUBTARGET_OVERRIDE_OPTIONS
+#define SUBSUBTARGET_OVERRIDE_OPTIONS \
+ do \
+ { \
+ if (!rs6000_explicit_options.alignment) \
+ rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
+ if (TARGET_64BIT) \
+ { \
+ if (DEFAULT_ABI != ABI_AIX) \
+ { \
+ rs6000_current_abi = ABI_AIX; \
+ error (INVALID_64BIT, "call"); \
+ } \
+ dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
+ if (target_flags & MASK_RELOCATABLE) \
+ { \
+ target_flags &= ~MASK_RELOCATABLE; \
+ error (INVALID_64BIT, "relocatable"); \
+ } \
+ if (target_flags & MASK_EABI) \
+ { \
+ target_flags &= ~MASK_EABI; \
+ error (INVALID_64BIT, "eabi"); \
+ } \
+ if (target_flags & MASK_PROTOTYPE) \
+ { \
+ target_flags &= ~MASK_PROTOTYPE; \
+ error (INVALID_64BIT, "prototype"); \
+ } \
+ if ((target_flags & MASK_POWERPC64) == 0) \
+ { \
+ target_flags |= MASK_POWERPC64; \
+ error ("64 bit CPU required"); \
+ } \
+ } \
+ } \
+ while (0)
+
+
#undef STARTFILE_DEFAULT_SPEC
#define STARTFILE_DEFAULT_SPEC "%(startfile_freebsd)"
@@ -57,8 +137,11 @@
c-common.c, and config/<arch>/<arch>.h. */
#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
+
/* rs6000.h gets this wrong for FreeBSD. We use the GCC defaults instead. */
#undef WCHAR_TYPE
@@ -75,3 +158,118 @@
/* Override rs6000.h definition. */
#undef ASM_APP_OFF
#define ASM_APP_OFF "#NO_APP\n"
+
+/* Tell the assembler we want 32/64-bit binaries if -m32 or -m64 is passed */
+#if (TARGET_DEFAULT & MASK_64BIT)
+#define SVR4_ASM_SPEC "%(asm_cpu) \
+%{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
+%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
+%{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
+%{memb|msdata|msdata=eabi: -memb} \
+%{mlittle|mlittle-endian:-mlittle; \
+ mbig|mbig-endian :-mbig; \
+ mcall-aixdesc | \
+ mcall-freebsd | \
+ mcall-netbsd | \
+ mcall-openbsd | \
+ mcall-linux | \
+ mcall-gnu :-mbig; \
+ mcall-i960-old :-mlittle}"
+#define LINK_OS_FREEBSD_SPEC_DEF "\
+ %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
+ %{v:-V} \
+ %{assert*} %{R*} %{rpath*} %{defsym*} \
+ %{shared:-Bshareable %{h*} %{soname*}} \
+ %{!static:--enable-new-dtags} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic: -export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
+ %{static:-Bstatic}} \
+ %{symbolic:-Bsymbolic}"
+
+
+#undef ASM_DEFAULT_SPEC
+#undef ASM_SPEC
+#undef LINK_OS_FREEBSD_SPEC
+#define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
+#define ASM_SPEC "%{m32:-a32}%{!m32:-a64} " SVR4_ASM_SPEC
+#define LINK_OS_FREEBSD_SPEC "%{m32:-melf32ppc_fbsd}%{!m32:-melf64ppc_fbsd} " LINK_OS_FREEBSD_SPEC_DEF
+#endif
+
+/* _init and _fini functions are built from bits spread across many
+ object files, each potentially with a different TOC pointer. For
+ that reason, place a nop after the call so that the linker can
+ restore the TOC pointer if a TOC adjusting call stub is needed. */
+#ifdef __powerpc64__
+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
+ asm (SECTION_OP "\n" \
+" bl " #FUNC "\n" \
+" nop\n" \
+" .previous");
+#endif
+
+/* __throw will restore its own return address to be the same as the
+ return address of the function that the throw is being made to.
+ This is unfortunate, because we want to check the original
+ return address to see if we need to restore the TOC.
+ So we have to squirrel it away with this. */
+#define SETUP_FRAME_ADDRESSES() \
+ do { if (TARGET_64BIT) rs6000_aix_emit_builtin_unwind_init (); } while (0)
+
+/* Select a format to encode pointers in exception handling data. CODE
+ is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
+ true if the symbol may be affected by dynamic relocations. */
+#undef ASM_PREFERRED_EH_DATA_FORMAT
+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
+ ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
+ ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
+ | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
+ : DW_EH_PE_absptr)
+
+#ifdef __powerpc64__
+#define MD_FROB_UPDATE_CONTEXT(CTX, FS) \
+ if ((FS)->regs.reg[2].how == REG_UNSAVED) \
+ { \
+ unsigned int *insn = (unsigned int *) \
+ _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM); \
+ if (insn != NULL && *insn == 0xE8410028) \
+ _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \
+ }
+#endif
+
+#define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack
+
+/* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit
+ kernel. This is supported when running on a 64-bit kernel with
+ COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries
+ are compatible. */
+#define OS_MISSING_POWERPC64 !TARGET_64BIT
+
+/* Function profiling bits */
+#undef RS6000_MCOUNT
+#define RS6000_MCOUNT ((TARGET_64BIT) ? "._mcount" : "_mcount")
+#define PROFILE_HOOK(LABEL) \
+ do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
+
+#undef NEED_INDICATE_EXEC_STACK
+#define NEED_INDICATE_EXEC_STACK 1
+
+/* This is how to declare the size of a function. */
+#undef ASM_DECLARE_FUNCTION_SIZE
+#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
+ do \
+ { \
+ if (!flag_inhibit_size_directive) \
+ { \
+ fputs ("\t.size\t", (FILE)); \
+ if (TARGET_64BIT && DOT_SYMBOLS) \
+ putc ('.', (FILE)); \
+ assemble_name ((FILE), (FNAME)); \
+ fputs (",.-", (FILE)); \
+ rs6000_output_function_entry (FILE, FNAME); \
+ putc ('\n', (FILE)); \
+ } \
+ } \
+ while (0)
+
Modified: trunk/contrib/gcc/config/rs6000/rs6000-c.c
===================================================================
--- trunk/contrib/gcc4/config/rs6000/rs6000-c.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/rs6000-c.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -222,17 +222,17 @@
{ ALTIVEC_BUILTIN_VEC_UNPACKH, ALTIVEC_BUILTIN_VUPKHSB,
RS6000_BTI_V8HI, RS6000_BTI_V16QI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKH, ALTIVEC_BUILTIN_VUPKHSB,
- RS6000_BTI_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
+ RS6000_BTI_bool_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKH, ALTIVEC_BUILTIN_VUPKHSH,
RS6000_BTI_V4SI, RS6000_BTI_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKH, ALTIVEC_BUILTIN_VUPKHSH,
- RS6000_BTI_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKH, ALTIVEC_BUILTIN_VUPKHPX,
RS6000_BTI_unsigned_V4SI, RS6000_BTI_pixel_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKHSH, ALTIVEC_BUILTIN_VUPKHSH,
RS6000_BTI_V4SI, RS6000_BTI_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKHSH, ALTIVEC_BUILTIN_VUPKHSH,
- RS6000_BTI_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKHPX, ALTIVEC_BUILTIN_VUPKHPX,
RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKHPX, ALTIVEC_BUILTIN_VUPKHPX,
@@ -240,17 +240,17 @@
{ ALTIVEC_BUILTIN_VEC_VUPKHSB, ALTIVEC_BUILTIN_VUPKHSB,
RS6000_BTI_V8HI, RS6000_BTI_V16QI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKHSB, ALTIVEC_BUILTIN_VUPKHSB,
- RS6000_BTI_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
+ RS6000_BTI_bool_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKL, ALTIVEC_BUILTIN_VUPKLSB,
RS6000_BTI_V8HI, RS6000_BTI_V16QI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKL, ALTIVEC_BUILTIN_VUPKLSB,
- RS6000_BTI_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
+ RS6000_BTI_bool_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKL, ALTIVEC_BUILTIN_VUPKLPX,
RS6000_BTI_unsigned_V4SI, RS6000_BTI_pixel_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKL, ALTIVEC_BUILTIN_VUPKLSH,
RS6000_BTI_V4SI, RS6000_BTI_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_UNPACKL, ALTIVEC_BUILTIN_VUPKLSH,
- RS6000_BTI_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKLPX, ALTIVEC_BUILTIN_VUPKLPX,
RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKLPX, ALTIVEC_BUILTIN_VUPKLPX,
@@ -258,11 +258,11 @@
{ ALTIVEC_BUILTIN_VEC_VUPKLSH, ALTIVEC_BUILTIN_VUPKLSH,
RS6000_BTI_V4SI, RS6000_BTI_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKLSH, ALTIVEC_BUILTIN_VUPKLSH,
- RS6000_BTI_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKLSB, ALTIVEC_BUILTIN_VUPKLSB,
RS6000_BTI_V8HI, RS6000_BTI_V16QI, 0, 0 },
{ ALTIVEC_BUILTIN_VEC_VUPKLSB, ALTIVEC_BUILTIN_VUPKLSB,
- RS6000_BTI_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
+ RS6000_BTI_bool_V8HI, RS6000_BTI_bool_V16QI, 0, 0 },
/* Binary AltiVec builtins. */
{ ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUBM,
@@ -576,31 +576,23 @@
{ ALTIVEC_BUILTIN_VEC_CMPEQ, ALTIVEC_BUILTIN_VCMPEQFP,
RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPEQFP, ALTIVEC_BUILTIN_VCMPEQFP,
- RS6000_BTI_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
+
{ ALTIVEC_BUILTIN_VEC_VCMPEQUW, ALTIVEC_BUILTIN_VCMPEQUW,
- RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
- { ALTIVEC_BUILTIN_VEC_VCMPEQUW, ALTIVEC_BUILTIN_VCMPEQUW,
- RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
- { ALTIVEC_BUILTIN_VEC_VCMPEQUW, ALTIVEC_BUILTIN_VCMPEQUW,
RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPEQUW, ALTIVEC_BUILTIN_VCMPEQUW,
RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
+
{ ALTIVEC_BUILTIN_VEC_VCMPEQUH, ALTIVEC_BUILTIN_VCMPEQUH,
- RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
- { ALTIVEC_BUILTIN_VEC_VCMPEQUH, ALTIVEC_BUILTIN_VCMPEQUH,
- RS6000_BTI_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
- { ALTIVEC_BUILTIN_VEC_VCMPEQUH, ALTIVEC_BUILTIN_VCMPEQUH,
RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPEQUH, ALTIVEC_BUILTIN_VCMPEQUH,
RS6000_BTI_bool_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
+
{ ALTIVEC_BUILTIN_VEC_VCMPEQUB, ALTIVEC_BUILTIN_VCMPEQUB,
- RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
- { ALTIVEC_BUILTIN_VEC_VCMPEQUB, ALTIVEC_BUILTIN_VCMPEQUB,
- RS6000_BTI_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
- { ALTIVEC_BUILTIN_VEC_VCMPEQUB, ALTIVEC_BUILTIN_VCMPEQUB,
RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPEQUB, ALTIVEC_BUILTIN_VCMPEQUB,
RS6000_BTI_bool_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
+
{ ALTIVEC_BUILTIN_VEC_CMPGE, ALTIVEC_BUILTIN_VCMPGEFP,
RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
{ ALTIVEC_BUILTIN_VEC_CMPGT, ALTIVEC_BUILTIN_VCMPGTUB,
@@ -618,29 +610,29 @@
{ ALTIVEC_BUILTIN_VEC_CMPGT, ALTIVEC_BUILTIN_VCMPGTFP,
RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTFP, ALTIVEC_BUILTIN_VCMPGTFP,
- RS6000_BTI_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTSW, ALTIVEC_BUILTIN_VCMPGTSW,
- RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTSW, ALTIVEC_BUILTIN_VCMPGTSW,
RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTUW, ALTIVEC_BUILTIN_VCMPGTUW,
- RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
+ RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTUW, ALTIVEC_BUILTIN_VCMPGTUW,
RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTSH, ALTIVEC_BUILTIN_VCMPGTSH,
- RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
+ RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTSH, ALTIVEC_BUILTIN_VCMPGTSH,
RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTUH, ALTIVEC_BUILTIN_VCMPGTUH,
- RS6000_BTI_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
+ RS6000_BTI_bool_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTUH, ALTIVEC_BUILTIN_VCMPGTUH,
RS6000_BTI_bool_V8HI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTSB, ALTIVEC_BUILTIN_VCMPGTSB,
- RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
+ RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTSB, ALTIVEC_BUILTIN_VCMPGTSB,
RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTUB, ALTIVEC_BUILTIN_VCMPGTUB,
- RS6000_BTI_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
+ RS6000_BTI_bool_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
{ ALTIVEC_BUILTIN_VEC_VCMPGTUB, ALTIVEC_BUILTIN_VCMPGTUB,
RS6000_BTI_bool_V16QI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
{ ALTIVEC_BUILTIN_VEC_CMPLE, ALTIVEC_BUILTIN_VCMPGEFP,
Modified: trunk/contrib/gcc/config/rs6000/rs6000.c
===================================================================
--- trunk/contrib/gcc4/config/rs6000/rs6000.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/rs6000.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -664,6 +664,7 @@
static tree rs6000_builtin_mask_for_load (void);
static void def_builtin (int, const char *, tree, int);
+static bool rs6000_vector_alignment_reachable (tree, bool);
static void rs6000_init_builtins (void);
static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx);
static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx);
@@ -915,6 +916,9 @@
#undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
#define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load
+#undef TARGET_VECTOR_ALIGNMENT_REACHABLE
+#define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable
+
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS rs6000_init_builtins
@@ -1167,11 +1171,9 @@
{"801", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
{"821", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
{"823", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
- {"8540", PROCESSOR_PPC8540,
- POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_STRICT_ALIGN},
+ {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
/* 8548 has a dummy entry for now. */
- {"8548", PROCESSOR_PPC8540,
- POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_STRICT_ALIGN},
+ {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
{"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
{"970", PROCESSOR_POWER4,
POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
@@ -1584,6 +1586,37 @@
return 0;
}
+
+/* Return true iff, data reference of TYPE can reach vector alignment (16)
+ after applying N number of iterations. This routine does not determine
+ how may iterations are required to reach desired alignment. */
+
+static bool
+rs6000_vector_alignment_reachable (tree type ATTRIBUTE_UNUSED, bool is_packed)
+{
+ if (is_packed)
+ return false;
+
+ if (TARGET_32BIT)
+ {
+ if (rs6000_alignment_flags == MASK_ALIGN_NATURAL)
+ return true;
+
+ if (rs6000_alignment_flags == MASK_ALIGN_POWER)
+ return true;
+
+ return false;
+ }
+ else
+ {
+ if (TARGET_MACHO)
+ return false;
+
+ /* Assuming that all other types are naturally aligned. CHECKME! */
+ return true;
+ }
+}
+
/* Handle generic options of the form -mfoo=yes/no.
NAME is the option name.
VALUE is the option value.
@@ -11705,12 +11738,21 @@
try_again = true;
break;
case NE:
- /* Treat A != B as ~(A==B). */
+ case UNLE:
+ case UNLT:
+ case UNGE:
+ case UNGT:
+ /* Invert condition and try again.
+ e.g., A != B becomes ~(A==B). */
{
+ enum rtx_code rev_code;
enum insn_code nor_code;
- rtx eq_rtx = rs6000_emit_vector_compare (EQ, op0, op1,
- dest_mode);
+ rtx eq_rtx;
+ rev_code = reverse_condition_maybe_unordered (rcode);
+ eq_rtx = rs6000_emit_vector_compare (rev_code, op0, op1,
+ dest_mode);
+
nor_code = one_cmpl_optab->handlers[(int)dest_mode].insn_code;
gcc_assert (nor_code != CODE_FOR_nothing);
emit_insn (GEN_FCN (nor_code) (mask, eq_rtx));
@@ -14433,77 +14475,6 @@
sp_offset = info->total_size;
}
- /* Save AltiVec registers if needed. */
- if (!WORLD_SAVE_P (info) && TARGET_ALTIVEC_ABI && info->altivec_size != 0)
- {
- int i;
-
- /* There should be a non inline version of this, for when we
- are saving lots of vector registers. */
- for (i = info->first_altivec_reg_save; i <= LAST_ALTIVEC_REGNO; ++i)
- if (info->vrsave_mask & ALTIVEC_REG_BIT (i))
- {
- rtx areg, savereg, mem;
- int offset;
-
- offset = info->altivec_save_offset + sp_offset
- + 16 * (i - info->first_altivec_reg_save);
-
- savereg = gen_rtx_REG (V4SImode, i);
-
- areg = gen_rtx_REG (Pmode, 0);
- emit_move_insn (areg, GEN_INT (offset));
-
- /* AltiVec addressing mode is [reg+reg]. */
- mem = gen_frame_mem (V4SImode,
- gen_rtx_PLUS (Pmode, frame_reg_rtx, areg));
-
- insn = emit_move_insn (mem, savereg);
-
- rs6000_frame_related (insn, frame_ptr_rtx, info->total_size,
- areg, GEN_INT (offset));
- }
- }
-
- /* VRSAVE is a bit vector representing which AltiVec registers
- are used. The OS uses this to determine which vector
- registers to save on a context switch. We need to save
- VRSAVE on the stack frame, add whatever AltiVec registers we
- used in this function, and do the corresponding magic in the
- epilogue. */
-
- if (TARGET_ALTIVEC && TARGET_ALTIVEC_VRSAVE
- && info->vrsave_mask != 0)
- {
- rtx reg, mem, vrsave;
- int offset;
-
- /* Get VRSAVE onto a GPR. Note that ABI_V4 might be using r12
- as frame_reg_rtx and r11 as the static chain pointer for
- nested functions. */
- reg = gen_rtx_REG (SImode, 0);
- vrsave = gen_rtx_REG (SImode, VRSAVE_REGNO);
- if (TARGET_MACHO)
- emit_insn (gen_get_vrsave_internal (reg));
- else
- emit_insn (gen_rtx_SET (VOIDmode, reg, vrsave));
-
- if (!WORLD_SAVE_P (info))
- {
- /* Save VRSAVE. */
- offset = info->vrsave_save_offset + sp_offset;
- mem = gen_frame_mem (SImode,
- gen_rtx_PLUS (Pmode, frame_reg_rtx,
- GEN_INT (offset)));
- insn = emit_move_insn (mem, reg);
- }
-
- /* Include the registers in the mask. */
- emit_insn (gen_iorsi3 (reg, reg, GEN_INT ((int) info->vrsave_mask)));
-
- insn = emit_insn (generate_set_vrsave (reg, info, 0));
- }
-
/* If we use the link register, get it into r0. */
if (!WORLD_SAVE_P (info) && info->lr_save_p)
{
@@ -14741,7 +14712,19 @@
for which it was done previously. */
if (!WORLD_SAVE_P (info) && info->push_p
&& !(DEFAULT_ABI == ABI_V4 || current_function_calls_eh_return))
- rs6000_emit_allocate_stack (info->total_size, FALSE);
+ {
+ if (info->total_size < 32767)
+ sp_offset = info->total_size;
+ else
+ frame_reg_rtx = frame_ptr_rtx;
+ rs6000_emit_allocate_stack (info->total_size,
+ (frame_reg_rtx != sp_reg_rtx
+ && ((info->altivec_size != 0)
+ || (info->vrsave_mask != 0)
+ )));
+ if (frame_reg_rtx != sp_reg_rtx)
+ rs6000_emit_stack_tie ();
+ }
/* Set frame pointer, if needed. */
if (frame_pointer_needed)
@@ -14751,6 +14734,78 @@
RTX_FRAME_RELATED_P (insn) = 1;
}
+ /* Save AltiVec registers if needed. Save here because the red zone does
+ not include AltiVec registers. */
+ if (!WORLD_SAVE_P (info) && TARGET_ALTIVEC_ABI && info->altivec_size != 0)
+ {
+ int i;
+
+ /* There should be a non inline version of this, for when we
+ are saving lots of vector registers. */
+ for (i = info->first_altivec_reg_save; i <= LAST_ALTIVEC_REGNO; ++i)
+ if (info->vrsave_mask & ALTIVEC_REG_BIT (i))
+ {
+ rtx areg, savereg, mem;
+ int offset;
+
+ offset = info->altivec_save_offset + sp_offset
+ + 16 * (i - info->first_altivec_reg_save);
+
+ savereg = gen_rtx_REG (V4SImode, i);
+
+ areg = gen_rtx_REG (Pmode, 0);
+ emit_move_insn (areg, GEN_INT (offset));
+
+ /* AltiVec addressing mode is [reg+reg]. */
+ mem = gen_frame_mem (V4SImode,
+ gen_rtx_PLUS (Pmode, frame_reg_rtx, areg));
+
+ insn = emit_move_insn (mem, savereg);
+
+ rs6000_frame_related (insn, frame_ptr_rtx, info->total_size,
+ areg, GEN_INT (offset));
+ }
+ }
+
+ /* VRSAVE is a bit vector representing which AltiVec registers
+ are used. The OS uses this to determine which vector
+ registers to save on a context switch. We need to save
+ VRSAVE on the stack frame, add whatever AltiVec registers we
+ used in this function, and do the corresponding magic in the
+ epilogue. */
+
+ if (TARGET_ALTIVEC && TARGET_ALTIVEC_VRSAVE
+ && info->vrsave_mask != 0)
+ {
+ rtx reg, mem, vrsave;
+ int offset;
+
+ /* Get VRSAVE onto a GPR. Note that ABI_V4 might be using r12
+ as frame_reg_rtx and r11 as the static chain pointer for
+ nested functions. */
+ reg = gen_rtx_REG (SImode, 0);
+ vrsave = gen_rtx_REG (SImode, VRSAVE_REGNO);
+ if (TARGET_MACHO)
+ emit_insn (gen_get_vrsave_internal (reg));
+ else
+ emit_insn (gen_rtx_SET (VOIDmode, reg, vrsave));
+
+ if (!WORLD_SAVE_P (info))
+ {
+ /* Save VRSAVE. */
+ offset = info->vrsave_save_offset + sp_offset;
+ mem = gen_frame_mem (SImode,
+ gen_rtx_PLUS (Pmode, frame_reg_rtx,
+ GEN_INT (offset)));
+ insn = emit_move_insn (mem, reg);
+ }
+
+ /* Include the registers in the mask. */
+ emit_insn (gen_iorsi3 (reg, reg, GEN_INT ((int) info->vrsave_mask)));
+
+ insn = emit_insn (generate_set_vrsave (reg, info, 0));
+ }
+
/* If we are using RS6000_PIC_OFFSET_TABLE_REGNUM, we need to set it up. */
if ((TARGET_TOC && TARGET_MINIMAL_TOC && get_pool_size () != 0)
|| (DEFAULT_ABI == ABI_V4
@@ -15008,34 +15063,10 @@
return;
}
- /* If we have a frame pointer, a call to alloca, or a large stack
- frame, restore the old stack pointer using the backchain. Otherwise,
- we know what size to update it with. */
- if (use_backchain_to_restore_sp)
- {
- /* Under V.4, don't reset the stack pointer until after we're done
- loading the saved registers. */
- if (DEFAULT_ABI == ABI_V4)
- frame_reg_rtx = gen_rtx_REG (Pmode, 11);
+ /* Set sp_offset based on the stack push from the prologue. */
+ if (info->total_size < 32767)
+ sp_offset = info->total_size;
- emit_move_insn (frame_reg_rtx,
- gen_rtx_MEM (Pmode, sp_reg_rtx));
- }
- else if (info->push_p)
- {
- if (DEFAULT_ABI == ABI_V4
- || current_function_calls_eh_return)
- sp_offset = info->total_size;
- else
- {
- emit_insn (TARGET_32BIT
- ? gen_addsi3 (sp_reg_rtx, sp_reg_rtx,
- GEN_INT (info->total_size))
- : gen_adddi3 (sp_reg_rtx, sp_reg_rtx,
- GEN_INT (info->total_size)));
- }
- }
-
/* Restore AltiVec registers if needed. */
if (TARGET_ALTIVEC_ABI && info->altivec_size != 0)
{
@@ -15075,6 +15106,36 @@
emit_insn (generate_set_vrsave (reg, info, 1));
}
+ sp_offset = 0;
+
+ /* If we have a frame pointer, a call to alloca, or a large stack
+ frame, restore the old stack pointer using the backchain. Otherwise,
+ we know what size to update it with. */
+ if (use_backchain_to_restore_sp)
+ {
+ /* Under V.4, don't reset the stack pointer until after we're done
+ loading the saved registers. */
+ if (DEFAULT_ABI == ABI_V4)
+ frame_reg_rtx = gen_rtx_REG (Pmode, 11);
+
+ emit_move_insn (frame_reg_rtx,
+ gen_rtx_MEM (Pmode, sp_reg_rtx));
+ }
+ else if (info->push_p)
+ {
+ if (DEFAULT_ABI == ABI_V4
+ || current_function_calls_eh_return)
+ sp_offset = info->total_size;
+ else
+ {
+ emit_insn (TARGET_32BIT
+ ? gen_addsi3 (sp_reg_rtx, sp_reg_rtx,
+ GEN_INT (info->total_size))
+ : gen_adddi3 (sp_reg_rtx, sp_reg_rtx,
+ GEN_INT (info->total_size)));
+ }
+ }
+
/* Get the old lr if we saved it. */
if (info->lr_save_p)
{
@@ -18426,7 +18487,7 @@
static void
rs6000_elf_end_indicate_exec_stack (void)
{
- if (TARGET_32BIT)
+ if (NEED_INDICATE_EXEC_STACK)
file_end_indicate_exec_stack ();
}
#endif
Modified: trunk/contrib/gcc/config/rs6000/rs6000.md
===================================================================
--- trunk/contrib/gcc4/config/rs6000/rs6000.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/rs6000.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -10075,6 +10075,7 @@
""
"
{
+ operands[1] = force_reg (Pmode, operands[1]);
operands[2] = gen_reg_rtx (Pmode);
operands[3] = gen_frame_mem (Pmode, operands[0]);
operands[4] = gen_frame_mem (Pmode, operands[1]);
Modified: trunk/contrib/gcc/config/rs6000/sysv4.h
===================================================================
--- trunk/contrib/gcc4/config/rs6000/sysv4.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/sysv4.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -634,7 +634,7 @@
%{profile: -p}"
/* Don't put -Y P,<path> for cross compilers. */
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#define LINK_PATH_SPEC "\
%{!R*:%{L*:-R %*}} \
%{!nostdlib: %{!YP,*: \
Modified: trunk/contrib/gcc/config/rs6000/tramp.asm
===================================================================
--- trunk/contrib/gcc4/config/rs6000/tramp.asm 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/rs6000/tramp.asm 2018-06-04 17:30:21 UTC (rev 10405)
@@ -115,3 +115,5 @@
FUNC_END(__trampoline_setup)
#endif
+
+ .section .note.GNU-stack,"",%progbits
Modified: trunk/contrib/gcc/config/s390/s390.md
===================================================================
--- trunk/contrib/gcc4/config/s390/s390.md 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/s390/s390.md 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1500,7 +1500,7 @@
&& !s_operand (operands[1], VOIDmode)"
[(set (match_dup 0) (match_dup 1))]
{
- rtx addr = operand_subword (operands[0], 1, 0, DFmode);
+ rtx addr = operand_subword (operands[0], 1, 0, TFmode);
s390_load_address (addr, XEXP (operands[1], 0));
operands[1] = replace_equiv_address (operands[1], addr);
})
@@ -5624,7 +5624,7 @@
"s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
"@
xgr\t%0,%2
- xr\t%0,%2"
+ xg\t%0,%2"
[(set_attr "op_type" "RRE,RXY")])
(define_insn "*xordi3_extimm"
Modified: trunk/contrib/gcc/config/sparc/freebsd.h
===================================================================
--- trunk/contrib/gcc4/config/sparc/freebsd.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/sparc/freebsd.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -19,7 +19,7 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/config/sparc/freebsd.h 238472 2012-07-15 10:54:10Z kib $ */
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
Modified: trunk/contrib/gcc/config/svr4.h
===================================================================
--- trunk/contrib/gcc4/config/svr4.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config/svr4.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -84,7 +84,7 @@
/* Under svr4, the normal location of the `ld' and `as' programs is the
/usr/ccs/bin directory. */
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#undef MD_EXEC_PREFIX
#define MD_EXEC_PREFIX "/usr/ccs/bin/"
#endif
@@ -92,7 +92,7 @@
/* Under svr4, the normal location of the various *crt*.o files is the
/usr/ccs/lib directory. */
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#undef MD_STARTFILE_PREFIX
#define MD_STARTFILE_PREFIX "/usr/ccs/lib/"
#endif
@@ -136,7 +136,7 @@
not being done. */
#undef LINK_SPEC
-#ifdef CROSS_COMPILE
+#ifdef CROSS_DIRECTORY_STRUCTURE
#define LINK_SPEC "%{h*} %{v:-V} \
%{b} \
%{static:-dn -Bstatic} \
Modified: trunk/contrib/gcc/config.gcc
===================================================================
--- trunk/contrib/gcc4/config.gcc 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/config.gcc 2018-06-04 17:30:21 UTC (rev 10405)
@@ -269,12 +269,12 @@
i[34567]86-*-*)
cpu_type=i386
extra_headers="mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h
- pmmintrin.h tmmintrin.h"
+ pmmintrin.h tmmintrin.h ammintrin.h"
;;
x86_64-*-*)
cpu_type=i386
extra_headers="mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h
- pmmintrin.h tmmintrin.h"
+ pmmintrin.h tmmintrin.h ammintrin.h"
need_64bit_hwint=yes
;;
ia64-*-*)
@@ -394,7 +394,7 @@
# the generic ELF configuration of FreeBSD (i.e. it must be
# ordered before that section).
;;
-*-*-freebsd* | *-*-midnightbsd*)
+*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
# machine-specific sections may refine and add to this
# configuration.
@@ -423,13 +423,15 @@
*-*-freebsd6 | *-*-freebsd[6].*)
tm_defines="${tm_defines} FBSD_MAJOR=6" ;;
*-*-freebsd7 | *-*-freebsd[7].*)
- tm_defines="${tm_defines} FBSD_MAJOR=7 MNBSD_MAJOR=1" ;;
+ tm_defines="${tm_defines} FBSD_MAJOR=7" ;;
*-*-freebsd8 | *-*-freebsd[8].*)
tm_defines="${tm_defines} FBSD_MAJOR=8" ;;
*-*-freebsd9 | *-*-freebsd[9].*)
tm_defines="${tm_defines} FBSD_MAJOR=9" ;;
- *-*-midnightbsd0 | *-*-midnightbsd[0].*)
- tm_defines="${tm_defines} MNBSD_MAJOR=1" ;;
+ *-*-freebsd10 | *-*-freebsd10.*)
+ tm_defines="${tm_defines} FBSD_MAJOR=10" ;;
+ *-*-freebsd11 | *-*-freebsd11.*)
+ tm_defines="${tm_defines} FBSD_MAJOR=11" ;;
*)
echo 'Please update *-*-freebsd* in gcc/config.gcc'
exit 1
@@ -1211,7 +1213,7 @@
# FIXME: -m64 for i[34567]86-*-* should be allowed just
# like -m32 for x86_64-*-*.
case X"${with_cpu}" in
- Xgeneric|Xcore2|Xnocona|Xx86-64|Xk8|Xopteron|Xathlon64|Xathlon-fx)
+ Xgeneric|Xcore2|Xnocona|Xx86-64|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx)
;;
X)
with_cpu=generic
@@ -1218,7 +1220,7 @@
;;
*)
echo "Unsupported CPU used in --with-cpu=$with_cpu, supported values:" 1>&2
- echo "generic core2 nocona x86-64 k8 opteron athlon64 athlon-fx" 1>&2
+ echo "generic core2 nocona x86-64 amdfam10 barcelona k8 opteron athlon64 athlon-fx" 1>&2
exit 1
;;
esac
@@ -2517,6 +2519,9 @@
;;
i686-*-* | i786-*-*)
case ${target_noncanonical} in
+ amdfam10-*|barcelona-*)
+ with_cpu=amdfam10
+ ;;
k8-*|opteron-*|athlon_64-*)
with_cpu=k8
;;
@@ -2557,6 +2562,9 @@
;;
x86_64-*-*)
case ${target_noncanonical} in
+ amdfam10-*|barcelona-*)
+ with_cpu=amdfam10
+ ;;
k8-*|opteron-*|athlon_64-*)
with_cpu=k8
;;
@@ -2797,7 +2805,7 @@
esac
# OK
;;
- "" | k8 | opteron | athlon64 | athlon-fx | nocona | core2 | generic)
+ "" | amdfam10 | barcelona | k8 | opteron | athlon64 | athlon-fx | nocona | core2 | generic)
# OK
;;
*)
Modified: trunk/contrib/gcc/configure
===================================================================
--- trunk/contrib/gcc4/configure 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/configure 2018-06-04 17:30:21 UTC (rev 10405)
@@ -13151,7 +13151,8 @@
esac
done
-# Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
+# Define macro CROSS_DIRECTORY_STRUCTURE in compilation if this is a
+# cross-compiler which does not use the native headers and libraries.
# Also use all.cross instead of all.internal and adjust SYSTEM_HEADER_DIR.
CROSS=
ALL=all.internal
@@ -13168,7 +13169,7 @@
if test x$host != x$target
then
- CROSS="-DCROSS_COMPILE"
+ CROSS="-DCROSS_DIRECTORY_STRUCTURE"
ALL=all.cross
SYSTEM_HEADER_DIR=$build_system_header_dir
case "$host","$target" in
Modified: trunk/contrib/gcc/configure.ac
===================================================================
--- trunk/contrib/gcc4/configure.ac 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/configure.ac 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1729,7 +1729,8 @@
esac
done
-# Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
+# Define macro CROSS_DIRECTORY_STRUCTURE in compilation if this is a
+# cross-compiler which does not use the native headers and libraries.
# Also use all.cross instead of all.internal and adjust SYSTEM_HEADER_DIR.
CROSS= AC_SUBST(CROSS)
ALL=all.internal AC_SUBST(ALL)
@@ -1746,7 +1747,7 @@
if test x$host != x$target
then
- CROSS="-DCROSS_COMPILE"
+ CROSS="-DCROSS_DIRECTORY_STRUCTURE"
ALL=all.cross
SYSTEM_HEADER_DIR=$build_system_header_dir
case "$host","$target" in
Modified: trunk/contrib/gcc/convert.c
===================================================================
--- trunk/contrib/gcc4/convert.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/convert.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -64,17 +64,66 @@
case BOOLEAN_TYPE:
if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE)
expr = fold_build1 (NOP_EXPR,
- lang_hooks.types.type_for_size (POINTER_SIZE, 0),
+ lang_hooks.types.type_for_size (POINTER_SIZE, 0),
expr);
return fold_build1 (CONVERT_EXPR, type, expr);
+ /* APPLE LOCAL begin blocks (C++ ck) */
+ case BLOCK_POINTER_TYPE:
+ /* APPLE LOCAL begin radar 5809099 */
+ if (objc_is_id (type)
+ || (TREE_CODE (type) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type))))
+ /* APPLE LOCAL end radar 5809099 */
+ return fold_build1 (NOP_EXPR, type, expr);
+ /* APPLE LOCAL end blocks (C++ ck) */
+ default:
+ error ("cannot convert to a pointer type");
+ return convert_to_pointer (type, integer_zero_node);
+ }
+}
- default:
- error ("cannot convert to a pointer type");
- return convert_to_pointer (type, integer_zero_node);
+/* APPLE LOCAL begin blocks (C++ ck) */
+tree
+convert_to_block_pointer (tree type, tree expr)
+{
+ if (TREE_TYPE (expr) == type)
+ return expr;
+
+ if (integer_zerop (expr))
+ {
+ tree t = build_int_cst (type, 0);
+ if (TREE_OVERFLOW (expr) || TREE_CONSTANT_OVERFLOW (expr))
+ t = force_fit_type (t, 0, TREE_OVERFLOW (expr),
+ TREE_CONSTANT_OVERFLOW (expr));
+ return t;
}
+
+ switch (TREE_CODE (TREE_TYPE (expr)))
+ {
+ case BLOCK_POINTER_TYPE:
+ return fold_build1 (NOP_EXPR, type, expr);
+
+ case INTEGER_TYPE:
+ if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE)
+ expr = fold_build1 (NOP_EXPR,
+ lang_hooks.types.type_for_size (POINTER_SIZE, 0),
+ expr);
+ return fold_build1 (CONVERT_EXPR, type, expr);
+
+ case POINTER_TYPE:
+ /* APPLE LOCAL radar 5809099 */
+ if (objc_is_id (TREE_TYPE (expr)) || VOID_TYPE_P (TREE_TYPE (TREE_TYPE (expr))))
+ return build1 (NOP_EXPR, type, expr);
+ /* fall thru */
+
+ default:
+ error ("cannot convert to a block pointer type");
+ return convert_to_block_pointer (type, integer_zero_node);
+ }
}
+/* APPLE LOCAL end blocks (C++ ck) */
+
/* Avoid any floating point extensions from EXP. */
tree
strip_float_extensions (tree exp)
@@ -459,6 +508,8 @@
{
case POINTER_TYPE:
case REFERENCE_TYPE:
+ /* APPLE LOCAL radar 6035389 */
+ case BLOCK_POINTER_TYPE:
if (integer_zerop (expr))
return build_int_cst (type, 0);
Modified: trunk/contrib/gcc/convert.h
===================================================================
--- trunk/contrib/gcc4/convert.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/convert.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -26,5 +26,7 @@
extern tree convert_to_real (tree, tree);
extern tree convert_to_complex (tree, tree);
extern tree convert_to_vector (tree, tree);
+/* APPLE LOCAL blocks */
+extern tree convert_to_block_pointer (tree, tree);
#endif /* GCC_CONVERT_H */
Modified: trunk/contrib/gcc/coverage.c
===================================================================
--- trunk/contrib/gcc4/coverage.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/coverage.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -429,57 +429,75 @@
static unsigned
coverage_checksum_string (unsigned chksum, const char *string)
{
- int i;
char *dup = NULL;
+ char *ptr;
/* Look for everything that looks if it were produced by
- get_file_function_name_long and zero out the second part
+ get_file_function_name and zero out the second part
that may result from flag_random_seed. This is not critical
as the checksums are used only for sanity checking. */
- for (i = 0; string[i]; i++)
+#define GLOBAL_PREFIX "_GLOBAL__"
+#define TRAILING_N "N_"
+#define ISCAPXDIGIT(a) (((a) >= '0' && (a) <= '9') || ((a) >= 'A' && (a) <= 'F'))
+ if ((ptr = strstr (string, GLOBAL_PREFIX)))
{
- int offset = 0;
- if (!strncmp (string + i, "_GLOBAL__N_", 11))
- offset = 11;
- if (!strncmp (string + i, "_GLOBAL__", 9))
- offset = 9;
+ /* Skip _GLOBAL__. */
+ ptr += strlen (GLOBAL_PREFIX);
- /* C++ namespaces do have scheme:
- _GLOBAL__N_<filename>_<wrongmagicnumber>_<magicnumber>functionname
- since filename might contain extra underscores there seems
- to be no better chance then walk all possible offsets looking
- for magicnuber. */
- if (offset)
- {
- for (i = i + offset; string[i]; i++)
- if (string[i]=='_')
- {
- int y;
+ /* Skip optional N_ (in case __GLOBAL_N__). */
+ if (!strncmp (ptr, TRAILING_N, strlen (TRAILING_N)))
+ ptr += strlen (TRAILING_N);
+ /* At this point, ptr should point after "_GLOBAL__N_" or "_GLOBAL__". */
- for (y = 1; y < 9; y++)
- if (!(string[i + y] >= '0' && string[i + y] <= '9')
- && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
- break;
- if (y != 9 || string[i + 9] != '_')
- continue;
- for (y = 10; y < 18; y++)
- if (!(string[i + y] >= '0' && string[i + y] <= '9')
- && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
- break;
- if (y != 18)
- continue;
- if (!dup)
- string = dup = xstrdup (string);
- for (y = 10; y < 18; y++)
- dup[i + y] = '0';
- }
- break;
- }
+ while ((ptr = strchr (ptr, '_')) != NULL)
+ {
+ int y;
+ /* For every "_" in the rest of the string,
+ try the follwing pattern matching */
+
+ /* Skip over '_'. */
+ ptr++;
+#define NDIGITS (8)
+ /* Try matching the pattern:
+ <8-digit hex>_<8-digit hex>
+ The second number is randomly generated
+ so we want to mask it out before computing the checksum. */
+ for (y = 0; *ptr != 0 && y < NDIGITS; y++, ptr++)
+ if (!ISCAPXDIGIT (*ptr))
+ break;
+ if (y != NDIGITS || *ptr != '_')
+ continue;
+ /* Skip over '_' again. */
+ ptr++;
+ for (y = 0; *ptr != 0 && y < NDIGITS; y++, ptr++)
+ if (!ISCAPXDIGIT (*ptr))
+ break;
+
+ if (y == NDIGITS)
+ {
+ /* We have a match.
+ Duplicate the string and mask out
+ the second 8-digit number. */
+ dup = xstrdup (string);
+ ptr = dup + (ptr - string);
+ for(y = -NDIGITS - 1 ; y < 0; y++)
+ {
+ ptr[y] = '0';
+ }
+ ptr = dup;
+ break;
+ }
+ }
+ /* "ptr" should be NULL if we couldn't find the match
+ (strchr will return NULL if no match is found),
+ or it should point to dup which contains the string
+ with the random part masked. */
}
- chksum = crc32_string (chksum, string);
+ chksum = crc32_string (chksum, (ptr) ? ptr : string);
+
if (dup)
- free (dup);
+ free (dup);
return chksum;
}
Added: trunk/contrib/gcc/cp/ChangeLog.apple
===================================================================
--- trunk/contrib/gcc/cp/ChangeLog.apple (rev 0)
+++ trunk/contrib/gcc/cp/ChangeLog.apple 2018-06-04 17:30:21 UTC (rev 10405)
@@ -0,0 +1,674 @@
+2008-11-07 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5847976
+ * decl.c (synth_block_byref_id_object_copy_func): Takes new 'flag' argument
+ and produces the new much simplified API.
+ (synth_block_byref_id_object_dispose_func): Ditto.
+ (new_block_byref_decl): Turn off -fobjc-gc so we don't get
+ bogus warning on field declared as __weak.
+ (init_byref_decl): Takes a new 'flag' argument and passes
+ it down to synth_block_byref_id_object_copy_func and
+ synth_block_byref_id_object_dispose_func.
+ (cp_finish_decl): Calculates the flag for the block
+ variable declaration and passes it down to init_byref_decl.
+ * parser.c (build_block_struct_initlist): Removes call to
+ copy_in_object (not needed).
+ (synth_copy_helper_block_func): Produce the new, simplified
+ API.
+ (synth_destroy_helper_block_func): Ditto.
+ (build_block_byref_decl): Copy over COPYABLE_WEAK_BLOCK flag.
+
+2008-10-31 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6175959
+ * parser.c (synth_copy_helper_block_func): Use the new API
+ _Block_object_assign for ObjC object copying.
+ (block_object_dispose): New
+ (synth_destroy_helper_block_func): Call block_object_dispose
+ to use new _Block_object_dispose API for ObjC object release.
+
+2008-10-27 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6231433
+ * typeck.c (objc_compare_types, objc_have_common_type):
+ Take an extra argument for better diagnostics.
+ * call.c: Ditto
+
+2010-03-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7760213
+ * semantics.c (get_final_block_variable): Diagnose
+ access of __block array.
+
+2010-03-12 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7735196
+ * cp/parser.c (build_block_struct_initlist):
+ Set BLOCK_USE_STRET flag in block descriptor for
+ blocks which return their aggregate value in memory.
+
+2010-03-05 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 7721728
+ * semantics.c (get_final_block_variable): Diagnose
+ importation of copied-in variables.
+
+2009-02-11 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6573923
+ * decl.c (synth_block_byref_id_object_copy_func,
+ synth_block_byref_id_object_dispose_func): Set BLOCK_BYREF_CALLER
+ flag in call to copy/dispose helper functions.
+
+2009-02-11 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6545782
+ * semantics.c (get_final_block_variable): New
+ (finish_id_expression): Call get_final_block_variable.
+
+2008-10-27 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6302949
+ * parser.c (objc_cp_parser_at_property): Warn on missing
+ ',' separator for property attribute list.
+
+2008-10-24 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6305545
+ * semantics.c (expand_or_defer_fn): Lower nested function
+ of the structors.
+
+2008-10-24 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5847213 (minor tweak)
+ * parser.c (build_block_descriptor_type):
+ Make descriptor_ptr_type and descriptor_ptr_type_with_copydispose
+ visible to pch.
+
+2008-10-17 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6289031
+ * decl.c: Removed all code related to
+ radar 6083129 (byref escapes).
+
+2008-10-15 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6271728
+ * parser.c (cp_parser_objc_method_definition_list): Method
+ definition always start with '{', or it is error.
+
+2008-10-14 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6275956
+ * semantics.c (finish_this_expr): Reference to "this" in a block
+ must be looked up.
+
+2008-10-10 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5847213 - New Block ABI
+
+ * typeck.c (build_block_call): New code gen for block call.
+ * parser.c (build_descriptor_block_decl) New
+ (build_block_struct_type): New block literal type.
+ (build_block_struct_initlist): New block literal initializers.
+ (build_block_literal_tmp): New block literal variable initialization.
+ (synth_copy_helper_block_func): Fixed a minor bug (unrelated to this radar).
+ (build_block_internal_types): Removed.
+ (build_block_descriptor_type): New routine to build build descriptor type.
+ (make_block_pointer_declarator): Unnecessary code is removed.
+
+2008-10-02 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6246527
+ * parser.c (cp_parser_block_literal_expr): Call to do the delta
+ on printf attribute.
+
+2008-09-30 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6230297
+ * c-parser.c (build_block_struct_initlist): 'trivial'
+ block temporary can be static as well.
+ (build_block_literal_tmp): Accomodate 'trivial' block
+ literal temporary variable as static.
+
+2008-09-30 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6230297
+ * parser.c (build_block_struct_initlist): 'trivial'
+ block temporary can be static as well.
+ (build_block_literal_tmp): Accomodate 'trivial' block
+ literal temporary variable as static.
+
+2008-09-30 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6225809
+ * parser.c (build_block_byref_decl): Add __block vaiables
+ to intervening blocks.
+
+2008-09-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6154598
+ tree.c (maybe_dummy_object): Build expression for
+ copied in "this" in the block.
+
+2008-09-26 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6243400
+ * parser.c (build_block_struct_type): Mostly rewritten
+ to use C++'s API for building block's main struct so structors
+ for those data members requiring them are synthesized and
+ used.
+
+2008-09-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6244520
+ * decl.c (new_block_byref_decl): New field added to
+ struct __Block_byref_x.
+ (init_byref_decl): Above field initialized to NULL.
+
+2008-09-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6237713
+ * parser.c (cp_parser_block_literal_expr): Parse
+ and set attribute on block literals.
+
+2008-09-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6214617
+ * parser.c (cp_block_requires_copying): New
+ (build_block_struct_type): Set BlockImportsCxxObjects flag.
+ (build_block_struct_initlist): Set BLOCK_HAS_CXX_OBJ if need be.
+ (synth_copy_helper_block_func): Call copy ctor if copied in object has one.
+ (synth_destroy_helper_block_func): Call dtor on cxx object.
+
+2008-09-12 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6212722 (tweak)
+ * parser.c (build_block_ref_decl): Use decay_conversion.
+
+2008-09-09 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6169580
+ * decl.c (synth_block_byref_id_object_copy_func): Pass new flag
+ to finish_function.
+ (synth_block_byref_id_object_): Ditto.
+ (finish_function): Don't pop the nested class when synthesizing
+ block helpers.
+ * semantics.c (finish_id_expression): Added logic to attach
+ copied-in "this" to stand-alone field reference in a block.
+ * parser.c (synth_copy_helper_block_func, synth_destroy_helper_block_func):
+ Pass new flag to finish_function.
+ (cp_parser_block_literal_expr): When block is in non-static member
+ function, need to import "this" as a read-only copied in variable.
+
+2008-09-05 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6169527
+ * parser.c (build_block_struct_type): Set CLASSTYPE_AS_BASE.
+ (build_block_internal_types): Ditto.
+ (build_block_struct_initlist): Rewritten.
+ (build_block_literal_tmp): Rewritten.
+ (build_block_ref_decl): Just add copied-in variable to
+ the scope.
+ (declare_block_prologue_local_vars): Rewritten.
+ (declare_block_prologue_local_byref_vars): New
+ (block_build_prologue): Call declare_block_prologue_local_byref_vars
+ for byref variables.
+
+2008-09-03 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6185344
+ * typeck.c (check_return_expr): Added extra check
+ for return type checking.
+ * parser.c (cp_parser_direct_declarator): Added
+ extra check for type used as block return type.
+ (cp_parser_block_literal_expr): Parse and handle
+ user provided block return type syntax.
+
+2008-08-28 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6160536
+ * parser.c (cp_parser_block_literal_expr): Call build_block_helper_name
+ to get pretty name for block helper function.
+
+2008-08-28 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6180456
+ * decl.c (synth_block_byref_id_object_copy_func): Use different
+ API when copying __block object in c language.
+ (synth_block_byref_id_object_dispose_func): Use different
+ API when releasing a __block object in c.
+ * parser.c (synth_copy_helper_block_func): Refactored to
+ call build_block_byref_assign_copy_decl().
+
+2008-08-27 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6087117
+ * typeck.c (convert_arguments): Takes an extra argument
+ for distiguinsing block call to function calls.
+ (build_function_call): Tell convert_arguments if we
+ are calling a block.
+
+2008-08-24 Caroline Tice <ctice at apple.com.
+
+ Radar 6144664
+ * parser.c (build_block_byref_decl): Assign the
+ source location for each byref decl to the source
+ location of the helper function decl.
+ (build_block_ref_decl): Ditto for ref decls.
+
+2008-07-21 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6029624
+ * call.c (objcp_reference_related_p): New
+ * cp-tree.h (objcp_reference_related_p): New decl.
+
+2008-06-05 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5982990
+ * parser.c (cp_parser_compound_statement): Take a new
+ argument which is used to call objc_mark_locals_volatile.
+ (cp_parser_primary_expression, cp_parser_statement,
+ etc.): add extra argument in calling cp_parser_compound_statement.
+ (cp_parser_objc_synchronized_statement): Passes
+ flag_objc_sjlj_exceptions as last argument in calling
+ cp_parser_compound_statement.
+
+2008-03-20 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5802025
+ * typeck.c (finish_class_member_access_expr): Generate getter call
+ from an OBJC_PROPERTY_REFERENCE_EXPR.
+
+2008-03-19 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5733674
+ * decl.c (expand_static_init): Generate write barrier for
+ static initialization in objective-c++ mode.
+
+2008-02-20 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5732232 - code gen part 2.
+ * cp-lang.c (c_finish_return): Defined these
+ templates to get a clean compile.
+
+2007-08-22 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4947311
+ * parser.c (cp_parser_objc_protocol_declaration): Takes attribute list
+ as extra argument and passes it down to
+ objc_declare_protocols/objc_start_protocol.
+ (cp_parser_objc_class_interface): Now receives attribute list as input.
+ (cp_parser_objc_declaration): Parses attribute list and passes it down
+ to cp_parser_objc_class_interface/cp_parser_objc_protocol_declaration.
+
+2007-07-13 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5277239
+ * parser.c (cp_parser_objc_reference_expression): New routine to
+ build a property reference expression.
+ (cp_objc_property_reference_prefix): New routine to recognize a
+ property dot syntax.
+ (cp_parser_primary_expression): Build a property reference expression
+ when a property dot-syntax is recognized.
+ (cp_parser_type_name): Exclude property dot-syntax from being recognized
+ as a type name.
+ (cp_parser_class_name): Exclude property dot-syntax from being recognized
+ as a class name.
+
+2007-07-10 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5285911
+ * typeck.c (finish_class_member_access_expr): Call
+ objc_build_property_reference_expr instead of objc_build_getter_call.
+
+2007-06-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5276085
+ * typeck.c (build_modify_expr): Call objc_weak_reference_expr
+ instead of objc_remove_weak_read.
+ * parser.c (cp_parser_cast_expression): Call
+ objc_build_weak_reference_tree instead of objc_generate_weak_read.
+ (cp_parser_cast_expression): Ditto.
+
+2007-05-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5202926
+ * mangle.c (write_mangled_name): Removed suppression in last patch.
+
+2007-04-20 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5130983
+ * c-common.h (enum lvalue_use): New enumerator lv_foreach
+ added.
+ * c-common.c (lvalue_error): Diagnose on lv_foreach.
+
+2007-04-20 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 5130983
+ * parser.c (cp_parser_parse_foreach_stmt): Parse selector expression
+ as an expression.
+ (objc_foreach_stmt): Issue diagnostic on non-lavlue selector
+ expression.
+
+2007-03-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4947014 - objc atomic property
+ * lex.c (RID_NONATOMIC): Add
+ * parser.c (objc_cp_parser_at_property): Recognize 'nonatomic' as
+ new property attribute.
+
+2007-03-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4564694
+ * lex.c (RID_AT_PACKAGE): Add
+ * parser.c (cp_lexer_get_preprocessor_token): Parse @package.
+
+2006-12-14 Fariborz Jahanian <fjahania at apple.com>
+
+ Radar 4854605
+ * parser.c (objc_foreach_stmt): Set iterator
+ to nil.
+
+2006-09-01 Fariborz Jahanian <fjahania at apple.com>
+
+ Radar 4712269
+ * typeck.c (build_unary_op): Call objc_build_incr_decr_setter_call
+ for potential ince/decr pre/post expressions involving properties.
+
+2006-07-21 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4631818
+ * parser.c (cp_parser_parse_foreach_stmt): New.
+ (cp_parser_iteration_statement): Remove old code.
+ Replace it with call to cp_parser_parse_foreach_stmt.
+ (cp_parser_simple_declaration): Remove old code.
+ (cp_parser_init_declarator): Remove old code.
+
+2006-08-31 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4697411
+ * typeck.c (build_class_member_access_expr): Call
+ objc_volatilize_component_ref.
+
+2006-07-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4592503
+ * class.c (layout_class_type): Check on illegal use of __weak
+ on struct fields.
+ * decl.c (start_decl): Check on illegal use of __weak on
+ variable declarations.
+
+2006-07-14 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4621020
+ * lex.c (reswords): Added entry for 'weak' attribute keyword.
+ * parser.c (objc_cp_parser_at_property): Recorgnize 'weak'attribute.
+
+2006-06-26 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4591909
+ * lex.c (reswords): New entry for 'dynamic' attribute.
+ * parser.c (objc_cp_parser_at_property): Change to parse new
+ attribute syntax.
+
+2006-05-18 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4548636 (objc attributes on class)
+ * parser.c (objc_attr_follwed_by_at_keyword): New routine to disambiguate
+ attribute before a type and attribute before an @interface declaration..
+ (cp_parser_declaration): Handle case of attribute list which can be
+ followed by an @interface.
+ (cp_parser_objc_class_interface): Parse possible attribute list before
+ parsing @interface.
+ (cp_parser_objc_declaration): Recognize 'attribute' as a valid token which
+ can start an @interface declaration.
+
+2006-05-16 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4547045
+ * parser.c (objc_foreach_stmt): Fix a thinko.
+
+2006-04-12 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4507230
+ * parser.c (objc_foreach_stmt): Check for valid objc
+ objects in foreach header.
+
+2006-04-06 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4436866
+ (Missing copies attribute)
+ * lex.c (reswords): New keyword 'copies' added.
+ * parser.c (objc_cp_parser_at_property): Parse 'copies'
+ attribute.
+
+2006-02-15 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4445586
+ * semantics.c (begin_do_stmt): DO_STMT nodes take an
+ extra argument to build.
+
+2005-11-08 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4330422
+
+ * typeck.c (comp_ptr_ttypes_real): Remove the hack. un-volatize the
+ artificially 'volatized' type before doing pointer comparison.
+
+2005-08-15 Ziemowit Laski <zlaski at apple.com>
+
+ Radar 4093475
+ * parser.c (cp_parser_objc_interstitial_code): Catch stray
+ '{' and '}' tokens and issue appropriate errors.
+ (cp_parser_objc_method_prototype_list,
+ cp_parser_objc_method_definition_list): Bail out if end-of-file
+ is seen; issue error if trailing '@end' is not seen.
+
+2008-08-06 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305 - work in progress.
+ * parser.c (clean_and_exit): Clean up if inside
+ a function.
+ (cp_parser_block_literal_expr): Set DECL_NO_STATIC_CHAIN
+ if inside a function.
+
+2008-08-05 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305 - work in progress.
+ * decl.c (init_byref_decl): Generate c-style helper
+ functions for compose/dispose helpers.
+
+2008-08-04 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305 - work in progress.
+ * decl.c (synth_block_byref_id_object_copy_func,
+ synth_block_byref_id_object_dispose_func,
+ block_start_struct, block_finish_struct,
+ new_block_byref_decl, init_byref_decl): New routines.
+ (cp_finish_decl): Build the APIed version of
+ a __byref local vriable.
+ * semantics.c (finish_id_expression): Add a __byref
+ variable to the list of such variables for current
+ block.
+ * parser.c (build_component_ref): Fix to make it work.
+ (cp_parser_block_literal_expr): Push/pop language-c,
+ set context of the helper function.
+ (declare_block_prologue_local_vars): Mend tree for
+ the built-in local variables in the helper prologue.
+
+2008-07-30 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305
+ * call.c (standard_conversion): Allow conversion of 'id'
+ type to a block pointer.
+
+2008-07-30 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305
+ * typeck.c (build_block_call): New
+ (build_function_call): Call build_block_call
+ for block calls.
+ * call.c (standard_conversion): Remove "void *" to
+ block pointer conversion.
+
+2008-07-29 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305
+ * call.c (standard_conversion): Allow assignment of
+ "void *" to block pointer object.
+
+2008-07-28 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6040305
+ * typeck.c (comptypes): block-pointer types'
+ return type get special treatment.
+
+2008-07-16 Eugene Marinelli <marinelli at apple.com>
+
+ Radar 5559195
+ * decl.c (cxx_maybe_build_cleanup): When considering whether to
+ build a cleanup for a class type, use
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY and
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE instead of
+ TYPE_HAS_NONTRIVIAL_DESTRUCTOR to determine whether it must be
+ output.
+
+2008-07-15 Eugene Marinelli <marinelli at apple.com>
+
+ Radar 5559195
+ * cp-tree.h (struct lang_type_class): Add destructor_triviality_final
+ flag to mark when has_nontrivial_destructor_body and
+ destructor_nontrivial_because_of_base are final. Add accessor for
+ this flag.
+ * parser.c (cp_parser_statement_seq_opt): Use
+ CLASSTYPE_DESTRUCTOR_TRIVIALITY_FINAL to determine if
+ destructor should be checked for being empty, and set it if
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY is changed.
+
+2008-07-10 Eugene Marinelli <marinelli at apple.com>
+
+ Radar 5559195
+ * init.c (push_base_cleanups): Check flags indicating whether
+ destructor of base class has a nontrivial body, has a base destructor
+ that must be called, or is private to determine whether it should be
+ called by the derived class. Set
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE to 1 if it has
+ members that must be deleted.
+ * class.c (check_bases, finish_struct_bits,
+ add_implicitly_declared_members): Set
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE and
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY based on base classes.
+ (check_methods): Set CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY to 1
+ whenever a user-declared destructor is seen as a conservative
+ assumption.
+ * cp-tree.h (struct lang_type_class): Add
+ has_nontrivial_destructor_body and
+ destructor_nontrivial_because_of_base flags. Decrement remaining
+ dummy bits. Add accessors for these flags.
+ * parser.c (cp_parser_statement_seq_opt): Unmark
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY and then set it again only if
+ a statement is parsed.
+
+2007-05-07 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4157812
+ * parser.c (cp_parser_objc_method_keyword_params): Recognize optional
+ method argument attribute.
+
+2007-03-21 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 2848255
+ * except.c (do_begin_catch): Take a new argument to decide
+ to call objc_begin_catch for objc exceptions.
+ (objcp_build_eh_type_type): New.
+ (do_end_catch): Call objc_end_catch for objc type
+ exceptions.
+ (expand_start_catch_block): Add new argument to do_begin_catch call.
+ (build_throw): Call objc_throw_exception for throwing objc type objects.
+ * cp-tree.h (objc2_valid_objc_catch_type, objcp_build_eh_type_type):
+ New extern decl.
+ * parser.c (cp_parser_objc_try_catch_finally_stateme): Add syntax for
+ @catch(...).
+
+2006-04-26 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 3803157 (method attributes)
+ * parser.c (cp_parser_objc_maybe_attributes): New.
+ (cp_parser_objc_method_keyword_params): Parse attributes at end
+ of method declaration.
+ (cp_parser_objc_method_tail_params_opt): Parse attributes after
+ '...'.
+ (cp_parser_objc_method_signature): Retreive method attribute for
+ the caller.
+ (cp_parser_objc_method_prototype_list): Pass new arg. to
+ cp_parser_objc_method_signature and pass attributes to
+ objc_add_method_declaration.
+ (cp_parser_objc_method_definition_list): Pass new arg. to
+ cp_parser_objc_method_signature and pass attributes to
+ objc_start_method_definition.
+
+2006-03-27 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4133425
+ * lex.c (unqualified_name_lookup_error): Issue diagnostic
+ for private 'ivar' access.
+
+2006-02-02 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4426814
+ * typeck.c (build_modify_expr): Undo call to objc_read_weak
+ on LHS of the assignment.
+ * parser.c (cp_parser_cast_expression): Central place to add
+ objc_read_weak call on expressions of __weak objects.
+
+2005-12-15 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4229905
+ * typeck.c (composite_pointer_type): Call objc_have_common_type
+ when comparing two objective-c pointer types.
+
+2005-10-17 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 4290840
+
+ * parser.c (cp_parser_objc_method_keyword_params): Check for valid
+ method parameters and issue error.
+ (cp_parser_objc_method_definition_list): Check for invalid tokens
+ which cannot start a function definition.
+
+2005-08-02 Ziemowit Laski <zlaski at apple.com>
+
+ Radar 4185810
+ * parser.c (cp_parser_compound_statement): Continue
+ parsing even if the initial '{' is missing; an error
+ message is already being produced.
+ (cp_parser_statement_seq_opt): In addition to '}' and
+ end-of-file, a statement sequence may also be terminated
+ by a stray 'else' or '@end'.
+
+ # APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+2007-08-03 Geoffrey Keating <geoffk at apple.com>
+
+ Radar 5295549
+ * parser.c (cp_parser_iteration_statement): Handle attributes.
+ * semantics.c (begin_for_stmt): Put attributes in built tree.
+ (begin_while_stmt): Put attributes in built tree.
+ (begin_do_stmt): Put attributes in built tree.
+ * pt.c (tsubst_expr): Handle attributes for FOR_STMT, WHILE_STMT,
+ DO_STMT.
+ * cp-gimplify.c (gimplify_cp_loop): Handle attributes.
+ (gimplify_for_stmt): Pass attributes to gimplify_cp_loop.
+ (gimplify_while_stmt): Pass attributes to gimplify_cp_loop.
+ (gimplify_do_stmt): Pass attributes to gimplify_cp_loop.
+ * dump.c (cp_dump_tree): Dump attributes for FOR_STMT, WHILE_STMT,
+ DO_STMT.
+ * cp-tree.h (begin_while_stmt): Update prototype.
+ (begin_do_stmt): Likewise.
+ (begin_for_stmt): Likewise.
+ * cp-tree.def (FOR_STMT): Add extra parameter.
+ (WHILE_STMT): Likewise.
+ (DO_STMT): Likewise.
+ * init.c (build_vec_init): Update for change to begin_for_stmt.
+
+ # APPLE LOCAL end for-fsf-4_4 3274130 5295549
Added: trunk/contrib/gcc/cp/ChangeLog.gcc43
===================================================================
--- trunk/contrib/gcc/cp/ChangeLog.gcc43 (rev 0)
+++ trunk/contrib/gcc/cp/ChangeLog.gcc43 2018-06-04 17:30:21 UTC (rev 10405)
@@ -0,0 +1,108 @@
+2007-07-09 Geoffrey Keating <geoffk at apple.com> (r126529)
+
+ PR 32617
+ * decl.c (cxx_init_decl_processing): Don't set
+ force_align_functions_log.
+ (grokfndecl): Honour ptrmemfunc_vbit_in_pfn.
+ * typeck.c (cxx_alignof_expr): When alignof is used on a plain
+ FUNCTION_DECL, return its alignment.
+
+2007-07-01 Ollie Wild <aaw at google.com> (r126177)
+
+ * name-lookup.c (ambiguous_decl): Fix case when new->value is hidden.
+ (select_decl): Remove function.
+ (unqualified_namespace_lookup): Populate binding by calling
+ ambiguous_decl. Remove select_decl call.
+ (lookup_qualified_name): Remove select_decl call.
+ * decl.c (lookup_and_check_tag): Check for ambiguous references.
+ * parser.c (cp_parser_elaborated_type_specifier): Skip redundant error
+ generation when name lookup is ambiguous.
+
+2007-06-28 Geoffrey Keating <geoffk at apple.com> (r126088)
+
+ * decl2.c (determine_visibility): Implement
+ flag_visibility_ms_compat effect on type info.
+ * decl.c (cxx_init_decl_processing): Implement
+ global effect of flag_visibility_ms_compat.
+
+2007-06-28 Geoffrey Keating <geoffk at apple.com> (r126080)
+
+ * decl2.c (start_objects): Mark constructor-runnning function
+ as artificial.
+
+2007-06-14 Geoff Keating <geoffk at apple.com> (r125721)
+
+ PR 31093
+ * decl2.c (determine_visibility): Remove duplicate code for
+ handling type info.
+
+2007-05-31 Daniel Berlin <dberlin at dberlin.org> (r125239)
+
+ * typeck.c (build_binary_op): Include types in error.
+
+2007-05-22 Ollie Wild <aaw at google.com> (r124963)
+
+ * name-lookup.c (ambiguous_decl): Adds check for hidden types.
+ (unqualified_namespace_lookup): Adds check for hidden types.
+
+2007-05-18 Geoffrey Keating <geoffk at apple.com> (r124839)
+
+ * mangle.c (write_real_cst): Use 'unsigned long' for %lx.
+
+2007-05-14 Paolo Carlini <pcarlini at suse.de> (r124724)
+
+ PR c++/29928
+ * rtti.c (get_tinfo_decl_dynamic, get_typeid): Try to complete the
+ type only if is a class type (5.2.8/4).
+
+2007-05-05 Geoffrey Keating <geoffk at apple.com> (r124467)
+
+ PR 31775
+ * mangle.c (write_mangled_name): Mangle static variable names.
+ (write_unqualified_name): Use local-source-name for
+ namespace-scope static variables.
+
+2007-03-12 Seongbae Park <seongbae.park at gmail.com> (r122851)
+
+ * decl.c (compute_array_index_type): New warning flag warn_vla.
+
+2007-01-08 Mark Shinwell <shinwell at codesourcery.com> (r120572)
+
+ * call.c (standard_conversion): Pass flag to
+ vector_types_convertible_p to disallow emission of note.
+ * typeck.c (convert_for_assignment): Pass flag to
+ vector_types_convertible_p to allow emission of note.
+ (ptr_reasonably_similar): Pass flag to vector_types_convertible_p
+ to disallow emission of note.
+
+2007-01-07 Manuel Lopez-Ibanez <manu at gcc.gnu.org> (r120558)
+
+ PR c++/28986
+ * typeck.c (build_binary_op): Call overflow_warning if
+ TREE_OVERFLOW_P is true for the result and not for any of the
+ operands.
+
+2007-01-05 Manuel Lopez-Ibanez <manu at gcc.gnu.org> (r120505)
+
+ PR c/19978
+ * semantics.c (finish_unary_op_expr): Warn only if result
+ overflowed and operands did not.
+
+2006-12-01 Geoffrey Keating <geoffk at apple.com> (r119427)
+
+ * decl.c (poplevel): Check DECL_INITIAL invariant.
+ (duplicate_decls): Preserve DECL_INITIAL when eliminating
+ a new definition in favour of an old declaration.
+ (start_preparsed_function): Define and document value of
+ DECL_INITIAL before and after routine.
+ (finish_function): Check DECL_INITIAL invariant.
+ * parser.c
+ (cp_parser_function_definition_from_specifiers_and_declarator):
+ Skip duplicate function definitions.
+
+2006-10-31 Geoffrey Keating <geoffk at apple.com> (r118360)
+
+ * name-lookup.c (get_anonymous_namespace_name): New.
+ (push_namespace_with_attribs): Use get_anonymous_namespace_name.
+ * decl2.c (start_objects): Update for rename of
+ get_file_function_name_long.
Modified: trunk/contrib/gcc/cp/Make-lang.in
===================================================================
--- trunk/contrib/gcc4/cp/Make-lang.in 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/Make-lang.in 2018-06-04 17:30:21 UTC (rev 10405)
@@ -265,7 +265,7 @@
$(TARGET_H) debug.h
cp/ptree.o: cp/ptree.c $(CXX_TREE_H) $(TM_H)
cp/rtti.o: cp/rtti.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h convert.h \
- gt-cp-rtti.h
+ $(TARGET_H) gt-cp-rtti.h
cp/except.o: cp/except.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) $(RTL_H) except.h \
toplev.h cp/cfns.h $(EXPR_H) libfuncs.h $(TREE_INLINE_H) $(TARGET_H)
cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_H) $(RTL_H) $(FLAGS_H) $(EXPR_H) \
Modified: trunk/contrib/gcc/cp/call.c
===================================================================
--- trunk/contrib/gcc4/cp/call.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/call.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -281,7 +281,8 @@
function = build_addr_func (function);
- gcc_assert (TYPE_PTR_P (TREE_TYPE (function)));
+ /* APPLE LOCAL blocks 6040305 */
+ gcc_assert (TYPE_PTR_P (TREE_TYPE (function)) || TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE);
fntype = TREE_TYPE (TREE_TYPE (function));
gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE
|| TREE_CODE (fntype) == METHOD_TYPE);
@@ -657,7 +658,8 @@
if (same_type_p (from, to))
return conv;
- if ((tcode == POINTER_TYPE || TYPE_PTR_TO_MEMBER_P (to))
+ /* APPLE LOCAL blocks 6040305 (ck) */
+ if ((tcode == POINTER_TYPE || tcode == BLOCK_POINTER_TYPE || TYPE_PTR_TO_MEMBER_P (to))
&& expr && null_ptr_cst_p (expr))
conv = build_conv (ck_std, to, conv);
else if ((tcode == INTEGER_TYPE && fcode == POINTER_TYPE)
@@ -810,6 +812,8 @@
if (ARITHMETIC_TYPE_P (from)
|| fcode == ENUMERAL_TYPE
|| fcode == POINTER_TYPE
+ /* APPLE LOCAL blocks 6040305 (cl) */
+ || fcode == BLOCK_POINTER_TYPE
|| TYPE_PTR_TO_MEMBER_P (from))
{
conv = build_conv (ck_std, to, conv);
@@ -838,7 +842,7 @@
conv->rank = cr_promotion;
}
else if (fcode == VECTOR_TYPE && tcode == VECTOR_TYPE
- && vector_types_convertible_p (from, to))
+ && vector_types_convertible_p (from, to, false))
return build_conv (ck_std, to, conv);
else if (!(flags & LOOKUP_CONSTRUCTOR_CALLABLE)
&& IS_AGGR_TYPE (to) && IS_AGGR_TYPE (from)
@@ -877,6 +881,15 @@
&& DERIVED_FROM_P (t1, t2)));
}
+/* APPLE LOCAL begin radar 6029624 */
+/* Used in objective-c++, same as reference_related_p */
+bool
+objcp_reference_related_p (tree t1, tree t2)
+{
+ return reference_related_p (t1, t2);
+}
+/* APPLE LOCAL end radar 6029624 */
+
/* Returns nonzero if T1 is reference-compatible with T2. */
static bool
@@ -3520,10 +3533,19 @@
cv-qualification of either the second or the third operand.
The result is of the common type. */
else if ((null_ptr_cst_p (arg2)
- && (TYPE_PTR_P (arg3_type) || TYPE_PTR_TO_MEMBER_P (arg3_type)))
+ /* APPLE LOCAL begin blocks 6040305 (co) */
+ && (TYPE_PTR_P (arg3_type) || TYPE_PTR_TO_MEMBER_P (arg3_type)
+ || TREE_CODE (arg3_type) == BLOCK_POINTER_TYPE))
+ /* APPLE LOCAL end blocks 6040305 (co) */
|| (null_ptr_cst_p (arg3)
- && (TYPE_PTR_P (arg2_type) || TYPE_PTR_TO_MEMBER_P (arg2_type)))
- || (TYPE_PTR_P (arg2_type) && TYPE_PTR_P (arg3_type))
+ /* APPLE LOCAL begin blocks 6040305 (co) */
+ && (TYPE_PTR_P (arg2_type) || TYPE_PTR_TO_MEMBER_P (arg2_type)
+ || TREE_CODE (arg2_type) == BLOCK_POINTER_TYPE))
+ || ((TYPE_PTR_P (arg2_type)
+ || TREE_CODE (arg2_type) == BLOCK_POINTER_TYPE)
+ && (TYPE_PTR_P (arg3_type)
+ || TREE_CODE (arg3_type) == BLOCK_POINTER_TYPE))
+ /* APPLE LOCAL end blocks 6040305 (co) */
|| (TYPE_PTRMEM_P (arg2_type) && TYPE_PTRMEM_P (arg3_type))
|| (TYPE_PTRMEMFUNC_P (arg2_type) && TYPE_PTRMEMFUNC_P (arg3_type)))
{
Modified: trunk/contrib/gcc/cp/class.c
===================================================================
--- trunk/contrib/gcc4/cp/class.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/class.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1282,6 +1282,12 @@
TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (basetype);
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
|= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (basetype);
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ if (CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (basetype)
+ || CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (basetype))
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (t) = 1;
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
+
TYPE_HAS_COMPLEX_ASSIGN_REF (t)
|= TYPE_HAS_COMPLEX_ASSIGN_REF (basetype);
TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (basetype);
@@ -1440,6 +1446,13 @@
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (variants)
= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t);
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (variants) =
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (t);
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (variants) =
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (t);
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
+
TYPE_POLYMORPHIC_P (variants) = TYPE_POLYMORPHIC_P (t);
TYPE_BINFO (variants) = TYPE_BINFO (t);
@@ -2540,6 +2553,13 @@
{
bool lazy_p = true;
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ /* Since this is an empty destructor, it can only be nontrivial
+ because one of its base classes has a destructor that must be
+ called. */
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (t) = 1;
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
+
if (TYPE_FOR_JAVA (t))
/* If this a Java class, any non-trivial destructor is
invalid, even if compiler-generated. Therefore, if the
@@ -3729,7 +3749,16 @@
}
/* All user-declared destructors are non-trivial. */
if (DECL_DESTRUCTOR_P (x))
- TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = 1;
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ {
+ TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = 1;
+
+ /* Conservatively assume that destructor body is nontrivial. Will
+ be unmarked during parsing of function body if it happens to be
+ trivial. */
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (t) = 1;
+ }
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
}
}
Modified: trunk/contrib/gcc/cp/cp-gimplify.c
===================================================================
--- trunk/contrib/gcc4/cp/cp-gimplify.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/cp-gimplify.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -188,7 +188,10 @@
loop body as in do-while loops. */
static tree
-gimplify_cp_loop (tree cond, tree body, tree incr, bool cond_is_first)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+gimplify_cp_loop (tree cond, tree body, tree incr, tree attrs,
+ bool cond_is_first, tree inner_foreach)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
{
tree top, entry, exit, cont_block, break_block, stmt_list, t;
location_t stmt_locus;
@@ -197,8 +200,20 @@
stmt_list = NULL_TREE;
entry = NULL_TREE;
- break_block = begin_bc_block (bc_break);
- cont_block = begin_bc_block (bc_continue);
+ /* APPLE LOCAL begin C* language */
+ /* Order of label addition to stack is important for objc's foreach-stmt. */
+ /* APPLE LOCAL radar 4667060 */
+ if (inner_foreach == integer_zero_node)
+ {
+ cont_block = begin_bc_block (bc_continue);
+ break_block = begin_bc_block (bc_break);
+ }
+ else
+ {
+ break_block = begin_bc_block (bc_break);
+ cont_block = begin_bc_block (bc_continue);
+ }
+ /* APPLE LOCAL end C* language */
/* If condition is zero don't generate a loop construct. */
if (cond && integer_zerop (cond))
@@ -223,6 +238,12 @@
out of the loop, or to the top of it. If there's no exit condition,
then we just build a jump back to the top. */
exit = build_and_jump (&LABEL_EXPR_LABEL (top));
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+
+ /* Add the attributes to the 'top' label. */
+ decl_attributes (&LABEL_EXPR_LABEL (top), attrs, 0);
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
if (cond && !integer_nonzerop (cond))
{
t = build_bc_goto (bc_break);
@@ -243,10 +264,19 @@
}
}
+ /* APPLE LOCAL begin radar 4547045 */
+ /* Pop foreach's inner loop break label so outer loop's
+ break label becomes target of inner loop body's break statements.
+ */
+ t = NULL_TREE;
gimplify_stmt (&body);
gimplify_stmt (&incr);
body = finish_bc_block (bc_continue, cont_block, body);
+ /* APPLE LOCAL begin radar 4547045 */
+ /* Push back inner loop's own 'break' label so rest
+ of code works seemlessly. */
+ /* APPLE LOCAL radar 4667060 */
append_to_statement_list (top, &stmt_list);
append_to_statement_list (body, &stmt_list);
@@ -270,8 +300,11 @@
if (FOR_INIT_STMT (stmt))
gimplify_and_add (FOR_INIT_STMT (stmt), pre_p);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
*stmt_p = gimplify_cp_loop (FOR_COND (stmt), FOR_BODY (stmt),
- FOR_EXPR (stmt), 1);
+ FOR_EXPR (stmt), FOR_ATTRIBUTES (stmt), 1,
+ NULL_TREE);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
/* Gimplify a WHILE_STMT node. */
@@ -280,8 +313,11 @@
gimplify_while_stmt (tree *stmt_p)
{
tree stmt = *stmt_p;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
*stmt_p = gimplify_cp_loop (WHILE_COND (stmt), WHILE_BODY (stmt),
- NULL_TREE, 1);
+ NULL_TREE, WHILE_ATTRIBUTES (stmt), 1,
+ NULL_TREE);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
/* Gimplify a DO_STMT node. */
@@ -290,8 +326,11 @@
gimplify_do_stmt (tree *stmt_p)
{
tree stmt = *stmt_p;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
*stmt_p = gimplify_cp_loop (DO_COND (stmt), DO_BODY (stmt),
- NULL_TREE, 0);
+ NULL_TREE, DO_ATTRIBUTES (stmt), 0,
+ DO_FOREACH (stmt));
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
/* Genericize a SWITCH_STMT by turning it into a SWITCH_EXPR. */
Modified: trunk/contrib/gcc/cp/cp-lang.c
===================================================================
--- trunk/contrib/gcc4/cp/cp-lang.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/cp-lang.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -44,6 +44,8 @@
#define LANG_HOOKS_NAME "GNU C++"
#undef LANG_HOOKS_INIT
#define LANG_HOOKS_INIT cxx_init
+#undef LANG_HOOKS_GENERIC_TYPE_P
+#define LANG_HOOKS_GENERIC_TYPE_P class_tmpl_impl_spec_p
#undef LANG_HOOKS_DECL_PRINTABLE_NAME
#define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name
#undef LANG_HOOKS_FOLD_OBJ_TYPE_REF
Modified: trunk/contrib/gcc/cp/cp-objcp-common.c
===================================================================
--- trunk/contrib/gcc4/cp/cp-objcp-common.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/cp-objcp-common.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -259,5 +259,37 @@
tree_map_eq, 0);
}
+/* APPLE LOCAL begin radar 5741070 */
+/* Given an IDENTIFIER tree for a class interface, find (if possible) and
+ return the record type for the class interface. */
+tree
+c_return_interface_record_type (tree typename)
+{
+ enum tree_code_class class;
+ enum tree_code code;
+ tree retval = NULL;
+
+ if (typename == NULL)
+ return retval;
+
+ code = TREE_CODE (typename);
+ class = TREE_CODE_CLASS (code);
+
+ if (code != IDENTIFIER_NODE
+ || class != tcc_exceptional)
+ return retval;
+
+ if (TREE_TYPE (typename)
+ && TREE_CODE (TREE_TYPE (typename)) == RECORD_TYPE)
+ retval = TREE_TYPE (typename);
+
+ if (retval
+ && TREE_CODE (retval) != RECORD_TYPE)
+ retval = NULL;
+
+ return retval;
+}
+/* APPLE LOCAL end radar 5741070 */
+
#include "gt-cp-cp-objcp-common.h"
Modified: trunk/contrib/gcc/cp/cp-objcp-common.h
===================================================================
--- trunk/contrib/gcc4/cp/cp-objcp-common.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/cp-objcp-common.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -166,4 +166,10 @@
#undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE cxx_omp_privatize_by_reference
+/* APPLE LOCAL begin radar 6353006 */
+#undef LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE
+#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
+ c_build_generic_block_struct_type
+/* APPLE LOCAL end radar 6353006 */
+
#endif /* GCC_CP_OBJCP_COMMON */
Modified: trunk/contrib/gcc/cp/cp-tree.def
===================================================================
--- trunk/contrib/gcc4/cp/cp-tree.def 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/cp-tree.def 2018-06-04 17:30:21 UTC (rev 10405)
@@ -281,18 +281,23 @@
and COND_EXPR for the benefit of templates. */
DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 3)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
/* Used to represent a `for' statement. The operands are
- FOR_INIT_STMT, FOR_COND, FOR_EXPR, and FOR_BODY, respectively. */
-DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 4)
+ FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY and FOR_ATTRIBUTES
+ respectively. */
+DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 5)
/* Used to represent a 'while' statement. The operands are WHILE_COND
- and WHILE_BODY, respectively. */
-DEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 2)
+ WHILE_BODY, and WHILE_ATTRIBUTES respectively. */
+DEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 3)
-/* Used to represent a 'do' statement. The operands are DO_BODY and
- DO_COND, respectively. */
-DEFTREECODE (DO_STMT, "do_stmt", tcc_statement, 2)
+/* APPLE LOCAL begin radar 4445586 */
+/* Used to represent a 'do' statement. The operands are DO_BODY,
+ DO_COND, DO_ATTRIBUTES, and DO_FOREACH respectively. */
+DEFTREECODE (DO_STMT, "do_stmt", tcc_statement, 4)
+/* APPLE LOCAL end radar 4445586 */
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* Used to represent a 'break' statement. */
DEFTREECODE (BREAK_STMT, "break_stmt", tcc_statement, 0)
Modified: trunk/contrib/gcc/cp/cp-tree.h
===================================================================
--- trunk/contrib/gcc4/cp/cp-tree.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/cp-tree.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1052,6 +1052,13 @@
unsigned has_complex_assign_ref : 1;
unsigned non_aggregate : 1;
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ unsigned has_nontrivial_destructor_body : 1;
+ unsigned destructor_nontrivial_because_of_base : 1;
+ unsigned destructor_triviality_final : 1;
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
+
+
/* When adding a flag here, consider whether or not it ought to
apply to a template instance if it applies to the template. If
so, make sure to copy it in instantiate_class_template! */
@@ -1059,7 +1066,9 @@
/* There are some bits left to fill out a 32-bit word. Keep track
of this by updating the size of this bitfield whenever you add or
remove a flag. */
- unsigned dummy : 12;
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ unsigned dummy : 10;
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
tree primary_base;
VEC(tree_pair_s,gc) *vcall_indices;
@@ -2439,6 +2448,8 @@
|| TREE_CODE (TYPE) == ENUMERAL_TYPE \
|| ARITHMETIC_TYPE_P (TYPE) \
|| TYPE_PTR_P (TYPE) \
+ /* APPLE LOCAL blocks 6040305 */ \
+ || TREE_CODE (TYPE) == BLOCK_POINTER_TYPE \
|| TYPE_PTRMEMFUNC_P (TYPE))
/* [dcl.init.aggr]
@@ -2520,6 +2531,20 @@
#define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) \
(TYPE_LANG_FLAG_4 (NODE))
+/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+/* One if the body of the destructor of class type NODE has been shown to do
+ nothing, else zero. */
+#define CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_nontrivial_destructor_body)
+
+/* One if destructor of this type must be called by its base classes because
+ one of its base classes' destructors must be called. */
+#define CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->destructor_nontrivial_because_of_base)
+
+/* One if the values of CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE
+ and CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY are final. */
+#define CLASSTYPE_DESTRUCTOR_TRIVIALITY_FINAL(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->destructor_triviality_final)
+/* APPLE LOCAL end omit calls to empty destructors 5559195 */
+
/* Nonzero for class type means that copy initialization of this type can use
a bitwise copy. */
#define TYPE_HAS_TRIVIAL_INIT_REF(NODE) \
@@ -3080,12 +3105,24 @@
while statement and the body of the while statement, respectively. */
#define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0)
#define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+#define WHILE_ATTRIBUTES(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 2)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* DO_STMT accessors. These give access to the condition of the do
statement and the body of the do statement, respectively. */
#define DO_COND(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 0)
#define DO_BODY(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 1)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+#define DO_ATTRIBUTES(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 2)
+/* APPLE LOCAL begin C* language */
+/* Used as a flag to indicate synthesized inner do-while loop of a
+ foreach statement. Used for generation of break/continue statement
+ of the loop. */
+#define DO_FOREACH(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 3)
+/* APPLE LOCAL end C* language */
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* FOR_STMT accessors. These give access to the init statement,
condition, update expression, and body of the for statement,
respectively. */
@@ -3093,7 +3130,10 @@
#define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
#define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
#define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+#define FOR_ATTRIBUTES(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 4)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
#define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
#define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
#define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
@@ -3689,6 +3729,8 @@
cdk_pointer,
cdk_reference,
cdk_ptrmem,
+ /* APPLE LOCAL blocks 6040305 (ch) */
+ cdk_block_pointer,
cdk_error
} cp_declarator_kind;
@@ -3757,6 +3799,13 @@
/* For cdk_ptrmem, the class type containing the member. */
tree class_type;
} pointer;
+ /* APPLE LOCAL begin blocks 6040305 (ch) */
+ /* For cdk_block_pointer. */
+ struct {
+ /* The cv-qualifiers for the pointer. */
+ cp_cv_quals qualifiers;
+ } block_pointer;
+ /* APPLE LOCAL end blocks 6040305 (ch) */
} u;
};
@@ -3907,6 +3956,8 @@
extern tree check_tag_decl (cp_decl_specifier_seq *);
extern tree shadow_tag (cp_decl_specifier_seq *);
extern tree groktypename (cp_decl_specifier_seq *, const cp_declarator *);
+/* APPLE LOCAL 6339747 */
+extern tree grokblockdecl (cp_decl_specifier_seq *, const cp_declarator *);
extern tree start_decl (const cp_declarator *, cp_decl_specifier_seq *, int, tree, tree, tree *);
extern void start_decl_1 (tree, bool);
extern void cp_finish_decl (tree, tree, bool, tree, int);
@@ -4258,14 +4309,20 @@
extern void begin_else_clause (tree);
extern void finish_else_clause (tree);
extern void finish_if_stmt (tree);
-extern tree begin_while_stmt (void);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+extern tree begin_while_stmt (tree);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
extern void finish_while_stmt_cond (tree, tree);
extern void finish_while_stmt (tree);
-extern tree begin_do_stmt (void);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+extern tree begin_do_stmt (tree);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
extern void finish_do_body (tree);
extern void finish_do_stmt (tree, tree);
extern tree finish_return_stmt (tree);
-extern tree begin_for_stmt (void);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+extern tree begin_for_stmt (tree);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
extern void finish_for_init_stmt (tree);
extern void finish_for_cond (tree, tree);
extern void finish_for_expr (tree, tree);
@@ -4373,6 +4430,7 @@
extern tree cxx_maybe_build_cleanup (tree);
extern void init_tree (void);
extern int pod_type_p (tree);
+extern bool class_tmpl_impl_spec_p (tree);
extern int zero_init_p (tree);
extern tree canonical_type_variant (tree);
extern tree copy_binfo (tree, tree, tree,
@@ -4460,8 +4518,9 @@
extern tree build_indirect_ref (tree, const char *);
extern tree build_array_ref (tree, tree);
extern tree get_member_function_from_ptrfunc (tree *, tree);
-extern tree build_x_binary_op (enum tree_code, tree, tree,
- bool *);
+extern tree build_x_binary_op (enum tree_code, tree,
+ enum tree_code, tree,
+ enum tree_code, bool *);
extern tree build_x_unary_op (enum tree_code, tree);
extern tree unary_complex_lvalue (enum tree_code, tree);
extern tree build_x_conditional_expr (tree, tree, tree);
@@ -4577,5 +4636,11 @@
extern void cp_cpp_error (cpp_reader *, int,
const char *, va_list *)
ATTRIBUTE_GCC_CXXDIAG(3,0);
+/* APPLE LOCAL radar 5741070 */
+extern tree c_return_interface_record_type (tree);
+/* APPLE LOCAL begin blocks 6040305 (cg) */
+extern cp_declarator* make_block_pointer_declarator (tree, cp_cv_quals,
+ cp_declarator *);
+/* APPLE LOCAL end blocks 6040305 (cg) */
#endif /* ! GCC_CP_TREE_H */
Modified: trunk/contrib/gcc/cp/cvt.c
===================================================================
--- trunk/contrib/gcc4/cp/cvt.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/cvt.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -615,7 +615,7 @@
if ((invalid_conv_diag
= targetm.invalid_conversion (TREE_TYPE (expr), type)))
{
- error (invalid_conv_diag);
+ error (invalid_conv_diag, "");
return error_mark_node;
}
Modified: trunk/contrib/gcc/cp/decl.c
===================================================================
--- trunk/contrib/gcc4/cp/decl.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/decl.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -52,7 +52,8 @@
#include "timevar.h"
#include "tree-flow.h"
-static tree grokparms (cp_parameter_declarator *, tree *);
+/* APPLE LOCAL blocks 6040305 (ce) */
+tree grokparms (cp_parameter_declarator *, tree *);
static const char *redeclaration_error_message (tree, tree);
static int decl_jump_unsafe (tree);
@@ -232,10 +233,17 @@
with __attribute__((deprecated)). An object declared as
__attribute__((deprecated)) suppresses warnings of uses of other
deprecated items. */
+/* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+/* An object declared as __attribute__((unavailable)) suppresses
+ any reports of being declared with unavailable or deprecated
+ items. */
+/* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
enum deprecated_states {
DEPRECATED_NORMAL,
DEPRECATED_SUPPRESS
+ /* APPLE LOCAL "unavailable" attribute (radar 2809697) */
+ , DEPRECATED_UNAVAILABLE_SUPPRESS
};
static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
@@ -758,7 +766,12 @@
leave_scope ();
if (functionbody)
- DECL_INITIAL (current_function_decl) = block;
+ {
+ /* The current function is being defined, so its DECL_INITIAL
+ should be error_mark_node. */
+ gcc_assert (DECL_INITIAL (current_function_decl) == error_mark_node);
+ DECL_INITIAL (current_function_decl) = block;
+ }
else if (block)
current_binding_level->blocks
= chainon (current_binding_level->blocks, block);
@@ -1635,7 +1648,8 @@
}
/* If the new declaration is a definition, update the file and
- line information on the declaration. */
+ line information on the declaration, and also make
+ the old declaration the same definition. */
if (DECL_INITIAL (old_result) == NULL_TREE
&& DECL_INITIAL (new_result) != NULL_TREE)
{
@@ -1642,6 +1656,7 @@
DECL_SOURCE_LOCATION (olddecl)
= DECL_SOURCE_LOCATION (old_result)
= DECL_SOURCE_LOCATION (newdecl);
+ DECL_INITIAL (old_result) = DECL_INITIAL (new_result);
if (DECL_FUNCTION_TEMPLATE_P (newdecl))
DECL_ARGUMENTS (old_result)
= DECL_ARGUMENTS (new_result);
@@ -3157,13 +3172,10 @@
}
if (flag_inline_functions)
flag_inline_trees = 2;
+
+ if (flag_visibility_ms_compat)
+ default_visibility = VISIBILITY_HIDDEN;
- /* Force minimum function alignment if using the least significant
- bit of function pointers to store the virtual bit. */
- if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
- && force_align_functions_log < 1)
- force_align_functions_log = 1;
-
/* Initially, C. */
current_lang_name = lang_name_c;
@@ -3789,7 +3801,26 @@
return t;
}
-
+
+/* APPLE LOCAL begin blocks 6339747 */
+/* Decode a block literal type, such as "int **", returning a ...FUNCTION_DECL node. */
+
+tree
+grokblockdecl (cp_decl_specifier_seq *type_specifiers,
+ const cp_declarator *declarator)
+{
+ tree decl;
+ tree attrs = type_specifiers->attributes;
+
+ type_specifiers->attributes = NULL_TREE;
+
+ decl = grokdeclarator (declarator, type_specifiers, BLOCKDEF, 0, &attrs);
+ if (attrs)
+ cplus_decl_attributes (&decl, attrs, 0);
+ return decl;
+}
+/* APPLE LOCAL end blocks 6339747 */
+
/* Decode a "typename", such as "int **", returning a ..._TYPE node. */
tree
@@ -3832,14 +3863,40 @@
tree decl;
tree type, tem;
tree context;
+ /* APPLE LOCAL "unavailable" attribute (radar 2809697) */
+ tree a;
bool was_public;
*pushed_scope_p = NULL_TREE;
- /* An object declared as __attribute__((deprecated)) suppresses
- warnings of uses of other deprecated items. */
+ /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */
+ /* An object declared as __attribute__((unavailable)) suppresses
+ any reports of being declared with unavailable or deprecated
+ items. An object declared as __attribute__((deprecated))
+ suppresses warnings of uses of other deprecated items. */
+#ifdef A_LESS_INEFFICENT_WAY /* which I really don't want to do! */
if (lookup_attribute ("deprecated", attributes))
deprecated_state = DEPRECATED_SUPPRESS;
+ else if (lookup_attribute ("unavailable", attributes))
+ deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS;
+#else /* a more efficient way doing what lookup_attribute would do */
+ for (a = attributes; a; a = TREE_CHAIN (a))
+ {
+ tree name = TREE_PURPOSE (a);
+ if (TREE_CODE (name) == IDENTIFIER_NODE)
+ if (is_attribute_p ("deprecated", name))
+ {
+ deprecated_state = DEPRECATED_SUPPRESS;
+ break;
+ }
+ if (is_attribute_p ("unavailable", name))
+ {
+ deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS;
+ break;
+ }
+ }
+#endif
+ /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */
attributes = chainon (attributes, prefix_attributes);
@@ -4965,10 +5022,15 @@
if (DECL_LANG_SPECIFIC (decl) && DECL_IN_AGGR_P (decl))
{
gcc_assert (TREE_STATIC (decl));
+ /* APPLE LOCAL begin templated static data 6298605 */
/* An in-class declaration of a static data member should be
- external; it is only a declaration, and not a definition. */
- if (init == NULL_TREE)
- gcc_assert (DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl));
+ external if the decl is accessible from outside this
+ translation unit (eg something not in an anonymous
+ namespace); it is only a declaration, and not a
+ definition. */
+ if (init == NULL_TREE && TREE_PUBLIC (decl))
+ gcc_assert (DECL_EXTERNAL (decl));
+ /* APPLE LOCAL end templated static data 6298605 */
}
/* We don't create any RTL for local variables. */
@@ -5123,6 +5185,367 @@
return false;
}
+/* APPLE LOCAL begin blocks 6040305 (cr) */
+#define BLOCK_ALIGN_MAX 18
+static tree block_byref_id_object_copy[BLOCK_BYREF_CURRENT_MAX*(BLOCK_ALIGN_MAX+1)];
+static tree block_byref_id_object_dispose[BLOCK_BYREF_CURRENT_MAX*(BLOCK_ALIGN_MAX+1)];
+
+/**
+ This routine builds:
+
+ void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
+ struct Block_byref_id_object *src) {
+ _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
+ _Block_object_assign(&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // blocks
+ } */
+static void
+synth_block_byref_id_object_copy_func (int flag, int kind)
+{
+ tree stmt;
+ tree dst_arg, src_arg;
+ tree dst_obj, src_obj;
+ tree call_exp;
+
+ gcc_assert (block_byref_id_object_copy[kind]);
+ /* Set up: (void* _dest, void*_src) parameters. */
+ dst_arg = build_decl (PARM_DECL, get_identifier ("_dst"),
+ ptr_type_node);
+ TREE_USED (dst_arg) = 1;
+ DECL_ARG_TYPE (dst_arg) = ptr_type_node;
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ ptr_type_node);
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = ptr_type_node;
+ /* arg_info = xcalloc (1, sizeof (struct c_arg_info)); */
+ TREE_CHAIN (dst_arg) = src_arg;
+ /* arg_info->parms = dst_arg; */
+ /* arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE,
+ ptr_type_node,
+ NULL_TREE)); */
+ DECL_ARGUMENTS (block_byref_id_object_copy[kind]) = dst_arg;
+ /* function header synthesis. */
+ push_function_context ();
+ /* start_block_helper_function (block_byref_id_object_copy[kind], true); */
+ /* store_parm_decls_from (arg_info); */
+ start_preparsed_function (block_byref_id_object_copy[kind],
+ /*attrs*/NULL_TREE,
+ SF_PRE_PARSED);
+
+ /* Body of the function. */
+ stmt = begin_compound_stmt (BCS_FN_BODY);
+ /* Build dst->object */
+ dst_obj = build_indirect_object_id_exp (dst_arg);
+
+
+ /* src_obj is: _src->object. */
+ src_obj = build_indirect_object_id_exp (src_arg);
+ /* APPLE LOCAL begin radar 6180456 */
+ /* _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT) or:
+ _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK) */
+ /* APPLE LOCAL begin radar 6573923 */
+ /* Also add the new flag when calling _Block_object_dispose
+ from byref dispose helper. */
+ flag |= BLOCK_BYREF_CALLER;
+ /* APPLE LOCAL end radar 6573923 */
+ call_exp = build_block_object_assign_call_exp (build_fold_addr_expr (dst_obj), src_obj, flag);
+ add_stmt (call_exp);
+ /* APPLE LOCAL end radar 6180456 */
+
+ finish_compound_stmt (stmt);
+ /* APPLE LOCAL radar 6169580 */
+ finish_function (4);
+ pop_function_context ();
+}
+
+/**
+ This routine builds:
+
+ void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
+ _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
+ _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // blocks
+ } */
+static void synth_block_byref_id_object_dispose_func (int flag, int kind)
+{
+ tree stmt;
+ tree src_arg, src_obj, rel_exp;
+
+ gcc_assert (block_byref_id_object_dispose[kind]);
+ /* Set up: (void *_src) parameter. */
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ ptr_type_node);
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = ptr_type_node;
+ /* arg_info = xcalloc (1, sizeof (struct c_arg_info));
+ arg_info->parms = src_arg;
+ arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
+ NULL_TREE); */
+ DECL_ARGUMENTS (block_byref_id_object_dispose[kind]) = src_arg;
+ /* function header synthesis. */
+ push_function_context ();
+ /* start_block_helper_function (block_byref_id_object_dispose[kind], true); */
+ /* store_parm_decls_from (arg_info); */
+ start_preparsed_function (block_byref_id_object_dispose[kind],
+ /*attrs*/NULL_TREE,
+ SF_PRE_PARSED);
+
+ /* Body of the function. */
+ stmt = begin_compound_stmt (BCS_FN_BODY);
+ src_obj = build_indirect_object_id_exp (src_arg);
+
+ /* APPLE LOCAL begin radar 6180456 */
+ /* _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT) or:
+ _Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK) */
+ /* APPLE LOCAL begin radar 6573923 */
+ /* Also add the new flag when calling _Block_object_dispose
+ from byref dispose helper. */
+ flag |= BLOCK_BYREF_CALLER;
+ /* APPLE LOCAL end radar 6573923 */
+ rel_exp = build_block_object_dispose_call_exp (src_obj, flag);
+ /* APPLE LOCAL end radar 6180456 */
+ add_stmt (rel_exp);
+
+ finish_compound_stmt (stmt);
+ /* APPLE LOCAL radar 6169580 */
+ finish_function (4);
+ pop_function_context ();
+}
+
+static tree
+block_start_struct (tree name)
+{
+ tree s;
+ /* The idea here is to mimic the actions that the C++ parser takes when
+ constructing 'extern "C" struct NAME {'. */
+ push_lang_context (lang_name_c);
+
+ s = xref_tag (record_type, name, ts_global, 0);
+ CLASSTYPE_DECLARED_CLASS (s) = 0; /* this is a 'struct', not a 'class'. */
+ xref_basetypes (s, NULL_TREE); /* no base classes here! */
+
+ return begin_class_definition (s, NULL_TREE);
+}
+
+static tree
+block_finish_struct (tree t, tree fieldlist)
+{
+ tree field, next_field;
+
+ for (field = fieldlist; field; field = next_field)
+ {
+ next_field = TREE_CHAIN (field); /* insert one field at a time; */
+ TREE_CHAIN (field) = NULL_TREE; /* otherwise, grokfield croaks. */
+ finish_member_declaration (field);
+ }
+ t = finish_struct (t, NULL);
+ pop_lang_context ();
+
+ return t;
+}
+
+/* new_block_byref_decl - This routine changes a 'typex x' declared variable into:
+
+ struct __Block_byref_x {
+ // APPLE LOCAL radar 6244520
+ void *__isa; // NULL for everything except __weak pointers
+ struct Block_byref_x *__forwarding;
+ int32_t __flags;
+ int32_t __size;
+ void *__ByrefKeepFuncPtr; // Only if variable is __block ObjC object
+ void *__ByrefDestroyFuncPtr; // Only if variable is __block ObjC object
+ typex x;
+ } x;
+*/
+
+static tree
+new_block_byref_decl (tree decl)
+{
+ static int unique_count;
+ /* APPLE LOCAL radar 5847976 */
+ int save_flag_objc_gc;
+ tree Block_byref_type;
+ tree fields = NULL_TREE, field;
+ const char *prefix = "__Block_byref_";
+ char *string = (char*)alloca (strlen (IDENTIFIER_POINTER (DECL_NAME (decl))) +
+ strlen (prefix) + 8 /* to hold the count */);
+
+ sprintf (string, "%s%d_%s", prefix, ++unique_count,
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+
+ push_to_top_level ();
+
+ /* Block_byref_type = start_struct (RECORD_TYPE, get_identifier (string)); */
+ Block_byref_type = block_start_struct (get_identifier (string));
+
+ /* APPLE LOCAL begin radar 6244520 */
+ /* void *__isa; */
+ field = build_decl (FIELD_DECL, get_identifier ("__isa"), ptr_type_node);
+ fields = field;
+ /* APPLE LOCAL end radar 6244520 */
+
+ /* struct Block_byref_x *__forwarding; */
+ field = build_decl (FIELD_DECL, get_identifier ("__forwarding"),
+ build_pointer_type (Block_byref_type));
+ /* APPLE LOCAL radar 6244520 */
+ chainon (fields, field);
+
+ /* int32_t __flags; */
+ field = build_decl (FIELD_DECL, get_identifier ("__flags"),
+ unsigned_type_node);
+ chainon (fields, field);
+
+ /* int32_t __size; */
+ field = build_decl (FIELD_DECL, get_identifier ("__size"),
+ unsigned_type_node);
+ chainon (fields, field);
+
+ if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+ {
+ /* void *__ByrefKeepFuncPtr; */
+ field = build_decl (FIELD_DECL, get_identifier ("__ByrefKeepFuncPtr"),
+ ptr_type_node);
+ chainon (fields, field);
+
+ /* void *__ByrefDestroyFuncPtr; */
+ field = build_decl (FIELD_DECL, get_identifier ("__ByrefDestroyFuncPtr"),
+ ptr_type_node);
+ chainon (fields, field);
+ }
+
+ /* typex x; */
+ field = build_decl (FIELD_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ chainon (fields, field);
+
+ /* APPLE LOCAL begin radar 5847976 */
+ /* Hack so we don't issue warning on a field_decl having __weak attribute */
+ save_flag_objc_gc = flag_objc_gc;
+ flag_objc_gc = 0;
+ /* finish_struct (Block_byref_type, field_decl_chain, NULL_TREE); */
+ block_finish_struct (Block_byref_type, fields);
+ flag_objc_gc = save_flag_objc_gc;
+ /* APPLE LOCAL end radar 5847976 */
+ pop_from_top_level ();
+
+ TREE_TYPE (decl) = Block_byref_type;
+ /* Force layout_decl to recompute these fields. */
+ DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = 0;
+ layout_decl (decl, 0);
+ return decl;
+}
+
+/* init_byref_decl - This routine builds the initializer for the __Block_byref_x
+ type in the form of:
+ { NULL, &x, 0, sizeof(struct __Block_byref_x), initializer-expr};
+
+ or:
+ { NULL, &x, 0, sizeof(struct __Block_byref_x)};
+ when INIT is NULL_TREE
+
+ For __block ObjC objects, it also adds "byref_keep" and "byref_destroy"
+ Funtion pointers. So the most general initializers would be:
+
+ { NULL, &x, 0, sizeof(struct __Block_byref_x), &byref_keep, &byref_destroy,
+ &initializer-expr};
+ */
+static tree
+init_byref_decl (tree decl, tree init, int flag)
+{
+ tree initlist;
+ tree block_byref_type = TREE_TYPE (decl);
+ int size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (block_byref_type));
+ unsigned flags = 0;
+ tree fields;
+
+ if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+ flags = BLOCK_HAS_COPY_DISPOSE;
+
+ fields = TYPE_FIELDS (block_byref_type);
+ /* APPLE LOCAL begin radar 6244520 */
+ initlist = tree_cons (fields, fold_convert (ptr_type_node, ((flag & BLOCK_FIELD_IS_WEAK) != 0) ? integer_one_node
+ : integer_zero_node),
+ 0);
+ fields = TREE_CHAIN (fields);
+
+ initlist = tree_cons (fields,
+ build_unary_op (ADDR_EXPR, decl, 0), initlist);
+ /* APPLE LOCAL end radar 6244520 */
+ fields = TREE_CHAIN (fields);
+
+ initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), flags),
+ initlist);
+ fields = TREE_CHAIN (fields);
+ initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), size),
+ initlist);
+ fields = TREE_CHAIN (fields);
+
+ if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
+ {
+ char name[64];
+ int align = exact_log2 ((DECL_ALIGN (decl)+TYPE_ALIGN (ptr_type_node)-1) / TYPE_ALIGN (ptr_type_node));
+ int kind;
+ if (align == -1 || align > BLOCK_ALIGN_MAX) {
+ error ("invalid alignment for __block variable");
+ kind = 0;
+ } else
+ kind = align*BLOCK_BYREF_CURRENT_MAX + flag;
+ /* Add &__Block_byref_id_object_copy, &__Block_byref_id_object_dispose
+ initializers. */
+ if (!block_byref_id_object_copy[kind])
+ {
+ tree func_type;
+ push_lang_context (lang_name_c);
+ /* Build a void __Block_byref_id_object_copy(void*, void*) type. */
+ func_type =
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node)));
+ sprintf (name, "__Block_byref_id_object_copy%d", kind);
+ block_byref_id_object_copy[kind] = build_helper_func_decl (get_identifier (name),
+ func_type);
+ DECL_CONTEXT (block_byref_id_object_copy[kind]) = current_function_decl;
+ /* Synthesize function definition. */
+ synth_block_byref_id_object_copy_func (flag, kind);
+ pop_lang_context ();
+ }
+ initlist = tree_cons (fields,
+ build_fold_addr_expr (block_byref_id_object_copy[kind]),
+ initlist);
+ fields = TREE_CHAIN (fields);
+
+ if (!block_byref_id_object_dispose[kind])
+ {
+ tree func_type;
+ push_lang_context (lang_name_c);
+ /* Synthesize void __Block_byref_id_object_dispose (void*) and
+ build &__Block_byref_id_object_dispose. */
+ func_type =
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node, void_list_node));
+ sprintf (name, "__Block_byref_id_object_dispose%d", kind);
+ block_byref_id_object_dispose[kind] = build_helper_func_decl (get_identifier (name),
+ func_type);
+ DECL_CONTEXT (block_byref_id_object_dispose[kind]) = current_function_decl;
+ /* Synthesize function definition. */
+ synth_block_byref_id_object_dispose_func (flag, kind);
+ pop_lang_context ();
+ }
+ initlist = tree_cons (fields,
+ build_fold_addr_expr (block_byref_id_object_dispose[kind]),
+ initlist);
+ fields = TREE_CHAIN (fields);
+ }
+
+ if (init)
+ {
+ init = digest_init (TREE_TYPE (fields), init);
+ initlist = tree_cons (fields, init, initlist);
+ }
+ init = build_constructor_from_list (block_byref_type, nreverse (initlist));
+ return init;
+}
+/* APPLE LOCAL end blocks 6040305 (cr) */
+
/* Finish processing of a declaration;
install its line number and initial value.
If the length of an array type is not known before,
@@ -5258,6 +5681,17 @@
if (DECL_THREAD_LOCAL_P (decl) && !pod_type_p (TREE_TYPE (decl)))
error ("%qD cannot be thread-local because it has non-POD type %qT",
decl, TREE_TYPE (decl));
+ /* APPLE LOCAL begin blocks 6040305 (cq) */
+ if (COPYABLE_BYREF_LOCAL_VAR (decl)) {
+ if (DECL_EXTERNAL (decl) || TREE_STATIC (decl))
+ {
+ error ("__block attribute on %q+D not allowed, only allowed on local variables", decl);
+ COPYABLE_BYREF_LOCAL_VAR (decl) = 0;
+ COPYABLE_BYREF_LOCAL_NONPOD (decl) = 0;
+ }
+ }
+ /* APPLE LOCAL end blocks 6040305 (cq) */
+
/* If this is a local variable that will need a mangled name,
register it now. We must do this before processing the
initializer for the variable, since the initialization might
@@ -5723,6 +6157,16 @@
&& TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
return;
+ /* APPLE LOCAL begin radar 5733674 */
+ if (c_dialect_objc () && flag_objc_gc && init && TREE_CODE (init) == INIT_EXPR)
+ {
+ tree result = objc_generate_write_barrier (TREE_OPERAND (init, 0),
+ INIT_EXPR, TREE_OPERAND (init, 1));
+ if (result)
+ init = result;
+ }
+ /* APPLE LOCAL end radar 5733674 */
+
if (DECL_FUNCTION_SCOPE_P (decl))
{
/* Emit code to perform this initialization but once. */
@@ -6065,6 +6509,14 @@
if (TYPE_VOLATILE (type))
TREE_THIS_VOLATILE (decl) = 1;
+ /* If pointers to member functions use the least significant bit to
+ indicate whether a function is virtual, ensure a pointer
+ to this function will have that bit clear. */
+ if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
+ && TREE_CODE (type) == METHOD_TYPE
+ && DECL_ALIGN (decl) < 2 * BITS_PER_UNIT)
+ DECL_ALIGN (decl) = 2 * BITS_PER_UNIT;
+
if (friendp
&& TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR)
{
@@ -6702,13 +7154,22 @@
error ("size of array is not an integral constant-expression");
size = integer_one_node;
}
- else if (pedantic)
+ else if (pedantic && warn_vla != 0)
{
if (name)
- pedwarn ("ISO C++ forbids variable-size array %qD", name);
+ pedwarn ("ISO C++ forbids variable length array %qD", name);
else
- pedwarn ("ISO C++ forbids variable-size array");
+ pedwarn ("ISO C++ forbids variable length array");
}
+ else if (warn_vla > 0)
+ {
+ if (name)
+ warning (OPT_Wvla,
+ "variable length array %qD is used", name);
+ else
+ warning (OPT_Wvla,
+ "variable length array is used");
+ }
if (processing_template_decl && !TREE_CONSTANT (size))
/* A variable sized array. */
@@ -7181,6 +7642,8 @@
case cdk_pointer:
case cdk_reference:
case cdk_ptrmem:
+ /* APPLE LOCAL blocks 6040305 */
+ case cdk_block_pointer:
break;
case cdk_error:
@@ -7253,6 +7716,19 @@
type = NULL_TREE;
type_was_error_mark_node = true;
}
+
+ /* APPLE LOCAL begin unavailable attribute (radar 2809697) --bowdidge */
+ /* If the entire declaration is itself tagged as unavailable then
+ suppress reports of unavailable/deprecated items. If the
+ entire declaration is tagged as only deprecated we still
+ report unavailable uses. */
+ if (type && TREE_DEPRECATED (type) && TREE_UNAVAILABLE (type))
+ {
+ if (deprecated_state != DEPRECATED_UNAVAILABLE_SUPPRESS)
+ warn_deprecated_use (type);
+ }
+ else
+ /* APPLE LOCAL end unavailable attribute (radar 2809697) --bowdidge */
/* If the entire declaration is itself tagged as deprecated then
suppress reports of deprecated items. */
if (type && TREE_DEPRECATED (type)
@@ -7863,6 +8339,33 @@
ctype = NULL_TREE;
break;
+ /* APPLE LOCAL begin blocks 6040305 (cj) */
+ case cdk_block_pointer:
+ if (TREE_CODE (type) != FUNCTION_TYPE)
+ {
+ error ("block pointer to non-function type is invalid");
+ type = error_mark_node;
+ }
+ else
+ {
+ /* We now know that the TYPE_QUALS don't apply to the decl,
+ but to the target of the pointer. */
+ type_quals = TYPE_UNQUALIFIED;
+
+ type = build_block_pointer_type (type);
+
+ if (declarator->u.pointer.qualifiers)
+ {
+ type
+ = cp_build_qualified_type (type,
+ declarator->u.pointer.qualifiers);
+ type_quals = cp_type_quals (type);
+ }
+ }
+ ctype = NULL_TREE;
+ break;
+ /* APPLE LOCAL end blocks 6040305 (cj) */
+
case cdk_error:
break;
@@ -8054,6 +8557,38 @@
}
}
+ /* APPLE LOCAL begin blocks 6339747 */
+ if (decl_context == BLOCKDEF)
+ {
+ tree decl;
+
+ if (type == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (type) != FUNCTION_TYPE)
+ {
+ tree t = make_node (FUNCTION_TYPE);
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ error ("block declared as returning an array");
+ return error_mark_node;
+ }
+
+ TYPE_ARG_TYPES (t) = void_list_node;
+ TREE_TYPE (t) = type;
+ type = t;
+ parms = NULL_TREE;
+ }
+
+ if (raises)
+ type = build_exception_variant (type, raises);
+ decl = build_lang_decl (FUNCTION_DECL, NULL_TREE, type);
+ DECL_ARGUMENTS (decl) = parms;
+ return decl;
+ }
+ /* APPLE LOCAL end blocks 6339747 */
+
/* If this is declaring a typedef name, return a TYPE_DECL. */
if (declspecs->specs[(int)ds_typedef] && decl_context != TYPENAME)
{
@@ -8906,7 +9441,8 @@
*PARMS is set to the chain of PARM_DECLs created. */
-static tree
+/* APPLE LOCAL blocks 6040305 (ce) */
+tree
grokparms (cp_parameter_declarator *first_parm, tree *parms)
{
tree result = NULL_TREE;
@@ -9717,6 +10253,12 @@
| DECL_SELF_REFERENCE_P (decl));
return t;
}
+ else if (decl && TREE_CODE (decl) == TREE_LIST)
+ {
+ error ("reference to %qD is ambiguous", name);
+ print_candidates (decl);
+ return error_mark_node;
+ }
else
return NULL_TREE;
}
@@ -10495,8 +11037,14 @@
For C++, we must first check whether that datum makes any sense.
For example, "class A local_a(1,2);" means that variable local_a
is an aggregate of type A, which should have a constructor
- applied to it with the argument list [1, 2]. */
+ applied to it with the argument list [1, 2].
+ On entry, DECL_INITIAL (decl1) should be NULL_TREE or error_mark_node,
+ or may be a BLOCK if the function has been defined previously
+ in this translation unit. On exit, DECL_INITIAL (decl1) will be
+ error_mark_node if the function has never been defined, or
+ a BLOCK if the function has been defined somewhere. */
+
void
start_preparsed_function (tree decl1, tree attrs, int flags)
{
@@ -10624,24 +11172,6 @@
cp_apply_type_quals_to_decl (cp_type_quals (restype), resdecl);
}
- /* Initialize RTL machinery. We cannot do this until
- CURRENT_FUNCTION_DECL and DECL_RESULT are set up. We do this
- even when processing a template; this is how we get
- CFUN set up, and our per-function variables initialized.
- FIXME factor out the non-RTL stuff. */
- bl = current_binding_level;
- allocate_struct_function (decl1);
- current_binding_level = bl;
-
- /* Even though we're inside a function body, we still don't want to
- call expand_expr to calculate the size of a variable-sized array.
- We haven't necessarily assigned RTL to all variables yet, so it's
- not safe to try to expand expressions involving them. */
- cfun->x_dont_save_pending_sizes_p = 1;
-
- /* Start the statement-tree, start the tree now. */
- DECL_SAVED_TREE (decl1) = push_stmt_list ();
-
/* Let the user know we're compiling this function. */
announce_function (decl1);
@@ -10687,10 +11217,34 @@
maybe_apply_pragma_weak (decl1);
}
- /* Reset these in case the call to pushdecl changed them. */
+ /* Reset this in case the call to pushdecl changed it. */
current_function_decl = decl1;
- cfun->decl = decl1;
+ gcc_assert (DECL_INITIAL (decl1));
+
+ /* This function may already have been parsed, in which case just
+ return; our caller will skip over the body without parsing. */
+ if (DECL_INITIAL (decl1) != error_mark_node)
+ return;
+
+ /* Initialize RTL machinery. We cannot do this until
+ CURRENT_FUNCTION_DECL and DECL_RESULT are set up. We do this
+ even when processing a template; this is how we get
+ CFUN set up, and our per-function variables initialized.
+ FIXME factor out the non-RTL stuff. */
+ bl = current_binding_level;
+ allocate_struct_function (decl1);
+ current_binding_level = bl;
+
+ /* Even though we're inside a function body, we still don't want to
+ call expand_expr to calculate the size of a variable-sized array.
+ We haven't necessarily assigned RTL to all variables yet, so it's
+ not safe to try to expand expressions involving them. */
+ cfun->x_dont_save_pending_sizes_p = 1;
+
+ /* Start the statement-tree, start the tree now. */
+ DECL_SAVED_TREE (decl1) = push_stmt_list ();
+
/* If we are (erroneously) defining a function that we have already
defined before, wipe out what we knew before. */
if (!DECL_PENDING_INLINE_P (decl1))
@@ -10830,6 +11384,82 @@
}
+/* APPLE LOCAL begin warn missing prototype 6261539 */
+static bool
+fn_previously_found (tree decl, tree olddecl)
+{
+ int types_match;
+
+ if (olddecl == 0)
+ return false;
+
+ if (TREE_CODE (olddecl) == OVERLOAD)
+ {
+ if (OVL_CHAIN (olddecl) == NULL_TREE)
+ olddecl = OVL_CURRENT (olddecl);
+ else
+ {
+ tree match;
+ for (match = olddecl; match; match = OVL_NEXT (match))
+ {
+ if (fn_previously_found (decl, OVL_CURRENT (match)))
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /* Don't warn about previously erroneous things that have the same
+ name. */
+ if (TREE_TYPE (olddecl) == error_mark_node)
+ return true;
+
+ /* Internally defined things still need a prototype to escape the
+ warning. */
+ if (DECL_ARTIFICIAL (olddecl))
+ return false;
+
+ if (TREE_CODE (olddecl) != FUNCTION_DECL)
+ return false;
+
+ /* These will match or error, don't also spew prototype warnings. */
+ if (DECL_EXTERN_C_P (olddecl)
+ && DECL_EXTERN_C_P (decl))
+ return true;
+
+ /* These will match or error, don't also spew prototype warnings. */
+ if (compparms (TYPE_ARG_TYPES (TREE_TYPE (decl)),
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
+ return true;
+
+ types_match = decls_match (decl, olddecl);
+
+ if (types_match)
+ return true;
+
+ return false;
+}
+
+inline static void
+check_missing_prototype (tree decl)
+{
+ if (warn_missing_prototypes
+ && namespace_bindings_p ()
+ && TREE_PUBLIC (decl)
+ && !DECL_MAIN_P (decl)
+ && DECL_NON_THUNK_FUNCTION_P (decl)
+ && ! DECL_FUNCTION_MEMBER_P (decl)
+ && DECL_NAMESPACE_SCOPE_P (decl)
+ && ! decl_anon_ns_mem_p (decl)
+ && ! DECL_DECLARED_INLINE_P (decl))
+ {
+ tree olddecl = namespace_binding (DECL_NAME (decl), DECL_CONTEXT (decl));
+ if (!fn_previously_found (decl, olddecl))
+ warning (OPT_Wmissing_prototypes, "no previous prototype for %q+D", decl);
+ }
+}
+/* APPLE LOCAL end warn missing prototype 6261539 */
+
/* Like start_preparsed_function, except that instead of a
FUNCTION_DECL, this function takes DECLSPECS and DECLARATOR.
@@ -10856,6 +11486,10 @@
gcc_assert (same_type_p (TREE_TYPE (TREE_TYPE (decl1)),
integer_type_node));
+ /* APPLE LOCAL begin warn missing prototype 6261539 */
+ check_missing_prototype (decl1);
+ /* APPLE LOCAL end warn missing prototype 6261539 */
+
start_preparsed_function (decl1, attrs, /*flags=*/SF_DEFAULT);
return 1;
@@ -11174,6 +11808,8 @@
tree fndecl = current_function_decl;
tree fntype, ctype = NULL_TREE;
int inclass_inline = (flags & 2) != 0;
+ /* APPLE LOCAL radar 6169580 */
+ int in_blocks_helper_function = (flags & 4) != 0;
int nested;
/* When we get some parse errors, we can end up without a
@@ -11198,6 +11834,10 @@
which then got a warning when stored in a ptr-to-function variable. */
gcc_assert (building_stmt_tree ());
+ /* The current function is being defined, so its DECL_INITIAL should
+ be set, and unless there's a multiple definition, it should be
+ error_mark_node. */
+ gcc_assert (DECL_INITIAL (fndecl) == error_mark_node);
/* For a cloned function, we've already got all the code we need;
there's no need to add any extra bits. */
@@ -11363,7 +12003,8 @@
maybe_end_member_template_processing ();
/* Leave the scope of the class. */
- if (ctype)
+ /* APPLE LOCAL radar 6169580 */
+ if (ctype && !in_blocks_helper_function)
pop_nested_class ();
--function_depth;
@@ -11589,13 +12230,32 @@
{
tree type = TREE_TYPE (decl);
- if (type != error_mark_node && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ tree dtor = NULL_TREE;
+ bool build_cleanup = false;
+
+ if (TREE_CODE (type) == RECORD_TYPE)
+ dtor = CLASSTYPE_DESTRUCTORS (type);
+
+ if (type != error_mark_node)
{
+ if (TREE_CODE (type) == RECORD_TYPE)
+ /* For RECORD_TYPEs, we can refer to more precise flags than
+ TYPE_HAS_NONTRIVIAL_DESTRUCTOR. */
+ build_cleanup = (dtor && TREE_PRIVATE (dtor))
+ || CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (type)
+ || CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (type);
+ else
+ build_cleanup = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type);
+ }
+
+ if (build_cleanup)
+ {
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
int flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
tree rval;
bool has_vbases = (TREE_CODE (type) == RECORD_TYPE
&& CLASSTYPE_VBASECLASSES (type));
-
if (TREE_CODE (type) == ARRAY_TYPE)
rval = decl;
else
Modified: trunk/contrib/gcc/cp/decl.h
===================================================================
--- trunk/contrib/gcc4/cp/decl.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/decl.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -27,6 +27,8 @@
FIELD, /* Declaration inside struct or union */
BITFIELD, /* Likewise but with specified width */
TYPENAME, /* Typename (inside cast or sizeof) */
+ /* APPLE LOCAL blocks 6339747 */
+ BLOCKDEF, /* Declaratin of block literal */
MEMFUNCDEF /* Member function definition */
};
@@ -34,3 +36,7 @@
extern tree grokdeclarator (const cp_declarator *,
const cp_decl_specifier_seq *,
enum decl_context, int, tree*);
+/* APPLE LOCAL radar 4721858 */
+extern void emit_instantiate_pending_templates (location_t *);
+/* APPLE LOCAL blocks 6040305 (ce) */
+extern tree grokparms (cp_parameter_declarator *first_parm, tree *parms);
Modified: trunk/contrib/gcc/cp/decl2.c
===================================================================
--- trunk/contrib/gcc4/cp/decl2.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/decl2.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1698,10 +1698,6 @@
class can influence the visibility of the DECL. */
if (DECL_CLASS_SCOPE_P (decl))
class_type = DECL_CONTEXT (decl);
- else if (TREE_CODE (decl) == VAR_DECL
- && DECL_TINFO_P (decl)
- && CLASS_TYPE_P (TREE_TYPE (DECL_NAME (decl))))
- class_type = TREE_TYPE (DECL_NAME (decl));
else
{
/* Not a class member. */
@@ -1730,6 +1726,19 @@
but have no TEMPLATE_INFO, so don't try to check it. */
use_template = 0;
}
+ else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl)
+ && flag_visibility_ms_compat)
+ {
+ /* Under -fvisibility-ms-compat, types are visible by default,
+ even though their contents aren't. */
+ tree underlying_type = TREE_TYPE (DECL_NAME (decl));
+ int underlying_vis = type_visibility (underlying_type);
+ if (underlying_vis == VISIBILITY_ANON
+ || CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type))
+ constrain_visibility (decl, underlying_vis);
+ else
+ DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
+ }
else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl))
{
/* tinfo visibility is based on the type it's for. */
@@ -1787,7 +1796,8 @@
{
/* Propagate anonymity from type to decl. */
int tvis = type_visibility (TREE_TYPE (decl));
- if (tvis == VISIBILITY_ANON)
+ if (tvis == VISIBILITY_ANON
+ || ! DECL_VISIBILITY_SPECIFIED (decl))
constrain_visibility (decl, tvis);
}
}
@@ -1894,6 +1904,27 @@
}
}
+/* APPLE LOCAL begin weak types 5954418 */
+static bool
+typeinfo_comdat (tree type)
+{
+ tree binfo, base_binfo;
+ int j;
+
+ if (lookup_attribute ("weak", TYPE_ATTRIBUTES (type)))
+ return true;
+
+ for (binfo = TYPE_BINFO (type), j = 0;
+ BINFO_BASE_ITERATE (binfo, j, base_binfo); ++j)
+ {
+ if (typeinfo_comdat (BINFO_TYPE (base_binfo)))
+ return true;
+ }
+
+ return false;
+}
+/* APPLE LOCAL end weak types 5954418 */
+
/* DECL is a FUNCTION_DECL or VAR_DECL. If the object file linkage
for DECL has not already been determined, do so now by setting
DECL_EXTERNAL, DECL_COMDAT and other related flags. Until this
@@ -2090,7 +2121,10 @@
{
comdat_p = (targetm.cxx.class_data_always_comdat ()
|| (CLASSTYPE_KEY_METHOD (type)
- && DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (type))));
+ /* APPLE LOCAL begin weak types 5954418 */
+ && DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (type)))
+ || typeinfo_comdat (type));
+ /* APPLE LOCAL end weak types 5954418 */
mark_needed (decl);
if (!flag_weak)
{
@@ -2326,7 +2360,7 @@
sprintf (type, "%c", method_type);
fndecl = build_lang_decl (FUNCTION_DECL,
- get_file_function_name_long (type),
+ get_file_function_name (type),
build_function_type (void_type_node,
void_list_node));
start_preparsed_function (fndecl, /*attrs=*/NULL_TREE, SF_PRE_PARSED);
@@ -2335,6 +2369,10 @@
to scan the object file to find its ctor/dtor routine. */
TREE_PUBLIC (current_function_decl) = ! targetm.have_ctors_dtors;
+ /* Mark as artificial because it's not explicitly in the user's
+ source code. */
+ DECL_ARTIFICIAL (current_function_decl) = 1;
+
/* Mark this declaration as used to avoid spurious warnings. */
TREE_USED (current_function_decl) = 1;
@@ -3029,6 +3067,10 @@
}
}
+/* APPLE LOCAL begin radar 4721858 */
+static void emit_deferred (location_t *);
+/* APPLE LOCAL end radar 4721858 */
+
/* This routine is called from the last rule in yyparse ().
Its job is to create all the code needed to initialize and
destroy the global aggregates. We do the destruction
@@ -3037,14 +3079,10 @@
void
cp_finish_file (void)
{
- tree vars;
- bool reconsider;
- size_t i;
+ /* APPLE LOCAL begin radar 4721858 */
location_t locus;
- unsigned ssdf_count = 0;
- int retries = 0;
- tree decl;
-
+ /* APPLE LOCAL end radar 4721858 */
+
locus = input_location;
at_eof = 1;
@@ -3052,8 +3090,8 @@
if (! global_bindings_p () || current_class_type || decl_namespace_list)
return;
- if (pch_file)
- c_common_write_pch ();
+ /* APPLE LOCAL radar 4874613 */
+ /* dump of pch file moved to c_parse_file (). */
#ifdef USE_MAPPED_LOCATION
/* FIXME - huh? */
@@ -3083,6 +3121,29 @@
emit_support_tinfos ();
+ /* APPLE LOCAL begin radar 4721858 */
+ emit_instantiate_pending_templates (&locus);
+
+ emit_deferred (&locus);
+}
+
+/* This routine emits pending functions and instatiates pending templates
+ as more opportunities arises. */
+
+void
+emit_instantiate_pending_templates (location_t *locusp)
+{
+ tree vars;
+ bool reconsider;
+ size_t i;
+ unsigned ssdf_count = 0;
+ int retries = 0;
+
+ /* APPLE LOCAL radar 4874626 */
+ /* initialization removed. */
+ at_eof = 1;
+/* APPLE LOCAL end radar 4721858 */
+
do
{
tree t;
@@ -3160,7 +3221,8 @@
/* Set the line and file, so that it is obviously not from
the source file. */
- input_location = locus;
+ /* APPLE LOCAL radar 4721858 */
+ input_location = *locusp;
ssdf_body = start_static_storage_duration_function (ssdf_count);
/* Make sure the back end knows about all the variables. */
@@ -3186,7 +3248,8 @@
/* Finish up the static storage duration function for this
round. */
- input_location = locus;
+ /* APPLE LOCAL radar 4721858 */
+ input_location = *locusp;
finish_static_storage_duration_function (ssdf_body);
/* All those initializations and finalizations might cause
@@ -3197,7 +3260,8 @@
#ifdef USE_MAPPED_LOCATION
/* ??? */
#else
- locus.line++;
+ /* APPLE LOCAL radar 4721858 */
+ locusp->line++;
#endif
}
@@ -3295,27 +3359,36 @@
retries++;
}
while (reconsider);
+/* APPLE LOCAL begin radar 4721858 */
+}
+static void
+emit_deferred (location_t *locusp)
+{
+ size_t i;
+ tree decl;
+ bool reconsider = false;
+ /* APPLE LOCAL end radar 4721858 */
/* All used inline functions must have a definition at this point. */
for (i = 0; VEC_iterate (tree, deferred_fns, i, decl); ++i)
{
if (/* Check online inline functions that were actually used. */
- TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
- /* If the definition actually was available here, then the
- fact that the function was not defined merely represents
- that for some reason (use of a template repository,
- #pragma interface, etc.) we decided not to emit the
- definition here. */
- && !DECL_INITIAL (decl)
- /* An explicit instantiation can be used to specify
- that the body is in another unit. It will have
- already verified there was a definition. */
- && !DECL_EXPLICIT_INSTANTIATION (decl))
- {
- warning (0, "inline function %q+D used but never defined", decl);
- /* Avoid a duplicate warning from check_global_declaration_1. */
- TREE_NO_WARNING (decl) = 1;
- }
+ TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
+ /* If the definition actually was available here, then the
+ fact that the function was not defined merely represents
+ that for some reason (use of a template repository,
+ #pragma interface, etc.) we decided not to emit the
+ definition here. */
+ && !DECL_INITIAL (decl)
+ /* An explicit instantiation can be used to specify
+ that the body is in another unit. It will have
+ already verified there was a definition. */
+ && !DECL_EXPLICIT_INSTANTIATION (decl))
+ {
+ warning (0, "inline function %q+D used but never defined", decl);
+ /* Avoid a duplicate warning from check_global_declaration_1. */
+ TREE_NO_WARNING (decl) = 1;
+ }
}
/* We give C linkage to static constructors and destructors. */
@@ -3326,7 +3399,8 @@
if (priority_info_map)
splay_tree_foreach (priority_info_map,
generate_ctor_and_dtor_functions_for_priority,
- /*data=*/&locus);
+ /* APPLE LOCAL radar 4721858 */
+ /*data=*/locusp);
else
{
/* If we have a ctor or this is obj-c++ and we need a static init,
@@ -3333,10 +3407,12 @@
call generate_ctor_or_dtor_function. */
if (static_ctors || (c_dialect_objc () && objc_static_init_needed_p ()))
generate_ctor_or_dtor_function (/*constructor_p=*/true,
- DEFAULT_INIT_PRIORITY, &locus);
+ /* APPLE LOCAL radar 4721858 */
+ DEFAULT_INIT_PRIORITY, locusp);
if (static_dtors)
generate_ctor_or_dtor_function (/*constructor_p=*/false,
- DEFAULT_INIT_PRIORITY, &locus);
+ /* APPLE LOCAL radar 4721858 */
+ DEFAULT_INIT_PRIORITY, locusp);
}
/* We're done with the splay-tree now. */
@@ -3389,7 +3465,8 @@
dump_tree_statistics ();
dump_time_statistics ();
}
- input_location = locus;
+ /* APPLE LOCAL radar 4721858 */
+ input_location = *locusp;
#ifdef ENABLE_CHECKING
validate_conversion_obstack ();
Modified: trunk/contrib/gcc/cp/dump.c
===================================================================
--- trunk/contrib/gcc4/cp/dump.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/dump.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -433,6 +433,9 @@
dump_stmt (di, t);
dump_child ("body", DO_BODY (t));
dump_child ("cond", DO_COND (t));
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ dump_child ("attrs", DO_ATTRIBUTES (t));
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
break;
case FOR_STMT:
@@ -441,6 +444,9 @@
dump_child ("cond", FOR_COND (t));
dump_child ("expr", FOR_EXPR (t));
dump_child ("body", FOR_BODY (t));
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ dump_child ("attrs", FOR_ATTRIBUTES (t));
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
break;
case SWITCH_STMT:
@@ -453,6 +459,9 @@
dump_stmt (di, t);
dump_child ("cond", WHILE_COND (t));
dump_child ("body", WHILE_BODY (t));
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ dump_child ("attrs", WHILE_ATTRIBUTES (t));
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
break;
case STMT_EXPR:
Modified: trunk/contrib/gcc/cp/error.c
===================================================================
--- trunk/contrib/gcc4/cp/error.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/error.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -342,6 +342,8 @@
reduces code size. */
case ARRAY_TYPE:
case POINTER_TYPE:
+ /* APPLE LOCAL blocks 6040305 */
+ case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
offset_type:
@@ -497,6 +499,8 @@
switch (TREE_CODE (t))
{
case POINTER_TYPE:
+ /* APPLE LOCAL blocks 6040305 */
+ case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
{
tree sub = TREE_TYPE (t);
@@ -507,7 +511,10 @@
pp_cxx_whitespace (cxx_pp);
pp_cxx_left_paren (cxx_pp);
}
- pp_character (cxx_pp, "&*"[TREE_CODE (t) == POINTER_TYPE]);
+ /* APPLE LOCAL begin blocks 6040305 */
+ pp_character (cxx_pp, "&*^"[(TREE_CODE (t) == POINTER_TYPE)
+ + (TREE_CODE (t) == BLOCK_POINTER_TYPE)*2]);
+ /* APPLE LOCAL end blocks 6040305 */
pp_base (cxx_pp)->padding = pp_before;
pp_cxx_cv_qualifier_seq (cxx_pp, t);
}
@@ -593,6 +600,8 @@
switch (TREE_CODE (t))
{
case POINTER_TYPE:
+ /* APPLE LOCAL blocks 6040305 */
+ case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
Modified: trunk/contrib/gcc/cp/init.c
===================================================================
--- trunk/contrib/gcc4/cp/init.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/init.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2563,7 +2563,9 @@
tree elt_init;
tree to;
- for_stmt = begin_for_stmt ();
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ for_stmt = begin_for_stmt (NULL_TREE);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
finish_for_init_stmt (for_stmt);
finish_for_cond (build2 (NE_EXPR, boolean_type_node, iterator,
build_int_cst (TREE_TYPE (iterator), -1)),
@@ -2903,7 +2905,13 @@
for (binfo = TYPE_BINFO (current_class_type), i = 0;
BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- if (TYPE_HAS_TRIVIAL_DESTRUCTOR (BINFO_TYPE (base_binfo))
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ tree dtor = CLASSTYPE_DESTRUCTORS (BINFO_TYPE (base_binfo));
+
+ if ((!CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (BINFO_TYPE (base_binfo))
+ && !CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (BINFO_TYPE (base_binfo))
+ && !(dtor && (TREE_PRIVATE (dtor))))
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
|| BINFO_VIRTUAL_P (base_binfo))
continue;
@@ -2933,6 +2941,12 @@
LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_NORMAL,
0);
finish_decl_cleanup (NULL_TREE, expr);
+
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ /* Even if body of current class's destructor was found to be empty,
+ it must now be called because it must delete its members. */
+ CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (current_class_type) = 1;
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
}
}
}
Modified: trunk/contrib/gcc/cp/mangle.c
===================================================================
--- trunk/contrib/gcc4/cp/mangle.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/mangle.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -688,7 +688,8 @@
}
}
else if (TREE_CODE (decl) == VAR_DECL
- /* The names of global variables aren't mangled. */
+ /* The names of non-static global variables aren't mangled. */
+ && DECL_EXTERNAL_LINKAGE_P (decl)
&& (CP_DECL_CONTEXT (decl) == global_namespace
/* And neither are `extern "C"' variables. */
|| DECL_EXTERN_C_P (decl)))
@@ -1086,8 +1087,11 @@
<unqualified-name> ::= <operator-name>
::= <special-name>
- ::= <source-name> */
+ ::= <source-name>
+ ::= <local-source-name>
+ <local-source-name> ::= L <source-name> <discriminator> */
+
static void
write_unqualified_name (const tree decl)
{
@@ -1126,6 +1130,16 @@
write_string (oni[DECL_OVERLOADED_OPERATOR_P (decl)].mangled_name);
}
+ else if (VAR_OR_FUNCTION_DECL_P (decl) && ! TREE_PUBLIC (decl)
+ && DECL_NAMESPACE_SCOPE_P (decl)
+ && decl_linkage (decl) == lk_internal)
+ {
+ MANGLE_TRACE_TREE ("local-source-name", decl);
+ write_char ('L');
+ write_source_name (DECL_NAME (decl));
+ /* The default discriminator is 1, and that's all we ever use,
+ so there's no code to output one here. */
+ }
else
write_source_name (DECL_NAME (decl));
}
@@ -1326,7 +1340,7 @@
for (; i != limit; i += dir)
{
- sprintf (buffer, "%08lx", target_real[i]);
+ sprintf (buffer, "%08lx", (unsigned long) target_real[i]);
write_chars (buffer, 8);
}
}
@@ -1620,6 +1634,13 @@
write_type (TREE_TYPE (type));
break;
+ /* APPLE LOCAL begin blocks 6040305 */
+ case BLOCK_POINTER_TYPE:
+ write_string ("U13block_pointer");
+ write_type (TREE_TYPE (type));
+ break;
+ /* APPLE LOCAL end blocks 6040305 */
+
case REFERENCE_TYPE:
write_char ('R');
write_type (TREE_TYPE (type));
Modified: trunk/contrib/gcc/cp/method.c
===================================================================
--- trunk/contrib/gcc4/cp/method.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/method.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -407,10 +407,6 @@
}
}
- /* The back-end expects DECL_INITIAL to contain a BLOCK, so we
- create one. */
- DECL_INITIAL (thunk_fndecl) = make_node (BLOCK);
-
/* Set up cloned argument trees for the thunk. */
t = NULL_TREE;
for (a = DECL_ARGUMENTS (function); a; a = TREE_CHAIN (a))
@@ -424,7 +420,6 @@
}
a = nreverse (t);
DECL_ARGUMENTS (thunk_fndecl) = a;
- BLOCK_VARS (DECL_INITIAL (thunk_fndecl)) = a;
if (this_adjusting
&& targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset,
@@ -431,10 +426,17 @@
virtual_value, alias))
{
const char *fnname;
+ tree fn_block;
+
current_function_decl = thunk_fndecl;
DECL_RESULT (thunk_fndecl)
= build_decl (RESULT_DECL, 0, integer_type_node);
fnname = XSTR (XEXP (DECL_RTL (thunk_fndecl), 0), 0);
+ /* The back-end expects DECL_INITIAL to contain a BLOCK, so we
+ create one. */
+ fn_block = make_node (BLOCK);
+ BLOCK_VARS (fn_block) = a;
+ DECL_INITIAL (thunk_fndecl) = fn_block;
init_function_start (thunk_fndecl);
current_function_is_thunk = 1;
assemble_start_function (thunk_fndecl, fnname);
Modified: trunk/contrib/gcc/cp/name-lookup.c
===================================================================
--- trunk/contrib/gcc4/cp/name-lookup.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/name-lookup.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -42,7 +42,6 @@
#define EMPTY_SCOPE_BINDING { NULL_TREE, NULL_TREE }
static cxx_scope *innermost_nonclass_level (void);
-static tree select_decl (const struct scope_binding *, int);
static cxx_binding *binding_for_name (cxx_scope *, tree);
static tree lookup_name_innermost_nonclass_level (tree);
static tree push_overloaded_decl (tree, int, bool);
@@ -61,7 +60,25 @@
unit. */
static GTY(()) tree anonymous_namespace_name;
+/* Initialise anonymous_namespace_name if necessary, and return it. */
+static tree
+get_anonymous_namespace_name(void)
+{
+ if (!anonymous_namespace_name)
+ {
+ /* The anonymous namespace has to have a unique name
+ if typeinfo objects are being compared by name. */
+ if (! flag_weak || ! SUPPORTS_ONE_ONLY)
+ anonymous_namespace_name = get_file_function_name ("N");
+ else
+ /* The demangler expects anonymous namespaces to be called
+ something starting with '_GLOBAL__N_'. */
+ anonymous_namespace_name = get_identifier ("_GLOBAL__N_1");
+ }
+ return anonymous_namespace_name;
+}
+
/* Compute the chain index of a binding_entry given the HASH value of its
name and the total COUNT of chains. COUNT is assumed to be a power
of 2. */
@@ -302,35 +319,11 @@
cp_class_binding *cb;
cxx_binding *binding;
- if (VEC_length (cp_class_binding, scope->class_shadowed))
- {
- cp_class_binding *old_base;
- old_base = VEC_index (cp_class_binding, scope->class_shadowed, 0);
- if (VEC_reserve (cp_class_binding, gc, scope->class_shadowed, 1))
- {
- /* Fixup the current bindings, as they might have moved. */
- size_t i;
-
- for (i = 0;
- VEC_iterate (cp_class_binding, scope->class_shadowed, i, cb);
- i++)
- {
- cxx_binding **b;
- b = &IDENTIFIER_BINDING (cb->identifier);
- while (*b != &old_base[i].base)
- b = &((*b)->previous);
- *b = &cb->base;
- }
- }
- cb = VEC_quick_push (cp_class_binding, scope->class_shadowed, NULL);
- }
- else
cb = VEC_safe_push (cp_class_binding, gc, scope->class_shadowed, NULL);
cb->identifier = name;
- binding = &cb->base;
+ cb->base = binding = cxx_binding_make (value, type);
binding->scope = scope;
- cxx_binding_init (binding, value, type);
return binding;
}
@@ -346,6 +339,8 @@
{
binding = cxx_binding_make (decl, NULL_TREE);
binding->scope = level;
+ /* APPLE LOCAL blocks 6040305 (ch) */
+ binding->declared_in_block = cur_block != 0;
}
else
binding = new_class_binding (id, decl, /*type=*/NULL_TREE, level);
@@ -1804,6 +1799,8 @@
result->scope = scope;
result->is_local = false;
result->value_is_inherited = false;
+ /* APPLE LOCAL blocks 6040305 (ch) */
+ result->declared_in_block = 0;
IDENTIFIER_NAMESPACE_BINDINGS (name) = result;
return result;
}
@@ -2082,6 +2079,22 @@
return;
}
+ /* LLVM LOCAL begin mainline */
+ /* Shift the old and new bindings around so we're comparing class and
+ enumeration names to each other. */
+ if (oldval && DECL_IMPLICIT_TYPEDEF_P (oldval))
+ {
+ oldtype = oldval;
+ oldval = NULL_TREE;
+ }
+
+ if (decls.value && DECL_IMPLICIT_TYPEDEF_P (decls.value))
+ {
+ decls.type = decls.value;
+ decls.value = NULL_TREE;
+ }
+ /* LLVM LOCAL end mainline */
+
/* It is impossible to overload a built-in function; any explicit
declaration eliminates the built-in declaration. So, if OLDVAL
is a built-in, then we can just pretend it isn't there. */
@@ -2091,95 +2104,112 @@
&& !DECL_HIDDEN_FRIEND_P (oldval))
oldval = NULL_TREE;
- /* Check for using functions. */
- if (decls.value && is_overloaded_fn (decls.value))
+ /* LLVM LOCAL begin mainline */
+ if (decls.value)
{
- tree tmp, tmp1;
-
- if (oldval && !is_overloaded_fn (oldval))
+ /* Check for using functions. */
+ if (is_overloaded_fn (decls.value))
{
- if (!DECL_IMPLICIT_TYPEDEF_P (oldval))
- error ("%qD is already declared in this scope", name);
- oldval = NULL_TREE;
- }
+ tree tmp, tmp1;
- *newval = oldval;
- for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp))
- {
- tree new_fn = OVL_CURRENT (tmp);
+ if (oldval && !is_overloaded_fn (oldval))
+ {
+ error ("%qD is already declared in this scope", name);
+ oldval = NULL_TREE;
+ }
- /* [namespace.udecl]
-
- If a function declaration in namespace scope or block
- scope has the same name and the same parameter types as a
- function introduced by a using declaration the program is
- ill-formed. */
- for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1))
+ *newval = oldval;
+ for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp))
{
- tree old_fn = OVL_CURRENT (tmp1);
+ tree new_fn = OVL_CURRENT (tmp);
- if (new_fn == old_fn)
- /* The function already exists in the current namespace. */
- break;
- else if (OVL_USED (tmp1))
- continue; /* this is a using decl */
- else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
- TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
+ /* [namespace.udecl]
+
+ If a function declaration in namespace scope or block
+ scope has the same name and the same parameter types as a
+ function introduced by a using declaration the program is
+ ill-formed. */
+ for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1))
{
- gcc_assert (!DECL_ANTICIPATED (old_fn)
- || DECL_HIDDEN_FRIEND_P (old_fn));
+ tree old_fn = OVL_CURRENT (tmp1);
- /* There was already a non-using declaration in
- this scope with the same parameter types. If both
- are the same extern "C" functions, that's ok. */
- if (decls_match (new_fn, old_fn))
+ if (new_fn == old_fn)
+ /* The function already exists in the current namespace. */
break;
- else
+ else if (OVL_USED (tmp1))
+ continue; /* this is a using decl */
+ else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
+ TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
{
- error ("%qD is already declared in this scope", name);
- break;
+ gcc_assert (!DECL_ANTICIPATED (old_fn)
+ || DECL_HIDDEN_FRIEND_P (old_fn));
+
+ /* There was already a non-using declaration in
+ this scope with the same parameter types. If both
+ are the same extern "C" functions, that's ok. */
+ if (decls_match (new_fn, old_fn))
+ break;
+ else
+ {
+ error ("%qD is already declared in this scope", name);
+ break;
+ }
}
}
- }
- /* If we broke out of the loop, there's no reason to add
- this function to the using declarations for this
- scope. */
- if (tmp1)
- continue;
+ /* If we broke out of the loop, there's no reason to add
+ this function to the using declarations for this
+ scope. */
+ if (tmp1)
+ continue;
- /* If we are adding to an existing OVERLOAD, then we no
- longer know the type of the set of functions. */
- if (*newval && TREE_CODE (*newval) == OVERLOAD)
- TREE_TYPE (*newval) = unknown_type_node;
- /* Add this new function to the set. */
- *newval = build_overload (OVL_CURRENT (tmp), *newval);
- /* If there is only one function, then we use its type. (A
- using-declaration naming a single function can be used in
- contexts where overload resolution cannot be
- performed.) */
- if (TREE_CODE (*newval) != OVERLOAD)
- {
- *newval = ovl_cons (*newval, NULL_TREE);
- TREE_TYPE (*newval) = TREE_TYPE (OVL_CURRENT (tmp));
+ /* If we are adding to an existing OVERLOAD, then we no
+ longer know the type of the set of functions. */
+ if (*newval && TREE_CODE (*newval) == OVERLOAD)
+ TREE_TYPE (*newval) = unknown_type_node;
+ /* Add this new function to the set. */
+ *newval = build_overload (OVL_CURRENT (tmp), *newval);
+ /* If there is only one function, then we use its type. (A
+ using-declaration naming a single function can be used in
+ contexts where overload resolution cannot be
+ performed.) */
+ if (TREE_CODE (*newval) != OVERLOAD)
+ {
+ *newval = ovl_cons (*newval, NULL_TREE);
+ TREE_TYPE (*newval) = TREE_TYPE (OVL_CURRENT (tmp));
+ }
+ OVL_USED (*newval) = 1;
}
- OVL_USED (*newval) = 1;
}
+ else
+ {
+ *newval = decls.value;
+ if (oldval && !decls_match (*newval, oldval))
+ error ("%qD is already declared in this scope", name);
+ }
}
else
+ *newval = oldval;
+
+ if (decls.type && TREE_CODE (decls.type) == TREE_LIST)
{
- *newval = decls.value;
- if (oldval && !decls_match (*newval, oldval))
+ error ("reference to %qD is ambiguous", name);
+ print_candidates (decls.type);
+ }
+ else
+ {
+ *newtype = decls.type;
+ if (oldtype && *newtype && !decls_match (oldtype, *newtype))
error ("%qD is already declared in this scope", name);
}
- *newtype = decls.type;
- if (oldtype && *newtype && !same_type_p (oldtype, *newtype))
- {
- error ("using declaration %qD introduced ambiguous type %qT",
- name, oldtype);
- return;
- }
+ /* If *newval is empty, shift any class or enumeration name down. */
+ if (!*newval)
+ {
+ *newval = *newtype;
+ *newtype = NULL_TREE;
+ }
+ /* LLVM LOCAL end mainline */
}
/* Process a using-declaration at function scope. */
@@ -2447,7 +2477,10 @@
for (i = 0;
VEC_iterate (cp_class_binding, level->class_shadowed, i, cb);
++i)
- IDENTIFIER_BINDING (cb->identifier) = cb->base.previous;
+ {
+ IDENTIFIER_BINDING (cb->identifier) = cb->base->previous;
+ cxx_binding_free (cb->base);
+ }
ggc_free (level->class_shadowed);
level->class_shadowed = NULL;
}
@@ -3011,11 +3044,7 @@
if (anon)
{
- /* The name of anonymous namespace is unique for the translation
- unit. */
- if (!anonymous_namespace_name)
- anonymous_namespace_name = get_file_function_name ('N');
- name = anonymous_namespace_name;
+ name = get_anonymous_namespace_name();
d = IDENTIFIER_NAMESPACE_VALUE (name);
if (d)
/* Reopening anonymous namespace. */
@@ -3477,43 +3506,63 @@
XXX In what way should I treat extern declarations?
XXX I don't want to repeat the entire duplicate_decls here */
+/* LLVM LOCAL begin mainline */
static void
-ambiguous_decl (tree name, struct scope_binding *old, cxx_binding *new,
- int flags)
+ambiguous_decl (struct scope_binding *old, cxx_binding *new, int flags)
{
tree val, type;
gcc_assert (old != NULL);
+
+ /* Copy the type. */
+ type = new->type;
+ if (LOOKUP_NAMESPACES_ONLY (flags)
+ || (type && hidden_name_p (type) && !(flags & LOOKUP_HIDDEN)))
+ type = NULL_TREE;
+
/* Copy the value. */
val = new->value;
if (val)
- switch (TREE_CODE (val))
- {
- case TEMPLATE_DECL:
- /* If we expect types or namespaces, and not templates,
- or this is not a template class. */
- if ((LOOKUP_QUALIFIERS_ONLY (flags)
- && !DECL_CLASS_TEMPLATE_P (val))
- || hidden_name_p (val))
- val = NULL_TREE;
- break;
- case TYPE_DECL:
- if (LOOKUP_NAMESPACES_ONLY (flags) || hidden_name_p (val))
- val = NULL_TREE;
- break;
- case NAMESPACE_DECL:
- if (LOOKUP_TYPES_ONLY (flags))
- val = NULL_TREE;
- break;
- case FUNCTION_DECL:
- /* Ignore built-in functions that are still anticipated. */
- if (LOOKUP_QUALIFIERS_ONLY (flags) || hidden_name_p (val))
- val = NULL_TREE;
- break;
- default:
- if (LOOKUP_QUALIFIERS_ONLY (flags))
- val = NULL_TREE;
- }
+ {
+ if (hidden_name_p (val) && !(flags & LOOKUP_HIDDEN))
+ val = NULL_TREE;
+ else
+ switch (TREE_CODE (val))
+ {
+ case TEMPLATE_DECL:
+ /* If we expect types or namespaces, and not templates,
+ or this is not a template class. */
+ if ((LOOKUP_QUALIFIERS_ONLY (flags)
+ && !DECL_CLASS_TEMPLATE_P (val)))
+ val = NULL_TREE;
+ break;
+ case TYPE_DECL:
+ if (LOOKUP_NAMESPACES_ONLY (flags)
+ || (type && (flags & LOOKUP_PREFER_TYPES)))
+ val = NULL_TREE;
+ break;
+ case NAMESPACE_DECL:
+ if (LOOKUP_TYPES_ONLY (flags))
+ val = NULL_TREE;
+ break;
+ case FUNCTION_DECL:
+ /* Ignore built-in functions that are still anticipated. */
+ if (LOOKUP_QUALIFIERS_ONLY (flags))
+ val = NULL_TREE;
+ break;
+ default:
+ if (LOOKUP_QUALIFIERS_ONLY (flags))
+ val = NULL_TREE;
+ }
+ }
+ /* If val is hidden, shift down any class or enumeration name. */
+ if (!val)
+ {
+ val = type;
+ type = NULL_TREE;
+ }
+
+/* LLVM LOCAL end mainline */
if (!old->value)
old->value = val;
else if (val && val != old->value)
@@ -3523,25 +3572,21 @@
else
{
old->value = tree_cons (NULL_TREE, old->value,
- build_tree_list (NULL_TREE, new->value));
+ build_tree_list (NULL_TREE, val));
TREE_TYPE (old->value) = error_mark_node;
}
}
- /* ... and copy the type. */
- type = new->type;
- if (LOOKUP_NAMESPACES_ONLY (flags))
- type = NULL_TREE;
+
+ /* LLVM LOCAL begin mainline */
if (!old->type)
old->type = type;
else if (type && old->type != type)
{
- if (flags & LOOKUP_COMPLAIN)
- {
- error ("%qD denotes an ambiguous type",name);
- error ("%J first type here", TYPE_MAIN_DECL (old->type));
- error ("%J other type here", TYPE_MAIN_DECL (type));
- }
+ old->type = tree_cons (NULL_TREE, old->type,
+ build_tree_list (NULL_TREE, type));
+ TREE_TYPE (old->type) = error_mark_node;
}
+ /* LLVM LOCAL end mainline */
}
/* Return the declarations that are members of the namespace NS. */
@@ -3630,36 +3675,6 @@
return fns;
}
-/* Select the right _DECL from multiple choices. */
-
-static tree
-select_decl (const struct scope_binding *binding, int flags)
-{
- tree val;
- val = binding->value;
-
- timevar_push (TV_NAME_LOOKUP);
- if (LOOKUP_NAMESPACES_ONLY (flags))
- {
- /* We are not interested in types. */
- if (val && (TREE_CODE (val) == NAMESPACE_DECL
- || TREE_CODE (val) == TREE_LIST))
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
- }
-
- /* If looking for a type, or if there is no non-type binding, select
- the value binding. */
- if (binding->type && (!val || (flags & LOOKUP_PREFER_TYPES)))
- val = binding->type;
- /* Don't return non-types if we really prefer types. */
- else if (val && LOOKUP_TYPES_ONLY (flags)
- && ! DECL_DECLARES_TYPE_P (val))
- val = NULL_TREE;
-
- POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
-}
-
/* Unscoped lookup of a global: iterate over current namespaces,
considering using-directives. */
@@ -3671,22 +3686,18 @@
tree siter;
struct cp_binding_level *level;
tree val = NULL_TREE;
- struct scope_binding binding = EMPTY_SCOPE_BINDING;
timevar_push (TV_NAME_LOOKUP);
for (; !val; scope = CP_DECL_CONTEXT (scope))
{
+ struct scope_binding binding = EMPTY_SCOPE_BINDING;
cxx_binding *b =
cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
if (b)
- {
- if (b->value
- && ((flags & LOOKUP_HIDDEN) || !hidden_name_p (b->value)))
- binding.value = b->value;
- binding.type = b->type;
- }
+ /* LLVM LOCAL mainline */
+ ambiguous_decl (&binding, b, flags);
/* Add all _DECLs seen through local using-directives. */
for (level = current_binding_level;
@@ -3711,7 +3722,7 @@
siter = CP_DECL_CONTEXT (siter);
}
- val = select_decl (&binding, flags);
+ val = binding.value;
if (scope == global_namespace)
break;
}
@@ -3741,7 +3752,7 @@
if (is_type_p)
flags |= LOOKUP_PREFER_TYPES;
if (qualified_lookup_using_namespace (name, scope, &binding, flags))
- t = select_decl (&binding, flags);
+ t = binding.value;
}
else if (is_aggr_type (scope, complain))
t = lookup_member (scope, name, 2, is_type_p);
@@ -3774,7 +3785,8 @@
cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (used), name);
/* Resolve ambiguities. */
if (val1)
- ambiguous_decl (name, val, val1, flags);
+ /* LLVM LOCAL mainline */
+ ambiguous_decl (val, val1, flags);
}
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val->value != error_mark_node);
}
@@ -3803,7 +3815,8 @@
cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
seen = tree_cons (scope, NULL_TREE, seen);
if (binding)
- ambiguous_decl (name, result, binding, flags);
+ /* LLVM LOCAL mainline */
+ ambiguous_decl (result, binding, flags);
/* Consider strong using directives always, and non-strong ones
if we haven't found a binding yet. ??? Shouldn't we consider
@@ -4567,6 +4580,8 @@
return arg_assoc_type (k, TYPE_PTRMEMFUNC_FN_TYPE (type));
return arg_assoc_class (k, type);
case POINTER_TYPE:
+ /* APPLE LOCAL blocks 6040305 */
+ case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
case ARRAY_TYPE:
return arg_assoc_type (k, TREE_TYPE (type));
Modified: trunk/contrib/gcc/cp/name-lookup.h
===================================================================
--- trunk/contrib/gcc4/cp/name-lookup.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/name-lookup.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -76,6 +76,8 @@
cxx_scope *scope;
unsigned value_is_inherited : 1;
unsigned is_local : 1;
+ /* APPLE LOCAL blocks 6040305 (ch) */
+ unsigned declared_in_block : 1;
};
/* Datatype used to temporarily save C++ bindings (for implicit
@@ -142,7 +144,7 @@
typedef struct cp_class_binding GTY(())
{
- cxx_binding base;
+ cxx_binding *base;
/* The bound name. */
tree identifier;
} cp_class_binding;
Modified: trunk/contrib/gcc/cp/parser.c
===================================================================
--- trunk/contrib/gcc4/cp/parser.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/parser.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -38,6 +38,8 @@
#include "target.h"
#include "cgraph.h"
#include "c-common.h"
+/* APPLE LOCAL C* language */
+#include "tree-iterator.h"
/* The lexer. */
@@ -1120,6 +1122,10 @@
typedef enum cp_parser_declarator_kind
{
+ /* APPLE LOCAL begin blocks 6339747 */
+ /* We want a block declarator. */
+ CP_PARSER_DECLARATOR_BLOCK,
+ /* APPLE LOCAL end blocks 6339747 */
/* We want an abstract declarator. */
CP_PARSER_DECLARATOR_ABSTRACT,
/* We want a named declarator. */
@@ -1177,8 +1183,15 @@
typedef struct cp_parser_expression_stack_entry
{
+ /* Left hand side of the binary operation we are currently
+ parsing. */
tree lhs;
+ /* Original tree code for left hand side, if it was a binary
+ expression itself (used for -Wparentheses). */
+ enum tree_code lhs_type;
+ /* Tree code for the binary operation we are parsing. */
enum tree_code tree_type;
+ /* Precedence of the binary operation we are parsing. */
int prec;
} cp_parser_expression_stack_entry;
@@ -1532,21 +1545,39 @@
(cp_parser *, bool, bool *);
static tree cp_parser_builtin_offsetof
(cp_parser *);
+/* APPLE LOCAL begin blocks 6040305 (ca) */
+static tree cp_parser_block_literal_expr (cp_parser *);
+/* APPLE LOCAL end blocks 6040305 (ca) */
+/* APPLE LOCAL begin C* language */
+static void objc_foreach_stmt
+ (cp_parser *, tree);
+/* APPLE LOCAL end C* language */
+/* APPLE LOCAL begin C* property (Radar 4436866) */
+static void objc_cp_parser_at_property
+ (cp_parser *);
+static void objc_cp_parse_property_decl
+ (cp_parser *);
+/* APPLE LOCAL end C* property (Radar 4436866) */
+/* APPLE LOCAL begin radar 4548636 */
+static bool objc_attr_follwed_by_at_keyword
+ (cp_parser *);
+/* APPLE LOCAL end radar 4548636 */
/* Statements [gram.stmt.stmt] */
static void cp_parser_statement
- (cp_parser *, tree, bool);
+ (cp_parser *, tree, bool, bool *);
static void cp_parser_label_for_labeled_statement
(cp_parser *);
static tree cp_parser_expression_statement
(cp_parser *, tree);
static tree cp_parser_compound_statement
- (cp_parser *, tree, bool);
+ /* APPLE LOCAL radar 5982990 */
+ (cp_parser *, tree, bool, bool);
static void cp_parser_statement_seq_opt
(cp_parser *, tree);
static tree cp_parser_selection_statement
- (cp_parser *);
+ (cp_parser *, bool *);
static tree cp_parser_condition
(cp_parser *);
static tree cp_parser_iteration_statement
@@ -1559,7 +1590,7 @@
(cp_parser *);
static tree cp_parser_implicitly_scoped_statement
- (cp_parser *);
+ (cp_parser *, bool *);
static void cp_parser_already_scoped_statement
(cp_parser *);
@@ -1770,6 +1801,10 @@
(cp_parser *);
static tree cp_parser_objc_message_expression
(cp_parser *);
+/* APPLE LOCAL begin radar 5277239 */
+static tree cp_parser_objc_reference_expression
+ (cp_parser *, tree);
+/* APPLE LOCAL end radar 5277239 */
static tree cp_parser_objc_encode_expression
(cp_parser *);
static tree cp_parser_objc_defs_expression
@@ -1784,6 +1819,12 @@
(enum cpp_ttype);
static tree cp_parser_objc_selector
(cp_parser *);
+/* APPLE LOCAL begin radar 3803157 - objc attribute */
+static void cp_parser_objc_maybe_attributes
+(cp_parser *, tree *);
+static tree cp_parser_objc_identifier_list
+(cp_parser *);
+/* APPLE LOCAL end radar 3803157 - objc attribute */
static tree cp_parser_objc_protocol_refs_opt
(cp_parser *);
static void cp_parser_objc_declaration
@@ -2436,6 +2477,141 @@
}
}
+/* APPLE LOCAL begin radar 5277239 */
+/* This routine checks that type_decl is a class or class object followed by a '.'
+ which is an alternative syntax to class-method messaging [class-name class-method]
+ */
+
+static bool
+cp_objc_property_reference_prefix (cp_parser *parser, tree type)
+{
+ return c_dialect_objc () && cp_lexer_peek_token (parser->lexer)->type == CPP_DOT
+ && (objc_is_id (type) || objc_is_class_name (type));
+}
+/* APPLE LOCAL end radar 5277239 */
+/* APPLE LOCAL begin C* property (Radar 4436866, 4591909) */
+/* This routine parses the propery declarations. */
+
+static void
+objc_cp_parse_property_decl (cp_parser *parser)
+{
+ int declares_class_or_enum;
+ cp_decl_specifier_seq declspecs;
+
+ cp_parser_decl_specifier_seq (parser,
+ CP_PARSER_FLAGS_NONE,
+ &declspecs,
+ &declares_class_or_enum);
+ /* Keep going until we hit the `;' at the end of the declaration. */
+ while (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
+ {
+ tree property;
+ cp_token *token;
+ cp_declarator *declarator
+ = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED,
+ NULL, NULL, false);
+ property = grokdeclarator (declarator, &declspecs, NORMAL,0, NULL);
+ /* Revover from any kind of error in property declaration. */
+ if (property == error_mark_node || property == NULL_TREE)
+ return;
+ /* Add to property list. */
+ objc_add_property_variable (copy_node (property));
+ if (token->type == CPP_COMMA)
+ {
+ cp_lexer_consume_token (parser->lexer); /* Eat ','. */
+ continue;
+ }
+ else if (token->type == CPP_EOF)
+ return;
+ }
+ cp_lexer_consume_token (parser->lexer); /* Eat ';'. */
+}
+
+/* This function parses a @property declaration inside an objective class
+ or its implementation. */
+
+static void
+objc_cp_parser_at_property (cp_parser *parser)
+{
+ cp_token *token;
+
+ objc_set_property_attr (0, NULL_TREE);
+ /* Consume @property */
+ cp_lexer_consume_token (parser->lexer);
+ token = cp_lexer_peek_token (parser->lexer);
+ if (token->type == CPP_OPEN_PAREN)
+ {
+ cp_lexer_consume_token (parser->lexer);
+ while (token->type != CPP_CLOSE_PAREN && token->type != CPP_EOF)
+ {
+ tree node;
+ /* property has attribute list. */
+ /* Consume '(' */
+ node = cp_parser_identifier (parser);
+ if (node == ridpointers [(int) RID_READONLY])
+ {
+ /* Do the readyonly thing. */
+ objc_set_property_attr (1, NULL_TREE);
+ }
+ else if (node == ridpointers [(int) RID_GETTER]
+ || node == ridpointers [(int) RID_SETTER])
+ {
+ /* Do the getter/setter attribute. */
+ token = cp_lexer_consume_token (parser->lexer);
+ if (token->type == CPP_EQ)
+ {
+ /* APPLE LOCAL radar 4675792 */
+ tree attr_ident = cp_parser_objc_selector (parser);
+ int num;
+ if (node == ridpointers [(int) RID_GETTER])
+ num = 2;
+ else
+ {
+ num = 3;
+ /* Consume the ':' which must always follow the setter name. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
+ cp_lexer_consume_token (parser->lexer);
+ }
+ objc_set_property_attr (num, attr_ident);
+ }
+ else
+ {
+ error ("getter/setter attribute must be followed by '='");
+ break;
+ }
+ }
+ /* APPLE LOCAL begin radar 4947014 - objc atomic property */
+ else if (node == ridpointers [(int) RID_NONATOMIC])
+ {
+ objc_set_property_attr (13, NULL_TREE);
+ }
+ /* APPLE LOCAL end radar 4947014 - objc atomic property */
+ else
+ {
+ error ("unknown property attribute");
+ break;
+ }
+ /* APPLE LOCAL begin radar 6302949 */
+ if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)
+ && cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)
+ && cp_lexer_next_token_is_not (parser->lexer, CPP_EOF))
+ warning (0, "property attributes must be separated by a comma");
+ /* APPLE LOCAL end radar 6302949 */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
+ cp_lexer_consume_token (parser->lexer);
+ token = cp_lexer_peek_token (parser->lexer);
+ }
+ if (token->type != CPP_CLOSE_PAREN)
+ {
+ error ("syntax error in @property's attribute declaration");
+ }
+ /* Consume ')' */
+ cp_lexer_consume_token (parser->lexer);
+ }
+ objc_cp_parse_property_decl (parser);
+}
+/* APPLE LOCAL end C* property (Radar 4436866, 4591909) */
+
/* This function is called at the end of a statement or declaration.
If the next token is a semicolon, it is consumed; otherwise, error
recovery is attempted. */
@@ -2894,6 +3070,8 @@
( compound-statement )
__builtin_va_arg ( assignment-expression , type-id )
__builtin_offsetof ( type-id , offsetof-expression )
+ APPLE LOCAL blocks 6040305 (cf)
+ block-literal-expr
Objective-C++ Extension:
@@ -2927,6 +3105,16 @@
token = cp_lexer_peek_token (parser->lexer);
switch (token->type)
{
+ /* APPLE LOCAL begin blocks 6040305 (cf) */
+ case CPP_XOR:
+ if (flag_blocks)
+ {
+ tree expr = cp_parser_block_literal_expr (parser);
+ return expr;
+ }
+ cp_parser_error (parser, "expected primary-expression");
+ return error_mark_node;
+ /* APPLE LOCAL end blocks 6040305 (cf) */
/* literal:
integer-literal
character-literal
@@ -3020,7 +3208,8 @@
/* Start the statement-expression. */
expr = begin_stmt_expr ();
/* Parse the compound-statement. */
- cp_parser_compound_statement (parser, expr, false);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, expr, false, false);
/* Finish up. */
expr = finish_stmt_expr (expr, false);
}
@@ -3190,6 +3379,11 @@
if (ambiguous_decls)
return error_mark_node;
+ /* APPLE LOCAL begin radar 5277239 */
+ if (TREE_CODE (decl) == TYPE_DECL
+ && cp_objc_property_reference_prefix (parser, TREE_TYPE (decl)))
+ return cp_parser_objc_reference_expression (parser, decl);
+ /* APPLE LOCAL end radar 5277239 */
/* In Objective-C++, an instance variable (ivar) may be preferred
to whatever cp_parser_lookup_name() found. */
decl = objc_lookup_ivar (decl, id_expression);
@@ -5730,12 +5924,13 @@
cp_parser_expression_stack_entry *sp = &stack[0];
tree lhs, rhs;
cp_token *token;
- enum tree_code tree_type;
+ enum tree_code tree_type, lhs_type, rhs_type;
enum cp_parser_prec prec = PREC_NOT_OPERATOR, new_prec, lookahead_prec;
bool overloaded_p;
/* Parse the first expression. */
lhs = cp_parser_cast_expression (parser, /*address_p=*/false, cast_p);
+ lhs_type = ERROR_MARK;
for (;;)
{
@@ -5768,6 +5963,7 @@
/* Extract another operand. It may be the RHS of this expression
or the LHS of a new, higher priority expression. */
rhs = cp_parser_simple_cast_expression (parser);
+ rhs_type = ERROR_MARK;
/* Get another operator token. Look up its precedence to avoid
building a useless (immediately popped) stack entry for common
@@ -5783,8 +5979,10 @@
sp->prec = prec;
sp->tree_type = tree_type;
sp->lhs = lhs;
+ sp->lhs_type = lhs_type;
sp++;
lhs = rhs;
+ lhs_type = rhs_type;
prec = new_prec;
new_prec = lookahead_prec;
goto get_rhs;
@@ -5801,11 +5999,15 @@
prec = sp->prec;
tree_type = sp->tree_type;
rhs = lhs;
+ rhs_type = lhs_type;
lhs = sp->lhs;
+ lhs_type = sp->lhs_type;
}
overloaded_p = false;
- lhs = build_x_binary_op (tree_type, lhs, rhs, &overloaded_p);
+ lhs = build_x_binary_op (tree_type, lhs, lhs_type, rhs, rhs_type,
+ &overloaded_p);
+ lhs_type = tree_type;
/* If the binary operator required the use of an overloaded operator,
then this expression cannot be an integral constant-expression.
@@ -6222,11 +6424,15 @@
try-block
IN_COMPOUND is true when the statement is nested inside a
- cp_parser_compound_statement; this matters for certain pragmas. */
+ cp_parser_compound_statement; this matters for certain pragmas.
+ If IF_P is not NULL, *IF_P is set to indicate whether the statement
+ is a (possibly labeled) if statement which is not enclosed in braces
+ and has an else clause. This is used to implement -Wparentheses. */
+
static void
cp_parser_statement (cp_parser* parser, tree in_statement_expr,
- bool in_compound)
+ bool in_compound, bool *if_p)
{
tree statement;
cp_token *token;
@@ -6233,6 +6439,8 @@
location_t statement_location;
restart:
+ if (if_p != NULL)
+ *if_p = false;
/* There is no statement yet. */
statement = NULL_TREE;
/* Peek at the next token. */
@@ -6257,7 +6465,7 @@
case RID_IF:
case RID_SWITCH:
- statement = cp_parser_selection_statement (parser);
+ statement = cp_parser_selection_statement (parser, if_p);
break;
case RID_WHILE:
@@ -6308,7 +6516,8 @@
}
/* Anything that starts with a `{' must be a compound-statement. */
else if (token->type == CPP_OPEN_BRACE)
- statement = cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ statement = cp_parser_compound_statement (parser, NULL, false, false);
/* CPP_PRAGMA is a #pragma inside a function body, which constitutes
a statement all its own. */
else if (token->type == CPP_PRAGMA)
@@ -6482,7 +6691,8 @@
static tree
cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr,
- bool in_try)
+ /* APPLE LOCAL radar 5982990 */
+ bool in_try, bool objc_sjlj_exceptions)
{
tree compound_stmt;
@@ -6493,6 +6703,10 @@
compound_stmt = begin_compound_stmt (in_try ? BCS_TRY_BLOCK : 0);
/* Parse an (optional) statement-seq. */
cp_parser_statement_seq_opt (parser, in_statement_expr);
+ /* APPLE LOCAL begin radar 5982990 */
+ if (objc_sjlj_exceptions)
+ objc_mark_locals_volatile (NULL);
+ /* APPLE LOCAL end radar 5982990 */
/* Finish the compound-statement. */
finish_compound_stmt (compound_stmt);
/* Consume the `}'. */
@@ -6510,19 +6724,47 @@
static void
cp_parser_statement_seq_opt (cp_parser* parser, tree in_statement_expr)
{
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ tree class_type = DECL_CONTEXT (current_function_decl);
+
+ bool determine_destructor_triviality =
+ DECL_DESTRUCTOR_P (current_function_decl) && class_type != NULL_TREE
+ && !CLASSTYPE_DESTRUCTOR_TRIVIALITY_FINAL (class_type);
+
+ /* Assume that the destructor is trivial at first, and mark nontrivial if
+ any statement is parsed. */
+ if (determine_destructor_triviality)
+ {
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (class_type) = 0;
+ CLASSTYPE_DESTRUCTOR_TRIVIALITY_FINAL (class_type) = 1;
+ }
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
+
/* Scan statements until there aren't any more. */
while (true)
{
cp_token *token = cp_lexer_peek_token (parser->lexer);
- /* If we're looking at a `}', then we've run out of statements. */
+ /* APPLE LOCAL begin ObjC++ 4185810 */
+ /* If we're looking at a `}', then we've run out of
+ statements; the same is true if we have reached the end
+ of file, or have stumbled upon a stray 'else' or '@end'. */
if (token->type == CPP_CLOSE_BRACE
|| token->type == CPP_EOF
- || token->type == CPP_PRAGMA_EOL)
+ || token->type == CPP_PRAGMA_EOL
+ || (token->type == CPP_KEYWORD
+ && (token->keyword == RID_ELSE
+ || token->keyword == RID_AT_END)))
+ /* APPLE LOCAL end ObjC++ 4185810 */
break;
+ /* APPLE LOCAL begin omit calls to empty destructors 5559195 */
+ if (determine_destructor_triviality)
+ CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (class_type) = 1;
+ /* APPLE LOCAL end omit calls to empty destructors 5559195 */
+
/* Parse the statement. */
- cp_parser_statement (parser, in_statement_expr, true);
+ cp_parser_statement (parser, in_statement_expr, true, NULL);
}
}
@@ -6533,14 +6775,22 @@
if ( condition ) statement else statement
switch ( condition ) statement
- Returns the new IF_STMT or SWITCH_STMT. */
+ Returns the new IF_STMT or SWITCH_STMT.
+ If IF_P is not NULL, *IF_P is set to indicate whether the statement
+ is a (possibly labeled) if statement which is not enclosed in
+ braces and has an else clause. This is used to implement
+ -Wparentheses. */
+
static tree
-cp_parser_selection_statement (cp_parser* parser)
+cp_parser_selection_statement (cp_parser* parser, bool *if_p)
{
cp_token *token;
enum rid keyword;
+ if (if_p != NULL)
+ *if_p = false;
+
/* Peek at the next token. */
token = cp_parser_require (parser, CPP_KEYWORD, "selection-statement");
@@ -6576,11 +6826,13 @@
if (keyword == RID_IF)
{
+ bool nested_if;
+
/* Add the condition. */
finish_if_stmt_cond (condition, statement);
/* Parse the then-clause. */
- cp_parser_implicitly_scoped_statement (parser);
+ cp_parser_implicitly_scoped_statement (parser, &nested_if);
finish_then_clause (statement);
/* If the next token is `else', parse the else-clause. */
@@ -6591,9 +6843,29 @@
cp_lexer_consume_token (parser->lexer);
begin_else_clause (statement);
/* Parse the else-clause. */
- cp_parser_implicitly_scoped_statement (parser);
+ cp_parser_implicitly_scoped_statement (parser, NULL);
finish_else_clause (statement);
+
+ /* If we are currently parsing a then-clause, then
+ IF_P will not be NULL. We set it to true to
+ indicate that this if statement has an else clause.
+ This may trigger the Wparentheses warning below
+ when we get back up to the parent if statement. */
+ if (if_p != NULL)
+ *if_p = true;
}
+ else
+ {
+ /* This if statement does not have an else clause. If
+ NESTED_IF is true, then the then-clause is an if
+ statement which does have an else clause. We warn
+ about the potential ambiguity. */
+ if (nested_if)
+ warning (OPT_Wparentheses,
+ ("%Hsuggest explicit braces "
+ "to avoid ambiguous %<else%>"),
+ EXPR_LOCUS (statement));
+ }
/* Now we're all done with the if-statement. */
finish_if_stmt (statement);
@@ -6611,7 +6883,7 @@
in_statement = parser->in_statement;
parser->in_switch_statement_p = true;
parser->in_statement |= IN_SWITCH_STMT;
- cp_parser_implicitly_scoped_statement (parser);
+ cp_parser_implicitly_scoped_statement (parser, NULL);
parser->in_switch_statement_p = in_switch_statement_p;
parser->in_statement = in_statement;
@@ -6728,14 +7000,132 @@
return cp_parser_expression (parser, /*cast_p=*/false);
}
+/* APPLE LOCAL begin radar 4631818 */
+/* This routine looks for objective-c++'s foreach statement by scanning for-loop
+ header looking for either 1) 'for (type selector in...)' or 2) 'for (selector in...)'
+ where selector is already declared in outer scope. If it failed, it undoes the lexical
+ look-ahead and returns false. If it succeeded, it adds the 'selector' to the statement
+ list and returns true. At success, lexer points to token following the 'in' keyword.
+*/
+
+static bool
+cp_parser_parse_foreach_stmt (cp_parser *parser)
+{
+ int decl_spec_declares_class_or_enum;
+ bool is_cv_qualifier;
+ tree type_spec;
+ cp_decl_specifier_seq decl_specs;
+ tree node;
+ cp_token *token;
+ bool is_legit_foreach = false;
+ cp_declarator *declarator;
+
+ /* Exclude class/struct/enum type definition in for-loop header, which is
+ aparently legal in c++. Otherwise, it causes side-effect (type is enterred
+ in function's scope) when type is re-parsed. */
+ token = cp_lexer_peek_token (parser->lexer);
+ if (cp_parser_token_is_class_key (token) || token->keyword == RID_ENUM)
+ return false;
+
+ cp_parser_parse_tentatively (parser);
+ clear_decl_specs (&decl_specs);
+ type_spec
+ = cp_parser_type_specifier (parser, CP_PARSER_FLAGS_OPTIONAL,
+ &decl_specs,
+ /*is_declaration=*/true,
+ &decl_spec_declares_class_or_enum,
+ &is_cv_qualifier);
+ declarator
+ = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED,
+ NULL,
+ /*parenthesized_p=*/NULL,
+ /*member_p=*/false);
+ if (declarator == cp_error_declarator)
+ {
+ cp_parser_abort_tentative_parse (parser);
+ return false;
+ }
+
+ token = cp_lexer_peek_token (parser->lexer);
+
+ node = token->u.value;
+ if (node && TREE_CODE (node) == IDENTIFIER_NODE
+ && node == ridpointers [(int) RID_IN])
+ {
+ enum cpp_ttype nt = cp_lexer_peek_nth_token (parser->lexer, 2)->type;
+ switch (nt)
+ {
+ case CPP_NAME:
+ case CPP_OPEN_PAREN:
+ case CPP_MULT:
+ case CPP_PLUS: case CPP_PLUS_PLUS:
+ case CPP_MINUS: case CPP_MINUS_MINUS:
+ case CPP_OPEN_SQUARE:
+ is_legit_foreach = true;
+ default:
+ break;
+ }
+ }
+ if (is_legit_foreach)
+ {
+ tree pushed_scope = NULL;
+ tree decl;
+ if (type_spec)
+ {
+ /* we have: 'for (type selector in...)' */
+ cp_parser_commit_to_tentative_parse (parser);
+ decl = start_decl (declarator, &decl_specs,
+ false /*is_initialized*/,
+ NULL_TREE /*attributes*/,
+ NULL_TREE /*prefix_attributes*/,
+ &pushed_scope);
+ /* APPLE LOCAL begin radar 5130983 */
+ if (!decl || decl == error_mark_node)
+ {
+ error ("selector is undeclared");
+ is_legit_foreach = false;
+ }
+ else
+ cp_finish_decl (decl,
+ NULL_TREE /*initializer*/,
+ false /*init_const_expr_p=*/,
+ NULL_TREE /*asm_specification*/,
+ 0 /*flags */);
+ }
+ else {
+ tree statement;
+ /* we have: 'for (selector in...)' */
+ /* Parse it as an expression. */
+ cp_parser_abort_tentative_parse (parser);
+ statement = cp_parser_expression (parser, /*cast_p=*/false);
+ add_stmt (statement);
+ }
+ /* APPLE LOCAL end radar 5130983 */
+ /* Consume the 'in' token */
+ cp_lexer_consume_token (parser->lexer);
+ }
+ else
+ cp_parser_abort_tentative_parse (parser);
+ return is_legit_foreach;
+}
+/* APPLE LOCAL end radar 4631818 */
+
/* Parse an iteration-statement.
iteration-statement:
- while ( condition ) statement
- do statement while ( expression ) ;
for ( for-init-statement condition [opt] ; expression [opt] )
statement
+ APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+ GNU extension:
+
+ while attributes [opt] ( condition ) statement
+ do attributes [opt] statement while ( expression ) ;
+ for attributes [opt]
+ ( for-init-statement condition [opt] ; expression [opt] )
+ statement
+
+ APPLE LOCAL end for-fsf-4_4 3274130 5295549
Returns the new WHILE_STMT, DO_STMT, or FOR_STMT. */
static tree
@@ -6743,10 +7133,14 @@
{
cp_token *token;
enum rid keyword;
- tree statement;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tree statement, attributes;
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
unsigned char in_statement;
- /* Peek at the next token. */
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ /* Get the keyword at the start of the loop. */
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
token = cp_parser_require (parser, CPP_KEYWORD, "iteration-statement");
if (!token)
return error_mark_node;
@@ -6755,6 +7149,11 @@
statement. */
in_statement = parser->in_statement;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ /* Parse the attributes, if any. */
+ attributes = cp_parser_attributes_opt (parser);
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* See what kind of keyword it is. */
keyword = token->keyword;
switch (keyword)
@@ -6764,7 +7163,9 @@
tree condition;
/* Begin the while-statement. */
- statement = begin_while_stmt ();
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ statement = begin_while_stmt (attributes);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "`('");
/* Parse the condition. */
@@ -6786,10 +7187,12 @@
tree expression;
/* Begin the do-statement. */
- statement = begin_do_stmt ();
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ statement = begin_do_stmt (attributes);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* Parse the body of the do-statement. */
parser->in_statement = IN_ITERATION_STMT;
- cp_parser_implicitly_scoped_statement (parser);
+ cp_parser_implicitly_scoped_statement (parser, NULL);
parser->in_statement = in_statement;
finish_do_body (statement);
/* Look for the `while' keyword. */
@@ -6813,7 +7216,9 @@
tree expression = NULL_TREE;
/* Begin the for-statement. */
- statement = begin_for_stmt ();
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ statement = begin_for_stmt (attributes);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "`('");
/* Parse the initialization. */
@@ -6974,6 +7379,10 @@
break;
case RID_GOTO:
+ /* APPLE LOCAL begin blocks 6040305 (cb) */
+ if (cur_block)
+ error ("goto not allowed in block literal");
+ /* APPLE LOCAL end blocks 6040305 (cb) */
/* Create the goto-statement. */
if (cp_lexer_next_token_is (parser->lexer, CPP_MULT))
{
@@ -7031,13 +7440,21 @@
but ensures that is in its own scope, even if it is not a
compound-statement.
+ If IF_P is not NULL, *IF_P is set to indicate whether the statement
+ is a (possibly labeled) if statement which is not enclosed in
+ braces and has an else clause. This is used to implement
+ -Wparentheses.
+
Returns the new statement. */
static tree
-cp_parser_implicitly_scoped_statement (cp_parser* parser)
+cp_parser_implicitly_scoped_statement (cp_parser* parser, bool *if_p)
{
tree statement;
+ if (if_p != NULL)
+ *if_p = false;
+
/* Mark if () ; with a special NOP_EXPR. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
@@ -7046,7 +7463,8 @@
}
/* if a compound is opened, we simply parse the statement directly. */
else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
- statement = cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ statement = cp_parser_compound_statement (parser, NULL, false, false);
/* If the token is not a `{', then we must take special action. */
else
{
@@ -7053,7 +7471,7 @@
/* Create a compound-statement. */
statement = begin_compound_stmt (0);
/* Parse the dependent-statement. */
- cp_parser_statement (parser, NULL_TREE, false);
+ cp_parser_statement (parser, NULL_TREE, false, if_p);
/* Finish the dummy compound-statement. */
finish_compound_stmt (statement);
}
@@ -7072,7 +7490,7 @@
{
/* If the token is a `{', then we must take special action. */
if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
- cp_parser_statement (parser, NULL_TREE, false);
+ cp_parser_statement (parser, NULL_TREE, false, NULL);
else
{
/* Avoid calling cp_parser_compound_statement, so that we
@@ -10253,6 +10671,7 @@
if (parser->scope)
{
tree decl;
+ tree ambiguous_decls;
decl = cp_parser_lookup_name (parser, identifier,
tag_type,
@@ -10259,8 +10678,13 @@
/*is_template=*/false,
/*is_namespace=*/false,
/*check_dependency=*/true,
- /*ambiguous_decls=*/NULL);
+ &ambiguous_decls);
+ /* If the lookup was ambiguous, an error will already have been
+ issued. */
+ if (ambiguous_decls)
+ return error_mark_node;
+
/* If we are parsing friend declaration, DECL may be a
TEMPLATE_DECL tree node here. However, we need to check
whether this TEMPLATE_DECL results in valid code. Consider
@@ -11369,6 +11793,37 @@
return decl;
}
+/* APPLE LOCAL begin blocks 6040305 (cc) */
+static cp_cv_quals
+cp_parser_cv_qualifier_or_attribute_seq_opt (cp_parser *parser, tree *attrs_p)
+{
+ cp_cv_quals quals = TYPE_UNQUALIFIED;
+ cp_cv_quals q;
+ cp_token *token;
+
+ *attrs_p = NULL_TREE;
+ while (true)
+ {
+ /* Peek at the next token. */
+ token = cp_lexer_peek_token (parser->lexer);
+ /* Handle attributes. */
+ if (token->keyword == RID_ATTRIBUTE)
+ {
+ /* Parse the attributes. */
+ *attrs_p = chainon (*attrs_p,
+ cp_parser_attributes_opt (parser));
+ continue;
+ }
+
+ q = cp_parser_cv_qualifier_seq_opt (parser);
+ if (q == TYPE_UNQUALIFIED)
+ break;
+ quals |= q;
+ }
+ return quals;
+}
+/* APPLE LOCAL end blocks 6040305 (cc) */
+
/* Parse a declarator.
declarator:
@@ -11389,6 +11844,12 @@
attributes [opt] ptr-operator abstract-declarator [opt]
attributes [opt] direct-abstract-declarator
+ APPLE LOCAL begin blocks 6339747
+ block-declarator:
+ attributes [opt] ptr-operator block-declarator [opt]
+ attributes [opt] direct-block-declarator
+ APPLE LOCAL end blocks 6339747
+
If CTOR_DTOR_OR_CONV_P is not NULL, *CTOR_DTOR_OR_CONV_P is used to
detect constructor, destructor or conversion operators. It is set
to -1 if the declarator is a name, and +1 if it is a
@@ -11433,6 +11894,28 @@
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
+ /* APPLE LOCAL begin blocks 6040305 (cc) */
+ if (flag_blocks && token->type == CPP_XOR)
+ {
+ cp_cv_quals quals;
+ cp_declarator *inner;
+ tree attrs;
+
+ cp_lexer_consume_token (parser->lexer);
+
+ /* cp_parse_declspecs (parser, quals_attrs, false, false, true); */
+ quals = cp_parser_cv_qualifier_or_attribute_seq_opt (parser, &attrs);
+
+ inner = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_EITHER,
+ /*ctor_dtor_or_conv_p=*/NULL,
+ /*parenthesized_p=*/NULL,
+ /*member_p=*/false);
+ if (inner == cp_error_declarator)
+ return inner;
+ return make_block_pointer_declarator (attrs, quals, inner);
+ }
+ /* APPLE LOCAL end blocks 6040305 (cc) */
+
/* Check for the ptr-operator production. */
cp_parser_parse_tentatively (parser);
/* Parse the ptr-operator. */
@@ -11508,6 +11991,17 @@
direct-abstract-declarator [opt] [ constant-expression [opt] ]
( abstract-declarator )
+ APPLE LOCAL begin blocks 6339747
+ GNU Extensions:
+
+ direct-block-declarator:
+ direct-block-declarator [opt]
+ ( parameter-declaration-clause ) [opt]
+ exception-specification [opt]
+ direct-block-declarator [opt] [ constant-expression [opt] ]
+ ( block-declarator )
+ APPLE LOCAL end blocks 6339747
+
Returns a representation of the declarator. DCL_KIND is
CP_PARSER_DECLARATOR_ABSTRACT, if we are parsing a
direct-abstract-declarator. It is CP_PARSER_DECLARATOR_NAMED, if
@@ -11624,8 +12118,16 @@
/* Consume the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
- /* Parse the cv-qualifier-seq. */
- cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
+ /* APPLE LOCAL begin blocks 6339747 */
+ if (dcl_kind != BLOCKDEF)
+ {
+ /* Parse the cv-qualifier-seq. */
+ cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
+ }
+ else
+ cv_quals = TYPE_UNQUALIFIED;
+ /* APPLE LOCAL end blocks 6339747 */
+
/* And the exception-specification. */
exception_specification
= cp_parser_exception_specification_opt (parser);
@@ -11725,7 +12227,10 @@
declarator = make_array_declarator (declarator, bounds);
}
- else if (first && dcl_kind != CP_PARSER_DECLARATOR_ABSTRACT)
+ /* APPLE LOCAL begin blocks 6339747 */
+ else if (first && (dcl_kind == CP_PARSER_DECLARATOR_NAMED
+ || dcl_kind == CP_PARSER_DECLARATOR_EITHER))
+ /* APPLE LOCAL end blocks 6339747 */
{
tree qualifying_scope;
tree unqualified_name;
@@ -11886,7 +12391,8 @@
/* For an abstract declarator, we might wind up with nothing at this
point. That's an error; the declarator is not optional. */
- if (!declarator)
+ /* APPLE LOCAL blocks 6339747 */
+ if (!declarator && dcl_kind != CP_PARSER_DECLARATOR_BLOCK)
cp_parser_error (parser, "expected declarator");
/* If we entered a scope, we must exit it now. */
@@ -11910,6 +12416,8 @@
ptr-operator:
& cv-qualifier-seq [opt]
+ APPLE LOCAL blocks 6040305 (cc)
+ ^
Returns INDIRECT_REF if a pointer, or pointer-to-member, was used.
Returns ADDR_EXPR if a reference was used. In the case of a
@@ -12692,7 +13200,8 @@
static void
cp_parser_function_body (cp_parser *parser)
{
- cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, NULL, false, false);
}
/* Parse a ctor-initializer-opt followed by a function-body. Return
@@ -14449,7 +14958,8 @@
cp_parser_require_keyword (parser, RID_TRY, "`try'");
try_block = begin_try_block ();
- cp_parser_compound_statement (parser, NULL, true);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, NULL, true, false);
finish_try_block (try_block);
cp_parser_handler_seq (parser);
finish_handler_sequence (try_block);
@@ -14526,7 +15036,8 @@
declaration = cp_parser_exception_declaration (parser);
finish_handler_parms (declaration, handler);
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
- cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, NULL, false, false);
finish_handler (handler);
}
@@ -15311,6 +15822,8 @@
case cdk_pointer:
case cdk_reference:
case cdk_ptrmem:
+ /* APPLE LOCAL blocks 6040305 */
+ case cdk_block_pointer:
return (cp_parser_check_declarator_template_parameters
(parser, declarator->declarator));
@@ -15578,6 +16091,16 @@
cp_parser_skip_to_end_of_block_or_statement (parser);
fn = error_mark_node;
}
+ else if (DECL_INITIAL (current_function_decl) != error_mark_node)
+ {
+ /* Seen already, skip it. An error message has already been output. */
+ cp_parser_skip_to_end_of_block_or_statement (parser);
+ fn = current_function_decl;
+ current_function_decl = NULL_TREE;
+ /* If this is a function from a class, pop the nested class. */
+ if (current_class_name)
+ pop_nested_class ();
+ }
else
fn = cp_parser_function_definition_after_declarator (parser,
/*inline_p=*/false);
@@ -17009,6 +17532,25 @@
return objc_build_message_expr (build_tree_list (receiver, messageargs));
}
+/* APPLE LOCAL begin radar 5277239 */
+/* Parse an Objective-C dot-syntax class expression.
+
+ objc-message-expression:
+ class-name '.' class-method-name
+
+ Returns an objc_property_reference expression. */
+
+static tree
+cp_parser_objc_reference_expression (cp_parser* parser, tree type_decl)
+{
+ tree receiver, component;
+ receiver = objc_get_class_reference (TREE_TYPE (type_decl));
+ cp_lexer_consume_token (parser->lexer); /* Eact '.' */
+ component = cp_parser_objc_message_args (parser);
+ return objc_build_property_reference_expr (receiver, TREE_PURPOSE (component));
+}
+/* APPLE LOCAL end radar 5277239 */
+
/* Parse an objc-message-receiver.
objc-message-receiver:
@@ -17460,10 +18002,25 @@
}
}
+/* APPLE LOCAL begin radar 3803157 - objc attribute */
+static void
+cp_parser_objc_maybe_attributes (cp_parser* parser, tree* attributes)
+{
+ cp_token *token = cp_lexer_peek_token (parser->lexer);
+ if (*attributes != NULL_TREE)
+ {
+ error ("method attributes must be specified at the end only");
+ *attributes = NULL_TREE;
+ }
+ if (token->keyword == RID_ATTRIBUTE)
+ *attributes = cp_parser_attributes_opt (parser);
+}
+
/* Parse an Objective-C params list. */
static tree
-cp_parser_objc_method_keyword_params (cp_parser* parser)
+cp_parser_objc_method_keyword_params (cp_parser* parser, tree* attributes)
+/* APPLE LOCAL end radar 3803157 - objc attribute */
{
tree params = NULL_TREE;
bool maybe_unary_selector_p = true;
@@ -17472,6 +18029,8 @@
while (cp_parser_objc_selector_p (token->type) || token->type == CPP_COLON)
{
tree selector = NULL_TREE, typename, identifier;
+ /* APPLE LOCAL radar 4157812 */
+ tree attr = NULL_TREE;
if (token->type != CPP_COLON)
selector = cp_parser_objc_selector (parser);
@@ -17478,23 +18037,42 @@
/* Detect if we have a unary selector. */
if (maybe_unary_selector_p
- && cp_lexer_next_token_is_not (parser->lexer, CPP_COLON))
- return selector;
+ && cp_lexer_next_token_is_not (parser->lexer, CPP_COLON))
+ /* APPLE LOCAL begin radar 3803157 - objc attribute */
+ {
+ cp_parser_objc_maybe_attributes (parser, attributes);
+ if (cp_lexer_next_token_is_not (parser->lexer, CPP_COLON))
+ return selector;
+ }
+ /* APPLE LOCAL end radar 3803157 - objc attribute */
maybe_unary_selector_p = false;
cp_parser_require (parser, CPP_COLON, "`:'");
typename = cp_parser_objc_typename (parser);
+ /* APPLE LOCAL radar 4157812 */
+ cp_parser_objc_maybe_attributes (parser, &attr);
identifier = cp_parser_identifier (parser);
+ /* APPLE LOCAL radar 3803157 - objc attribute */
+ cp_parser_objc_maybe_attributes (parser, attributes);
params
= chainon (params,
objc_build_keyword_decl (selector,
typename,
- identifier));
+ /* APPLE LOCAL radar 4157812 */
+ identifier, attr));
token = cp_lexer_peek_token (parser->lexer);
}
+ /* APPLE LOCAL begin radar 4290840 */
+ if (params == NULL_TREE)
+ {
+ cp_parser_error (parser, "objective-c++ method declaration is expected");
+ return error_mark_node;
+ }
+ /* APPLE LOCAL end radar 4290840 */
+
return params;
}
@@ -17501,7 +18079,8 @@
/* Parse the non-keyword Objective-C params. */
static tree
-cp_parser_objc_method_tail_params_opt (cp_parser* parser, bool *ellipsisp)
+/* APPLE LOCAL radar 3803157 - objc attribute */
+cp_parser_objc_method_tail_params_opt (cp_parser* parser, bool *ellipsisp, tree* attributes)
{
tree params = make_node (TREE_LIST);
cp_token *token = cp_lexer_peek_token (parser->lexer);
@@ -17516,11 +18095,13 @@
token = cp_lexer_peek_token (parser->lexer);
if (token->type == CPP_ELLIPSIS)
- {
- cp_lexer_consume_token (parser->lexer); /* Eat '...'. */
- *ellipsisp = true;
- break;
- }
+ {
+ cp_lexer_consume_token (parser->lexer); /* Eat '...'. */
+ *ellipsisp = true;
+ /* APPLE LOCAL radar 3803157 - objc attribute */
+ cp_parser_objc_maybe_attributes (parser, attributes);
+ break;
+ }
parmdecl = cp_parser_parameter_declaration (parser, false, NULL);
parm = grokdeclarator (parmdecl->declarator,
@@ -17561,7 +18142,8 @@
/* Parse a method signature. */
static tree
-cp_parser_objc_method_signature (cp_parser* parser)
+/* APPLE LOCAL radar 3803157 - objc attribute */
+cp_parser_objc_method_signature (cp_parser* parser, tree* attributes)
{
tree rettype, kwdparms, optparms;
bool ellipsis = false;
@@ -17568,8 +18150,11 @@
cp_parser_objc_method_type (parser);
rettype = cp_parser_objc_typename (parser);
- kwdparms = cp_parser_objc_method_keyword_params (parser);
- optparms = cp_parser_objc_method_tail_params_opt (parser, &ellipsis);
+ /* APPLE LOCAL begin radar 3803157 - objc attribute */
+ *attributes = NULL_TREE;
+ kwdparms = cp_parser_objc_method_keyword_params (parser, attributes);
+ optparms = cp_parser_objc_method_tail_params_opt (parser, &ellipsis, attributes);
+ /* APPLE LOCAL end radar 3803157 - objc attribute */
return objc_build_method_signature (rettype, kwdparms, optparms, ellipsis);
}
@@ -17581,22 +18166,31 @@
{
cp_token *token = cp_lexer_peek_token (parser->lexer);
- while (token->keyword != RID_AT_END)
+ /* APPLE LOCAL 4093475 */
+ while (token->keyword != RID_AT_END && token->type != CPP_EOF)
{
if (token->type == CPP_PLUS || token->type == CPP_MINUS)
- {
- objc_add_method_declaration
- (cp_parser_objc_method_signature (parser));
- cp_parser_consume_semicolon_at_end_of_statement (parser);
- }
+ {
+ /* APPLE LOCAL begin radar 3803157 - objc attribute */
+ tree attributes, sig;
+ sig = cp_parser_objc_method_signature (parser, &attributes);
+ objc_add_method_declaration (sig, attributes);
+ /* APPLE LOCAL end radar 3803157 - objc attribute */
+ cp_parser_consume_semicolon_at_end_of_statement (parser);
+ }
+ /* APPLE LOCAL begin C* interface */
+ else if (token->keyword == RID_AT_PROPERTY)
+ objc_cp_parser_at_property (parser);
+ /* APPLE LOCAL end C* interface */
else
- /* Allow for interspersed non-ObjC++ code. */
+ /* Allow for interspersed non-ObjC++ code. */
cp_parser_objc_interstitial_code (parser);
token = cp_lexer_peek_token (parser->lexer);
}
- cp_lexer_consume_token (parser->lexer); /* Eat '@end'. */
+ /* APPLE LOCAL 4093475 */
+ cp_parser_require_keyword (parser, RID_AT_END, "`@end'");
objc_finish_interface ();
}
@@ -17607,27 +18201,49 @@
{
cp_token *token = cp_lexer_peek_token (parser->lexer);
- while (token->keyword != RID_AT_END)
+ /* APPLE LOCAL 4093475 */
+ while (token->keyword != RID_AT_END && token->type != CPP_EOF)
{
tree meth;
if (token->type == CPP_PLUS || token->type == CPP_MINUS)
- {
- push_deferring_access_checks (dk_deferred);
- objc_start_method_definition
- (cp_parser_objc_method_signature (parser));
+ {
+ /* APPLE LOCAL radar 4290840 */
+ cp_token *ptk;
+ /* APPLE LOCAL begin radar 3803157 - objc attribute */
+ tree sig, attribute;
+ push_deferring_access_checks (dk_deferred);
+ sig = cp_parser_objc_method_signature (parser, &attribute);
+ objc_start_method_definition (sig, attribute);
+ /* APPLE LOCAL end radar 3803157 - objc attribute */
/* For historical reasons, we accept an optional semicolon. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
cp_lexer_consume_token (parser->lexer);
- perform_deferred_access_checks ();
- stop_deferring_access_checks ();
- meth = cp_parser_function_definition_after_declarator (parser,
- false);
- pop_deferring_access_checks ();
- objc_finish_method_definition (meth);
+ /* APPLE LOCAL begin radar 4290840 */
+ /* Check for all possibilities of illegal lookahead tokens. */
+ ptk = cp_lexer_peek_token (parser->lexer);
+ /* APPLE LOCAL radar 6271728 */
+ if (ptk->type == CPP_OPEN_BRACE)
+ {
+ perform_deferred_access_checks ();
+ stop_deferring_access_checks ();
+ meth = cp_parser_function_definition_after_declarator (parser,
+ false);
+ pop_deferring_access_checks ();
+ objc_finish_method_definition (meth);
}
+ /* APPLE LOCAL begin radar 6271728 */
+ else
+ cp_parser_require (parser, CPP_OPEN_BRACE, "`{'");
+ /* APPLE LOCAL end radar 6271728 */
+ /* APPLE LOCAL end radar 4290840 */
+ }
+ /* APPLE LOCAL begin C* interface */
+ else if (token->keyword == RID_AT_PROPERTY)
+ objc_cp_parser_at_property (parser);
+ /* APPLE LOCAL end C* interface */
else
/* Allow for interspersed non-ObjC++ code. */
cp_parser_objc_interstitial_code (parser);
@@ -17635,7 +18251,8 @@
token = cp_lexer_peek_token (parser->lexer);
}
- cp_lexer_consume_token (parser->lexer); /* Eat '@end'. */
+ /* APPLE LOCAL 4093475 */
+ cp_parser_require_keyword (parser, RID_AT_END, "`@end'");
objc_finish_implementation ();
}
@@ -17761,7 +18378,8 @@
/* Parse an Objective-C protocol declaration. */
static void
-cp_parser_objc_protocol_declaration (cp_parser* parser)
+/* APPLE LOCAL radar 4947311 */
+cp_parser_objc_protocol_declaration (cp_parser* parser, tree attributes)
{
tree proto, protorefs;
cp_token *tok;
@@ -17779,8 +18397,9 @@
/* Try a forward declaration first. */
if (tok->type == CPP_COMMA || tok->type == CPP_SEMICOLON)
{
- objc_declare_protocols (cp_parser_objc_identifier_list (parser));
- finish:
+ /* APPLE LOCAL radar 4947311 */
+ objc_declare_protocols (cp_parser_objc_identifier_list (parser), attributes);
+ finish:
cp_parser_consume_semicolon_at_end_of_statement (parser);
}
@@ -17789,7 +18408,8 @@
{
proto = cp_parser_identifier (parser);
protorefs = cp_parser_objc_protocol_refs_opt (parser);
- objc_start_protocol (proto, protorefs);
+ /* APPLE LOCAL radar 4947311 */
+ objc_start_protocol (proto, protorefs, attributes);
cp_parser_objc_method_prototype_list (parser);
}
}
@@ -17796,13 +18416,15 @@
/* Parse an Objective-C superclass or category. */
+/* APPLE LOCAL begin radar 4965989 */
static void
cp_parser_objc_superclass_or_category (cp_parser *parser, tree *super,
- tree *categ)
+ tree *categ, bool *is_category)
{
cp_token *next = cp_lexer_peek_token (parser->lexer);
*super = *categ = NULL_TREE;
+ *is_category = false;
if (next->type == CPP_COLON)
{
cp_lexer_consume_token (parser->lexer); /* Eat ':'. */
@@ -17811,29 +18433,47 @@
else if (next->type == CPP_OPEN_PAREN)
{
cp_lexer_consume_token (parser->lexer); /* Eat '('. */
- *categ = cp_parser_identifier (parser);
+ /* APPLE LOCAL begin radar 4965989 */
+ next = cp_lexer_peek_token (parser->lexer);
+ *categ = (next->type == CPP_CLOSE_PAREN) ? NULL_TREE : cp_parser_identifier (parser);
+ *is_category = true;
+ /* APPLE LOCAL end radar 4965989 */
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
}
}
+/* APPLE LOCAL end radar 4965989 */
/* Parse an Objective-C class interface. */
static void
-cp_parser_objc_class_interface (cp_parser* parser)
+/* APPLE LOCAL radar 4947311 */
+cp_parser_objc_class_interface (cp_parser* parser, tree attributes)
{
tree name, super, categ, protos;
-
+ /* APPLE LOCAL radar 4965989 */
+ bool is_categ;
+ /* APPLE LOCAL radar 4947311 */
+ /* Code for radar 4548636 removed. */
cp_lexer_consume_token (parser->lexer); /* Eat '@interface'. */
name = cp_parser_identifier (parser);
- cp_parser_objc_superclass_or_category (parser, &super, &categ);
+ /* APPLE LOCAL radar 4965989 */
+ cp_parser_objc_superclass_or_category (parser, &super, &categ, &is_categ);
protos = cp_parser_objc_protocol_refs_opt (parser);
-
+
/* We have either a class or a category on our hands. */
- if (categ)
- objc_start_category_interface (name, categ, protos);
+ /* APPLE LOCAL radar 4965989 */
+ if (is_categ)
+ /* APPLE LOCAL begin radar 4548636 */
+ {
+ if (attributes)
+ error ("attributes may not be specified on a category");
+ objc_start_category_interface (name, categ, protos);
+ }
+ /* APPLE LOCAL end radar 4548636 */
else
{
- objc_start_class_interface (name, super, protos);
+ /* APPLE LOCAL radar 4548636 */
+ objc_start_class_interface (name, super, protos, attributes);
/* Handle instance variable declarations, if any. */
cp_parser_objc_class_ivars (parser);
objc_continue_interface ();
@@ -17848,14 +18488,25 @@
cp_parser_objc_class_implementation (cp_parser* parser)
{
tree name, super, categ;
-
+ /* APPLE LOCAL radar 4965989 */
+ bool is_categ;
cp_lexer_consume_token (parser->lexer); /* Eat '@implementation'. */
name = cp_parser_identifier (parser);
- cp_parser_objc_superclass_or_category (parser, &super, &categ);
+ /* APPLE LOCAL radar 4965989 */
+ cp_parser_objc_superclass_or_category (parser, &super, &categ, &is_categ);
/* We have either a class or a category on our hands. */
- if (categ)
- objc_start_category_implementation (name, categ);
+ /* APPLE LOCAL begin radar 4965989 */
+ if (is_categ)
+ {
+ if (categ == NULL_TREE)
+ {
+ error ("cannot implement anonymous category");
+ return;
+ }
+ objc_start_category_implementation (name, categ);
+ }
+ /* APPLE LOCAL end radar 4965989 */
else
{
objc_start_class_implementation (name, super);
@@ -17893,10 +18544,24 @@
cp_parser_objc_class_declaration (parser);
break;
case RID_AT_PROTOCOL:
- cp_parser_objc_protocol_declaration (parser);
+ /* APPLE LOCAL radar 4947311 */
+ cp_parser_objc_protocol_declaration (parser, NULL_TREE);
break;
+ /* APPLE LOCAL begin radar 4548636 - radar 4947311 */
+ case RID_ATTRIBUTE:
+ {
+ tree attributes = NULL_TREE;
+ cp_parser_objc_maybe_attributes (parser, &attributes);
+ if (cp_lexer_peek_token (parser->lexer)->keyword == RID_AT_INTERFACE)
+ cp_parser_objc_class_interface (parser, attributes);
+ else if (cp_lexer_peek_token (parser->lexer)->keyword == RID_AT_PROTOCOL)
+ cp_parser_objc_protocol_declaration (parser, attributes);
+ break;
+ }
+ /* APPLE LOCAL end radar 4548636 - radar 4947311 */
case RID_AT_INTERFACE:
- cp_parser_objc_class_interface (parser);
+ /* APPLE LOCAL radar 4947311 */
+ cp_parser_objc_class_interface (parser, NULL_TREE);
break;
case RID_AT_IMPLEMENTATION:
cp_parser_objc_class_implementation (parser);
@@ -17937,7 +18602,8 @@
/* NB: The @try block needs to be wrapped in its own STATEMENT_LIST
node, lest it get absorbed into the surrounding block. */
stmt = push_stmt_list ();
- cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, NULL, false, false);
objc_begin_try_stmt (location, pop_stmt_list (stmt));
while (cp_lexer_next_token_is_keyword (parser->lexer, RID_AT_CATCH))
@@ -17947,14 +18613,10 @@
cp_lexer_consume_token (parser->lexer);
cp_parser_require (parser, CPP_OPEN_PAREN, "`('");
- parmdecl = cp_parser_parameter_declaration (parser, false, NULL);
- parm = grokdeclarator (parmdecl->declarator,
- &parmdecl->decl_specifiers,
- PARM, /*initialized=*/0,
- /*attrlist=*/NULL);
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
objc_begin_catch_clause (parm);
- cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, NULL, false, false);
objc_finish_catch_clause ();
}
@@ -17965,7 +18627,8 @@
/* NB: The @finally block needs to be wrapped in its own STATEMENT_LIST
node, lest it get absorbed into the surrounding block. */
stmt = push_stmt_list ();
- cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, NULL, false, false);
objc_build_finally_clause (location, pop_stmt_list (stmt));
}
@@ -17994,7 +18657,8 @@
/* NB: The @synchronized block needs to be wrapped in its own STATEMENT_LIST
node, lest it get absorbed into the surrounding block. */
stmt = push_stmt_list ();
- cp_parser_compound_statement (parser, NULL, false);
+ /* APPLE LOCAL radar 5982990 */
+ cp_parser_compound_statement (parser, NULL, false, flag_objc_sjlj_exceptions);
return objc_build_synchronized (location, lock, pop_stmt_list (stmt));
}
@@ -18042,7 +18706,1735 @@
return error_mark_node;
}
-
+
+/* APPLE LOCAL begin C* language */
+/* Routine closes up the C*'s foreach statement.
+*/
+
+static void
+objc_finish_foreach_stmt (tree for_stmt)
+{
+ if (flag_new_for_scope > 0)
+ {
+ tree scope = TREE_CHAIN (for_stmt);
+ TREE_CHAIN (for_stmt) = NULL;
+ add_stmt (do_poplevel (scope));
+ }
+
+ finish_stmt ();
+}
+
+/*
+ Synthesizer routine for C*'s feareach statement.
+
+ It synthesizes:
+ for ( type elem in collection) { stmts; }
+
+ Into:
+ {
+ type elem;
+ __objcFastEnumerationState enumState = { 0 };
+ id items[16];
+
+ unsigned long limit = [collection countByEnumeratingWithState:&enumState objects:items count:16];
+ if (limit) {
+ unsigned long startMutations = *enumState.mutationsPtr;
+ do {
+ unsigned long counter = 0;
+ do {
+ if (startMutations != *enumState.mutationsPtr) objc_enumerationMutation(collection);
+ elem = enumState.itemsPtr[counter++];
+ stmts;
+ } while (counter < limit);
+ } while (limit = [collection countByEnumeratingWithState:&enumState objects:items count:16]);
+ }
+ else
+ elem = nil; radar 4854605, 5128402
+
+*/
+
+static void
+objc_foreach_stmt (cp_parser* parser, tree statement)
+{
+ unsigned char in_statement;
+ tree enumerationMutation_call_exp;
+ tree countByEnumeratingWithState;
+ tree receiver;
+ tree exp, bind;
+ tree enumState_decl, items_decl;
+ tree limit_decl, limit_decl_assign_expr;
+ tree outer_if_stmt, inner_if_stmt, if_condition, startMutations_decl;
+ tree outer_do_stmt, inner_do_stmt, do_condition;
+ tree counter_decl;
+ tree_stmt_iterator i = tsi_start (TREE_CHAIN (statement));
+ tree t = tsi_stmt (i);
+ /* APPLE LOCAL radar 5130983 */
+ tree elem_decl = TREE_CODE (t) == DECL_EXPR ? DECL_EXPR_DECL (t) : t;
+
+ receiver = cp_parser_condition (parser);
+ cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
+
+ /* APPLE LOCAL begin radar 4507230 */
+ if (!objc_type_valid_for_messaging (TREE_TYPE (elem_decl)))
+ {
+ error ("selector element does not have a valid object type");
+ return;
+ }
+
+ if (!objc_type_valid_for_messaging (TREE_TYPE (receiver)))
+ {
+ error ("expression does not have a valid object type");
+ return;
+ }
+ /* APPLE LOCAL end radar 4507230 */
+
+ enumerationMutation_call_exp = objc_build_foreach_components (receiver, &enumState_decl,
+ &items_decl, &limit_decl,
+ &startMutations_decl, &counter_decl,
+ &countByEnumeratingWithState);
+
+ /* __objcFastEnumerationState enumState = { 0 }; */
+ exp = build_stmt (DECL_EXPR, enumState_decl);
+ bind = build3 (BIND_EXPR, void_type_node, enumState_decl, exp, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+
+ /* id items[16]; */
+ bind = build3 (BIND_EXPR, void_type_node, items_decl, NULL, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+
+ /* Generate this statement and add it to the list. */
+ /* limit = [collection countByEnumeratingWithState:&enumState objects:items count:16] */
+ limit_decl_assign_expr = build2 (MODIFY_EXPR, TREE_TYPE (limit_decl), limit_decl,
+ countByEnumeratingWithState);
+ bind = build3 (BIND_EXPR, void_type_node, limit_decl, NULL, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+
+ /* if (limit) { */
+ outer_if_stmt = begin_if_stmt ();
+ /* APPLE LOCAL radar 4547045 */
+ if_condition = build_binary_op (NE_EXPR, limit_decl_assign_expr,
+ fold_convert (TREE_TYPE (limit_decl), integer_zero_node),
+ 1);
+
+ finish_if_stmt_cond (if_condition, outer_if_stmt);
+
+ /* unsigned long startMutations = *enumState.mutationsPtr; */
+ exp = objc_build_component_ref (enumState_decl, get_identifier("mutationsPtr"));
+ exp = build_indirect_ref (exp, "unary *");
+ exp = build2 (MODIFY_EXPR, void_type_node, startMutations_decl, exp);
+ bind = build3 (BIND_EXPR, void_type_node, startMutations_decl, exp, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+
+ /* do { */
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ outer_do_stmt = begin_do_stmt (NULL_TREE);
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
+ /* Body of the outer do-while loop */
+ /* unsigned int counter = 0; */
+ exp = build2 (MODIFY_EXPR, void_type_node, counter_decl,
+ fold_convert (TREE_TYPE (counter_decl), integer_zero_node));
+ bind = build3 (BIND_EXPR, void_type_node, counter_decl, exp, NULL);
+ TREE_SIDE_EFFECTS (bind) = 1;
+ add_stmt (bind);
+
+ /* do { */
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ inner_do_stmt = begin_do_stmt (NULL_TREE);
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
+ /* Body of the inner do-while loop */
+
+ /* if (startMutations != *enumState.mutationsPtr) objc_enumerationMutation (collection); */
+ inner_if_stmt = begin_if_stmt ();
+ exp = objc_build_component_ref (enumState_decl, get_identifier("mutationsPtr"));
+ exp = build_indirect_ref (exp, "unary *");
+ if_condition = build_binary_op (NE_EXPR, startMutations_decl, exp, 1);
+ finish_if_stmt_cond (if_condition, inner_if_stmt);
+
+ add_stmt (enumerationMutation_call_exp);
+ finish_then_clause (inner_if_stmt);
+ finish_if_stmt (inner_if_stmt);
+
+ /* elem = enumState.itemsPtr [counter]; */
+ exp = objc_build_component_ref (enumState_decl, get_identifier("itemsPtr"));
+ exp = build_array_ref (exp, counter_decl);
+ add_stmt (build2 (MODIFY_EXPR, void_type_node, elem_decl, exp));
+ /* APPLE LOCAL radar 4538105 */
+ TREE_USED (elem_decl) = 1;
+
+ /* counter++; */
+ exp = build2 (PLUS_EXPR, TREE_TYPE (counter_decl), counter_decl,
+ build_int_cst (NULL_TREE, 1));
+ add_stmt (build2 (MODIFY_EXPR, void_type_node, counter_decl, exp));
+
+ /* ADD << stmts >> from the foreach loop. */
+ /* Parse the body of the for-statement. */
+ in_statement = parser->in_statement;
+ parser->in_statement = IN_ITERATION_STMT;
+ cp_parser_already_scoped_statement (parser);
+ parser->in_statement = in_statement;
+
+ finish_do_body (inner_do_stmt);
+
+ /* } while (counter < limit ); */
+ do_condition = build_binary_op (LT_EXPR, counter_decl, limit_decl, 1);
+ finish_do_stmt (do_condition, inner_do_stmt);
+ DO_FOREACH (inner_do_stmt) = integer_zero_node;
+ /* APPLE LOCAL radar 4667060 */
+ DO_FOREACH (outer_do_stmt) = elem_decl;
+
+ finish_do_body (outer_do_stmt);
+
+ /* } while (limit = [collection countByEnumeratingWithState:&enumState objects:items count:16]); */
+
+ exp = unshare_expr (limit_decl_assign_expr);
+ do_condition = build_binary_op (NE_EXPR, exp,
+ fold_convert (TREE_TYPE (limit_decl), integer_zero_node),
+ 1);
+ finish_do_stmt (do_condition, outer_do_stmt);
+
+
+ finish_then_clause (outer_if_stmt);
+
+ /* } */
+ /* APPLE LOCAL begin radar 4854605 - radar 5128402 */
+ begin_else_clause (outer_if_stmt);
+ add_stmt (build2 (MODIFY_EXPR, void_type_node, elem_decl,
+ fold_convert (TREE_TYPE (elem_decl), integer_zero_node)));
+ finish_else_clause (outer_if_stmt);
+ /* APPLE LOCAL end radar 4854605 - radar 5128402 */
+
+ finish_if_stmt (outer_if_stmt);
+
+ objc_finish_foreach_stmt (statement);
+}
+/* APPLE LOCAL end C* language */
+/* APPLE LOCAL begin blocks 6040305 (ce) */
+#define I_SYMBOL_BINDING(t) IDENTIFIER_BINDING(t)
+
+tree build_component_ref (tree e, tree member);
+tree
+build_component_ref (tree e, tree member)
+{
+ if (!DECL_P (member))
+ member = lookup_member (TREE_TYPE (e), member, 0, 0);
+ if (processing_template_decl)
+ return build3 (COMPONENT_REF, TREE_TYPE (member), e, DECL_NAME (member), NULL_TREE);
+ return build_class_member_access_expr (e, member,
+ NULL_TREE, false);
+}
+
+/* APPLE LOCAL begin radar 6214617 */
+static bool
+cp_block_requires_copying (tree exp)
+{
+ return (block_requires_copying (exp)
+ || TYPE_HAS_CONSTRUCTOR (TREE_TYPE (exp))
+ || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp)));
+}
+/* APPLE LOCAL end radar 6214617 */
+
+/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
+/** build_descriptor_block_decl -
+ This routine builds a static block_descriptior variable of type:
+ struct __block_descriptor; and initializes it to:
+ {0, sizeof(struct literal_block_n),
+ copy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
+ destroy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
+ }
+ */
+static tree
+build_descriptor_block_decl (tree block_struct_type, struct block_sema_info *block_impl)
+{
+ extern tree create_tmp_var_raw (tree, const char *);
+ static int desc_unique_count;
+ int size;
+ tree helper_addr;
+ tree decl, constructor;
+ char name [32];
+ VEC(constructor_elt,gc) *impl_v = NULL;
+ tree descriptor_type =
+ TREE_TYPE (build_block_descriptor_type (block_impl->BlockHasCopyDispose));
+
+ sprintf (name, "__block_descriptor_tmp_%d", ++desc_unique_count);
+ decl = create_tmp_var_raw (descriptor_type, name);
+ DECL_CONTEXT (decl) = NULL_TREE;
+
+ /* Initialize "reserved" field to 0 for now. */
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, build_int_cst (long_unsigned_type_node, 0));
+
+ /* Initialize "Size" field. */
+ size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (block_struct_type));
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, build_int_cst (long_unsigned_type_node, size));
+
+ if (block_impl->BlockHasCopyDispose)
+ {
+ /* Initialize "CopyFuncPtr" and "DestroyFuncPtr" fields. */
+ /* Helpers were previously generated completeley as a nested
+ function (and context was required for code gen.) But they are not,
+ so context must be set to NULL so initialization logic does not complain. */
+ DECL_CONTEXT (block_impl->copy_helper_func_decl) = NULL_TREE;
+ helper_addr = build_fold_addr_expr (block_impl->copy_helper_func_decl);
+ helper_addr = convert (ptr_type_node, helper_addr);
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, helper_addr);
+
+ DECL_CONTEXT (block_impl->destroy_helper_func_decl) = NULL_TREE;
+ helper_addr = build_fold_addr_expr (block_impl->destroy_helper_func_decl);
+ helper_addr = convert (ptr_type_node, helper_addr);
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, helper_addr);
+ }
+ /* Create a CONSTRUCTOR to represent the braced-initializer. */
+ constructor = make_node (CONSTRUCTOR);
+ CONSTRUCTOR_ELTS (constructor) = impl_v;
+ TREE_PUBLIC (decl) = 0;
+ TREE_STATIC (decl) = 1;
+ cp_finish_decl (decl, constructor, 0, 0, LOOKUP_ONLYCONVERTING);
+ return decl;
+}
+
+/* APPLE LOCAL begin radar 6300081 */
+/* This function builds a "generic" block struct type, to be passed
+ into the debug information for blocks pointers, to allow gdb to
+ find the actual function pointer for the block. Any time the Blocks
+ structure layout changes, this may also need to change.
+
+ Currently a block pointer is a pointer to a __block_literal_n struct,
+ the third field of which is a pointer to a __block_descriptor struct,
+ whose third field is the function pointer. There are other fields as
+ well, but these are the ones gdb needs to know about to find the
+ function pointer. Therefore a generic block struct currently looks
+ like this:
+
+ struct __block_literal_generic
+ {
+ void * __isa;
+ int __flags;
+ int __reserved;
+ void *__FuncPtr;
+ struct __block_descriptor
+ {
+ unsigned long int reserved;
+ unsigned long int Size;
+ } *__descriptor;
+ };
+
+ IF AT ANY TIME THE STRUCTURE OF A __BLOCK_LITERAL_N CHANGES, THIS
+ MUST BE CHANGED ALSO!!
+
+ */
+
+tree
+/* APPLE LOCAL radar 6353006 */
+c_build_generic_block_struct_type (void)
+{
+ tree fields = NULL_TREE;
+ tree field;
+ tree block_struct_type;
+
+ push_to_top_level ();
+ block_struct_type = xref_tag (record_type,
+ get_identifier ("__block_literal_generic"),
+ ts_current, false);
+ xref_basetypes (block_struct_type, NULL_TREE);
+ CLASSTYPE_DECLARED_CLASS (block_struct_type) = 0;
+ pushclass (block_struct_type);
+
+ field = build_decl (FIELD_DECL, get_identifier ("__isa"), ptr_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ field = build_decl (FIELD_DECL, get_identifier ("__flags"),
+ integer_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ field = build_decl (FIELD_DECL, get_identifier ("__reserved"),
+ integer_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ field = build_decl (FIELD_DECL, get_identifier ("__FuncPtr"),
+ ptr_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ field = build_decl (FIELD_DECL, get_identifier ("__descriptor"),
+ build_block_descriptor_type (false));
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ TYPE_FIELDS (block_struct_type) = fields;
+ TYPE_NAME (block_struct_type) = build_decl (TYPE_DECL,
+ get_identifier ("__block_literal_generic"),
+ block_struct_type);
+ TYPE_STUB_DECL (block_struct_type) = TYPE_NAME (block_struct_type);
+ TYPE_BLOCK_IMPL_STRUCT (block_struct_type) = 1;
+ finish_struct (block_struct_type, NULL_TREE);
+ pop_from_top_level ();
+
+ return block_struct_type;
+}
+/* APPLE LOCAL end radar 6300081 */
+
+/** build_block_struct_type -
+ struct __block_literal_n {
+ void *__isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
+ int __flags;
+ int __reserved;
+ void *__FuncPtr;
+
+ struct __block_descriptor {
+ unsigned long int reserved; // NULL
+ unsigned long int Size; // sizeof(struct __block_literal_n)
+
+ // optional helper functions
+ void *CopyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ void *DestroyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ } *__descriptor;
+
+ // imported variables
+ int x; // ref variable list ...
+ int *y; // byref variable list
+ };
+ */
+static tree
+build_block_struct_type (struct block_sema_info * block_impl)
+{
+ tree fields = NULL_TREE, field, chain;
+ char buffer[32];
+ static int unique_count;
+ tree block_struct_type;
+
+ /* Check and see if this block is required to have a Copy/Dispose
+ helper function. If yes, set BlockHasCopyDispose to TRUE. */
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ /* APPLE LOCAL begin radar 6214617 */
+ if (cp_block_requires_copying (TREE_VALUE (chain)))
+ {
+ tree type = TREE_TYPE (TREE_VALUE (chain));
+ block_impl->BlockHasCopyDispose = TRUE;
+ if (TYPE_HAS_CONSTRUCTOR (type) || TYPE_NEEDS_CONSTRUCTING (type))
+ {
+ block_impl->BlockImportsCxxObjects = TRUE;
+ break;
+ }
+ /* APPLE LOCAL end radar 6214617 */
+ }
+
+ /* Further check to see that we have __block variables which require
+ Copy/Dispose helpers. */
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
+ {
+ block_impl->BlockHasCopyDispose = TRUE;
+ break;
+ }
+
+ sprintf(buffer, "__block_literal_%d", ++unique_count);
+ push_to_top_level ();
+ /* APPLE LOCAL begin radar 6243400 */
+ block_struct_type = xref_tag (record_type, get_identifier (buffer), ts_current, false);
+ xref_basetypes (block_struct_type, NULL_TREE);
+ CLASSTYPE_DECLARED_CLASS (block_struct_type) = 0;
+ pushclass (block_struct_type);
+ /* APPLE LOCAL end radar 6243400 */
+ /* void * __isa; */
+ field = build_decl (FIELD_DECL, get_identifier ("__isa"), ptr_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ /* int __flags. */
+ field = build_decl (FIELD_DECL, get_identifier ("__flags"), integer_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ /* int __reserved. */
+ field = build_decl (FIELD_DECL, get_identifier ("__reserved"), integer_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ /* void *__FuncPtr. */
+ field = build_decl (FIELD_DECL, get_identifier ("__FuncPtr"),
+ ptr_type_node);
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ /* struct __block_descriptor *__descriptor */
+ field = build_decl (FIELD_DECL, get_identifier ("__descriptor"),
+ build_block_descriptor_type (block_impl->BlockHasCopyDispose));
+ TREE_CHAIN (field) = fields;
+ fields = field;
+
+ if (block_impl->BlockHasCopyDispose)
+ {
+ /* If inner block of a nested block has BlockHasCopyDispose, so
+ does its outer block. */
+ if (block_impl->prev_block_info)
+ block_impl->prev_block_info->BlockHasCopyDispose = TRUE;
+ }
+
+ /* int x; // ref variable list ... */
+ for (chain = block_impl->block_ref_decl_list; chain; chain = TREE_CHAIN (chain))
+ {
+ tree p = TREE_VALUE (chain);
+ /* Note! const-ness of copied in variable must not be carried over to the
+ type of the synthesized struct field. It prevents to assign to this
+ field when copy constructor is synthesized. */
+ field = build_decl (FIELD_DECL, DECL_NAME (p),
+ c_build_qualified_type (TREE_TYPE (p),
+ TYPE_UNQUALIFIED));
+ TREE_CHAIN (field) = fields;
+ fields = field;
+ }
+
+ /* int *y; // byref variable list */
+ for (chain = block_impl->block_byref_decl_list; chain; chain = TREE_CHAIN (chain))
+ {
+ tree p = TREE_VALUE (chain);
+ field = build_decl (FIELD_DECL, DECL_NAME (p),
+ TREE_TYPE (p));
+ TREE_CHAIN (field) = fields;
+ fields = field;
+ }
+
+ /* APPLE LOCAL begin radar 6243400 */
+ TYPE_FIELDS (block_struct_type) = fields;
+ TYPE_NAME (block_struct_type) =
+ build_decl (TYPE_DECL, get_identifier (buffer), block_struct_type);
+ TYPE_STUB_DECL (block_struct_type) = TYPE_NAME (block_struct_type);
+ finish_struct (block_struct_type, NULL_TREE);
+ pop_from_top_level ();
+ /* APPLE LOCAL end radar 6243400 */
+ return block_struct_type;
+}
+
+/**
+ build_block_struct_initlist - builds the initializer list:
+ { &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // __isa,
+ BLOCK_USE_STRET | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // __flags,
+ 0, // __reserved,
+ &helper_1, // __FuncPtr,
+ &static_descriptor_variable // __descriptor,
+ x, // user variables.
+ &y
+ ...
+ }
+*/
+/* APPLE LOCAL begin radar 6169527 */
+/* This routine is entirely rewritten as we now have to deal with full-blown
+ c++ classes with fields which may require construction. */
+static VEC(constructor_elt,gc) *
+build_block_struct_initlist (tree block_struct_type,
+ struct block_sema_info *block_impl)
+{
+ tree expr, chain, helper_addr;
+ /* APPLE LOCAL radar 7735196 */
+ unsigned flags = 0;
+ static tree NSConcreteStackBlock_decl = NULL_TREE;
+ static tree NSConcreteGlobalBlock_decl = NULL_TREE;
+ VEC(constructor_elt,gc) *impl_v = NULL;
+ tree descriptor_block_decl = build_descriptor_block_decl (block_struct_type, block_impl);
+
+ if (block_impl->BlockHasCopyDispose)
+ /* Note! setting of this flag merely indicates to the runtime that
+ we have destroy_helper_block/copy_helper_block helper
+ routines. */
+ flags |= BLOCK_HAS_COPY_DISPOSE;
+ /* APPLE LOCAL begin radar 6214617 */
+ /* Set BLOCK_HAS_CXX_OBJ if block is importing a cxx object. */
+ if (block_impl->BlockImportsCxxObjects)
+ flags |= BLOCK_HAS_CXX_OBJ;
+ /* APPLE LOCAL end radar 6214617 */
+/* APPLE LOCAL begin radar 7735196 */
+ if (block_impl->return_type && aggregate_value_p(block_impl->return_type, 0))
+ flags |= BLOCK_USE_STRET;
+ /* APPLE LOCAL end 7735196 */
+ /* APPLE LOCAL begin radar 6230297 */
+ if (!current_function_decl ||
+ (block_impl->block_ref_decl_list == NULL_TREE &&
+ block_impl->block_byref_decl_list == NULL_TREE))
+ /* APPLE LOCAL end radar 6230297 */
+ {
+ /* This is a global block. */
+ /* Find an existing declaration for _NSConcreteGlobalBlock or declare
+ extern void *_NSConcreteGlobalBlock; */
+ if (NSConcreteGlobalBlock_decl == NULL_TREE)
+ {
+ tree name_id = get_identifier("_NSConcreteGlobalBlock");
+ NSConcreteGlobalBlock_decl = lookup_name (name_id);
+ if (!NSConcreteGlobalBlock_decl)
+ {
+ NSConcreteGlobalBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+ DECL_EXTERNAL (NSConcreteGlobalBlock_decl) = 1;
+ TREE_PUBLIC (NSConcreteGlobalBlock_decl) = 1;
+ pushdecl_top_level (NSConcreteGlobalBlock_decl);
+ rest_of_decl_compilation (NSConcreteGlobalBlock_decl, 0, 0);
+ }
+ }
+ /* APPLE LOCAL begin radar 6457359 */
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE,
+ convert (ptr_type_node,
+ build_fold_addr_expr (NSConcreteGlobalBlock_decl)));
+ /* APPLE LOCAL end radar 6457359 */
+ flags |= BLOCK_IS_GLOBAL;
+ }
+ else
+ {
+ /* Find an existing declaration for _NSConcreteStackBlock or declare
+ extern void *_NSConcreteStackBlock; */
+ if (NSConcreteStackBlock_decl == NULL_TREE)
+ {
+ tree name_id = get_identifier("_NSConcreteStackBlock");
+ NSConcreteStackBlock_decl = lookup_name (name_id);
+ if (!NSConcreteStackBlock_decl)
+ {
+ NSConcreteStackBlock_decl = build_decl (VAR_DECL, name_id, ptr_type_node);
+ DECL_EXTERNAL (NSConcreteStackBlock_decl) = 1;
+ TREE_PUBLIC (NSConcreteStackBlock_decl) = 1;
+ pushdecl_top_level (NSConcreteStackBlock_decl);
+ rest_of_decl_compilation (NSConcreteStackBlock_decl, 0, 0);
+ }
+ }
+ /* APPLE LOCAL begin radar 6457359 */
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE,
+ convert (ptr_type_node,
+ build_fold_addr_expr (NSConcreteStackBlock_decl)));
+ /* APPLE LOCAL end radar 6457359 */
+ }
+
+ /* __flags */
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, build_int_cst (integer_type_node, flags));
+ /* __reserved */
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, build_int_cst (integer_type_node, 0));
+ /* __FuncPtr */
+ helper_addr = build_fold_addr_expr (block_impl->helper_func_decl);
+ helper_addr = convert (ptr_type_node, helper_addr);
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, helper_addr);
+
+ /* &static_descriptor_variable initializer */
+ expr = build_fold_addr_expr (descriptor_block_decl);
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, expr);
+
+ for (chain = block_impl->block_original_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ {
+ tree y = TREE_VALUE (chain);
+ TREE_USED (y) = 1;
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, y);
+ }
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ {
+ tree y = lookup_name (DECL_NAME (TREE_VALUE (chain)));
+ tree forwarding_expr;
+ gcc_assert (y);
+ TREE_USED (y) = 1;
+ if (COPYABLE_BYREF_LOCAL_VAR (y))
+ {
+ /* For variables declared __block, either the original one
+ at the point of declaration or the imported version (which is
+ initialized in the helper function's prologue) is used to
+ initilize the byref variable field in the temporary. */
+ if (TREE_CODE (TREE_TYPE (y)) != RECORD_TYPE)
+ y = build_indirect_ref (y, "unary *");
+ /* We will be using the __block_struct_variable.__forwarding as the
+ initializer. */
+ forwarding_expr = build_component_ref (y, get_identifier ("__forwarding"));
+ }
+ else
+ /* Global variable is always assumed passed by its address. */
+ forwarding_expr = build_fold_addr_expr (y);
+
+ CONSTRUCTOR_APPEND_ELT(impl_v, NULL_TREE, forwarding_expr);
+ }
+ return impl_v;
+}
+/* APPLE LOCAL end radar 6169527 */
+/* APPLE LOCAL end radar 5847213 - radar 6329245 */
+
+/**
+ build_block_literal_tmp - This routine:
+
+ 1) builds block type:
+ struct __block_literal_n {
+ void *__isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
+ int __flags;
+ int __reserved;
+ void *__FuncPtr;
+
+ struct __block_descriptor {
+ unsigned long int reserved; // NULL
+ unsigned long int Size; // sizeof(struct Block_literal_1)
+
+ // optional helper functions
+ void *CopyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ void *DestroyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE
+ } *__descriptor;
+
+ // imported variables
+ int x; // ref variable list ...
+ int *y; // byref variable list
+ };
+
+ 2) build function prototype:
+ double helper_1(struct block_1 *ii, int z);
+
+ 3) build the temporary initialization:
+ struct block_1 I = {
+ { &_NSConcreteStackBlock or &_NSConcreteGlobalBlock // isa,
+ BLOCK_HAS_CXX_OBJ | BLOCK_HAS_COPY_DISPOSE | BLOCK_IS_GLOBAL // flags,
+ 0, // reserved,
+ &helper_1,
+ &{
+ NULL,
+ sizeof(struct block_1),
+ copy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
+ destroy_helper_block_1, // only if block BLOCK_HAS_COPY_DISPOSE
+ },
+ x,
+ &y
+};
+
+It return the temporary.
+*/
+/* APPLE LOCAL begin radar 6169527 */
+static tree
+build_block_literal_tmp (const char *name,
+ struct block_sema_info * block_impl)
+{
+ extern tree create_tmp_var_raw (tree, const char *);
+ tree block_holder_tmp_decl;
+ tree constructor;
+ tree block_struct_type = TREE_TYPE (block_impl->block_arg_ptr_type);
+ /* APPLE LOCAL begin radar 6230297 */
+ bool staticBlockTmp = (block_impl->block_ref_decl_list == NULL_TREE &&
+ block_impl->block_byref_decl_list == NULL_TREE);
+
+ block_holder_tmp_decl = create_tmp_var_raw (block_struct_type, name);
+ /* Context will not be known until when the literal is synthesized.
+ This is more so in the case of nested block literal blocks. */
+ maybe_push_decl (block_holder_tmp_decl);
+ DECL_CONTEXT (block_holder_tmp_decl) = staticBlockTmp ? NULL_TREE
+ : current_function_decl;
+ if (staticBlockTmp)
+ DECL_CONTEXT (block_impl->helper_func_decl) = NULL_TREE;
+ /* APPLE LOCAL end radar 6230297 */
+ DECL_ARTIFICIAL (block_holder_tmp_decl) = 1;
+
+ /* Create a CONSTRUCTOR to represent the braced-initializer. */
+ constructor = make_node (CONSTRUCTOR);
+
+ CONSTRUCTOR_ELTS (constructor) = build_block_struct_initlist (block_struct_type,
+ block_impl);
+ /* Temporary representing a global block is made global static. */
+ /* APPLE LOCAL radar 6230297 */
+ if (staticBlockTmp || global_bindings_p ()) {
+ TREE_PUBLIC (block_holder_tmp_decl) = 0;
+ TREE_STATIC (block_holder_tmp_decl) = 1;
+ }
+ cp_finish_decl (block_holder_tmp_decl, constructor, 0, 0, LOOKUP_ONLYCONVERTING);
+ return block_holder_tmp_decl;
+}
+/* APPLE LOCAL end radar 6169527 */
+
+static tree
+clean_and_exit (tree block)
+{
+ pop_function_context ();
+ pop_lang_context ();
+ if (current_function_decl)
+ free (finish_block (block));
+ return error_mark_node;
+}
+
+/** synth_copy_helper_block_func - This function synthesizes
+ void copy_helper_block (struct block* _dest, struct block *_src) function.
+ */
+
+static void
+synth_copy_helper_block_func (struct block_sema_info * block_impl)
+{
+ tree stmt, chain;
+ tree dst_arg, src_arg;
+ /* struct c_arg_info * arg_info; */
+ /* Set up: (struct block* _dest, struct block *_src) parameters. */
+ dst_arg = build_decl (PARM_DECL, get_identifier ("_dst"),
+ block_impl->block_arg_ptr_type);
+ DECL_CONTEXT (dst_arg) = cur_block->copy_helper_func_decl;
+ TREE_USED (dst_arg) = 1;
+ DECL_ARG_TYPE (dst_arg) = block_impl->block_arg_ptr_type;
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ block_impl->block_arg_ptr_type);
+ DECL_CONTEXT (src_arg) = cur_block->copy_helper_func_decl;
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = block_impl->block_arg_ptr_type;
+ /* arg_info = xcalloc (1, sizeof (struct c_arg_info)); */
+ TREE_CHAIN (dst_arg) = src_arg;
+
+ pushdecl (cur_block->copy_helper_func_decl);
+ /* arg_info->parms = dst_arg; */
+ /* arg_info->types = tree_cons (NULL_TREE, block_impl->block_arg_ptr_type,
+ tree_cons (NULL_TREE,
+ block_impl->block_arg_ptr_type,
+ NULL_TREE)); */
+ DECL_ARGUMENTS (cur_block->copy_helper_func_decl) = dst_arg;
+ /* function header synthesis. */
+ push_function_context ();
+ /* start_block_helper_function (cur_block->copy_helper_func_decl, true); */
+ /* store_parm_decls (arg_info); */
+ start_preparsed_function (cur_block->copy_helper_func_decl,
+ /*attrs*/NULL_TREE,
+ SF_PRE_PARSED);
+
+ /* Body of the function. */
+ stmt = begin_compound_stmt (BCS_FN_BODY);
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ /* APPLE LOCAL radar 6214617 */
+ if (cp_block_requires_copying (TREE_VALUE (chain)))
+ {
+ /* APPLE LOCAL begin radar 6175959 */
+ int flag = 0;
+ tree p = TREE_VALUE (chain);
+ tree dst_block_component, src_block_component;
+ dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
+ DECL_NAME (p));
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+
+ if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
+ /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_BLOCK) */
+ flag = BLOCK_FIELD_IS_BLOCK;
+ /* APPLE LOCAL begin radar 6214617 */
+ else if (TYPE_HAS_CONSTRUCTOR (TREE_TYPE (p))
+ || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (p)))
+ {
+ tree call_exp = build_aggr_init (dst_block_component, src_block_component,
+ LOOKUP_ONLYCONVERTING);
+ add_stmt (call_exp);
+ }
+ /* APPLE LOCAL end radar 6214617 */
+ else
+ /* _Block_object_assign(&_dest->myImportedBlock, _src->myImportedClosure, BLOCK_FIELD_IS_OBJECT) */
+ flag = BLOCK_FIELD_IS_OBJECT;
+ if (flag)
+ {
+ tree call_exp;
+ dst_block_component = build_fold_addr_expr (dst_block_component);
+ call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
+ add_stmt (call_exp);
+ }
+ /* APPLE LOCAL end radar 6175959 */
+ }
+
+ /* For each __block declared variable used in |...| Must generate call to:
+ _Block_object_assign(&_dest->myImportedBlock, _src->myImportedBlock, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK])
+ */
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
+ {
+ int flag = BLOCK_FIELD_IS_BYREF;
+ tree call_exp;
+ tree p = TREE_VALUE (chain);
+ tree dst_block_component, src_block_component;
+ dst_block_component = build_component_ref (build_indirect_ref (dst_arg, "->"),
+ DECL_NAME (p));
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+
+ /* _Block_object_assign(&_dest->myImportedClosure, _src->myImportedClosure, BLOCK_FIELD_IS_BYREF [|BLOCK_FIELD_IS_WEAK]) */
+ if (COPYABLE_WEAK_BLOCK (p))
+ flag |= BLOCK_FIELD_IS_WEAK;
+
+ dst_block_component = build_fold_addr_expr (dst_block_component);
+ call_exp = build_block_object_assign_call_exp (dst_block_component, src_block_component, flag);
+ add_stmt (call_exp);
+ }
+
+ finish_compound_stmt (stmt);
+ /* APPLE LOCAL radar 6169580 */
+ finish_function (4);
+ /* Hum, would be nice if someone else did this for us. */
+ if (global_bindings_p ())
+ cgraph_finalize_function (block_impl->copy_helper_func_decl, false);
+ pop_function_context ();
+ /* free (arg_info); */
+}
+
+static void
+synth_destroy_helper_block_func (struct block_sema_info * block_impl)
+{
+ tree stmt, chain;
+ tree src_arg;
+ /* struct c_arg_info * arg_info; */
+ /* Set up: (struct block *_src) parameter. */
+ src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
+ block_impl->block_arg_ptr_type);
+ DECL_CONTEXT (src_arg) = cur_block->destroy_helper_func_decl;
+ TREE_USED (src_arg) = 1;
+ DECL_ARG_TYPE (src_arg) = block_impl->block_arg_ptr_type;
+ /* arg_info = xcalloc (1, sizeof (struct c_arg_info)); */
+
+ pushdecl (cur_block->destroy_helper_func_decl);
+ /* arg_info->parms = src_arg; */
+ /* arg_info->types = tree_cons (NULL_TREE, block_impl->block_arg_ptr_type,
+ NULL_TREE); */
+ DECL_ARGUMENTS (cur_block->destroy_helper_func_decl) = src_arg;
+
+ /* function header synthesis. */
+ push_function_context ();
+ /* start_block_helper_function (cur_block->destroy_helper_func_decl, true); */
+ /* store_parm_decls_from (arg_info); */
+ start_preparsed_function (cur_block->destroy_helper_func_decl,
+ /*attrs*/NULL_TREE,
+ SF_PRE_PARSED);
+
+ /* Body of the function. */
+ stmt = begin_compound_stmt (BCS_FN_BODY);
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ /* APPLE LOCAL begin radar 6214617 */
+ if (block_requires_copying (TREE_VALUE (chain))
+ || (TREE_CODE (TREE_TYPE (TREE_VALUE (chain))) == RECORD_TYPE
+ && CLASSTYPE_DESTRUCTORS (TREE_TYPE (TREE_VALUE (chain)))))
+ /* APPLE LOCAL end radar 6214617 */
+ {
+ int flag = 0;
+ tree rel_exp;
+ tree p = TREE_VALUE (chain);
+ tree src_block_component;
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+
+ if (TREE_CODE (TREE_TYPE (p)) == BLOCK_POINTER_TYPE)
+ /* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_BLOCK); */
+ flag = BLOCK_FIELD_IS_BLOCK;
+ /* APPLE LOCAL begin radar 6214617 */
+ else if (TREE_CODE (TREE_TYPE (p)) == RECORD_TYPE
+ && CLASSTYPE_DESTRUCTORS (TREE_TYPE (p)))
+ {
+ tree call_exp = cxx_maybe_build_cleanup (src_block_component);
+ gcc_assert (call_exp);
+ add_stmt (call_exp);
+ }
+ /* APPLE LOCAL end radar 6214617 */
+ else
+ /* _Block_object_dispose(_src->imported_object_0, BLOCK_FIELD_IS_OBJECT); */
+ flag = BLOCK_FIELD_IS_OBJECT;
+ if (flag)
+ {
+ rel_exp = build_block_object_dispose_call_exp (src_block_component, flag);
+ add_stmt (rel_exp);
+ }
+ }
+
+ /* For each __block declared variable used in |...| Must generate call to:
+ _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK])
+ */
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ if (COPYABLE_BYREF_LOCAL_VAR (TREE_VALUE (chain)))
+ {
+ tree call_exp;
+ int flag = BLOCK_FIELD_IS_BYREF;
+ tree p = TREE_VALUE (chain);
+ tree src_block_component;
+
+ src_block_component = build_component_ref (build_indirect_ref (src_arg, "->"),
+ DECL_NAME (p));
+ if (COPYABLE_WEAK_BLOCK (p))
+ flag |= BLOCK_FIELD_IS_WEAK;
+ /* _Block_object_dispose(_src->myImportedClosure, BLOCK_FIELD_IS_BYREF[|BLOCK_FIELD_IS_WEAK]) */
+ call_exp = build_block_object_dispose_call_exp (src_block_component, flag);
+ add_stmt (call_exp);
+ }
+
+ finish_compound_stmt (stmt);
+ /* APPLE LOCAL radar 6169580 */
+ finish_function (4);
+ /* Hum, would be nice if someone else did this for us. */
+ if (global_bindings_p ())
+ cgraph_finalize_function (block_impl->destroy_helper_func_decl, false);
+ pop_function_context ();
+}
+
+/* Parse a block-id.
+
+ GNU Extension:
+
+ block-id:
+ type-specifier-seq block-declarator
+
+ Returns the DECL specified or implied. */
+
+static tree
+cp_parser_block_id (cp_parser* parser)
+{
+ cp_decl_specifier_seq type_specifier_seq;
+ cp_declarator *declarator;
+
+ /* Parse the type-specifier-seq. */
+ cp_parser_type_specifier_seq (parser, /*is_condition=*/false,
+ &type_specifier_seq);
+ if (type_specifier_seq.type == error_mark_node)
+ return error_mark_node;
+
+ /* Look for the block-declarator. */
+ declarator
+ = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_BLOCK, NULL,
+ /*parenthesized_p=*/NULL,
+ /*member_p=*/false);
+
+ return grokblockdecl (&type_specifier_seq, declarator);
+}
+
+/* Parse a block-literal-expr.
+
+ GNU Extension:
+
+ block-literal-expr:
+ ^ parameter-declation-clause exception-specification [opt] compound-statement
+ ^ block-id compound-statement
+
+ It synthesizes the helper function for later generation and builds
+ the necessary data to represent the block literal where it is
+ declared. */
+static tree
+cp_parser_block_literal_expr (cp_parser* parser)
+{
+ char name [32];
+ static int global_unique_count;
+ int unique_count = ++global_unique_count;
+ tree block_helper_function_decl;
+ tree expr, type, arglist = NULL_TREE, ftype;
+ tree self_arg, stmt;
+ /* struct c_arg_info *args = NULL; */
+ cp_parameter_declarator *args = NULL;
+ tree arg_type = void_list_node;
+ struct block_sema_info *block_impl;
+ tree tmp;
+ tree restype;
+ tree typelist;
+ tree helper_function_type;
+ tree block;
+ /* APPLE LOCAL radar 6185344 */
+ tree declared_block_return_type = NULL_TREE;
+ /* APPLE LOCAL radar 6237713 */
+ tree attributes = NULL_TREE;
+ /* APPLE LOCAL radar 6169580 */
+ int context_is_nonstatic_method;
+ tree raises = NULL_TREE;
+
+ cp_lexer_consume_token (parser->lexer); /* eat '^' */
+
+ /* APPLE LOCAL begin radar 6237713 */
+ if (cp_lexer_peek_token (parser->lexer)->keyword == RID_ATTRIBUTE)
+ attributes = cp_parser_attributes_opt (parser);
+ /* APPLE LOCAL end radar 6237713 */
+
+ if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
+ {
+ /* Parse the optional argument list */
+ cp_lexer_consume_token (parser->lexer);
+ /* Open the scope to collect parameter decls */
+ /* push_scope (); */
+ /* args = c_parser_parms_declarator (parser, true, NULL_TREE); */
+ /* Parse the parameter-declaration-clause. */
+ args = cp_parser_parameter_declaration_clause (parser);
+ cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
+ arg_type = grokparms (args, &arglist);
+ /* Check for args as it might be NULL due to error. */
+ if (! args)
+ {
+ return error_mark_node;
+ }
+ raises = cp_parser_exception_specification_opt (parser);
+ }
+ /* APPLE LOCAL begin radar 6185344 */
+ else if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
+ {
+ /* Parse user declared return type. */
+ tree decl;
+
+ /* APPLE LOCAL begin radar 6237713 */
+ if (attributes)
+ {
+ warning (0, "attributes before block type are ignored");
+ attributes = NULL_TREE;
+ }
+ /* APPLE LOCAL end radar 6237713 */
+
+ decl = cp_parser_block_id (parser);
+
+ if (decl && decl != error_mark_node)
+ {
+ arg_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
+ arglist = DECL_ARGUMENTS (decl);
+ raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl));
+ declared_block_return_type = TREE_TYPE (TREE_TYPE (decl));
+ }
+ }
+ /* APPLE LOCAL end radar 6185344 */
+
+ block = begin_block ();
+ /* APPLE LOCAL begin radar 6169580 */
+ context_is_nonstatic_method = (current_function_decl
+ && DECL_NONSTATIC_MEMBER_FUNCTION_P (current_function_decl));
+ /* APPLE LOCAL end radar 6169580 */
+
+ /* cur_block->arg_info = NULL; */
+ /* APPLE LOCAL begin radar 6185344 */
+ if (declared_block_return_type)
+ {
+ cur_block->return_type = TYPE_MAIN_VARIANT (declared_block_return_type);
+ cur_block->block_has_return_type = true;
+ }
+ else
+ cur_block->return_type = NULL_TREE;
+ /* APPLE LOCAL end radar 6185344 */
+
+ /* Must also build hidden parameter .block_descriptor added to the helper
+ function, even though we do not know its type yet. */
+ /* APPLE LOCAL radar 6404979 */
+ self_arg = build_artificial_parm (get_identifier (".block_descriptor"), ptr_type_node);
+
+ /* TREE_CHAIN (self_arg) = cur_block->arg_info->parms; */
+ TREE_CHAIN (self_arg) = arglist;
+ arg_type = tree_cons (NULL_TREE, ptr_type_node, arg_type);
+ arglist = self_arg;
+
+ /* APPLE LOCAL begin radar 6185344 */
+ /* Build the declaration of the helper function (if we do not know its result
+ type yet, assume it is 'void'. If user provided it, use it).
+ Treat this as a nested function and use nested function infrastructure for
+ its generation. */
+
+ push_lang_context (lang_name_c);
+
+ ftype = build_function_type ((!cur_block->block_has_return_type
+ ? void_type_node : cur_block->return_type),
+ arg_type);
+ /* APPLE LOCAL end radar 6185344 */
+ if (raises)
+ ftype = build_exception_variant (ftype, raises);
+ /* APPLE LOCAL radar 6160536 */
+ block_helper_function_decl = build_helper_func_decl (build_block_helper_name (unique_count),
+ ftype);
+ DECL_CONTEXT (block_helper_function_decl) = current_function_decl;
+ cur_block->helper_func_decl = block_helper_function_decl;
+
+ DECL_ARGUMENTS (block_helper_function_decl) = arglist;
+
+ push_function_context ();
+ /* start_block_helper_function (cur_block->helper_func_decl, false); */
+ /* Enter parameter list to the scope of the helper function. */
+ /* store_parm_decls_from (cur_block->arg_info); */
+ start_preparsed_function (cur_block->helper_func_decl,
+ /*attrs*/NULL_TREE,
+ SF_PRE_PARSED);
+ /* APPLE LOCAL begin radar 6237713 */
+ if (cp_lexer_peek_token (parser->lexer)->keyword == RID_ATTRIBUTE)
+ attributes = cp_parser_attributes_opt (parser);
+ /* APPLE LOCAL radar 6246527 */
+ any_recognized_block_attribute (attributes);
+ decl_attributes (&cur_block->helper_func_decl, attributes, 0);
+ /* APPLE LOCAL end radar 6237713 */
+
+ /* Start parsing body or expression part of the block literal. */
+ {
+ unsigned save = parser->in_statement;
+ /* Indicate no valid break/continue context. We'll notice and
+ emit the proper error message in c_finish_bc_stmt. */
+ parser->in_statement = 0;
+ stmt = begin_compound_stmt (BCS_FN_BODY);
+ /* Set block's scope to the scope of the helper function's main body.
+ This is primarily used when nested blocks are declared. */
+ cur_block->cp_the_scope = current_binding_level;
+ /* APPLE LOCAL begin radar 6169580 */
+ if (context_is_nonstatic_method)
+ {
+ tree this_decl = lookup_name (this_identifier);
+ gcc_assert (this_decl);
+ build_block_ref_decl (this_identifier, this_decl);
+ }
+ /* APPLE LOCAL end radar 6169580 */
+ cp_parser_compound_statement (parser, NULL, false, false);
+ parser->in_statement = save;
+ }
+
+ cur_block->block_arg_ptr_type =
+ build_pointer_type (build_block_struct_type (cur_block));
+
+ restype = !cur_block->return_type ? void_type_node
+ : cur_block->return_type;
+ if (restype == error_mark_node)
+ return clean_and_exit (block);
+
+ /* Now that we know type of the hidden .block_descriptor argument, fix its type. */
+ TREE_TYPE (self_arg) = cur_block->block_arg_ptr_type;
+ DECL_ARG_TYPE (self_arg) = cur_block->block_arg_ptr_type;
+
+ /* The DECL_RESULT should already have the correct type by now. */
+ gcc_assert (TREE_TYPE (DECL_RESULT (current_function_decl))
+ == restype);
+
+ cur_block->block_body = stmt;
+ block_build_prologue (cur_block);
+
+ finish_compound_stmt (stmt);
+ /* add_stmt (fnbody); */
+
+ /* We are done parsing of the block body. Return type of block is now known.
+ We also know all we need to know about the helper function. So, fix its
+ type here. */
+ /* We moved this here because for global blocks, helper function body is
+ not nested and is gimplified in call to finish_function() and return type
+ of the function must be correct. */
+ ftype = build_function_type (restype, TREE_CHAIN (arg_type));
+ if (raises)
+ ftype = build_exception_variant (ftype, raises);
+ /* Declare helper function; as in:
+ double helper_1(struct block_1 *ii, int z); */
+ typelist = TYPE_ARG_TYPES (ftype);
+ /* (struct block_1 *ii, int z, ...) */
+ typelist = tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
+ typelist);
+ helper_function_type = build_function_type (TREE_TYPE (ftype), typelist);
+ if (raises)
+ helper_function_type = build_exception_variant (helper_function_type, raises);
+ TREE_TYPE (cur_block->helper_func_decl) = helper_function_type;
+ finish_function (4);
+ pop_function_context ();
+ /* Hum, would be nice if someone else did this for us. */
+ if (global_bindings_p ())
+ cgraph_finalize_function (cur_block->helper_func_decl, false);
+ pop_lang_context ();
+
+ /* Build the declaration for copy_helper_block and destroy_helper_block
+ helper functions for later use. */
+
+ if (cur_block->BlockHasCopyDispose)
+ {
+ tree s_ftype;
+
+ push_lang_context (lang_name_c);
+ /* void copy_helper_block (struct block*, struct block *); */
+ s_ftype = build_function_type (void_type_node,
+ tree_cons (NULL_TREE, cur_block->block_arg_ptr_type,
+ tree_cons (NULL_TREE,
+ cur_block->block_arg_ptr_type,
+ void_list_node)));
+ sprintf (name, "__copy_helper_block_%d", unique_count);
+ cur_block->copy_helper_func_decl =
+ build_helper_func_decl (get_identifier (name), s_ftype);
+ DECL_CONTEXT (cur_block->copy_helper_func_decl) = current_function_decl;
+ synth_copy_helper_block_func (cur_block);
+
+ /* void destroy_helper_block (struct block*); */
+ s_ftype = build_function_type (void_type_node,
+ tree_cons (NULL_TREE,
+ cur_block->block_arg_ptr_type, void_list_node));
+ sprintf (name, "__destroy_helper_block_%d", unique_count);
+ cur_block->destroy_helper_func_decl =
+ build_helper_func_decl (get_identifier (name), s_ftype);
+ DECL_CONTEXT (cur_block->destroy_helper_func_decl) = current_function_decl;
+ synth_destroy_helper_block_func (cur_block);
+ pop_lang_context ();
+ }
+
+ block_impl = finish_block (block);
+
+ /* Build unqiue name of the temporary used in code gen. */
+ sprintf (name, "__block_holder_tmp_%d", unique_count);
+ tmp = build_block_literal_tmp (name, block_impl);
+ tmp = build_fold_addr_expr (tmp);
+ type = build_block_pointer_type (ftype);
+ expr = convert (type, convert (ptr_type_node, tmp));
+ free (block_impl);
+ return expr;
+}
+/* APPLE LOCAL end blocks 6040305 (ce) */
+
+/* APPLE LOCAL begin blocks 6040305 (ch) */
+/* build_byref_local_var_access - converts EXPR to:
+ EXPR.__forwarding-><decl-name>.
+ */
+tree
+build_byref_local_var_access (tree expr, tree decl_name)
+{
+ tree exp = build_component_ref (expr, get_identifier ("__forwarding"));
+ exp = build_indirect_ref (exp, "unary *");
+ exp = build_component_ref (exp, decl_name);
+ return exp;
+}
+
+#define BINDING_VALUE(b) ((b)->value)
+
+/**
+ build_block_byref_decl - This routine inserts a variable declared as a
+ 'byref' variable using the |...| syntax in helper function's outer-most scope.
+ */
+tree
+build_block_byref_decl (tree name, tree decl, tree exp)
+{
+ tree ptr_type, byref_decl;
+ /* APPLE LOCAL begin radar 6225809 */
+ if (cur_block->prev_block_info) {
+ /* Traverse enclosing blocks. Insert a __block variable in
+ each enclosing block which has no declaration of this
+ variable. This is to ensure that the current (inner) block
+ gets the __block version of the variable; */
+ struct block_sema_info *cb = cur_block->prev_block_info;
+ while (cb) {
+ struct cxx_binding *b = I_SYMBOL_BINDING (name);
+ gcc_assert (b);
+ gcc_assert (BINDING_VALUE (b));
+ gcc_assert (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL);
+ /* Find the first declaration not in current block. */
+ while (b && BINDING_VALUE (b)
+ && (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL)
+ && DECL_CONTEXT (BINDING_VALUE (b)) == cur_block->helper_func_decl)
+ {
+ /* FIXME: This can't happen?! */
+ abort ();
+ /* b = b->previous; */
+ }
+
+ gcc_assert (b);
+ gcc_assert (BINDING_VALUE (b));
+ gcc_assert (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL);
+
+ /* Is the next declaration not in the enclosing block? */
+ if (b && BINDING_VALUE (b)
+ && (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL)
+ && DECL_CONTEXT (BINDING_VALUE (b)) != cb->helper_func_decl)
+ {
+ /* No declaration of variable seen in the block. Must insert one. */
+ /* FIXME: does this push enough? scope? */
+ struct cp_binding_level *save_scope = current_binding_level;
+ struct block_sema_info *save_current_block = cur_block;
+ tree save_current_function_decl = current_function_decl;
+ current_binding_level = cb->cp_the_scope;
+ cur_block = cb;
+ current_function_decl = cb->helper_func_decl;
+ decl = build_block_byref_decl (name, decl, exp);
+ cur_block = save_current_block;
+ current_binding_level = save_scope;
+ current_function_decl = save_current_function_decl;
+ }
+ cb = cb->prev_block_info;
+ }
+ }
+ /* APPLE LOCAL end radar 6225809 */
+
+ /* If it is already a byref declaration, do not add the pointer type
+ because such declarations already have the pointer type
+ added. This happens when we have two nested byref declarations in
+ nested blocks. */
+ ptr_type = (TREE_CODE (decl) == VAR_DECL && BLOCK_DECL_BYREF (decl))
+ ? TREE_TYPE (decl) : build_pointer_type (TREE_TYPE (decl));
+ byref_decl = build_decl (VAR_DECL, name, ptr_type);
+ DECL_CONTEXT (byref_decl) = current_function_decl;
+ BLOCK_DECL_BYREF (byref_decl) = 1;
+
+ if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
+ {
+ COPYABLE_BYREF_LOCAL_VAR (byref_decl) = 1;
+ COPYABLE_BYREF_LOCAL_NONPOD (byref_decl) = COPYABLE_BYREF_LOCAL_NONPOD (decl);
+ /* APPLE LOCAL radar 5847976 */
+ COPYABLE_WEAK_BLOCK (byref_decl) = COPYABLE_WEAK_BLOCK (decl);
+ }
+
+ /* Current scope must be that of the main function body. */
+ /* FIXME gcc_assert (current_scope->function_body);*/
+ pushdecl (byref_decl);
+ mark_used (byref_decl);
+ /* APPLE LOCAL begin radar 6083129 - byref escapes (cp) */
+ /* FIXME: finish this off, ensure the decl is scoped appropriately
+ for when we want the cleanup to run. */
+ /* APPLE LOCAL end radar 6083129 - byref escapes (cp) */
+ cur_block->block_byref_decl_list =
+ tree_cons (NULL_TREE, byref_decl, cur_block->block_byref_decl_list);
+ /* APPLE LOCAL radar 5847213 */
+ /* build of block_original_byref_decl_list us removed. */
+ /* APPLE LOCAL begin radar 6144664 */
+ DECL_SOURCE_LOCATION (byref_decl)
+ = DECL_SOURCE_LOCATION (cur_block->helper_func_decl);
+ /* APPLE LOCAL end radar 6144664 */
+ return byref_decl;
+}
+
+/**
+ build_block_ref_decl - This routine inserts a copied-in variable (a variable
+ referenced in the block but whose scope is outside the block) in helper
+ function's outer-most scope. It also sets its type to 'const' as such
+ variables are read-only.
+ */
+tree
+build_block_ref_decl (tree name, tree decl)
+{
+ /* FIXME - Broken, should be found via objc runtime testcases. */
+ /* FIXME - Don't use DECL_CONTEXT on any helpers */
+ tree ref_decl;
+ /* APPLE LOCAL radar 6212722 */
+ tree type, exp;
+ /* 'decl' was previously declared as __block. Simply, copy the value
+ embedded in the above variable. */
+ if (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl))
+ decl = build_byref_local_var_access (decl, DECL_NAME (decl));
+ else {
+ if (cur_block->prev_block_info) {
+ /* Traverse enclosing blocks. Insert a copied-in variable in
+ each enclosing block which has no declaration of this
+ variable. This is to ensure that the current (inner) block
+ has the 'frozen' value of the copied-in variable; which means
+ the value of the copied in variable is at the point of the
+ block declaration and *not* when the inner block is
+ invoked. */
+ struct block_sema_info *cb = cur_block->prev_block_info;
+ while (cb) {
+ struct cxx_binding *b = I_SYMBOL_BINDING (name);
+ gcc_assert (b);
+ gcc_assert (BINDING_VALUE (b));
+ gcc_assert (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL);
+ /* Find the first declaration not in current block. */
+ while (b && BINDING_VALUE (b)
+ && (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL)
+ && DECL_CONTEXT (BINDING_VALUE (b)) == cur_block->helper_func_decl)
+ {
+ /* FIXME: This can't happen?! */
+ abort ();
+ /* b = b->previous; */
+ }
+
+ gcc_assert (b);
+ gcc_assert (BINDING_VALUE (b));
+ gcc_assert (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL);
+
+ /* Is the next declaration not in the enclosing block? */
+ if (b && BINDING_VALUE (b)
+ && (TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ || TREE_CODE (BINDING_VALUE (b)) == PARM_DECL)
+ && DECL_CONTEXT (BINDING_VALUE (b)) != cb->helper_func_decl)
+ {
+ /* No declaration of variable seen in the block. Must
+ insert one, so it 'freezes' the variable in this
+ block. */
+ /* FIXME: does this push enough? scope? */
+ struct cp_binding_level *save_scope = current_binding_level;
+ struct block_sema_info *save_current_block = cur_block;
+ tree save_current_function_decl = current_function_decl;
+ current_binding_level = cb->cp_the_scope;
+ cur_block = cb;
+ current_function_decl = cb->helper_func_decl;
+ decl = build_block_ref_decl (name, decl);
+ cur_block = save_current_block;
+ current_binding_level = save_scope;
+ current_function_decl = save_current_function_decl;
+ }
+ cb = cb->prev_block_info;
+ }
+ }
+ }
+ /* APPLE LOCAL begin radar 6212722 */
+ exp = decl;
+ type = TREE_TYPE (exp);
+ if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == FUNCTION_TYPE) {
+ exp = decay_conversion (exp);
+ type = TREE_TYPE (exp);
+ }
+ ref_decl = build_decl (VAR_DECL, name,
+ build_qualified_type (type, TYPE_QUAL_CONST));
+ /* APPLE LOCAL end radar 6212722 */
+ /* APPLE LOCAL begin radar 6144664 */
+ DECL_SOURCE_LOCATION (ref_decl) = DECL_SOURCE_LOCATION
+ (cur_block->helper_func_decl);
+ /* APPLE LOCAL end radar 6144664 */
+ DECL_CONTEXT (ref_decl) = current_function_decl;
+ DECL_INITIAL (ref_decl) = error_mark_node;
+ c_apply_type_quals_to_decl (TYPE_QUAL_CONST, ref_decl);
+ BLOCK_DECL_COPIED (ref_decl) = 1;
+
+ /* Find the scope for function body (outer-most scope) and insert
+ this variable in that scope. This is to avoid duplicate
+ declaration of the save variable. */
+ {
+ struct cp_binding_level *b = current_binding_level;
+ while (b->level_chain->kind != sk_function_parms)
+ b = b->level_chain;
+ pushdecl_with_scope (ref_decl, b, /*is_friend=*/false);
+ /* APPLE LOCAL radar 6169527 */
+ add_decl_expr (ref_decl);
+ }
+ cur_block->block_ref_decl_list =
+ tree_cons (NULL_TREE, ref_decl, cur_block->block_ref_decl_list);
+ cur_block->block_original_ref_decl_list =
+ /* APPLE LOCAL radar 6212722 */
+ tree_cons (NULL_TREE, exp, cur_block->block_original_ref_decl_list);
+ return ref_decl;
+}
+
+/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
+static GTY (()) tree descriptor_ptr_type;
+static GTY (()) tree descriptor_ptr_type_with_copydispose;
+/** build_block_descriptor_type - This routine builds following internal type:
+ struct __block_descriptor {
+ unsigned long int reserved; // NULL
+ unsigned long int Size; // sizeof(struct Block_literal_1)
+
+ // optional helper functions
+ void *CopyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE is set (withCopyDispose true)
+ void *DestroyFuncPtr; // When BLOCK_HAS_COPY_DISPOSE is set (withCopyDispose true)
+ } *descriptor_ptr_type;
+
+ Objects of this type will always be static. This is one main component of abi change.
+ */
+tree
+build_block_descriptor_type (bool withCopyDispose)
+{
+ tree field_decl_chain = NULL_TREE, field_decl;
+ tree main_type;
+
+ if (withCopyDispose && descriptor_ptr_type_with_copydispose)
+ return descriptor_ptr_type_with_copydispose;
+ if (!withCopyDispose && descriptor_ptr_type)
+ return descriptor_ptr_type;
+
+ main_type = make_aggr_type (RECORD_TYPE);
+ xref_basetypes (main_type, NULL_TREE);
+
+ /* unsigned long int reserved; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("reserved"), long_unsigned_type_node);
+ TREE_CHAIN (field_decl) = field_decl_chain;
+ field_decl_chain = field_decl;
+
+ /* unsigned long int Size; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("Size"), long_unsigned_type_node);
+ TREE_CHAIN (field_decl) = field_decl_chain;
+ field_decl_chain = field_decl;
+
+ if (withCopyDispose)
+ {
+ /* void *CopyFuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("CopyFuncPtr"), ptr_type_node);
+ TREE_CHAIN (field_decl) = field_decl_chain;
+ field_decl_chain = field_decl;
+ /* void *DestroyFuncPtr; */
+ field_decl = build_decl (FIELD_DECL, get_identifier ("DestroyFuncPtr"), ptr_type_node);
+ TREE_CHAIN (field_decl) = field_decl_chain;
+ field_decl_chain = field_decl;
+ }
+
+ /* Mark this struct as being a block struct rather than a 'normal'
+ struct. */
+ TYPE_BLOCK_IMPL_STRUCT (main_type) = 1;
+ if (withCopyDispose)
+ finish_builtin_struct (main_type, "__block_descriptor_withcopydispose", field_decl_chain, NULL_TREE);
+ else
+ finish_builtin_struct (main_type, "__block_descriptor", field_decl_chain, NULL_TREE);
+ CLASSTYPE_AS_BASE (main_type) = main_type;
+
+ main_type = build_pointer_type (main_type);
+ if (withCopyDispose)
+ descriptor_ptr_type_with_copydispose = main_type;
+ else
+ descriptor_ptr_type = main_type;
+ return main_type;
+}
+/* APPLE LOCAL end radar 5847213 - radar 6329245 */
+
+cp_declarator *
+make_block_pointer_declarator (tree attributes,
+ cp_cv_quals quals,
+ cp_declarator *target)
+{
+ struct cp_declarator *itarget = target;
+ struct cp_declarator *ret = make_declarator (cdk_block_pointer);
+
+ /* APPLE LOCAL radar 5847213 */
+ /* code removed */
+
+
+ ret->attributes = attributes;
+ ret->declarator = itarget;
+ ret->u.block_pointer.qualifiers = quals;
+ return ret;
+}
+
+/* This routine returns 'true' if 'name' has a declaration inside the
+ current block, 'false' otherwise. If 'name' has no declaration in
+ the current block, it returns in DECL the user declaration for
+ 'name' found in the enclosing scope. Note that if it is declared
+ in current declaration, it can be either a user declaration or a
+ byref/copied-in declaration added in current block's scope by the
+ compiler. */
+bool
+lookup_name_in_block (tree name, tree *decl)
+{
+ /* FIXME - Broken, should be found via objc runtime testcases. */
+ /* FIXME - Don't use DECL_CONTEXT on any helpers */
+ cxx_binding *b = I_SYMBOL_BINDING (name);
+ if (b && b->declared_in_block
+ && DECL_CONTEXT (BINDING_VALUE (b)) == current_function_decl)
+ return true;
+
+ /* Check for variables only, as we may have parameters, such as
+ 'self' */
+ /* Note that if a copied-in variable (BLOCK_DECL_COPIED) in the
+ enclosing block is found, it must be returned as this is
+ where the variable in current (nested block) will have to get
+ its value. */
+ while (b
+ && TREE_CODE (BINDING_VALUE (b)) == VAR_DECL
+ && (BLOCK_DECL_BYREF (BINDING_VALUE (b))))
+ b = b->previous;
+ if (b)
+ *decl = BINDING_VALUE (b);
+ return false;
+}
+
+/**
+ build_helper_func_decl - This routine builds a FUNCTION_DECL for
+ a block helper function.
+ */
+tree
+build_helper_func_decl (tree ident, tree type)
+{
+ tree func_decl = build_decl (FUNCTION_DECL, ident, type);
+ DECL_EXTERNAL (func_decl) = 0;
+ TREE_PUBLIC (func_decl) = 0;
+ TREE_USED (func_decl) = 1;
+ TREE_NOTHROW (func_decl) = 0;
+ /* APPLE LOCAL radar 6172148 */
+ BLOCK_SYNTHESIZED_FUNC (func_decl) = 1;
+ retrofit_lang_decl (func_decl);
+ if (current_function_decl)
+ DECL_NO_STATIC_CHAIN (current_function_decl) = 0;
+ return func_decl;
+}
+
+/**
+ declare_block_prologue_local_vars - utility routine to do the actual
+ declaration and initialization for each referecned block variable.
+ */
+/* APPLE LOCAL begin radar 6169527 */
+/* This routine is mostly rewritten for c++ because initialization of variables
+ may involve copy construction. */
+static void
+declare_block_prologue_local_vars (tree self_parm, tree component,
+ tree stmt)
+{
+ tree decl, block_component;
+ tree_stmt_iterator i;
+ tree initialization_stmt;
+ /* APPLE LOCAL radar 6163705 */
+ int save_line = LOCATION_LINE (input_location);
+
+ decl = component;
+ block_component = build_component_ref (build_indirect_ref (self_parm, "->"),
+ DECL_NAME (component));
+ gcc_assert (block_component);
+ /* APPLE LOCAL radar 6163705 */
+ LOCATION_LINE (input_location) = DECL_SOURCE_LINE (decl) - 1;
+ DECL_EXTERNAL (decl) = 0;
+ TREE_STATIC (decl) = 0;
+ TREE_USED (decl) = 1;
+ DECL_CONTEXT (decl) = current_function_decl;
+ DECL_ARTIFICIAL (decl) = 1;
+ initialization_stmt = push_stmt_list();
+ cp_finish_decl (decl, block_component, 0, 0, LOOKUP_ONLYCONVERTING);
+ initialization_stmt = pop_stmt_list (initialization_stmt);
+ /* APPLE LOCAL radar 6163705 */
+ LOCATION_LINE (input_location) = save_line;
+ /* Prepend a initialization_stmt statement to the statement list. */
+ i = tsi_start (stmt);
+ tsi_link_before (&i, initialization_stmt, TSI_SAME_STMT);
+}
+
+/**
+ declare_block_prologue_local_byref_vars - utility routine to do the actual
+ declaration and initialization for each __block referenced block variable.
+ */
+static void
+declare_block_prologue_local_byref_vars (tree self_parm, tree component,
+ tree stmt)
+{
+ tree decl, block_component;
+ tree_stmt_iterator i;
+ tree decl_stmt;
+
+ decl = component;
+ block_component = build_component_ref (build_indirect_ref (self_parm, "->"),
+ DECL_NAME (component));
+ gcc_assert (block_component);
+ DECL_EXTERNAL (decl) = 0;
+ TREE_STATIC (decl) = 0;
+ TREE_USED (decl) = 1;
+ DECL_CONTEXT (decl) = current_function_decl;
+ DECL_ARTIFICIAL (decl) = 1;
+ DECL_INITIAL (decl) = block_component;
+ /* Prepend a DECL_EXPR statement to the statement list. */
+ i = tsi_start (stmt);
+ decl_stmt = build_stmt (DECL_EXPR, decl);
+ SET_EXPR_LOCATION (decl_stmt, DECL_SOURCE_LOCATION (decl));
+ /* APPLE LOCAL begin radar 6163705, Blocks prologues */
+ /* Give the prologue statements a line number of one before the beginning of
+ the function, to make them easily identifiable later. */
+ EXPR_LINENO (decl_stmt) = DECL_SOURCE_LINE (decl) - 1;
+ /* APPLE LOCAL end radar 6163705, Blocks prologues */
+ decl_stmt = build3 (BIND_EXPR, void_type_node, decl, decl_stmt, NULL);
+ TREE_SIDE_EFFECTS (decl_stmt) = 1;
+
+ tsi_link_before (&i, decl_stmt, TSI_SAME_STMT);
+}
+/* APPLE LOCAL end radar 6169527 */
+
+/**
+ block_build_prologue
+ - This routine builds the declarations for the
+ variables referenced in the block; as in:
+ int *y = .block_descriptor->y;
+ int x = .block_descriptor->x;
+
+ The decl_expr declaration for each initialization is enterred at the
+ beginning of the helper function's statement-list which is passed
+ in block_impl->block_body.
+ */
+void
+block_build_prologue (struct block_sema_info *block_impl)
+{
+ tree chain;
+ tree self_parm = lookup_name (get_identifier (".block_descriptor"));
+ gcc_assert (self_parm);
+
+ for (chain = block_impl->block_ref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ declare_block_prologue_local_vars (self_parm, TREE_VALUE (chain),
+ block_impl->block_body);
+ /* APPLE LOCAL begin radar 6169527 */
+ for (chain = block_impl->block_byref_decl_list; chain;
+ chain = TREE_CHAIN (chain))
+ declare_block_prologue_local_byref_vars (self_parm, TREE_VALUE (chain),
+ block_impl->block_body);
+ /* APPLE LOCAL end radar 6169527 */
+}
+/* APPLE LOCAL end blocks 6040305 (ch) */
+
/* OpenMP 2.5 parsing routines. */
/* All OpenMP clauses. OpenMP 2.5. */
@@ -18645,7 +21037,7 @@
tree stmt = begin_omp_structured_block ();
unsigned int save = cp_parser_begin_omp_structured_block (parser);
- cp_parser_statement (parser, NULL_TREE, false);
+ cp_parser_statement (parser, NULL_TREE, false, NULL);
cp_parser_end_omp_structured_block (parser, save);
return finish_omp_structured_block (stmt);
@@ -18781,6 +21173,7 @@
return c_finish_omp_critical (stmt, name);
}
+
/* OpenMP 2.5:
# pragma omp flush flush-vars[opt] new-line
@@ -18890,7 +21283,7 @@
/* Note that the grammar doesn't call for a structured block here,
though the loop as a whole is a structured block. */
body = push_stmt_list ();
- cp_parser_statement (parser, NULL_TREE, false);
+ cp_parser_statement (parser, NULL_TREE, false, NULL);
body = pop_stmt_list (body);
return finish_omp_for (loc, decl, init, cond, incr, body, pre_body);
@@ -18983,7 +21376,7 @@
while (1)
{
- cp_parser_statement (parser, NULL_TREE, false);
+ cp_parser_statement (parser, NULL_TREE, false, NULL);
tok = cp_lexer_peek_token (parser->lexer);
if (tok->pragma_kind == PRAGMA_OMP_SECTION)
Modified: trunk/contrib/gcc/cp/pt.c
===================================================================
--- trunk/contrib/gcc4/cp/pt.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/pt.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -7835,6 +7835,11 @@
complain);
}
+ /* APPLE LOCAL begin blocks 6204446 */
+ case BLOCK_POINTER_TYPE:
+ return t;
+ /* APPLE LOCAL end blocks 6204446 */
+
default:
sorry ("use of %qs in template",
tree_code_name [(int) TREE_CODE (t)]);
@@ -8593,8 +8598,11 @@
}
case FOR_STMT:
- stmt = begin_for_stmt ();
- RECUR (FOR_INIT_STMT (t));
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tmp = RECUR (FOR_ATTRIBUTES (t));
+ stmt = begin_for_stmt (tmp);
+ RECUR (FOR_INIT_STMT (t));
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
finish_for_init_stmt (stmt);
tmp = RECUR (FOR_COND (t));
finish_for_cond (tmp, stmt);
@@ -8605,7 +8613,10 @@
break;
case WHILE_STMT:
- stmt = begin_while_stmt ();
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tmp = RECUR (WHILE_ATTRIBUTES (t));
+ stmt = begin_while_stmt (tmp);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
tmp = RECUR (WHILE_COND (t));
finish_while_stmt_cond (tmp, stmt);
RECUR (WHILE_BODY (t));
@@ -8613,7 +8624,10 @@
break;
case DO_STMT:
- stmt = begin_do_stmt ();
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tmp = RECUR (DO_ATTRIBUTES (t));
+ stmt = begin_do_stmt (tmp);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
RECUR (DO_BODY (t));
finish_do_body (stmt);
tmp = RECUR (DO_COND (t));
@@ -8925,7 +8939,7 @@
/*template_arg_p=*/false,
&error_msg);
if (error_msg)
- error (error_msg);
+ error ("%s", error_msg);
if (!function_p && TREE_CODE (decl) == IDENTIFIER_NODE)
decl = unqualified_name_lookup_error (decl);
return decl;
@@ -9078,7 +9092,13 @@
return build_x_binary_op
(TREE_CODE (t),
RECUR (TREE_OPERAND (t, 0)),
+ (TREE_NO_WARNING (TREE_OPERAND (t, 0))
+ ? ERROR_MARK
+ : TREE_CODE (TREE_OPERAND (t, 0))),
RECUR (TREE_OPERAND (t, 1)),
+ (TREE_NO_WARNING (TREE_OPERAND (t, 1))
+ ? ERROR_MARK
+ : TREE_CODE (TREE_OPERAND (t, 1))),
/*overloaded_p=*/NULL);
case SCOPE_REF:
@@ -9087,7 +9107,14 @@
case ARRAY_REF:
op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
args, complain, in_decl);
- return build_x_binary_op (ARRAY_REF, op1, RECUR (TREE_OPERAND (t, 1)),
+ return build_x_binary_op (ARRAY_REF, op1,
+ (TREE_NO_WARNING (TREE_OPERAND (t, 0))
+ ? ERROR_MARK
+ : TREE_CODE (TREE_OPERAND (t, 0))),
+ RECUR (TREE_OPERAND (t, 1)),
+ (TREE_NO_WARNING (TREE_OPERAND (t, 1))
+ ? ERROR_MARK
+ : TREE_CODE (TREE_OPERAND (t, 1))),
/*overloaded_p=*/NULL);
case SIZEOF_EXPR:
Modified: trunk/contrib/gcc/cp/ptree.c
===================================================================
--- trunk/contrib/gcc4/cp/ptree.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/ptree.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -20,7 +20,7 @@
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/cp/ptree.c 169699 2007-05-19 02:12:21Z kan $ */
#include "config.h"
#include "system.h"
Modified: trunk/contrib/gcc/cp/rtti.c
===================================================================
--- trunk/contrib/gcc4/cp/rtti.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/rtti.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -32,6 +32,7 @@
#include "assert.h"
#include "toplev.h"
#include "convert.h"
+#include "target.h"
/* C++ returns type information to the user in struct type_info
objects. We also use type information to implement dynamic_cast and
@@ -237,7 +238,7 @@
/* Peel off cv qualifiers. */
type = TYPE_MAIN_VARIANT (type);
- if (!VOID_TYPE_P (type))
+ if (CLASS_TYPE_P (type))
type = complete_type_or_else (type, exp);
if (!type)
@@ -429,7 +430,7 @@
that is the operand of typeid are always ignored. */
type = TYPE_MAIN_VARIANT (type);
- if (!VOID_TYPE_P (type))
+ if (CLASS_TYPE_P (type))
type = complete_type_or_else (type, NULL_TREE);
if (!type)
@@ -1427,8 +1428,11 @@
comdat_linkage for details.) Since we want these objects
to have external linkage so that copies do not have to be
emitted in code outside the runtime library, we make them
- non-COMDAT here. */
- if (!flag_weak)
+ non-COMDAT here.
+
+ It might also not be necessary to follow this detail of the
+ ABI. */
+ if (!flag_weak || ! targetm.cxx.library_rtti_comdat ())
{
gcc_assert (TREE_PUBLIC (tinfo) && !DECL_COMDAT (tinfo));
DECL_INTERFACE_KNOWN (tinfo) = 1;
Modified: trunk/contrib/gcc/cp/semantics.c
===================================================================
--- trunk/contrib/gcc4/cp/semantics.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/semantics.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -587,6 +587,16 @@
/* Do the conversion. */
cond = convert_from_reference (cond);
+
+ if (TREE_CODE (cond) == MODIFY_EXPR
+ && !TREE_NO_WARNING (cond)
+ && warn_parentheses)
+ {
+ warning (OPT_Wparentheses,
+ "suggest parentheses around assignment used as truth value");
+ TREE_NO_WARNING (cond) = 1;
+ }
+
return condition_conversion (cond);
}
@@ -694,10 +704,14 @@
appropriate. */
tree
-begin_while_stmt (void)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+begin_while_stmt (tree attribs)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
{
tree r;
- r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE, attribs);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
add_stmt (r);
WHILE_BODY (r) = do_pushlevel (sk_block);
begin_cond (&WHILE_COND (r));
@@ -727,9 +741,14 @@
appropriate. */
tree
-begin_do_stmt (void)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+begin_do_stmt (tree attribs)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
{
- tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE);
+ /* APPLE LOCAL radar 4445586 */
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE, attribs, NULL_TREE);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
add_stmt (r);
DO_BODY (r) = push_stmt_list ();
return r;
@@ -793,13 +812,18 @@
/* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
tree
-begin_for_stmt (void)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+begin_for_stmt (tree attribs)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
{
tree r;
r = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
- NULL_TREE, NULL_TREE);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ NULL_TREE, NULL_TREE, attribs);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
+
if (flag_new_for_scope > 0)
TREE_CHAIN (r) = do_pushlevel (sk_for);
@@ -1919,6 +1943,18 @@
error ("%<this%> is unavailable for static member functions");
result = error_mark_node;
}
+ /* APPLE LOCAL begin radar 6275956 */
+ else if (cur_block && current_function_decl
+ && BLOCK_SYNTHESIZED_FUNC (current_function_decl))
+ {
+ result = lookup_name (this_identifier);
+ if (!result)
+ {
+ error ("invalid use of %<this%> in a block");
+ result = error_mark_node;
+ }
+ }
+ /* APPLE LOCAL end radar 6275956 */
else
{
if (current_function_decl)
@@ -2002,7 +2038,9 @@
result = copy_node (result);
TREE_NEGATED_INT (result) = 1;
}
- overflow_warning (result);
+ if (TREE_OVERFLOW_P (result) && !TREE_OVERFLOW_P (expr))
+ overflow_warning (result);
+
return result;
}
@@ -2444,6 +2482,82 @@
return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE);
}
+/* APPLE LOCAL begin blocks 6040305 */
+static bool
+block_var_ok_for_context (tree context)
+{
+ /* FIXME - local classes inside blocks, templates, etc */
+ struct block_sema_info *b = cur_block;
+ tree decl = current_function_decl;
+
+ /* If in a block helper, only variables from the context of the helper
+ are ok. */
+ while (b && b->helper_func_decl == decl)
+ {
+ if (context == DECL_CONTEXT (decl))
+ return true;
+ decl = DECL_CONTEXT (decl);
+ b = b->prev_block_info;
+ }
+
+ return false;
+}
+
+/* APPLE LOCAL begin radar 6545782 */
+/** This routine does all the work on use of variables in a block. */
+static tree get_final_block_variable (tree name, tree var) {
+ tree decl = var;
+
+ if (cur_block
+ && (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL)
+ && !lookup_name_in_block (name, &decl))
+ {
+ bool gdecl;
+ /* We are referencing a variable inside a block whose
+ declaration is outside. */
+ gcc_assert (decl &&
+ (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == PARM_DECL));
+ gdecl = (TREE_CODE (decl) == VAR_DECL &&
+ (DECL_EXTERNAL (decl) || TREE_STATIC (decl)));
+ /* Treat all 'global' variables as 'byref' by default. */
+ if (gdecl
+ || (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl)))
+ {
+ /* byref globals are directly accessed. */
+ /* APPLE LOCAL begin radar 7760213 */
+ if (!gdecl) {
+ if (HasByrefArray(TREE_TYPE (decl)))
+ error ("cannot access __block variable of array type inside block");
+ /* build a decl for the byref variable. */
+ decl = build_block_byref_decl (name, decl, decl);
+ }
+ /* APPLE LOCAL end radar 7760213 */
+ else
+ add_block_global_byref_list (decl);
+ }
+ else
+ {
+ /* 'byref' globals are never copied-in. So, do not add
+ them to the copied-in list. */
+ if (!in_block_global_byref_list (decl)) {
+ /* APPLE LOCAL begin radar 7721728 */
+ if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ error ("cannot access copied-in variable of array type inside block");
+ /* APPLE LOCAL end radar 7721728 */
+ /* build a new decl node. set its type to 'const' type
+ of the old decl. */
+ decl = build_block_ref_decl (name, decl);
+ }
+ }
+ }
+ return decl;
+}
+/* APPLE LOCAL end radar 6545782 */
+
+/* APPLE LOCAL end blocks 6040305 */
+
/* ID_EXPRESSION is a representation of parsed, but unprocessed,
id-expression. (See cp_parser_id_expression for details.) SCOPE,
if non-NULL, is the type or namespace used to explicitly qualify
@@ -2510,6 +2624,7 @@
if (decl == error_mark_node)
{
/* Name lookup failed. */
+
if (scope
&& (!TYPE_P (scope)
|| (!dependent_type_p (scope)
@@ -2550,7 +2665,10 @@
{
tree context = decl_function_context (decl);
if (context != NULL_TREE && context != current_function_decl
- && ! TREE_STATIC (decl))
+ /* APPLE LOCAL begin blocks 6040305 */
+ && ! TREE_STATIC (decl)
+ && !block_var_ok_for_context (context))
+ /* APPLE LOCAL end blocks 6040305 */
{
error (TREE_CODE (decl) == VAR_DECL
? "use of %<auto%> variable from containing function"
@@ -2826,8 +2944,21 @@
Access checking has been performed during name lookup
already. Turn off checking to avoid duplicate errors. */
push_deferring_access_checks (dk_no_check);
- decl = finish_non_static_data_member (decl, current_class_ref,
- /*qualifying_scope=*/NULL_TREE);
+ /* APPLE LOCAL begin radar 6169580 */
+ if (cur_block)
+ {
+ tree exp;
+ tree this_copiedin_var = lookup_name (this_identifier);
+ gcc_assert (!current_class_ref);
+ gcc_assert (this_copiedin_var);
+ exp = build_x_arrow (this_copiedin_var);
+ decl = build_class_member_access_expr (exp, decl, TREE_TYPE (exp),
+ /*preserve_reference=*/false);
+ }
+ else
+ decl = finish_non_static_data_member (decl, current_class_ref,
+ /*qualifying_scope=*/NULL_TREE);
+ /* APPLE LOCAL end radar 6169580 */
pop_deferring_access_checks ();
}
else if (is_overloaded_fn (decl))
@@ -2868,7 +2999,8 @@
path = currently_open_derived_class (DECL_CONTEXT (decl));
perform_or_defer_access_check (TYPE_BINFO (path), decl, decl);
}
-
+ /* APPLE LOCAL radar 6545782 */
+ decl = get_final_block_variable (id_expression, decl);
decl = convert_from_reference (decl);
}
}
@@ -2876,6 +3008,30 @@
if (TREE_DEPRECATED (decl))
warn_deprecated_use (decl);
+ /* APPLE LOCAL begin blocks 6040305 (cd) */
+ if (TREE_CODE (decl) == VAR_DECL)
+ {
+ if (BLOCK_DECL_BYREF (decl))
+ {
+ tree orig_decl = decl;
+ decl = build_indirect_ref (decl, "unary *");
+ if (COPYABLE_BYREF_LOCAL_VAR (orig_decl))
+ {
+ /* What we have is an expression which is of type
+ struct __Block_byref_X. Must get to the value of the variable
+ embedded in this structure. It is at:
+ __Block_byref_X.__forwarding->x */
+ decl = build_byref_local_var_access (decl,
+ DECL_NAME (orig_decl));
+ }
+ }
+ else
+ if (COPYABLE_BYREF_LOCAL_VAR (decl))
+ decl = build_byref_local_var_access (decl,
+ DECL_NAME (decl));
+ }
+ /* APPLE LOCAL end blocks 6040305 (cd) */
+
return decl;
}
@@ -3147,6 +3303,11 @@
it. */
if (maybe_clone_body (fn))
{
+ /* APPLE LOCAL begin radar 6305545 */
+ /* Must lower the nested functions which could be, among other
+ things, block helper functions. */
+ lower_if_nested_functions (fn);
+ /* APPLE LOCAL end radar 6305545 */
/* We don't want to process FN again, so pretend we've written
it out, even though we haven't. */
TREE_ASM_WRITTEN (fn) = 1;
@@ -3939,6 +4100,42 @@
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
+
+/* APPLE LOCAL begin blocks 6040305 (ch) */
+tree
+begin_block (void)
+{
+ struct block_sema_info *csi;
+ tree block;
+ /* push_scope (); */
+ current_stmt_tree ()->stmts_are_full_exprs_p = 1;
+#if 0
+ block = do_pushlevel (sk_block);
+#else
+ block = NULL_TREE;
+#endif
+ csi = (struct block_sema_info*)xcalloc (1, sizeof (struct block_sema_info));
+ csi->prev_block_info = cur_block;
+ cur_block = csi;
+ return block;
+}
+
+struct block_sema_info *
+finish_block (tree block)
+{
+ struct block_sema_info *csi = cur_block;
+ cur_block = cur_block->prev_block_info;
+ /* pop_scope (); */
+#if 0
+ if (block)
+ do_poplevel (block);
+#else
+ block = 0;
+#endif
+ return csi;
+}
+/* APPLE LOCAL end blocks 6040305 (ch) */
+
void
init_cp_semantics (void)
Modified: trunk/contrib/gcc/cp/tree.c
===================================================================
--- trunk/contrib/gcc4/cp/tree.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/tree.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1717,6 +1717,15 @@
&& same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)),
current_class_type))
decl = current_class_ref;
+ /* APPLE LOCAL begin radar 6154598 */
+ else if (cur_block)
+ {
+ tree this_copiedin_var = lookup_name (this_identifier);
+ gcc_assert (!current_class_ref);
+ gcc_assert (this_copiedin_var);
+ decl = build_x_arrow (this_copiedin_var);
+ }
+ /* APPLE LOCAL end radar 6154598 */
else
decl = build_dummy_object (context);
@@ -1762,6 +1771,14 @@
return 1;
}
+/* Nonzero iff type T is a class template implicit specialization. */
+
+bool
+class_tmpl_impl_spec_p (tree t)
+{
+ return CLASS_TYPE_P (t) && CLASSTYPE_TEMPLATE_INSTANTIATION (t);
+}
+
/* Returns 1 iff zero initialization of type T means actually storing
zeros in it. */
Modified: trunk/contrib/gcc/cp/typeck.c
===================================================================
--- trunk/contrib/gcc4/cp/typeck.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cp/typeck.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -57,7 +57,8 @@
static bool casts_away_constness (tree, tree);
static void maybe_warn_about_returning_address_of_local (tree);
static tree lookup_destructor (tree, tree, tree);
-static tree convert_arguments (tree, tree, tree, int);
+/* APPLE LOCAL radar 6087117 */
+static tree convert_arguments (tree, tree, tree, int, int);
/* Do `exp = require_complete_type (exp);' to make sure exp
does not have an incomplete type. (That includes void types.)
@@ -406,7 +407,8 @@
tree attributes;
/* Determine the types pointed to by T1 and T2. */
- if (TREE_CODE (t1) == POINTER_TYPE)
+ /* APPLE LOCAL blocks 6040305 */
+ if (TREE_CODE (t1) == POINTER_TYPE || TREE_CODE (t1) == BLOCK_POINTER_TYPE)
{
pointee1 = TREE_TYPE (t1);
pointee2 = TREE_TYPE (t2);
@@ -453,8 +455,13 @@
result_type = build_ptrmem_type (TYPE_PTRMEM_CLASS_TYPE (t1),
result_type);
}
+ /* APPLE LOCAL begin blocks 6065211 */
+ else if (TREE_CODE (t1) == BLOCK_POINTER_TYPE
+ && result_type != void_type_node)
+ result_type = build_block_pointer_type (result_type);
else
result_type = build_pointer_type (result_type);
+ /* APPLE LOCAL end blocks 6065211 */
/* Merge the attributes. */
attributes = (*targetm.merge_type_attributes) (t1, t2);
@@ -524,8 +531,10 @@
if (c_dialect_objc () && TREE_CODE (t1) == POINTER_TYPE
&& TREE_CODE (t2) == POINTER_TYPE)
{
- if (objc_compare_types (t1, t2, -3, NULL_TREE))
- return t1;
+ /* APPLE LOCAL radar 4229905 - radar 6231433 */
+ if (objc_have_common_type (t1, t2, -3, NULL_TREE, location))
+ /* APPLE LOCAL 4154928 */
+ return objc_common_type (t1, t2);
}
/* [expr.eq] permits the application of a pointer conversion to
@@ -572,6 +581,14 @@
return error_mark_node;
}
}
+ /* APPLE LOCAL begin blocks 6065211 */
+ else if (TREE_CODE (t1) != TREE_CODE (t2))
+ {
+ error ("%s between distinct pointer types %qT and %qT "
+ "lacks a cast", location, t1, t2);
+ return error_mark_node;
+ }
+ /* APPLE LOCAL end blocks 6065211 */
return composite_pointer_type_r (t1, t2, location);
}
@@ -1039,6 +1056,21 @@
return false;
break;
+ /* APPLE LOCAL begin blocks 6040305 */
+ case BLOCK_POINTER_TYPE:
+ if (TREE_CODE (t2) == BLOCK_POINTER_TYPE)
+ {
+ tree pt1 = TREE_TYPE (t1);
+ tree pt2 = TREE_TYPE (t2);
+ if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (pt1),
+ TREE_TYPE (pt2)))
+ return false;
+ if (!compparms (TYPE_ARG_TYPES (pt1), TYPE_ARG_TYPES (pt2)))
+ return false;
+ break;
+ }
+ /* APPLE LOCAL end blocks 6040305 */
+
case POINTER_TYPE:
case REFERENCE_TYPE:
if (TYPE_MODE (t1) != TYPE_MODE (t2)
@@ -1358,7 +1390,10 @@
{
pedwarn ("ISO C++ forbids applying %<__alignof%> to an expression of "
"function type");
- t = size_one_node;
+ if (TREE_CODE (e) == FUNCTION_DECL)
+ t = size_int (DECL_ALIGN_UNIT (e));
+ else
+ t = size_one_node;
}
else if (type_unknown_p (e))
{
@@ -1690,17 +1725,20 @@
are equal, so we know what conditional expression this used to be. */
if (TREE_CODE (t) == MIN_EXPR || TREE_CODE (t) == MAX_EXPR)
{
+ tree op0 = TREE_OPERAND (t, 0);
+ tree op1 = TREE_OPERAND (t, 1);
+
/* The following code is incorrect if either operand side-effects. */
- gcc_assert (!TREE_SIDE_EFFECTS (TREE_OPERAND (t, 0))
- && !TREE_SIDE_EFFECTS (TREE_OPERAND (t, 1)));
+ gcc_assert (!TREE_SIDE_EFFECTS (op0)
+ && !TREE_SIDE_EFFECTS (op1));
return
build_conditional_expr (build_x_binary_op ((TREE_CODE (t) == MIN_EXPR
? LE_EXPR : GE_EXPR),
- TREE_OPERAND (t, 0),
- TREE_OPERAND (t, 1),
+ op0, TREE_CODE (op0),
+ op1, TREE_CODE (op1),
/*overloaded_p=*/NULL),
- build_unary_op (code, TREE_OPERAND (t, 0), 0),
- build_unary_op (code, TREE_OPERAND (t, 1), 0));
+ build_unary_op (code, op0, 0),
+ build_unary_op (code, op1, 0));
}
return
@@ -2331,6 +2369,19 @@
types. */
tree t = canonical_type_variant (TREE_TYPE (type));
+ if (TREE_CODE (ptr) == CONVERT_EXPR
+ || TREE_CODE (ptr) == NOP_EXPR
+ || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
+ {
+ /* If a warning is issued, mark it to avoid duplicates from
+ the backend. This only needs to be done at
+ warn_strict_aliasing > 2. */
+ if (warn_strict_aliasing > 2)
+ if (strict_aliasing_warning (TREE_TYPE (TREE_OPERAND (ptr, 0)),
+ type, TREE_OPERAND (ptr, 0)))
+ TREE_NO_WARNING (ptr) = 1;
+ }
+
if (VOID_TYPE_P (t))
{
/* A pointer to incomplete type (other than cv void) can be
@@ -2643,6 +2694,53 @@
return function;
}
+/* APPLE LOCAL begin blocks 6040305 (cm) */
+/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
+/**
+ build_block_call - Routine to build a block call; as in:
+ ((double(*)(void *, int))(BLOCK_PTR_EXP->__FuncPtr))(I, 42);
+ FNTYPE is the original function type derived from the syntax.
+ BLOCK_PTR_EXP is the block pointer variable.
+ PARAMS is the parameter list.
+*/
+static tree
+build_block_call (tree fntype, tree block_ptr_exp, tree params)
+{
+ tree function_ptr_exp;
+ tree typelist;
+ tree result;
+ /* APPLE LOCAL radar 6396238 */
+ bool block_ptr_exp_side_effect = TREE_SIDE_EFFECTS (block_ptr_exp);
+
+ /* First convert it to 'void *'. */
+ block_ptr_exp = convert (ptr_type_node, block_ptr_exp);
+ gcc_assert (generic_block_literal_struct_type);
+ block_ptr_exp = convert (build_pointer_type (generic_block_literal_struct_type),
+ block_ptr_exp);
+ if (block_ptr_exp_side_effect)
+ block_ptr_exp = save_expr (block_ptr_exp);
+
+ /* BLOCK_PTR_VAR->__FuncPtr */
+ function_ptr_exp =
+ finish_class_member_access_expr (build_indirect_ref (block_ptr_exp, "->"),
+ get_identifier ("__FuncPtr"), false);
+ gcc_assert (function_ptr_exp);
+
+ /* Build: result_type(*)(void *, function-arg-type-list) */
+ typelist = TYPE_ARG_TYPES (fntype);
+ typelist = tree_cons (NULL_TREE, ptr_type_node, typelist);
+ fntype = build_function_type (TREE_TYPE (fntype), typelist);
+ function_ptr_exp = convert (build_pointer_type (fntype), function_ptr_exp);
+ params = tree_cons (NULL_TREE, block_ptr_exp, params);
+ result = build3 (CALL_EXPR, TREE_TYPE (fntype),
+ function_ptr_exp, params, NULL_TREE);
+ /* FIXME: should do more from build_cxx_call */
+ result = convert_from_reference (result);
+ return result;
+}
+/* APPLE LOCAL end radar 5847213 - radar 6329245 */
+/* APPLE LOCAL end blocks 6040305 (cm) */
+
tree
build_function_call (tree function, tree params)
{
@@ -2705,7 +2803,8 @@
is_method = (TREE_CODE (fntype) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (fntype)) == METHOD_TYPE);
- if (!((TREE_CODE (fntype) == POINTER_TYPE
+ /* APPLE LOCAL blocks 6040305 */
+ if (!(((TREE_CODE (fntype) == POINTER_TYPE || TREE_CODE (fntype) == BLOCK_POINTER_TYPE)
&& TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE)
|| is_method
|| TREE_CODE (function) == TEMPLATE_ID_EXPR))
@@ -2720,8 +2819,11 @@
/* Convert the parameters to the types declared in the
function prototype, or apply default promotions. */
+ /* APPLE LOCAL begin radar 6087117 */
coerced_params = convert_arguments (TYPE_ARG_TYPES (fntype),
- params, fndecl, LOOKUP_NORMAL);
+ params, fndecl, LOOKUP_NORMAL,
+ (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE));
+ /* APPLE LOCAL end radar 6087117 */
if (coerced_params == error_mark_node)
return error_mark_node;
@@ -2730,10 +2832,14 @@
check_function_arguments (TYPE_ATTRIBUTES (fntype), coerced_params,
TYPE_ARG_TYPES (fntype));
+ /* APPLE LOCAL begin blocks 6040305 */
+ if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
+ return build_block_call (fntype, function, coerced_params);
+ /* APPLE LOCAL end blocks 6040305 */
return build_cxx_call (function, coerced_params);
}
-
+
/* Convert the actual parameter expressions in the list VALUES
to the types in the list TYPELIST.
If parmdecls is exhausted, or when an element has NULL as its type,
@@ -2752,7 +2858,8 @@
default arguments, if such were specified. Do so here. */
static tree
-convert_arguments (tree typelist, tree values, tree fndecl, int flags)
+/* APPLE LOCAL radar 6087117 */
+convert_arguments (tree typelist, tree values, tree fndecl, int flags, int block_call)
{
tree typetail, valtail;
tree result = NULL_TREE;
@@ -2794,7 +2901,8 @@
error ("at this point in file");
}
else
- error ("too many arguments to function");
+ /* APPLE LOCAL radar 6087117 */
+ error ("too many arguments to %s", (block_call ? "block call" : "function"));
/* In case anybody wants to know if this argument
list is valid. */
if (result)
@@ -2896,7 +3004,8 @@
error ("at this point in file");
}
else
- error ("too few arguments to function");
+ /* APPLE LOCAL radar 6087117 */
+ error ("too few arguments to %s", (block_call ? "block call" : "function"));
return error_mark_node;
}
}
@@ -2908,8 +3017,8 @@
conversions on the operands. CODE is the kind of expression to build. */
tree
-build_x_binary_op (enum tree_code code, tree arg1, tree arg2,
- bool *overloaded_p)
+build_x_binary_op (enum tree_code code, tree arg1, enum tree_code arg1_code,
+ tree arg2, enum tree_code arg2_code, bool *overloaded_p)
{
tree orig_arg1;
tree orig_arg2;
@@ -2933,6 +3042,17 @@
expr = build_new_op (code, LOOKUP_NORMAL, arg1, arg2, NULL_TREE,
overloaded_p);
+ /* Check for cases such as x+y<<z which users are likely to
+ misinterpret. But don't warn about obj << x + y, since that is a
+ common idiom for I/O. */
+ if (warn_parentheses
+ && !processing_template_decl
+ && !error_operand_p (arg1)
+ && !error_operand_p (arg2)
+ && (code != LSHIFT_EXPR
+ || !IS_AGGR_TYPE (TREE_TYPE (arg1))))
+ warn_about_parentheses (code, arg1_code, arg2_code);
+
if (processing_template_decl && expr != error_mark_node)
return build_min_non_dep (code, expr, orig_arg1, orig_arg2);
@@ -3077,7 +3197,7 @@
if ((invalid_op_diag
= targetm.invalid_binary_op (code, type0, type1)))
{
- error (invalid_op_diag);
+ error (invalid_op_diag, "");
return error_mark_node;
}
@@ -3284,22 +3404,29 @@
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
|| code1 == COMPLEX_TYPE))
short_compare = 1;
- else if ((code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+ /* APPLE LOCAL begin blocks 6040305 */
+ else if (((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE)
+ && (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
|| (TYPE_PTRMEM_P (type0) && TYPE_PTRMEM_P (type1)))
+ /* APPLE LOCAL end blocks 6040305 */
result_type = composite_pointer_type (type0, type1, op0, op1,
"comparison");
- else if ((code0 == POINTER_TYPE || TYPE_PTRMEM_P (type0))
+ /* APPLE LOCAL blocks 6040305 (cl) */
+ else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE || TYPE_PTRMEM_P (type0))
&& null_ptr_cst_p (op1))
result_type = type0;
- else if ((code1 == POINTER_TYPE || TYPE_PTRMEM_P (type1))
+ /* APPLE LOCAL blocks 6040305 (cl) */
+ else if ((code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE || TYPE_PTRMEM_P (type1))
&& null_ptr_cst_p (op0))
result_type = type1;
- else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+ /* APPLE LOCAL blocks 6040305 (cl) */
+ else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE) && code1 == INTEGER_TYPE)
{
result_type = type0;
error ("ISO C++ forbids comparison between pointer and integer");
}
- else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
+ /* APPLE LOCAL blocks 6040305 (cl) */
+ else if (code0 == INTEGER_TYPE && (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
{
result_type = type1;
error ("ISO C++ forbids comparison between pointer and integer");
@@ -3446,7 +3573,7 @@
|| !same_scalar_type_ignoring_signedness (TREE_TYPE (type0),
TREE_TYPE (type1)))
{
- binary_op_error (code);
+ binary_op_error (code, type0, type1);
return error_mark_node;
}
arithmetic_types_p = 1;
@@ -3759,6 +3886,12 @@
result = fold_if_not_in_template (result);
if (final_type != 0)
result = cp_convert (final_type, result);
+
+ if (TREE_OVERFLOW_P (result)
+ && !TREE_OVERFLOW_P (op0)
+ && !TREE_OVERFLOW_P (op1))
+ overflow_warning (result);
+
return result;
}
@@ -3998,7 +4131,7 @@
: code),
TREE_TYPE (xarg))))
{
- error (invalid_op_diag);
+ error (invalid_op_diag, "");
return error_mark_node;
}
@@ -5211,6 +5344,30 @@
else if (TYPE_PTR_P (type) && INTEGRAL_OR_ENUMERATION_TYPE_P (intype))
/* OK */
;
+ /* APPLE LOCAL begin blocks 6040305 (ck) */
+ else if (TREE_CODE (type) == INTEGER_TYPE && TREE_CODE (intype) == BLOCK_POINTER_TYPE)
+ {
+ if (TYPE_PRECISION (type) < TYPE_PRECISION (intype))
+ pedwarn ("cast from %qT to %qT loses precision",
+ intype, type);
+ }
+ else if (TREE_CODE (type) == BLOCK_POINTER_TYPE && TREE_CODE (intype) == INTEGER_TYPE)
+ /* OK */
+ ;
+ else if (TREE_CODE (type) == BLOCK_POINTER_TYPE && TREE_CODE (intype) == BLOCK_POINTER_TYPE)
+ /* OK */
+ ;
+ else if (TREE_CODE (intype) == BLOCK_POINTER_TYPE
+ && (objc_is_id (type)
+ || (TREE_CODE (type) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type)))))
+ /* OK */
+ ;
+ else if (TREE_CODE (type) == BLOCK_POINTER_TYPE
+ && TREE_CODE (intype) == POINTER_TYPE
+ && (objc_is_id (intype) || VOID_TYPE_P (TREE_TYPE (intype))))
+ /* OK */
+ ;
+ /* APPLE LOCAL end blocks 6040305 (ck) */
else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
|| (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
return fold_if_not_in_template (build_nop (type, expr));
@@ -5236,7 +5393,8 @@
/* We need to strip nops here, because the frontend likes to
create (int *)&a for array-to-pointer decay, instead of &a[0]. */
STRIP_NOPS (sexpr);
- strict_aliasing_warning (intype, type, sexpr);
+ if (warn_strict_aliasing <= 2)
+ strict_aliasing_warning (intype, type, sexpr);
return fold_if_not_in_template (build_nop (type, expr));
}
@@ -5263,6 +5421,14 @@
return error_mark_node;
}
+ /* APPLE LOCAL begin don't sign-extend pointers cast to integers */
+ if (TREE_CODE (type) == INTEGER_TYPE
+ && TREE_CODE (intype) == POINTER_TYPE
+ && TYPE_PRECISION (type) > TYPE_PRECISION (intype)
+ && TYPE_UNSIGNED (type))
+ expr = cp_convert (c_common_type_for_size (POINTER_SIZE, 1), expr);
+ /* APPLE LOCAL end don't sign-extend pointers cast to integers */
+
return cp_convert (type, expr);
}
@@ -5688,6 +5854,19 @@
return error_mark_node;
return result;
}
+ /* APPLE LOCAL end C* property (Radar 4436866) */
+ /* `operator=' is not an inheritable operator. */
+ if (! IS_AGGR_TYPE (lhstype))
+ /* Do the default thing. */;
+ else
+ {
+ result = build_new_op (MODIFY_EXPR, LOOKUP_NORMAL,
+ lhs, rhs, make_node (NOP_EXPR),
+ /*overloaded_p=*/NULL);
+ if (result == NULL_TREE)
+ return error_mark_node;
+ return result;
+ }
lhstype = olhstype;
}
else
@@ -5708,6 +5887,7 @@
/* Now it looks like a plain assignment. */
modifycode = NOP_EXPR;
+ lhstype = olhstype;
}
gcc_assert (TREE_CODE (lhstype) != REFERENCE_TYPE);
gcc_assert (TREE_CODE (TREE_TYPE (newrhs)) != REFERENCE_TYPE);
@@ -5861,10 +6041,47 @@
tree
build_x_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
{
+ /* APPLE LOCAL __block assign sequence point 6639533 */
+ bool insert_sequence_point = false;
+
if (processing_template_decl)
return build_min_nt (MODOP_EXPR, lhs,
build_min_nt (modifycode, NULL_TREE, NULL_TREE), rhs);
+ /* APPLE LOCAL begin __block assign sequence point 6639533 */
+ /* For byref = x;, we have to transform this into ({ typeof(x) x' =
+ x; byref = x`; )} to ensure there is a sequence point before the
+ evaluation of the byref, inorder to ensure that the access
+ expression for byref doesn't start running before x is evaluated,
+ as it will access the __forwarding pointer and that must be done
+ after x is evaluated. */
+ /* First we check to see if lhs is a byref... byrefs look like:
+ __Block_byref_X.__forwarding->x */
+ if (TREE_CODE (lhs) == COMPONENT_REF)
+ {
+ tree inner = TREE_OPERAND (lhs, 0);
+ /* now check for -> */
+ if (TREE_CODE (inner) == INDIRECT_REF)
+ {
+ inner = TREE_OPERAND (inner, 0);
+ if (TREE_CODE (inner) == COMPONENT_REF)
+ {
+ inner = TREE_OPERAND (inner, 0);
+ if (TREE_CODE (inner) == VAR_DECL
+ && COPYABLE_BYREF_LOCAL_VAR (inner))
+ {
+ tree old_rhs = rhs;
+ /* then we save the rhs. */
+ rhs = save_expr (rhs);
+ if (rhs != old_rhs)
+ /* And arrange for the sequence point to be inserted. */
+ insert_sequence_point = true;
+ }
+ }
+ }
+ }
+ /* APPLE LOCAL end __block assign sequence point 6639533 */
+
if (modifycode != NOP_EXPR)
{
tree rval = build_new_op (MODIFY_EXPR, LOOKUP_NORMAL, lhs, rhs,
@@ -5872,11 +6089,20 @@
/*overloaded_p=*/NULL);
if (rval)
{
+ /* APPLE LOCAL begin __block assign sequence point 6639533 */
+ if (insert_sequence_point)
+ rval = build2 (COMPOUND_EXPR, TREE_TYPE (rval), rhs, rval);
+ /* APPLE LOCAL end __block assign sequence point 6639533 */
TREE_NO_WARNING (rval) = 1;
return rval;
}
}
- return build_modify_expr (lhs, modifycode, rhs);
+ lhs = build_modify_expr (lhs, modifycode, rhs);
+ /* APPLE LOCAL begin __block assign sequence point 6639533 */
+ if (insert_sequence_point)
+ lhs = build2 (COMPOUND_EXPR, TREE_TYPE (lhs), rhs, lhs);
+ /* APPLE LOCAL end __block assign sequence point 6639533 */
+ return lhs;
}
@@ -6183,6 +6409,8 @@
{
tree rhstype;
enum tree_code coder;
+ /* APPLE LOCAL radar 4874632 */
+ tree new_rhs = NULL_TREE;
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
@@ -6192,7 +6420,7 @@
coder = TREE_CODE (rhstype);
if (TREE_CODE (type) == VECTOR_TYPE && coder == VECTOR_TYPE
- && vector_types_convertible_p (type, rhstype))
+ && vector_types_convertible_p (type, rhstype, true))
return convert (type, rhs);
if (rhs == error_mark_node || rhstype == error_mark_node)
@@ -6233,8 +6461,10 @@
}
}
- if (objc_compare_types (type, rhstype, parmno, rname))
- return convert (type, rhs);
+ /* APPLE LOCAL file radar 6231433 */
+ if (objc_compare_types (type, rhstype, parmno, rname, "comparison"))
+ /* APPLE LOCAL radar 4874632 */
+ new_rhs = convert (type, rhs);
}
/* [expr.ass]
@@ -6280,6 +6510,19 @@
errtype);
}
+ /* If -Wparentheses, warn about a = b = c when a has type bool and b
+ does not. */
+ if (warn_parentheses
+ && type == boolean_type_node
+ && TREE_CODE (rhs) == MODIFY_EXPR
+ && !TREE_NO_WARNING (rhs)
+ && TREE_TYPE (rhs) != boolean_type_node)
+ {
+ warning (OPT_Wparentheses,
+ "suggest parentheses around assignment used as truth value");
+ TREE_NO_WARNING (rhs) = 1;
+ }
+
return perform_implicit_conversion (strip_top_quals (type), rhs);
}
@@ -6427,6 +6670,10 @@
if (TREE_CODE (valtype) == REFERENCE_TYPE)
warning (0, "reference to local variable %q+D returned",
whats_returned);
+ /* APPLE LOCAL begin blocks 6040305 (cn) */
+ else if (TREE_CODE (valtype) == BLOCK_POINTER_TYPE)
+ error ("returning block that lives on the local stack");
+ /* APPLE LOCAL end blocks 6040305 (cn) */
else
warning (0, "address of local variable %q+D returned",
whats_returned);
@@ -6434,6 +6681,14 @@
}
}
+/* APPLE LOCAL begin blocks 6040305 (cm) */
+static bool
+types_are_block_compatible (tree t1, tree t2)
+{
+ return comptypes (t1, t2, COMPARE_STRICT);
+}
+/* APPLE LOCAL end blocks 6040305 (cm) */
+
/* Check that returning RETVAL from the current function is valid.
Return an expression explicitly showing all conversions required to
change RETVAL into the function return type, and to assign it to
@@ -6477,6 +6732,64 @@
return NULL_TREE;
}
+ /* APPLE LOCAL begin blocks 6040305 (cm) */
+ /* APPLE LOCAL radar 6185344 */
+ if (cur_block && !cur_block->block_has_return_type)
+ {
+ /* If this is the first return we've seen in the block, infer the type of
+ the block from it. */
+ if (cur_block->return_type == NULL_TREE)
+ {
+ if (retval)
+ {
+ tree restype;
+ retval = decay_conversion (retval);
+ restype = TYPE_MAIN_VARIANT (TREE_TYPE (retval));
+ TREE_TYPE (current_function_decl)
+ = build_function_type (restype,
+ TYPE_ARG_TYPES (TREE_TYPE (current_function_decl)));
+ TREE_TYPE (DECL_RESULT (current_function_decl)) = restype;
+ relayout_decl (DECL_RESULT (current_function_decl));
+ cur_block->return_type = restype;
+ }
+ else
+ cur_block->return_type = void_type_node;
+ }
+
+ /* Verify that this result type matches the previous one. We
+ are pickier with blocks than for normal functions because
+ this is a new feature and we set the rules. */
+ if (TREE_CODE (cur_block->return_type) == VOID_TYPE)
+ {
+ if (retval)
+ {
+ error ("void block should not return a value");
+ return error_mark_node;
+ }
+ }
+ else if (!retval)
+ {
+ error ("non-void block should return a value");
+ return error_mark_node;
+ }
+
+ if (retval)
+ {
+ /* We have a non-void block with an expression, continue checking. */
+ valtype = TREE_TYPE (retval);
+
+ /* For now, restrict multiple return statements in a block to have
+ strict compatible types only. */
+ if (!types_are_block_compatible (cur_block->return_type, valtype))
+ {
+ error ("incompatible type returning %qT, expected %qT",
+ valtype, cur_block->return_type);
+ return error_mark_node;
+ }
+ }
+ }
+ /* APPLE LOCAL end blocks 6040305 (cm) */
+
if (processing_template_decl)
{
current_function_returns_value = 1;
@@ -6749,7 +7062,7 @@
continue;
if (TREE_CODE (to) == VECTOR_TYPE
- && vector_types_convertible_p (to, from))
+ && vector_types_convertible_p (to, from, false))
return 1;
if (TREE_CODE (to) == INTEGER_TYPE
Modified: trunk/contrib/gcc/cppdefault.c
===================================================================
--- trunk/contrib/gcc4/cppdefault.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/cppdefault.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -33,7 +33,7 @@
#define STANDARD_INCLUDE_COMPONENT 0
#endif
-#if defined (CROSS_COMPILE) && !defined (TARGET_SYSTEM_ROOT)
+#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
# undef LOCAL_INCLUDE_DIR
# undef SYSTEM_INCLUDE_DIR
# undef STANDARD_INCLUDE_DIR
Modified: trunk/contrib/gcc/dbxout.c
===================================================================
--- trunk/contrib/gcc4/dbxout.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/dbxout.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1825,6 +1825,8 @@
{
case VOID_TYPE:
case LANG_TYPE:
+ /* APPLE LOCAL blocks 6034272 */
+ case BLOCK_POINTER_TYPE:
/* For a void type, just define it as itself; i.e., "5=5".
This makes us consider it defined
without saying what it is. The debugger will make it
Modified: trunk/contrib/gcc/doc/cpp.texi
===================================================================
--- trunk/contrib/gcc4/doc/cpp.texi 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/cpp.texi 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2134,6 +2134,10 @@
This macro is defined, with value 2, when @option{-fstack-protector-all} is
in use.
+ at item __SSP_STRONG__
+This macro is defined, with value 3, when @option{-fstack-protector-strong} is
+in use.
+
@item __TIMESTAMP__
This macro expands to a string constant that describes the date and time
of the last modification of the current source file. The string constant
Modified: trunk/contrib/gcc/doc/cppopts.texi
===================================================================
--- trunk/contrib/gcc4/doc/cppopts.texi 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/cppopts.texi 2018-06-04 17:30:21 UTC (rev 10405)
@@ -506,6 +506,22 @@
@xref{Search Path}.
@end ifset
+ at item -fdirectives-only
+ at opindex fdirectives-only
+This option provides a simplified preprocessor to improve the
+performance of distributed build systems such as distcc. It's
+behavior depends on a number of other flags.
+
+If the @option{-E} option is enabled, it suppresses things like macro
+expansion, trigraph conversion, and escaped newline splicing
+outside of directives. All directives are processed normally, except that
+macro definitions are output similar to the @option{-dD} option.
+
+If the @option{-fpreprocessed} option is enabled, it suppresses
+predefinition of most builtin and command line macros. This
+prevents duplicate definition of macros output with the @option{-E}
+option.
+
@item -fdollars-in-identifiers
@opindex fdollars-in-identifiers
@anchor{fdollars-in-identifiers}
@@ -629,6 +645,10 @@
@noindent
will show all the predefined macros.
+If you use @option{-dM} without the @option{-E} option, @option{-dM} is
+interpreted as a synonym for @option{-fdump-rtl-mach}.
+ at xref{Debugging Options, , ,gcc}.
+
@item D
@opindex dD
Like @samp{M} except in two respects: it does @emph{not} include the
Modified: trunk/contrib/gcc/doc/extend.texi
===================================================================
--- trunk/contrib/gcc4/doc/extend.texi 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/extend.texi 2018-06-04 17:30:21 UTC (rev 10405)
@@ -58,6 +58,9 @@
* Character Escapes:: @samp{\e} stands for the character @key{ESC}.
* Variable Attributes:: Specifying attributes of variables.
* Type Attributes:: Specifying attributes of types.
+ at c APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+* Label Attributes:: Specifying attributes of labels and statements.
+ at c APPLE LOCAL end for-fsf-4_4 3274130 5295549
* Alignment:: Inquiring about the alignment of a type or variable.
* Inline:: Defining inline functions (as fast as macros).
* Extended Asm:: Assembler instructions with C expressions as operands.
@@ -81,6 +84,9 @@
* Pragmas:: Pragmas accepted by GCC.
* Unnamed Fields:: Unnamed struct/union fields within structs/unions.
* Thread-Local:: Per-thread variables.
+* Binary constants:: Binary constants using the @samp{0b} prefix.
+ at c APPLE LOCAL blocks 7205047 5811887
+* Blocks:: Anonymous functions (closures).
@end menu
@node Statement Exprs
@@ -374,9 +380,14 @@
@cindex thunks
A @dfn{nested function} is a function defined inside another function.
-(Nested functions are not supported for GNU C++.) The nested function's
-name is local to the block where it is defined. For example, here we
-define a nested function named @code{square}, and call it twice:
+ at c APPLE LOCAL begin nested functions 4357979
+Nested functions are not supported for GNU C++ and are disable by
+default on FreeBSD. The @option{-fnested-functions} and
+ at option{-fno-nested-functions} options can be used to enable and
+disable nested function suppport. The nested function's name is local
+to the block where it is defined. For example, here we define a
+nested function named @code{square}, and call it twice:
+ at c APPLE LOCAL end nested functions 4357979
@smallexample
@group
@@ -1576,6 +1587,7 @@
attributes when making a declaration. This keyword is followed by an
attribute specification inside double parentheses. The following
attributes are currently defined for functions on all targets:
+ at code{aligned},
@code{noreturn}, @code{returns_twice}, @code{noinline}, @code{always_inline},
@code{flatten}, @code{pure}, @code{const}, @code{nothrow}, @code{sentinel},
@code{format}, @code{format_arg}, @code{no_instrument_function},
@@ -1585,8 +1597,11 @@
@code{gnu_inline} and @code{externally_visible}. Several other
attributes are defined for functions on particular target systems. Other
attributes, including @code{section} are supported for variables declarations
-(@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
+ at c APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+(@pxref{Variable Attributes}), for types (@pxref{Type Attributes}),
+and labels (@pxref{Label Attributes}).
+ at c APPLE LOCAL end for-fsf-4_4 3274130 5295549
You may also specify attributes with @samp{__} preceding and following
each keyword. This allows you to use them in header files without
being concerned about a possible macro of the same name. For example,
@@ -1614,6 +1629,27 @@
Not all target machines support this attribute.
+ at item aligned (@var{alignment})
+ at cindex @code{aligned} attribute
+This attribute specifies a minimum alignment for the function,
+measured in bytes.
+
+You cannot use this attribute to decrease the alignment of a function,
+only to increase it. However, when you explicitly specify a function
+alignment this will override the effect of the
+ at option{-falign-functions} (@pxref{Optimize Options}) option for this
+function.
+
+Note that the effectiveness of @code{aligned} attributes may be
+limited by inherent limitations in your linker. On many systems, the
+linker is only able to arrange for functions to be aligned up to a
+certain maximum alignment. (For some linkers, the maximum supported
+alignment may be very very small.) See your linker documentation for
+further information.
+
+The @code{aligned} attribute can also be used for variables and fields
+(@pxref{Variable Attributes}.)
+
@item always_inline
@cindex @code{always_inline} function attribute
Generally, functions are not inlined unless optimization is specified.
@@ -2617,10 +2653,14 @@
@xref{Function Attributes}, for details of the semantics of attributes
applying to functions. @xref{Variable Attributes}, for details of the
-semantics of attributes applying to variables. @xref{Type Attributes},
-for details of the semantics of attributes applying to structure, union
-and enumerated types.
+ at c APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+semantics of attributes applying to variables. @xref{Type
+Attributes}, for details of the semantics of attributes applying to
+structure, union and enumerated types. @xref{Label Attributes}, for
+details of the semantics of attributes applying to labels and
+statements.
+ at c APPLE LOCAL end for-fsf-4_4 3274130 5295549
An @dfn{attribute specifier} is of the form
@code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
is a possibly empty comma-separated sequence of @dfn{attributes}, where
@@ -2657,19 +2697,18 @@
An @dfn{attribute specifier list} is a sequence of one or more attribute
specifiers, not separated by any other tokens.
-In GNU C, an attribute specifier list may appear after the colon following a
-label, other than a @code{case} or @code{default} label. The only
-attribute it makes sense to use after a label is @code{unused}. This
-feature is intended for code generated by programs which contains labels
-that may be unused but which is compiled with @option{-Wall}. It would
-not normally be appropriate to use in it human-written code, though it
-could be useful in cases where the code that jumps to the label is
-contained within an @code{#ifdef} conditional. GNU C++ does not permit
-such placement of attribute lists, as it is permissible for a
-declaration, which could begin with an attribute list, to be labelled in
-C++. Declarations cannot be labelled in C90 or C99, so the ambiguity
-does not arise there.
+ at c APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+In GNU C, an attribute specifier list may appear after the colon
+following a label, other than a @code{case} or @code{default} label.
+GNU C++ does not permit such placement of attribute lists, as it is
+permissible for a declaration, which could begin with an attribute
+list, to be labelled in C++. Declarations cannot be labelled in C90
+or C99, so the ambiguity does not arise there.
+In GNU C an attribute specifier list may also appear after the keyword
+ at code{while} in a while loop, after @code{do} and after @code{for}.
+
+ at c APPLE LOCAL end for-fsf-4_4 3274130 5295549
An attribute specifier list may appear as part of a @code{struct},
@code{union} or @code{enum} specifier. It may go either immediately
after the @code{struct}, @code{union} or @code{enum} keyword, or after
@@ -2973,10 +3012,12 @@
attributes are currently defined generically for variables.
Other attributes are defined for variables on particular target
systems. Other attributes are available for functions
-(@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
-Other front ends might define more attributes
-(@pxref{C++ Extensions,,Extensions to the C++ Language}).
+ at c APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+(@pxref{Function Attributes}), types (@pxref{Type Attributes}) and
+labels (@pxref{Label Attributes}). Other front ends might define
+more attributes (@pxref{C++ Extensions,,Extensions to the C++ Language}).
+ at c APPLE LOCAL end for-fsf-4_4 3274130 5295549
You may also specify attributes with @samp{__} preceding and following
each keyword. This allows you to use them in header files without
being concerned about a possible macro of the same name. For example,
@@ -3043,6 +3084,9 @@
in an @code{__attribute__} will still only provide you with 8 byte
alignment. See your linker documentation for further information.
+The @code{aligned} attribute can also be used for functions
+(@pxref{Function Attributes}.)
+
@item cleanup (@var{cleanup_function})
@cindex @code{cleanup} attribute
The @code{cleanup} attribute runs a function when the variable goes
@@ -3470,9 +3514,11 @@
types: @code{aligned}, @code{packed}, @code{transparent_union},
@code{unused}, @code{deprecated}, @code{visibility}, and
@code{may_alias}. Other attributes are defined for functions
-(@pxref{Function Attributes}) and for variables (@pxref{Variable
-Attributes}).
+ at c APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+(@pxref{Function Attributes}), variables (@pxref{Variable
+Attributes}), and labels (@pxref{Label Attributes}).
+ at c APPLE LOCAL end for-fsf-4_4 3274130 5295549
You may also specify any one of these attributes with @samp{__}
preceding and following its keyword. This allows you to use these
attributes in header files without being concerned about a possible
@@ -3747,6 +3793,22 @@
Otherwise the two shared objects will be unable to use the same
typeinfo node and exception handling will break.
+ at c APPLE LOCAL begin weak types 5954418
+ at item weak
+In C++, attribute weak can be applied to a class to ensure that all
+non-hidden instances of the type are treated as the same type across
+shared library boundaries on platforms (such as darwin and arm aapcs)
+that can emit vtables and the type info meta data as non-comdat
+symbols. This is useful when the class has a key method and the
+translation unit that contains the key method is used in more than one
+shared library or in a shared library and the application. Doing this
+results in more expensive startup times. This attribute is inherited
+by subclasses, so it is only necessary to mark a base type. The
+typical use would be to mark any types used for throwing across shared
+library boundaries or those used in dynamic_cast operations across a
+shared library boundary.
+ at c APPLE LOCAL end weak types 5954418
+
@subsection ARM Type Attributes
On those ARM targets that support @code{dllimport} (such as Symbian
@@ -3820,6 +3882,67 @@
These attributes mainly are intended to support the @code{__vector},
@code{__pixel}, and @code{__bool} AltiVec keywords.
+ at c APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+ at node Label Attributes
+ at section Specifying Attributes of Labels and Statements
+ at cindex attribute of labels
+ at cindex label attributes
+ at cindex attribute of statements
+ at cindex statement attributes
+
+The keyword @code{__attribute__} allows you to specify special
+attributes of labels and statements.
+
+Some attributes are currently defined generically for variables.
+Other attributes are defined for variables on particular target
+systems. Other attributes are available for functions
+(@pxref{Function Attributes}), types (@pxref{Type Attributes}) and
+variables (@pxref{Variable Attributes}).
+
+You may also specify attributes with @samp{__} preceding and following
+each keyword. This allows you to use them in header files without
+being concerned about a possible macro of the same name. For example,
+you may use @code{__aligned__} instead of @code{aligned}.
+
+ at xref{Attribute Syntax}, for details of the exact syntax for using
+attributes.
+
+ at table @code
+ at cindex @code{aligned} attribute
+ at item aligned (@var{alignment})
+This attribute specifies a minimum alignment for the label,
+measured in bytes. For example, the declaration:
+
+ at smallexample
+ some_label: __attribute__((aligned(16)))
+ at end smallexample
+
+ at noindent
+requests the compiler to align the label, inserting @code{nop}s as necessary,
+to a 16-byte boundary.
+
+The alignment is only a request. The compiler will usually be able to
+honour it but sometimes the label will be eliminated by the compiler,
+in which case its alignment will be eliminated too.
+
+When applied to loops, the @code{aligned} attribute causes the loop to
+be aligned.
+
+ at item unused
+When attached to a label this attribute means that the label might not
+be used. GCC will not produce a warning for the label, even if the
+label doesn't seem to be referenced. This feature is intended for
+code generated by programs which contains labels that may be unused
+but which is compiled with @option{-Wall}. It would not normally be
+appropriate to use in it human-written code, though it could be useful
+in cases where the code that jumps to the label is contained within an
+ at code{#ifdef} conditional.
+
+This attribute can only be applied to labels, not statements, because
+there is no warning if a statement is removed.
+ at end table
+
+ at c APPLE LOCAL end for-fsf-4_4 3274130 5295549
@node Inline
@section An Inline Function is As Fast As a Macro
@cindex inline functions
@@ -6145,7 +6268,17 @@
are @code{long double}.
@end deftypefn
+ at deftypefn {Built-in Function} int32_t __builtin_bswap32 (int32_t x)
+Returns @var{x} with the order of the bytes reversed; for example,
+ at code{0xaabbccdd} becomes @code{0xddccbbaa}. Byte here always means
+exactly 8 bits.
+ at end deftypefn
+ at deftypefn {Built-in Function} int64_t __builtin_bswap64 (int64_t x)
+Similar to @code{__builtin_bswap32}, except the argument and return types
+are 64-bit.
+ at end deftypefn
+
@node Target Builtins
@section Built-in Functions Specific to Particular Target Machines
@@ -7255,6 +7388,23 @@
v8hi __builtin_ia32_pabsw128 (v8hi)
@end smallexample
+The following built-in functions are available when @option{-msse4a} is used.
+
+ at smallexample
+void _mm_stream_sd (double*,__m128d);
+Generates the @code{movntsd} machine instruction.
+void _mm_stream_ss (float*,__m128);
+Generates the @code{movntss} machine instruction.
+__m128i _mm_extract_si64 (__m128i, __m128i);
+Generates the @code{extrq} machine instruction with only SSE register operands.
+__m128i _mm_extracti_si64 (__m128i, int, int);
+Generates the @code{extrq} machine instruction with SSE register and immediate operands.
+__m128i _mm_insert_si64 (__m128i, __m128i);
+Generates the @code{insertq} machine instruction with only SSE register operands.
+__m128i _mm_inserti_si64 (__m128i, __m128i, int, int);
+Generates the @code{insertq} machine instruction with SSE register and immediate operands.
+ at end smallexample
+
The following built-in functions are available when @option{-m3dnow} is used.
All of them generate the machine instruction that is part of the name.
@@ -10407,6 +10557,40 @@
@end quotation
@end itemize
+ at c APPLE LOCAL begin blocks 7205047 5811887
+ at node Blocks
+ at section Blocks
+ at cindex Blocks
+ at cindex __block
+
+Blocks is a language feature that allows one to create anonymous
+functions. The feature is also known as lambdas or closures in other
+languages. The feature is controlled by @option{-fblocks}.
+See @uref{http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html} for additional details.
+ at c APPLE LOCAL end blocks 7205047 5811887
+
+ at node Binary constants
+ at section Binary constants using the @samp{0b} prefix
+ at cindex Binary constants using the @samp{0b} prefix
+
+Integer constants can be written as binary constants, consisting of a
+sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
+ at samp{0B}. This is particularly useful in environments that operate a
+lot on the bit-level (like microcontrollers).
+
+The following statements are identical:
+
+ at smallexample
+i = 42;
+i = 0x2a;
+i = 052;
+i = 0b101010;
+ at end smallexample
+
+The type of these constants follows the same rules as for octal or
+hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
+can be applied.
+
@node C++ Extensions
@chapter Extensions to the C++ Language
@cindex extensions, C++ language
Modified: trunk/contrib/gcc/doc/gcc.1
===================================================================
--- trunk/contrib/gcc4/doc/gcc.1 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/gcc.1 2018-06-04 17:30:21 UTC (rev 10405)
@@ -339,7 +339,7 @@
\&\fB\-fsched2\-use\-superblocks
\&\-fsched2\-use\-traces \-fsee \-freschedule\-modulo\-scheduled\-loops
\&\-fsection\-anchors \-fsignaling\-nans \-fsingle\-precision\-constant
-\&\-fstack\-protector \-fstack\-protector\-all
+\&\-fstack\-protector \-fstack\-protector\-all \-fstack\-protector\-strong
\&\-fstrict\-aliasing \-fstrict\-overflow \-ftracer \-fthread\-jumps
\&\-funroll\-all\-loops \-funroll\-loops \-fpeel\-loops
\&\-fsplit\-ivs\-in\-unroller \-funswitch\-loops
@@ -5193,6 +5193,11 @@
.IP "\fB\-fstack\-protector\-all\fR" 4
.IX Item "-fstack-protector-all"
Like \fB\-fstack\-protector\fR except that all functions are protected.
+.IP "\fB\-fstack\-protector\-strong\fR" 4
+.IX Item "-fstack-protector-strong"
+Like \fB\-fstack\-protector\fR but includes additional functions to
+be protected \-\-\- those that have local array definitions, or have
+references to local frame addresses.
.IP "\fB\-fsection\-anchors\fR" 4
.IX Item "-fsection-anchors"
Try to reduce the number of symbolic address calculations by using
Modified: trunk/contrib/gcc/doc/invoke.texi
===================================================================
--- trunk/contrib/gcc4/doc/invoke.texi 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/invoke.texi 2018-06-04 17:30:21 UTC (rev 10405)
@@ -164,11 +164,16 @@
@xref{C Dialect Options,,Options Controlling C Dialect}.
@gccoptlist{-ansi -std=@var{standard} -fgnu89-inline @gol
-aux-info @var{filename} @gol
--fno-asm -fno-builtin -fno-builtin- at var{function} @gol
+ at c APPLE LOCAL blocks 7205047 5811887
+-fno-asm -fno-blocks -fno-builtin -fno-builtin- at var{function} @gol
-fhosted -ffreestanding -fopenmp -fms-extensions @gol
-trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol
--fallow-single-precision -fcond-mismatch @gol
+-fallow-single-precision -fcond-mismatch -flax-vector-conversions @gol
+ at c APPLE LOCAL nested functions 4357979 */
+-fno-nested-functions @gol
-fsigned-bitfields -fsigned-char @gol
+ at c APPLE LOCAL -Wnewline-eof 2001-08-23 --sts **
+-Wnewline-eof (Apple compatible) @gol
-funsigned-bitfields -funsigned-char}
@item C++ Language Options
@@ -186,6 +191,7 @@
-frepo -fno-rtti -fstats -ftemplate-depth- at var{n} @gol
-fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol
-fno-default-inline -fvisibility-inlines-hidden @gol
+-fvisibility-ms-compat @gol
-Wabi -Wctor-dtor-privacy @gol
-Wnon-virtual-dtor -Wreorder @gol
-Weffc++ -Wno-deprecated -Wstrict-null-sentinel @gol
@@ -214,10 +220,15 @@
-Wimport -Wno-import -Winit-self -Winline @gol
-Wno-int-to-pointer-cast @gol
-Wno-invalid-offsetof -Winvalid-pch @gol
--Wlarger-than- at var{len} -Wunsafe-loop-optimizations -Wlong-long @gol
+-Wlarger-than- at var{len} -Wframe-larger-than- at var{len} @gol
+-Wunsafe-loop-optimizations -Wlong-long @gol
-Wmain -Wmissing-braces -Wmissing-field-initializers @gol
-Wmissing-format-attribute -Wmissing-include-dirs @gol
-Wmissing-noreturn @gol
+ at c APPLE LOCAL warn missing prototype 6261539
+-Wmissing-prototypes @gol
+ at c APPLE LOCAL -Wmost
+-Wmost (APPLE ONLY) @gol
-Wno-multichar -Wnonnull -Wno-overflow @gol
-Woverlength-strings -Wpacked -Wpadded @gol
-Wparentheses -Wpointer-arith -Wno-pointer-to-int-cast @gol
@@ -230,12 +241,14 @@
-Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code @gol
-Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
--Wunused-value -Wunused-variable -Wvariadic-macros @gol
+-Wunused-value -Wunused-variable @gol
+-Wvariadic-macros -Wvla @gol
-Wvolatile-register-var -Wwrite-strings}
@item C-only Warning Options
@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
--Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol
+ at c APPLE LOCAL warn missing prototype 6261539
+-Wnested-externs -Wold-style-definition @gol
-Wstrict-prototypes -Wtraditional @gol
-Wdeclaration-after-statement -Wpointer-sign}
@@ -274,6 +287,8 @@
-ftest-coverage -ftime-report -fvar-tracking @gol
-g -g at var{level} -gcoff -gdwarf-2 @gol
-ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol
+-femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
+-femit-struct-debug-detailed at r{[}=@var{spec-list}@r{]} @gol
-p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
-print-multi-directory -print-multi-lib @gol
-print-prog-name=@var{program} -print-search-dirs -Q @gol
@@ -316,7 +331,7 @@
-fsched2-use-superblocks @gol
-fsched2-use-traces -fsee -freschedule-modulo-scheduled-loops @gol
-fsection-anchors -fsignaling-nans -fsingle-precision-constant @gol
--fstack-protector -fstack-protector-all @gol
+-fstack-protector -fstack-protector-all -fstack-protector-strong @gol
-fstrict-aliasing -fstrict-overflow -ftracer -fthread-jumps @gol
-funroll-all-loops -funroll-loops -fpeel-loops @gol
-fsplit-ivs-in-unroller -funswitch-loops @gol
@@ -513,7 +528,7 @@
-mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol
-mno-wide-multiply -mrtd -malign-double @gol
-mpreferred-stack-boundary=@var{num} @gol
--mmmx -msse -msse2 -msse3 -mssse3 -m3dnow @gol
+-mmmx -msse -msse2 -msse3 -mssse3 -msse4a -m3dnow -mpopcnt -mabm -maes @gol
-mthreads -mno-align-stringops -minline-all-stringops @gol
-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
-m96bit-long-double -mregparm=@var{num} -msseregparm @gol
@@ -755,6 +770,8 @@
-fnon-call-exceptions -funwind-tables @gol
-fasynchronous-unwind-tables @gol
-finhibit-size-directive -finstrument-functions @gol
+-finstrument-functions-exclude-function-list=@var{sym}, at var{sym}, at dots{} @gol
+-finstrument-functions-exclude-file-list=@var{file}, at var{file}, at dots{} @gol
-fno-common -fno-ident @gol
-fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol
-fno-jump-tables @gol
@@ -1219,6 +1236,16 @@
switch only affects the @code{asm} and @code{typeof} keywords, since
@code{inline} is a standard keyword in ISO C99.
+ at c APPLE LOCAL begin blocks 7205047 5811887
+ at item -fno-blocks
+ at opindex fno-blocks
+Disable the use of blocks. In @option{-std=c99} mode, blocks are
+turned off by default. @option{-fblocks} can be used to re-enable the
+feature, if off. Runtime support for blocks first appeared in Mac OS
+X 10.6. When targeting 10.6 (see @option{-mmacosx-version-min}) and
+later, the extension is on by default.
+ at c APPLE LOCAL end blocks 7205047 5811887
+
@item -fno-builtin
@itemx -fno-builtin- at var{function}
@opindex fno-builtin
@@ -1325,6 +1352,13 @@
The preprocessor continues to support a pre-standard mode. See the GNU
CPP manual for details.
+ at c APPLE LOCAL begin nested functions 4357979
+ at item -fno-nested-functions
+ at opindex fno-nested-functions
+Disable nested functions. This option is not supported for C++ or
+Objective-C++. On FreeBSD, nested functions are disabled by default.
+ at c APPLE LOCAL end nested functions 4357979
+
@item -fcond-mismatch
@opindex fcond-mismatch
Allow conditional expressions with mismatched types in the second and
@@ -1331,6 +1365,12 @@
third arguments. The value of such an expression is void. This option
is not supported for C++.
+ at item -flax-vector-conversions
+ at opindex flax-vector-conversions
+Allow implicit conversions between vectors with differing numbers of
+elements and/or incompatible element types. This option should not be
+used for new code.
+
@item -funsigned-char
@opindex funsigned-char
Let the type @code{char} be unsigned, like @code{unsigned char}.
@@ -1614,6 +1654,40 @@
as their linkage might otherwise cross a shared library boundary.
@xref{Template Instantiation}.
+ at item -fvisibility-ms-compat
+ at opindex fvisibility-ms-compat
+This flag attempts to use visibility settings to make GCC's C++
+linkage model compatible with that of Microsoft Visual Studio.
+
+The flag makes these changes to GCC's linkage model:
+
+ at enumerate
+ at item
+It sets the default visibility to @code{hidden}, like
+ at option{-fvisibility=hidden}.
+
+ at item
+Types, but not their members, are not hidden by default.
+
+ at item
+The One Definition Rule is relaxed for types without explicit
+visibility specifications which are defined in more than one different
+shared object: those declarations are permitted if they would have
+been permitted when this option was not used.
+ at end enumerate
+
+In new code it is better to use @option{-fvisibility=hidden} and
+export those classes which are intended to be externally visible.
+Unfortunately it is possible for code to rely, perhaps accidentally,
+on the Visual Studio behaviour.
+
+Among the consequences of these changes are that static data members
+of the same type with the same name but defined in different shared
+objects will be different, so changing one will not change the other;
+and that pointers to function members defined in different shared
+objects may not compare equal. When this flag is given, it is a
+violation of the ODR to define types with the same name differently.
+
@item -fno-weak
@opindex fno-weak
Do not use weak symbol support, even if it is provided by the linker.
@@ -2035,6 +2109,12 @@
@opindex Wno-import
Inhibit warning messages about the use of @samp{#import}.
+ at c APPLE LOCAL begin -Wnewline-eof 2001-08-23 --sts **
+ at item -Wnewline-eof
+ at opindex Wnewline-eof
+Warn about files missing a newline at the end of the file. (Apple compatible)
+ at c APPLE LOCAL end -Wnewline-eof 2001-08-23 --sts **
+
@item -Wchar-subscripts
@opindex Wchar-subscripts
Warn if an array subscript has type @code{char}. This is a common cause
@@ -2212,9 +2292,7 @@
Warn if parentheses are omitted in certain contexts, such
as when there is an assignment in a context where a truth value
is expected, or when operators are nested whose precedence people
-often get confused about. Only the warning for an assignment used as
-a truth value is supported when compiling C++; the other warnings are
-only supported when compiling C at .
+often get confused about.
Also warn if a comparison like @samp{x<=y<=z} appears; this is
equivalent to @samp{(x<=y ? 1 : 0) <= z}, which is a different
@@ -2236,14 +2314,15 @@
@end group
@end smallexample
-In C, every @code{else} branch belongs to the innermost possible @code{if}
-statement, which in this example is @code{if (b)}. This is often not
-what the programmer expected, as illustrated in the above example by
-indentation the programmer chose. When there is the potential for this
-confusion, GCC will issue a warning when this flag is specified.
-To eliminate the warning, add explicit braces around the innermost
- at code{if} statement so there is no way the @code{else} could belong to
-the enclosing @code{if}. The resulting code would look like this:
+In C/C++, every @code{else} branch belongs to the innermost possible
+ at code{if} statement, which in this example is @code{if (b)}. This is
+often not what the programmer expected, as illustrated in the above
+example by indentation the programmer chose. When there is the
+potential for this confusion, GCC will issue a warning when this flag
+is specified. To eliminate the warning, add explicit braces around
+the innermost @code{if} statement so there is no way the @code{else}
+could belong to the enclosing @code{if}. The resulting code would
+look like this:
@smallexample
@group
@@ -2503,15 +2582,41 @@
compiler is using for optimization. The warning does not catch all
cases, but does attempt to catch the more common pitfalls. It is
included in @option{-Wall}.
+It is equivalent to -Wstrict-aliasing=3
- at item -Wstrict-aliasing=2
- at opindex Wstrict-aliasing=2
+ at item -Wstrict-aliasing=n
+ at opindex Wstrict-aliasing=n
This option is only active when @option{-fstrict-aliasing} is active.
It warns about code which might break the strict aliasing rules that the
-compiler is using for optimization. This warning catches more cases than
- at option{-Wstrict-aliasing}, but it will also give a warning for some ambiguous
-cases that are safe.
+compiler is using for optimization.
+Higher levels correspond to higher accuracy (fewer false positives).
+Higher levels also correspond to more effort, similar to the way -O works.
+ at option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=n},
+with n=3.
+Level 1: Most aggressive, quick, least accurate.
+Possibly useful when higher levels
+do not warn but -fstrict-aliasing still breaks the code, as it has very few
+false negatives. However, it has many false positives.
+Warns for all pointer conversions between possibly incompatible types,
+even if never dereferenced. Runs in the frontend only.
+
+Level 2: Aggressive, quick, not too precise.
+May still have many false positives (not as many as level 1 though),
+and few false negatives (but possibly more than level 1).
+Unlike level 1, it only warns when an address is taken. Warns about
+incomplete types. Runs in the frontend only.
+
+Level 3 (default for @option{-Wstrict-aliasing}):
+Should have very few false positives and few false
+negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
+Takes care of the common punn+dereference pattern in the frontend:
+ at code{*(int*)&some_float}.
+If optimization is enabled, it also runs in the backend, where it deals
+with multiple statement cases using flow-sensitive points-to information.
+Only warns when the converted pointer is dereferenced.
+Does not warn about incomplete types.
+
@item -Wstrict-overflow
@item -Wstrict-overflow=@var{n}
@opindex Wstrict-overflow
@@ -2572,7 +2677,12 @@
that are easy to avoid (or modify to prevent the warning), even in
conjunction with macros. This also enables some language-specific
warnings described in @ref{C++ Dialect Options}.
+ at c APPLE LOCAL begin -Wmost
+ at item -Wmost
+ at opindex Wmost
+This is equivalent to -Wall -Wno-parentheses. (Apple compatible)
@end table
+ at c APPLE LOCAL end -Wmost
The following @option{-W at dots{}} options are not implied by @option{-Wall}.
Some of them warn about constructions that users generally do not
@@ -2826,6 +2936,10 @@
@opindex Wlarger-than
Warn whenever an object of larger than @var{len} bytes is defined.
+ at item -Wframe-larger-than- at var{len}
+ at opindex Wframe-larger-than
+Warn whenever the frame size of a function is larger than @var{len} bytes.
+
@item -Wunsafe-loop-optimizations
@opindex Wunsafe-loop-optimizations
Warn if the loop cannot be optimized because the compiler could not
@@ -2941,7 +3055,8 @@
Warn if an old-style function definition is used. A warning is given
even if there is a previous prototype.
- at item -Wmissing-prototypes @r{(C only)}
+ at c APPLE LOCAL warn missing prototype 6261539
+ at item -Wmissing-prototypes
@opindex Wmissing-prototypes
Warn if a global function is defined without a previous prototype
declaration. This warning is issued even if the definition itself
@@ -3202,6 +3317,13 @@
alternate syntax when in pedantic ISO C99 mode. This is default.
To inhibit the warning messages, use @option{-Wno-variadic-macros}.
+ at item -Wvla
+ at opindex Wvla
+ at opindex Wno-vla
+Warn if variable length array is used in the code.
+ at option{-Wno-vla} will prevent the @option{-pedantic} warning of
+the variable length array.
+
@item -Wvolatile-register-var
@opindex Wvolatile-register-var
@opindex Wno-volatile-register-var
@@ -3404,6 +3526,78 @@
information about each symbol. This option only makes sense when
generating DWARF2 debugging information with @option{-gdwarf-2}.
+ at item -femit-struct-debug-baseonly
+Emit debug information for struct-like types
+only when the base name of the compilation source file
+matches the base name of file in which the struct was defined.
+
+This option substantially reduces the size of debugging information,
+but at significant potential loss in type information to the debugger.
+See @option{-femit-struct-debug-reduced} for a less aggressive option.
+See @option{-femit-struct-debug-detailed} for more detailed control.
+
+This option works only with DWARF 2.
+
+ at item -femit-struct-debug-reduced
+Emit debug information for struct-like types
+only when the base name of the compilation source file
+matches the base name of file in which the type was defined,
+unless the struct is a template or defined in a system header.
+
+This option significantly reduces the size of debugging information,
+with some potential loss in type information to the debugger.
+See @option{-femit-struct-debug-baseonly} for a more aggressive option.
+See @option{-femit-struct-debug-detailed} for more detailed control.
+
+This option works only with DWARF 2.
+
+ at item -femit-struct-debug-detailed at r{[}=@var{spec-list}@r{]}
+Specify the struct-like types
+for which the compiler will generate debug information.
+The intent is to reduce duplicate struct debug information
+between different object files within the same program.
+
+This option is a detailed version of
+ at option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
+which will serve for most needs.
+
+A specification has the syntax
+[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
+
+The optional first word limits the specification to
+structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
+A struct type is used directly when it is the type of a variable, member.
+Indirect uses arise through pointers to structs.
+That is, when use of an incomplete struct would be legal, the use is indirect.
+An example is
+ at samp{struct one direct; struct two * indirect;}.
+
+The optional second word limits the specification to
+ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
+Generic structs are a bit complicated to explain.
+For C++, these are non-explicit specializations of template classes,
+or non-template classes within the above.
+Other programming languages have generics,
+but @samp{-femit-struct-debug-detailed} does not yet implement them.
+
+The third word specifies the source files for those
+structs for which the compiler will emit debug information.
+The values @samp{none} and @samp{any} have the normal meaning.
+The value @samp{base} means that
+the base of name of the file in which the type declaration appears
+must match the base of the name of the main compilation file.
+In practice, this means that
+types declared in @file{foo.c} and @file{foo.h} will have debug information,
+but types declared in other header will not.
+The value @samp{sys} means those types satisfying @samp{base}
+or declared in system or compiler headers.
+
+You may need to experiment to determine the best settings for your application.
+
+The default is @samp{-femit-struct-debug-detailed=all}.
+
+This option works only with DWARF 2.
+
@cindex @command{prof}
@item -p
@opindex p
@@ -3520,7 +3714,9 @@
compiler. The file names for most of the dumps are made by appending a
pass number and a word to the @var{dumpname}. @var{dumpname} is generated
from the name of the output file, if explicitly specified and it is not
-an executable, otherwise it is the basename of the source file.
+an executable, otherwise it is the basename of the source file. These
+switches may have different effects when @option{-E} is used for
+preprocessing.
Most debug dumps can be enabled either passing a letter to the @option{-d}
option, or with a long @option{-fdump-rtl} switch; here are the possible
@@ -3655,7 +3851,7 @@
@opindex dM
@opindex fdump-rtl-mach
Dump after performing the machine dependent reorganization pass, to
- at file{@var{file}.155r.mach}.
+ at file{@var{file}.155r.mach} if that pass exists.
@item -dn
@itemx -fdump-rtl-rnreg
@@ -5614,6 +5810,11 @@
@item -fstack-protector-all
Like @option{-fstack-protector} except that all functions are protected.
+ at item -fstack-protector-strong
+Like @option{-fstack-protector} but includes additional functions to
+be protected --- those that have local array definitions, or have
+references to local frame addresses.
+
@item -fsection-anchors
@opindex fsection-anchors
Try to reduce the number of symbolic address calculations by using
@@ -9061,6 +9262,10 @@
MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)
@item k8-sse3, opteron-sse3, athlon64-sse3
Improved versions of k8, opteron and athlon64 with SSE3 instruction set support.
+ at item amdfam10, barcelona
+AMD Family 10h core based CPUs with x86-64 instruction set support. (This
+supersets MMX, SSE, SSE2, SSE3, SSE4A, 3dNOW!, enhanced 3dNOW!, ABM and 64-bit
+instruction set extensions.)
@item winchip-c6
IDT Winchip C6 CPU, dealt in same way as i486 with additional MMX instruction
set support.
@@ -9355,8 +9560,16 @@
@itemx -mno-sse3
@item -mssse3
@itemx -mno-ssse3
+ at item -msse4a
+ at item -mno-sse4a
@item -m3dnow
@itemx -mno-3dnow
+ at item -mpopcnt
+ at itemx -mno-popcnt
+ at item -mabm
+ at itemx -mno-abm
+ at item -maes
+ at itemx -mno-aes
@opindex mmmx
@opindex mno-mmx
@opindex msse
@@ -9364,10 +9577,10 @@
@opindex m3dnow
@opindex mno-3dnow
These switches enable or disable the use of instructions in the MMX,
-SSE, SSE2, SSE3, SSSE3 or 3DNow! extended instruction sets.
-These extensions are also available as built-in functions: see
- at ref{X86 Built-in Functions}, for details of the functions enabled and
-disabled by these switches.
+SSE, SSE2, SSE3, SSSE3, SSE4A, ABM, AES or 3DNow! extended
+instruction sets. These extensions are also available as built-in
+functions: see @ref{X86 Built-in Functions}, for details of the functions
+enabled and disabled by these switches.
To have SSE/SSE2 instructions generated automatically from floating-point
code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
@@ -13262,6 +13475,37 @@
cannot safely be called (perhaps signal handlers, if the profiling
routines generate output or allocate memory).
+ at item -finstrument-functions-exclude-file-list=@var{file}, at var{file}, at dots{}
+ at opindex finstrument-functions-exclude-file-list
+
+Set the list of functions that are excluded from instrumentation (see
+the description of @code{-finstrument-functions}). If the file that
+contains a function definition matches with one of @var{file}, then
+that function is not instrumented. The match is done on substrings:
+if the @var{file} parameter is a substring of the file name, it is
+considered to be a match.
+
+For example,
+ at code{-finstrument-functions-exclude-file-list=/bits/stl,include/sys}
+will exclude any inline function defined in files whose pathnames
+contain @code{/bits/stl} or @code{include/sys}.
+
+If, for some reason, you want to include letter @code{','} in one of
+ at var{sym}, write @code{'\,'}. For example,
+ at code{-finstrument-functions-exclude-file-list='\,\,tmp'}
+(note the single quote surrounding the option).
+
+ at item -finstrument-functions-exclude-function-list=@var{sym}, at var{sym}, at dots{}
+ at opindex finstrument-functions-exclude-function-list
+
+This is similar to @code{-finstrument-functions-exclude-file-list},
+but this option sets the list of function names to be excluded from
+instrumentation. The function name to be matched is its user-visible
+name, such as @code{vector<int> blah(const vector<int> &)}, not the
+internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
+match is done on substrings: if the @var{sym} parameter is a substring
+of the function name, it is considered to be a match.
+
@item -fstack-check
@opindex fstack-check
Generate code to verify that you do not go beyond the boundary of the
@@ -13839,3 +14083,4 @@
@xref{Protoize Caveats}, for more information on how to use
@code{protoize} successfully.
+
Modified: trunk/contrib/gcc/doc/libgcc.texi
===================================================================
--- trunk/contrib/gcc4/doc/libgcc.texi 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/libgcc.texi 2018-06-04 17:30:21 UTC (rev 10405)
@@ -212,6 +212,11 @@
These functions return the number of bits set in @var{a}.
@end deftypefn
+ at deftypefn {Runtime Function} int32_t __bswapsi2 (int32_t @var{a})
+ at deftypefnx {Runtime Function} int64_t __bswapdi2 (int64_t @var{a})
+These functions return the @var{a} byteswapped.
+ at end deftypefn
+
@node Soft float library routines
@section Routines for floating point emulation
@cindex soft float library
@@ -728,4 +733,3 @@
@deftypefn {Runtime Function} void __clear_cache (char *@var{beg}, char *@var{end})
This function clears the instruction cache between @var{beg} and @var{end}.
@end deftypefn
-
Modified: trunk/contrib/gcc/doc/rtl.texi
===================================================================
--- trunk/contrib/gcc4/doc/rtl.texi 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/rtl.texi 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2084,6 +2084,11 @@
Represents the number of 1-bits modulo 2 in @var{x}, represented as an
integer of mode @var{m}. The mode of @var{x} will usually be an integer
mode.
+
+ at findex bswap
+ at item (bswap:@var{m} @var{x})
+Represents the value @var{x} with the order of bytes reversed, carried out
+in mode @var{m}, which must be a fixed-point machine mode.
@end table
@node Comparisons
Modified: trunk/contrib/gcc/doc/tm.texi
===================================================================
--- trunk/contrib/gcc4/doc/tm.texi 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/doc/tm.texi 2018-06-04 17:30:21 UTC (rev 10405)
@@ -8953,6 +8953,12 @@
unit will not be COMDAT.
@end deftypefn
+ at deftypefn {Target Hook} bool TARGET_CXX_LIBRARY_RTTI_COMDAT (void)
+This hook returns true (the default) if the RTTI information for
+the basic types which is defined in the C++ runtime should always
+be COMDAT, false if it should not be COMDAT.
+ at end deftypefn
+
@deftypefn {Target Hook} bool TARGET_CXX_USE_AEABI_ATEXIT (void)
This hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI)
should be used to register static destructors when @option{-fuse-cxa-atexit}
Modified: trunk/contrib/gcc/dwarf2.h
===================================================================
--- trunk/contrib/gcc4/dwarf2.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/dwarf2.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -376,7 +376,14 @@
/* PGI (STMicroelectronics) extensions. */
DW_AT_PGI_lbase = 0x3a00,
DW_AT_PGI_soffset = 0x3a01,
- DW_AT_PGI_lstride = 0x3a02
+ /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to blocks */
+ DW_AT_PGI_lstride = 0x3a02,
+ /* APPLE LOCAL begin radar 6386976 */
+ DW_AT_APPLE_block = 0x3fe4,
+ /* APPLE LOCAL end radar 5811943 - Fix type of pointers to blocks */
+ DW_AT_APPLE_major_runtime_vers = 0x3fe5,
+ DW_AT_APPLE_runtime_class = 0x3fe6
+ /* APPLE LOCAL end radar 6386976 */
};
#define DW_AT_lo_user 0x2000 /* Implementation-defined range start. */
Modified: trunk/contrib/gcc/dwarf2out.c
===================================================================
--- trunk/contrib/gcc4/dwarf2out.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/dwarf2out.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -156,6 +156,7 @@
static GTY(()) section *debug_line_section;
static GTY(()) section *debug_loc_section;
static GTY(()) section *debug_pubnames_section;
+static GTY(()) section *debug_pubtypes_section;
static GTY(()) section *debug_str_section;
static GTY(()) section *debug_ranges_section;
static GTY(()) section *debug_frame_section;
@@ -2030,7 +2031,7 @@
/* We have no special eh_frame section. Put the information in
the data section and emit special labels to guide collect2. */
switch_to_section (data_section);
- label = get_file_function_name ('F');
+ label = get_file_function_name ("F");
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
targetm.asm_out.globalize_label (asm_out_file,
IDENTIFIER_POINTER (label));
@@ -2192,6 +2193,9 @@
specialization doesn't. */
if (TARGET_USES_WEAK_UNWIND_INFO
&& ! flag_asynchronous_unwind_tables
+/* APPLE LOCAL begin for-fsf-4_4 5480287 */ \
+ && flag_exceptions
+/* APPLE LOCAL end for-fsf-4_4 5480287 */ \
&& for_eh)
for (i = 0; i < fde_table_in_use; i++)
if ((fde_table[i].nothrow || fde_table[i].all_throwers_are_sibcalls)
@@ -3759,6 +3763,9 @@
}
pubname_entry;
+DEF_VEC_O(pubname_entry);
+DEF_VEC_ALLOC_O(pubname_entry, gc);
+
struct dw_ranges_struct GTY(())
{
int block_num;
@@ -3940,18 +3947,12 @@
/* A pointer to the base of a table that contains a list of publicly
accessible names. */
-static GTY ((length ("pubname_table_allocated"))) pubname_ref pubname_table;
+static GTY (()) VEC (pubname_entry, gc) * pubname_table;
-/* Number of elements currently allocated for pubname_table. */
-static GTY(()) unsigned pubname_table_allocated;
+/* A pointer to the base of a table that contains a list of publicly
+ accessible types. */
+static GTY (()) VEC (pubname_entry, gc) * pubtype_table;
-/* Number of elements in pubname_table currently in use. */
-static GTY(()) unsigned pubname_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the
- pubname_table. */
-#define PUBNAME_TABLE_INCREMENT 64
-
/* Array of dies for which we should generate .debug_arange info. */
static GTY((length ("arange_table_allocated"))) dw_die_ref *arange_table;
@@ -4115,7 +4116,7 @@
static void mark_dies (dw_die_ref);
static void unmark_dies (dw_die_ref);
static void unmark_all_dies (dw_die_ref);
-static unsigned long size_of_pubnames (void);
+static unsigned long size_of_pubnames (VEC (pubname_entry,gc) *);
static unsigned long size_of_aranges (void);
static enum dwarf_form value_format (dw_attr_ref);
static void output_value_format (dw_attr_ref);
@@ -4126,7 +4127,8 @@
static void output_comp_unit (dw_die_ref, int);
static const char *dwarf2_name (tree, int);
static void add_pubname (tree, dw_die_ref);
-static void output_pubnames (void);
+static void add_pubtype (tree, dw_die_ref);
+static void output_pubnames (VEC (pubname_entry,gc) *);
static void add_arange (tree, dw_die_ref);
static void output_aranges (void);
static unsigned int add_ranges (tree);
@@ -4215,7 +4217,8 @@
static dw_die_ref gen_compile_unit_die (const char *);
static void gen_inheritance_die (tree, tree, dw_die_ref);
static void gen_member_die (tree, dw_die_ref);
-static void gen_struct_or_union_type_die (tree, dw_die_ref);
+static void gen_struct_or_union_type_die (tree, dw_die_ref,
+ enum debug_info_usage);
static void gen_subroutine_type_die (tree, dw_die_ref);
static void gen_typedef_die (tree, dw_die_ref);
static void gen_type_die (tree, dw_die_ref);
@@ -4728,6 +4731,11 @@
case DW_AT_VMS_rtnbeg_pd_address:
return "DW_AT_VMS_rtnbeg_pd_address";
+ /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to Blocks */
+ case DW_AT_APPLE_block:
+ return "DW_AT_APPLE_block";
+ /* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
+
default:
return "DW_AT_<unknown>";
}
@@ -5740,11 +5748,11 @@
unsigned ix;
print_spaces (outfile);
- fprintf (outfile, "DIE %4lu: %s\n",
+ fprintf (outfile, "DIE %4ld: %s\n",
die->die_offset, dwarf_tag_name (die->die_tag));
print_spaces (outfile);
fprintf (outfile, " abbrev id: %lu", die->die_abbrev);
- fprintf (outfile, " offset: %lu\n", die->die_offset);
+ fprintf (outfile, " offset: %ld\n", die->die_offset);
for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
{
@@ -5792,7 +5800,7 @@
if (AT_ref (a)->die_symbol)
fprintf (outfile, "die -> label: %s", AT_ref (a)->die_symbol);
else
- fprintf (outfile, "die -> %lu", AT_ref (a)->die_offset);
+ fprintf (outfile, "die -> %ld", AT_ref (a)->die_offset);
}
else
fprintf (outfile, "die -> <null>");
@@ -6749,21 +6757,22 @@
unmark_all_dies (AT_ref (a));
}
-/* Return the size of the .debug_pubnames table generated for the
- compilation unit. */
+/* Return the size of the .debug_pubnames or .debug_pubtypes table
+ generated for the compilation unit. */
static unsigned long
-size_of_pubnames (void)
+size_of_pubnames (VEC (pubname_entry, gc) * names)
{
unsigned long size;
unsigned i;
+ pubname_ref p;
size = DWARF_PUBNAMES_HEADER_SIZE;
- for (i = 0; i < pubname_table_in_use; i++)
- {
- pubname_ref p = &pubname_table[i];
- size += DWARF_OFFSET_SIZE + strlen (p->name) + 1;
- }
+ for (i = 0; VEC_iterate (pubname_entry, names, i, p); i++)
+ if (names != pubtype_table
+ || p->die->die_offset != 0
+ || !flag_eliminate_unused_debug_types)
+ size += strlen (p->name) + DWARF_OFFSET_SIZE + 1;
size += DWARF_OFFSET_SIZE;
return size;
@@ -7062,7 +7071,8 @@
output_die_symbol (die);
dw2_asm_output_data_uleb128 (die->die_abbrev, "(DIE (0x%lx) %s)",
- die->die_offset, dwarf_tag_name (die->die_tag));
+ (unsigned long)die->die_offset,
+ dwarf_tag_name (die->die_tag));
for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
{
@@ -7244,7 +7254,7 @@
/* Add null byte to terminate sibling list. */
if (die->die_child != NULL)
dw2_asm_output_data (1, 0, "end of children of DIE 0x%lx",
- die->die_offset);
+ (unsigned long) die->die_offset);
}
/* Output the compilation unit that appears at the beginning of the
@@ -7330,41 +7340,73 @@
static void
add_pubname (tree decl, dw_die_ref die)
{
- pubname_ref p;
+ pubname_entry e;
if (! TREE_PUBLIC (decl))
return;
- if (pubname_table_in_use == pubname_table_allocated)
+ e.die = die;
+ e.name = xstrdup (dwarf2_name (decl, 1));
+ VEC_safe_push (pubname_entry, gc, pubname_table, &e);
+}
+
+/* Add a new entry to .debug_pubtypes if appropriate. */
+
+static void
+add_pubtype (tree decl, dw_die_ref die)
+{
+ pubname_entry e;
+
+ e.name = NULL;
+ if ((TREE_PUBLIC (decl)
+ || die->die_parent == comp_unit_die)
+ && (die->die_tag == DW_TAG_typedef || COMPLETE_TYPE_P (decl)))
{
- pubname_table_allocated += PUBNAME_TABLE_INCREMENT;
- pubname_table
- = ggc_realloc (pubname_table,
- (pubname_table_allocated * sizeof (pubname_entry)));
- memset (pubname_table + pubname_table_in_use, 0,
- PUBNAME_TABLE_INCREMENT * sizeof (pubname_entry));
+ e.die = die;
+ if (TYPE_P (decl))
+ {
+ if (TYPE_NAME (decl))
+ {
+ if (TREE_CODE (TYPE_NAME (decl)) == IDENTIFIER_NODE)
+ e.name = xstrdup ((const char *) IDENTIFIER_POINTER
+ (TYPE_NAME (decl)));
+ else if (TREE_CODE (TYPE_NAME (decl)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (decl)))
+ e.name = xstrdup ((const char *) IDENTIFIER_POINTER
+ (DECL_NAME (TYPE_NAME (decl))));
+ else
+ e.name = xstrdup ((const char *) get_AT_string (die, DW_AT_name));
+ }
+ }
+ else
+ e.name = xstrdup (dwarf2_name (decl, 1));
+
+ /* If we don't have a name for the type, there's no point in adding
+ it to the table. */
+ if (e.name && e.name[0] != '\0')
+ VEC_safe_push (pubname_entry, gc, pubtype_table, &e);
}
-
- p = &pubname_table[pubname_table_in_use++];
- p->die = die;
- p->name = xstrdup (dwarf2_name (decl, 1));
}
/* Output the public names table used to speed up access to externally
- visible names. For now, only generate entries for externally
- visible procedures. */
+ visible names; or the public types table used to find type definitions. */
static void
-output_pubnames (void)
+output_pubnames (VEC (pubname_entry, gc) * names)
{
unsigned i;
- unsigned long pubnames_length = size_of_pubnames ();
+ unsigned long pubnames_length = size_of_pubnames (names);
+ pubname_ref pub;
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating 64-bit DWARF extension");
- dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
- "Length of Public Names Info");
+ if (names == pubname_table)
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
+ "Length of Public Names Info");
+ else
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
+ "Length of Public Type Names Info");
dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
debug_info_section,
@@ -7372,17 +7414,21 @@
dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset,
"Compilation Unit Length");
- for (i = 0; i < pubname_table_in_use; i++)
+ for (i = 0; VEC_iterate (pubname_entry, names, i, pub); i++)
{
- pubname_ref pub = &pubname_table[i];
+ /* We shouldn't see pubnames for DIEs outside of the main CU. */
+ if (names == pubname_table)
+ gcc_assert (pub->die->die_mark);
- /* We shouldn't see pubnames for DIEs outside of the main CU. */
- gcc_assert (pub->die->die_mark);
+ if (names != pubtype_table
+ || pub->die->die_offset != 0
+ || !flag_eliminate_unused_debug_types)
+ {
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, pub->die->die_offset,
+ "DIE offset");
- dw2_asm_output_data (DWARF_OFFSET_SIZE, pub->die->die_offset,
- "DIE offset");
-
- dw2_asm_output_nstring (pub->name, -1, "external name");
+ dw2_asm_output_nstring (pub->name, -1, "external name");
+ }
}
dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, NULL);
@@ -8257,6 +8303,8 @@
case ERROR_MARK:
return error_mark_node;
+ /* APPLE LOCAL radar 5732232 - blocks */
+ case BLOCK_POINTER_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
return type_main_variant (root_type (TREE_TYPE (type)));
@@ -8289,6 +8337,8 @@
case ENUMERAL_TYPE:
case FUNCTION_TYPE:
case METHOD_TYPE:
+ /* APPLE LOCAL radar 5732232 - blocks */
+ case BLOCK_POINTER_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
@@ -8476,7 +8526,8 @@
mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die, type);
sub_die = modified_type_die (type, 0, 0, context_die);
}
- else if (code == POINTER_TYPE)
+ /* APPLE LOCAL radar 5732232 - blocks */
+ else if (code == POINTER_TYPE || code == BLOCK_POINTER_TYPE)
{
mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
@@ -11129,6 +11180,19 @@
enum tree_code code = TREE_CODE (type);
dw_die_ref type_die = NULL;
+/* APPLE LOCAL begin radar 5847213 */
+ /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to blocks */
+ /* APPLE LOCAL - radar 6113240 */
+ /* APPLE LOCAL begin radar 6300081 */
+ if (code == BLOCK_POINTER_TYPE && generic_block_literal_struct_type)
+ {
+ type = build_pointer_type (generic_block_literal_struct_type);
+ code = TREE_CODE (type);
+ }
+ /* APPLE LOCAL end radar 6300081 */
+ /* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
+/* APPLE LOCAL end radar 5847213 */
+
/* ??? If this type is an unnamed subrange type of an integral or
floating-point type, use the inner type. This is because we have no
support for unnamed types in base_type_die. This can happen if this is
@@ -11296,6 +11360,9 @@
#endif
add_type_attribute (array_die, element_type, 0, 0, context_die);
+
+ if (get_AT (array_die, DW_AT_name))
+ add_pubtype (type, array_die);
}
#if 0
@@ -11431,6 +11498,9 @@
else
add_AT_flag (type_die, DW_AT_declaration, 1);
+ if (get_AT (type_die, DW_AT_name))
+ add_pubtype (type, type_die);
+
return type_die;
}
@@ -12473,7 +12543,8 @@
member DIEs needed by later specification DIEs. */
static void
-gen_struct_or_union_type_die (tree type, dw_die_ref context_die)
+gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
+ enum debug_info_usage usage)
{
dw_die_ref type_die = lookup_type_die (type);
dw_die_ref scope_die = 0;
@@ -12482,6 +12553,7 @@
&& (! TYPE_STUB_DECL (type)
|| ! TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type))));
int ns_decl = (context_die && context_die->die_tag == DW_TAG_namespace);
+ complete = complete && should_emit_struct_debug (type, usage);
if (type_die && ! complete)
return;
@@ -12506,7 +12578,11 @@
add_AT_specification (type_die, old_die);
else
add_name_attribute (type_die, type_tag (type));
- }
+ /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to Blocks */
+ if (TYPE_BLOCK_IMPL_STRUCT (type))
+ add_AT_flag (type_die, DW_AT_APPLE_block, 1);
+ /* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
+ }
else
remove_AT (type_die, DW_AT_declaration);
@@ -12549,6 +12625,9 @@
&& ! decl_function_context (TYPE_STUB_DECL (type)))
VEC_safe_push (tree, gc, incomplete_types, type);
}
+
+ if (get_AT (type_die, DW_AT_name))
+ add_pubtype (type, type_die);
}
/* Generate a DIE for a subroutine _type_. */
@@ -12565,6 +12644,9 @@
add_prototyped_attribute (subr_die, type);
add_type_attribute (subr_die, return_type, 0, 0, context_die);
gen_formal_types_die (type, subr_die);
+
+ if (get_AT (subr_die, DW_AT_name))
+ add_pubtype (type, subr_die);
}
/* Generate a DIE for a type definition. */
@@ -12604,12 +12686,16 @@
if (DECL_ABSTRACT (decl))
equate_decl_number_to_die (decl, type_die);
+
+ if (get_AT (type_die, DW_AT_name))
+ add_pubtype (decl, type_die);
}
/* Generate a type description DIE. */
static void
-gen_type_die (tree type, dw_die_ref context_die)
+gen_type_die_with_usage (tree type, dw_die_ref context_die,
+ enum debug_info_usage usage)
{
int need_pop;
@@ -12645,7 +12731,8 @@
{
case ERROR_MARK:
break;
-
+ /* APPLE LOCAL radar 5732232 - blocks */
+ case BLOCK_POINTER_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
/* We must set TREE_ASM_WRITTEN in case this is a recursive type. This
@@ -12657,16 +12744,19 @@
/* For these types, all that is required is that we output a DIE (or a
set of DIEs) to represent the "basis" type. */
- gen_type_die (TREE_TYPE (type), context_die);
+ gen_type_die_with_usage (TREE_TYPE (type), context_die,
+ DINFO_USAGE_IND_USE);
break;
case OFFSET_TYPE:
/* This code is used for C++ pointer-to-data-member types.
Output a description of the relevant class type. */
- gen_type_die (TYPE_OFFSET_BASETYPE (type), context_die);
+ gen_type_die_with_usage (TYPE_OFFSET_BASETYPE (type), context_die,
+ DINFO_USAGE_IND_USE);
/* Output a description of the type of the object pointed to. */
- gen_type_die (TREE_TYPE (type), context_die);
+ gen_type_die_with_usage (TREE_TYPE (type), context_die,
+ DINFO_USAGE_IND_USE);
/* Now output a DIE to represent this pointer-to-data-member type
itself. */
@@ -12675,13 +12765,15 @@
case FUNCTION_TYPE:
/* Force out return type (in case it wasn't forced out already). */
- gen_type_die (TREE_TYPE (type), context_die);
+ gen_type_die_with_usage (TREE_TYPE (type), context_die,
+ DINFO_USAGE_DIR_USE);
gen_subroutine_type_die (type, context_die);
break;
case METHOD_TYPE:
/* Force out return type (in case it wasn't forced out already). */
- gen_type_die (TREE_TYPE (type), context_die);
+ gen_type_die_with_usage (TREE_TYPE (type), context_die,
+ DINFO_USAGE_DIR_USE);
gen_subroutine_type_die (type, context_die);
break;
@@ -12707,7 +12799,7 @@
&& AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
&& ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
{
- gen_type_die (TYPE_CONTEXT (type), context_die);
+ gen_type_die_with_usage (TYPE_CONTEXT (type), context_die, usage);
if (TREE_ASM_WRITTEN (type))
return;
@@ -12731,7 +12823,7 @@
gen_enumeration_type_die (type, context_die);
}
else
- gen_struct_or_union_type_die (type, context_die);
+ gen_struct_or_union_type_die (type, context_die, usage);
if (need_pop)
pop_decl_scope ();
@@ -12760,6 +12852,12 @@
TREE_ASM_WRITTEN (type) = 1;
}
+static void
+gen_type_die (tree type, dw_die_ref context_die)
+{
+ gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE);
+}
+
/* Generate a DIE for a tagged type instantiation. */
static void
@@ -13357,7 +13455,11 @@
if (!context)
scope_die = comp_unit_die;
else if (TYPE_P (context))
+ {
+ if (!should_emit_struct_debug (context, DINFO_USAGE_DIR_USE))
+ return;
scope_die = force_type_die (context);
+ }
else
scope_die = force_decl_die (context);
@@ -13383,7 +13485,12 @@
if (TYPE_CONTEXT (type))
if (TYPE_P (TYPE_CONTEXT (type)))
+ {
+ if (!should_emit_struct_debug (TYPE_CONTEXT (type),
+ DINFO_USAGE_DIR_USE))
+ return;
type_context_die = force_type_die (TYPE_CONTEXT (type));
+ }
else
type_context_die = force_decl_die (TYPE_CONTEXT (type));
else
@@ -13907,6 +14014,10 @@
/* Zero-th entry is allocated, but unused. */
line_info_table_in_use = 1;
+ /* Allocate the pubtypes and pubnames vectors. */
+ pubname_table = VEC_alloc (pubname_entry, gc, 32);
+ pubtype_table = VEC_alloc (pubname_entry, gc, 32);
+
/* Generate the initial DIE for the .debug section. Note that the (string)
value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
will (typically) be a relative pathname and that this pathname should be
@@ -13933,6 +14044,10 @@
SECTION_DEBUG, NULL);
debug_pubnames_section = get_section (DEBUG_PUBNAMES_SECTION,
SECTION_DEBUG, NULL);
+#ifdef DEBUG_PUBTYPES_SECTION
+ debug_pubtypes_section = get_section (DEBUG_PUBTYPES_SECTION,
+ SECTION_DEBUG, NULL);
+#endif
debug_str_section = get_section (DEBUG_STR_SECTION,
DEBUG_STR_SECTION_FLAGS, NULL);
debug_ranges_section = get_section (DEBUG_RANGES_SECTION,
@@ -14215,6 +14330,7 @@
{
unsigned int i;
limbo_die_node *node;
+ pubname_ref pub;
#if ENABLE_ASSERT_CHECKING
/* All the marks should already be clear. */
@@ -14230,8 +14346,8 @@
/* Also set the mark on nodes referenced from the
pubname_table or arange_table. */
- for (i = 0; i < pubname_table_in_use; i++)
- prune_unused_types_mark (pubname_table[i].die, 1);
+ for (i = 0; VEC_iterate (pubname_entry, pubname_table, i, pub); i++)
+ prune_unused_types_mark (pub->die, 1);
for (i = 0; i < arange_table_in_use; i++)
prune_unused_types_mark (arange_table[i], 1);
@@ -14412,12 +14528,21 @@
output_abbrev_section ();
/* Output public names table if necessary. */
- if (pubname_table_in_use)
+ if (!VEC_empty (pubname_entry, pubname_table))
{
switch_to_section (debug_pubnames_section);
- output_pubnames ();
+ output_pubnames (pubname_table);
}
+#ifdef DEBUG_PUBTYPES_SECTION
+ /* Output public types table if necessary. */
+ if (!VEC_empty (pubname_entry, pubtype_table))
+ {
+ switch_to_section (debug_pubtypes_section);
+ output_pubnames (pubtype_table);
+ }
+#endif
+
/* Output the address range information. We only put functions in the arange
table, so don't write it out if we don't have any. */
if (fde_table_in_use)
Modified: trunk/contrib/gcc/emit-rtl.c
===================================================================
--- trunk/contrib/gcc4/emit-rtl.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/emit-rtl.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2062,7 +2062,9 @@
gen_label_rtx (void)
{
return gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX, NULL_RTX,
- NULL, label_num++, NULL);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ NULL, label_num++, NULL, 0);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
/* For procedure integration. */
Modified: trunk/contrib/gcc/expmed.c
===================================================================
--- trunk/contrib/gcc4/expmed.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/expmed.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2616,16 +2616,12 @@
do_alg_addsub_t_m2:
for (w = 1; (w & t) != 0; w <<= 1)
;
- /* If T was -1, then W will be zero after the loop. This is another
- case where T ends with ...111. Handling this with (T + 1) and
- subtract 1 produces slightly better code and results in algorithm
- selection much faster than treating it like the ...0111 case
- below. */
- if (w == 0
- || (w > 2
+ /* APPLE LOCAL begin 7744816 DImode multiply by 0xffffffffULL */
+ if (w > 2
/* Reject the case where t is 3.
Thus we prefer addition in that case. */
- && t != 3))
+ && t != 3)
+ /* APPLE LOCAL end 7744816 DImode multiply by 0xffffffffULL */
{
/* T ends with ...111. Multiply by (T + 1) and subtract 1. */
Modified: trunk/contrib/gcc/expr.c
===================================================================
--- trunk/contrib/gcc4/expr.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/expr.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -361,6 +361,8 @@
gcc_assert (to_real == from_real);
+ gcc_assert (to_mode != BLKmode);
+ gcc_assert (from_mode != BLKmode);
/* If the source and destination are already the same, then there's
nothing to do. */
@@ -415,7 +417,7 @@
!= GET_MODE_PRECISION (to_mode))
|| (DECIMAL_FLOAT_MODE_P (from_mode)
!= DECIMAL_FLOAT_MODE_P (to_mode)));
-
+
if (GET_MODE_PRECISION (from_mode) == GET_MODE_PRECISION (to_mode))
/* Conversion between decimal float and binary float, same size. */
tab = DECIMAL_FLOAT_MODE_P (from_mode) ? trunc_optab : sext_optab;
@@ -2135,7 +2137,7 @@
use_reg (rtx *call_fusage, rtx reg)
{
gcc_assert (REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER);
-
+
*call_fusage
= gen_rtx_EXPR_LIST (VOIDmode,
gen_rtx_USE (VOIDmode, reg), *call_fusage);
@@ -2682,7 +2684,7 @@
pred = insn_data[(int) code].operand[1].predicate;
if (pred != 0 && ! (*pred) (opsize, mode))
opsize = copy_to_mode_reg (mode, opsize);
-
+
opchar = val;
char_mode = insn_data[(int) code].operand[2].mode;
if (char_mode != VOIDmode)
@@ -3140,9 +3142,9 @@
rtx seq, inner;
bool need_clobber;
int i;
-
+
gcc_assert (GET_MODE_SIZE (mode) >= UNITS_PER_WORD);
-
+
/* If X is a push on the stack, do the push now and replace
X with a reference to the stack pointer. */
if (push_operand (x, mode))
@@ -4440,6 +4442,11 @@
temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
emit_move_insn (target, temp);
}
+ else if (GET_MODE (target) == BLKmode)
+ emit_block_move (target, temp, expr_size (exp),
+ (call_param_p
+ ? BLOCK_OP_CALL_PARM
+ : BLOCK_OP_NORMAL));
else
convert_move (target, temp, unsignedp);
}
@@ -4571,7 +4578,7 @@
case CONSTRUCTOR:
{
HOST_WIDE_INT nz = 0, ic = 0;
-
+
bool const_elt_p
= categorize_ctor_elements_1 (value, &nz, &ic, p_must_clear);
@@ -4648,7 +4655,7 @@
largest element. Which would avoid comparing the size of the
initialized element against any tail padding in the union.
Doesn't seem worth the effort... */
- if (simple_cst_equal (TYPE_SIZE (TREE_TYPE (ctor)),
+ if (simple_cst_equal (TYPE_SIZE (TREE_TYPE (ctor)),
TYPE_SIZE (init_sub_type)) == 1)
{
/* And now we have to find out if the element itself is fully
@@ -4763,6 +4770,8 @@
case ENUMERAL_TYPE:
case BOOLEAN_TYPE:
case POINTER_TYPE:
+ /* APPLE LOCAL radar 5732232 - blocks */
+ case BLOCK_POINTER_TYPE:
case OFFSET_TYPE:
case REFERENCE_TYPE:
return 1;
@@ -4944,24 +4953,24 @@
HOST_WIDE_INT bitpos = 0;
tree offset;
rtx to_rtx = target;
-
+
/* Just ignore missing fields. We cleared the whole
structure, above, if any fields are missing. */
if (field == 0)
continue;
-
+
if (cleared && initializer_zerop (value))
continue;
-
+
if (host_integerp (DECL_SIZE (field), 1))
bitsize = tree_low_cst (DECL_SIZE (field), 1);
else
bitsize = -1;
-
+
mode = DECL_MODE (field);
if (DECL_BIT_FIELD (field))
mode = VOIDmode;
-
+
offset = DECL_FIELD_OFFSET (field);
if (host_integerp (offset, 0)
&& host_integerp (bit_position (field), 0))
@@ -4971,11 +4980,11 @@
}
else
bitpos = tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 0);
-
+
if (offset)
{
rtx offset_rtx;
-
+
offset
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (offset,
make_tree (TREE_TYPE (exp),
@@ -4983,7 +4992,7 @@
offset_rtx = expand_normal (offset);
gcc_assert (MEM_P (to_rtx));
-
+
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (offset_rtx) != Pmode)
offset_rtx = convert_to_mode (Pmode, offset_rtx, 0);
@@ -5011,7 +5020,7 @@
&& bitpos + BITS_PER_WORD <= exp_size * BITS_PER_UNIT)
{
tree type = TREE_TYPE (value);
-
+
if (TYPE_PRECISION (type) < BITS_PER_WORD)
{
type = lang_hooks.types.type_for_size
@@ -5018,7 +5027,7 @@
(BITS_PER_WORD, TYPE_UNSIGNED (type));
value = fold_convert (type, value);
}
-
+
if (BYTES_BIG_ENDIAN)
value
= fold_build2 (LSHIFT_EXPR, type, value,
@@ -5035,7 +5044,7 @@
to_rtx = copy_rtx (to_rtx);
MEM_KEEP_ALIAS_SET_P (to_rtx) = 1;
}
-
+
store_constructor_field (to_rtx, bitsize, bitpos, mode,
value, type, cleared,
get_alias_set (TREE_TYPE (field)));
@@ -5079,7 +5088,7 @@
tree index, value;
HOST_WIDE_INT count = 0, zero_count = 0;
need_to_clear = ! const_bounds_p;
-
+
/* This loop is a more accurate version of the loop in
mostly_zeros_p (it handles RANGE_EXPR in an index). It
is also needed to check for missing elements. */
@@ -5089,12 +5098,12 @@
if (need_to_clear)
break;
-
+
if (index != NULL_TREE && TREE_CODE (index) == RANGE_EXPR)
{
tree lo_index = TREE_OPERAND (index, 0);
tree hi_index = TREE_OPERAND (index, 1);
-
+
if (! host_integerp (lo_index, 1)
|| ! host_integerp (hi_index, 1))
{
@@ -5101,18 +5110,18 @@
need_to_clear = 1;
break;
}
-
+
this_node_count = (tree_low_cst (hi_index, 1)
- tree_low_cst (lo_index, 1) + 1);
}
else
this_node_count = 1;
-
+
count += this_node_count;
if (mostly_zeros_p (value))
zero_count += this_node_count;
}
-
+
/* Clear the entire array first if there are any missing
elements, or if the incidence of zero elements is >=
75%. */
@@ -5121,7 +5130,7 @@
|| 4 * zero_count >= 3 * count))
need_to_clear = 1;
}
-
+
if (need_to_clear && size > 0)
{
if (REG_P (target))
@@ -5145,10 +5154,10 @@
HOST_WIDE_INT bitpos;
int unsignedp;
rtx xtarget = target;
-
+
if (cleared && initializer_zerop (value))
continue;
-
+
unsignedp = TYPE_UNSIGNED (elttype);
mode = TYPE_MODE (elttype);
if (mode == BLKmode)
@@ -5157,7 +5166,7 @@
: -1);
else
bitsize = GET_MODE_BITSIZE (mode);
-
+
if (index != NULL_TREE && TREE_CODE (index) == RANGE_EXPR)
{
tree lo_index = TREE_OPERAND (index, 0);
@@ -5165,7 +5174,7 @@
rtx index_r, pos_rtx;
HOST_WIDE_INT lo, hi, count;
tree position;
-
+
/* If the range is constant and "small", unroll the loop. */
if (const_bounds_p
&& host_integerp (lo_index, 0)
@@ -5183,7 +5192,7 @@
for (; lo <= hi; lo++)
{
bitpos = lo * tree_low_cst (TYPE_SIZE (elttype), 0);
-
+
if (MEM_P (target)
&& !MEM_KEEP_ALIAS_SET_P (target)
&& TREE_CODE (type) == ARRAY_TYPE
@@ -5192,7 +5201,7 @@
target = copy_rtx (target);
MEM_KEEP_ALIAS_SET_P (target) = 1;
}
-
+
store_constructor_field
(target, bitsize, bitpos, mode, value, type, cleared,
get_alias_set (elttype));
@@ -5203,18 +5212,18 @@
rtx loop_start = gen_label_rtx ();
rtx loop_end = gen_label_rtx ();
tree exit_cond;
-
+
expand_normal (hi_index);
unsignedp = TYPE_UNSIGNED (domain);
-
+
index = build_decl (VAR_DECL, NULL_TREE, domain);
-
+
index_r
= gen_reg_rtx (promote_mode (domain, DECL_MODE (index),
&unsignedp, 0));
SET_DECL_RTL (index, index_r);
store_expr (lo_index, index_r, 0);
-
+
/* Build the head of the loop. */
do_pending_stack_adjust ();
emit_label (loop_start);
@@ -5231,7 +5240,7 @@
size_binop (MULT_EXPR, position,
fold_convert (ssizetype,
TYPE_SIZE_UNIT (elttype)));
-
+
pos_rtx = expand_normal (position);
xtarget = offset_address (target, pos_rtx,
highest_pow2_factor (position));
@@ -5246,15 +5255,15 @@
exit_cond = build2 (LT_EXPR, integer_type_node,
index, hi_index);
jumpif (exit_cond, loop_end);
-
+
/* Update the loop counter, and jump to the head of
the loop. */
expand_assignment (index,
build2 (PLUS_EXPR, TREE_TYPE (index),
index, integer_one_node));
-
+
emit_jump (loop_start);
-
+
/* Build the end of the loop. */
emit_label (loop_end);
}
@@ -5263,10 +5272,10 @@
|| ! host_integerp (TYPE_SIZE (elttype), 1))
{
tree position;
-
+
if (index == 0)
index = ssize_int (1);
-
+
if (minelt)
index = fold_convert (ssizetype,
fold_build2 (MINUS_EXPR,
@@ -5273,7 +5282,7 @@
TREE_TYPE (index),
index,
TYPE_MIN_VALUE (domain)));
-
+
position =
size_binop (MULT_EXPR, index,
fold_convert (ssizetype,
@@ -5291,7 +5300,7 @@
* tree_low_cst (TYPE_SIZE (elttype), 1));
else
bitpos = (i * tree_low_cst (TYPE_SIZE (elttype), 1));
-
+
if (MEM_P (target) && !MEM_KEEP_ALIAS_SET_P (target)
&& TREE_CODE (type) == ARRAY_TYPE
&& TYPE_NONALIASED_COMPONENT (type))
@@ -5320,25 +5329,25 @@
HOST_WIDE_INT bitpos;
rtvec vector = NULL;
unsigned n_elts;
-
+
gcc_assert (eltmode != BLKmode);
-
+
n_elts = TYPE_VECTOR_SUBPARTS (type);
if (REG_P (target) && VECTOR_MODE_P (GET_MODE (target)))
{
enum machine_mode mode = GET_MODE (target);
-
+
icode = (int) vec_init_optab->handlers[mode].insn_code;
if (icode != CODE_FOR_nothing)
{
unsigned int i;
-
+
vector = rtvec_alloc (n_elts);
for (i = 0; i < n_elts; i++)
RTVEC_ELT (vector, i) = CONST0_RTX (GET_MODE_INNER (mode));
}
}
-
+
/* If the constructor has fewer elements than the vector,
clear the whole array first. Similarly if this is static
constructor of a non-BLKmode object. */
@@ -5350,7 +5359,7 @@
{
unsigned HOST_WIDE_INT count = 0, zero_count = 0;
tree value;
-
+
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value)
{
int n_elts_here = tree_low_cst
@@ -5357,7 +5366,7 @@
(int_const_binop (TRUNC_DIV_EXPR,
TYPE_SIZE (TREE_TYPE (value)),
TYPE_SIZE (elttype), 0), 1);
-
+
count += n_elts_here;
if (mostly_zeros_p (value))
zero_count += n_elts_here;
@@ -5367,7 +5376,7 @@
or if the incidence of zero elements is >= 75%. */
need_to_clear = (count < n_elts || 4 * zero_count >= 3 * count);
}
-
+
if (need_to_clear && size > 0 && !vector)
{
if (REG_P (target))
@@ -5376,7 +5385,7 @@
clear_storage (target, GEN_INT (size), BLOCK_OP_NORMAL);
cleared = 1;
}
-
+
/* Inform later passes that the old value is dead. */
if (!cleared && !vector && REG_P (target))
emit_move_insn (target, CONST0_RTX (GET_MODE (target)));
@@ -5389,16 +5398,16 @@
{
HOST_WIDE_INT eltpos;
tree value = ce->value;
-
+
bitsize = tree_low_cst (TYPE_SIZE (TREE_TYPE (value)), 1);
if (cleared && initializer_zerop (value))
continue;
-
+
if (ce->index)
eltpos = tree_low_cst (ce->index, 1);
else
eltpos = i;
-
+
if (vector)
{
/* Vector CONSTRUCTORs should only be built from smaller
@@ -5419,7 +5428,7 @@
cleared, get_alias_set (elttype));
}
}
-
+
if (vector)
emit_insn (GEN_FCN (icode)
(target,
@@ -5426,7 +5435,7 @@
gen_rtx_PARALLEL (GET_MODE (target), vector)));
break;
}
-
+
default:
gcc_unreachable ();
}
@@ -6965,7 +6974,7 @@
&& GET_MODE (decl_rtl) != DECL_MODE (exp))
{
enum machine_mode pmode;
-
+
/* Get the signedness used for this variable. Ensure we get the
same mode we got when the variable was declared. */
pmode = promote_mode (type, DECL_MODE (exp), &unsignedp,
@@ -7336,19 +7345,19 @@
tree index1 = index;
tree low_bound = array_ref_low_bound (exp);
index1 = fold_convert (sizetype, TREE_OPERAND (exp, 1));
-
+
/* Optimize the special-case of a zero lower bound.
-
+
We convert the low_bound to sizetype to avoid some problems
with constant folding. (E.g. suppose the lower bound is 1,
and its mode is QI. Without the conversion,l (ARRAY
+(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
+INDEX), which becomes (ARRAY+255+INDEX). Opps!) */
-
+
if (! integer_zerop (low_bound))
index1 = size_diffop (index1, fold_convert (sizetype,
low_bound));
-
+
if (0 > compare_tree_int (index1,
TREE_STRING_LENGTH (init)))
{
@@ -7751,7 +7760,7 @@
else
{
gcc_assert (REG_P (target));
-
+
/* Store this field into a union of the proper type. */
store_field (target,
MIN ((int_size_in_bytes (TREE_TYPE
@@ -7837,9 +7846,9 @@
other. */
else if (SCALAR_INT_MODE_P (GET_MODE (op0))
&& SCALAR_INT_MODE_P (TYPE_MODE (type)))
- op0 = convert_modes (TYPE_MODE (type), GET_MODE (op0), op0,
+ op0 = convert_modes (TYPE_MODE (type), GET_MODE (op0), op0,
TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
- /* As a last resort, spill op0 to memory, and reload it in a
+ /* As a last resort, spill op0 to memory, and reload it in a
different mode. */
else if (!MEM_P (op0))
{
@@ -8742,7 +8751,7 @@
case REALIGN_LOAD_EXPR:
{
- tree oprnd0 = TREE_OPERAND (exp, 0);
+ tree oprnd0 = TREE_OPERAND (exp, 0);
tree oprnd1 = TREE_OPERAND (exp, 1);
tree oprnd2 = TREE_OPERAND (exp, 2);
rtx op2;
@@ -8750,7 +8759,7 @@
this_optab = optab_for_tree_code (code, type);
expand_operands (oprnd0, oprnd1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
op2 = expand_normal (oprnd2);
- temp = expand_ternary_op (mode, this_optab, op0, op1, op2,
+ temp = expand_ternary_op (mode, this_optab, op0, op1, op2,
target, unsignedp);
gcc_assert (temp);
return temp;
@@ -8765,7 +8774,7 @@
expand_operands (oprnd0, oprnd1, NULL_RTX, &op0, &op1, EXPAND_NORMAL);
op2 = expand_normal (oprnd2);
- target = expand_widen_pattern_expr (exp, op0, op1, op2,
+ target = expand_widen_pattern_expr (exp, op0, op1, op2,
target, unsignedp);
return target;
}
@@ -8774,7 +8783,7 @@
{
tree oprnd0 = TREE_OPERAND (exp, 0);
tree oprnd1 = TREE_OPERAND (exp, 1);
-
+
expand_operands (oprnd0, oprnd1, NULL_RTX, &op0, &op1, 0);
target = expand_widen_pattern_expr (exp, op0, NULL_RTX, op1,
target, unsignedp);
Modified: trunk/contrib/gcc/final.c
===================================================================
--- trunk/contrib/gcc4/final.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/final.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -343,16 +343,14 @@
for each insn we'll call the alignment chain of this insn in the following
comments. */
-struct label_alignment
-{
- short alignment;
- short max_skip;
-};
-
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
static rtx *uid_align;
static int *uid_shuid;
-static struct label_alignment *label_align;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
+
/* Indicate that branch shortening hasn't yet been done. */
void
@@ -555,20 +553,16 @@
#define INSN_SHUID(INSN) (uid_shuid[INSN_UID (INSN)])
-static int min_labelno, max_labelno;
-
-#define LABEL_TO_ALIGNMENT(LABEL) \
- (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].alignment)
-
-#define LABEL_TO_MAX_SKIP(LABEL) \
- (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].max_skip)
-
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* For the benefit of port specific code do this also as a function. */
int
label_to_alignment (rtx label)
{
- return LABEL_TO_ALIGNMENT (label);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ return LABEL_ALIGN_LOG (label);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
#ifdef HAVE_ATTR_length
@@ -617,7 +611,9 @@
align_addr = INSN_ADDRESSES (uid) - insn_lengths[uid];
if (uid_shuid[uid] > end_shuid)
break;
- known_align_log = LABEL_TO_ALIGNMENT (align_label);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ known_align_log = LABEL_ALIGN_LOG (align_label);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
new_align = 1 << known_align_log;
if (new_align < known_align)
continue;
@@ -682,19 +678,13 @@
static unsigned int
compute_alignments (void)
{
- int log, max_skip, max_log;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
basic_block bb;
- if (label_align)
- {
- free (label_align);
- label_align = 0;
- }
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
- max_labelno = max_label_num ();
- min_labelno = get_first_label_num ();
- label_align = XCNEWVEC (struct label_alignment, max_labelno - min_labelno + 1);
-
/* If not optimizing or optimizing for size, don't assign any alignments. */
if (! optimize || optimize_size)
return 0;
@@ -705,10 +695,19 @@
int fallthru_frequency = 0, branch_frequency = 0, has_fallthru = 0;
edge e;
edge_iterator ei;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ int log, max_skip, max_log;
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
if (!LABEL_P (label)
|| probably_never_executed_bb_p (bb))
continue;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ /* If user has specified an alignment, honour it. */
+ if (LABEL_ALIGN_LOG (label) > 0)
+ continue;
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
max_log = LABEL_ALIGN (label);
max_skip = LABEL_ALIGN_MAX_SKIP;
@@ -757,8 +756,9 @@
max_skip = LOOP_ALIGN_MAX_SKIP;
}
}
- LABEL_TO_ALIGNMENT (label) = max_log;
- LABEL_TO_MAX_SKIP (label) = max_skip;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ SET_LABEL_ALIGN (label, max_log, max_skip);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
return 0;
}
@@ -811,7 +811,9 @@
#endif
- /* Compute maximum UID and allocate label_align / uid_shuid. */
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ /* Compute maximum UID and allocate uid_shuid. */
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
max_uid = get_max_uid ();
/* Free uid_shuid before reallocating it. */
@@ -819,29 +821,8 @@
uid_shuid = XNEWVEC (int, max_uid);
- if (max_labelno != max_label_num ())
- {
- int old = max_labelno;
- int n_labels;
- int n_old_labels;
-
- max_labelno = max_label_num ();
-
- n_labels = max_labelno - min_labelno + 1;
- n_old_labels = old - min_labelno + 1;
-
- label_align = xrealloc (label_align,
- n_labels * sizeof (struct label_alignment));
-
- /* Range of labels grows monotonically in the function. Failing here
- means that the initialization of array got lost. */
- gcc_assert (n_old_labels <= n_labels);
-
- memset (label_align + n_old_labels, 0,
- (n_labels - n_old_labels) * sizeof (struct label_alignment));
- }
-
- /* Initialize label_align and set up uid_shuid to be strictly
+ /* APPLE LOCAL for-fsf-4_4 3274130 5295549 */ \
+ /* Initialize set up uid_shuid to be strictly
monotonically rising with insn order. */
/* We use max_log here to keep track of the maximum alignment we want to
impose on the next CODE_LABEL (or the current one if we are processing
@@ -863,11 +844,15 @@
rtx next;
/* Merge in alignments computed by compute_alignments. */
- log = LABEL_TO_ALIGNMENT (insn);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ log = LABEL_ALIGN_LOG (insn);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
if (max_log < log)
{
max_log = log;
- max_skip = LABEL_TO_MAX_SKIP (insn);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ max_skip = LABEL_MAX_SKIP (insn);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
log = LABEL_ALIGN (insn);
@@ -895,8 +880,9 @@
}
}
}
- LABEL_TO_ALIGNMENT (insn) = max_log;
- LABEL_TO_MAX_SKIP (insn) = max_skip;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ SET_LABEL_ALIGN (insn, max_log, max_skip);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
max_log = 0;
max_skip = 0;
}
@@ -943,7 +929,9 @@
{
int uid = INSN_UID (seq);
int log;
- log = (LABEL_P (seq) ? LABEL_TO_ALIGNMENT (seq) : 0);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ log = (LABEL_P (seq) ? LABEL_ALIGN_LOG (seq) : 0);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
uid_align[uid] = align_tab[0];
if (log)
{
@@ -991,8 +979,10 @@
max = shuid;
max_lab = lab;
}
- if (min_align > LABEL_TO_ALIGNMENT (lab))
- min_align = LABEL_TO_ALIGNMENT (lab);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ if (min_align > (int) LABEL_ALIGN_LOG (lab))
+ min_align = LABEL_ALIGN_LOG (lab);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
XEXP (pat, 2) = gen_rtx_LABEL_REF (Pmode, min_lab);
XEXP (pat, 3) = gen_rtx_LABEL_REF (Pmode, max_lab);
@@ -1021,7 +1011,9 @@
if (LABEL_P (insn))
{
- int log = LABEL_TO_ALIGNMENT (insn);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ int log = LABEL_ALIGN_LOG (insn);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
if (log)
{
int align = 1 << log;
@@ -1127,7 +1119,9 @@
if (LABEL_P (insn))
{
- int log = LABEL_TO_ALIGNMENT (insn);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ int log = LABEL_ALIGN_LOG (insn);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
if (log > insn_current_align)
{
int align = 1 << log;
@@ -1176,7 +1170,9 @@
prev = PREV_INSN (prev))
if (varying_length[INSN_UID (prev)] & 2)
{
- rel_align = LABEL_TO_ALIGNMENT (prev);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ rel_align = LABEL_ALIGN_LOG (prev);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
break;
}
@@ -1425,6 +1421,15 @@
TREE_ASM_WRITTEN (DECL_INITIAL (current_function_decl)) = 1;
}
+ if (warn_frame_larger_than
+ && get_frame_size () > frame_larger_than_size)
+ {
+ /* Issue a warning */
+ warning (OPT_Wframe_larger_than_,
+ "the frame size of %wd bytes is larger than %wd bytes",
+ get_frame_size (), frame_larger_than_size);
+ }
+
/* First output the function prologue: code to set up the stack frame. */
targetm.asm_out.function_prologue (file, get_frame_size ());
@@ -1839,26 +1844,27 @@
case CODE_LABEL:
/* The target port might emit labels in the output function for
some insn, e.g. sh.c output_branchy_insn. */
- if (CODE_LABEL_NUMBER (insn) <= max_labelno)
- {
- int align = LABEL_TO_ALIGNMENT (insn);
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ {
+ int align = LABEL_ALIGN_LOG (insn);
#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
- int max_skip = LABEL_TO_MAX_SKIP (insn);
+ int max_skip = LABEL_MAX_SKIP (insn);
#endif
-
- if (align && NEXT_INSN (insn))
- {
+
+ if (align && NEXT_INSN (insn))
+ {
#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
- ASM_OUTPUT_MAX_SKIP_ALIGN (file, align, max_skip);
+ ASM_OUTPUT_MAX_SKIP_ALIGN (file, align, max_skip);
#else
#ifdef ASM_OUTPUT_ALIGN_WITH_NOP
- ASM_OUTPUT_ALIGN_WITH_NOP (file, align);
+ ASM_OUTPUT_ALIGN_WITH_NOP (file, align);
#else
- ASM_OUTPUT_ALIGN (file, align);
+ ASM_OUTPUT_ALIGN (file, align);
#endif
#endif
- }
- }
+ }
+ }
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
#ifdef HAVE_cc0
CC_STATUS_INIT;
/* If this label is reached from only one place, set the condition
@@ -4083,4 +4089,3 @@
0, /* todo_flags_finish */
0 /* letter */
};
-
Modified: trunk/contrib/gcc/flags.h
===================================================================
--- trunk/contrib/gcc4/flags.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/flags.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -23,6 +23,7 @@
#ifndef GCC_FLAGS_H
#define GCC_FLAGS_H
+#include "coretypes.h"
#include "options.h"
enum debug_info_type
@@ -54,6 +55,25 @@
/* Specify how much debugging info to generate. */
extern enum debug_info_level debug_info_level;
+/* A major contribution to object and executable size is debug
+ information size. A major contribution to debug information
+ size is struct descriptions replicated in several object files.
+ The following function determines whether or not debug information
+ should be generated for a given struct. The indirect parameter
+ indicates that the struct is being handled indirectly, via
+ a pointer. See opts.c for the implementation. */
+
+enum debug_info_usage
+{
+ DINFO_USAGE_DFN, /* A struct definition. */
+ DINFO_USAGE_DIR_USE, /* A direct use, such as the type of a variable. */
+ DINFO_USAGE_IND_USE, /* An indirect use, such as through a pointer. */
+ DINFO_USAGE_NUM_ENUMS /* The number of enumerators. */
+};
+
+extern bool should_emit_struct_debug (tree type_decl, enum debug_info_usage);
+extern void set_struct_debug_option (const char *value);
+
/* Nonzero means use GNU-only extensions in the generated symbolic
debugging information. */
extern bool use_gnu_debug_info_extensions;
@@ -102,6 +122,15 @@
extern void set_Wunused (int setting);
+/* Used to set the level of -Wstrict-aliasing, when no level is specified.
+ The external way to set the default level is to use
+ -Wstrict-aliasing=level.
+ ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified,
+ and 0 otherwise. After calling this function, wstrict_aliasing will be
+ set to the default value of -Wstrict_aliasing=level. */
+
+extern void set_warn_strict_aliasing (int onoff);
+
/* Nonzero means warn about any objects definitions whose size is larger
than N bytes. Also want about function definitions whose returned
values are larger than N bytes. The value N is in `larger_than_size'. */
@@ -109,6 +138,12 @@
extern bool warn_larger_than;
extern HOST_WIDE_INT larger_than_size;
+/* Nonzero means warn about any function whose frame size is larger
+ than N bytes. */
+
+extern bool warn_frame_larger_than;
+extern HOST_WIDE_INT frame_larger_than_size;
+
/* Nonzero means warn about constructs which might not be strict
aliasing safe. */
@@ -226,10 +261,6 @@
extern int align_labels_max_skip;
extern int align_functions_log;
-/* Like align_functions_log above, but used by front-ends to force the
- minimum function alignment. Zero means no alignment is forced. */
-extern int force_align_functions_log;
-
/* Nonzero if we dump in VCG format, not plain text. */
extern int dump_for_graph;
@@ -267,6 +298,10 @@
#define abi_version_at_least(N) \
(flag_abi_version == 0 || flag_abi_version >= (N))
+/* Return whether the function should be excluded from
+ instrumentation. */
+extern bool flag_instrument_functions_exclude_p (tree fndecl);
+
/* True if the given mode has a NaN representation and the treatment of
NaN operands is important. Certain optimizations, such as folding
x * 0 into 0, are not correct for NaN operands, and are normally
Modified: trunk/contrib/gcc/fold-const.c
===================================================================
--- trunk/contrib/gcc4/fold-const.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/fold-const.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -992,7 +992,7 @@
}
}
else if (issue_strict_overflow_warning (wc))
- warning (OPT_Wstrict_overflow, gmsgid);
+ warning (OPT_Wstrict_overflow, "%s", gmsgid);
}
/* Return true if the built-in mathematical function specified by CODE
@@ -2150,6 +2150,8 @@
{
case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
case POINTER_TYPE: case REFERENCE_TYPE:
+ /* APPLE LOCAL blocks 5862465 */
+ case BLOCK_POINTER_TYPE:
case OFFSET_TYPE:
if (TREE_CODE (arg) == INTEGER_CST)
{
@@ -12591,6 +12593,8 @@
CASE_INT_FN (BUILT_IN_FFS):
CASE_INT_FN (BUILT_IN_PARITY):
CASE_INT_FN (BUILT_IN_POPCOUNT):
+ case BUILT_IN_BSWAP32:
+ case BUILT_IN_BSWAP64:
/* Always true. */
return 1;
Modified: trunk/contrib/gcc/function.c
===================================================================
--- trunk/contrib/gcc4/function.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/function.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -20,7 +20,7 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/function.c 261188 2014-01-26 19:49:54Z pfg $ */
/* This file handles the generation of rtl code from tree structure
at the level of the function as a whole.
@@ -116,6 +116,10 @@
post-instantiation libcalls. */
int virtuals_instantiated;
+/* APPLE LOCAL begin radar 5732232 - blocks */
+struct block_sema_info *cur_block;
+/* APPLE LOCAL end radar 5732232 - blocks */
+
/* Assign unique numbers to labels generated for profiling, debugging, etc. */
static GTY(()) int funcdef_no;
@@ -214,6 +218,8 @@
static void do_clobber_return_reg (rtx, void *);
static void do_use_return_reg (rtx, void *);
static void set_insn_locators (rtx, int) ATTRIBUTE_UNUSED;
+/* APPLE LOCAL radar 6163705, Blocks prologues */
+static rtx find_block_prologue_insns (void);
/* Pointer to chain of `struct function' for containing functions. */
struct function *outer_function_chain;
@@ -3813,8 +3819,13 @@
DECL_STRUCT_FUNCTION (fndecl) = cfun;
cfun->decl = fndecl;
- result = DECL_RESULT (fndecl);
- if (aggregate_value_p (result, fndecl))
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ /* We cannot support blocks which return aggregates because at this
+ point we do not have info on the return type. */
+ if (!cur_block)
+ {
+ result = DECL_RESULT (fndecl);
+ if (aggregate_value_p (result, fndecl))
{
#ifdef PCC_STATIC_STRUCT_RETURN
current_function_returns_pcc_struct = 1;
@@ -3821,9 +3832,10 @@
#endif
current_function_returns_struct = 1;
}
-
- current_function_returns_pointer = POINTER_TYPE_P (TREE_TYPE (result));
-
+ /* This code is not used anywhere ! */
+ current_function_returns_pointer = POINTER_TYPE_P (TREE_TYPE (result));
+ }
+ /* APPLE LOCAL end radar 5732232 - blocks */
current_function_stdarg
= (fntype
&& TYPE_ARG_TYPES (fntype) != 0
@@ -5060,6 +5072,140 @@
}
#endif
+/* APPLE LOCAL begin radar 6163705, Blocks prologues */
+
+/* The function should only be called for Blocks functions.
+
+ On being called, the main instruction list for the Blocks function
+ may contain instructions for setting up the ref_decl and byref_decl
+ variables in the Block. Those isns really need to go before the
+ function prologue note rather than after. If such instructions are
+ present, they are identifiable by their source line number, which
+ will be one line preceding the declaration of the function. If
+ they are present, there will also be a source line note instruction
+ for that line.
+
+ This function does a set of things:
+ - It finds the first such prologue insn.
+ - It finds the last such prologue insn.
+ - It changes the insn locator of all such prologue insns to
+ the prologue locator.
+ - It finds the source line note for the bogus location and
+ removes it.
+ - It decides if it is safe to place the prolgoue end note
+ after the last prologue insn it finds, and if so, returns
+ the last prologue insn (otherwise it returns NULL).
+
+ This function makes the following checks to determine if it is
+ safe to move the prologue end note to just below the last
+ prologue insn it finds. If ALL of the checks succeed then it
+ is safe. If any check fails, this function returns NULL. The
+ checks it makes are:
+
+ - There were no INSN_P instructions that occurred before the
+ first prologue insn.
+ - If there are any non-prologue insns between the first & last
+ prologue insn, the non-prologue insns do not outnumber the
+ prologue insns.
+ - The first prologue insn & the last prologue insn are in the
+ same basic block.
+*/
+
+static rtx
+find_block_prologue_insns (void)
+{
+ rtx first_prologue_insn = NULL;
+ rtx last_prologue_insn = NULL;
+ rtx line_number_note = NULL;
+ rtx tmp_insn;
+ int num_prologue_insns = 0;
+ int total_insns = 0;
+ int prologue_line = DECL_SOURCE_LINE (cfun->decl) - 1;
+ bool other_insns_before_prologue = false;
+ bool start_of_fnbody_found = false;
+
+ /* Go through all the insns and find the first prologue insn, the
+ last prologue insn, the source line location note, and whether or
+ not there are any "real" insns that occur before the first
+ prologue insn. Re-set the insn locator for prologue insns to the
+ prologue locator. */
+
+ for (tmp_insn = get_insns(); tmp_insn; tmp_insn = NEXT_INSN (tmp_insn))
+ {
+ if (INSN_P (tmp_insn))
+ {
+ if (insn_line (tmp_insn) == prologue_line)
+ {
+ if (!first_prologue_insn)
+ first_prologue_insn = tmp_insn;
+ num_prologue_insns++;
+ last_prologue_insn = tmp_insn;
+ INSN_LOCATOR (tmp_insn) = prologue_locator;
+ }
+ else if (!first_prologue_insn
+ && start_of_fnbody_found)
+ other_insns_before_prologue = true;
+ }
+ else if (NOTE_P (tmp_insn)
+ && NOTE_LINE_NUMBER (tmp_insn) == NOTE_INSN_FUNCTION_BEG)
+ start_of_fnbody_found = true;
+ else if (NOTE_P (tmp_insn)
+ && (XINT (tmp_insn, 5) == prologue_line))
+ line_number_note = tmp_insn;
+ }
+
+ /* If there were no prologue insns, return now. */
+
+ if (!first_prologue_insn)
+ return NULL;
+
+ /* If the source location note for the line before the beginning of the
+ function was found, remove it. */
+
+ if (line_number_note)
+ remove_insn (line_number_note);
+
+ /* If other real insns got moved above the prologue insns, we can't
+ pull out the prologue insns, so return now. */
+
+ if (other_insns_before_prologue && (optimize > 0))
+ return NULL;
+
+ /* Count the number of insns between the first prologue insn and the
+ last prologue insn; also count the number of non-prologue insns
+ between the first prologue insn and the last prologue insn. */
+
+ tmp_insn = first_prologue_insn;
+ while (tmp_insn != last_prologue_insn)
+ {
+ total_insns++;
+ tmp_insn = NEXT_INSN (tmp_insn);
+ }
+ total_insns++;
+
+ /* If more than half of the insns between the first & last prologue
+ insns are not prologue insns, then there is too much code that
+ got moved in between prologue insns (by optimizations), so we
+ will not try to pull it out. */
+
+ if ((num_prologue_insns * 2) <= total_insns)
+ return NULL;
+
+ /* Make sure all the prologue insns are within one basic block.
+ If the insns cross a basic block boundary, then there is a chance
+ that moving them will cause incorrect code, so don't do it. */
+
+ gcc_assert (first_prologue_insn != NULL);
+ gcc_assert (last_prologue_insn != NULL);
+
+ if (BLOCK_FOR_INSN (first_prologue_insn) !=
+ BLOCK_FOR_INSN (last_prologue_insn))
+ return NULL;
+
+ return last_prologue_insn;
+}
+/* APPLE LOCAL end radar 6163705, Blocks prologues */
+
/* Generate the prologue and epilogue RTL if the machine supports it. Thread
this into place with notes indicating where the prologue ends and where
the epilogue begins. Update the basic block information when possible. */
@@ -5083,6 +5229,13 @@
#ifdef HAVE_prologue
if (HAVE_prologue)
{
+ /* APPLE LOCAL begin radar 6163705, Blocks prologues */
+ rtx last_prologue_insn = NULL;
+
+ if (BLOCK_SYNTHESIZED_FUNC (cfun->decl))
+ last_prologue_insn = find_block_prologue_insns();
+ /* APPLE LOCAL end radar 6163705, Blocks prologues */
+
start_sequence ();
seq = gen_prologue ();
emit_insn (seq);
@@ -5089,7 +5242,10 @@
/* Retain a map of the prologue insns. */
record_insns (seq, &prologue);
- prologue_end = emit_note (NOTE_INSN_PROLOGUE_END);
+ /* APPLE LOCAL begin radar 6163705, Blocks prologues */
+ if (!last_prologue_insn)
+ prologue_end = emit_note (NOTE_INSN_PROLOGUE_END);
+ /* APPLE LOCAL end radar 6163705, Blocks prologues */
#ifndef PROFILE_BEFORE_PROLOGUE
/* Ensure that instructions are not moved into the prologue when
@@ -5110,7 +5266,11 @@
insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
inserted = 1;
- }
+
+ /* APPLE LOCAL begin radar 6163705, Blocks prologues */
+ if (last_prologue_insn)
+ emit_note_after (NOTE_INSN_PROLOGUE_END, last_prologue_insn);
+ /* APPLE LOCAL end radar 6163705, Blocks prologues */ }
#endif
/* If the exit block has no non-fake predecessors, we don't need
Modified: trunk/contrib/gcc/function.h
===================================================================
--- trunk/contrib/gcc4/function.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/function.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -264,6 +264,12 @@
needed by inner routines. */
rtx x_arg_pointer_save_area;
+ /* APPLE LOCAL begin radar 6411649 */
+ /* Holds a unique number for this function. It is used to
+ generate block number for block names. */
+ int unqiue_block_number;
+ /* APPLE LOCAL end radar 6411649 */
+
/* Offset to end of allocated area of stack frame.
If stack grows down, this is the address of the last stack slot allocated.
If stack grows up, this is the address for the next slot. */
@@ -579,4 +585,6 @@
extern void used_types_insert (tree);
+/* APPLE LOCAL radar 5732232 - blocks */
+extern struct block_sema_info *cur_block;
#endif /* GCC_FUNCTION_H */
Modified: trunk/contrib/gcc/gcc.c
===================================================================
--- trunk/contrib/gcc4/gcc.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/gcc.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -23,7 +23,7 @@
This paragraph is here to try to keep Sun CC from dying.
The number of chars here seems crucial!!!! */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/gcc.c 286713 2015-08-13 01:02:57Z pfg $ */
/* This program is the user interface to the C compiler and possibly to
other compilers. It is used because compilation is a complicated procedure
@@ -240,7 +240,7 @@
/* Nonzero if cross-compiling.
When -b is used, the value comes from the `specs' file. */
-#ifdef CROSS_COMPILE
+#ifdef CROSS_DIRECTORY_STRUCTURE
static const char *cross_compile = "1";
#else
static const char *cross_compile = "0";
@@ -680,7 +680,7 @@
#ifdef TARGET_LIBC_PROVIDES_SSP
#define LINK_SSP_SPEC "%{fstack-protector:}"
#else
-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}"
+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-strong|fstack-protector-all:-lssp_nonshared -lssp}"
#endif
#endif
@@ -1469,7 +1469,7 @@
#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
#endif
-#ifdef CROSS_COMPILE /* Don't use these prefixes for a cross compiler. */
+#ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */
#undef MD_EXEC_PREFIX
#undef MD_STARTFILE_PREFIX
#undef MD_STARTFILE_PREFIX_1
@@ -2974,7 +2974,7 @@
if (errmsg != NULL)
{
if (err == 0)
- fatal (errmsg);
+ fatal ("%s", errmsg);
else
{
errno = err;
@@ -6525,7 +6525,7 @@
if (! verbose_flag)
{
- printf (_("\nFor bug reporting instructions, please see:\n"));
+ printf ("%s", _("\nFor bug reporting instructions, please see:\n"));
printf ("%s.\n", bug_report_url);
return (0);
Modified: trunk/contrib/gcc/gcov.c
===================================================================
--- trunk/contrib/gcc4/gcov.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/gcov.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -417,7 +417,7 @@
fnotice (stdout, "gcov (GCC) %s\n", version_string);
fprintf (stdout, "Copyright %s 2006 Free Software Foundation, Inc.\n",
_("(C)"));
- fnotice (stdout,
+ fnotice (stdout, "%s",
_("This is free software; see the source for copying conditions.\n"
"There is NO warranty; not even for MERCHANTABILITY or \n"
"FITNESS FOR A PARTICULAR PURPOSE.\n\n"));
Modified: trunk/contrib/gcc/genattrtab.c
===================================================================
--- trunk/contrib/gcc4/genattrtab.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/genattrtab.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -959,6 +959,7 @@
case CTZ:
case POPCOUNT:
case PARITY:
+ case BSWAP:
XEXP (exp, 0) = check_attr_value (XEXP (exp, 0), attr);
break;
Modified: trunk/contrib/gcc/genopinit.c
===================================================================
--- trunk/contrib/gcc4/genopinit.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/genopinit.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -148,6 +148,7 @@
"atan_optab->handlers[$A].insn_code = CODE_FOR_$(atan$a2$)",
"strlen_optab->handlers[$A].insn_code = CODE_FOR_$(strlen$a$)",
"one_cmpl_optab->handlers[$A].insn_code = CODE_FOR_$(one_cmpl$a2$)",
+ "bswap_optab->handlers[$A].insn_code = CODE_FOR_$(bswap$a2$)",
"ffs_optab->handlers[$A].insn_code = CODE_FOR_$(ffs$a2$)",
"clz_optab->handlers[$A].insn_code = CODE_FOR_$(clz$a2$)",
"ctz_optab->handlers[$A].insn_code = CODE_FOR_$(ctz$a2$)",
Modified: trunk/contrib/gcc/ggc-common.c
===================================================================
--- trunk/contrib/gcc4/ggc-common.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/ggc-common.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -716,10 +716,12 @@
min_expand = ggc_rlimit_bound (min_expand);
/* The heuristic is a percentage equal to 30% + 70%*(RAM/1GB), yielding
- a lower bound of 30% and an upper bound of 100% (when RAM >= 1GB). */
+ APPLE LOCAL retune gc params 6124839
+ a lower bound of 30% and an upper bound of 150% (when RAM >= 1.7GB). */
min_expand /= 1024*1024*1024;
min_expand *= 70;
- min_expand = MIN (min_expand, 70);
+ /* APPLE LOCAL retune gc params 6124839 */
+ min_expand = MIN (min_expand, 120);
min_expand += 30;
return min_expand;
@@ -727,7 +729,8 @@
/* Heuristic to set a default for GGC_MIN_HEAPSIZE. */
int
-ggc_min_heapsize_heuristic (void)
+/* APPLE LOCAL retune gc params 6124839 */
+ggc_min_heapsize_heuristic (bool optimize)
{
double phys_kbytes = physmem_total();
double limit_kbytes = ggc_rlimit_bound (phys_kbytes * 2);
@@ -739,6 +742,13 @@
bound of 128M (when RAM >= 1GB). */
phys_kbytes /= 8;
+ /* APPLE LOCAL begin retune gc params 6124839 */
+
+ /* Additionally, on a multicore machine, we assume that we share the
+ memory with others reasonably equally. */
+ phys_kbytes /= (double)ncpu_available() / (2 - optimize);
+ /* APPLE LOCAL end retune gc params 6124839 */
+
#if defined(HAVE_GETRLIMIT) && defined (RLIMIT_RSS)
/* Try not to overrun the RSS limit while doing garbage collection.
The RSS limit is only advisory, so no margin is subtracted. */
@@ -765,11 +775,13 @@
}
void
-init_ggc_heuristics (void)
+/* APPLE LOCAL retune gc params 6124839 */
+init_ggc_heuristics (bool optimize ATTRIBUTE_UNUSED)
{
#if !defined ENABLE_GC_CHECKING && !defined ENABLE_GC_ALWAYS_COLLECT
set_param_value ("ggc-min-expand", ggc_min_expand_heuristic());
- set_param_value ("ggc-min-heapsize", ggc_min_heapsize_heuristic());
+ /* APPLE LOCAL retune gc params 6124839 */
+ set_param_value ("ggc-min-heapsize", ggc_min_heapsize_heuristic(optimize));
#endif
}
Modified: trunk/contrib/gcc/ggc.h
===================================================================
--- trunk/contrib/gcc4/ggc.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/ggc.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -290,8 +290,10 @@
/* Heuristics. */
extern int ggc_min_expand_heuristic (void);
-extern int ggc_min_heapsize_heuristic (void);
-extern void init_ggc_heuristics (void);
+/* APPLE LOCAL begin retune gc params 6124839 */
+extern int ggc_min_heapsize_heuristic (bool);
+extern void init_ggc_heuristics (bool);
+/* APPLE LOCAL end retune gc params 6124839 */
/* Zone collection. */
#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
Modified: trunk/contrib/gcc/gimplify.c
===================================================================
--- trunk/contrib/gcc4/gimplify.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/gimplify.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -6397,7 +6397,8 @@
catch the exit hook. */
/* ??? Add some way to ignore exceptions for this TFE. */
if (flag_instrument_function_entry_exit
- && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl))
+ && !DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl)
+ && !flag_instrument_functions_exclude_p (fndecl))
{
tree tf, x, bind;
Modified: trunk/contrib/gcc/ginclude/stdarg.h
===================================================================
--- trunk/contrib/gcc4/ginclude/stdarg.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/ginclude/stdarg.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -93,7 +93,7 @@
But on BSD NET2 we must not test or define or undef it.
(Note that the comments in NET 2's ansi.h
are incorrect for _VA_LIST_--see stdio.h!) */
-#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(__MidnightBSD__) || defined(WINNT)
+#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */
#ifndef _VA_LIST_DEFINED
/* The macro _VA_LIST is used in SCO Unix 3.2. */
@@ -107,7 +107,7 @@
#endif /* not _VA_LIST_T_H */
#endif /* not _VA_LIST */
#endif /* not _VA_LIST_DEFINED */
-#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(__MidnightBSD__))
+#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
#define _VA_LIST_
#endif
#ifndef _VA_LIST
Modified: trunk/contrib/gcc/ginclude/stddef.h
===================================================================
--- trunk/contrib/gcc4/ginclude/stddef.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/ginclude/stddef.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -58,7 +58,7 @@
#include <machine/ansi.h>
#endif
/* On FreeBSD 5, machine/ansi.h does not exist anymore... */
-#if defined (__FreeBSD__) && (__FreeBSD__ >= 5) || defined(__MidnightBSD__)
+#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
#include <sys/_types.h>
#endif
@@ -202,7 +202,7 @@
#define ___int_size_t_h
#define _GCC_SIZE_T
#define _SIZET_
-#if defined (__FreeBSD__) && (__FreeBSD__ >= 5) || defined(__MidnightBSD__)
+#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
/* __size_t is a typedef on FreeBSD 5!, must not trash it. */
#else
#define __size_t
@@ -295,7 +295,7 @@
typedef _BSD_RUNE_T_ rune_t;
#define _BSD_WCHAR_T_DEFINED_
#define _BSD_RUNE_T_DEFINED_ /* Darwin */
-#if defined (__FreeBSD__) && (__FreeBSD__ < 5) || defined(__MidnightBSD__)
+#if defined (__FreeBSD__) && (__FreeBSD__ < 5)
/* Why is this file so hard to maintain properly? In contrast to
the comment above regarding BSD/386 1.1, on FreeBSD for as long
as the symbol has existed, _BSD_RUNE_T_ must not stay defined or
@@ -308,7 +308,7 @@
/* FreeBSD 5 can't be handled well using "traditional" logic above
since it no longer defines _BSD_RUNE_T_ yet still desires to export
rune_t in some cases... */
-#if defined (__FreeBSD__) && (__FreeBSD__ >= 5) || defined(__MidnightBSD__)
+#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
#if __BSD_VISIBLE
#ifndef _RUNE_T_DECLARED
Modified: trunk/contrib/gcc/gthr-posix.h
===================================================================
--- trunk/contrib/gcc4/gthr-posix.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/gthr-posix.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -157,7 +157,7 @@
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
which means the alternate __gthread_active_p below cannot be used there. */
-#if defined(__FreeBSD__) || defined(__MidnightBSD__) || (defined(__sun) && defined(__svr4__))
+#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
static volatile int __gthread_active = -1;
Modified: trunk/contrib/gcc/gthr-posix95.h
===================================================================
--- trunk/contrib/gcc4/gthr-posix95.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/gthr-posix95.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -115,10 +115,16 @@
it is passed so we cannot pretend that the interface is active if -pthreads
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
we need to play the usual game with weak symbols. On Solaris 10 and up, a
- working interface is always exposed. */
+ working interface is always exposed. On FreeBSD 6 and later, libc also
+ exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
+ to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
+ which means the alternate __gthread_active_p below cannot be used there. */
-#if defined(__sun) && defined(__svr4__)
+ */
+
+#if defined(__FreeBSD__) || defined(__sun) && defined(__svr4__)
+
static volatile int __gthread_active = -1;
static void
@@ -160,7 +166,7 @@
return __gthread_active_latest_value != 0;
}
-#else /* not Solaris */
+#else /* neither FreeBSD nor Solaris */
static inline int
__gthread_active_p (void)
@@ -170,7 +176,7 @@
return __gthread_active_ptr != 0;
}
-#endif /* Solaris */
+#endif /* FreeBSD or Solaris */
#else /* not SUPPORTS_WEAK */
Modified: trunk/contrib/gcc/langhooks-def.h
===================================================================
--- trunk/contrib/gcc4/langhooks-def.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/langhooks-def.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -95,6 +95,13 @@
extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
tree);
+/* APPLE LOCAL begin 6353006 */
+extern tree lhd_build_generic_block_struct_type (void);
+/* APPLE LOCAL end 6353006 */
+
+/* APPLE LOCAL radar 6386976 */
+extern bool lhd_is_runtime_specific_type (tree);
+
#define LANG_HOOKS_NAME "GNU unknown"
#define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier)
#define LANG_HOOKS_INIT hook_bool_void_false
@@ -141,6 +148,11 @@
#define LANG_HOOKS_FUNCTION_LEAVE_NESTED lhd_do_nothing_f
#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P hook_bool_tree_true
+/* APPLE LOCAL begin radar 6353006 */
+#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
+lhd_build_generic_block_struct_type
+/* APPLE LOCAL end radar 6353006 */
+
/* Attribute hooks. */
#define LANG_HOOKS_ATTRIBUTE_TABLE NULL
#define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE NULL
@@ -217,11 +229,14 @@
so we create a compile-time error instead. */
#define LANG_HOOKS_MAKE_TYPE lhd_make_node
#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR lhd_incomplete_type_error
+#define LANG_HOOKS_GENERIC_TYPE_P hook_bool_tree_false
#define LANG_HOOKS_TYPE_PROMOTES_TO lhd_type_promotes_to
#define LANG_HOOKS_REGISTER_BUILTIN_TYPE lhd_register_builtin_type
#define LANG_HOOKS_TYPE_MAX_SIZE lhd_return_null_tree
#define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \
lhd_omp_firstprivatize_type_sizes
+/* APPLE LOCAL radar 6386976 */
+#define LANG_HOOKS_IS_RUNTIME_SPECIFIC_TYPE lhd_is_runtime_specific_type
#define LANG_HOOKS_HASH_TYPES true
#define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
@@ -231,11 +246,14 @@
LANG_HOOKS_UNSIGNED_TYPE, \
LANG_HOOKS_SIGNED_TYPE, \
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
+ LANG_HOOKS_GENERIC_TYPE_P, \
LANG_HOOKS_TYPE_PROMOTES_TO, \
LANG_HOOKS_REGISTER_BUILTIN_TYPE, \
LANG_HOOKS_INCOMPLETE_TYPE_ERROR, \
LANG_HOOKS_TYPE_MAX_SIZE, \
LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES, \
+ /* APPLE LOCAL radar 6386976 */ \
+ LANG_HOOKS_IS_RUNTIME_SPECIFIC_TYPE, \
LANG_HOOKS_HASH_TYPES \
}
@@ -331,6 +349,8 @@
LANG_HOOKS_BUILTIN_FUNCTION, \
LANG_HOOKS_INIT_TS, \
LANG_HOOKS_EXPR_TO_DECL, \
+/* APPLE LOCAL radar 6353006 */ \
+ LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE, \
}
#endif /* GCC_LANG_HOOKS_DEF_H */
Modified: trunk/contrib/gcc/langhooks.c
===================================================================
--- trunk/contrib/gcc4/langhooks.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/langhooks.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -588,3 +588,19 @@
tree t ATTRIBUTE_UNUSED)
{
}
+
+/* APPLE LOCAL begin radar 6353006 */
+tree
+lhd_build_generic_block_struct_type (void)
+{
+ return NULL_TREE;
+}
+/* APPLE LOCAL end radar 6353006 */
+
+/* APPLE LOCAL begin radar 6386976 */
+bool
+lhd_is_runtime_specific_type (tree type ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+/* APPLE LOCAL end radar 6386976 */
Modified: trunk/contrib/gcc/langhooks.h
===================================================================
--- trunk/contrib/gcc4/langhooks.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/langhooks.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -119,6 +119,10 @@
according to UNSIGNEDP. */
tree (*signed_or_unsigned_type) (int, tree);
+ /* True if the type is an instantiation of a generic type,
+ e.g. C++ template implicit specializations. */
+ bool (*generic_p) (tree);
+
/* Given a type, apply default promotions to unnamed function
arguments and return the new type. Return the same type if no
change. Required by any language that supports variadic
@@ -148,6 +152,12 @@
firstprivate variables. */
void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree);
+ /* APPLE LOCAL begin radar 6386976 */
+ /* Determine whether the type-tree passed in is specific to the
+ language/runtime definitions, e.g. is an Objective-C class... */
+ bool (*is_runtime_specific_type) (tree);
+ /* APPLE LOCAL end radar 6386976 */
+
/* Nonzero if types that are identical are to be hashed so that only
one copy is kept. If a language requires unique types for each
user-specified type, such as Ada, this should be set to TRUE. */
@@ -464,6 +474,12 @@
TREE_SIDE_EFFECTS need updating. */
tree (*expr_to_decl) (tree expr, bool *tc, bool *ti, bool *se);
+ /* APPLE LOCAL begin radar 6353006 */
+ /* For c-based languages, builds a generic type for Blocks pointers (for
+ emitting debug information. For other languages, returns NULL. */
+ tree (*build_generic_block_struct_type) (void);
+ /* APPLE LOCAL end radar 6353006 */
+
/* Whenever you add entries here, make sure you adjust langhooks-def.h
and langhooks.c accordingly. */
};
Modified: trunk/contrib/gcc/libgcc-std.ver
===================================================================
--- trunk/contrib/gcc4/libgcc-std.ver 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/libgcc-std.ver 2018-06-04 17:30:21 UTC (rev 10405)
@@ -274,3 +274,10 @@
__floatuntitf
_Unwind_GetIPInfo
}
+
+%inherit GCC_4.3 GCC_4.2.0
+GCC_4.3.0 {
+ # byte swapping routines
+ __bswapsi2
+ __bswapdi2
+}
Modified: trunk/contrib/gcc/longlong.h
===================================================================
--- trunk/contrib/gcc4/longlong.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/longlong.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -205,7 +205,7 @@
"rI" ((USItype) (bl)) __CLOBBER_CC)
#define umul_ppmm(xh, xl, a, b) \
{register USItype __t0, __t1, __t2; \
- __asm__ ("%@ Inlined umul_ppmm\n" \
+ __asm__ ("/* Inlined umul_ppmm */\n" \
" mov %2, %5, lsr #16\n" \
" mov %0, %6, lsr #16\n" \
" bic %3, %5, %2, lsl #16\n" \
@@ -1086,8 +1086,8 @@
"bcs,a,pn %%xcc, 1f\n\t" \
"add %0, 1, %0\n" \
"1:" \
- : "=r" ((UDItype)(sh)), \
- "=&r" ((UDItype)(sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%rJ" ((UDItype)(ah)), \
"rI" ((UDItype)(bh)), \
"%rJ" ((UDItype)(al)), \
@@ -1100,8 +1100,8 @@
"bcs,a,pn %%xcc, 1f\n\t" \
"sub %0, 1, %0\n\t" \
"1:" \
- : "=r" ((UDItype)(sh)), \
- "=&r" ((UDItype)(sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "rJ" ((UDItype)(ah)), \
"rI" ((UDItype)(bh)), \
"rJ" ((UDItype)(al)), \
@@ -1133,8 +1133,8 @@
"sllx %3,32,%3\n\t" \
"add %1,%3,%1\n\t" \
"add %5,%2,%0" \
- : "=r" ((UDItype)(wh)), \
- "=&r" ((UDItype)(wl)), \
+ : "=r" (wh), \
+ "=&r" (wl), \
"=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
: "r" ((UDItype)(u)), \
"r" ((UDItype)(v)) \
Modified: trunk/contrib/gcc/mips-tdump.c
===================================================================
--- trunk/contrib/gcc4/mips-tdump.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/mips-tdump.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -29,11 +29,11 @@
#ifdef index
#undef index
#endif
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#include <a.out.h>
#else
#include "mips/a.out.h"
-#endif /* CROSS_COMPILE */
+#endif /* CROSS_DIRECTORY_STRUCTURE */
/* Include getopt.h for the sake of getopt_long. */
#include "getopt.h"
Modified: trunk/contrib/gcc/mips-tfile.c
===================================================================
--- trunk/contrib/gcc4/mips-tfile.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/mips-tfile.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -667,11 +667,11 @@
#include <signal.h>
-#ifndef CROSS_COMPILE
+#ifndef CROSS_DIRECTORY_STRUCTURE
#include <a.out.h>
#else
#include "mips/a.out.h"
-#endif /* CROSS_COMPILE */
+#endif /* CROSS_DIRECTORY_STRUCTURE */
#include "gstab.h"
Modified: trunk/contrib/gcc/mklibgcc.in
===================================================================
--- trunk/contrib/gcc4/mklibgcc.in 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/mklibgcc.in 2018-06-04 17:30:21 UTC (rev 10405)
@@ -91,7 +91,7 @@
_ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
_popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
_powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
- _divxc3 _divtc3'
+ _divxc3 _divtc3 _bswapsi2 _bswapdi2'
if [ "$LIB2_SIDITI_CONV_FUNCS" ]; then
for func in $swfloatfuncs; do
Modified: trunk/contrib/gcc/optabs.c
===================================================================
--- trunk/contrib/gcc4/optabs.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/optabs.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2591,6 +2591,10 @@
goto try_libcall;
}
+ /* We can't widen a bswap. */
+ if (unoptab == bswap_optab)
+ goto try_libcall;
+
if (CLASS_HAS_WIDER_MODES_P (class))
for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
@@ -5253,6 +5257,7 @@
absv_optab = init_optabv (ABS);
addcc_optab = init_optab (UNKNOWN);
one_cmpl_optab = init_optab (NOT);
+ bswap_optab = init_optab (BSWAP);
ffs_optab = init_optab (FFS);
clz_optab = init_optab (CLZ);
ctz_optab = init_optab (CTZ);
@@ -5456,6 +5461,11 @@
init_interclass_conv_libfuncs (trunc_optab, "trunc", MODE_FLOAT, MODE_DECIMAL_FLOAT);
init_interclass_conv_libfuncs (trunc_optab, "trunc", MODE_DECIMAL_FLOAT, MODE_FLOAT);
+ /* Explicitly initialize the bswap libfuncs since we need them to be
+ valid for things other than word_mode. */
+ set_optab_libfunc (bswap_optab, SImode, "__bswapsi2");
+ set_optab_libfunc (bswap_optab, DImode, "__bswapdi2");
+
/* Use cabs for double complex abs, since systems generally have cabs.
Don't define any libcall for float complex, so that cabs will be used. */
if (complex_double_type_node)
Modified: trunk/contrib/gcc/optabs.h
===================================================================
--- trunk/contrib/gcc4/optabs.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/optabs.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -146,6 +146,8 @@
/* Abs value */
OTI_abs,
OTI_absv,
+ /* Byteswap */
+ OTI_bswap,
/* Bitwise not */
OTI_one_cmpl,
/* Bit scanning and counting */
@@ -315,6 +317,7 @@
#define abs_optab (optab_table[OTI_abs])
#define absv_optab (optab_table[OTI_absv])
#define one_cmpl_optab (optab_table[OTI_one_cmpl])
+#define bswap_optab (optab_table[OTI_bswap])
#define ffs_optab (optab_table[OTI_ffs])
#define clz_optab (optab_table[OTI_clz])
#define ctz_optab (optab_table[OTI_ctz])
Modified: trunk/contrib/gcc/opth-gen.awk
===================================================================
--- trunk/contrib/gcc4/opth-gen.awk 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/opth-gen.awk 2018-06-04 17:30:21 UTC (rev 10405)
@@ -87,7 +87,7 @@
}
for (var in masknum) {
- if (masknum[var] > 31) {
+ if (masknum[var] > 32) {
if (var == "")
print "#error too many target masks"
else
Modified: trunk/contrib/gcc/opts.c
===================================================================
--- trunk/contrib/gcc4/opts.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/opts.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -20,7 +20,7 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/opts.c 259405 2013-12-15 03:47:31Z pfg $ */
#include "config.h"
#include "system.h"
@@ -59,6 +59,11 @@
bool warn_larger_than;
HOST_WIDE_INT larger_than_size;
+/* True to warn about any function whose frame size is larger
+ * than N bytes. */
+bool warn_frame_larger_than;
+HOST_WIDE_INT frame_larger_than_size;
+
/* Nonzero means warn about constructs which might not be
strict-aliasing safe. */
int warn_strict_aliasing;
@@ -79,6 +84,256 @@
the definitions of the different possible levels. */
enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
+/* A major contribution to object and executable size is debug
+ information size. A major contribution to debug information size
+ is struct descriptions replicated in several object files. The
+ following flags attempt to reduce this information. The basic
+ idea is to not emit struct debugging information in the current
+ compilation unit when that information will be generated by
+ another compilation unit.
+
+ Debug information for a struct defined in the current source
+ file should be generated in the object file. Likewise the
+ debug information for a struct defined in a header should be
+ generated in the object file of the corresponding source file.
+ Both of these case are handled when the base name of the file of
+ the struct definition matches the base name of the source file
+ of thet current compilation unit. This matching emits minimal
+ struct debugging information.
+
+ The base file name matching rule above will fail to emit debug
+ information for structs defined in system headers. So a second
+ category of files includes system headers in addition to files
+ with matching bases.
+
+ The remaining types of files are library headers and application
+ headers. We cannot currently distinguish these two types. */
+
+enum debug_struct_file
+{
+ DINFO_STRUCT_FILE_NONE, /* Debug no structs. */
+ DINFO_STRUCT_FILE_BASE, /* Debug structs defined in files with the
+ same base name as the compilation unit. */
+ DINFO_STRUCT_FILE_SYS, /* Also debug structs defined in system
+ header files. */
+ DINFO_STRUCT_FILE_ANY /* Debug structs defined in all files. */
+};
+
+/* Generic structs (e.g. templates not explicitly specialized)
+ may not have a compilation unit associated with them, and so
+ may need to be treated differently from ordinary structs.
+
+ Structs only handled by reference (indirectly), will also usually
+ not need as much debugging information. */
+
+static enum debug_struct_file debug_struct_ordinary[DINFO_USAGE_NUM_ENUMS]
+ = { DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY };
+static enum debug_struct_file debug_struct_generic[DINFO_USAGE_NUM_ENUMS]
+ = { DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY, DINFO_STRUCT_FILE_ANY };
+
+/* Parse the -femit-struct-debug-detailed option value
+ and set the flag variables. */
+
+#define MATCH( prefix, string ) \
+ ((strncmp (prefix, string, sizeof prefix - 1) == 0) \
+ ? ((string += sizeof prefix - 1), 1) : 0)
+
+void
+set_struct_debug_option (const char *spec)
+{
+ /* various labels for comparison */
+ static char dfn_lbl[] = "dfn:", dir_lbl[] = "dir:", ind_lbl[] = "ind:";
+ static char ord_lbl[] = "ord:", gen_lbl[] = "gen:";
+ static char none_lbl[] = "none", any_lbl[] = "any";
+ static char base_lbl[] = "base", sys_lbl[] = "sys";
+
+ enum debug_struct_file files = DINFO_STRUCT_FILE_ANY;
+ /* Default is to apply to as much as possible. */
+ enum debug_info_usage usage = DINFO_USAGE_NUM_ENUMS;
+ int ord = 1, gen = 1;
+
+ /* What usage? */
+ if (MATCH (dfn_lbl, spec))
+ usage = DINFO_USAGE_DFN;
+ else if (MATCH (dir_lbl, spec))
+ usage = DINFO_USAGE_DIR_USE;
+ else if (MATCH (ind_lbl, spec))
+ usage = DINFO_USAGE_IND_USE;
+
+ /* Generics or not? */
+ if (MATCH (ord_lbl, spec))
+ gen = 0;
+ else if (MATCH (gen_lbl, spec))
+ ord = 0;
+
+ /* What allowable environment? */
+ if (MATCH (none_lbl, spec))
+ files = DINFO_STRUCT_FILE_NONE;
+ else if (MATCH (any_lbl, spec))
+ files = DINFO_STRUCT_FILE_ANY;
+ else if (MATCH (sys_lbl, spec))
+ files = DINFO_STRUCT_FILE_SYS;
+ else if (MATCH (base_lbl, spec))
+ files = DINFO_STRUCT_FILE_BASE;
+ else
+ error ("argument %qs to %<-femit-struct-debug-detailed%> not recognized",
+ spec);
+
+ /* Effect the specification. */
+ if (usage == DINFO_USAGE_NUM_ENUMS)
+ {
+ if (ord)
+ {
+ debug_struct_ordinary[DINFO_USAGE_DFN] = files;
+ debug_struct_ordinary[DINFO_USAGE_DIR_USE] = files;
+ debug_struct_ordinary[DINFO_USAGE_IND_USE] = files;
+ }
+ if (gen)
+ {
+ debug_struct_generic[DINFO_USAGE_DFN] = files;
+ debug_struct_generic[DINFO_USAGE_DIR_USE] = files;
+ debug_struct_generic[DINFO_USAGE_IND_USE] = files;
+ }
+ }
+ else
+ {
+ if (ord)
+ debug_struct_ordinary[usage] = files;
+ if (gen)
+ debug_struct_generic[usage] = files;
+ }
+
+ if (*spec == ',')
+ set_struct_debug_option (spec+1);
+ else
+ {
+ /* No more -femit-struct-debug-detailed specifications.
+ Do final checks. */
+ if (*spec != '\0')
+ error ("argument %qs to %<-femit-struct-debug-detailed%> unknown",
+ spec);
+ if (debug_struct_ordinary[DINFO_USAGE_DIR_USE]
+ < debug_struct_ordinary[DINFO_USAGE_IND_USE]
+ || debug_struct_generic[DINFO_USAGE_DIR_USE]
+ < debug_struct_generic[DINFO_USAGE_IND_USE])
+ error ("%<-femit-struct-debug-detailed=dir:...%> must allow at least"
+ " as much as %<-femit-struct-debug-detailed=ind:...%>");
+ }
+}
+
+/* Find the base name of a path, stripping off both directories and
+ a single final extension. */
+static int
+base_of_path (const char *path, const char **base_out)
+{
+ const char *base = path;
+ const char *dot = 0;
+ const char *p = path;
+ char c = *p;
+ while (c)
+ {
+ if (IS_DIR_SEPARATOR(c))
+ {
+ base = p + 1;
+ dot = 0;
+ }
+ else if (c == '.')
+ dot = p;
+ c = *++p;
+ }
+ if (!dot)
+ dot = p;
+ *base_out = base;
+ return dot - base;
+}
+
+/* Match the base name of a file to the base name of a compilation unit. */
+
+static const char *main_input_basename;
+static int main_input_baselength;
+
+static int
+matches_main_base (const char *path)
+{
+ /* Cache the last query. */
+ static const char *last_path = NULL;
+ static int last_match = 0;
+ if (path != last_path)
+ {
+ const char *base;
+ int length = base_of_path (path, &base);
+ last_path = path;
+ last_match = (length == main_input_baselength
+ && memcmp (base, main_input_basename, length) == 0);
+ }
+ return last_match;
+}
+
+#ifdef DEBUG_DEBUG_STRUCT
+
+static int
+dump_struct_debug (tree type, enum debug_info_usage usage,
+ enum debug_struct_file criterion, int generic,
+ int matches, int result)
+{
+ /* Find the type name. */
+ tree type_decl = TYPE_STUB_DECL (type);
+ tree t = type_decl;
+ const char *name = 0;
+ if (TREE_CODE (t) == TYPE_DECL)
+ t = DECL_NAME (t);
+ if (t)
+ name = IDENTIFIER_POINTER (t);
+
+ fprintf (stderr, " struct %d %s %s %s %s %d %p %s\n",
+ criterion,
+ DECL_IN_SYSTEM_HEADER (type_decl) ? "sys" : "usr",
+ matches ? "bas" : "hdr",
+ generic ? "gen" : "ord",
+ usage == DINFO_USAGE_DFN ? ";" :
+ usage == DINFO_USAGE_DIR_USE ? "." : "*",
+ result,
+ (void*) type_decl, name);
+ return result;
+}
+#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
+ dump_struct_debug (type, usage, criterion, generic, matches, result)
+
+#else
+
+#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
+ (result)
+
+#endif
+
+
+bool
+should_emit_struct_debug (tree type, enum debug_info_usage usage)
+{
+ enum debug_struct_file criterion;
+ tree type_decl;
+ bool generic = lang_hooks.types.generic_p (type);
+
+ if (generic)
+ criterion = debug_struct_generic[usage];
+ else
+ criterion = debug_struct_ordinary[usage];
+
+ if (criterion == DINFO_STRUCT_FILE_NONE)
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
+ if (criterion == DINFO_STRUCT_FILE_ANY)
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
+
+ type_decl = TYPE_STUB_DECL (type);
+
+ if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
+
+ if (matches_main_base (DECL_SOURCE_FILE (type_decl)))
+ return DUMP_GSTRUCT (type, usage, criterion, generic, true, true);
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
+}
+
/* Nonzero means use GNU-only extensions in the generated symbolic
debugging information. Currently, this only has an effect when
write_symbols is set to DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
@@ -108,6 +363,15 @@
static bool flag_value_profile_transformations_set;
static bool flag_peel_loops_set, flag_branch_probabilities_set;
+/* Functions excluded from profiling. */
+
+typedef char *char_p; /* For DEF_VEC_P. */
+DEF_VEC_P(char_p);
+DEF_VEC_ALLOC_P(char_p,heap);
+
+static VEC(char_p,heap) *flag_instrument_functions_exclude_functions;
+static VEC(char_p,heap) *flag_instrument_functions_exclude_files;
+
/* Input file names. */
const char **in_fnames;
unsigned num_in_fnames;
@@ -354,6 +618,87 @@
in_fnames[num_in_fnames - 1] = filename;
}
+/* Add functions or file names to a vector of names to exclude from
+ instrumentation. */
+
+static void
+add_instrument_functions_exclude_list (VEC(char_p,heap) **pvec,
+ const char* arg)
+{
+ char *tmp;
+ char *r;
+ char *w;
+ char *token_start;
+
+ /* We never free this string. */
+ tmp = xstrdup (arg);
+
+ r = tmp;
+ w = tmp;
+ token_start = tmp;
+
+ while (*r != '\0')
+ {
+ if (*r == ',')
+ {
+ *w++ = '\0';
+ ++r;
+ VEC_safe_push (char_p, heap, *pvec, token_start);
+ token_start = w;
+ }
+ if (*r == '\\' && r[1] == ',')
+ {
+ *w++ = ',';
+ r += 2;
+ }
+ else
+ *w++ = *r++;
+ }
+ if (*token_start != '\0')
+ VEC_safe_push (char_p, heap, *pvec, token_start);
+}
+
+/* Return whether we should exclude FNDECL from instrumentation. */
+
+bool
+flag_instrument_functions_exclude_p (tree fndecl)
+{
+ if (VEC_length (char_p, flag_instrument_functions_exclude_functions) > 0)
+ {
+ const char *name;
+ int i;
+ char *s;
+
+ name = lang_hooks.decl_printable_name (fndecl, 0);
+ for (i = 0;
+ VEC_iterate (char_p, flag_instrument_functions_exclude_functions,
+ i, s);
+ ++i)
+ {
+ if (strstr (name, s) != NULL)
+ return true;
+ }
+ }
+
+ if (VEC_length (char_p, flag_instrument_functions_exclude_files) > 0)
+ {
+ const char *name;
+ int i;
+ char *s;
+
+ name = DECL_SOURCE_FILE (fndecl);
+ for (i = 0;
+ VEC_iterate (char_p, flag_instrument_functions_exclude_files, i, s);
+ ++i)
+ {
+ if (strstr (name, s) != NULL)
+ return true;
+ }
+ }
+
+ return false;
+}
+
/* Decode and handle the vector of command line options. LANG_MASK
contains has a single bit set representing the current
language. */
@@ -370,7 +715,11 @@
if (opt[0] != '-' || opt[1] == '\0')
{
if (main_input_filename == NULL)
+ {
main_input_filename = opt;
+ main_input_baselength
+ = base_of_path (main_input_filename, &main_input_basename);
+ }
add_input_filename (opt);
n = 1;
continue;
@@ -504,7 +853,7 @@
/* XXX: some issues with ports have been traced to -ftree-vrp.
So remove it from -O2 and above. Note that jdk1{5,6} are affected
and they build with w/-O3 - so we cannot just move it to -O3. */
- // flag_tree_vrp = 1;
+ /* flag_tree_vrp = 1; // See GCC tree-optimization/33099 */
if (!optimize_size)
{
@@ -725,7 +1074,15 @@
warn_larger_than = value != -1;
break;
+ case OPT_Wframe_larger_than_:
+ frame_larger_than_size = value;
+ warn_frame_larger_than = value != -1;
+ break;
+
case OPT_Wstrict_aliasing:
+ set_warn_strict_aliasing (value);
+ break;
+
case OPT_Wstrict_aliasing_:
warn_strict_aliasing = value;
break;
@@ -832,6 +1189,16 @@
set_param_value ("max-inline-insns-auto", value / 2);
break;
+ case OPT_finstrument_functions_exclude_function_list_:
+ add_instrument_functions_exclude_list
+ (&flag_instrument_functions_exclude_functions, arg);
+ break;
+
+ case OPT_finstrument_functions_exclude_file_list_:
+ add_instrument_functions_exclude_list
+ (&flag_instrument_functions_exclude_files, arg);
+ break;
+
case OPT_fmessage_length_:
pp_set_line_maximum_length (global_dc->printer, value);
break;
@@ -1094,6 +1461,20 @@
warn_unused_value = setting;
}
+/* Used to set the level of strict aliasing warnings,
+ when no level is specified (i.e., when -Wstrict-aliasing, and not
+ -Wstrict-aliasing=level was given).
+ ONOFF is assumed to take value 1 when -Wstrict-aliasing is specified,
+ and 0 otherwise. After calling this function, wstrict_aliasing will be
+ set to the default value of -Wstrict_aliasing=level, currently 3. */
+void
+set_warn_strict_aliasing (int onoff)
+{
+ gcc_assert (onoff == 0 || onoff == 1);
+ if (onoff != 0)
+ warn_strict_aliasing = 3;
+}
+
/* The following routines are useful in setting all the flags that
-ffast-math and -fno-fast-math imply. */
void
Modified: trunk/contrib/gcc/postreload-gcse.c
===================================================================
--- trunk/contrib/gcc4/postreload-gcse.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/postreload-gcse.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -197,8 +197,6 @@
static bool reg_killed_on_edge (rtx, edge);
static bool reg_used_on_edge (rtx, edge);
-static rtx reg_set_between_after_reload_p (rtx, rtx, rtx);
-static rtx reg_used_between_after_reload_p (rtx, rtx, rtx);
static rtx get_avail_load_store_reg (rtx);
static bool bb_has_well_behaved_predecessors (basic_block);
@@ -470,7 +468,23 @@
fprintf (file, "\n");
}
+/* Return true if register X is recorded as being set by an instruction
+ whose CUID is greater than the one given. */
+static bool
+reg_changed_after_insn_p (rtx x, int cuid)
+{
+ unsigned int regno, end_regno;
+
+ regno = REGNO (x);
+ end_regno = END_HARD_REGNO (x);
+ do
+ if (reg_avail_info[regno] > cuid)
+ return true;
+ while (++regno < end_regno);
+ return false;
+}
+
/* Return nonzero if the operands of expression X are unchanged
1) from the start of INSN's basic block up to but not including INSN
if AFTER_INSN is false, or
@@ -493,14 +507,9 @@
/* We are called after register allocation. */
gcc_assert (REGNO (x) < FIRST_PSEUDO_REGISTER);
if (after_insn)
- /* If the last CUID setting the insn is less than the CUID of
- INSN, then reg X is not changed in or after INSN. */
- return reg_avail_info[REGNO (x)] < INSN_CUID (insn);
+ return !reg_changed_after_insn_p (x, INSN_CUID (insn) - 1);
else
- /* Reg X is not set before INSN in the current basic block if
- we have not yet recorded the CUID of an insn that touches
- the reg. */
- return reg_avail_info[REGNO (x)] == 0;
+ return !reg_changed_after_insn_p (x, 0);
case MEM:
if (load_killed_in_block_p (INSN_CUID (insn), x, after_insn))
@@ -717,12 +726,28 @@
/* Finally, if this is a call, record all call clobbers. */
if (CALL_P (insn))
{
- unsigned int regno;
+ unsigned int regno, end_regno;
+ rtx link, x;
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if (TEST_HARD_REG_BIT (regs_invalidated_by_call, regno))
record_last_reg_set_info (insn, regno);
+ for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
+ if (GET_CODE (XEXP (link, 0)) == CLOBBER)
+ {
+ x = XEXP (XEXP (link, 0), 0);
+ if (REG_P (x))
+ {
+ gcc_assert (HARD_REGISTER_P (x));
+ regno = REGNO (x);
+ end_regno = END_HARD_REGNO (x);
+ do
+ record_last_reg_set_info (insn, regno);
+ while (++regno < end_regno);
+ }
+ }
+
if (! CONST_OR_PURE_CALL_P (insn))
record_last_mem_set_info (insn);
}
@@ -856,96 +881,6 @@
return false;
}
-
-/* Return the insn that sets register REG or clobbers it in between
- FROM_INSN and TO_INSN (exclusive of those two).
- Just like reg_set_between but for hard registers and not pseudos. */
-
-static rtx
-reg_set_between_after_reload_p (rtx reg, rtx from_insn, rtx to_insn)
-{
- rtx insn;
-
- /* We are called after register allocation. */
- gcc_assert (REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER);
-
- if (from_insn == to_insn)
- return NULL_RTX;
-
- for (insn = NEXT_INSN (from_insn);
- insn != to_insn;
- insn = NEXT_INSN (insn))
- if (INSN_P (insn))
- {
- if (set_of (reg, insn) != NULL_RTX)
- return insn;
- if ((CALL_P (insn)
- && call_used_regs[REGNO (reg)])
- || find_reg_fusage (insn, CLOBBER, reg))
- return insn;
-
- if (FIND_REG_INC_NOTE (insn, reg))
- return insn;
- }
-
- return NULL_RTX;
-}
-
-/* Return the insn that uses register REG in between FROM_INSN and TO_INSN
- (exclusive of those two). Similar to reg_used_between but for hard
- registers and not pseudos. */
-
-static rtx
-reg_used_between_after_reload_p (rtx reg, rtx from_insn, rtx to_insn)
-{
- rtx insn;
-
- /* We are called after register allocation. */
- gcc_assert (REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER);
-
- if (from_insn == to_insn)
- return NULL_RTX;
-
- for (insn = NEXT_INSN (from_insn);
- insn != to_insn;
- insn = NEXT_INSN (insn))
- if (INSN_P (insn))
- {
- if (reg_overlap_mentioned_p (reg, PATTERN (insn))
- || (CALL_P (insn)
- && call_used_regs[REGNO (reg)])
- || find_reg_fusage (insn, USE, reg)
- || find_reg_fusage (insn, CLOBBER, reg))
- return insn;
-
- if (FIND_REG_INC_NOTE (insn, reg))
- return insn;
- }
-
- return NULL_RTX;
-}
-
-/* Return true if REG is used, set, or killed between the beginning of
- basic block BB and UP_TO_INSN. Caches the result in reg_avail_info. */
-
-static bool
-reg_set_or_used_since_bb_start (rtx reg, basic_block bb, rtx up_to_insn)
-{
- rtx insn, start = PREV_INSN (BB_HEAD (bb));
-
- if (reg_avail_info[REGNO (reg)] != 0)
- return true;
-
- insn = reg_used_between_after_reload_p (reg, start, up_to_insn);
- if (! insn)
- insn = reg_set_between_after_reload_p (reg, start, up_to_insn);
-
- if (insn)
- reg_avail_info[REGNO (reg)] = INSN_CUID (insn);
-
- return insn != NULL_RTX;
-}
-
/* Return the loaded/stored register of a load/store instruction. */
static rtx
@@ -1037,7 +972,8 @@
/* Check that the loaded register is not used, set, or killed from the
beginning of the block. */
- if (reg_set_or_used_since_bb_start (dest, bb, insn))
+ if (reg_changed_after_insn_p (dest, 0)
+ || reg_used_between_p (dest, PREV_INSN (BB_HEAD (bb)), insn))
return;
/* Check potential for replacing load with copy for predecessors. */
@@ -1068,8 +1004,7 @@
avail_insn = NULL;
continue;
}
- if (! reg_set_between_after_reload_p (avail_reg, avail_insn,
- next_pred_bb_end))
+ if (!reg_set_between_p (avail_reg, avail_insn, next_pred_bb_end))
/* AVAIL_INSN remains non-null. */
break;
else
Modified: trunk/contrib/gcc/print-rtl.c
===================================================================
--- trunk/contrib/gcc4/print-rtl.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/print-rtl.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -606,6 +606,11 @@
case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break;
default: gcc_unreachable ();
}
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ if (LABEL_ALIGN_LOG (in_rtx) > 0)
+ fprintf (outfile, " [log_align %u skip %u]", LABEL_ALIGN_LOG (in_rtx),
+ LABEL_MAX_SKIP (in_rtx));
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
break;
default:
Modified: trunk/contrib/gcc/print-tree.c
===================================================================
--- trunk/contrib/gcc4/print-tree.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/print-tree.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -302,6 +302,10 @@
fputs (" static", file);
if (TREE_DEPRECATED (node))
fputs (" deprecated", file);
+ /* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) */
+ if (TREE_UNAVAILABLE (node))
+ fputs (" unavailable", file);
+ /* APPLE LOCAL end "unavailable" attribute (Radar 2809697) */
if (TREE_VISITED (node))
fputs (" visited", file);
if (TREE_LANG_FLAG_0 (node))
@@ -439,18 +443,16 @@
|| DECL_INLINE (node) || DECL_BUILT_IN (node))
indent_to (file, indent + 3);
- if (TREE_CODE (node) != FUNCTION_DECL)
+ if (DECL_USER_ALIGN (node))
+ fprintf (file, " user");
+
+ fprintf (file, " align %d", DECL_ALIGN (node));
+ if (TREE_CODE (node) == FIELD_DECL)
+ fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
+ DECL_OFFSET_ALIGN (node));
+
+ if (TREE_CODE (node) == FUNCTION_DECL && DECL_BUILT_IN (node))
{
- if (DECL_USER_ALIGN (node))
- fprintf (file, " user");
-
- fprintf (file, " align %d", DECL_ALIGN (node));
- if (TREE_CODE (node) == FIELD_DECL)
- fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
- DECL_OFFSET_ALIGN (node));
- }
- else if (DECL_BUILT_IN (node))
- {
if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));
else
Modified: trunk/contrib/gcc/regs.h
===================================================================
--- trunk/contrib/gcc4/regs.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/regs.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -239,5 +239,41 @@
/* Specify number of hard registers given machine mode occupy. */
extern unsigned char hard_regno_nregs[FIRST_PSEUDO_REGISTER][MAX_MACHINE_MODE];
+/* Return an exclusive upper bound on the registers occupied by hard
+ register (reg:MODE REGNO). */
+static inline unsigned int
+end_hard_regno (enum machine_mode mode, unsigned int regno)
+{
+ return regno + hard_regno_nregs[regno][(int) mode];
+}
+
+/* Likewise for hard register X. */
+
+#define END_HARD_REGNO(X) end_hard_regno (GET_MODE (X), REGNO (X))
+
+/* Likewise for hard or pseudo register X. */
+
+#define END_REGNO(X) (HARD_REGISTER_P (X) ? END_HARD_REGNO (X) : REGNO (X) + 1)
+
+
+/* Return true if (reg:MODE REGNO) includes an element of REGS. */
+
+static inline bool
+overlaps_hard_reg_set_p (const HARD_REG_SET regs, enum machine_mode mode,
+ unsigned int regno)
+{
+ unsigned int end_regno;
+
+ if (TEST_HARD_REG_BIT (regs, regno))
+ return true;
+
+ end_regno = end_hard_regno (mode, regno);
+ while (++regno < end_regno)
+ if (TEST_HARD_REG_BIT (regs, regno))
+ return true;
+
+ return false;
+}
+
#endif /* GCC_REGS_H */
Modified: trunk/contrib/gcc/reload1.c
===================================================================
--- trunk/contrib/gcc4/reload1.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/reload1.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2555,6 +2555,7 @@
case CTZ:
case POPCOUNT:
case PARITY:
+ case BSWAP:
new = eliminate_regs_1 (XEXP (x, 0), mem_mode, insn, false);
if (new != XEXP (x, 0))
return gen_rtx_fmt_e (code, GET_MODE (x), new);
@@ -2775,6 +2776,7 @@
case CTZ:
case POPCOUNT:
case PARITY:
+ case BSWAP:
elimination_effects (XEXP (x, 0), mem_mode);
return;
@@ -6236,16 +6238,24 @@
transfer_replacements (i, j);
}
- /* If this is now RELOAD_OTHER, look for any reloads that load
- parts of this operand and set them to RELOAD_FOR_OTHER_ADDRESS
- if they were for inputs, RELOAD_OTHER for outputs. Note that
- this test is equivalent to looking for reloads for this operand
- number. */
- /* We must take special care with RELOAD_FOR_OUTPUT_ADDRESS; it may
- share registers with a RELOAD_FOR_INPUT, so we can not change it
- to RELOAD_FOR_OTHER_ADDRESS. We should never need to, since we
- do not modify RELOAD_FOR_OUTPUT. */
+ /* If this is now RELOAD_OTHER, look for any reloads that
+ load parts of this operand and set them to
+ RELOAD_FOR_OTHER_ADDRESS if they were for inputs,
+ RELOAD_OTHER for outputs. Note that this test is
+ equivalent to looking for reloads for this operand
+ number.
+ We must take special care with RELOAD_FOR_OUTPUT_ADDRESS;
+ it may share registers with a RELOAD_FOR_INPUT, so we can
+ not change it to RELOAD_FOR_OTHER_ADDRESS. We should
+ never need to, since we do not modify RELOAD_FOR_OUTPUT.
+
+ It is possible that the RELOAD_FOR_OPERAND_ADDRESS
+ instruction is assigned the same register as the earlier
+ RELOAD_FOR_OTHER_ADDRESS instruction. Merging these two
+ instructions will cause the RELOAD_FOR_OTHER_ADDRESS
+ instruction to be deleted later on. */
+
if (rld[i].when_needed == RELOAD_OTHER)
for (j = 0; j < n_reloads; j++)
if (rld[j].in != 0
@@ -6252,6 +6262,7 @@
&& rld[j].when_needed != RELOAD_OTHER
&& rld[j].when_needed != RELOAD_FOR_OTHER_ADDRESS
&& rld[j].when_needed != RELOAD_FOR_OUTPUT_ADDRESS
+ && rld[j].when_needed != RELOAD_FOR_OPERAND_ADDRESS
&& (! conflicting_input
|| rld[j].when_needed == RELOAD_FOR_INPUT_ADDRESS
|| rld[j].when_needed == RELOAD_FOR_INPADDR_ADDRESS)
Modified: trunk/contrib/gcc/rtl.def
===================================================================
--- trunk/contrib/gcc4/rtl.def 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/rtl.def 2018-06-04 17:30:21 UTC (rev 10405)
@@ -139,9 +139,13 @@
4: is used in jump.c for the use-count of the label.
5: is used in flow.c to point to the chain of label_ref's to this label.
6: is a number that is unique in the entire compilation.
- 7: is the user-given name of the label, if any. */
-DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuuB00is", RTX_EXTRA)
+ APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+ 7: is the user-given name of the label, if any.
+ 8: is the alignment of the label, made up of two parts,
+ LABEL_ALIGNMENT and LABEL_MAX_SKIP. */
+DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuuB00isi", RTX_EXTRA)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
#ifdef USE_MAPPED_LOCATION
/* Say where in the code a source line starts, for symbol table's sake.
Operand:
@@ -567,6 +571,9 @@
/* Square root */
DEF_RTL_EXPR(SQRT, "sqrt", "e", RTX_UNARY)
+/* Swap bytes. */
+DEF_RTL_EXPR(BSWAP, "bswap", "e", RTX_UNARY)
+
/* Find first bit that is set.
Value is 1 + number of trailing zeros in the arg.,
or 0 if arg is 0. */
Modified: trunk/contrib/gcc/rtl.h
===================================================================
--- trunk/contrib/gcc4/rtl.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/rtl.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -908,6 +908,15 @@
of LABEL_REFs that point at it, so unused labels can be deleted. */
#define LABEL_NUSES(RTX) XCINT (RTX, 4, CODE_LABEL)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+/* The alignment of the label, as the log-base-2 of the alignment in bytes. */
+#define LABEL_ALIGN_LOG(RTX) (XCUINT (RTX, 8, CODE_LABEL) & 0xFF)
+/* The maximum number of bytes to skip to achieve that alignment. */
+#define LABEL_MAX_SKIP(RTX) (XCUINT (RTX, 8, CODE_LABEL) >> 8)
+#define SET_LABEL_ALIGN(RTX, ALIGN, MAX_SKIP) \
+ (XCUINT (RTX, 8, CODE_LABEL) = (ALIGN) | ((MAX_SKIP) << 8))
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
/* Labels carry a two-bit field composed of the ->jump and ->call
bits. This field indicates whether the label is an alternate
entry point, and if so, what kind. */
Modified: trunk/contrib/gcc/rtlanal.c
===================================================================
--- trunk/contrib/gcc4/rtlanal.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/rtlanal.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -748,8 +748,8 @@
|| (CALL_P (insn)
&& ((REG_P (reg)
&& REGNO (reg) < FIRST_PSEUDO_REGISTER
- && TEST_HARD_REG_BIT (regs_invalidated_by_call,
- REGNO (reg)))
+ && overlaps_hard_reg_set_p (regs_invalidated_by_call,
+ GET_MODE (reg), REGNO (reg)))
|| MEM_P (reg)
|| find_reg_fusage (insn, CLOBBER, reg)))))
return 1;
Modified: trunk/contrib/gcc/sched-vis.c
===================================================================
--- trunk/contrib/gcc4/sched-vis.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/sched-vis.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -430,7 +430,10 @@
if (FLOAT_MODE_P (GET_MODE (x)))
real_to_decimal (t, CONST_DOUBLE_REAL_VALUE (x), sizeof (t), 0, 1);
else
- sprintf (t, "<0x%lx,0x%lx>", (long) CONST_DOUBLE_LOW (x), (long) CONST_DOUBLE_HIGH (x));
+ sprintf (t,
+ "<" HOST_WIDE_INT_PRINT_HEX "," HOST_WIDE_INT_PRINT_HEX ">",
+ (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x),
+ (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x));
cur = safe_concat (buf, cur, t);
break;
case CONST_STRING:
Modified: trunk/contrib/gcc/simplify-rtx.c
===================================================================
--- trunk/contrib/gcc4/simplify-rtx.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/simplify-rtx.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1044,6 +1044,9 @@
val &= 1;
break;
+ case BSWAP:
+ return 0;
+
case TRUNCATE:
val = arg0;
break;
@@ -4887,4 +4890,3 @@
}
return NULL;
}
-
Modified: trunk/contrib/gcc/stmt.c
===================================================================
--- trunk/contrib/gcc4/stmt.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/stmt.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -136,9 +136,19 @@
if (!DECL_RTL_SET_P (label))
{
rtx r = gen_label_rtx ();
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ unsigned align = DECL_ALIGN_UNIT (label);
+ int align_log2 = exact_log2 (align);
+
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
SET_DECL_RTL (label, r);
if (FORCED_LABEL (label) || DECL_NONLOCAL (label))
LABEL_PRESERVE_P (r) = 1;
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+
+ if (align_log2 >= 0 && align_log2 <= 0xFF)
+ SET_LABEL_ALIGN (r, align_log2, align - 1);
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
}
return DECL_RTL (label);
@@ -194,11 +204,12 @@
/* Specify the location in the RTL code of a label LABEL,
which is a LABEL_DECL tree node.
- This is used for the kind of label that the user can jump to with a
- goto statement, and for alternatives of a switch or case statement.
- RTL labels generated for loops and conditionals don't go through here;
- they are generated directly at the RTL level, by other functions below.
+ APPLE LOCAL begin for-fsf-4_4 3274130 5295549
+ This is used for those labels created by the front-end that survive
+ through CFG generation, including all user labels. (Some labels
+ are removed by cleanup_dead_labels in tree-cfg.c.)
+ APPLE LOCAL end for-fsf-4_4 3274130 5295549
Note that this has nothing to do with defining label *names*.
Languages vary in how they do that and what that even means. */
Modified: trunk/contrib/gcc/stor-layout.c
===================================================================
--- trunk/contrib/gcc4/stor-layout.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/stor-layout.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1684,6 +1684,8 @@
case POINTER_TYPE:
case REFERENCE_TYPE:
+ /* APPLE LOCAL blocks */
+ case BLOCK_POINTER_TYPE:
{
enum machine_mode mode = ((TREE_CODE (type) == REFERENCE_TYPE
Modified: trunk/contrib/gcc/stub-objc.c
===================================================================
--- trunk/contrib/gcc4/stub-objc.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/stub-objc.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -45,6 +45,13 @@
return 0;
}
+/* APPLE LOCAL begin radar 4133425 */
+bool objc_diagnose_private_ivar (tree ARG_UNUSED (arg))
+{
+ return false;
+}
+/* APPLE LOCAL end radar 4133425 */
+
tree
objc_lookup_ivar (tree other, tree ARG_UNUSED (arg))
{
@@ -56,6 +63,28 @@
objc_check_decl (tree ARG_UNUSED (decl))
{
}
+
+/* APPLE LOCAL begin radar 4281748 */
+void
+objc_check_global_decl (tree ARG_UNUSED (decl))
+{
+}
+/* APPLE LOCAL end radar 4281748 */
+
+/* APPLE LOCAL begin radar 4330422 */
+tree
+objc_non_volatilized_type (tree type)
+{
+ return type;
+}
+/* APPLE LOCAL end radar 4330422 */
+
+/* APPLE LOCAL begin radar 4697411 */
+void
+objc_volatilize_component_ref (tree ARG_UNUSED (cref), tree ARG_UNUSED (type))
+{
+}
+/* APPLE LOCAL end radar 4697411 */
int
objc_is_reserved_word (tree ARG_UNUSED (ident))
@@ -63,13 +92,34 @@
return 0;
}
+/* APPLE LOCAL begin 4154928 */
+tree
+objc_common_type (tree ARG_UNUSED (type1), tree ARG_UNUSED (type2))
+{
+ return false;
+}
+/* APPLE LOCAL end 4154928 */
+
bool
objc_compare_types (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
- int ARG_UNUSED (argno), tree ARG_UNUSED (callee))
+ /* APPLE LOCAL begin radar 6231433 */
+ int ARG_UNUSED (argno), tree ARG_UNUSED (callee),
+ const char * ARG_UNUSED (message))
+ /* APPLE LOCAL end radar 6231433 */
{
return false;
}
+/* APPLE LOCAL begin radar 4229905 - radar 6231433 */
+bool
+objc_have_common_type (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
+ int ARG_UNUSED (argno), tree ARG_UNUSED (callee),
+ const char * ARG_UNUSED (message))
+{
+ return false;
+}
+/* APPLE LOCAL end radar 4229905 - radar 6231433 */
+
void
objc_volatilize_decl (tree ARG_UNUSED (decl))
{
@@ -104,20 +154,26 @@
}
void
-objc_declare_protocols (tree ARG_UNUSED (list))
+/* APPLE LOCAL begin radar 4947311 - protocol attributes */
+objc_declare_protocols (tree ARG_UNUSED (list), tree ARG_UNUSED (attributes))
{
}
void
objc_start_protocol (tree ARG_UNUSED (proto),
- tree ARG_UNUSED (protorefs))
+ tree ARG_UNUSED (protorefs),
+ tree ARG_UNUSED (attributes))
{
}
+/* APPLE LOCAL end radar 4947311 - protocol attributes */
void
objc_start_class_interface (tree ARG_UNUSED (name),
tree ARG_UNUSED (super),
- tree ARG_UNUSED (protos))
+/* APPLE LOCAL begin radar 4548636 */
+ tree ARG_UNUSED (protos),
+ tree ARG_UNUSED (attributes))
+/* APPLE LOCAL end radar 4548636 */
{
}
@@ -181,12 +237,18 @@
}
void
-objc_add_method_declaration (tree ARG_UNUSED (signature))
+/* APPLE LOCAL begin radar 3803157 - objc attribute */
+objc_add_method_declaration (tree ARG_UNUSED (signature),
+ tree ARG_UNUSED (attribute))
+/* APPLE LOCAL end radar 3803157 - objc attribute */
{
}
void
-objc_start_method_definition (tree ARG_UNUSED (signature))
+/* APPLE LOCAL begin radar 3803157 - objc attribute */
+objc_start_method_definition (tree ARG_UNUSED (signature),
+ tree ARG_UNUSED (attribute))
+/* APPLE LOCAL end radar 3803157 - objc attribute */
{
}
@@ -198,7 +260,10 @@
tree
objc_build_keyword_decl (tree ARG_UNUSED (selector),
tree ARG_UNUSED (typename),
- tree ARG_UNUSED (identifier))
+ /* APPLE LOCAL begin radar 4157812 */
+ tree ARG_UNUSED (identifier),
+ tree ARG_UNUSED (attribute))
+ /* APPLE LOCAL end radar 4157812 */
{
return 0;
}
@@ -248,7 +313,19 @@
return 0;
}
+/* APPLE LOCAL begin radar 4291785 */
tree
+objc_get_interface_ivars (tree ARG_UNUSED (fieldlist))
+{
+ return 0;
+}
+void
+objc_detect_field_duplicates (tree ARG_UNUSED (fieldlist))
+{
+}
+/* APPLE LOCAL end radar 4291785 */
+
+tree
objc_get_protocol_qualified_type (tree ARG_UNUSED (name),
tree ARG_UNUSED (protos))
{
@@ -273,7 +350,50 @@
return 1;
}
+/* APPLE LOCAL begin C* language */
+void
+objc_set_method_opt (int ARG_UNUSED (opt))
+{
+}
+
tree
+objc_build_component_ref (tree ARG_UNUSED (datum), tree ARG_UNUSED (component))
+{
+ return 0;
+}
+
+tree
+objc_build_foreach_components (tree ARG_UNUSED (receiver),
+ tree *ARG_UNUSED (enumState_decl),
+ tree *ARG_UNUSED (items_decl),
+ tree *ARG_UNUSED (limit_decl),
+ tree *ARG_UNUSED (startMutations_decl),
+ tree *ARG_UNUSED (counter_decl),
+ tree *ARG_UNUSED (countByEnumeratingWithState))
+{
+ return 0;
+}
+/* APPLE LOCAL end C* language */
+
+/* APPLE LOCAL begin C* property (Radar 4436866) */
+void
+objc_set_property_attr (int ARG_UNUSED (code), tree ARG_UNUSED (identifier))
+{
+}
+void
+objc_add_property_variable (tree ARG_UNUSED (prop))
+{
+}
+/* APPLE LOCAL radar 5285911 */
+/* Stub for objc_build_getter_call is removed. */
+tree
+objc_build_setter_call (tree ARG_UNUSED (lhs), tree ARG_UNUSED (rhs))
+{
+ return 0;
+}
+/* APPLE LOCAL end C* property (Radar 4436866) */
+
+tree
objc_get_class_ivars (tree ARG_UNUSED (name))
{
return 0;
@@ -326,3 +446,143 @@
{
return 0;
}
+/* APPLE LOCAL begin radar 5276085 */
+void objc_weak_reference_expr (tree* ARG_UNUSED (expr))
+{
+}
+
+tree
+objc_build_weak_reference_tree (tree expr)
+{
+ return expr;
+}
+/* APPLE LOCAL end radar 5276085 */
+
+/* APPLE LOCAL begin C* warnings to easy porting to new abi */
+void
+diagnose_selector_cast (tree ARG_UNUSED (cast_type), tree ARG_UNUSED (sel_exp))
+{
+}
+/* APPLE LOCAL end C* warnings to easy porting to new abi */
+
+/* APPLE LOCAL begin radar 4441049 */
+tree
+objc_v2_component_ref_field_offset (tree ARG_UNUSED (exp))
+{
+ return 0;
+}
+
+tree
+objc_v2_bitfield_ivar_bitpos (tree ARG_UNUSED (exp))
+{
+ return 0;
+}
+/* APPLE LOCAL end radar 4441049 */
+/* APPLE LOCAL begin radar 4507230 */
+bool
+objc_type_valid_for_messaging (tree ARG_UNUSED (exp))
+{
+ return false;
+}
+/* APPLE LOCAL end radar 4507230 */
+/* APPLE LOCAL begin radar 3803157 - objc attribute */
+bool
+objc_method_decl (enum tree_code ARG_UNUSED (opcode))
+{
+ return false;
+}
+/* APPLE LOCAL end radar 3803157 - objc attribute */
+
+/* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
+void
+objc_finish_foreach_loop (location_t ARG_UNUSED (location), tree ARG_UNUSED (cond),
+ tree ARG_UNUSED (for_body), tree ARG_UNUSED (blab),
+ tree ARG_UNUSED (clab))
+{
+ return;
+}
+/* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
+/* APPLE LOCAL begin radar 5847976 */
+int
+objc_is_gcable_type (tree ARG_UNUSED (type))
+{
+ return 0;
+}
+/* APPLE LOCAL end radar 5847976 */
+/* APPLE LOCAL begin radar 4592503 */
+void
+objc_checkon_weak_attribute (tree ARG_UNUSED (decl))
+{
+ return;
+}
+/* APPLE LOCAL end radar 4592503 */
+/* APPLE LOCAL begin radar 4712269 */
+tree
+objc_build_incr_decr_setter_call (enum tree_code ARG_UNUSED (code),
+ tree ARG_UNUSED (lhs),
+ tree ARG_UNUSED (inc))
+{
+ return NULL_TREE;
+}
+/* APPLE LOCAL end radar 4712269 */
+/* APPLE LOCAL begin objc new property */
+void objc_declare_property_impl (int ARG_UNUSED (code),
+ tree ARG_UNUSED (tree_list))
+{
+}
+/* APPLE LOCAL begin radar 5285911 */
+tree
+objc_build_property_reference_expr (tree ARG_UNUSED (datum),
+ tree ARG_UNUSED (component))
+{
+ return 0;
+}
+bool
+objc_property_reference_expr (tree ARG_UNUSED (exp))
+{
+ return false;
+}
+/* APPLE LOCAL end radar 5285911 */
+/* APPLE LOCAL end objc new property */
+/* APPLE LOCAL begin radar 4985544 */
+bool
+objc_check_format_nsstring (tree ARG_UNUSED (argument),
+ unsigned HOST_WIDE_INT ARG_UNUSED (format_num),
+ bool * ARG_UNUSED(no_add_attrs))
+{
+ return false;
+}
+/* APPLE LOCAL end radar 4985544 */
+/* APPLE LOCAL begin radar 5202926 */
+bool
+objc_anonymous_local_objc_name (const char * ARG_UNUSED (name))
+{
+ return false;
+}
+/* APPLE LOCAL begin radar 5195402 */
+bool
+objc_check_nsstring_pointer_type (tree ARG_UNUSED (type))
+{
+ return false;
+}
+/* APPLE LOCAL end radar 5195402 */
+/* APPLE LOCAL end radar 5202926 */
+
+/* APPLE LOCAL begin radar 5782740 - blocks */
+bool block_requires_copying (tree exp)
+{
+ /* APPLE LOCAL begin radar 6175959 */
+ tree type = TREE_TYPE (exp);
+ return TREE_CODE (type) == BLOCK_POINTER_TYPE
+ || (POINTER_TYPE_P (type)
+ && lookup_attribute ("NSObject", TYPE_ATTRIBUTES (type)));
+ /* APPLE LOCAL end radar 6175959 */
+}
+/* APPLE LOCAL end radar 5782740 - blocks */
+
+/* APPLE LOCAL begin radar 5802025 */
+tree objc_build_property_getter_func_call (tree object)
+{
+ return object;
+}
+/* APPLE LOCAL end radar 5802025 */
Modified: trunk/contrib/gcc/target-def.h
===================================================================
--- trunk/contrib/gcc4/target-def.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/target-def.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -587,6 +587,10 @@
#define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_true
#endif
+#ifndef TARGET_CXX_LIBRARY_RTTI_COMDAT
+#define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_true
+#endif
+
#ifndef TARGET_CXX_USE_AEABI_ATEXIT
#define TARGET_CXX_USE_AEABI_ATEXIT hook_bool_void_false
#endif
@@ -606,6 +610,7 @@
TARGET_CXX_KEY_METHOD_MAY_BE_INLINE, \
TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY, \
TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT, \
+ TARGET_CXX_LIBRARY_RTTI_COMDAT, \
TARGET_CXX_USE_AEABI_ATEXIT, \
TARGET_CXX_ADJUST_CLASS_AT_DEFINITION \
}
Modified: trunk/contrib/gcc/target.h
===================================================================
--- trunk/contrib/gcc4/target.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/target.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -783,6 +783,10 @@
class data for classes whose virtual table will be emitted in
only one translation unit will not be COMDAT. */
bool (*class_data_always_comdat) (void);
+ /* Returns true (the default) if the RTTI for the basic types,
+ which is always defined in the C++ runtime, should be COMDAT;
+ false if it should not be COMDAT. */
+ bool (*library_rtti_comdat) (void);
/* Returns true if __aeabi_atexit should be used to register static
destructors. */
bool (*use_aeabi_atexit) (void);
Modified: trunk/contrib/gcc/targhooks.c
===================================================================
--- trunk/contrib/gcc4/targhooks.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/targhooks.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -95,6 +95,18 @@
#endif
}
+/* APPLE LOCAL begin radar 4781080 */
+bool
+default_objc_fpreturn_msgcall (tree type, bool no_long_double)
+{
+#ifndef OBJC_FPRETURN_MSGCALL
+ return type == NULL_TREE && no_long_double;
+#else
+ return OBJC_FPRETURN_MSGCALL (type, no_long_double);
+#endif
+}
+/* APPLE LOCAL end radar 4781080 */
+
rtx
default_expand_builtin_saveregs (void)
{
Modified: trunk/contrib/gcc/tlink.c
===================================================================
--- trunk/contrib/gcc4/tlink.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tlink.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -381,7 +381,7 @@
FILE *stream = fopen (f->key, "r");
if (tlink_verbose >= 2)
- fprintf (stderr, _("collect: reading %s\n"), f->key);
+ fprintf (stderr, "%s", _("collect: reading %s\n"), f->key);
while (fscanf (stream, "%c ", &c) == 1)
{
Modified: trunk/contrib/gcc/toplev.c
===================================================================
--- trunk/contrib/gcc4/toplev.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/toplev.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -20,7 +20,7 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/10/contrib/gcc/toplev.c 261188 2014-01-26 19:49:54Z pfg $ */
/* This is the top level of cc1/c++.
It parses command args, opens files, invokes the various passes
@@ -369,10 +369,6 @@
int align_labels_max_skip;
int align_functions_log;
-/* Like align_functions_log above, but used by front-ends to force the
- minimum function alignment. Zero means no alignment is forced. */
-int force_align_functions_log;
-
typedef struct
{
const char *const string;
@@ -950,6 +946,46 @@
}
}
+/* APPLE LOCAL begin "unavailable" attribute (radar 2809697) --ilr */
+/* Warn about a use of an identifier which was marked deprecated. */
+void
+error_unavailable_use (tree node)
+{
+ if (node == 0)
+ return;
+
+ if (DECL_P (node))
+ error ("%qs is unavailable (declared at %s:%d)",
+ IDENTIFIER_POINTER (DECL_NAME (node)),
+ DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
+ else if (TYPE_P (node))
+ {
+ const char *what = NULL;
+ tree decl = TYPE_STUB_DECL (node);
+
+ if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
+ what = IDENTIFIER_POINTER (TYPE_NAME (node));
+ else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (node)))
+ what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
+
+ if (what)
+ {
+ if (decl)
+ error ("%qs is unavailable (declared at %s:%d)", what,
+ DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+ else
+ error ("%qs is unavailable", what);
+ }
+ else if (decl)
+ error ("type is unavailable (declared at %s:%d)",
+ DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+ else
+ error ("type is unavailable");
+ }
+}
+/* APPLE LOCAL end "unavailable" attribute (radar 2809697) --ilr */
+
/* Save the current INPUT_LOCATION on the top entry in the
INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
INPUT_LOCATION accordingly. */
@@ -1530,8 +1566,19 @@
/* Register the language-independent parameters. */
add_params (lang_independent_params, LAST_PARAM);
- /* This must be done after add_params but before argument processing. */
- init_ggc_heuristics();
+ /* APPLE LOCAL begin retune gc params 6124839 */
+ { int i = 0;
+ bool opt = false;
+ while (save_argv[++i])
+ {
+ if (strncmp (save_argv[i], "-O", 2) == 0
+ && strcmp (save_argv[i], "-O0") != 0)
+ opt = true;
+ }
+ /* This must be done after add_params but before argument processing. */
+ init_ggc_heuristics(opt);
+ }
+ /* APPLE LOCAL end retune gc params 6124839 */
init_optimization_passes ();
}
Modified: trunk/contrib/gcc/toplev.h
===================================================================
--- trunk/contrib/gcc4/toplev.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/toplev.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -79,6 +79,8 @@
extern void error_for_asm (rtx, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
extern void warning_for_asm (rtx, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
extern void warn_deprecated_use (tree);
+/* APPLE LOCAL "unavailable" attribute (radar 2809697) */
+extern void error_unavailable_use (tree);
#ifdef BUFSIZ
extern void output_quoted_string (FILE *, const char *);
Modified: trunk/contrib/gcc/tree-cfg.c
===================================================================
--- trunk/contrib/gcc4/tree-cfg.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-cfg.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1051,9 +1051,12 @@
for_each_eh_region (update_eh_label);
- /* Finally, purge dead labels. All user-defined labels and labels that
- can be the target of non-local gotos and labels which have their
- address taken are preserved. */
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ /* Finally, purge dead labels. All user-defined labels, labels that
+ can be the target of non-local gotos, labels which have their
+ address taken and labels which have attributes or alignment are
+ preserved. */
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
FOR_EACH_BB (bb)
{
block_stmt_iterator i;
@@ -1073,6 +1076,10 @@
if (label == label_for_this_bb
|| ! DECL_ARTIFICIAL (label)
+/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
+ || DECL_ATTRIBUTES (label)
+ || DECL_USER_ALIGN (label)
+/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
|| DECL_NONLOCAL (label)
|| FORCED_LABEL (label))
bsi_next (&i);
Modified: trunk/contrib/gcc/tree-dump.c
===================================================================
--- trunk/contrib/gcc4/tree-dump.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-dump.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -166,7 +166,7 @@
dump_pointer (dump_info_p di, const char *field, void *ptr)
{
dump_maybe_newline (di);
- fprintf (di->stream, "%-4s: %-8lx ", field, (long) ptr);
+ fprintf (di->stream, "%-4s: %-8lx ", field, (unsigned long) ptr);
di->column += 15;
}
Modified: trunk/contrib/gcc/tree-flow.h
===================================================================
--- trunk/contrib/gcc4/tree-flow.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-flow.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -694,6 +694,8 @@
definition, a function with this prototype is called. */
typedef bool (*walk_use_def_chains_fn) (tree, tree, void *);
+/* In tree-ssa-alias-warnings.c */
+extern void strict_aliasing_warning_backend (void);
/* In tree-ssa.c */
extern void init_tree_ssa (void);
Modified: trunk/contrib/gcc/tree-gimple.h
===================================================================
--- trunk/contrib/gcc4/tree-gimple.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-gimple.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -140,7 +140,8 @@
extern tree omp_reduction_init (tree, tree);
/* In tree-nested.c. */
-extern void lower_nested_functions (tree);
+/* APPLE LOCAL radar 6305545 */
+extern void lower_nested_functions (tree, bool);
extern void insert_field_into_struct (tree, tree);
/* Convenience routines to walk all statements of a gimple function.
Modified: trunk/contrib/gcc/tree-nested.c
===================================================================
--- trunk/contrib/gcc4/tree-nested.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-nested.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1970,7 +1970,8 @@
subroutines and turn them into something less tightly bound. */
void
-lower_nested_functions (tree fndecl)
+/* APPLE LOCAL radar 6305545 */
+lower_nested_functions (tree fndecl, bool skip_outermost_fndecl)
{
struct cgraph_node *cgn;
@@ -1980,6 +1981,13 @@
return;
root = create_nesting_tree (cgn);
+ /* APPLE LOCAL begin radar 6305545 */
+ /* If skip_outermost_fndecl is true, we are lowering nested functions of
+ a constructor/destructor which are cloned and thrown away. But we
+ still have to lower their nested functions, but not the outermost function. */
+ if (skip_outermost_fndecl)
+ root = root->inner;
+ /* APPLE LOCAL end radar 6305545 */
walk_all_functions (convert_nonlocal_reference, root);
walk_all_functions (convert_local_reference, root);
walk_all_functions (convert_nl_goto_reference, root);
Added: trunk/contrib/gcc/tree-ssa-alias-warnings.c
===================================================================
--- trunk/contrib/gcc/tree-ssa-alias-warnings.c (rev 0)
+++ trunk/contrib/gcc/tree-ssa-alias-warnings.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -0,0 +1,1036 @@
+/* Strict aliasing checks.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Contributed by Silvius Rus <rus at google.com>.
+
+ 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. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "alloc-pool.h"
+#include "tree.h"
+#include "tree-dump.h"
+#include "tree-flow.h"
+#include "params.h"
+#include "function.h"
+#include "expr.h"
+#include "toplev.h"
+#include "diagnostic.h"
+#include "tree-ssa-structalias.h"
+#include "tree-ssa-propagate.h"
+#include "langhooks.h"
+
+/* Module to issue a warning when a program uses data through a type
+ different from the type through which the data were defined.
+ Implements -Wstrict-aliasing and -Wstrict-aliasing=n.
+ These checks only happen when -fstrict-aliasing is present.
+
+ The idea is to use the compiler to identify occurrences of nonstandard
+ aliasing, and report them to programmers. Programs free of such aliasing
+ are more portable, maintainable, and can usually be optimized better.
+
+ The current, as of April 2007, C and C++ language standards forbid
+ accessing data of type A through an lvalue of another type B,
+ with certain exceptions. See the C Standard ISO/IEC 9899:1999,
+ section 6.5, paragraph 7, and the C++ Standard ISO/IEC 14882:1998,
+ section 3.10, paragraph 15.
+
+ Example 1:*a is used as int but was defined as a float, *b.
+ int* a = ...;
+ float* b = reinterpret_cast<float*> (a);
+ *b = 2.0;
+ return *a
+
+ Unfortunately, the problem is in general undecidable if we take into
+ account arithmetic expressions such as array indices or pointer arithmetic.
+ (It is at least as hard as Peano arithmetic decidability.)
+ Even ignoring arithmetic, the problem is still NP-hard, because it is
+ at least as hard as flow-insensitive may-alias analysis, which was proved
+ NP-hard by Horwitz et al, TOPLAS 1997.
+
+ It is clear that we need to choose some heuristics.
+ Unfortunately, various users have different goals which correspond to
+ different time budgets so a common approach will not suit all.
+ We present the user with three effort/accuracy levels. By accuracy, we mean
+ a common-sense mix of low count of false positives with a
+ reasonably low number of false negatives. We are heavily biased
+ towards a low count of false positives.
+ The effort (compilation time) is likely to increase with the level.
+
+ -Wstrict-aliasing=1
+ ===================
+ Most aggressive, least accurate. Possibly useful when higher levels
+ do not warn but -fstrict-aliasing still breaks the code, as
+ it has very few false negatives.
+ Warn for all bad pointer conversions, even if never dereferenced.
+ Implemented in the front end (c-common.c).
+ Uses alias_sets_might_conflict to compare types.
+
+ -Wstrict-aliasing=2
+ ===================
+ Aggressive, not too precise.
+ May still have many false positives (not as many as level 1 though),
+ and few false negatives (but possibly more than level 1).
+ Runs only in the front end. Uses alias_sets_might_conflict to
+ compare types. Does not check for pointer dereferences.
+ Only warns when an address is taken. Warns about incomplete type punning.
+
+ -Wstrict-aliasing=3 (default)
+ ===================
+ Should have very few false positives and few false negatives.
+ Takes care of the common punn+dereference pattern in the front end:
+ *(int*)&some_float.
+ Takes care of multiple statement cases in the back end,
+ using flow-sensitive points-to information (-O required).
+ Uses alias_sets_conflict_p to compare types and only warns
+ when the converted pointer is dereferenced.
+ Does not warn about incomplete type punning.
+
+ Future improvements can be included by adding higher levels.
+
+ In summary, expression level analysis is performed in the front-end,
+ and multiple-statement analysis is performed in the backend.
+ The remainder of this discussion is only about the backend analysis.
+
+ This implementation uses flow-sensitive points-to information.
+ Flow-sensitivity refers to accesses to the pointer, and not the object
+ pointed. For instance, we do not warn about the following case.
+
+ Example 2.
+ int* a = (int*)malloc (...);
+ float* b = reinterpret_cast<float*> (a);
+ *b = 2.0;
+ a = (int*)malloc (...);
+ return *a;
+
+ In SSA, it becomes clear that the INT value *A_2 referenced in the
+ return statement is not aliased to the FLOAT defined through *B_1.
+ int* a_1 = (int*)malloc (...);
+ float* b_1 = reinterpret_cast<float*> (a_1);
+ *b_1 = 2.0;
+ a_2 = (int*)malloc (...);
+ return *a_2;
+
+
+ Algorithm Outline
+ =================
+
+ ForEach (ptr, object) in the points-to table
+ If (incompatible_types (*ptr, object))
+ If (referenced (ptr, current function)
+ and referenced (object, current function))
+ Issue warning (ptr, object, reference locations)
+
+ The complexity is:
+ O (sizeof (points-to table)
+ + sizeof (function body) * lookup_time (points-to table))
+
+ Pointer dereference locations are looked up on demand. The search is
+ a single scan of the function body, in which all references to pointers
+ and objects in the points-to table are recorded. However, this dominant
+ time factor occurs rarely, only when cross-type aliasing was detected.
+
+
+ Limitations of the Proposed Implementation
+ ==========================================
+
+ 1. We do not catch the following case, because -fstrict-aliasing will
+ associate different tags with MEM while building points-to information,
+ thus before we get to analyze it.
+ XXX: this could be solved by either running with -fno-strict-aliasing
+ or by recording the points-to information before splitting the orignal
+ tag based on type.
+
+ Example 3.
+ void* mem = malloc (...);
+ int* pi = reinterpret_cast<int*> (mem);
+ float* b = reinterpret_cast<float*> (mem);
+ *b = 2.0;
+ return *pi+1;
+
+ 2. We do not check whether the two conflicting (de)references can
+ reach each other in the control flow sense. If we fixed limitation
+ 1, we would wrongly issue a warning in the following case.
+
+ Example 4.
+ void* raw = malloc (...);
+ if (...) {
+ float* b = reinterpret_cast<float*> (raw);
+ *b = 2.0;
+ return (int)*b;
+ } else {
+ int* a = reinterpret_cast<int*> (raw);
+ *a = 1;
+ return *a;
+
+ 3. Only simple types are compared, thus no structures, unions or classes
+ are analyzed. A first attempt to deal with structures introduced much
+ complication and has not showed much improvement in preliminary tests,
+ so it was left out.
+
+ 4. All analysis is intraprocedural. */
+
+
+/* Local declarations. */
+static void find_references_in_function (void);
+
+
+
+/* Get main type of tree TYPE, stripping array dimensions and qualifiers. */
+
+static tree
+get_main_type (tree type)
+{
+ while (TREE_CODE (type) == ARRAY_TYPE)
+ type = TREE_TYPE (type);
+ return TYPE_MAIN_VARIANT (type);
+}
+
+
+/* Get the type of the given object. If IS_PTR is true, get the type of the
+ object pointed to or referenced by OBJECT instead.
+ For arrays, return the element type. Ignore all qualifiers. */
+
+static tree
+get_otype (tree object, bool is_ptr)
+{
+ tree otype = TREE_TYPE (object);
+
+ if (is_ptr)
+ {
+ gcc_assert (POINTER_TYPE_P (otype));
+ otype = TREE_TYPE (otype);
+ }
+ return get_main_type (otype);
+}
+
+
+/* Return true if tree TYPE is struct, class or union. */
+
+static bool
+struct_class_union_p (tree type)
+{
+ return (TREE_CODE (type) == RECORD_TYPE
+ || TREE_CODE (type) == UNION_TYPE
+ || TREE_CODE (type) == QUAL_UNION_TYPE);
+}
+
+
+
+/* Keep data during a search for an aliasing site.
+ RHS = object or pointer aliased. No LHS is specified because we are only
+ looking in the UseDef paths of a given variable, so LHS will always be
+ an SSA name of the same variable.
+ When IS_RHS_POINTER = true, we are looking for ... = RHS. Otherwise,
+ we are looking for ... = &RHS.
+ SITE is the output of a search, non-NULL if the search succeeded. */
+
+struct alias_match
+{
+ tree rhs;
+ bool is_rhs_pointer;
+ tree site;
+};
+
+
+/* Callback for find_alias_site. Return true if the right hand site
+ of STMT matches DATA. */
+
+static bool
+find_alias_site_helper (tree var ATTRIBUTE_UNUSED, tree stmt, void *data)
+{
+ struct alias_match *match = (struct alias_match *) data;
+ tree rhs_pointer = get_rhs (stmt);
+ tree to_match = NULL_TREE;
+
+ while (TREE_CODE (rhs_pointer) == NOP_EXPR
+ || TREE_CODE (rhs_pointer) == CONVERT_EXPR
+ || TREE_CODE (rhs_pointer) == VIEW_CONVERT_EXPR)
+ rhs_pointer = TREE_OPERAND (rhs_pointer, 0);
+
+ if (!rhs_pointer)
+ /* Not a type conversion. */
+ return false;
+
+ if (TREE_CODE (rhs_pointer) == ADDR_EXPR && !match->is_rhs_pointer)
+ to_match = TREE_OPERAND (rhs_pointer, 0);
+ else if (POINTER_TYPE_P (rhs_pointer) && match->is_rhs_pointer)
+ to_match = rhs_pointer;
+
+ if (to_match != match->rhs)
+ /* Type conversion, but not a name match. */
+ return false;
+
+ /* Found it. */
+ match->site = stmt;
+ return true;
+}
+
+
+/* Find the statement where OBJECT1 gets aliased to OBJECT2.
+ If IS_PTR2 is true, consider OBJECT2 to be the name of a pointer or
+ reference rather than the actual aliased object.
+ For now, just implement the case where OBJECT1 is an SSA name defined
+ by a PHI statement. */
+
+static tree
+find_alias_site (tree object1, bool is_ptr1 ATTRIBUTE_UNUSED,
+ tree object2, bool is_ptr2)
+{
+ struct alias_match match;
+
+ match.rhs = object2;
+ match.is_rhs_pointer = is_ptr2;
+ match.site = NULL_TREE;
+
+ if (TREE_CODE (object1) != SSA_NAME)
+ return NULL_TREE;
+
+ walk_use_def_chains (object1, find_alias_site_helper, &match, false);
+ return match.site;
+}
+
+
+/* Structure to store temporary results when trying to figure out whether
+ an object is referenced. Just its presence in the text is not enough,
+ as we may just be taking its address. */
+
+struct match_info
+{
+ tree object;
+ bool is_ptr;
+ /* The difference between the number of references to OBJECT
+ and the number of occurences of &OBJECT. */
+ int found;
+};
+
+
+/* Return the base if EXPR is an SSA name. Return EXPR otherwise. */
+
+static tree
+get_ssa_base (tree expr)
+{
+ if (TREE_CODE (expr) == SSA_NAME)
+ return SSA_NAME_VAR (expr);
+ else
+ return expr;
+}
+
+
+/* Record references to objects and pointer dereferences across some piece of
+ code. The number of references is recorded for each item.
+ References to an object just to take its address are not counted.
+ For instance, if PTR is a pointer and OBJ is an object:
+ 1. Expression &obj + *ptr will have the following reference match structure:
+ ptrs: <ptr, 1>
+ objs: <ptr, 1>
+ OBJ does not appear as referenced because we just take its address.
+ 2. Expression ptr + *ptr will have the following reference match structure:
+ ptrs: <ptr, 1>
+ objs: <ptr, 2>
+ PTR shows up twice as an object, but is dereferenced only once.
+
+ The elements of the hash tables are tree_map objects. */
+struct reference_matches
+{
+ htab_t ptrs;
+ htab_t objs;
+};
+
+
+/* Return the match, if any. Otherwise, return NULL_TREE. It will
+ return NULL_TREE even when a match was found, if the value associated
+ to KEY is NULL_TREE. */
+
+static inline tree
+match (htab_t ref_map, tree key)
+{
+ struct tree_map to_find;
+ struct tree_map *found;
+ void **slot = NULL;
+
+ to_find.from = key;
+ to_find.hash = htab_hash_pointer (key);
+ slot = htab_find_slot (ref_map, &to_find, NO_INSERT);
+
+ if (!slot)
+ return NULL_TREE;
+
+ found = (struct tree_map *) *slot;
+ return found->to;
+}
+
+
+/* Set the entry corresponding to KEY, but only if the entry
+ already exists and its value is NULL_TREE. Otherwise, do nothing. */
+
+static inline void
+maybe_add_match (htab_t ref_map, struct tree_map *key)
+{
+ struct tree_map *found = htab_find (ref_map, key);
+
+ if (found && !found->to)
+ found->to = key->to;
+}
+
+
+/* Add an entry to HT, with key T and value NULL_TREE. */
+
+static void
+add_key (htab_t ht, tree t, alloc_pool references_pool)
+{
+ void **slot;
+ struct tree_map *tp = pool_alloc (references_pool);
+
+ tp->from = t;
+ tp->to = NULL_TREE;
+ tp->hash = htab_hash_pointer(tp->from);
+
+ slot = htab_find_slot (ht, tp, INSERT);
+ *slot = (void *) tp;
+}
+
+
+/* Some memory to keep the objects in the reference table. */
+
+static alloc_pool ref_table_alloc_pool = NULL;
+
+
+/* Get some memory to keep the objects in the reference table. */
+
+static inline alloc_pool
+reference_table_alloc_pool (bool build)
+{
+ if (ref_table_alloc_pool || !build)
+ return ref_table_alloc_pool;
+
+ ref_table_alloc_pool =
+ create_alloc_pool ("ref_table_alloc_pool", sizeof (struct tree_map), 20);
+
+ return ref_table_alloc_pool;
+}
+
+
+/* Initialize the reference table by adding all pointers in the points-to
+ table as keys, and NULL_TREE as associated values. */
+
+static struct reference_matches *
+build_reference_table (void)
+{
+ unsigned int i;
+ struct reference_matches *ref_table = NULL;
+ alloc_pool references_pool = reference_table_alloc_pool (true);
+
+ ref_table = XNEW (struct reference_matches);
+ ref_table->objs = htab_create (10, tree_map_hash, tree_map_eq, NULL);
+ ref_table->ptrs = htab_create (10, tree_map_hash, tree_map_eq, NULL);
+
+ for (i = 1; i < num_ssa_names; i++)
+ {
+ tree ptr = ssa_name (i);
+ struct ptr_info_def *pi;
+
+ if (ptr == NULL_TREE)
+ continue;
+
+ pi = SSA_NAME_PTR_INFO (ptr);
+
+ if (!SSA_NAME_IN_FREE_LIST (ptr) && pi && pi->name_mem_tag)
+ {
+ /* Add pointer to the interesting dereference list. */
+ add_key (ref_table->ptrs, ptr, references_pool);
+
+ /* Add all aliased names to the interesting reference list. */
+ if (pi->pt_vars)
+ {
+ unsigned ix;
+ bitmap_iterator bi;
+
+ EXECUTE_IF_SET_IN_BITMAP (pi->pt_vars, 0, ix, bi)
+ {
+ tree alias = referenced_var (ix);
+ add_key (ref_table->objs, alias, references_pool);
+ }
+ }
+ }
+ }
+
+ return ref_table;
+}
+
+
+/* Reference table. */
+
+static struct reference_matches *ref_table = NULL;
+
+
+/* Clean up the reference table if allocated. */
+
+static void
+maybe_free_reference_table (void)
+{
+ if (ref_table)
+ {
+ htab_delete (ref_table->ptrs);
+ htab_delete (ref_table->objs);
+ free (ref_table);
+ ref_table = NULL;
+ }
+
+ if (ref_table_alloc_pool)
+ {
+ free_alloc_pool (ref_table_alloc_pool);
+ ref_table_alloc_pool = NULL;
+ }
+}
+
+
+/* Get the reference table. Initialize it if needed. */
+
+static inline struct reference_matches *
+reference_table (bool build)
+{
+ if (ref_table || !build)
+ return ref_table;
+
+ ref_table = build_reference_table ();
+ find_references_in_function ();
+ return ref_table;
+}
+
+
+/* Callback for find_references_in_function.
+ Check whether *TP is an object reference or pointer dereference for the
+ variables given in ((struct match_info*)DATA)->OBJS or
+ ((struct match_info*)DATA)->PTRS. The total number of references
+ is stored in the same structures. */
+
+static tree
+find_references_in_tree_helper (tree *tp,
+ int *walk_subtrees ATTRIBUTE_UNUSED,
+ void *data)
+{
+ struct tree_map match;
+ static int parent_tree_code = ERROR_MARK;
+
+ /* Do not report references just for the purpose of taking an address.
+ XXX: we rely on the fact that the tree walk is in preorder
+ and that ADDR_EXPR is not a leaf, thus cannot be carried over across
+ walks. */
+ if (parent_tree_code == ADDR_EXPR)
+ goto finish;
+
+ match.to = (tree) data;
+
+ if (TREE_CODE (*tp) == INDIRECT_REF)
+ {
+ match.from = TREE_OPERAND (*tp, 0);
+ match.hash = htab_hash_pointer (match.from);
+ maybe_add_match (reference_table (true)->ptrs, &match);
+ }
+ else
+ {
+ match.from = *tp;
+ match.hash = htab_hash_pointer (match.from);
+ maybe_add_match (reference_table (true)->objs, &match);
+ }
+
+finish:
+ parent_tree_code = TREE_CODE (*tp);
+ return NULL_TREE;
+}
+
+
+/* Find all the references to aliased variables in the current function. */
+
+static void
+find_references_in_function (void)
+{
+ basic_block bb;
+ block_stmt_iterator i;
+
+ FOR_EACH_BB (bb)
+ for (i = bsi_start (bb); !bsi_end_p (i); bsi_next (&i))
+ walk_tree (bsi_stmt_ptr (i), find_references_in_tree_helper,
+ (void *) *bsi_stmt_ptr (i), NULL);
+}
+
+
+/* Find the reference site for OBJECT.
+ If IS_PTR is true, look for derferences of OBJECT instead.
+ XXX: only the first site is returned in the current
+ implementation. If there are no matching sites, return NULL_TREE. */
+
+static tree
+reference_site (tree object, bool is_ptr)
+{
+ if (is_ptr)
+ return match (reference_table (true)->ptrs, object);
+ else
+ return match (reference_table (true)->objs, object);
+}
+
+
+/* Try to get more location info when something is missing.
+ OBJECT1 and OBJECT2 are aliased names. If IS_PTR1 or IS_PTR2, the alias
+ is on the memory referenced or pointed to by OBJECT1 and OBJECT2.
+ ALIAS_SITE, DEREF_SITE1 and DEREF_SITE2 are the statements where the
+ alias takes place (some pointer assignment usually) and where the
+ alias is referenced through OBJECT1 and OBJECT2 respectively.
+ REF_TYPE1 and REF_TYPE2 will return the type of the reference at the
+ respective sites. Only the first matching reference is returned for
+ each name. If no statement is found, the function header is returned. */
+
+static void
+maybe_find_missing_stmts (tree object1, bool is_ptr1,
+ tree object2, bool is_ptr2,
+ tree *alias_site,
+ tree *deref_site1,
+ tree *deref_site2)
+{
+ if (object1 && object2)
+ {
+ if (!*alias_site || !EXPR_HAS_LOCATION (*alias_site))
+ *alias_site = find_alias_site (object1, is_ptr1, object2, is_ptr2);
+
+ if (!*deref_site1 || !EXPR_HAS_LOCATION (*deref_site1))
+ *deref_site1 = reference_site (object1, is_ptr1);
+
+ if (!*deref_site2 || !EXPR_HAS_LOCATION (*deref_site2))
+ *deref_site2 = reference_site (object2, is_ptr2);
+ }
+
+ /* If we could not find the alias site, set it to one of the dereference
+ sites, if available. */
+ if (!*alias_site)
+ {
+ if (*deref_site1)
+ *alias_site = *deref_site1;
+ else if (*deref_site2)
+ *alias_site = *deref_site2;
+ }
+
+ /* If we could not find the dereference sites, set them to the alias site,
+ if known. */
+ if (!*deref_site1 && *alias_site)
+ *deref_site1 = *alias_site;
+ if (!*deref_site2 && *alias_site)
+ *deref_site2 = *alias_site;
+}
+
+
+/* Callback for find_first_artificial_name.
+ Find out if there are no artificial names at tree node *T. */
+
+static tree
+ffan_walker (tree *t,
+ int *go_below ATTRIBUTE_UNUSED,
+ void *data ATTRIBUTE_UNUSED)
+{
+ if (TREE_CODE (*t) == VAR_DECL || TREE_CODE (*t) == PARM_DECL)
+ if (DECL_ARTIFICIAL (*t))
+ return *t;
+
+ return NULL_TREE;
+}
+
+/* Return the first artificial name within EXPR, or NULL_TREE if
+ none exists. */
+
+static tree
+find_first_artificial_name (tree expr)
+{
+ return walk_tree_without_duplicates (&expr, ffan_walker, NULL);
+}
+
+
+/* Get a name from the original program for VAR. */
+
+static const char *
+get_var_name (tree var)
+{
+ if (TREE_CODE (var) == SSA_NAME)
+ return get_var_name (get_ssa_base (var));
+
+ if (find_first_artificial_name (var))
+ return "{unknown}";
+
+ if (TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == PARM_DECL)
+ if (DECL_NAME (var))
+ return IDENTIFIER_POINTER (DECL_NAME (var));
+
+ return "{unknown}";
+}
+
+
+/* Return true if VAR contains an artificial name. */
+
+static bool
+contains_artificial_name_p (tree var)
+{
+ if (TREE_CODE (var) == SSA_NAME)
+ return contains_artificial_name_p (get_ssa_base (var));
+
+ return find_first_artificial_name (var) != NULL_TREE;
+}
+
+
+/* Return "*" if OBJECT is not the actual alias but a pointer to it, or
+ "" otherwise.
+ IS_PTR is true when OBJECT is not the actual alias.
+ In addition to checking IS_PTR, we also make sure that OBJECT is a pointer
+ since IS_PTR would also be true for C++ references, but we should only
+ print a * before a pointer and not before a reference. */
+
+static const char *
+get_maybe_star_prefix (tree object, bool is_ptr)
+{
+ gcc_assert (object);
+ return (is_ptr
+ && TREE_CODE (TREE_TYPE (object)) == POINTER_TYPE) ? "*" : "";
+}
+
+
+/* Callback for contains_node_type_p.
+ Returns true if *T has tree code *(int*)DATA. */
+
+static tree
+contains_node_type_p_callback (tree *t,
+ int *go_below ATTRIBUTE_UNUSED,
+ void *data)
+{
+ return ((int) TREE_CODE (*t) == *((int *) data)) ? *t : NULL_TREE;
+}
+
+
+/* Return true if T contains a node with tree code TYPE. */
+
+static bool
+contains_node_type_p (tree t, int type)
+{
+ return (walk_tree_without_duplicates (&t, contains_node_type_p_callback,
+ (void *) &type)
+ != NULL_TREE);
+}
+
+
+/* Return true if a warning was issued in the front end at STMT. */
+
+static bool
+already_warned_in_frontend_p (tree stmt)
+{
+ tree rhs_pointer;
+
+ if (stmt == NULL_TREE)
+ return false;
+
+ rhs_pointer = get_rhs (stmt);
+
+ if ((TREE_CODE (rhs_pointer) == NOP_EXPR
+ || TREE_CODE (rhs_pointer) == CONVERT_EXPR
+ || TREE_CODE (rhs_pointer) == VIEW_CONVERT_EXPR)
+ && TREE_NO_WARNING (rhs_pointer))
+ return true;
+ else
+ return false;
+}
+
+
+/* Return true if and only if TYPE is a function or method pointer type,
+ or pointer to a pointer to ... to a function or method. */
+
+static bool
+is_method_pointer (tree type)
+{
+ while (TREE_CODE (type) == POINTER_TYPE)
+ type = TREE_TYPE (type);
+ return TREE_CODE (type) == METHOD_TYPE || TREE_CODE (type) == FUNCTION_TYPE;
+}
+
+
+/* Issue a -Wstrict-aliasing warning.
+ OBJECT1 and OBJECT2 are aliased names.
+ If IS_PTR1 and/or IS_PTR2 is true, then the corresponding name
+ OBJECT1/OBJECT2 is a pointer or reference to the aliased memory,
+ rather than actual storage.
+ ALIAS_SITE is a statement where the alias took place. In the most common
+ case, that is where a pointer was assigned to the address of an object. */
+
+static bool
+strict_aliasing_warn (tree alias_site,
+ tree object1, bool is_ptr1,
+ tree object2, bool is_ptr2,
+ bool filter_artificials)
+{
+ tree ref_site1 = NULL_TREE;
+ tree ref_site2 = NULL_TREE;
+ const char *name1;
+ const char *name2;
+ location_t alias_loc;
+ location_t ref1_loc;
+ location_t ref2_loc;
+ gcc_assert (object1);
+ gcc_assert (object2);
+
+ if (contains_artificial_name_p (object1)
+ || contains_artificial_name_p (object2))
+ return false;
+
+ name1 = get_var_name (object1);
+ name2 = get_var_name (object2);
+
+ if (is_method_pointer (get_main_type (TREE_TYPE (object2))))
+ return false;
+
+ maybe_find_missing_stmts (object1, is_ptr1, object2, is_ptr2, &alias_site,
+ &ref_site1, &ref_site2);
+
+ if (!alias_site)
+ return false;
+
+ if (EXPR_HAS_LOCATION (alias_site))
+ alias_loc = EXPR_LOCATION (alias_site);
+ else
+ return false;
+
+ if (EXPR_HAS_LOCATION (ref_site1))
+ ref1_loc = EXPR_LOCATION (ref_site1);
+ else
+ ref1_loc = alias_loc;
+
+ if (EXPR_HAS_LOCATION (ref_site2))
+ ref2_loc = EXPR_LOCATION (ref_site2);
+ else
+ ref2_loc = alias_loc;
+
+ if (already_warned_in_frontend_p (alias_site))
+ return false;
+
+ /* If they are not SSA names, but contain SSA names, drop the warning
+ because it cannot be displayed well.
+ Also drop it if they both contain artificials.
+ XXX: this is a hack, must figure out a better way to display them. */
+ if (filter_artificials)
+ if ((find_first_artificial_name (get_ssa_base (object1))
+ && find_first_artificial_name (get_ssa_base (object2)))
+ || (TREE_CODE (object1) != SSA_NAME
+ && contains_node_type_p (object1, SSA_NAME))
+ || (TREE_CODE (object2) != SSA_NAME
+ && contains_node_type_p (object2, SSA_NAME)))
+ return false;
+
+ /* XXX: In the following format string, %s:%d should be replaced by %H.
+ However, in my tests only the first %H printed ok, while the
+ second and third were printed as blanks. */
+ warning (OPT_Wstrict_aliasing,
+ "%Hlikely type-punning may break strict-aliasing rules: "
+ "object %<%s%s%> of main type %qT is referenced at or around "
+ "%s:%d and may be "
+ "aliased to object %<%s%s%> of main type %qT which is referenced "
+ "at or around %s:%d.",
+ &alias_loc,
+ get_maybe_star_prefix (object1, is_ptr1),
+ name1, get_otype (object1, is_ptr1),
+ LOCATION_FILE (ref1_loc), LOCATION_LINE (ref1_loc),
+ get_maybe_star_prefix (object2, is_ptr2),
+ name2, get_otype (object2, is_ptr2),
+ LOCATION_FILE (ref2_loc), LOCATION_LINE (ref2_loc));
+
+ return true;
+}
+
+
+
+/* Return true when any objects of TYPE1 and TYPE2 respectively
+ may not be aliased according to the language standard. */
+
+static bool
+nonstandard_alias_types_p (tree type1, tree type2)
+{
+ HOST_WIDE_INT set1;
+ HOST_WIDE_INT set2;
+
+ if (VOID_TYPE_P (type1) || VOID_TYPE_P (type2))
+ return false;
+
+ set1 = get_alias_set (type1);
+ set2 = get_alias_set (type2);
+ return !alias_sets_conflict_p (set1, set2);
+}
+
+
+
+/* Returns true if the given name is a struct field tag (SFT). */
+
+static bool
+struct_field_tag_p (tree var)
+{
+ return TREE_CODE (var) == STRUCT_FIELD_TAG;
+}
+
+
+/* Returns true when *PTR may not be aliased to ALIAS.
+ See C standard 6.5p7 and C++ standard 3.10p15.
+ If PTR_PTR is true, ALIAS represents a pointer or reference to the
+ aliased storage rather than its actual name. */
+
+static bool
+nonstandard_alias_p (tree ptr, tree alias, bool ptr_ptr)
+{
+ /* Find the types to compare. */
+ tree ptr_type = get_otype (ptr, true);
+ tree alias_type = get_otype (alias, ptr_ptr);
+
+ /* XXX: for now, say it's OK if the alias escapes.
+ Not sure this is needed in general, but otherwise GCC will not
+ bootstrap. */
+ if (var_ann (get_ssa_base (alias))->escape_mask != NO_ESCAPE)
+ return false;
+
+ /* XXX: don't get into structures for now. It brings much complication
+ and little benefit. */
+ if (struct_class_union_p (ptr_type) || struct_class_union_p (alias_type))
+ return false;
+
+ /* XXX: In 4.2.1, field resolution in alias is not as good as in pre-4.3
+ This fixes problems found during the backport, where a pointer to the
+ first field of a struct appears to be aliased to the whole struct. */
+ if (struct_field_tag_p (alias))
+ return false;
+
+ /* If they are both SSA names of artificials, let it go, the warning
+ is too confusing. */
+ if (find_first_artificial_name (ptr) && find_first_artificial_name (alias))
+ return false;
+
+ /* Compare the types. */
+ return nonstandard_alias_types_p (ptr_type, alias_type);
+}
+
+
+/* Return true when we should skip analysis for pointer PTR based on the
+ fact that their alias information *PI is not considered relevant. */
+
+static bool
+skip_this_pointer (tree ptr ATTRIBUTE_UNUSED, struct ptr_info_def *pi)
+{
+ /* If it is not dereferenced, it is not a problem (locally). */
+ if (!pi->is_dereferenced)
+ return true;
+
+ /* This would probably cause too many false positives. */
+ if (pi->value_escapes_p || pi->pt_anything)
+ return true;
+
+ return false;
+}
+
+
+/* Find aliasing to named objects for pointer PTR. */
+
+static void
+dsa_named_for (tree ptr)
+{
+ struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
+
+ if (pi)
+ {
+ if (skip_this_pointer (ptr, pi))
+ return;
+
+ /* For all the variables it could be aliased to. */
+ if (pi->pt_vars)
+ {
+ unsigned ix;
+ bitmap_iterator bi;
+
+ EXECUTE_IF_SET_IN_BITMAP (pi->pt_vars, 0, ix, bi)
+ {
+ tree alias = referenced_var (ix);
+
+ if (is_global_var (alias))
+ continue;
+
+ if (nonstandard_alias_p (ptr, alias, false))
+ strict_aliasing_warn (SSA_NAME_DEF_STMT (ptr),
+ ptr, true, alias, false, true);
+ }
+ }
+ }
+}
+
+
+/* Detect and report strict aliasing violation of named objects. */
+
+static void
+detect_strict_aliasing_named (void)
+{
+ unsigned int i;
+
+ for (i = 1; i < num_ssa_names; i++)
+ {
+ tree ptr = ssa_name (i);
+ struct ptr_info_def *pi;
+
+ if (ptr == NULL_TREE)
+ continue;
+
+ pi = SSA_NAME_PTR_INFO (ptr);
+
+ if (!SSA_NAME_IN_FREE_LIST (ptr) && pi && pi->name_mem_tag)
+ dsa_named_for (ptr);
+ }
+}
+
+
+/* Return false only the first time I see each instance of FUNC. */
+
+static bool
+processed_func_p (tree func)
+{
+ static htab_t seen = NULL;
+ void **slot;
+
+ if (!seen)
+ seen = htab_create (100, htab_hash_pointer, htab_eq_pointer, NULL);
+
+ slot = htab_find_slot (seen, func, INSERT);
+ gcc_assert (slot);
+
+ if (*slot)
+ return true;
+
+ *slot = func;
+ return false;
+}
+
+
+/* Detect and warn about type-punning using points-to information. */
+
+void
+strict_aliasing_warning_backend (void)
+{
+ if (!(flag_strict_aliasing
+ && warn_strict_aliasing == 3
+ && !processed_func_p (current_function_decl)))
+ return;
+
+ detect_strict_aliasing_named ();
+ maybe_free_reference_table ();
+}
Property changes on: trunk/contrib/gcc/tree-ssa-alias-warnings.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/contrib/gcc/tree-ssa-alias.c
===================================================================
--- trunk/contrib/gcc4/tree-ssa-alias.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-ssa-alias.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -652,7 +652,7 @@
compute_may_aliases (void)
{
struct alias_info *ai;
-
+
memset (&alias_stats, 0, sizeof (alias_stats));
/* Initialize aliasing information. */
@@ -710,6 +710,9 @@
dump_alias_info (dump_file);
}
+ /* Report strict aliasing violations. */
+ strict_aliasing_warning_backend ();
+
/* Deallocate memory used by aliasing data structures. */
delete_alias_info (ai);
Modified: trunk/contrib/gcc/tree-ssa-propagate.c
===================================================================
--- trunk/contrib/gcc4/tree-ssa-propagate.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-ssa-propagate.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1,5 +1,5 @@
/* Generic SSA value propagation engine.
- Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo at redhat.com>
This file is part of GCC.
@@ -176,6 +176,8 @@
static void
cfg_blocks_add (basic_block bb)
{
+ bool head = false;
+
gcc_assert (bb != ENTRY_BLOCK_PTR && bb != EXIT_BLOCK_PTR);
gcc_assert (!TEST_BIT (bb_in_list, bb->index));
@@ -198,12 +200,26 @@
cfg_blocks_head = 0;
VEC_safe_grow (basic_block, heap, cfg_blocks, 2 * cfg_blocks_tail);
}
- else
+ /* Minor optimization: we prefer to see blocks with more
+ predecessors later, because there is more of a chance that
+ the incoming edges will be executable. */
+ else if (EDGE_COUNT (bb->preds)
+ >= EDGE_COUNT (VEC_index (basic_block, cfg_blocks,
+ cfg_blocks_head)->preds))
cfg_blocks_tail = ((cfg_blocks_tail + 1)
% VEC_length (basic_block, cfg_blocks));
+ else
+ {
+ if (cfg_blocks_head == 0)
+ cfg_blocks_head = VEC_length (basic_block, cfg_blocks);
+ --cfg_blocks_head;
+ head = true;
+ }
}
- VEC_replace (basic_block, cfg_blocks, cfg_blocks_tail, bb);
+ VEC_replace (basic_block, cfg_blocks,
+ head ? cfg_blocks_head : cfg_blocks_tail,
+ bb);
SET_BIT (bb_in_list, bb->index);
}
Modified: trunk/contrib/gcc/tree-vrp.c
===================================================================
--- trunk/contrib/gcc4/tree-vrp.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree-vrp.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -2509,12 +2509,18 @@
true))
return;
+ type = TREE_TYPE (var);
+
+ /* If we see a pointer type starting at a constant, then we have an
+ unusual ivopt. It may legitimately wrap. */
+ if (POINTER_TYPE_P (type) && is_gimple_min_invariant (init))
+ return;
+
/* We use TYPE_MIN_VALUE and TYPE_MAX_VALUE here instead of
negative_overflow_infinity and positive_overflow_infinity,
because we have concluded that the loop probably does not
wrap. */
- type = TREE_TYPE (var);
if (POINTER_TYPE_P (type) || !TYPE_MIN_VALUE (type))
tmin = lower_bound_in_type (type, type);
else
@@ -4914,7 +4920,7 @@
{
bool sop = false;
- val = compare_range_with_value (GT_EXPR, vr, integer_zero_node, &sop);
+ val = compare_range_with_value (GE_EXPR, vr, integer_zero_node, &sop);
if (val
&& sop
Modified: trunk/contrib/gcc/tree.c
===================================================================
--- trunk/contrib/gcc4/tree.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -69,6 +69,10 @@
"expression",
};
+/* APPLE LOCAL begin 6353006 */
+tree generic_block_literal_struct_type;
+/* APPLE LOCAL end 6353006 */
+
/* obstack.[ch] explicitly declined to prototype this. */
extern int _obstack_allocated_p (struct obstack *h, void *obj);
@@ -541,9 +545,13 @@
DECL_IN_SYSTEM_HEADER (t) = in_system_header;
if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
{
- if (code != FUNCTION_DECL)
+ if (code == FUNCTION_DECL)
+ {
+ DECL_ALIGN (t) = FUNCTION_BOUNDARY;
+ DECL_MODE (t) = FUNCTION_MODE;
+ }
+ else
DECL_ALIGN (t) = 1;
- DECL_USER_ALIGN (t) = 0;
/* We have not yet computed the alias set for this declaration. */
DECL_POINTER_ALIAS_SET (t) = -1;
}
@@ -1881,14 +1889,13 @@
align1 = expr_align (TREE_OPERAND (t, 2));
return MIN (align0, align1);
+ /* FIXME: LABEL_DECL and CONST_DECL never have DECL_ALIGN set
+ meaningfully, it's always 1. */
case LABEL_DECL: case CONST_DECL:
case VAR_DECL: case PARM_DECL: case RESULT_DECL:
- if (DECL_ALIGN (t) != 0)
- return DECL_ALIGN (t);
- break;
-
case FUNCTION_DECL:
- return FUNCTION_BOUNDARY;
+ gcc_assert (DECL_ALIGN (t) != 0);
+ return DECL_ALIGN (t);
default:
break;
@@ -3174,8 +3181,6 @@
if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
layout_decl (t, 0);
- else if (code == FUNCTION_DECL)
- DECL_MODE (t) = FUNCTION_MODE;
return t;
}
@@ -5015,6 +5020,31 @@
return build_pointer_type_for_mode (to_type, ptr_mode, false);
}
+/* APPLE LOCAL begin radar 5732232 - blocks */
+tree
+build_block_pointer_type (tree to_type)
+{
+ tree t;
+
+ /* APPLE LOCAL begin radar 6300081 & 6353006 */
+ if (!generic_block_literal_struct_type)
+ generic_block_literal_struct_type =
+ lang_hooks.build_generic_block_struct_type ();
+ /* APPLE LOCAL end radar 6300081 & 6353006 */
+
+ t = make_node (BLOCK_POINTER_TYPE);
+
+ TREE_TYPE (t) = to_type;
+ TYPE_MODE (t) = ptr_mode;
+
+ /* Lay out the type. This function has many callers that are concerned
+ with expression-construction, and this simplifies them all. */
+ layout_type (t);
+
+ return t;
+}
+/* APPLE LOCAL end radar 5732232 - blocks */
+
/* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE. */
tree
@@ -6044,41 +6074,48 @@
*p = '_';
}
-/* Generate a name for a function unique to this translation unit.
+/* Generate a name for a special-purpose function function.
+ The generated name may need to be unique across the whole link.
TYPE is some string to identify the purpose of this function to the
- linker or collect2. */
+ linker or collect2; it must start with an uppercase letter,
+ one of:
+ I - for constructors
+ D - for destructors
+ N - for C++ anonymous namespaces
+ F - for DWARF unwind frame information. */
tree
-get_file_function_name_long (const char *type)
+get_file_function_name (const char *type)
{
char *buf;
const char *p;
char *q;
+ /* If we already have a name we know to be unique, just use that. */
if (first_global_object_name)
+ p = first_global_object_name;
+ /* If the target is handling the constructors/destructors, they
+ will be local to this file and the name is only necessary for
+ debugging purposes. */
+ else if ((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors)
{
- p = first_global_object_name;
-
- /* For type 'F', the generated name must be unique not only to this
- translation unit but also to any given link. Since global names
- can be overloaded, we concatenate the first global object name
- with a string derived from the file name of this object. */
- if (!strcmp (type, "F"))
- {
- const char *file = main_input_filename;
-
- if (! file)
- file = input_filename;
-
- q = alloca (strlen (p) + 10);
- sprintf (q, "%s_%08X", p, crc32_string (0, file));
-
- p = q;
- }
+ const char *file = main_input_filename;
+ if (! file)
+ file = input_filename;
+ /* Just use the file's basename, because the full pathname
+ might be quite long. */
+ p = strrchr (file, '/');
+ if (p)
+ p++;
+ else
+ p = file;
+ p = q = ASTRDUP (p);
+ clean_symbol_name (q);
}
else
{
- /* We don't have anything that we know to be unique to this translation
+ /* Otherwise, the name must be unique across the entire link.
+ We don't have anything that we know to be unique to this translation
unit, so use what we do have and throw in some randomness. */
unsigned len;
const char *name = weak_global_object_name;
@@ -6110,20 +6147,6 @@
return get_identifier (buf);
}
-
-/* If KIND=='I', return a suitable global initializer (constructor) name.
- If KIND=='D', return a suitable global clean-up (destructor) name. */
-
-tree
-get_file_function_name (int kind)
-{
- char p[2];
-
- p[0] = kind;
- p[1] = 0;
-
- return get_file_function_name_long (p);
-}
#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
@@ -6585,6 +6608,10 @@
long_double_ptr_type_node = build_pointer_type (long_double_type_node);
integer_ptr_type_node = build_pointer_type (integer_type_node);
+ /* Fixed size integer types. */
+ uint32_type_node = build_nonstandard_integer_type (32, true);
+ uint64_type_node = build_nonstandard_integer_type (64, true);
+
/* Decimal float types. */
dfloat32_type_node = make_node (REAL_TYPE);
TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE;
@@ -7773,4 +7800,5 @@
return true;
}
+
#include "gt-tree.h"
Modified: trunk/contrib/gcc/tree.def
===================================================================
--- trunk/contrib/gcc4/tree.def 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree.def 2018-06-04 17:30:21 UTC (rev 10405)
@@ -177,6 +177,11 @@
automatically to the value it points to. Used in C++. */
DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0)
+/* APPLE LOCAL begin radar 5732232 - blocks */
+/* All pointer-to-block types have code BLOCK_POINTER_TYPE.
+ The TREE_TYPE points to the node for the type pointed to. */
+DEFTREECODE (BLOCK_POINTER_TYPE, "block_pointer_type", tcc_type, 0)
+/* APPLE LOCAL end radar 5732232 - blocks */
/* The ordering of the following codes is optimized for the checking
macros in tree.h. Changing the order will degrade the speed of the
compiler. COMPLEX_TYPE, VECTOR_TYPE, ARRAY_TYPE. */
Modified: trunk/contrib/gcc/tree.h
===================================================================
--- trunk/contrib/gcc4/tree.h 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/tree.h 2018-06-04 17:30:21 UTC (rev 10405)
@@ -386,6 +386,8 @@
unsigned lang_flag_5 : 1;
unsigned lang_flag_6 : 1;
unsigned visited : 1;
+ /* APPLE LOCAL "unavailable" attribute (Radar 2809697) --ilr */
+ unsigned unavailable_flag : 1;
};
/* The following table lists the uses of each of the above flags and
@@ -533,6 +535,13 @@
IDENTIFIER_TRANSPARENT_ALIAS in
IDENTIFIER_NODE
+ APPLE LOCAL begin "unavailable" attribute (Radar 2809697)
+ unavailable_flag:
+
+ TREE_UNAVAILABLE in
+ ..._DECL
+ APPLE LOCAL end "unavailable" attribute (Radar 2809697)
+
visited:
Used in tree traversals to mark visited nodes.
@@ -860,7 +869,8 @@
#define CST_CHECK(T) TREE_CLASS_CHECK (T, tcc_constant)
#define STMT_CHECK(T) TREE_CLASS_CHECK (T, tcc_statement)
#define FUNC_OR_METHOD_CHECK(T) TREE_CHECK2 (T, FUNCTION_TYPE, METHOD_TYPE)
-#define PTR_OR_REF_CHECK(T) TREE_CHECK2 (T, POINTER_TYPE, REFERENCE_TYPE)
+/* APPLE LOCAL blocks 5862465 */
+#define PTR_OR_REF_CHECK(T) TREE_CHECK3 (T, POINTER_TYPE, REFERENCE_TYPE, BLOCK_POINTER_TYPE)
#define RECORD_OR_UNION_CHECK(T) \
TREE_CHECK3 (T, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE)
@@ -989,8 +999,12 @@
(It should be renamed to INDIRECT_TYPE_P.) Keep these checks in
ascending code order. */
+/* APPLE LOCAL begin blocks 5862465 */
#define POINTER_TYPE_P(TYPE) \
- (TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE)
+ (TREE_CODE (TYPE) == POINTER_TYPE \
+ || TREE_CODE (TYPE) == REFERENCE_TYPE \
+ || TREE_CODE (TYPE) == BLOCK_POINTER_TYPE)
+/* APPLE LOCAL end blocks 5862465 */
/* Nonzero if this type is a complete type. */
#define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE)
@@ -1084,6 +1098,11 @@
#define TREE_OVERFLOW(NODE) (CST_CHECK (NODE)->common.public_flag)
+/* TREE_OVERFLOW can only be true for EXPR of CONSTANT_CLASS_P. */
+
+#define TREE_OVERFLOW_P(EXPR) \
+ (CONSTANT_CLASS_P (EXPR) && TREE_OVERFLOW (EXPR))
+
/* In a VAR_DECL, FUNCTION_DECL, NAMESPACE_DECL or TYPE_DECL,
nonzero means name is to be accessible from outside this module.
In an IDENTIFIER_NODE, nonzero means an external declaration
@@ -1221,6 +1240,12 @@
#define TREE_DEPRECATED(NODE) \
((NODE)->common.deprecated_flag)
+/* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) */
+/* Nonzero in a IDENTIFIER_NODE if the use of the name is defined as a
+ unavailable feature by __attribute__((unavailable)). */
+#define TREE_UNAVAILABLE(NODE) ((NODE)->common.unavailable_flag)
+/* APPLE LOCAL end "unavailable" attribute (Radar 2809697) */
+
/* Nonzero in an IDENTIFIER_NODE if the name is a local alias, whose
uses are to be substituted for uses of the TREE_CHAINed identifier. */
#define IDENTIFIER_TRANSPARENT_ALIAS(NODE) \
@@ -2082,6 +2107,17 @@
#define TYPE_CONTAINS_PLACEHOLDER_INTERNAL(NODE) \
(TYPE_CHECK (NODE)->type.contains_placeholder_bits)
+/* APPLE LOCAL begin radar 5811943 - Fix type of pointers to blocks */
+/* Indicates that the struct type is a block struct, rather than
+ a 'normal' struct, i.e. one of its fields is a function that can
+ be called. This uses the existing bit-field lang_flag_2 in the
+ struct tree_type, rather than creating a new bit field, as
+ lang_flag_2 is currently unused and we don't want to increase the
+ size of trees if we can avoid it. */
+#define TYPE_BLOCK_IMPL_STRUCT(NODE) \
+(TYPE_CHECK (NODE)->type.lang_flag_2)
+/* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
+
struct die_struct;
struct tree_type GTY(())
@@ -2106,6 +2142,14 @@
unsigned lang_flag_0 : 1;
unsigned lang_flag_1 : 1;
+ /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to Blocks */
+ /* Since it is currently completely unused, and in the interest of
+ not making trees any bigger than they already are, lang_flag_2
+ in the tree_type struct will be used to indicate that a struct is a
+ block struct. The macro used for these purposes is
+ TYPE_BLOCK_IMPL_STRUCT, rather than TYPE_LANG_FLAG_2, in order to make
+ its uses in the code more clear. */
+ /* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
unsigned lang_flag_2 : 1;
unsigned lang_flag_3 : 1;
unsigned lang_flag_4 : 1;
@@ -2421,13 +2465,11 @@
/* Likewise for the size in bytes. */
#define DECL_SIZE_UNIT(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.size_unit)
/* Holds the alignment required for the datum, in bits. */
-#define DECL_ALIGN(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.u1.a.align)
+#define DECL_ALIGN(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.align)
/* The alignment of NODE, in bytes. */
#define DECL_ALIGN_UNIT(NODE) (DECL_ALIGN (NODE) / BITS_PER_UNIT)
-/* For FIELD_DECLs, off_align holds the number of low-order bits of
- DECL_FIELD_OFFSET which are known to be always zero.
- DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET
- has. */
+/* Set if the alignment of this DECL has been set by the user, for
+ example with an 'aligned' attribute. */
#define DECL_USER_ALIGN(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.user_align)
/* Holds the machine mode corresponding to the declaration of a variable or
field. Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a
@@ -2438,7 +2480,8 @@
operation it is. Note, however, that this field is overloaded, with
DECL_BUILT_IN_CLASS as the discriminant, so the latter must always be
checked before any access to the former. */
-#define DECL_FUNCTION_CODE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_common.u1.f)
+#define DECL_FUNCTION_CODE(NODE) \
+ (FUNCTION_DECL_CHECK (NODE)->function_decl.function_code)
#define DECL_DEBUG_EXPR_IS_FROM(NODE) \
(DECL_COMMON_CHECK (NODE)->decl_common.debug_expr_is_from)
@@ -2576,21 +2619,13 @@
unsigned gimple_reg_flag : 1;
unsigned call_clobbered_flag : 1;
- union tree_decl_u1 {
- /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is
- DECL_FUNCTION_CODE. */
- enum built_in_function f;
- /* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this
- is used by language-dependent code. */
- HOST_WIDE_INT i;
- /* DECL_ALIGN and DECL_OFFSET_ALIGN. (These are not used for
- FUNCTION_DECLs). */
- struct tree_decl_u1_a {
- unsigned int align : 24;
- unsigned int off_align : 8;
- } a;
- } GTY ((skip)) u1;
+ /* APPLE LOCAL duplicate decls in multiple files. */
+ unsigned duplicate_decl : 1;
+ unsigned int align : 24;
+ /* DECL_OFFSET_ALIGN, used only for FIELD_DECLs. */
+ unsigned int off_align : 8;
+
tree size_unit;
tree initial;
tree attributes;
@@ -2674,11 +2709,11 @@
DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET
has. */
#define DECL_OFFSET_ALIGN(NODE) \
- (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl_common.u1.a.off_align)
+ (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl_common.off_align)
/* Specify that DECL_ALIGN(NODE) is a multiple of X. */
#define SET_DECL_OFFSET_ALIGN(NODE, X) \
- (FIELD_DECL_CHECK (NODE)->decl_common.u1.a.off_align = exact_log2 ((X) & -(X)))
+ (FIELD_DECL_CHECK (NODE)->decl_common.off_align = exact_log2 ((X) & -(X)))
/* 1 if the alignment for this type was requested by "aligned" attribute,
0 if it is the default for this type. */
@@ -2768,6 +2803,9 @@
so it should not be output now. */
#define DECL_DEFER_OUTPUT(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.defer_output)
+/* APPLE LOCAL duplicate decls in multiple files. */
+#define DECL_DUPLICATE_DECL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.duplicate_decl)
+
/* Nonzero for a given ..._DECL node means that no warnings should be
generated just because this node is unused. */
#define DECL_IN_SYSTEM_HEADER(NODE) \
@@ -2911,7 +2949,21 @@
/* Belongs to VAR_DECL exclusively. */
ENUM_BITFIELD(tls_model) tls_model : 3;
- /* 11 unused bits. */
+
+ /* APPLE LOCAL begin radar 5732232 - blocks */
+ /* Belong to VAR_DECL exclusively. */
+ unsigned block_decl_byref : 1;
+ unsigned block_decl_copied : 1;
+ /* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
+ unsigned copyable_byref_local_var : 1;
+ unsigned copyable_byref_local_nonpod : 1;
+ /* APPLE LOCAL radar 6172148 */
+ unsigned block_synthesized_function : 1;
+ /* APPLE LOCAL radar 5847976 */
+ unsigned block_weak : 1;
+ /* 5 unused bits. */
+ /* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+ /* APPLE LOCAL end radar 5732232 - blocks */
};
/* In a VAR_DECL that's static,
@@ -2957,6 +3009,19 @@
thread-local storage. */
#define DECL_TLS_MODEL(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.tls_model)
+/* APPLE LOCAL begin radar 5732232 - blocks */
+#define BLOCK_DECL_BYREF(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_decl_byref)
+#define BLOCK_DECL_COPIED(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_decl_copied)
+/* APPLE LOCAL end radar 5732232 - blocks */
+/* APPLE LOCAL radar 6172148 */
+#define BLOCK_SYNTHESIZED_FUNC(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.block_synthesized_function)
+/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
+#define COPYABLE_BYREF_LOCAL_VAR(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_var)
+#define COPYABLE_BYREF_LOCAL_NONPOD(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_nonpod)
+/* APPLE LOCAL radar 5847976 */
+#define COPYABLE_WEAK_BLOCK(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_weak)
+/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
+
/* In a VAR_DECL, nonzero if the data should be allocated from
thread-local storage. */
#define DECL_THREAD_LOCAL_P(NODE) \
@@ -3091,6 +3156,10 @@
{
struct tree_decl_non_common common;
+ /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is
+ DECL_FUNCTION_CODE. Otherwise unused. */
+ enum built_in_function function_code;
+
unsigned static_ctor_flag : 1;
unsigned static_dtor_flag : 1;
unsigned uninlinable : 1;
@@ -3240,6 +3309,9 @@
TI_UINTDI_TYPE,
TI_UINTTI_TYPE,
+ TI_UINT32_TYPE,
+ TI_UINT64_TYPE,
+
TI_INTEGER_ZERO,
TI_INTEGER_ONE,
TI_INTEGER_MINUS_ONE,
@@ -3315,6 +3387,9 @@
#define unsigned_intDI_type_node global_trees[TI_UINTDI_TYPE]
#define unsigned_intTI_type_node global_trees[TI_UINTTI_TYPE]
+#define uint32_type_node global_trees[TI_UINT32_TYPE]
+#define uint64_type_node global_trees[TI_UINT64_TYPE]
+
#define integer_zero_node global_trees[TI_INTEGER_ZERO]
#define integer_one_node global_trees[TI_INTEGER_ONE]
#define integer_minus_one_node global_trees[TI_INTEGER_MINUS_ONE]
@@ -3597,6 +3672,8 @@
extern void fixup_unsigned_type (tree);
extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool);
extern tree build_pointer_type (tree);
+/* APPLE LOCAL radar 5732232 - blocks */
+extern tree build_block_pointer_type (tree);
extern tree build_reference_type_for_mode (tree, enum machine_mode, bool);
extern tree build_reference_type (tree);
extern tree build_vector_type_for_mode (tree, enum machine_mode);
@@ -4180,7 +4257,7 @@
/* In tree.c */
extern unsigned crc32_string (unsigned, const char *);
extern void clean_symbol_name (char *);
-extern tree get_file_function_name_long (const char *);
+extern tree get_file_function_name (const char *);
extern tree get_callee_fndecl (tree);
extern void change_decl_assembler_name (tree, tree);
extern int type_num_arguments (tree);
@@ -4523,10 +4600,6 @@
extern const char *get_name (tree);
extern tree unshare_expr (tree);
extern void sort_case_labels (tree);
-
-/* If KIND=='I', return a suitable global initializer (constructor) name.
- If KIND=='D', return a suitable global clean-up (destructor) name. */
-extern tree get_file_function_name (int);
/* Interface of the DWARF2 unwind info support. */
@@ -4647,4 +4720,8 @@
/* In expr.c. */
extern unsigned HOST_WIDE_INT highest_pow2_factor (tree);
+/* APPLE LOCAL begin radar 6300081 */
+extern GTY(()) tree generic_block_literal_struct_type;
+/* APPLE LOCAL end radar 6300081 */
+
#endif /* GCC_TREE_H */
Modified: trunk/contrib/gcc/unwind-dw2.c
===================================================================
--- trunk/contrib/gcc4/unwind-dw2.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/unwind-dw2.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1438,17 +1438,6 @@
context->ra = __builtin_extract_return_addr (outer_ra);
}
-#if defined(__clang__) && defined(__amd64__)
-/* Some versions of clang don't save and restore all callee registers, if a
- __builtin_eh_return() intrinsic is used in a function. This is particularly
- bad on amd64. For now, use the following ugly hack to force it to assume
- those registers are clobbered, when invoking __builtin_eh_return(), so it
- will emit code to save and restore them. */
-#define CLOBBER_REGS_HACK \
- __asm __volatile(" " : : : "r15", "r14", "r13", "r12", "rbx", "rdx", "rax");
-#else
-#define CLOBBER_REGS_HACK
-#endif /* __clang__ */
/* Install TARGET into CURRENT so that we can return to it. This is a
macro because __builtin_eh_return must be invoked in the context of
@@ -1459,7 +1448,6 @@
{ \
long offset = uw_install_context_1 ((CURRENT), (TARGET)); \
void *handler = __builtin_frob_return_addr ((TARGET)->ra); \
- CLOBBER_REGS_HACK \
__builtin_eh_return (offset, handler); \
} \
while (0)
Modified: trunk/contrib/gcc/varasm.c
===================================================================
--- trunk/contrib/gcc4/varasm.c 2018-06-04 03:52:12 UTC (rev 10404)
+++ trunk/contrib/gcc/varasm.c 2018-06-04 17:30:21 UTC (rev 10405)
@@ -1383,7 +1383,7 @@
if (flag_reorder_blocks_and_partition)
{
switch_to_section (unlikely_text_section ());
- assemble_align (FUNCTION_BOUNDARY);
+ assemble_align (DECL_ALIGN (decl));
ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_label);
/* When the function starts with a cold section, we need to explicitly
@@ -1393,7 +1393,7 @@
&& BB_PARTITION (ENTRY_BLOCK_PTR->next_bb) == BB_COLD_PARTITION)
{
switch_to_section (text_section);
- assemble_align (FUNCTION_BOUNDARY);
+ assemble_align (DECL_ALIGN (decl));
ASM_OUTPUT_LABEL (asm_out_file, cfun->hot_section_label);
hot_label_written = true;
first_function_block_is_cold = true;
@@ -1424,9 +1424,7 @@
ASM_OUTPUT_LABEL (asm_out_file, cfun->hot_section_label);
/* Tell assembler to move to target machine's alignment for functions. */
- align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
- if (align < force_align_functions_log)
- align = force_align_functions_log;
+ align = floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT);
if (align > 0)
{
ASM_OUTPUT_ALIGN (asm_out_file, align);
@@ -1433,9 +1431,10 @@
}
/* Handle a user-specified function alignment.
- Note that we still need to align to FUNCTION_BOUNDARY, as above,
+ Note that we still need to align to DECL_ALIGN, as above,
because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */
- if (align_functions_log > align
+ if (! DECL_USER_ALIGN (decl)
+ && align_functions_log > align
&& cfun->function_frequency != FUNCTION_FREQUENCY_UNLIKELY_EXECUTED)
{
#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
@@ -4072,6 +4071,8 @@
case ENUMERAL_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
+ /* APPLE LOCAL radar 5822844 */
+ case BLOCK_POINTER_TYPE:
case OFFSET_TYPE:
if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
EXPAND_INITIALIZER),
More information about the Midnightbsd-cvs
mailing list