Commit 4f45da44 by Kelvin Nilsen

darn-0.c: New test.

gcc/testsuite/ChangeLog:

2016-05-19  Kelvin Nilsen  <kelvin@gcc.gnu.org>

	* gcc.target/powerpc/darn-0.c: New test.
	* gcc.target/powerpc/darn-1.c: New test.
	* gcc.target/powerpc/darn-2.c: New test.


gcc/ChangeLog:

2016-05-19  Kelvin Nilsen  <kelvin@gcc.gnu.org>

	* config/rs6000/altivec.md (UNSPEC_DARN): New unspec constant.
	(UNSPEC_DARN_32): New unspec constant.
	(UNSPEC_DARN_RAW): New unspec constant.
	(darn_32): New instruction.
	(darn_raw): New instruction.
	(darn): New instruction.
	* config/rs6000/rs6000-builtin.def (RS6000_BUILTIN_0): Add
	support and documentation for this macro.
	(BU_P9_MISC_1): New macro definition.
	(BU_P9_64BIT_MISC_0): New macro definition.
	(BU_P9_MISC_0): New macro definition.
	(darn_32): New builtin definition.
	(darn_raw): New builtin definition.
	(darn): New builtin definition.
	* config/rs6000/rs6000.c: Add #define RS6000_BUILTIN_0 and #undef
	RS6000_BUILTIN_0 directives to surround each occurrence of
	#include "rs6000-builtin.def".
	(rs6000_builtin_mask_calculate): Add in the RS6000_BTM_MODULO and
	RS6000_BTM_64BIT flags to the returned mask, depending on
	configuration.
	(def_builtin): Correct an error in the assignments made to the
	debugging variable attr_string.
	(rs6000_expand_builtin): Add support for no-operand built-in
	functions.
	(builtin_function_type): Remove fatal_error assertion that is no
	longer valid.
	(rs6000_common_init_builtins): Add support for no-operand built-in
	functions.
	* config/rs6000/rs6000.h (RS6000_BTM_MODULO): New macro
	definition.
	(RS6000_BTM_PURE): Enhance comment to clarify intent of this flag
	definition.
	(RS6000_BTM_64BIT): New macro definition.
	* doc/extend.texi: Document __builtin_darn (void),
	__builtin_darn_raw (void), and __builtin_darn_32 (void) built-in
	functions.

From-SVN: r236480
parent cb6b1bdf
2016-05-19 Kelvin Nilsen <kelvin@gcc.gnu.org>
* config/rs6000/altivec.md (UNSPEC_DARN): New unspec constant.
(UNSPEC_DARN_32): New unspec constant.
(UNSPEC_DARN_RAW): New unspec constant.
(darn_32): New instruction.
(darn_raw): New instruction.
(darn): New instruction.
* config/rs6000/rs6000-builtin.def (RS6000_BUILTIN_0): Add
support and documentation for this macro.
(BU_P9_MISC_1): New macro definition.
(BU_P9_64BIT_MISC_0): New macro definition.
(BU_P9_MISC_0): New macro definition.
(darn_32): New builtin definition.
(darn_raw): New builtin definition.
(darn): New builtin definition.
* config/rs6000/rs6000.c: Add #define RS6000_BUILTIN_0 and #undef
RS6000_BUILTIN_0 directives to surround each occurrence of
#include "rs6000-builtin.def".
(rs6000_builtin_mask_calculate): Add in the RS6000_BTM_MODULO and
RS6000_BTM_64BIT flags to the returned mask, depending on
configuration.
(def_builtin): Correct an error in the assignments made to the
debugging variable attr_string.
(rs6000_expand_builtin): Add support for no-operand built-in
functions.
(builtin_function_type): Remove fatal_error assertion that is no
longer valid.
(rs6000_common_init_builtins): Add support for no-operand built-in
functions.
* config/rs6000/rs6000.h (RS6000_BTM_MODULO): New macro
definition.
(RS6000_BTM_PURE): Enhance comment to clarify intent of this flag
definition.
(RS6000_BTM_64BIT): New macro definition.
* doc/extend.texi: Document __builtin_darn (void),
__builtin_darn_raw (void), and __builtin_darn_32 (void) built-in
functions.
2016-05-19 Jan Hubicka <hubicka@ucw.cz> 2016-05-19 Jan Hubicka <hubicka@ucw.cz>
* tree-vect-loop.c (vect_analyze_loop_2): Use also * tree-vect-loop.c (vect_analyze_loop_2): Use also
......
...@@ -73,6 +73,9 @@ ...@@ -73,6 +73,9 @@
UNSPEC_VUNPACK_LO_SIGN_DIRECT UNSPEC_VUNPACK_LO_SIGN_DIRECT
UNSPEC_VUPKHPX UNSPEC_VUPKHPX
UNSPEC_VUPKLPX UNSPEC_VUPKLPX
UNSPEC_DARN
UNSPEC_DARN_32
UNSPEC_DARN_RAW
UNSPEC_DST UNSPEC_DST
UNSPEC_DSTT UNSPEC_DSTT
UNSPEC_DSTST UNSPEC_DSTST
...@@ -3590,6 +3593,27 @@ ...@@ -3590,6 +3593,27 @@
[(set_attr "length" "4") [(set_attr "length" "4")
(set_attr "type" "vecsimple")]) (set_attr "type" "vecsimple")])
(define_insn "darn_32"
[(set (match_operand:SI 0 "register_operand" "=r")
(unspec:SI [(const_int 0)] UNSPEC_DARN_32))]
"TARGET_MODULO"
"darn %0,0"
[(set_attr "type" "integer")])
(define_insn "darn_raw"
[(set (match_operand:DI 0 "register_operand" "=r")
(unspec:DI [(const_int 0)] UNSPEC_DARN_RAW))]
"TARGET_MODULO && TARGET_64BIT"
"darn %0,2"
[(set_attr "type" "integer")])
(define_insn "darn"
[(set (match_operand:DI 0 "register_operand" "=r")
(unspec:DI [(const_int 0)] UNSPEC_DARN))]
"TARGET_MODULO && TARGET_64BIT"
"darn %0,1"
[(set_attr "type" "integer")])
(define_expand "bcd<bcd_add_sub>_<code>" (define_expand "bcd<bcd_add_sub>_<code>"
[(parallel [(set (reg:CCFP 74) [(parallel [(set (reg:CCFP 74)
(compare:CCFP (compare:CCFP
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
/* Before including this file, some macros must be defined: /* Before including this file, some macros must be defined:
RS6000_BUILTIN_0 -- 0 arg builtins
RS6000_BUILTIN_1 -- 1 arg builtins RS6000_BUILTIN_1 -- 1 arg builtins
RS6000_BUILTIN_2 -- 2 arg builtins RS6000_BUILTIN_2 -- 2 arg builtins
RS6000_BUILTIN_3 -- 3 arg builtins RS6000_BUILTIN_3 -- 3 arg builtins
...@@ -43,6 +44,10 @@ ...@@ -43,6 +44,10 @@
ATTR builtin attribute information. ATTR builtin attribute information.
ICODE Insn code of the function that implents the builtin. */ ICODE Insn code of the function that implents the builtin. */
#ifndef RS6000_BUILTIN_0
#error "RS6000_BUILTIN_0 is not defined."
#endif
#ifndef RS6000_BUILTIN_1 #ifndef RS6000_BUILTIN_1
#error "RS6000_BUILTIN_1 is not defined." #error "RS6000_BUILTIN_1 is not defined."
#endif #endif
...@@ -637,6 +642,41 @@ ...@@ -637,6 +642,41 @@
| RS6000_BTC_TERNARY), \ | RS6000_BTC_TERNARY), \
CODE_FOR_ ## ICODE) /* ICODE */ CODE_FOR_ ## ICODE) /* ICODE */
/* Miscellaneous builtins for instructions added in ISA 3.0. These
instructions don't require either the DFP or VSX options, just the basic
ISA 3.0 enablement since they operate on general purpose registers. */
#define BU_P9_MISC_1(ENUM, NAME, ATTR, ICODE) \
RS6000_BUILTIN_1 (MISC_BUILTIN_ ## ENUM, /* ENUM */ \
"__builtin_" NAME, /* NAME */ \
RS6000_BTM_MODULO, /* MASK */ \
(RS6000_BTC_ ## ATTR /* ATTR */ \
| RS6000_BTC_UNARY), \
CODE_FOR_ ## ICODE) /* ICODE */
/* Miscellaneous builtins for instructions added in ISA 3.0. These
instructions don't require either the DFP or VSX options, just the basic
ISA 3.0 enablement since they operate on general purpose registers,
and they require 64-bit addressing. */
#define BU_P9_64BIT_MISC_0(ENUM, NAME, ATTR, ICODE) \
RS6000_BUILTIN_0 (MISC_BUILTIN_ ## ENUM, /* ENUM */ \
"__builtin_" NAME, /* NAME */ \
RS6000_BTM_MODULO \
| RS6000_BTM_64BIT, /* MASK */ \
(RS6000_BTC_ ## ATTR /* ATTR */ \
| RS6000_BTC_SPECIAL), \
CODE_FOR_ ## ICODE) /* ICODE */
/* Miscellaneous builtins for instructions added in ISA 3.0. These
instructions don't require either the DFP or VSX options, just the basic
ISA 3.0 enablement since they operate on general purpose registers. */
#define BU_P9_MISC_0(ENUM, NAME, ATTR, ICODE) \
RS6000_BUILTIN_0 (MISC_BUILTIN_ ## ENUM, /* ENUM */ \
"__builtin_" NAME, /* NAME */ \
RS6000_BTM_MODULO, /* MASK */ \
(RS6000_BTC_ ## ATTR /* ATTR */ \
| RS6000_BTC_SPECIAL), \
CODE_FOR_ ## ICODE) /* ICODE */
/* 128-bit long double floating point builtins. */ /* 128-bit long double floating point builtins. */
#define BU_LDBL128_2(ENUM, NAME, ATTR, ICODE) \ #define BU_LDBL128_2(ENUM, NAME, ATTR, ICODE) \
RS6000_BUILTIN_2 (MISC_BUILTIN_ ## ENUM, /* ENUM */ \ RS6000_BUILTIN_2 (MISC_BUILTIN_ ## ENUM, /* ENUM */ \
...@@ -1653,6 +1693,11 @@ BU_P8V_MISC_3 (BCDSUB_OV, "bcdsub_ov", CONST, bcdsub_unordered) ...@@ -1653,6 +1693,11 @@ BU_P8V_MISC_3 (BCDSUB_OV, "bcdsub_ov", CONST, bcdsub_unordered)
BU_DFP_MISC_2 (PACK_TD, "pack_dec128", CONST, packtd) BU_DFP_MISC_2 (PACK_TD, "pack_dec128", CONST, packtd)
BU_DFP_MISC_2 (UNPACK_TD, "unpack_dec128", CONST, unpacktd) BU_DFP_MISC_2 (UNPACK_TD, "unpack_dec128", CONST, unpacktd)
/* 0 argument general-purpose register functions added in ISA 3.0 (power9). */
BU_P9_MISC_0 (DARN_32, "darn_32", MISC, darn_32)
BU_P9_64BIT_MISC_0 (DARN_RAW, "darn_raw", MISC, darn_raw)
BU_P9_64BIT_MISC_0 (DARN, "darn", MISC, darn)
BU_LDBL128_2 (PACK_TF, "pack_longdouble", CONST, packtf) BU_LDBL128_2 (PACK_TF, "pack_longdouble", CONST, packtf)
BU_LDBL128_2 (UNPACK_TF, "unpack_longdouble", CONST, unpacktf) BU_LDBL128_2 (UNPACK_TF, "unpack_longdouble", CONST, unpacktf)
......
...@@ -648,6 +648,11 @@ extern int rs6000_vector_align[]; ...@@ -648,6 +648,11 @@ extern int rs6000_vector_align[];
#define MASK_PROTOTYPE OPTION_MASK_PROTOTYPE #define MASK_PROTOTYPE OPTION_MASK_PROTOTYPE
#endif #endif
#ifdef TARGET_MODULO
#define RS6000_BTM_MODULO OPTION_MASK_MODULO
#endif
/* For power systems, we want to enable Altivec and VSX builtins even if the /* For power systems, we want to enable Altivec and VSX builtins even if the
user did not use -maltivec or -mvsx to allow the builtins to be used inside user did not use -maltivec or -mvsx to allow the builtins to be used inside
of #pragma GCC target or the target attribute to change the code level for a of #pragma GCC target or the target attribute to change the code level for a
...@@ -2636,7 +2641,9 @@ extern int frame_pointer_needed; ...@@ -2636,7 +2641,9 @@ extern int frame_pointer_needed;
#define RS6000_BTC_MISC 0x00000000 /* No special attributes. */ #define RS6000_BTC_MISC 0x00000000 /* No special attributes. */
#define RS6000_BTC_CONST 0x00000100 /* uses no global state. */ #define RS6000_BTC_CONST 0x00000100 /* uses no global state. */
#define RS6000_BTC_PURE 0x00000200 /* reads global state/mem. */ #define RS6000_BTC_PURE 0x00000200 /* reads global
state/mem and does
not modify global state. */
#define RS6000_BTC_FP 0x00000400 /* depends on rounding mode. */ #define RS6000_BTC_FP 0x00000400 /* depends on rounding mode. */
#define RS6000_BTC_ATTR_MASK 0x00000700 /* Mask of the attributes. */ #define RS6000_BTC_ATTR_MASK 0x00000700 /* Mask of the attributes. */
...@@ -2672,6 +2679,7 @@ extern int frame_pointer_needed; ...@@ -2672,6 +2679,7 @@ extern int frame_pointer_needed;
#define RS6000_BTM_DFP MASK_DFP /* Decimal floating point. */ #define RS6000_BTM_DFP MASK_DFP /* Decimal floating point. */
#define RS6000_BTM_HARD_FLOAT MASK_SOFT_FLOAT /* Hardware floating point. */ #define RS6000_BTM_HARD_FLOAT MASK_SOFT_FLOAT /* Hardware floating point. */
#define RS6000_BTM_LDBL128 MASK_MULTIPLE /* 128-bit long double. */ #define RS6000_BTM_LDBL128 MASK_MULTIPLE /* 128-bit long double. */
#define RS6000_BTM_64BIT MASK_64BIT /* 64-bit addressing. */
#define RS6000_BTM_COMMON (RS6000_BTM_ALTIVEC \ #define RS6000_BTM_COMMON (RS6000_BTM_ALTIVEC \
| RS6000_BTM_VSX \ | RS6000_BTM_VSX \
...@@ -2691,6 +2699,7 @@ extern int frame_pointer_needed; ...@@ -2691,6 +2699,7 @@ extern int frame_pointer_needed;
/* Define builtin enum index. */ /* Define builtin enum index. */
#undef RS6000_BUILTIN_0
#undef RS6000_BUILTIN_1 #undef RS6000_BUILTIN_1
#undef RS6000_BUILTIN_2 #undef RS6000_BUILTIN_2
#undef RS6000_BUILTIN_3 #undef RS6000_BUILTIN_3
...@@ -2703,6 +2712,7 @@ extern int frame_pointer_needed; ...@@ -2703,6 +2712,7 @@ extern int frame_pointer_needed;
#undef RS6000_BUILTIN_S #undef RS6000_BUILTIN_S
#undef RS6000_BUILTIN_X #undef RS6000_BUILTIN_X
#define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
#define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) ENUM, #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
#define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) ENUM, #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
#define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) ENUM, #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
...@@ -2722,6 +2732,7 @@ enum rs6000_builtins ...@@ -2722,6 +2732,7 @@ enum rs6000_builtins
RS6000_BUILTIN_COUNT RS6000_BUILTIN_COUNT
}; };
#undef RS6000_BUILTIN_0
#undef RS6000_BUILTIN_1 #undef RS6000_BUILTIN_1
#undef RS6000_BUILTIN_2 #undef RS6000_BUILTIN_2
#undef RS6000_BUILTIN_3 #undef RS6000_BUILTIN_3
......
...@@ -14686,6 +14686,23 @@ The @code{__builtin_divde}, @code{__builtin_divdeo}, ...@@ -14686,6 +14686,23 @@ The @code{__builtin_divde}, @code{__builtin_divdeo},
64-bit environment support ISA 2.06 or later. 64-bit environment support ISA 2.06 or later.
The following built-in functions are available for the PowerPC family The following built-in functions are available for the PowerPC family
of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}
or @option{-mmodulo}):
@smallexample
long long __builtin_darn (void);
long long __builtin_darn_raw (void);
int __builtin_darn_32 (void);
@end smallexample
The @code{__builtin_darn} and @code{__builtin_darn_raw}
functions require a
64-bit environment supporting ISA 3.0 or later.
The @code{__builtin_darn} function provides a 64-bit conditioned
random number. The @code{__builtin_darn_raw} function provides a
64-bit raw random number. The @code{__builtin_darn_32} function
provides a 32-bit random number.
The following built-in functions are available for the PowerPC family
of processors when hardware decimal floating point of processors when hardware decimal floating point
(@option{-mhard-dfp}) is available: (@option{-mhard-dfp}) is available:
@smallexample @smallexample
......
2016-05-19 Kelvin Nilsen <kelvin@gcc.gnu.org>
* gcc.target/powerpc/darn-0.c: New test.
* gcc.target/powerpc/darn-1.c: New test.
* gcc.target/powerpc/darn-2.c: New test.
2016-05-19 Marek Polacek <polacek@redhat.com> 2016-05-19 Marek Polacek <polacek@redhat.com>
PR tree-optimization/71031 PR tree-optimization/71031
......
/* { dg-do compile { target { powerpc*-*-* } } } */
/* { dg-options "-mcpu=power9" } */
/* This test should succeed on both 32- and 64-bit configurations. */
#include <altivec.h>
int get_random ()
{
return __builtin_darn_32 ();
}
/* { dg-final { scan-assembler "darn" } } */
/* { dg-do compile { target { powerpc*-*-* } } } */
/* { dg-options "-mcpu=power9" } */
/* { dg-require-effective-target lp64 } */
#include <altivec.h>
long long get_conditioned_random ()
{
return __builtin_darn ();
}
/* { dg-final { scan-assembler "darn" } } */
/* { dg-do compile { target { powerpc*-*-* } } } */
/* { dg-options "-mcpu=power9" } */
/* { dg-require-effective-target lp64 } */
#include <altivec.h>
long long get_raw_random ()
{
return __builtin_darn_raw ();
}
/* { dg-final { scan-assembler "darn" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment