[parisc-linux-cvs] gcc amodra
Alan Modra
alan@linuxcare.com.au
Sat, 7 Apr 2001 09:48:45 +1000 (EST)
On Fri, 6 Apr 2001, Alan Modra wrote:
> gcc : ChangeLog.puffin
> gcc/config/pa : pa.c pa.h pa.md pa64-linux.h
>
> Log message:
> Modify TARGET_NO_SPACE_REGS so that it's useful for usermode and
> shared libs.
Forgot to post the diff..
Index: gcc/ChangeLog.puffin
===================================================================
RCS file: /home/cvs/parisc/gcc/gcc/ChangeLog.puffin,v
retrieving revision 1.11
diff -u -p -r1.11 ChangeLog.puffin
--- ChangeLog.puffin 2001/03/29 05:58:45 1.11
+++ ChangeLog.puffin 2001/04/06 07:41:43
@@ -1,3 +1,19 @@
+2001-04-06 Alan Modra <alan@linuxcare.com.au>
+
+ * config/pa/pa64-linux.h (INITIAL_ELIMINATION_OFFSET): Have another
+ bash at getting this right, but don't enable yet.
+ (CAN_ELIMINATE): This too.
+
+ * pa.h: Revise comments for TARGET_NO_SPACE_REGS and
+ TARGET_FAST_INDIRECT_CALLS.
+ * pa.c (override_options): TARGET_NO_SPACE_REGS is now OK with
+ -fPIC. Don't warn.
+ (output_millicode_call): For out of range calls, make -fPIC
+ take precedence, then TARGET_PORTABLE_RUNTIME, then ble. Don't
+ return before delay slot checks when TARGET_PORTABLE_RUNTIME.
+ * pa.md: Modify length attr calculation of all millicode insns to
+ match above.
+
2001-03-29 Alan Modra <alan@linuxcare.com.au>
* config/pa/pa-linux.h: (PREFERRED_DEBUGGING_TYPE): Don't
Index: gcc/config/pa/pa.c
===================================================================
RCS file: /home/cvs/parisc/gcc/gcc/config/pa/pa.c,v
retrieving revision 1.18
diff -u -p -r1.18 pa.c
--- pa.c 2001/03/27 14:08:42 1.18
+++ pa.c 2001/04/06 07:42:15
@@ -33,8 +33,8 @@ Boston, MA 02111-1307, USA. */
#include "insn-attr.h"
#include "flags.h"
#include "tree.h"
-#include "expr.h"
#include "reload.h"
+#include "expr.h"
#include "c-tree.h"
#include "function.h"
#include "obstack.h"
@@ -172,7 +172,7 @@ override_options ()
warning ("PIC code generation is not supported in the portable runtime model\n");
}
- if (flag_pic && (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS))
+ if (flag_pic && TARGET_FAST_INDIRECT_CALLS)
{
warning ("PIC code generation is not compatible with fast indirect calls\n");
}
@@ -1396,7 +1396,6 @@ emit_move_sequence (operands, mode, scra
/* We want to load the scratch register using the same mode as
the ultimate destination. */
scratch_reg = force_mode (GET_MODE (operand0), scratch_reg);
-
emit_move_insn (scratch_reg, operand1);
}
@@ -5787,9 +5786,7 @@ output_millicode_call (insn, call_dest)
rtx xoperands[4];
rtx seq_insn;
- xoperands[3] = gen_rtx_REG (SImode, 31);
- if (TARGET_64BIT)
- xoperands[3] = gen_rtx_REG (SImode, 2);
+ xoperands[3] = gen_rtx_REG (Pmode, TARGET_64BIT ? 2 : 31);
/* Handle common case -- empty delay slot or no jump in the delay slot,
and we're sure that the branch will reach the beginning of the $CODE$
@@ -5825,14 +5822,28 @@ output_millicode_call (insn, call_dest)
delay_insn_deleted = 1;
}
- /* If we're allowed to use be/ble instructions, then this is the
- best sequence to use for a long millicode call. */
- if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS
- || ! (flag_pic || TARGET_PORTABLE_RUNTIME))
+ /* PIC long millicode call sequence. */
+ if (flag_pic)
{
xoperands[0] = call_dest;
- output_asm_insn ("ldil L%%%0,%3", xoperands);
- output_asm_insn ("{ble|be,l} R%%%0(%%sr4,%3)", xoperands);
+ xoperands[1] = gen_label_rtx ();
+ /* Get our address + 8 into %r1. */
+ output_asm_insn ("{bl|b,l} .+8,%%r1", xoperands);
+
+ /* Add %r1 to the offset of our target from the next insn. */
+ output_asm_insn ("addil L%%%0-%1,%%r1", xoperands);
+ ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
+ CODE_LABEL_NUMBER (xoperands[1]));
+ output_asm_insn ("ldo R%%%0-%1(%%r1),%%r1", xoperands);
+
+ /* Get the return address into %r31. */
+ output_asm_insn ("blr 0,%3", xoperands);
+
+ /* Branch to our target which is in %r1. */
+ output_asm_insn ("bv,n %%r0(%%r1)", xoperands);
+
+ /* Empty delay slot. Note this insn gets fetched twice and
+ executed once. To be safe we use a nop. */
output_asm_insn ("nop", xoperands);
}
/* Pure portable runtime doesn't allow be/ble; we also don't have
@@ -5853,30 +5864,14 @@ output_millicode_call (insn, call_dest)
/* Empty delay slot. Note this insn gets fetched twice and
executed once. To be safe we use a nop. */
output_asm_insn ("nop", xoperands);
- return "";
}
- /* PIC long millicode call sequence. */
+ /* If we're allowed to use be/ble instructions, then this is the
+ best sequence to use for a long millicode call. */
else
{
xoperands[0] = call_dest;
- xoperands[1] = gen_label_rtx ();
- /* Get our address + 8 into %r1. */
- output_asm_insn ("{bl|b,l} .+8,%%r1", xoperands);
-
- /* Add %r1 to the offset of our target from the next insn. */
- output_asm_insn ("addil L%%%0-%1,%%r1", xoperands);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
- CODE_LABEL_NUMBER (xoperands[1]));
- output_asm_insn ("ldo R%%%0-%1(%%r1),%%r1", xoperands);
-
- /* Get the return address into %r31. */
- output_asm_insn ("blr 0,%3", xoperands);
-
- /* Branch to our target which is in %r1. */
- output_asm_insn ("bv,n %%r0(%%r1)", xoperands);
-
- /* Empty delay slot. Note this insn gets fetched twice and
- executed once. To be safe we use a nop. */
+ output_asm_insn ("ldil L%%%0,%3", xoperands);
+ output_asm_insn ("{ble|be,l} R%%%0(%%sr4,%3)", xoperands);
output_asm_insn ("nop", xoperands);
}
Index: gcc/config/pa/pa.h
===================================================================
RCS file: /home/cvs/parisc/gcc/gcc/config/pa/pa.h,v
retrieving revision 1.11
diff -u -p -r1.11 pa.h
--- pa.h 2001/03/27 14:08:42 1.11
+++ pa.h 2001/04/06 07:42:23
@@ -106,13 +106,9 @@ extern int target_flags;
#define MASK_DISABLE_FPREGS 2
#define TARGET_DISABLE_FPREGS (target_flags & MASK_DISABLE_FPREGS)
-/* Generate code which assumes that calls through function pointers will
- never cross a space boundary. Such assumptions are generally safe for
- building kernels and statically linked executables. Code compiled with
- this option will fail miserably if the executable is dynamically linked
- or uses nested functions!
-
- This is also used to trigger aggressive unscaled index addressing. */
+/* Generate code which assumes that all space register are equivalent.
+ Triggers aggressive unscaled index addressing and faster
+ builtin_return_address. */
#define MASK_NO_SPACE_REGS 4
#define TARGET_NO_SPACE_REGS (target_flags & MASK_NO_SPACE_REGS)
@@ -148,7 +144,12 @@ extern int target_flags;
#define MASK_LONG_LOAD_STORE 512
#define TARGET_LONG_LOAD_STORE (target_flags & MASK_LONG_LOAD_STORE)
-/* Use a faster sequence for indirect calls. */
+/* Use a faster sequence for indirect calls. This assumes that calls
+ through function pointers will never cross a space boundary, and
+ that the executable is not dynamically linked. Such assumptions
+ are generally safe for building kernels and statically linked
+ executables. Code compiled with this option will fail miserably if
+ the executable is dynamically linked or uses nested functions! */
#define MASK_FAST_INDIRECT_CALLS 1024
#define TARGET_FAST_INDIRECT_CALLS (target_flags & MASK_FAST_INDIRECT_CALLS)
Index: gcc/config/pa/pa.md
===================================================================
RCS file: /home/cvs/parisc/gcc/gcc/config/pa/pa.md,v
retrieving revision 1.5
diff -u -p -r1.5 pa.md
--- pa.md 2001/03/23 04:24:05 1.5
+++ pa.md 2001/04/06 07:42:33
@@ -3942,21 +3942,18 @@
(const_int 0)))
(const_int 4)
-;; NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
(const_int 0))
- (const_int 8)
+ (const_int 24)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
-;; same as NO_SPACE_REGS code
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 8)]
+;; Out of reach PORTABLE_RUNTIME
+ (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
+ (const_int 0))
+ (const_int 20)]
-;; Out of range and either PIC or PORTABLE_RUNTIME
- (const_int 24)))])
+;; Out of reach, can use ble
+ (const_int 12)))])
(define_expand "muldi3"
[(set (match_operand:DI 0 "register_operand" "")
@@ -4049,21 +4046,18 @@
(const_int 0)))
(const_int 4)
-;; NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
(const_int 0))
- (const_int 8)
+ (const_int 24)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
-;; same as NO_SPACE_REGS code
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 8)]
+;; Out of reach PORTABLE_RUNTIME
+ (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
+ (const_int 0))
+ (const_int 20)]
-;; Out of range and either PIC or PORTABLE_RUNTIME
- (const_int 24)))])
+;; Out of reach, can use ble
+ (const_int 12)))])
(define_expand "udivsi3"
[(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
@@ -4107,21 +4101,18 @@
(const_int 0)))
(const_int 4)
-;; NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
(const_int 0))
- (const_int 8)
+ (const_int 24)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
-;; same as NO_SPACE_REGS code
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 8)]
+;; Out of reach PORTABLE_RUNTIME
+ (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
+ (const_int 0))
+ (const_int 20)]
-;; Out of range and either PIC or PORTABLE_RUNTIME
- (const_int 24)))])
+;; Out of reach, can use ble
+ (const_int 12)))])
(define_expand "modsi3"
[(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
@@ -4162,21 +4153,18 @@
(const_int 0)))
(const_int 4)
-;; NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
(const_int 0))
- (const_int 8)
+ (const_int 24)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
-;; same as NO_SPACE_REGS code
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 8)]
+;; Out of reach PORTABLE_RUNTIME
+ (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
+ (const_int 0))
+ (const_int 20)]
-;; Out of range and either PIC or PORTABLE_RUNTIME
- (const_int 24)))])
+;; Out of reach, can use ble
+ (const_int 12)))])
(define_expand "umodsi3"
[(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
@@ -4217,21 +4205,18 @@
(const_int 0)))
(const_int 4)
-;; NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
(const_int 0))
- (const_int 8)
+ (const_int 24)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
-;; same as NO_SPACE_REGS code
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 8)]
+;; Out of reach PORTABLE_RUNTIME
+ (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
+ (const_int 0))
+ (const_int 20)]
-;; Out of range and either PIC or PORTABLE_RUNTIME
- (const_int 24)))])
+;; Out of reach, can use ble
+ (const_int 12)))])
;;- and instructions
;; We define DImode `and` so with DImode `not` we can get
@@ -5803,7 +5788,7 @@
rtx xoperands[2];
/* First the special case for kernels, level 0 systems, etc. */
- if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
+ if (TARGET_FAST_INDIRECT_CALLS)
return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
/* Now the normal case -- we can reach $$dyncall directly or
@@ -5838,8 +5823,8 @@
[(set_attr "type" "dyncall")
(set (attr "length")
(cond [
-;; First NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
+;; First FAST_INDIRECT_CALLS
+ (ne (symbol_ref "TARGET_FAST_INDIRECT_CALLS")
(const_int 0))
(const_int 8)
@@ -5850,19 +5835,18 @@
(const_int 0)))
(const_int 8)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 12)
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
+ (const_int 0))
+ (const_int 24)
+;; Out of reach PORTABLE_RUNTIME
(ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
(const_int 0))
(const_int 20)]
-;; Out of range PIC case
- (const_int 24)))])
+;; Out of reach, can use ble
+ (const_int 12)))])
(define_expand "call_value"
[(parallel [(set (match_operand 0 "" "")
@@ -5982,7 +5966,7 @@
rtx xoperands[2];
/* First the special case for kernels, level 0 systems, etc. */
- if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
+ if (TARGET_FAST_INDIRECT_CALLS)
return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
/* Now the normal case -- we can reach $$dyncall directly or
@@ -6017,8 +6001,8 @@
[(set_attr "type" "dyncall")
(set (attr "length")
(cond [
-;; First NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
+;; First FAST_INDIRECT_CALLS
+ (ne (symbol_ref "TARGET_FAST_INDIRECT_CALLS")
(const_int 0))
(const_int 8)
@@ -6029,19 +6013,18 @@
(const_int 0)))
(const_int 8)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 12)
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
+ (const_int 0))
+ (const_int 24)
+;; Out of reach PORTABLE_RUNTIME
(ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
(const_int 0))
(const_int 20)]
-;; Out of range PIC case
- (const_int 24)))])
+;; Out of reach, can use ble
+ (const_int 12)))])
;; Call subroutine returning any type.
@@ -7108,27 +7091,19 @@
(eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
(const_int 0)))
(const_int 28)
-
-;; NO_SPACE_REGS
- (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
- (const_int 0))
- (const_int 32)
-;; Out of reach, but not PIC or PORTABLE_RUNTIME
-;; same as NO_SPACE_REGS code
- (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
- (const_int 0))
- (eq (symbol_ref "flag_pic")
- (const_int 0)))
- (const_int 32)
+;; Out of reach PIC
+ (ne (symbol_ref "flag_pic")
+ (const_int 0))
+ (const_int 44)
-;; PORTABLE_RUNTIME
+;; Out of reach PORTABLE_RUNTIME
(ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
(const_int 0))
(const_int 40)]
-;; Out of range and PIC
- (const_int 44)))])
+;; Out of reach, can use ble
+ (const_int 32)))])
;; On the PA, the PIC register is call clobbered, so it must
;; be saved & restored around calls by the caller. If the call
Index: gcc/config/pa/pa64-linux.h
===================================================================
RCS file: /home/cvs/parisc/gcc/gcc/config/pa/pa64-linux.h,v
retrieving revision 1.3
diff -u -p -r1.3 pa64-linux.h
--- pa64-linux.h 2001/03/23 04:24:05 1.3
+++ pa64-linux.h 2001/04/06 07:42:33
@@ -21,7 +21,7 @@ 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 0 /* possibly needs some work, but I think this is OK now */
/* If defined, this macro specifies a table of register pairs used to
eliminate unneeded registers that point into the stack frame. */
@@ -36,12 +36,14 @@ Boston, MA 02111-1307, USA. */
replace register number FROM with register number TO. The frame pointer
is automatically handled. */
-#define CAN_ELIMINATE(FROM, TO) 1
+#define CAN_ELIMINATE(FROM, TO) \
+ ((FROM) != ARG_POINTER_REGNUM \
+ || ! (current_function_varargs || current_function_stdarg))
/* 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. */
+ registers, immediately after the function prologue. This macro
+ must be defined if `ELIMINABLE_REGS' is defined. */
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
do \
{ \
@@ -51,7 +53,7 @@ Boston, MA 02111-1307, USA. */
if ((TO) == FRAME_POINTER_REGNUM \
&& (FROM) == ARG_POINTER_REGNUM) \
{ \
- (OFFSET) = -16; \
+ (OFFSET) = 48 - current_function_args_size; \
break; \
} \
\
@@ -61,11 +63,11 @@ Boston, MA 02111-1307, USA. */
switch (FROM) \
{ \
case FRAME_POINTER_REGNUM: \
- (OFFSET) = - fsize; \
+ (OFFSET) = -fsize; \
break; \
\
case ARG_POINTER_REGNUM: \
- (OFFSET) = - fsize - 16; \
+ (OFFSET) = -fsize + 48 - current_function_args_size; \
break; \
\
default: \