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]

add prefetch support to sparc



This adds support for "prefetch" on sparc
bootstraped on sparc-sun-solaris2.8

and the assembly generated for the tests in: 

http://gcc.gnu.org/ml/gcc-patches/2001-11/msg02128.html

compiled with -O2 -mcpu=ultrasparc run and the assembly output looks
sane. 

2001-12-11 Dan Nicolaescu  <dann@ics.uci.edu>

	* config/sparc/sparc.md (prefetch): New pattern to support
          prefetching.



*** sparc.md.~1.136.~	Tue Dec 11 16:04:12 2001
--- sparc.md	Tue Dec 11 16:05:09 2001
***************
*** 9225,9230 ****
--- 9225,9262 ----
     && (USING_SJLJ_EXCEPTIONS || ! can_throw_internal (insn))"
    "call\\t%a0, %1\\n\\tadd\\t%%o7, (%l2-.-4), %%o7")
  
+ (define_insn "prefetch"
+   [(prefetch (match_operand:DI 0 "address_operand" "p")
+ 	     (match_operand:DI 1 "const_int_operand" "n")
+ 	     (match_operand:DI 2 "const_int_operand" "n"))]
+   "TARGET_V9"
+ {
+   static const char * const prefetch_instr[2][4] = {
+     {
+       "prefetch\\t[%a0], 1", /* no locality: prefetch for one read */
+       "prefetch\\t[%a0], 0", /* medium locality: prefetch for several reads */
+       "prefetch\\t[%a0], 0", /* medium locality: prefetch for several reads */
+       "prefetch\\t[%a0], 4", /* high locality: prefetch page */
+     },
+     {
+       "prefetch\\t[%a0], 3", /* no locality: prefetch for one write */	
+       "prefetch\\t[%a0], 2", /* medium locality: prefetch for several writes */
+       "prefetch\\t[%a0], 2", /* medium locality: prefetch for several writes */
+       "prefetch\\t[%a0], 4", /* high locality: prefetch page */
+     }
+   };
+   int read_or_write = INTVAL (operands[1]);
+   int locality = INTVAL (operands[2]);
+ 
+   if (read_or_write != 0 && read_or_write != 1)
+     abort ();
+   if (locality < 0 || locality > 3)
+     abort ();
+   return prefetch_instr [read_or_write][locality];
+ }
+   [(set_attr "type" "load")])
+ 
+ 
  (define_expand "prologue"
    [(const_int 1)]
    "flag_pic && current_function_uses_pic_offset_table"


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