Arm - add speculation_barrier pattern
authorRichard Earnshaw <rearnsha@arm.com>
Tue, 31 Jul 2018 17:35:41 +0000 (17:35 +0000)
committerRichard Earnshaw <rearnsha@gcc.gnu.org>
Tue, 31 Jul 2018 17:35:41 +0000 (17:35 +0000)
This patch defines a speculation barrier for AArch32.

* config/arm/unspecs.md (unspecv): Add VUNSPEC_SPECULATION_BARRIER.
* config/arm/arm.md (speculation_barrier): New expand.
(speculation_barrier_insn): New pattern.

From-SVN: r263169

gcc/ChangeLog
gcc/config/arm/arm.md
gcc/config/arm/unspecs.md

index de37f1f879cb4ba67758b541c2eff29dc68c260c..63971fa1c9a854c78fcfe9f8472a279a03b86cb9 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-31  Richard Earnshaw  <rearnsha@arm.com>
+
+       * config/arm/unspecs.md (unspecv): Add VUNSPEC_SPECULATION_BARRIER.
+       * config/arm/arm.md (speculation_barrier): New expand.
+       (speculation_barrier_insn): New pattern.
+
 2018-07-31  Richard Earnshaw  <rearnsha@arm.com>
 
        * builtin-types.def (BT_FN_PTR_PTR_VAR): New function type.
index 361a02668b0cfc9780c68a1eaf4a56fdf69b3d9d..ca2a2f5469f26d8bca512084c7924708be2715c1 100644 (file)
   [(set_attr "length" "4")
    (set_attr "type" "coproc")])
 
+(define_expand "speculation_barrier"
+  [(unspec_volatile [(const_int 0)] VUNSPEC_SPECULATION_BARRIER)]
+  "TARGET_EITHER"
+  "
+    /* Don't emit anything for Thumb1 and suppress the warning from the
+       generic expansion.  */
+    if (!TARGET_32BIT)
+       DONE;
+  "
+)
+
+;; Generate a hard speculation barrier when we have not enabled speculation
+;; tracking.
+(define_insn "*speculation_barrier_insn"
+  [(unspec_volatile [(const_int 0)] VUNSPEC_SPECULATION_BARRIER)]
+  "TARGET_32BIT"
+  "isb\;dsb\\tsy"
+  [(set_attr "type" "block")
+   (set_attr "length" "8")]
+)
+
 ;; Vector bits common to IWMMXT and Neon
 (include "vec-common.md")
 ;; Load the Intel Wireless Multimedia Extension patterns
index b05f85e10e47e4df1cf8f0c39a56789795a2da8b..19416736ef91fc2ac24352c30b6202c87510a3d2 100644 (file)
   VUNSPEC_MCRR2                ; Represent the coprocessor mcrr2 instruction.
   VUNSPEC_MRRC         ; Represent the coprocessor mrrc instruction.
   VUNSPEC_MRRC2                ; Represent the coprocessor mrrc2 instruction.
+  VUNSPEC_SPECULATION_BARRIER ; Represents an unconditional speculation barrier.
 ])
 
 ;; Enumerators for NEON unspecs.