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]

[PATCH 2/3] S/390: Implement two new builtins for efpc and sfpc


Hi,

this patch defines two new S/390 target specific macros:
__builtin_s390_efpc
__builtin_s390_sfpc

for extracting and setting the floating point control register.

I'll commit this to mainline after waiting a few days for comments.

Bye,

-Andreas-


2015-02-24  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* config/s390/s390.c (enum s390_builtin):
	Add S390_BUILTIN_S390_SFPC and S390_BUILTIN_S390_EFPC.
	(code_for_builtin): Add CODE_FOR_s390_sfpc and CODE_FOR_s390_efpc.
	(s390_init_builtins): Generate new builtin functions.
	* config/s390/s390.md (UNSPECV_SFPC, UNSPECV_EFPC): New constants.
	(s390_sfpc, s390_efpc): New pattern definitions.

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index a4fb4c7..f4709da 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -9982,6 +9982,9 @@ enum s390_builtin
   S390_BUILTIN_TX_NESTING_DEPTH,
   S390_BUILTIN_TX_ASSIST,
 
+  S390_BUILTIN_S390_SFPC,
+  S390_BUILTIN_S390_EFPC,
+
   S390_BUILTIN_MAX
 };
 
@@ -9997,7 +10000,10 @@ static enum insn_code const code_for_builtin[S390_BUILTIN_MAX] = {
   CODE_FOR_tabort,
   CODE_FOR_ntstg,
   CODE_FOR_etnd,
-  CODE_FOR_tx_assist
+  CODE_FOR_tx_assist,
+
+  CODE_FOR_s390_sfpc,
+  CODE_FOR_s390_efpc
 };
 
 static void
@@ -10025,6 +10031,12 @@ s390_init_builtins (void)
     add_builtin_function ("__builtin_tx_assist", ftype,
 			  S390_BUILTIN_TX_ASSIST, BUILT_IN_MD, NULL, NULL_TREE);
 
+  /* void foo (unsigned) */
+  ftype = build_function_type_list (void_type_node, unsigned_type_node,
+				    NULL_TREE);
+  s390_builtin_decls[S390_BUILTIN_S390_SFPC] =
+    add_builtin_function ("__builtin_s390_sfpc", ftype,
+			  S390_BUILTIN_S390_SFPC, BUILT_IN_MD, NULL, NULL_TREE);
 
   /* int foo (void *) */
   ftype = build_function_type_list (integer_type_node, ptr_type_node,
@@ -10061,6 +10073,11 @@ s390_init_builtins (void)
     add_builtin_function ("__builtin_tend", ftype,
 			  S390_BUILTIN_TEND, BUILT_IN_MD, NULL, NULL_TREE);
 
+  /* unsigned foo (void) */
+  ftype = build_function_type_list (unsigned_type_node, NULL_TREE);
+  s390_builtin_decls[S390_BUILTIN_S390_EFPC] =
+    add_builtin_function ("__builtin_s390_efpc", ftype,
+			  S390_BUILTIN_S390_EFPC, BUILT_IN_MD, NULL, NULL_TREE);
 
   /* void foo (uint64_t *, uint64_t) */
   if (TARGET_64BIT)
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index f5ba132..bf698b1 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -162,6 +162,10 @@
    UNSPECV_ETND
    UNSPECV_NTSTG
    UNSPECV_PPA
+
+   ; Set and get floating point control register
+   UNSPECV_SFPC
+   UNSPECV_EFPC
   ])
 
 ;;
@@ -10300,3 +10304,18 @@
   "TARGET_HTM && INTVAL (operands[2]) < 16"
   "ppa\t%0,%1,%2"
   [(set_attr "op_type" "RRF")])
+
+
+; Set and get floating point control register
+
+(define_insn "s390_sfpc"
+  [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")]
+		    UNSPECV_SFPC)]
+  "TARGET_HARD_FLOAT"
+  "sfpc\t%0")
+
+(define_insn "s390_efpc"
+  [(set (match_operand:SI 0 "register_operand" "=d")
+	(unspec_volatile:SI [(const_int 0)] UNSPECV_EFPC))]
+  "TARGET_HARD_FLOAT"
+  "efpc\t%0")
-- 
1.9.3


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