This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
hppa-linux support 2
- To: gcc-patches at gcc dot gnu dot org
- Subject: hppa-linux support 2
- From: Alan Modra <alan at linuxcare dot com dot au>
- Date: Wed, 4 Apr 2001 20:10:01 +1000 (EST)
Clean up existing pa-linux.h, adding lots of needed defines. Add dwarf2
support to pa.h, hppa-linux tweaks to pa.c, pa.md.
* elfos.h (SELECT_SECTION): Undef before defining.
* pa-linux.h (LINUX_DEFAULT_ELF, PTRDIFF_TYPE, CPP_SPEC): Remove.
(LIB_SPEC): Remove -lmilli.
(DBX_REGISTER_NUMBER): Remove.
(PREFERRED_DEBUGGING_TYPE, DWARF2_ASM_LINE_DEBUG_INFO,
(DWARF2_UNWIND_INFO, ASM_SPEC, LINK_SPEC, FUNCTION_OK_FOR_SIBCALL,
NO_PROFILE_COUNTERS, SELECT_RTX_SECTION, INCOMING_RETURN_ADDR_RTX,
DWARF_FRAME_RETURN_COLUMN, STRING_ASM_OP, TEXT_SECTION_ASM_OP,
DATA_SECTION_ASM_OP, BSS_SECTION_ASM_OP, ASM_FILE_START,
ASM_OUTPUT_DEF, ASM_OUTPUT_ADDR_VEC_ELT, ASM_OUTPUT_ADDR_DIFF_ELT,
ASM_OUTPUT_LABEL, ASM_GLOBALIZE_LABEL, ASM_DECLARE_FUNCTION_NAME,
TARGET_GAS): Define.
* pa.c (output_arg_descriptor): Disable for TARGET_ELF32.
(function_arg): If TARGET_ELF32, pass fp args in both general and fp
regs if we don't have a prototype.
* pa.md (canonicalize_funcptr_for_compare): Not for TARGET_ELF32.
* pa.h (TARGET_ELF32): Default to 0 if undefined.
(EH_RETURN_DATA_REGNO, EH_RETURN_STACKADJ_RTX,
EH_RETURN_HANDLER_RTX): Define.
* pa32-regs.h (DBX_REGISTER_NUMBER): Remove unnecessary test.
(DWARF_FRAME_REGNUM): Define.
* pa64-regs.h (DWARF_FRAME_REGNUM): Define.
* pa32-linux.h: New file.
* pa64-linux.h: New file.
Alan Modra
--
Linuxcare
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/elfos.h gcc-new/gcc/config/elfos.h
--- gcc-current/gcc/config/elfos.h Tue Apr 3 15:34:24 2001
+++ gcc-new/gcc/config/elfos.h Sat Mar 31 20:30:48 2001
@@ -494,6 +494,7 @@ dtors_section () \
or a constant of some sort. RELOC indicates whether forming
the initial value of DECL requires link-time relocations. */
+#undef SELECT_SECTION
#define SELECT_SECTION(DECL, RELOC) \
{ \
if (TREE_CODE (DECL) == STRING_CST) \
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa-linux.h gcc-new/gcc/config/pa/pa-linux.h
--- gcc-current/gcc/config/pa/pa-linux.h Fri Nov 3 09:59:12 2000
+++ gcc-new/gcc/config/pa/pa-linux.h Wed Apr 4 00:13:57 2001
@@ -1,5 +1,5 @@
/* Definitions for PA_RISC with ELF format
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -18,38 +18,161 @@ along with GNU CC; see the file COPYING.
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-/* FIXME - this doesn't seem to be used anywhere */
-#define LINUX_DEFAULT_ELF
-
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+/* Use DWARF2 debugging info and unwind. */
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+#define DWARF2_ASM_LINE_DEBUG_INFO 1
+#define DWARF2_UNWIND_INFO 1
#undef CPP_PREDEFINES
#define CPP_PREDEFINES "-D__ELF__ -Dunix -D__hppa__ -Dlinux -Asystem=unix -Asystem=posix -Acpu=hppa -Amachine=hppa -Amachine=bigendian"
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}\
- %{msnake:-D_PA_RISC1_1}\
- %{mpa-risc-1-1:-D_PA_RISC1_1}"
-
#undef LIB_SPEC
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} -lmilli"
-
-/* How to renumber registers for dbx and gdb.
-
- It is entirely possible linux will use a different numbering scheme.
- Until we know for sure, it's the same as hpux, osf & bsd, but we're
- ready if it needs to be different.
-
- Registers 0 - 31 remain unchanged.
-
- Registers 32 - 87 are mapped to 72 - 127
-
- Register 88 is mapped to 32. */
+#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-#define DBX_REGISTER_NUMBER(REGNO) \
- ((REGNO) <= 31 ? (REGNO) : \
- ((REGNO) > 31 && (REGNO) <= 87 ? (REGNO) + 40 : 32))
+#undef ASM_SPEC
+#define ASM_SPEC \
+ "%{v:-V} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}"
+
+/* Define this for shared library support because it isn't in the main
+ linux.h file. */
+
+#undef LINK_SPEC
+#define LINK_SPEC "\
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
+ %{static:-static}}"
+
+/* Sibcalls, stubs, and elf sections don't play well. */
+#undef FUNCTION_OK_FOR_SIBCALL
+#define FUNCTION_OK_FOR_SIBCALL(x) 0
+
+/* glibc's profiling functions don't need gcc to allocate counters. */
+#define NO_PROFILE_COUNTERS 1
+
+/* Put plabels into the data section so we can relocate them. */
+#undef SELECT_RTX_SECTION
+#define SELECT_RTX_SECTION(MODE,RTX) \
+ if (flag_pic && function_label_operand (RTX, MODE)) \
+ data_section (); \
+ else \
+ readonly_data_section ();
+
+/* A C expression whose value is RTL representing the location of the
+ incoming return address at the beginning of any function, before the
+ prologue. */
+#define INCOMING_RETURN_ADDR_RTX (gen_rtx_REG (word_mode, 2))
+#define DWARF_FRAME_RETURN_COLUMN (DWARF_FRAME_REGNUM (2))
+
+/* Define the strings used for the special svr4 .type and .size directives.
+ These strings generally do not vary from one system running svr4 to
+ another, but if a given system (e.g. m88k running svr) needs to use
+ different pseudo-op names for these, they may be overridden in the
+ file which includes this one. */
+
+#undef STRING_ASM_OP
+#define STRING_ASM_OP ".stringz"
+
+#define TEXT_SECTION_ASM_OP "\t.text"
+#define DATA_SECTION_ASM_OP "\t.data"
+#define BSS_SECTION_ASM_OP "\t.section\t.bss"
+
+/* Output at beginning of assembler file. We override the definition
+ from <linux.h> so that we can get the proper .LEVEL directive. */
+#undef ASM_FILE_START
+#define ASM_FILE_START(FILE) \
+ do \
+ { \
+ if (write_symbols != NO_DEBUG) \
+ { \
+ output_file_directive (FILE, main_input_filename); \
+ fputs ("\t.version\t\"01.01\"\n", FILE); \
+ } \
+ if (TARGET_64BIT) \
+ fputs("\t.LEVEL 2.0w\n", FILE); \
+ else if (TARGET_PA_20) \
+ fputs("\t.LEVEL 2.0\n", FILE); \
+ else if (TARGET_PA_11) \
+ fputs("\t.LEVEL 1.1\n", FILE); \
+ else \
+ fputs("\t.LEVEL 1.0\n", FILE); \
+ if (profile_flag) \
+ fputs ("\t.IMPORT _mcount, CODE\n", FILE); \
+ } \
+ while (0)
+
+/* Output a definition */
+#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
+ do \
+ { \
+ fprintf ((FILE), "\t%s\t", SET_ASM_OP); \
+ assemble_name (FILE, LABEL1); \
+ fprintf (FILE, ","); \
+ assemble_name (FILE, LABEL2); \
+ fprintf (FILE, "\n"); \
+ } \
+ while (0)
+
+/* Define these to generate the Linux/ELF/SysV style of internal
+ labels all the time - i.e. to be compatible with
+ ASM_GENERATE_INTERNAL_LABEL in <elfos.h>. Compare these with the
+ ones in pa.h and note the lack of dollar signs in these. FIXME:
+ shouldn't we fix pa.h to use ASM_GENERATE_INTERNAL_LABEL instead? */
+
+#undef ASM_OUTPUT_ADDR_VEC_ELT
+#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
+ if (TARGET_BIG_SWITCH) \
+ fprintf (FILE, "\tstw %%r1,-16(%%r30)\n\tldil LR'.L%d,%%r1\n\tbe RR'.L%d(%%sr4,%%r1)\n\tldw -16(%%r30),%%r1\n", VALUE, VALUE); \
+ else \
+ fprintf (FILE, "\tb .L%d\n\tnop\n", VALUE)
+
+#undef ASM_OUTPUT_ADDR_DIFF_ELT
+#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
+ if (TARGET_BIG_SWITCH) \
+ fprintf (FILE, "\tstw %%r1,-16(%%r30)\n\tldw T'.L%d(%%r19),%%r1\n\tbv %%r0(%%r1)\n\tldw -16(%%r30),%%r1\n", VALUE); \
+ else \
+ fprintf (FILE, "\tb .L%d\n\tnop\n", VALUE)
+
+/* This is how to output the definition of a user-level label named NAME,
+ such as the label on a static function or variable NAME. */
+
+#undef ASM_OUTPUT_LABEL
+#define ASM_OUTPUT_LABEL(FILE, NAME) \
+ do \
+ { \
+ assemble_name (FILE, NAME); \
+ fputs (":\n", FILE); \
+ } \
+ while (0)
+
+/* NOTE: ASM_OUTPUT_INTERNAL_LABEL() is defined for us by elfos.h, and
+ does what we want (i.e. uses colons). It must be compatible with
+ ASM_GENERATE_INTERNAL_LABEL(), so do not define it here. */
+
+#undef ASM_GLOBALIZE_LABEL
+#define ASM_GLOBALIZE_LABEL(FILE, NAME) \
+ (fputs (".globl ", FILE), assemble_name (FILE, NAME), fputs ("\n", FILE))
+
+/* FIXME: Hacked from the <elfos.h> one so that we avoid multiple
+ labels in a function declaration (since pa.c seems determined to do
+ it differently) */
+
+#undef ASM_DECLARE_FUNCTION_NAME
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
+ do \
+ { \
+ fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ putc (',', FILE); \
+ fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
+ putc ('\n', FILE); \
+ ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
+ } \
+ while (0)
+
+/* Linux always uses gas. */
+#undef TARGET_GAS
+#define TARGET_GAS 1
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa.c gcc-new/gcc/config/pa/pa.c
--- gcc-current/gcc/config/pa/pa.c Wed Apr 4 09:46:54 2001
+++ gcc-new/gcc/config/pa/pa.c Wed Apr 4 10:07:37 2001
@@ -4552,8 +4575,8 @@ output_arg_descriptor (call_insn)
int regno;
/* We neither need nor want argument location descriptors for the
- 64bit runtime environment. */
- if (TARGET_64BIT)
+ 64bit runtime environment or the ELF32 environment. */
+ if (TARGET_64BIT || TARGET_ELF32)
return;
for (i = 0; i < 4; i++)
@@ -7057,7 +7083,7 @@ function_arg (cum, mode, type, named, in
}
/* Determine if the register needs to be passed in both general and
floating point registers. */
- if ((TARGET_PORTABLE_RUNTIME || TARGET_64BIT)
+ if ((TARGET_PORTABLE_RUNTIME || TARGET_64BIT || TARGET_ELF32)
/* If we are doing soft-float with portable runtime, then there
is no need to worry about FP regs. */
&& ! TARGET_SOFT_FLOAT
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa.h gcc-new/gcc/config/pa/pa.h
--- gcc-current/gcc/config/pa/pa.h Tue Apr 3 16:42:05 2001
+++ gcc-new/gcc/config/pa/pa.h Sat Mar 31 22:11:39 2001
@@ -171,6 +171,11 @@ extern int target_flags;
#define TARGET_64BIT 0
#endif
+/* Generate code for ELF32 ABI. */
+#ifndef TARGET_ELF32
+#define TARGET_ELF32 0
+#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 }
@@ -516,6 +521,12 @@ extern void hppa_init_pic_save PARAMS ((
/* Register in which address to store a structure value
is passed to a function. */
#define STRUCT_VALUE_REGNUM 28
+
+/* Describe how we implement __builtin_eh_return. */
+#define EH_RETURN_DATA_REGNO(N) \
+ ((N) < 3 ? (N) + 20 : (N) == 4 ? 31 : INVALID_REGNUM)
+#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, 29)
+#define EH_RETURN_HANDLER_RTX gen_rtx_REG (Pmode, 2)
/* The letters I, J, K, L and M in a register constraint string
can be used to stand for particular ranges of immediate operands.
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa.md gcc-new/gcc/config/pa/pa.md
--- gcc-current/gcc/config/pa/pa.md Wed Apr 4 09:46:54 2001
+++ gcc-new/gcc/config/pa/pa.md Wed Apr 4 10:07:37 2001
@@ -7021,7 +7021,7 @@
(clobber (reg:SI 31))])
(set (match_operand:SI 0 "register_operand" "")
(reg:SI 29))]
- "! TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
+ "! TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && !TARGET_ELF32"
"
{
operands[2] = gen_reg_rtx (SImode);
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa32-linux.h gcc-new/gcc/config/pa/pa32-linux.h
--- gcc-current/gcc/config/pa/pa32-linux.h Thu Jan 1 09:30:00 1970
+++ gcc-new/gcc/config/pa/pa32-linux.h Sat Mar 31 19:08:36 2001
@@ -0,0 +1,26 @@
+/* Definitions for PA_RISC with ELF-32 format
+ Copyright (C) 2000 Free Software Foundation, Inc.
+
+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. */
+
+/* Turn off various SOM crap we don't want. */
+#undef TARGET_ELF32
+#define TARGET_ELF32 1
+
+#undef CPP_SPEC
+#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{mhppa:-D__hppa__} %{posix:-D_POSIX_SOURCE} -D_PA_RISC1_1"
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa32-regs.h gcc-new/gcc/config/pa/pa32-regs.h
--- gcc-current/gcc/config/pa/pa32-regs.h Wed Jan 17 15:53:21 2001
+++ gcc-new/gcc/config/pa/pa32-regs.h Sat Mar 31 19:08:36 2001
@@ -186,7 +186,12 @@
#define DBX_REGISTER_NUMBER(REGNO) \
((REGNO) <= 31 ? (REGNO) : \
- ((REGNO) > 31 && (REGNO) <= 87 ? (REGNO) + 40 : 32))
+ ((REGNO) <= 87 ? (REGNO) + 40 : 32))
+
+/* We must not use the DBX register numbers for the DWARF 2 CFA column
+ numbers because that maps to numbers beyond FIRST_PSEUDO_REGISTER.
+ Instead use the identity mapping. */
+#define DWARF_FRAME_REGNUM(REG) REG
/* Define the classes of registers for register constraints in the
machine description. Also define ranges of constants.
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa64-linux.h gcc-new/gcc/config/pa/pa64-linux.h
--- gcc-current/gcc/config/pa/pa64-linux.h Thu Jan 1 09:30:00 1970
+++ gcc-new/gcc/config/pa/pa64-linux.h Sat Mar 31 19:08:37 2001
@@ -0,0 +1,75 @@
+/* Definitions for PA_RISC with ELF format on 64-bit Linux
+ Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+
+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. */
+
+#undef CPP_SPEC
+#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{mhppa:-D__hppa__} %{posix:-D_POSIX_SOURCE} -D_PA_RISC2_0 -D__LP64__"
+
+#if 0 /* needs some work :-( */
+/* If defined, this macro specifies a table of register pairs used to
+ eliminate unneeded registers that point into the stack frame. */
+
+#define ELIMINABLE_REGS \
+{ \
+ {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
+ {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
+ {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
+}
+
+/* A C expression that returns non-zero if the compiler is allowed to try to
+ replace register number FROM with register number TO. The frame pointer
+ is automatically handled. */
+
+#define CAN_ELIMINATE(FROM, TO) 1
+
+/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It
+ specifies the initial difference between the specified pair of
+ registers. This macro must be defined if `ELIMINABLE_REGS' is
+ defined. */
+#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
+ do \
+ { \
+ int fsize; \
+ \
+ fsize = compute_frame_size (get_frame_size (), 0); \
+ if ((TO) == FRAME_POINTER_REGNUM \
+ && (FROM) == ARG_POINTER_REGNUM) \
+ { \
+ (OFFSET) = -16; \
+ break; \
+ } \
+ \
+ if ((TO) != STACK_POINTER_REGNUM) \
+ abort (); \
+ \
+ switch (FROM) \
+ { \
+ case FRAME_POINTER_REGNUM: \
+ (OFFSET) = - fsize; \
+ break; \
+ \
+ case ARG_POINTER_REGNUM: \
+ (OFFSET) = - fsize - 16; \
+ break; \
+ \
+ default: \
+ abort (); \
+ } \
+ } while (0)
+#endif
diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa64-regs.h gcc-new/gcc/config/pa/pa64-regs.h
--- gcc-current/gcc/config/pa/pa64-regs.h Wed Jan 17 15:53:22 2001
+++ gcc-new/gcc/config/pa/pa64-regs.h Sat Mar 31 19:08:37 2001
@@ -176,6 +176,11 @@ Boston, MA 02111-1307, USA. */
((REGNO) <= 31 ? (REGNO) : \
((REGNO) > 31 && (REGNO) <= 60 ? (REGNO - 32) * 2 + 72 : 32))
+/* We must not use the DBX register numbers for the DWARF 2 CFA column
+ numbers because that maps to numbers beyond FIRST_PSEUDO_REGISTER.
+ Instead use the identity mapping. */
+#define DWARF_FRAME_REGNUM(REG) REG
+
/* Define the classes of registers for register constraints in the
machine description. Also define ranges of constants.