* [bfin] Add l1 attributes
@ 2007-08-24 8:16 Jie Zhang
2007-08-27 0:48 ` Bernd Schmidt
0 siblings, 1 reply; 3+ messages in thread
From: Jie Zhang @ 2007-08-24 8:16 UTC (permalink / raw)
To: GCC Patches; +Cc: Bernd Schmidt
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
This patch adds l1_text attribute along with three others for variables:
l1_data, l1_data_A, l1_data_B. The functions with l1_text attribute will
be placed into the .l1.text section. If FDPIC ABI is used, calling into
and from l1_text functions will be through inline PLT when appropriate.
The variables with l1_data, l1_data_A or l1_data_B will be placed into
the .l1.data, .l1.data.A or .l1.data.B section respectively.
OK to commit?
Jie
[-- Attachment #2: bfin-l1-attributes.diff --]
[-- Type: text/x-patch, Size: 6587 bytes --]
* config/bfin/bfin.c (bfin_expand_call): Inline PLT with l1_text
attribute when appropriate.
(bfin_handle_l1_text_attribute): New.
(bfin_handle_l1_data_attribute): New.
(bfin_attribute_table): Add attributes: l1_text, l1_data,
l1_data_A and l1_data_B.
* doc/extend.texi (node Function Attributes): Document l1_text
function attribute.
(Variable Attributes): Add Blackfin subsection. Document l1_data,
l1_data_A and l1_data_B variable attributes.
Index: gcc/config/bfin/bfin.c
===================================================================
--- gcc.orig/config/bfin/bfin.c 2007-08-24 14:49:36.000000000 +0800
+++ gcc/config/bfin/bfin.c 2007-08-24 14:50:50.000000000 +0800
@@ -1867,11 +1867,30 @@
if (TARGET_FDPIC)
{
+ int caller_has_l1_text, callee_has_l1_text;
+
+ caller_has_l1_text = callee_has_l1_text = 0;
+
+ if (lookup_attribute ("l1_text",
+ DECL_ATTRIBUTES (cfun->decl)) != NULL_TREE)
+ caller_has_l1_text = 1;
+
+ if (GET_CODE (callee) == SYMBOL_REF
+ && SYMBOL_REF_DECL (callee) && DECL_P (SYMBOL_REF_DECL (callee))
+ && lookup_attribute
+ ("l1_text",
+ DECL_ATTRIBUTES (SYMBOL_REF_DECL (callee))) != NULL_TREE)
+ callee_has_l1_text = 1;
+
if (GET_CODE (callee) != SYMBOL_REF
|| bfin_longcall_p (callee, INTVAL (cookie))
|| (GET_CODE (callee) == SYMBOL_REF
&& !SYMBOL_REF_LOCAL_P (callee)
- && TARGET_INLINE_PLT))
+ && TARGET_INLINE_PLT)
+ || caller_has_l1_text != callee_has_l1_text
+ || (caller_has_l1_text && callee_has_l1_text
+ && (GET_CODE (callee) != SYMBOL_REF
+ || !SYMBOL_REF_LOCAL_P (callee))))
{
rtx addr = callee;
if (! address_operand (addr, Pmode))
@@ -4634,6 +4653,91 @@
return NULL_TREE;
}
+/* Handle a "l1_text" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+bfin_handle_l1_text_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree decl = *node;
+
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ {
+ error ("`%s' attribute only applies to functions",
+ IDENTIFIER_POINTER (name));
+ *no_add_attrs = true;
+ }
+
+ /* The decl may have already been given a section attribute
+ from a previous declaration. Ensure they match. */
+ else if (DECL_SECTION_NAME (decl) != NULL_TREE
+ && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
+ ".l1.text") != 0)
+ {
+ error ("section of %q+D conflicts with previous declaration",
+ decl);
+ *no_add_attrs = true;
+ }
+ else
+ DECL_SECTION_NAME (decl) = build_string (9, ".l1.text");
+
+ return NULL_TREE;
+}
+
+/* Handle a "l1_data", "l1_data_A" or "l1_data_B" attribute;
+ arguments as in struct attribute_spec.handler. */
+
+static tree
+bfin_handle_l1_data_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree decl = *node;
+
+ if (TREE_CODE (decl) != VAR_DECL)
+ {
+ error ("`%s' attribute only applies to variables",
+ IDENTIFIER_POINTER (name));
+ *no_add_attrs = true;
+ }
+ else if (current_function_decl != NULL_TREE
+ && !TREE_STATIC (decl))
+ {
+ error ("`%s' attribute cannot be specified for local variables",
+ IDENTIFIER_POINTER (name));
+ *no_add_attrs = true;
+ }
+ else
+ {
+ const char *section_name;
+
+ if (strcmp (IDENTIFIER_POINTER (name), "l1_data") == 0)
+ section_name = ".l1.data";
+ else if (strcmp (IDENTIFIER_POINTER (name), "l1_data_A") == 0)
+ section_name = ".l1.data.A";
+ else if (strcmp (IDENTIFIER_POINTER (name), "l1_data_B") == 0)
+ section_name = ".l1.data.B";
+ else
+ gcc_unreachable ();
+
+ /* The decl may have already been given a section attribute
+ from a previous declaration. Ensure they match. */
+ if (DECL_SECTION_NAME (decl) != NULL_TREE
+ && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
+ section_name) != 0)
+ {
+ error ("section of %q+D conflicts with previous declaration",
+ decl);
+ *no_add_attrs = true;
+ }
+ else
+ DECL_SECTION_NAME (decl)
+ = build_string (strlen (section_name) + 1, section_name);
+ }
+
+ return NULL_TREE;
+}
+
/* Table of valid machine attributes. */
const struct attribute_spec bfin_attribute_table[] =
{
@@ -4646,6 +4750,10 @@
{ "saveall", 0, 0, false, true, true, NULL },
{ "longcall", 0, 0, false, true, true, bfin_handle_longcall_attribute },
{ "shortcall", 0, 0, false, true, true, bfin_handle_longcall_attribute },
+ { "l1_text", 0, 0, true, false, false, bfin_handle_l1_text_attribute },
+ { "l1_data", 0, 0, true, false, false, bfin_handle_l1_data_attribute },
+ { "l1_data_A", 0, 0, true, false, false, bfin_handle_l1_data_attribute },
+ { "l1_data_B", 0, 0, true, false, false, bfin_handle_l1_data_attribute },
{ NULL, 0, 0, false, false, false, NULL }
};
\f
Index: gcc/doc/extend.texi
===================================================================
--- gcc.orig/doc/extend.texi 2007-08-24 14:49:48.000000000 +0800
+++ gcc/doc/extend.texi 2007-08-24 14:50:05.000000000 +0800
@@ -2144,6 +2144,13 @@
or @code{nmi_handler}, code will be generated to load the stack pointer
from the USP register in the function prologue.
+@item l1_text
+@cindex @code{l1_text} function attribute
+This attribute specifies a function to be placed into L1 Instruction
+SRAM. The function will be put into a specific section named @code{.l1.text}.
+With @option{-mfdpic}, function calls with a such function as the callee
+or caller will use inlined PLT.
+
@item long_call/short_call
@cindex indirect calls on ARM
This attribute specifies how a particular function is called on
@@ -3461,6 +3468,24 @@
@end table
+@subsection Blackfin Variable Attributes
+
+Three attributes are currently defined for the Blackfin.
+
+@table @code
+@item l1_data
+@item l1_data_A
+@item l1_data_B
+@cindex @code{l1_data} variable attribute
+@cindex @code{l1_data_A} variable attribute
+@cindex @code{l1_data_B} variable attribute
+Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
+Variables with @code{l1_data} attribute will be put into the specific section
+named @code{.l1.data}. Those with @code{l1_data_A} attribute will be put into
+the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
+attribute will be put into the specific section named @code{.l1.data.B}.
+@end table
+
@subsection M32R/D Variable Attributes
One attribute is currently defined for the M32R/D@.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bfin] Add l1 attributes
2007-08-24 8:16 [bfin] Add l1 attributes Jie Zhang
@ 2007-08-27 0:48 ` Bernd Schmidt
2007-08-29 9:33 ` Jie Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Bernd Schmidt @ 2007-08-27 0:48 UTC (permalink / raw)
To: Jie Zhang; +Cc: GCC Patches
Jie Zhang wrote:
> This patch adds l1_text attribute along with three others for variables:
> l1_data, l1_data_A, l1_data_B. The functions with l1_text attribute will
> be placed into the .l1.text section. If FDPIC ABI is used, calling into
> and from l1_text functions will be through inline PLT when appropriate.
> The variables with l1_data, l1_data_A or l1_data_B will be placed into
> the .l1.data, .l1.data.A or .l1.data.B section respectively.
>
> OK to commit?
Ok.
Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bfin] Add l1 attributes
2007-08-27 0:48 ` Bernd Schmidt
@ 2007-08-29 9:33 ` Jie Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Jie Zhang @ 2007-08-29 9:33 UTC (permalink / raw)
To: Bernd Schmidt; +Cc: GCC Patches
Bernd Schmidt wrote:
> Jie Zhang wrote:
>> This patch adds l1_text attribute along with three others for
>> variables: l1_data, l1_data_A, l1_data_B. The functions with l1_text
>> attribute will be placed into the .l1.text section. If FDPIC ABI is
>> used, calling into and from l1_text functions will be through inline
>> PLT when appropriate. The variables with l1_data, l1_data_A or
>> l1_data_B will be placed into the .l1.data, .l1.data.A or .l1.data.B
>> section respectively.
>>
>> OK to commit?
>
> Ok.
>
Committed as r127887.
Jie
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-08-29 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-24 8:16 [bfin] Add l1 attributes Jie Zhang
2007-08-27 0:48 ` Bernd Schmidt
2007-08-29 9:33 ` Jie Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).