This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, Thanks for your suggestions. I have updated the patch and added texi patch and Dejagnu patch. > > Lastly, could you generate a patch for the mainline as well? > Attached is patch created for mainline ( gcc-4.0-20040919 snapshot). Following patch I have created for gcc3.4.2 release sources. ChangeLog: 2004-09-24 Asgari Jinia <ajinia@kpitcummins.com> * config/h8300/h8300.c (h8300_handle_function_vector_attribute): New function. (print_operand): New switch case added to check jsr operands. (h8300_attrib): Changed for argument and new function. * config/h8300/h8300.md (call): Changed assembly output to get processed by print_operand function. (call_value): Likewise. * doc/extend.texi (function_vector): changed description. * testsuite/gcc.dg/func-vect.c: New test for function vector attribute. --- gcc-3.4-20040813/gcc/config/h8300/h8300.c 2004-08-31 17:33:40.000000000 +0530 +++ gcc-3.4-20040813/gcc/config/h8300/h8300.c.new 2004-09-24 11:09:35.000000000 +0530 @@ -61,6 +61,7 @@ static const char *cond_string (enum rtx static unsigned int h8300_asm_insn_count (const char *); static tree h8300_handle_fndecl_attribute (tree *, tree, tree, int, bool *); static tree h8300_handle_eightbit_data_attribute (tree *, tree, tree, int, bool *); +static tree h8300_handle_function_vector_attribute (tree *, tree, tree, int, bool *); static tree h8300_handle_tiny_data_attribute (tree *, tree, tree, int, bool *); static unsigned int h8300_section_type_flags PARAMS ((tree, const char *, int)); @@ -1161,6 +1162,7 @@ h8300_rtx_costs (rtx x, int code, int ou /* Documentation for the machine specific operand escapes: + 'C' print jsr operand 'E' like s but negative. 'F' like t but negative. 'G' constant just the negative @@ -1232,6 +1234,52 @@ print_operand (FILE *file, rtx x, int co switch (code) { + case 'C': + switch (GET_CODE (x)) + { + case MEM: + { + rtx inside = XEXP (x, 0); + if (GET_CODE (inside) == SYMBOL_REF + && (SYMBOL_REF_FLAGS (inside) & SYMBOL_FLAG_FUNCVEC_FUNCTION)) + { + int func_vect_num; + tree t; + t = SYMBOL_REF_DECL (inside); + + func_vect_num = TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (lookup_attribute ("function_vector", + DECL_ATTRIBUTES (t))))); + fprintf (file,"@%d:8",(func_vect_num & 0xff)); + } + else if (GET_CODE (inside) == SYMBOL_REF) + { + assemble_name (file,XSTR (inside,0)); + } + else if (GET_CODE (inside) == REG) + { + if (TARGET_H8300) + fprintf (file, "%s", names_big[REGNO (inside)]); + else + fprintf (file, "%s", names_extended[REGNO (inside)]); + } + else if (GET_CODE (inside) == CONST_INT) + { + if (TARGET_H8300 | TARGET_NORMAL_MODE) + fprintf (file, "%d", XINT (inside,0) & 0xffff); + else + fprintf (file, "%d", XINT (inside,0) & 0xffffff); + } + else + { + print_operand_address (file, inside); + } + + } + break; + default: + abort (); + } + break; case 'E': switch (GET_CODE (x)) { @@ -4274,7 +4322,7 @@ const struct attribute_spec h8300_attrib { "saveall", 0, 0, true, false, false, h8300_handle_fndecl_attribute }, { "OS_Task", 0, 0, true, false, false, h8300_handle_fndecl_attribute }, { "monitor", 0, 0, true, false, false, h8300_handle_fndecl_attribute }, - { "function_vector", 0, 0, true, false, false, h8300_handle_fndecl_attribute }, + { "function_vector", 1, 1, true, false, false, h8300_handle_function_vector_attribute }, { "eightbit_data", 0, 0, true, false, false, h8300_handle_eightbit_data_attribute }, { "tiny_data", 0, 0, true, false, false, h8300_handle_tiny_data_attribute }, { NULL, 0, 0, false, false, false, NULL } @@ -4298,6 +4346,31 @@ h8300_handle_fndecl_attribute (tree *nod return NULL_TREE; } +/* Handle a "function_vector" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +h8300_handle_function_vector_attribute (tree *node, tree name, + tree args ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED, + bool *no_add_attrs) +{ + if (TREE_CODE (*node) != FUNCTION_DECL) + { + warning ("`%s' attribute only applies to functions", + IDENTIFIER_POINTER (name)); + *no_add_attrs = true; + } + else if (TREE_CODE (TREE_VALUE (args)) != INTEGER_CST) + { + /* The argument must be a constant integer. */ + warning ("`%s' attribute argument not an integer constant", + IDENTIFIER_POINTER (name)); + *no_add_attrs = true; + } + return NULL_TREE; +} + /* Handle an "eightbit_data" attribute; arguments as in struct attribute_spec.handler. */ --- gcc-3.4-20040813/gcc/config/h8300/h8300.md 2004-08-31 17:33:40.000000000 +0530 +++ gcc-3.4-20040813/gcc/config/h8300/h8300.md.new 2004-09-24 11:09:44.000000000 +0530 @@ -1816,14 +1816,7 @@ [(call (match_operand:QI 0 "call_insn_operand" "or") (match_operand:HI 1 "general_operand" "g"))] "" - "* -{ - if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF - && SYMBOL_REF_FLAG (XEXP (operands[0], 0))) - return \"jsr\\t@%0:8\"; - else - return \"jsr\\t%0\"; -}" + "jsr @%C0" [(set_attr "cc" "clobber") (set (attr "length") (if_then_else (match_operand:QI 0 "small_call_insn_operand" "") @@ -1840,14 +1833,7 @@ (call (match_operand:QI 1 "call_insn_operand" "or") (match_operand:HI 2 "general_operand" "g")))] "" - "* -{ - if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF - && SYMBOL_REF_FLAG (XEXP (operands[1], 0))) - return \"jsr\\t@%1:8\"; - else - return \"jsr\\t%1\"; -}" + "jsr @%C1" [(set_attr "cc" "clobber") (set (attr "length") (if_then_else (match_operand:QI 0 "small_call_insn_operand" "") --- gcc-3.4.2/gcc/doc/extend.texi 2004-08-23 23:32:58.000000000 +0530 +++ gcc-3.4.2/gcc/doc/extend.texi.new 2004-09-20 20:32:20.000000000 +0530 @@ -2486,13 +2486,31 @@ contents of that register. The @code{s the offset to the function from the call site into the @samp{BL} instruction directly. -@item function_vector +@item function_vector (@var{vector_address}) @cindex calling functions through the function vector on the H8/300 processors Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified function should be called through the function vector. Calling a function through the function vector will reduce code size, however; the function vector has a limited size (maximum 128 entries on the H8/300 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector. +The "@var{vector_address}" is the vector location in the range from 0 to 255. + +Compiler uses 2 bytes instead of 4 bytes to call a function declared with this +attribute. For this compiler uses memory indirect call using jsr @@aa:8 instruction. + +For example, following call to "foo" will use 2 bytes instead of 4 bytes. + +@smallexample +void foo (void) __attribute__ ((function_vector(vector_address))); +void foo (void) +@{ +@} + +void bar (void) +@{ + foo(); +@} +@end smallexample You must use GAS and GLD from GNU binutils version 2.7 or later for this attribute to work correctly. --- /dev/null 2002-08-31 05:01:37.000000000 +0530 +++ gcc-3.4.2/gcc/testsuite/gcc.dg/func-vect.c 2004-09-22 13:07:31.000000000 +0530 @@ -0,0 +1,15 @@ +/* Test for function_vector attribute. */ +/* Origin: Asgari Jinia <asgarij@kpitcummins.com> */ +/* { dg-do compile {target h8300*-*-*}} */ +/* { dg-final { scan-assembler "jsr\t@@16:8" } } */ + +void foo(void) __attribute__((function_vector(16))); +void foo(void) +{ + +} + +void bar(void) +{ + foo(); +} Regards, Asgari Jinia KPIT Cummins InfoSystems Ltd. Pune, India ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Free download of GNU based tool-chains for Renesas' SH and H8 Series. The following site also offers free technical support to its users. Visit http://www.kpitgnutools.com for details. Latest versions of KPIT GNU tools are released on June 1, 2004. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Attachment:
function_vector_mainline.patch
Description: function_vector_mainline.patch
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |