From d50213e60fccf7b15095c01e4788f2ee52f6bdb7 Mon Sep 17 00:00:00 2001
From: uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 6 Feb 2002 20:55:37 +0000
Subject: [PATCH] 	* config/s390/linux64.h: Delete file. 	*
 config/s390/s390x.h: New file. 	* config.gcc (s390x-*-linux*): Use
 s390x.h instead of linux64.h 	as target header file. 	* config/s390/linux.h
 (TARGET_VERSION): Define depending on 	DEFAULT_TARGET_64BIT. 	(CPP_SPEC,
 ASM_SPEC, LINK_SPEC): Likewise. 	(SIZE_TYPE, PTRDIFF_TYPE): Likewise. 
 (NO_BUILTIN_SIZE_TYPE, NO_BUILTIN_PTRDIFF_TYPE): Define. 
 (CPP_ARCH31_SPEC, CPP_ARCH64_SPEC): New defines. 	(LINK_ARCH31_SPEC,
 LINK_ARCH64_SPEC): New defines. 	(EXTRA_SPEC): New define. 	*
 config/s390/s390.h (TARGET_VERSION): Define depending on 
 DEFAULT_TARGET_64BIT. 	(MASK_RETURN_ADDR): Add run-time check for
 TARGET_64BIT.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49552 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog             |  18 ++++++
 gcc/config.gcc            |   2 +-
 gcc/config/s390/linux.h   | 123 ++++++++++++++++++++++++++++----------
 gcc/config/s390/linux64.h |  65 --------------------
 gcc/config/s390/s390.h    |  13 ++--
 gcc/config/s390/s390x.h   |  27 +++++++++
 6 files changed, 148 insertions(+), 100 deletions(-)
 delete mode 100644 gcc/config/s390/linux64.h
 create mode 100644 gcc/config/s390/s390x.h

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c1ba34f534fb..8ccd65726471 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2002-02-06  Ulrich Weigand  <uweigand@de.ibm.com>
+
+	* config/s390/linux64.h: Delete file.
+	* config/s390/s390x.h: New file.
+	* config.gcc (s390x-*-linux*): Use s390x.h instead of linux64.h
+	as target header file.
+	* config/s390/linux.h (TARGET_VERSION): Define depending on
+	DEFAULT_TARGET_64BIT.
+	(CPP_SPEC, ASM_SPEC, LINK_SPEC): Likewise.
+	(SIZE_TYPE, PTRDIFF_TYPE): Likewise.
+	(NO_BUILTIN_SIZE_TYPE, NO_BUILTIN_PTRDIFF_TYPE): Define.
+	(CPP_ARCH31_SPEC, CPP_ARCH64_SPEC): New defines.
+	(LINK_ARCH31_SPEC, LINK_ARCH64_SPEC): New defines.
+	(EXTRA_SPEC): New define.
+	* config/s390/s390.h (TARGET_VERSION): Define depending on
+	DEFAULT_TARGET_64BIT.
+	(MASK_RETURN_ADDR): Add run-time check for TARGET_64BIT.
+
 2002-02-06  Jason Merrill  <jason@redhat.com>
 
 	* c-decl.c (finish_function): Warn about a non-void function with
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 9a9cfd5effa5..96d1137eed3a 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2870,7 +2870,7 @@ s390-*-linux*)
 	fi
 	;;
 s390x-*-linux*)
-	tm_file="s390/s390.h dbxelf.h elfos.h svr4.h linux.h s390/linux.h s390/linux64.h"
+	tm_file="s390/s390x.h s390/s390.h dbxelf.h elfos.h svr4.h linux.h s390/linux.h"
 	tm_p_file=s390/s390-protos.h
 	md_file=s390/s390.md
 	out_file=s390/s390.c
diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
index 55c602edb24f..cfd4ebf940cd 100644
--- a/gcc/config/s390/linux.h
+++ b/gcc/config/s390/linux.h
@@ -1,5 +1,5 @@
 /* Definitions for Linux for S/390.
-   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Hartmut Penner (hpenner@de.ibm.com) and
                   Ulrich Weigand (uweigand@de.ibm.com).
 
@@ -23,51 +23,114 @@ Boston, MA 02111-1307, USA.  */
 #ifndef _LINUX_H
 #define _LINUX_H
 
-#undef SIZE_TYPE                       /* use default                      */
+/* Target specific version string.  */
 
-#undef TARGET_VERSION
+#ifdef DEFAULT_TARGET_64BIT
+#undef  TARGET_VERSION
+#define TARGET_VERSION fprintf (stderr, " (Linux for zSeries)");
+#else
+#undef  TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (Linux for S/390)");
+#endif
 
-/* Names to predefine in the preprocessor for this target machine.  */
 
-#define CPP_PREDEFINES "-Dlinux -Asystem(linux) -Acpu(s390) -Amachine(s390) -D__s390__ -Asystem(unix) -Dunix -D__ELF__"
+/* Target specific type definitions.  */
 
-/* 
- * Caller save not (always) working in gcc-2.95.2
- */
+/* ??? Do we really want long as size_t on 31-bit?  */
+#undef  SIZE_TYPE
+#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "long unsigned int")
+#undef  PTRDIFF_TYPE
+#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
+
+#undef  WCHAR_TYPE
+#define WCHAR_TYPE "int"
+#undef  WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+
+/* Target specific preprocessor settings.  */
+
+#define NO_BUILTIN_SIZE_TYPE
+#define NO_BUILTIN_PTRDIFF_TYPE
+
+#define CPP_PREDEFINES \
+  "-Dunix -Asystem(unix) -Dlinux -Asystem(linux) -D__ELF__ \
+   -Acpu(s390) -Amachine(s390) -D__s390__"
+
+#define CPP_ARCH31_SPEC \
+  "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=int"
+#define CPP_ARCH64_SPEC \
+  "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
+   -D__s390x__ -D__LONG_MAX__=9223372036854775807L"
+
+#ifdef DEFAULT_TARGET_64BIT
+#undef  CPP_SPEC
+#define CPP_SPEC "%{m31:%(cpp_arch31)} %{!m31:%(cpp_arch64)}"
+#else
+#undef  CPP_SPEC
+#define CPP_SPEC "%{m64:%(cpp_arch64)} %{!m64:%(cpp_arch31)}"
+#endif
+
+
+/* Target specific compiler settings.  */
 
-#undef CC1_SPEC
+/* ??? -fcaller-saves sometimes doesn't work.  Fix this! */
+#undef  CC1_SPEC
 #define CC1_SPEC "-fno-caller-saves"
+#undef  CC1PLUS_SPEC
 #define CC1PLUS_SPEC "-fno-caller-saves"
 
-#undef	LINK_SPEC
-#ifdef CROSS_COMPILE
-#define LINK_SPEC "-m elf_s390 %{shared:-shared} \
-  %{!shared: \
-    %{!ibcs: \
+
+/* Target specific assembler settings.  */
+
+#ifdef DEFAULT_TARGET_64BIT
+#undef  ASM_SPEC
+#define ASM_SPEC "%{m31:-m31 -Aesa}"
+#else
+#undef  ASM_SPEC
+#define ASM_SPEC "%{m64:-m64 -Aesame}"
+#endif
+
+
+/* Target specific linker settings.  */
+
+#define LINK_ARCH31_SPEC \
+  "-m elf_s390 \
+   %{shared:-shared} \
+   %{!shared: \
+      %{static:-static} \
       %{!static: \
 	%{rdynamic:-export-dynamic} \
-	%{!dynamic-linker:-dynamic-linker /lib/ld.so.1 \
-        -rpath-link=/usr/local/s390-ibm-linux/lib}} \
-	%{static:-static}}}"
-#else
-#define LINK_SPEC "-m elf_s390 %{shared:-shared} \
-  %{!shared: \
-    %{!ibcs: \
+	%{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
+
+#define LINK_ARCH64_SPEC \
+  "-m elf64_s390 \
+   %{shared:-shared} \
+   %{!shared: \
+      %{static:-static} \
       %{!static: \
 	%{rdynamic:-export-dynamic} \
-	%{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
-	%{static:-static}}}"
+	%{!dynamic-linker:-dynamic-linker /lib/ld64.so.1}}}"
+
+#ifdef DEFAULT_TARGET_64BIT
+#undef  LINK_SPEC
+#define LINK_SPEC "%{m31:%(link_arch31)} %{!m31:%(link_arch64)}"
+#else
+#undef  LINK_SPEC
+#define LINK_SPEC "%{m64:%(link_arch64)} %{!m64:%(link_arch31)}"
 #endif
 
-/* Need to define this. Otherwise define to BITS_PER_WORD in cexp.c.
-   But BITS_PER_WORD depends on target flags, which are not defined in 
-   cexpc.c.  */
 
-#undef  WCHAR_TYPE
-#define WCHAR_TYPE "int"
-#undef  WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE 32
+/* This macro defines names of additional specifications to put in the specs
+   that can be used in various specifications like CC1_SPEC.  Its definition
+   is an initializer with a subgrouping for each command option.  */
+
+#define EXTRA_SPECS \
+  { "cpp_arch31",	CPP_ARCH31_SPEC },	\
+  { "cpp_arch64",	CPP_ARCH64_SPEC },	\
+  { "link_arch31",	LINK_ARCH31_SPEC },	\
+  { "link_arch64",	LINK_ARCH64_SPEC },	\
+
 
 /* Character to start a comment.  */
 
diff --git a/gcc/config/s390/linux64.h b/gcc/config/s390/linux64.h
deleted file mode 100644
index a65cf90f7d38..000000000000
--- a/gcc/config/s390/linux64.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Definitions for Linux for s/390 zSeries
-   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
-   Contributed by Hartmut Penner (hpenner@de.ibm.com) and
-                  Ulrich Weigand (uweigand@de.ibm.com).
-This file is part of GNU CC.
-
-GNU CC 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.
-
-GNU CC 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 GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-#ifndef _LINUX64_H
-#define _LINUX64_H
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "long int"
-
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT             0x13
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (Linux for S/390 zSeries 64 bit)");
-
-/* Names to predefine in the preprocessor for this target machine.  */
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES \
-  "-Dlinux -Asystem(linux) -Acpu(s390) -Amachine(s390) -D__s390__ -D__s390x__ \
-   -Asystem(unix) -Dunix -D__ELF__ \
-   -D__LONG_MAX__=9223372036854775807L"
-
-#undef	LINK_SPEC
-#ifdef CROSS_COMPILE
-#define LINK_SPEC "-m elf64_s390 %{shared:-shared} \
-  %{!shared: \
-    %{!ibcs: \
-      %{!static: \
-	%{rdynamic:-export-dynamic} \
-	%{!dynamic-linker:-dynamic-linker /lib/ld64.so.1 \
-        -rpath-link=/usr/local/s390x-ibm-linux/lib}} \
-	%{static:-static}}}"
-#else
-#define LINK_SPEC "-m elf64_s390 %{shared:-shared} \
-  %{!shared: \
-    %{!ibcs: \
-      %{!static: \
-	%{rdynamic:-export-dynamic} \
-	%{!dynamic-linker:-dynamic-linker /lib/ld64.so.1}} \
-	%{static:-static}}}"
-#endif
-
-#undef MASK_RETURN_ADDR 
-#undef SELECT_SECTION
-
-#endif
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index f64850526ecc..9bba974fd3de 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -22,8 +22,6 @@ Boston, MA 02111-1307, USA.  */
 #ifndef _S390_H
 #define _S390_H
 
-#define TARGET_VERSION fprintf (stderr, " (S/390)");
-
 extern int flag_pic; 
 
 /* Run-time compilation parameters selecting different hardware subsets.  */
@@ -33,14 +31,21 @@ extern int target_flags;
 /* Target macros checked at runtime of compiler.  */
 
 #define TARGET_HARD_FLOAT          (target_flags & 1)
+#define TARGET_SOFT_FLOAT          (!(target_flags & 1))
 #define TARGET_BACKCHAIN           (target_flags & 2)
 #define TARGET_SMALL_EXEC          (target_flags & 4)
 #define TARGET_DEBUG_ARG           (target_flags & 8)
 #define TARGET_64BIT               (target_flags & 16)
 #define TARGET_MVCLE               (target_flags & 32)
 
+#ifdef DEFAULT_TARGET_64BIT
+#define TARGET_DEFAULT             0x13
+#define TARGET_VERSION fprintf (stderr, " (zSeries)");
+#else
 #define TARGET_DEFAULT             0x3
-#define TARGET_SOFT_FLOAT          (!(target_flags & 1))
+#define TARGET_VERSION fprintf (stderr, " (S/390)");
+#endif
+
 
 /* Macro to define tables used to set the flags.  This is a list in braces
    of pairs in braces, each pair being { "NAME", VALUE }
@@ -640,7 +645,7 @@ extern enum reg_class regclass_map[FIRST_PSEUDO_REGISTER]; /* smalled class cont
 
 /* We have 31 bit mode.  */
 
-#define MASK_RETURN_ADDR (GEN_INT (0x7fffffff))
+#define MASK_RETURN_ADDR (TARGET_64BIT ? GEN_INT (-1) : GEN_INT (0x7fffffff))
 
 /* The offset from the incoming value of %sp to the top of the stack frame
    for the current function.  */
diff --git a/gcc/config/s390/s390x.h b/gcc/config/s390/s390x.h
new file mode 100644
index 000000000000..c79acf5dc4fe
--- /dev/null
+++ b/gcc/config/s390/s390x.h
@@ -0,0 +1,27 @@
+/* Definitions of target machine for IBM zSeries 64-bit
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   Contributed by Hartmut Penner (hpenner@de.ibm.com) and
+                  Ulrich Weigand (uweigand@de.ibm.com).
+This file is part of GNU CC.
+
+GNU CC 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.
+
+GNU CC 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 GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#ifndef _S390X_H
+#define _S390X_H
+
+#define DEFAULT_TARGET_64BIT
+
+#endif
-- 
GitLab