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]

4.0: Patch to add Blackfin builtins


This patch adds some Blackfin builtin functions to the 4.0 branch. I'll apply the hardware errata workaround patch on top of it next.


Bernd
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 2.7592.2.310
diff -c -p -r2.7592.2.310 ChangeLog
*** ChangeLog	11 Jul 2005 14:28:26 -0000	2.7592.2.310
--- ChangeLog	12 Jul 2005 09:48:59 -0000
***************
*** 1,3 ****
--- 1,15 ----
+ 2005-07-12  Bernd Schmidt  <bernd.schmidt@analog.com>
+ 
+ 	* config/bfin/bfin.md (UNSPEC_VOLATILE_CSYNC, UNSPEC_VOLATILE_SSYNC):
+ 	New constants.
+ 	(csync, ssync): New insn patterns.
+ 	* config/bfin/bfin.c (bfin_init_builtins, bfin_expand_builtin):
+ 	New functions.
+ 	(enum bfin_builtins): New.
+ 	(def_builtin): New macro.
+ 	(TARGET_INIT_BUILTINS, TARGET_EXPAND_BUILTIN): Define.
+ 	* doc/extend.texi (Blackfin Built-in Functions): New section.
+ 
  2005-07-11  Aldy Hernandez  <aldyh@redhat.com>
  
  	Backport from mainline:
Index: doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.240.2.8
diff -c -p -r1.240.2.8 extend.texi
*** doc/extend.texi	10 May 2005 00:21:18 -0000	1.240.2.8
--- doc/extend.texi	12 Jul 2005 09:49:05 -0000
*************** instructions, but allow the compiler to 
*** 5449,5454 ****
--- 5449,5455 ----
  @menu
  * Alpha Built-in Functions::
  * ARM Built-in Functions::
+ * Blackfin Built-in Functions::
  * FR-V Built-in Functions::
  * X86 Built-in Functions::
  * MIPS Paired-Single Support::
*************** long long __builtin_arm_wxor (long long,
*** 5685,5690 ****
--- 5686,5705 ----
  long long __builtin_arm_wzero ()
  @end smallexample
  
+ @node Blackfin Built-in Functions
+ @subsection Blackfin Built-in Functions
+ 
+ Currently, there are two Blackfin-specific built-in functions.  These are
+ used for generating @code{CSYNC} and @code{SSYNC} machine insns without
+ using inline assembly; by using these built-in functions the compiler can
+ automatically add workarounds for hardware errata involving these
+ instructions.  These functions are named as follows:
+ 
+ @smallexample
+ void __builtin_bfin_csync (void)
+ void __builtin_bfin_ssync (void)
+ @end smallexample
+ 
  @node FR-V Built-in Functions
  @subsection FR-V Built-in Functions
  
Index: config/bfin/bfin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/bfin/bfin.c,v
retrieving revision 1.5.2.2
diff -c -p -r1.5.2.2 bfin.c
*** config/bfin/bfin.c	19 May 2005 09:33:05 -0000	1.5.2.2
--- config/bfin/bfin.c	12 Jul 2005 09:49:06 -0000
*************** bfin_output_mi_thunk (FILE *file ATTRIBU
*** 2671,2676 ****
--- 2671,2737 ----
      output_asm_insn ("jump.l\t%P0", xops);
  }
  
+ /* Codes for all the Blackfin builtins.  */
+ enum bfin_builtins
+ {
+   BFIN_BUILTIN_CSYNC,
+   BFIN_BUILTIN_SSYNC,
+   BFIN_BUILTIN_MAX
+ };
+ 
+ #define def_builtin(NAME, TYPE, CODE)				\
+ do {								\
+   builtin_function ((NAME), (TYPE), (CODE), BUILT_IN_MD,	\
+ 		    NULL, NULL_TREE);				\
+ } while (0)
+ 
+ /* Set up all builtin functions for this target.  */
+ static void
+ bfin_init_builtins (void)
+ {
+   tree void_ftype_void
+     = build_function_type (void_type_node, void_list_node);
+ 
+   /* Add the remaining MMX insns with somewhat more complicated types.  */
+   def_builtin ("__builtin_bfin_csync", void_ftype_void, BFIN_BUILTIN_CSYNC);
+   def_builtin ("__builtin_bfin_ssync", void_ftype_void, BFIN_BUILTIN_SSYNC);
+ }
+ 
+ /* Expand an expression EXP that calls a built-in function,
+    with result going to TARGET if that's convenient
+    (and in mode MODE if that's convenient).
+    SUBTARGET may be used as the target for computing one of EXP's operands.
+    IGNORE is nonzero if the value is to be ignored.  */
+ 
+ static rtx
+ bfin_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED,
+ 		     rtx subtarget ATTRIBUTE_UNUSED,
+ 		     enum machine_mode mode ATTRIBUTE_UNUSED,
+ 		     int ignore ATTRIBUTE_UNUSED)
+ {
+   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
+   unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
+ 
+   switch (fcode)
+     {
+     case BFIN_BUILTIN_CSYNC:
+       emit_insn (gen_csync ());
+       return 0;
+     case BFIN_BUILTIN_SSYNC:
+       emit_insn (gen_ssync ());
+       return 0;
+ 
+     default:
+       gcc_unreachable ();
+     }
+ }
+ 
+ #undef TARGET_INIT_BUILTINS
+ #define TARGET_INIT_BUILTINS bfin_init_builtins
+ 
+ #undef TARGET_EXPAND_BUILTIN
+ #define TARGET_EXPAND_BUILTIN bfin_expand_builtin
+ 
  #undef TARGET_ASM_GLOBALIZE_LABEL
  #define TARGET_ASM_GLOBALIZE_LABEL bfin_globalize_label 
  
Index: config/bfin/bfin.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/bfin/bfin.md,v
retrieving revision 1.1.8.2
diff -c -p -r1.1.8.2 bfin.md
*** config/bfin/bfin.md	19 May 2005 09:33:05 -0000	1.1.8.2
--- config/bfin/bfin.md	12 Jul 2005 09:49:07 -0000
***************
*** 120,126 ****
     (UNSPEC_PUSH_MULTIPLE 5)])
  
  (define_constants
!   [(UNSPEC_VOLATILE_EH_RETURN 0)])
  
  (define_attr "type"
    "move,mvi,mcld,mcst,dsp32,mult,alu0,shft,brcc,br,call,misc,compare,dummy"
--- 120,128 ----
     (UNSPEC_PUSH_MULTIPLE 5)])
  
  (define_constants
!   [(UNSPEC_VOLATILE_EH_RETURN 0)
!    (UNSPEC_VOLATILE_CSYNC 1)
!    (UNSPEC_VOLATILE_SSYNC 2)])
  
  (define_attr "type"
    "move,mvi,mcld,mcst,dsp32,mult,alu0,shft,brcc,br,call,misc,compare,dummy"
***************
*** 1846,1851 ****
--- 1848,1865 ----
    gcc_unreachable ();
  })
  
+ (define_insn "csync"
+   [(unspec_volatile [(const_int 0)] UNSPEC_VOLATILE_CSYNC)]
+   ""
+   "csync;"
+   [(set_attr "type" "misc")])
+ 
+ (define_insn "ssync"
+   [(unspec_volatile [(const_int 0)] UNSPEC_VOLATILE_SSYNC)]
+   ""
+   "ssync;"
+   [(set_attr "type" "misc")])
+ 
  ;;; Vector instructions
  
  (define_insn "addv2hi"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]