This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[VMS/committed]: Add -mpointer-size switch


Hi,

Now that '#pragma pointer_size' is supported by GCC for VMS, we can add the '-mpointer-size' switch (modeled on /POINTER_SIZE=xx DEC-C qualifier) to set the default pointer size.  This also makes alpha64-dec-*vms* target obsolete (but still supported by alpha*-dec-*vms*).
The patch has many chunks to adjust ™ declarations.  Documentation will follow.

Tested by build gcc, committed on trunk.

Tristan.

2012-03-12  Tristan Gingold  <gingold@adacore.com>

       * config/vms/vms.opt: Add vms-opts.h header.
       (mmalloc64): Use flag_vms_malloc64 flag instead of MALLOC64
       target mask.
       (-mvms-return-codes): Document.
       (-mpointer-size): New option.
       (vms_pointer_size): Add enumeration.
       * config/vms/vms-opts.h: New file.
       * config/vms/vms.h (TARGET_OS_CPP_BUILTINS): Define
       __INITIAL_POINTER_SIZE.
       (POINTER_SIZE, SIZE_TYPE, PTRDIFF_TYPE): Adjust definition.
       (C_COMMON_OVERRIDE_OPTIONS): Define.
       (DWARF2_ADDR_SIZE): Define.
       * config/vms/vms.c (vms_patch_builtins): Adjust condition.
       * config/vms/vms-protos.h (vms_c_common_override_options):
       New prototype.
       * config/vms/vms-c.c (vms_pragma_pointer_size): Ignore pragma
       if -mno-pointer-size.
       (vms_c_common_override_options): New function.
       * config/ia64/vms.h (TARGET_DEFAULT): Remove MASK_MALLOC64.
       * config/alpha/vms.h (TARGET_DEFAULT): Remove MASK_MALLOC64.
       (MALLOC_ABI_ALIGNMENT): Use flag_vms_malloc64
       and flag_vms_pointer_size.
       (MASK_RETURN_ADDR): Set according to flag_vms_pointer_size.
       * config.gcc (*-*-*vms*): Define xm_file.
       (alpha*-dec-*vms*): Do not define xm_file.
       (alpha64-dec-*vms*): Remove.
       (ia64-hp-*vms*): Do not define xm_file.  Simplify tm_file
       and tmake_file.

ada/
2012-03-12  Tristan Gingold  <gingold@adacore.com>

       * gcc-interface/decl.c (gnat_to_gnu_param): Use flag_vms_malloc64
       instead of TARGET_MALLOC64.
       * gcc-interface/gigi.h (flag_vms_malloc64): Define instead
       of TARGET_MALLOC64.

libgcc/
2012-03-12  Tristan Gingold  <gingold@adacore.com>

       * config/alpha/t-vms: Define HOST_LIBGCC2_CFLAGS.
       * config/ia64/t-vms: Likewise.

diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 34183ba..120628e 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -5488,7 +5488,7 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech,
 
   /* VMS descriptors are themselves passed by reference.  */
   if (mech == By_Short_Descriptor ||
-      (mech == By_Descriptor && TARGET_ABI_OPEN_VMS && !TARGET_MALLOC64))
+      (mech == By_Descriptor && TARGET_ABI_OPEN_VMS && !flag_vms_malloc64))
     gnu_param_type
       = build_pointer_type (build_vms_descriptor32 (gnu_param_type,
 						    Mechanism (gnat_param),
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index 5e6495a..f7d787b 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -999,13 +999,11 @@ extern void enumerate_modes (void (*f) (const char *, int, int, int, int, int,
    intrusive preprocessor directives.  */
 #ifndef TARGET_ABI_OPEN_VMS
 #define TARGET_ABI_OPEN_VMS 0
-#endif
 
-/* VMS macro set by default, when clear forces 32bit mallocs and 32bit
+/* VMS option set by default, when clear forces 32bit mallocs and 32bit
    Descriptors. Always used in combination with TARGET_ABI_OPEN_VMS
    so no effect on non-VMS systems.  */
-#ifndef TARGET_MALLOC64
-#define TARGET_MALLOC64 0
+#define flag_vms_malloc64 0
 #endif
 
 /* Convenient shortcuts.  */
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 99f0b47..053f6ec 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -735,6 +735,7 @@ case ${target} in
   extra_objs="vms.o"
   target_gtfiles="$target_gtfiles \$(srcdir)/config/vms/vms.c"
   tm_p_file="${tm_p_file} vms/vms-protos.h"
+  xm_file="vms/xm-vms.h"
   c_target_objs="vms-c.o"
   cxx_target_objs="vms-c.o"
   if test x$gnu_ld != xyes; then
@@ -809,14 +810,8 @@ alpha*-dec-osf5.1*)
 	    ;;
 	esac
 	;;
-alpha64-dec-*vms*)
-	tm_file="${tm_file} vms/vms.h vms/vms64.h alpha/vms.h"
-	xm_file="alpha/xm-vms.h vms/xm-vms64.h"
-	tmake_file="${tmake_file} vms/t-vms64 alpha/t-vms"
-	;;
 alpha*-dec-*vms*)
 	tm_file="${tm_file} vms/vms.h alpha/vms.h"
-	xm_file="alpha/xm-vms.h"
 	tmake_file="${tmake_file} alpha/t-vms"
 	;;
 arm-wrs-vxworks)
@@ -1554,9 +1549,8 @@ ia64*-*-hpux*)
 	esac
 	;;
 ia64-hp-*vms*)
-	tm_file="${tm_file} elfos.h ia64/sysv4.h ia64/elf.h vms/vms.h vms/vms64.h ia64/vms.h"
-	xm_file="vms/xm-vms.h vms/xm-vms64.h"
-	tmake_file="${tmake_file} vms/t-vms64 ia64/t-ia64"
+	tm_file="${tm_file} elfos.h ia64/sysv4.h vms/vms.h ia64/vms.h"
+	tmake_file="${tmake_file} ia64/t-ia64"
 	target_cpu_default="0"
 	if test x$gas = xyes
 	then
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index a84c15e..2422da9 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -44,11 +44,7 @@ along with GCC; see the file COPYING3.  If not see
     } while (0)
 
 #undef TARGET_DEFAULT
-#if POINTER_SIZE == 64
-#define TARGET_DEFAULT (MASK_FPREGS | MASK_GAS | MASK_MALLOC64)
-#else
 #define TARGET_DEFAULT (MASK_FPREGS | MASK_GAS)
-#endif
 
 #define VMS_DEBUG_MAIN_POINTER "TRANSFER$BREAK$GO"
 
@@ -58,7 +54,9 @@ along with GCC; see the file COPYING3.  If not see
 
 /* The maximum alignment 'malloc' honors.  */
 #undef  MALLOC_ABI_ALIGNMENT
-#define MALLOC_ABI_ALIGNMENT ((TARGET_MALLOC64 ? 16 : 8) * BITS_PER_UNIT)
+#define MALLOC_ABI_ALIGNMENT \
+  ((flag_vms_malloc64 && flag_vms_pointer_size != VMS_POINTER_SIZE_NONE \
+   ? 16 : 8) * BITS_PER_UNIT)
 
 #undef FIXED_REGISTERS
 #define FIXED_REGISTERS  \
@@ -160,11 +158,12 @@ typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info;
 
 #define DEFAULT_PCC_STRUCT_RETURN 0
 
-#if POINTER_SIZE == 64
 /* Eventhough pointers are 64bits, only 32bit ever remain significant in code
    addresses.  */
-#define MASK_RETURN_ADDR (GEN_INT (0xffffffff))
-#endif
+#define MASK_RETURN_ADDR                                \
+  (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE       \
+   ? constm1_rtx                                        \
+   : GEN_INT (0xffffffff))
 
 #undef  ASM_WEAKEN_LABEL
 #define ASM_WEAKEN_LABEL(FILE, NAME)                            \
diff --git a/gcc/config/ia64/vms.h b/gcc/config/ia64/vms.h
index e847a0f..0c02f8a 100644
--- a/gcc/config/ia64/vms.h
+++ b/gcc/config/ia64/vms.h
@@ -28,11 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Need .debug_line info generated from gcc and gas.  */
 #undef TARGET_DEFAULT
-#if POINTER_SIZE == 64
-#define TARGET_DEFAULT (MASK_DWARF2_ASM | MASK_GNU_AS | MASK_MALLOC64)
-#else
 #define TARGET_DEFAULT (MASK_DWARF2_ASM | MASK_GNU_AS)
-#endif
 
 #define VMS_DEBUG_MAIN_POINTER "TRANSFER$BREAK$GO"
 
diff --git a/gcc/config/vms/vms-c.c b/gcc/config/vms/vms-c.c
index 4377eac..229846a 100644
--- a/gcc/config/vms/vms-c.c
+++ b/gcc/config/vms/vms-c.c
@@ -335,8 +335,8 @@ handle_pragma_pointer_size (const char *pragma_name)
 static void
 vms_pragma_pointer_size (cpp_reader * ARG_UNUSED (dummy))
 {
-  /* Ignore if 32 bit only.  */
-  if (POINTER_SIZE != 64)
+  /* Ignore if no -mpointer-size option.  */
+  if (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE)
     return;
 
   handle_pragma_pointer_size ("pointer_size");
@@ -449,3 +449,20 @@ vms_c_register_includes (const char *sysroot,
         }
     }
 }
+
+void
+vms_c_common_override_options (void)
+{
+  /* Initialize c_default_pointer_mode.  */
+  switch (flag_vms_pointer_size)
+    {
+    case VMS_POINTER_SIZE_NONE:
+      break;
+    case VMS_POINTER_SIZE_32:
+      c_default_pointer_mode = SImode;
+      break;
+    case VMS_POINTER_SIZE_64:
+      c_default_pointer_mode = DImode;
+      break;
+    }
+}
diff --git a/gcc/config/vms/vms-opts.h b/gcc/config/vms/vms-opts.h
new file mode 100644
index 0000000..979ff75
--- /dev/null
+++ b/gcc/config/vms/vms-opts.h
@@ -0,0 +1,31 @@
+/* Definitions for option handling for OpenVMS.
+   Copyright (C) 2012
+   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 3, 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 COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef VMS_OPTS_H
+#define VMS_OPTS_H
+
+enum vms_pointer_size
+  {
+    VMS_POINTER_SIZE_NONE,
+    VMS_POINTER_SIZE_32,
+    VMS_POINTER_SIZE_64
+  };
+
+#endif
diff --git a/gcc/config/vms/vms-protos.h b/gcc/config/vms/vms-protos.h
index a7ca346..a8b9ada 100644
--- a/gcc/config/vms/vms-protos.h
+++ b/gcc/config/vms/vms-protos.h
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* vms-c.c  */
 extern void vms_c_register_pragma (void);
+extern void vms_c_common_override_options (void);
 
 /* vms.c  */
 void vms_patch_builtins (void);
diff --git a/gcc/config/vms/vms.c b/gcc/config/vms/vms.c
index 6418536..4a7386f 100644
--- a/gcc/config/vms/vms.c
+++ b/gcc/config/vms/vms.c
@@ -160,9 +160,11 @@ vms_patch_builtins (void)
           alt[1 + nlen + 2] = 0;
           vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen);
 
-          use_64 = (((n->flags & VMS_CRTL_64) && POINTER_SIZE == 64)
+          use_64 = (((n->flags & VMS_CRTL_64)
+                     && flag_vms_pointer_size == VMS_POINTER_SIZE_64)
                     || ((n->flags & VMS_CRTL_MALLOC)
-                        && TARGET_MALLOC64));
+                        && flag_vms_malloc64
+                        && flag_vms_pointer_size != VMS_POINTER_SIZE_NONE));
           if (!use_64)
             vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen);
 
diff --git a/gcc/config/vms/vms.h b/gcc/config/vms/vms.h
index ab8f6e0..e11b1bf 100644
--- a/gcc/config/vms/vms.h
+++ b/gcc/config/vms/vms.h
@@ -21,17 +21,19 @@ along with GCC; see the file COPYING3.  If not see
 #define TARGET_OBJECT_SUFFIX ".obj"
 #define TARGET_EXECUTABLE_SUFFIX ".exe"
 
-#define TARGET_OS_CPP_BUILTINS()                     \
-  do {                                               \
-    builtin_define_std ("vms");                      \
-    builtin_define_std ("VMS");                      \
-    builtin_assert ("system=vms");                   \
-    SUBTARGET_OS_CPP_BUILTINS();                     \
-    if (POINTER_SIZE == 64)                          \
-      {                                              \
-        builtin_define ("__LONG_POINTERS=1");        \
-        builtin_define ("__int64=long long");        \
-      }                                              \
+#define TARGET_OS_CPP_BUILTINS()                                \
+  do {                                                          \
+    builtin_define_std ("vms");                                 \
+    builtin_define_std ("VMS");                                 \
+    builtin_assert ("system=vms");                              \
+    SUBTARGET_OS_CPP_BUILTINS();                                \
+    builtin_define ("__int64=long long");                       \
+    if (flag_vms_pointer_size == VMS_POINTER_SIZE_32)           \
+      builtin_define ("__INITIAL_POINTER_SIZE=32");             \
+    else if (flag_vms_pointer_size == VMS_POINTER_SIZE_64)      \
+      builtin_define ("__INITIAL_POINTER_SIZE=64");             \
+    if (POINTER_SIZE == 64)                                     \
+      builtin_define ("__LONG_POINTERS=1");                     \
   } while (0)
 
 extern void vms_c_register_includes (const char *, const char *, int);
@@ -53,15 +55,25 @@ extern void vms_c_register_includes (const char *, const char *, int);
 
 /* Pointer is 32 bits but the hardware has 64-bit addresses, sign extended.  */
 #undef POINTER_SIZE
-#define POINTER_SIZE 32
+#define POINTER_SIZE (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE ? 32 : 64)
 #define POINTERS_EXTEND_UNSIGNED 0
 
-/* Always 32 bits.  */
+/* FIXME: It should always be a 32 bit type.  */
 #undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE ? \
+		   "unsigned int" : "long long unsigned int")
+/* ???: Defined as a 'int' by dec-c, but obstack.h doesn't like it.  */
 #undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+#define PTRDIFF_TYPE (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE ? \
+                      "int" : "long long int")
+
+#define C_COMMON_OVERRIDE_OPTIONS vms_c_common_override_options ()
 
 /* VMS doesn't support other sections than .text for code.  */
 
 #define TARGET_ASM_FUNCTION_SECTION vms_function_section
+
+/* Always use 8 bytes addresses in dwarf2 debug info.  The default value doesn't
+   work as it may be 4 bytes, which won't match gas default (8 bytes for ia64),
+   and will thus produce incorrect values.  */
+#define DWARF2_ADDR_SIZE 8
diff --git a/gcc/config/vms/vms.opt b/gcc/config/vms/vms.opt
index a1713b8..4afe634 100644
--- a/gcc/config/vms/vms.opt
+++ b/gcc/config/vms/vms.opt
@@ -16,11 +16,14 @@
 ; along with GCC; see the file COPYING3.  If not see
 ; <http://www.gnu.org/licenses/>.
 
+HeaderInclude
+config/vms/vms-opts.h
+
 map
 Target RejectNegative
 
 mmalloc64
-Target Report Mask(MALLOC64)
+Target Report Var(flag_vms_malloc64) Init(1)
 Malloc data into P2 space
 
 mdebug-main=
@@ -28,4 +31,29 @@ Target RejectNegative Joined Var(vms_debug_main)
 Set name of main routine for the debugger
 
 mvms-return-codes
-Target RejectNegative
+Target Report Var(flag_vms_return_codes)
+Use VMS exit codes instead of posix ones
+
+mpointer-size=
+Target Joined Report RejectNegative Enum(vms_pointer_size) Var(flag_vms_pointer_size) Init(VMS_POINTER_SIZE_NONE)
+-mpointer-size=[no,32,short,64,long]	Set the default pointer size
+
+Enum
+Name(vms_pointer_size) Type(enum vms_pointer_size) UnknownError(unknown pointer size model %qs)
+
+EnumValue
+Enum(vms_pointer_size) String(no) Value(VMS_POINTER_SIZE_NONE)
+
+EnumValue
+Enum(vms_pointer_size) String(32) Value(VMS_POINTER_SIZE_32)
+
+EnumValue
+Enum(vms_pointer_size) String(short) Value(VMS_POINTER_SIZE_32)
+
+EnumValue
+Enum(vms_pointer_size) String(64) Value(VMS_POINTER_SIZE_64)
+
+EnumValue
+Enum(vms_pointer_size) String(long) Value(VMS_POINTER_SIZE_64)
+
+; This comment is to ensure we retain the blank line above.
diff --git a/gcc/config/vms/vms64.h b/gcc/config/vms/vms64.h
deleted file mode 100644
index 24249ce..0000000
--- a/gcc/config/vms/vms64.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Output variables, constants and external declarations, for GNU compiler.
-   Copyright (C) 2001, 2007, 2009 Free Software Foundation, Inc.
-   Contributed by Douglas Rupp (rupp@gnat.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 3, 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 COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#undef LONG_TYPE_SIZE
-#define LONG_TYPE_SIZE 64
-
-#undef POINTER_SIZE
-#define POINTER_SIZE 64
-
-/* Defaults to "long int" */
-#undef SIZE_TYPE
-#undef PTRDIFF_TYPE
diff --git a/libgcc/config/alpha/t-vms b/libgcc/config/alpha/t-vms
index dd5760d..870e44c 100644
--- a/libgcc/config/alpha/t-vms
+++ b/libgcc/config/alpha/t-vms
@@ -7,3 +7,5 @@ vms-dwarf2eh.o: $(srcdir)/config/alpha/vms-dwarf2eh.S
 	$(gcc_compile) -c -x assembler-with-cpp $<
 
 LIB2ADD += $(srcdir)/config/alpha/vms-gcc_shell_handler.c
+
+HOST_LIBGCC2_CFLAGS=-mpointer-size=64
diff --git a/libgcc/config/ia64/t-vms b/libgcc/config/ia64/t-vms
index 140c748..e95c58d 100644
--- a/libgcc/config/ia64/t-vms
+++ b/libgcc/config/ia64/t-vms
@@ -5,3 +5,5 @@ crtinitS.o: $(srcdir)/config/ia64/vms-crtinit.S
 	$(gcc_compile) -c -x assembler-with-cpp $<
 
 LIB2ADDEH += $(srcdir)/config/ia64/fde-vms.c
+
+HOST_LIBGCC2_CFLAGS=-mpointer-size=64


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]