public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, aarch64] Add prefetch support
@ 2014-07-04 10:57 Gopalasubramanian, Ganesh
  2014-07-05 20:42 ` Gopalasubramanian, Ganesh
  2014-07-09  8:54 ` Richard Earnshaw
  0 siblings, 2 replies; 16+ messages in thread
From: Gopalasubramanian, Ganesh @ 2014-07-04 10:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: marcus.shawcroft, richard.earnshaw

[-- Attachment #1: Type: text/plain, Size: 918 bytes --]

Hi,

Attached is a patch that implements
*	Prefetch with immediate offset in the range 0 to 32760 (multiple of 8). Added a predicate for this.
*	Prefetch with immediate offset - in the range -256 to 255 (Gets generated only when we have a negative offset. Generates prfum instruction). Added a predicate for this.
*	Prefetch with register offset. (modified for printing the locality)

This patch has been already discussed on https://gcc.gnu.org/ml/gcc-patches/2014-02/msg01644.html

"make -k check" passes. Ok for trunk?

Changelog

2014-07-04  Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com>

        * config/aarch64/aarch64.md (define_insn "*prefetch")
        (define_insn "prefetch"): New
        * config/aarch64/predicates.md (aarch64_prefetch_pimm) 
        (aarch64_prefetch_unscaled): New.
        * config/arm/types.md (define_attr "type"): Add prefetch.

Regards
Ganesh

[-- Attachment #2: prefetch.diff --]
[-- Type: application/octet-stream, Size: 3833 bytes --]

diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 3eb783c..1a86e02 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -311,6 +311,74 @@
   [(set_attr "type" "no_insn")]
 )
 
+(define_insn "*prefetch"
+  [(prefetch (plus:DI (match_operand:DI 0 "register_operand" "r")
+                      (match_operand:DI 1 "aarch64_prefetch_pimm" "")
+             )
+            (match_operand:QI 2 "const_int_operand" "n")
+           (match_operand:QI 3 "const_int_operand" "n"))]
+  ""
+  "*
+{
+  int locality = INTVAL (operands[3]);
+
+  gcc_assert (IN_RANGE (locality, 0, 3));
+
+  if (locality == 0)
+     /* non temporal locality */
+     return (INTVAL(operands[2])) ? \"prfm\\tPSTL1STRM, [%0, %1]\" : \"prfm\\tPLDL1STRM, [%0, %1]\";
+
+  /* temporal locality */
+  return (INTVAL(operands[2])) ? \"prfm\\tPSTL%3KEEP, [%0, %1]\" : \"prfm\\tPLDL%3KEEP, [%0, %1]\";
+}"
+  [(set_attr "type" "prefetch")]
+)
+
+(define_insn "*prefetch"
+  [(prefetch (plus:DI (match_operand:DI 0 "register_operand" "r")
+                      (match_operand:DI 1 "aarch64_prefetch_unscaled" "")
+             )
+            (match_operand:QI 2 "const_int_operand" "n")
+            (match_operand:QI 3 "const_int_operand" "n"))]
+  ""
+  "*
+{
+  int locality = INTVAL (operands[3]);
+
+  gcc_assert (IN_RANGE (locality, 0, 3));
+
+  if (locality == 0)
+     /* non temporal locality */
+     return (INTVAL(operands[2])) ? \"prfum\\tPSTL1STRM, [%0, %1]\" : \"prfm\\tPLDL1STRM, [%0, %1]\";
+
+  /* temporal locality */
+  return (INTVAL(operands[2])) ? \"prfum\\tPSTL%3KEEP, [%0, %1]\" : \"prfm\\tPLDL%3KEEP, [%0, %1]\";
+}"
+  [(set_attr "type" "prefetch")]
+)
+
+(define_insn "prefetch"
+  [(prefetch (match_operand:DI 0 "address_operand" "r")
+            (match_operand:QI 1 "const_int_operand" "n")
+            (match_operand:QI 2 "const_int_operand" "n"))]
+  ""
+  "*
+{
+  int locality = INTVAL (operands[2]);
+
+  gcc_assert (IN_RANGE (locality, 0, 3));
+
+  if (locality == 0)
+     /* non temporal locality */
+     return (INTVAL(operands[1])) ? \"prfm\\tPSTL1STRM, [%0, #0]\" : \"prfm\\tPLDL1STRM, [%0, #0]\";
+
+  /* temporal locality */
+  return (INTVAL(operands[1])) ? \"prfm\\tPSTL%2KEEP, [%0, #0]\" : \"prfm\\tPLDL%2KEEP, [%0, #0]\";
+}"
+  [(set_attr "type" "prefetch")]
+)
+
+
 (define_insn "trap"
   [(trap_if (const_int 1) (const_int 8))]
   ""
diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md
index 2702a3c..c37a8a9 100644
--- a/gcc/config/aarch64/predicates.md
+++ b/gcc/config/aarch64/predicates.md
@@ -66,6 +66,14 @@
   (ior (match_operand 0 "register_operand")
        (match_operand 0 "aarch64_plus_immediate")))
 
+(define_predicate "aarch64_prefetch_pimm"
+  (and (match_code "const_int")
+       (match_test "(INTVAL (op) < 0x7ff8 && (0 == INTVAL (op) % 8))")))
+
+(define_predicate "aarch64_prefetch_unscaled"
+  (and (match_code "const_int")
+       (match_test "(INTVAL (op) < 255 && INTVAL (op) > -256)")))
+
 (define_predicate "aarch64_pluslong_immediate"
   (and (match_code "const_int")
        (match_test "(INTVAL (op) < 0xffffff && INTVAL (op) > -0xffffff)")))
diff --git a/gcc/config/arm/types.md b/gcc/config/arm/types.md
index efbf7a7..0b92c1a 100644
--- a/gcc/config/arm/types.md
+++ b/gcc/config/arm/types.md
@@ -117,6 +117,7 @@
 ; mvn_shift_reg      inverting move instruction, shifted operand by a register.
 ; no_insn            an insn which does not represent an instruction in the
 ;                    final output, thus having no impact on scheduling.
+; prefetch           a prefetch instruction
 ; rbit               reverse bits.
 ; rev                reverse bytes.
 ; sdiv               signed division.
@@ -554,6 +555,7 @@
   call,\
   clz,\
   no_insn,\
+  prefetch,\
   csel,\
   crc,\
   extend,\

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [PATCH, aarch64] Add prefetch support
@ 2014-10-30  9:00 Gopalasubramanian, Ganesh
  2014-11-11 14:48 ` Marcus Shawcroft
  0 siblings, 1 reply; 16+ messages in thread
From: Gopalasubramanian, Ganesh @ 2014-10-30  9:00 UTC (permalink / raw)
  To: gcc-patches

Hi,

Below is the patch that implements prefetching support.

This patch has been already discussed on 
a) https://gcc.gnu.org/ml/gcc-patches/2014-02/msg01644.html
b) https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00612.html

I have not added a test as there are ample tests in compile and execute suites.
"make -k check" passes. Ok for trunk?

Changelog:
2014-10-30  Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com>

        * config/aarch64/aarch64.md (define_insn "prefetch"): New.
        * config/arm/types.md (define_attr "type"): Add prefetch.

Regards
Ganesh

diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 74b554e..12a3f170 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -320,6 +320,38 @@
   [(set_attr "type" "no_insn")]
)

+
+(define_insn "prefetch"
+  [(prefetch (match_operand:DI 0 "address_operand" "r")
+            (match_operand:QI 1 "const_int_operand" "")
+            (match_operand:QI 2 "const_int_operand" ""))]
+  ""
+  "*
+{
+  const char * pftype[2][10]
+    = { {\"PLDL1STRM\", \"PLDL3KEEP\", \"PLDL2KEEP\", \"PLDL1KEEP\"},
+       {\"PSTL1STRM\", \"PSTL3KEEP\", \"PSTL2KEEP\", \"PSTL1KEEP\"},
+      };
+
+  int locality = INTVAL (operands[2]);
+  char pattern[100];
+
+  gcc_assert (IN_RANGE (locality, 0, 3));
+
+  strcpy (pattern, \"prfm\\t\");
+  strcat (pattern, (const char*)pftype[INTVAL(operands[1])][locality]);
+  strcat (pattern, \", %a0\");
+
+  output_asm_insn (pattern,
+                   operands);
+
+  return \"\";
+
+}"
+  [(set_attr "type" "prefetch")]
+)
+
(define_insn "trap"
   [(trap_if (const_int 1) (const_int 8))]
   ""
diff --git a/gcc/config/arm/types.md b/gcc/config/arm/types.md
index c1151f5..8b4b7a1 100644
--- a/gcc/config/arm/types.md
+++ b/gcc/config/arm/types.md
@@ -118,6 +118,7 @@
; mvn_shift_reg      inverting move instruction, shifted operand by a register.
; no_insn            an insn which does not represent an instruction in the
;                    final output, thus having no impact on scheduling.
+; prefetch           a prefetch instruction
; rbit               reverse bits.
; rev                reverse bytes.
; sdiv               signed division.
@@ -556,6 +557,7 @@
   call,\
   clz,\
   no_insn,\
+  prefetch,\
   csel,\
   crc,\

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-01-13 14:32 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-04 10:57 [PATCH, aarch64] Add prefetch support Gopalasubramanian, Ganesh
2014-07-05 20:42 ` Gopalasubramanian, Ganesh
2014-07-09  5:29   ` FW: " Gopalasubramanian, Ganesh
2014-07-09  8:54 ` Richard Earnshaw
2014-10-30  9:00 Gopalasubramanian, Ganesh
2014-11-11 14:48 ` Marcus Shawcroft
2014-11-14 20:45   ` Gopalasubramanian, Ganesh
2014-11-17 13:31     ` Richard Henderson
2014-12-01  6:13       ` Gopalasubramanian, Ganesh
2014-12-01  7:49       ` Gopalasubramanian, Ganesh
2014-12-02  0:09         ` Richard Henderson
2014-12-03 13:49         ` Marcus Shawcroft
2015-01-11  8:53   ` Andrew Pinski
2015-01-13 14:31     ` Marcus Shawcroft
2015-01-13 14:32       ` Andrew Pinski
2015-01-13 14:58         ` Dr. Philipp Tomsich

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).