]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/config/msp430/msp430.c
Wrap option names in gcc internal messages with %< and %>.
[thirdparty/gcc.git] / gcc / config / msp430 / msp430.c
index 3d33f7caba84b9eced2f77a5d918ad916b576d1f..48d16a4d2ec7df45a343ddbe10b73928b947cb17 100644 (file)
@@ -1,5 +1,5 @@
 /* Subroutines used for code generation on TI MSP430 processors.
-   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+   Copyright (C) 2012-2019 Free Software Foundation, Inc.
    Contributed by Red Hat.
 
    This file is part of GCC.
@@ -18,6 +18,8 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define IN_TARGET_CODE 1
+
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -723,10 +725,25 @@ msp430_mcu_name (void)
   if (target_mcu)
     {
       unsigned int i;
-      static char mcu_name [64];
+      unsigned int start_upper;
+      unsigned int end_upper;
+      static char mcu_name[64];
 
-      snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
-      for (i = strlen (mcu_name); i--;)
+      /* The 'i' in the device name symbol for msp430i* devices must be lower
+        case, to match the expected symbol in msp430.h.  */
+      if (strncmp (target_mcu, "msp430i", 7) == 0)
+       {
+         snprintf (mcu_name, sizeof (mcu_name) - 1, "__MSP430i%s__",
+                   target_mcu + 7);
+         start_upper = 9;
+       }
+      else
+       {
+         snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
+         start_upper = 2;
+       }
+      end_upper = strlen (mcu_name) - 2;
+      for (i = start_upper; i < end_upper; i++)
        mcu_name[i] = TOUPPER (mcu_name[i]);
       return mcu_name;
     }
@@ -780,26 +797,31 @@ msp430_option_override (void)
            if (msp430_warn_mcu)
              {
                if (target_cpu&& msp430x != xisa)
-                 warning (0, "MCU '%s' supports %s ISA but -mcpu option is set to %s",
+                 warning (0, "MCU '%s' supports %s ISA but %<-mcpu%> option "
+                          "is set to %s",
                           target_mcu, xisa ? "430X" : "430", msp430x ? "430X" : "430");
 
                if (msp430_mcu_data[i].hwmpy == 0
                    && msp430_hwmult_type != MSP430_HWMULT_AUTO
                    && msp430_hwmult_type != MSP430_HWMULT_NONE)
-                 warning (0, "MCU '%s' does not have hardware multiply support, but -mhwmult is set to %s",
+                 warning (0, "MCU '%s' does not have hardware multiply "
+                          "support, but %<-mhwmult%> is set to %s",
                           target_mcu,
                           msp430_hwmult_type == MSP430_HWMULT_SMALL ? "16-bit"
                           : msp430_hwmult_type == MSP430_HWMULT_LARGE ? "32-bit" : "f5series");
                else if (msp430_hwmult_type == MSP430_HWMULT_SMALL
                    && msp430_mcu_data[i].hwmpy != 1
                    && msp430_mcu_data[i].hwmpy != 2 )
-                 warning (0, "MCU '%s' supports %s hardware multiply, but -mhwmult is set to 16-bit",
+                 warning (0, "MCU '%s' supports %s hardware multiply, "
+                          "but %<-mhwmult%> is set to 16-bit",
                           target_mcu, hwmult_name (msp430_mcu_data[i].hwmpy));
                else if (msp430_hwmult_type == MSP430_HWMULT_LARGE && msp430_mcu_data[i].hwmpy != 4)
-                 warning (0, "MCU '%s' supports %s hardware multiply, but -mhwmult is set to 32-bit",
+                 warning (0, "MCU '%s' supports %s hardware multiply, "
+                          "but %<-mhwmult%> is set to 32-bit",
                           target_mcu, hwmult_name (msp430_mcu_data[i].hwmpy));
                else if (msp430_hwmult_type == MSP430_HWMULT_F5SERIES && msp430_mcu_data[i].hwmpy != 8)
-                 warning (0, "MCU '%s' supports %s hardware multiply, but -mhwmult is set to f5series",
+                 warning (0, "MCU '%s' supports %s hardware multiply, "
+                          "but %<-mhwmult%> is set to f5series",
                           target_mcu, hwmult_name (msp430_mcu_data[i].hwmpy));
              }
 
@@ -817,13 +839,13 @@ msp430_option_override (void)
                    warning (0,
                             "Unrecognized MCU name '%s', assuming that it is "
                             "just a MSP430 with no hardware multiply.\n"
-                            "Use the -mcpu and -mhwmult options to set "
-                            "these explicitly.",
+                            "Use the %<-mcpu%> and %<-mhwmult%> options to "
+                            "set these explicitly.",
                             target_mcu);
                  else
                    warning (0,
                             "Unrecognized MCU name '%s', assuming that it "
-                            "has no hardware multiply.\nUse the -mhwmult "
+                            "has no hardware multiply.\nUse the %<-mhwmult%> "
                             "option to set this explicitly.",
                             target_mcu);
                }
@@ -835,8 +857,8 @@ msp430_option_override (void)
              if (msp430_warn_mcu)
                warning (0,
                         "Unrecognized MCU name '%s', assuming that it just "
-                        "supports the MSP430 ISA.\nUse the -mcpu option to "
-                        "set the ISA explicitly.",
+                        "supports the MSP430 ISA.\nUse the %<-mcpu%> option "
+                        "to set the ISA explicitly.",
                         target_mcu);
 
              msp430x = false;
@@ -851,12 +873,12 @@ msp430_option_override (void)
     msp430x = true;
 
   if (TARGET_LARGE && !msp430x)
-    error ("-mlarge requires a 430X-compatible -mmcu=");
+    error ("%<-mlarge%> requires a 430X-compatible %<-mmcu=%>");
 
   if (msp430_code_region == MSP430_REGION_UPPER && ! msp430x)
-    error ("-mcode-region=upper requires 430X-compatible cpu");
+    error ("%<-mcode-region=upper%> requires 430X-compatible cpu");
   if (msp430_data_region == MSP430_REGION_UPPER && ! msp430x)
-    error ("-mdata-region=upper requires 430X-compatible cpu");
+    error ("%<-mdata-region=upper%> requires 430X-compatible cpu");
 
   if (flag_exceptions || flag_non_call_exceptions
       || flag_unwind_tables || flag_asynchronous_unwind_tables)
@@ -912,6 +934,8 @@ msp430_hard_regno_nregs (unsigned int, machine_mode mode)
 {
   if (mode == PSImode && msp430x)
     return 1;
+  if (mode == CPSImode && msp430x)
+    return 2;
   return ((GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1)
          / UNITS_PER_WORD);
 }
@@ -934,6 +958,8 @@ msp430_hard_regno_nregs_with_padding (int regno ATTRIBUTE_UNUSED,
 {
   if (mode == PSImode)
     return 2;
+  if (mode == CPSImode)
+    return 4;
   return msp430_hard_regno_nregs (regno, mode);
 }
 
@@ -1849,6 +1875,17 @@ msp430_allocate_stack_slots_for_args (void)
   return ! is_naked_func ();
 }
 
+#undef TARGET_WARN_FUNC_RETURN
+#define TARGET_WARN_FUNC_RETURN msp430_warn_func_return
+
+static bool
+msp430_warn_func_return (tree decl)
+{
+  /* Naked functions are implemented entirely in assembly, including the
+     return sequence, so suppress warnings about this.  */
+  return !is_naked_func (decl);
+}
+
 /* Verify MSP430 specific attributes.  */
 #define TREE_NAME_EQ(NAME, STR) (strcmp (IDENTIFIER_POINTER (NAME), (STR)) == 0)
 
@@ -1861,11 +1898,9 @@ msp430_attr (tree * node,
 {
   gcc_assert (DECL_P (* node));
 
+  /* Only the interrupt attribute takes an argument.  */
   if (args != NULL)
     {
-      /* Only the interrupt attribute takes an argument.  */
-      gcc_assert (TREE_NAME_EQ (name, ATTR_INTR));
-
       tree value = TREE_VALUE (args);
 
       switch (TREE_CODE (value))
@@ -1910,13 +1945,19 @@ msp430_attr (tree * node,
       if (TREE_CODE (TREE_TYPE (* node)) == FUNCTION_TYPE
          && ! VOID_TYPE_P (TREE_TYPE (TREE_TYPE (* node))))
        message = "interrupt handlers must be void";
-
-      if (! TREE_PUBLIC (* node))
-       message = "interrupt handlers cannot be static";
-
-      /* Ensure interrupt handlers never get optimised out.  */
-      TREE_USED (* node) = 1;
-      DECL_PRESERVE_P (* node) = 1;
+      else
+       {
+         /* Ensure interrupt handlers never get optimised out.  */
+         TREE_USED (* node) = 1;
+         DECL_PRESERVE_P (* node) = 1;
+       }
+      if (is_critical_func (* node))
+       {
+         warning (OPT_Wattributes,
+                  "critical attribute has no effect on interrupt functions");
+         DECL_ATTRIBUTES (*node) = remove_attribute (ATTR_CRIT,
+                                                     DECL_ATTRIBUTES (* node));
+       }
     }
   else if (TREE_NAME_EQ (name, ATTR_REENT))
     {
@@ -1931,6 +1972,8 @@ msp430_attr (tree * node,
        message = "naked functions cannot be critical";
       else if (is_reentrant_func (* node))
        message = "reentrant functions cannot be critical";
+      else if (is_interrupt_func ( *node))
+       message = "critical attribute has no effect on interrupt functions";
     }
   else if (TREE_NAME_EQ (name, ATTR_NAKED))
     {
@@ -2049,28 +2092,28 @@ msp430_data_attr (tree * node,
 /* Table of MSP430-specific attributes.  */
 const struct attribute_spec msp430_attribute_table[] =
 {
-  /* Name        min_num_args     type_req,             affects_type_identity
-                      max_num_args,     fn_type_req
-                          decl_req               handler.  */
-  { ATTR_INTR,        0, 1, true,  false, false, msp430_attr, false, NULL },
-  { ATTR_NAKED,       0, 0, true,  false, false, msp430_attr, false, NULL },
-  { ATTR_REENT,       0, 0, true,  false, false, msp430_attr, false, NULL },
-  { ATTR_CRIT,        0, 0, true,  false, false, msp430_attr, false, NULL },
-  { ATTR_WAKEUP,      0, 0, true,  false, false, msp430_attr, false, NULL },
+  /* Name        min_num_args     type_req,             handler
+                     max_num_args,     fn_type_req             exclude
+                          decl_req               affects_type_identity.  */
+  { ATTR_INTR,        0, 1, true,  false, false, false, msp430_attr, NULL },
+  { ATTR_NAKED,       0, 0, true,  false, false, false, msp430_attr, NULL },
+  { ATTR_REENT,       0, 0, true,  false, false, false, msp430_attr, NULL },
+  { ATTR_CRIT,        0, 0, true,  false, false, false, msp430_attr, NULL },
+  { ATTR_WAKEUP,      0, 0, true,  false, false, false, msp430_attr, NULL },
 
-  { ATTR_LOWER,       0, 0, true,  false, false, msp430_section_attr, false,
+  { ATTR_LOWER,       0, 0, true,  false, false, false, msp430_section_attr,
     NULL },
-  { ATTR_UPPER,       0, 0, true,  false, false, msp430_section_attr, false,
+  { ATTR_UPPER,       0, 0, true,  false, false, false, msp430_section_attr,
     NULL },
-  { ATTR_EITHER,      0, 0, true,  false, false, msp430_section_attr, false,
+  { ATTR_EITHER,      0, 0, true,  false, false, false, msp430_section_attr,
     NULL },
 
-  { ATTR_NOINIT,      0, 0, true,  false, false, msp430_data_attr, false,
+  { ATTR_NOINIT,      0, 0, true,  false, false, false, msp430_data_attr,
     NULL },
-  { ATTR_PERSIST,     0, 0, true,  false, false, msp430_data_attr, false,
+  { ATTR_PERSIST,     0, 0, true,  false, false, false, msp430_data_attr,
     NULL },
 
-  { NULL,             0, 0, false, false, false, NULL, false, NULL }
+  { NULL,             0, 0, false, false, false, false, NULL,  NULL }
 };
 
 #undef  TARGET_ASM_FUNCTION_PROLOGUE
@@ -3399,6 +3442,9 @@ msp430_output_labelref (FILE *file, const char *name)
        }
     }
 
+  if (user_label_prefix[0] != 0)
+    fputs (user_label_prefix, file);
+
   fputs (name, file);
 }
 
@@ -3437,6 +3483,11 @@ msp430_print_operand_raw (FILE * file, rtx op)
     }
 }
 
+#undef  TARGET_ASM_ALIGNED_PSI_OP
+#define TARGET_ASM_ALIGNED_PSI_OP "\t.long\t"
+#undef  TARGET_ASM_UNALIGNED_PSI_OP
+#define TARGET_ASM_UNALIGNED_PSI_OP TARGET_ASM_ALIGNED_PSI_OP
+
 #undef  TARGET_PRINT_OPERAND_ADDRESS
 #define TARGET_PRINT_OPERAND_ADDRESS   msp430_print_operand_addr
 
@@ -3839,6 +3890,9 @@ msp430_can_change_mode_class (machine_mode from, machine_mode to, reg_class_t)
   return true;
 }
 \f
+#undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
+#define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-msp430.h"