]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/go/go-lang.c
Update copyright years.
[thirdparty/gcc.git] / gcc / go / go-lang.c
index 09e4fea09a5d4e3766cee575adc74496175b3a2e..387694e4f56d610aeda03e52059fc3aab83402df 100644 (file)
@@ -1,5 +1,5 @@
 /* go-lang.c -- Go frontend gcc interface.
-   Copyright (C) 2009-2017 Free Software Foundation, Inc.
+   Copyright (C) 2009-2020 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -39,6 +39,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "go-c.h"
 #include "go-gcc.h"
 
+#ifndef TARGET_AIX
+#define TARGET_AIX 0
+#endif
+
 /* Language-dependent contents of a type.  */
 
 struct GTY(()) lang_type
@@ -112,6 +116,9 @@ go_langhook_init (void)
   args.check_divide_overflow = go_check_divide_overflow;
   args.compiling_runtime = go_compiling_runtime;
   args.debug_escape_level = go_debug_escape_level;
+  args.debug_escape_hash = go_debug_escape_hash;
+  args.nil_check_size_threshold = TARGET_AIX ? -1 : 4096;
+  args.debug_optimization = go_debug_optimization;
   args.linemap = go_get_linemap();
   args.backend = go_get_backend();
   go_create_gogo (&args);
@@ -188,7 +195,7 @@ static bool
 go_langhook_handle_option (
     size_t scode,
     const char *arg,
-    int value ATTRIBUTE_UNUSED,
+    HOST_WIDE_INT value,
     int kind ATTRIBUTE_UNUSED,
     location_t loc ATTRIBUTE_UNUSED,
     const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
@@ -245,7 +252,7 @@ go_langhook_handle_option (
       break;
 
     case OPT_fgo_optimize_:
-      ret = go_enable_optimize (arg) ? true : false;
+      ret = go_enable_optimize (arg, value) ? true : false;
       break;
 
     case OPT_fgo_pkgpath_:
@@ -286,12 +293,17 @@ go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED)
     go_add_search_path (dir);
   go_search_dirs.release ();
 
-  if (flag_excess_precision_cmdline == EXCESS_PRECISION_DEFAULT)
-    flag_excess_precision_cmdline = EXCESS_PRECISION_STANDARD;
+  if (flag_excess_precision == EXCESS_PRECISION_DEFAULT)
+    flag_excess_precision = EXCESS_PRECISION_STANDARD;
 
   /* Tail call optimizations can confuse uses of runtime.Callers.  */
-  if (!global_options_set.x_flag_optimize_sibling_calls)
-    global_options.x_flag_optimize_sibling_calls = 0;
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                      flag_optimize_sibling_calls, 0);
+
+  /* Partial inlining can confuses uses of runtime.Callers.
+     See https://gcc.gnu.org/PR91663.  */
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                      flag_partial_inlining, 0);
 
   /* If the debug info level is still 1, as set in init_options, make
      sure that some debugging type is selected.  */
@@ -300,18 +312,18 @@ go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED)
     global_options.x_write_symbols = PREFERRED_DEBUGGING_TYPE;
 
   /* We turn on stack splitting if we can.  */
-  if (!global_options_set.x_flag_split_stack
-      && targetm_common.supports_split_stack (false, &global_options))
-    global_options.x_flag_split_stack = 1;
+  if (targetm_common.supports_split_stack (false, &global_options))
+    SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                        flag_split_stack, 1);
 
   /* If stack splitting is turned on, and the user did not explicitly
      request function partitioning, turn off partitioning, as it
      confuses the linker when trying to handle partitioned split-stack
      code that calls a non-split-stack function.  */
   if (global_options.x_flag_split_stack
-      && global_options.x_flag_reorder_blocks_and_partition
-      && !global_options_set.x_flag_reorder_blocks_and_partition)
-    global_options.x_flag_reorder_blocks_and_partition = 0;
+      && global_options.x_flag_reorder_blocks_and_partition)
+    SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                        flag_reorder_blocks_and_partition, 0);
 
   /* Returning false means that the backend should be used.  */
   return false;
@@ -372,7 +384,16 @@ go_langhook_type_for_mode (machine_mode mode, int unsignedp)
      make sense for the middle-end to ask the frontend for a type
      which the frontend does not support.  However, at least for now
      it is required.  See PR 46805.  */
-  if (VECTOR_MODE_P (mode))
+  if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL
+      && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
+    {
+      unsigned int elem_bits = vector_element_size (GET_MODE_BITSIZE (mode),
+                                                   GET_MODE_NUNITS (mode));
+      tree bool_type = build_nonstandard_boolean_type (elem_bits);
+      return build_vector_type_for_mode (bool_type, mode);
+    }
+  else if (VECTOR_MODE_P (mode)
+          && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
     {
       tree inner;
 
@@ -382,12 +403,14 @@ go_langhook_type_for_mode (machine_mode mode, int unsignedp)
       return NULL_TREE;
     }
 
-  enum mode_class mc = GET_MODE_CLASS (mode);
-  if (mc == MODE_INT)
-    return go_langhook_type_for_size (GET_MODE_BITSIZE (mode), unsignedp);
-  else if (mc == MODE_FLOAT)
+  scalar_int_mode imode;
+  scalar_float_mode fmode;
+  complex_mode cmode;
+  if (is_int_mode (mode, &imode))
+    return go_langhook_type_for_size (GET_MODE_BITSIZE (imode), unsignedp);
+  else if (is_float_mode (mode, &fmode))
     {
-      switch (GET_MODE_BITSIZE (mode))
+      switch (GET_MODE_BITSIZE (fmode))
        {
        case 32:
          return float_type_node;
@@ -396,13 +419,13 @@ go_langhook_type_for_mode (machine_mode mode, int unsignedp)
        default:
          // We have to check for long double in order to support
          // i386 excess precision.
-         if (mode == TYPE_MODE(long_double_type_node))
+         if (fmode == TYPE_MODE(long_double_type_node))
            return long_double_type_node;
        }
     }
-  else if (mc == MODE_COMPLEX_FLOAT)
+  else if (is_complex_float_mode (mode, &cmode))
     {
-      switch (GET_MODE_BITSIZE (mode))
+      switch (GET_MODE_BITSIZE (cmode))
        {
        case 64:
          return complex_float_type_node;
@@ -411,7 +434,7 @@ go_langhook_type_for_mode (machine_mode mode, int unsignedp)
        default:
          // We have to check for long double in order to support
          // i386 excess precision.
-         if (mode == TYPE_MODE(complex_long_double_type_node))
+         if (cmode == TYPE_MODE(complex_long_double_type_node))
            return complex_long_double_type_node;
        }
     }