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]

Some builtin functions for the Blackfin


This adds builtins to generate CSYNC and SSYNC instructions.


Bernd
	* config/bfin/bfin.h (enum bfin_builtins): New.
	* 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.
	(def_builtin): New macro.
	(TARGET_INIT_BUILTINS, TARGET_EXPAND_BUILTIN): Define.
	
Index: config/bfin/bfin.c
===================================================================
RCS file: /cvsroot/gcc3/gcc-3.4/gcc/config/bfin/bfin.c,v
retrieving revision 1.79
diff -c -p -r1.79 bfin.c
*** config/bfin/bfin.c	8 Jun 2005 07:32:35 -0000	1.79
--- config/bfin/bfin.c	8 Jun 2005 08:12:56 -0000
*************** bfin_output_mi_thunk (FILE *file ATTRIBU
*** 2843,2848 ****
--- 2844,2902 ----
      output_asm_insn ("jump.l\t%P0", xops);
  }
  
+ #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.h
===================================================================
RCS file: /cvsroot/gcc3/gcc-3.4/gcc/config/bfin/bfin.h,v
retrieving revision 1.63
diff -c -p -r1.63 bfin.h
*** config/bfin/bfin.h	31 May 2005 13:18:06 -0000	1.63
--- config/bfin/bfin.h	8 Jun 2005 08:12:57 -0000
*************** do {                                    
*** 1130,1135 ****
--- 1130,1143 ----
  #define EXTRA_CONSTRAINT(VALUE, D) \
      ((D) == 'Q' ? GET_CODE (VALUE) == SYMBOL_REF : 0)
  
+ /* Codes for all the Blackfin builtins.  */
+ enum bfin_builtins
+ {
+   BFIN_BUILTIN_CSYNC,
+   BFIN_BUILTIN_SSYNC,
+   BFIN_BUILTIN_MAX
+ };
+ 
  /* `FINALIZE_PIC'
       By generating position-independent code, when two different
       programs (A and B) share a common library (libC.a), the text of
Index: config/bfin/bfin.md
===================================================================
RCS file: /cvsroot/gcc3/gcc-3.4/gcc/config/bfin/bfin.md,v
retrieving revision 1.72
diff -c -p -r1.72 bfin.md
*** config/bfin/bfin.md	19 May 2005 02:06:27 -0000	1.72
--- config/bfin/bfin.md	8 Jun 2005 08:12:57 -0000
***************
*** 119,125 ****
     (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"
--- 119,127 ----
     (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"
***************
*** 1911,1916 ****
--- 1913,1930 ----
      }
  })
  
+ (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]