summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>2005-08-01 22:25:52 +0000
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>2005-08-01 22:25:52 +0000
commit3d375286e0a3565ac76a832376609035fd435cf4 (patch)
tree1b2f7b954419c82bc60f7e34da9c6744ffb94baf /gcc
parente8aaae4efa4777c8004424e8fd16376d21b2732e (diff)
downloadgcc-3d375286e0a3565ac76a832376609035fd435cf4.tar.gz
Add long_call attribute to mips port.
* config/mips/mips.c (mips_encode_section_info, mips_attribute_table, TARGET_ENCODE_SECTION_INFO, TARGET_ATTRIBUTE_TABLE): New. * config/mips/mips.h (SYMBOL_FLAG_LONG_CALL, SYMBOL_REF_LONG_CALL_P): New. * config/mips/predicates.md (const_call_insn_operand): Add check for SYMBOL_REF_LONG_CALL_P. * doc/extend.texi (long_call): Document the new attribute. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102646 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/config/mips/mips.c30
-rw-r--r--gcc/config/mips/mips.h5
-rw-r--r--gcc/config/mips/predicates.md6
-rw-r--r--gcc/doc/extend.texi8
5 files changed, 57 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cbc564b5388..bc765ffe59a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2005-08-01 James E Wilson <wilson@specifix.com>
+
+ * config/mips/mips.c (mips_encode_section_info, mips_attribute_table,
+ TARGET_ENCODE_SECTION_INFO, TARGET_ATTRIBUTE_TABLE): New.
+ * config/mips/mips.h (SYMBOL_FLAG_LONG_CALL, SYMBOL_REF_LONG_CALL_P):
+ New.
+ * config/mips/predicates.md (const_call_insn_operand): Add check for
+ SYMBOL_REF_LONG_CALL_P.
+ * doc/extend.texi (long_call): Document the new attribute.
+
2005-08-01 Ian Lance Taylor <ian@airs.com>
Richard Henderson <rth@redhat.com>
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index ba4efb37a13..8ae0f7e5148 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -406,6 +406,7 @@ static rtx mips_expand_builtin_compare (enum mips_builtin_type,
enum insn_code, enum mips_fp_condition,
rtx, tree);
static rtx mips_expand_builtin_bposge (enum mips_builtin_type, rtx);
+static void mips_encode_section_info (tree, rtx, int);
/* Structure to be filled in by compute_frame_size with register
save masks, and offsets for the current function. */
@@ -689,6 +690,13 @@ const enum reg_class mips_regno_to_class[] =
/* Map register constraint character to register class. */
enum reg_class mips_char_to_class[256];
+
+/* Table of machine dependent attributes. */
+const struct attribute_spec mips_attribute_table[] =
+{
+ { "long_call", 0, 0, false, true, true, NULL },
+ { NULL, 0, 0, false, false, false, NULL }
+};
/* A table describing all the processors gcc knows about. Names are
matched in the order listed. The first mention of an ISA level is
@@ -1146,6 +1154,12 @@ static struct mips_rtx_cost_data const mips_rtx_cost_data[PROCESSOR_MAX] =
#undef TARGET_CANNOT_FORCE_CONST_MEM
#define TARGET_CANNOT_FORCE_CONST_MEM mips_cannot_force_const_mem
+#undef TARGET_ENCODE_SECTION_INFO
+#define TARGET_ENCODE_SECTION_INFO mips_encode_section_info
+
+#undef TARGET_ATTRIBUTE_TABLE
+#define TARGET_ATTRIBUTE_TABLE mips_attribute_table
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Classify symbol X, which must be a SYMBOL_REF or a LABEL_REF. */
@@ -10719,4 +10733,20 @@ mips_expand_builtin_bposge (enum mips_builtin_type builtin_type, rtx target)
return target;
}
+/* Set SYMBOL_REF_FLAGS for the SYMBOL_REF inside RTL, which belongs to DECL.
+ FIRST is true if this is the first time handling this decl. */
+
+static void
+mips_encode_section_info (tree decl, rtx rtl, int first)
+{
+ default_encode_section_info (decl, rtl, first);
+
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && lookup_attribute ("long_call", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
+ {
+ rtx symbol = XEXP (rtl, 0);
+ SYMBOL_REF_FLAGS (symbol) |= SYMBOL_FLAG_LONG_CALL;
+ }
+}
+
#include "gt-mips.h"
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 76f81dee369..5fd3adf3e8a 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -2301,6 +2301,11 @@ typedef struct mips_args {
else \
asm_fprintf ((FILE), "%U%s", (NAME))
+/* Flag to mark a function decl symbol that requires a long call. */
+#define SYMBOL_FLAG_LONG_CALL (SYMBOL_FLAG_MACH_DEP << 0)
+#define SYMBOL_REF_LONG_CALL_P(X) \
+ ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_LONG_CALL) != 0)
+
/* Specify the machine mode that this machine uses
for the index in the tablejump instruction.
??? Using HImode in mips16 mode can cause overflow. */
diff --git a/gcc/config/mips/predicates.md b/gcc/config/mips/predicates.md
index e4e3805845f..a96e0172149 100644
--- a/gcc/config/mips/predicates.md
+++ b/gcc/config/mips/predicates.md
@@ -103,8 +103,10 @@
switch (symbol_type)
{
case SYMBOL_GENERAL:
- /* If -mlong-calls, force all calls to use register addressing. */
- return !TARGET_LONG_CALLS;
+ /* If -mlong-calls, force all calls to use register addressing. Also,
+ if this function has the long_call attribute, we must use register
+ addressing. */
+ return !TARGET_LONG_CALLS && !SYMBOL_REF_LONG_CALL_P (op);
case SYMBOL_GOT_GLOBAL:
/* Without explicit relocs, there is no special syntax for
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index dc02b62ae7a..225f5a32e5b 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1942,6 +1942,14 @@ both the @option{-mlongcall} switch and, on the RS/6000 and PowerPC, the
@xref{RS/6000 and PowerPC Options}, for more information on whether long
calls are necessary.
+@item long_call
+@cindex indirect calls on MIPS
+This attribute specifies how a particular function is called on MIPS@.
+The attribute overrides the @option{-mlong-calls} (@pxref{MIPS Options})
+command line switch. This attribute causes the compiler to always call
+the function by first loading its address into a register, and then using
+the contents of that register.
+
@item malloc
@cindex @code{malloc} attribute
The @code{malloc} attribute is used to tell the compiler that a function