This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Small improvements for -membedded-pic on MIPS
- To: gcc-patches at gcc dot gnu dot org, gavin at cygnus dot com
- Subject: Small improvements for -membedded-pic on MIPS
- From: Geoff Keating <geoffk at ozemail dot com dot au>
- Date: Sun, 10 Oct 1999 17:19:46 +1000
These patches have been in my tree for some time.
OK to commit?
The hack to ASM_OUTPUT_LABELREF is because otherwise it's possible to
have a function in one section which is inlined into a function in
another section, and if you have
.section ".gnu.linkonce.foo"
some_func:
.section ".text"
other_func:
.dword label-some_func
label:
and the linkonce section goes away, you can imagine ld doesn't like
it. (ld doesn't like it much even if the other section is still
there, since it doesn't have the right relocs for it.)
--
Geoffrey Keating <geoffk@cygnus.com>
===File ~/patches/cygnus/tx49-egcs-empic.patch==============
md5sum: 3fe0bd7ce737a285 8436037c47b96a8f 324913
Index: egcs/gcc/ChangeLog
0a
Wed Sep 22 16:37:42 1999 Geoffrey Keating <geoffk@cygnus.com>
* config/mips/mips.h (ASM_SPEC): Don't pass -G to the assembler
when -membedded-pic is passed.
* config/mips/mips.md (casesi): Handle 64-bit case too.
(casesi_internal_di): New insn.
* config/mips/mips.c (embedded_pic_offset): Always make the
embedded-pic subtractions relative to the name of the current
function by use of the magic string "..CURRENT_FUNCTION".
* config/mips/mips.h (ASM_OUTPUT_LABELREF): Make the magic happen.
.
Changed files:
egcs/gcc/ChangeLog
egcs/gcc/config/mips/mips.md
egcs/gcc/config/mips/mips.h
md5sum: 2b40042e0bee9d74 e3f7696c810d955b 321579
--- /sloth/disk0/co/egcs-mainline/egcs/gcc/config/mips/mips.md Sun Oct 10 13:02:30 1999
+++ egcs/gcc/config/mips/mips.md Sun Oct 10 17:09:20 1999
@@ -9217,10 +9217,6 @@ (define_expand "casesi"
"TARGET_EMBEDDED_PIC"
"
{
- /* We need slightly different code for eight byte table entries. */
- if (Pmode == DImode)
- abort ();
-
if (operands[0])
{
rtx reg = gen_reg_rtx (SImode);
@@ -9231,7 +9227,12 @@ (define_expand "casesi"
emit_insn (gen_bgtu (operands[4]));
/* Do the PIC jump. */
- emit_insn (gen_casesi_internal (reg, operands[3], gen_reg_rtx (SImode)));
+ if (Pmode != DImode)
+ emit_insn (gen_casesi_internal (reg, operands[3],
+ gen_reg_rtx (SImode)));
+ else
+ emit_insn (gen_casesi_internal_di (reg, operands[3],
+ gen_reg_rtx (DImode)));
DONE;
}
@@ -9263,6 +9264,26 @@ (define_insn "casesi_internal"
output_asm_insn (\"%(bal\\t%S1\;sll\\t%0,2\\n%~%S1:\", operands);
output_asm_insn (\"addu\\t%0,%0,$31%)\", operands);
output_asm_insn (\"lw\\t%0,%1-%S1(%0)\;addu\\t%0,%0,$31\", operands);
+ return \"j\\t%0\";
+}"
+ [(set_attr "type" "jump")
+ (set_attr "mode" "none")
+ (set_attr "length" "6")])
+
+(define_insn "casesi_internal_di"
+ [(set (pc)
+ (mem:DI (plus:DI (sign_extend:DI
+ (mult:SI (match_operand:SI 0 "register_operand" "d")
+ (const_int 8)))
+ (label_ref (match_operand 1 "" "")))))
+ (clobber (match_operand:DI 2 "register_operand" "d"))
+ (clobber (reg:DI 31))]
+ "TARGET_EMBEDDED_PIC"
+ "*
+{
+ output_asm_insn (\"%(bal\\t%S1\;sll\\t%0,3\\n%~%S1:\", operands);
+ output_asm_insn (\"addu\\t%0,%0,$31%)\", operands);
+ output_asm_insn (\"ld\\t%0,%1-%S1(%0)\;addu\\t%0,%0,$31\", operands);
return \"j\\t%0\";
}"
[(set_attr "type" "jump")
md5sum: c7f095d1d0a4b471 e5ac999d011bd83b 176606
--- /sloth/disk0/co/egcs-mainline/egcs/gcc/config/mips/mips.h Thu Oct 7 21:36:13 1999
+++ egcs/gcc/config/mips/mips.h Sun Oct 10 17:09:20 1999
@@ -753,7 +753,7 @@ while (0)
/* ASM_SPEC is the set of arguments to pass to the assembler. */
#define ASM_SPEC "\
-%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
+%{!membedded-pic:%{G*}} %{EB} %{EL} %{mips1} %{mips2} %{mips3} %{mips4} \
%{mips16:%{!mno-mips16:-mips16}} %{mno-mips16:-no-mips16} \
%(subtarget_asm_optimizing_spec) \
%(subtarget_asm_debugging_spec) \
@@ -3155,6 +3155,16 @@ typedef struct mips_args {
} \
} \
while (0)
+
+/* This handles the magic '..CURRENT_FUNCTION' symbol, which means
+ 'the start of the function that this code is output in'. */
+
+#define ASM_OUTPUT_LABELREF(FILE,NAME) \
+ if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \
+ asm_fprintf ((FILE), "%U%s", \
+ XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
+ else \
+ asm_fprintf ((FILE), "%U%s", (NAME))
/* The mips16 wants the constant pool to be after the function,
because the PC relative load instructions use unsigned offsets. */
============================================================