+2018-01-11 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ * config/rs6000/rs6000-builtin.def (BU_P7_MISC_X): New #define.
+ (SPEC_BARRIER): New instantiation of BU_P7_MISC_X.
+ * config/rs6000/rs6000.c (rs6000_expand_builtin): Handle
+ MISC_BUILTIN_SPEC_BARRIER.
+ (rs6000_init_builtins): Likewise.
+ * config/rs6000/rs6000.md (UNSPECV_SPEC_BARRIER): New UNSPECV
+ enum value.
+ (speculation_barrier): New define_insn.
+ * doc/extend.texi: Document __builtin_speculation_barrier.
+
2018-01-11 Jakub Jelinek <jakub@redhat.com>
PR target/83203
| RS6000_BTC_BINARY), \
CODE_FOR_ ## ICODE) /* ICODE */
+#define BU_P7_MISC_X(ENUM, NAME, ATTR) \
+ RS6000_BUILTIN_X (MISC_BUILTIN_ ## ENUM, /* ENUM */ \
+ "__builtin_" NAME, /* NAME */ \
+ RS6000_BTM_POPCNTD, /* MASK */ \
+ (RS6000_BTC_ ## ATTR /* ATTR */ \
+ | RS6000_BTC_SPECIAL), \
+ CODE_FOR_nothing) /* ICODE */
+
/* Miscellaneous builtins for instructions added in ISA 2.07. These
instructions do require the ISA 2.07 vector support, but they aren't vector
BU_DFP_MISC_2 (DSCRI, "dscri", CONST, dfp_dscri_dd)
BU_DFP_MISC_2 (DSCRIQ, "dscriq", CONST, dfp_dscri_td)
+/* 0 argument void function that we pretend was added in ISA 2.06.
+ It's a special nop recognized by 2018+ firmware for P7 and up,
+ with speculation barrier semantics. */
+BU_P7_MISC_X (SPEC_BARRIER, "rs6000_speculation_barrier", MISC)
+
/* 1 argument BCD functions added in ISA 2.06. */
BU_P7_MISC_1 (CDTBCD, "cdtbcd", CONST, cdtbcd)
BU_P7_MISC_1 (CBCDTD, "cbcdtd", CONST, cbcdtd)
case RS6000_BUILTIN_CPU_SUPPORTS:
return cpu_expand_builtin (fcode, exp, target);
+ case MISC_BUILTIN_SPEC_BARRIER:
+ {
+ emit_insn (gen_rs6000_speculation_barrier ());
+ return NULL_RTX;
+ }
+
case ALTIVEC_BUILTIN_MASK_FOR_LOAD:
case ALTIVEC_BUILTIN_MASK_FOR_STORE:
{
ftype = build_function_type_list (void_type_node, NULL_TREE);
def_builtin ("__builtin_cpu_init", ftype, RS6000_BUILTIN_CPU_INIT);
+ def_builtin ("__builtin_rs6000_speculation_barrier", ftype,
+ MISC_BUILTIN_SPEC_BARRIER);
ftype = build_function_type_list (bool_int_type_node, const_ptr_type_node,
NULL_TREE);
UNSPECV_MFFS ; Move from FPSCR
UNSPECV_MTFSF ; Move to FPSCR Fields
UNSPECV_SPLIT_STACK_RETURN ; A camouflaged return
+ UNSPECV_SPEC_BARRIER ; Speculation barrier
])
\f
return "ori 1,1,0";
return "ori 2,2,0";
})
+
+(define_insn "rs6000_speculation_barrier"
+ [(unspec_volatile:BLK [(const_int 0)] UNSPECV_SPEC_BARRIER)]
+ ""
+ "ori 31,31,0")
\f
;; Define the subtract-one-and-jump insns, starting with the template
;; so loop.c knows what to generate.
unsigned int cdtbcd (unsigned int);
unsigned int cbcdtd (unsigned int);
unsigned int addg6s (unsigned int, unsigned int);
+void __builtin_rs6000_speculation_barrier (void);
@end smallexample
The @code{__builtin_divde}, @code{__builtin_divdeo},
+2018-01-11 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ * gcc.target/powerpc/spec-barr-1.c: New file.
+
2018-01-11 H.J. Lu <hongjiu.lu@intel.com>
PR target/83330
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
+/* { dg-options "-mcpu=power7" } */
+
+void foo ()
+{
+ __builtin_rs6000_speculation_barrier ();
+}
+
+/* { dg-final { scan-assembler "ori 31,31,0" } } */