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]

Patch for llabs builtin


C99 adds the llabs() function by analogy with abs() and labs().  This
patch adds a builtin llabs() function to GCC; GCC already knows how to
generate code for it once converted to an ABS_EXPR.

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit?

2000-09-23  Joseph S. Myers  <jsm28@cam.ac.uk>

	* builtins.def (BUILT_IN_LLABS): Add.
	* builtins.c (expand_builtin): Also abort on BUILT_IN_LLABS.
	* c-common.c (c_common_nodes_builtins): Create builtin functions
	__builtin_llabs, and plain llabs unless no_nonansi_builtins
	outside of C99 mode.
	(expand_tree_builtin): Handle BUILT_IN_LLABS.

--- builtins.c.orig	Thu Sep 21 06:56:27 2000
+++ builtins.c	Sat Sep 23 14:11:08 2000
@@ -2595,6 +2595,7 @@ expand_builtin (exp, target, subtarget, 
     {
     case BUILT_IN_ABS:
     case BUILT_IN_LABS:
+    case BUILT_IN_LLABS:
     case BUILT_IN_FABS:
       /* build_function_call changes these into ABS_EXPR.  */
       abort ();
--- builtins.def.orig	Thu Sep 21 06:56:27 2000
+++ builtins.def	Sat Sep 23 14:10:56 2000
@@ -23,6 +23,7 @@
 DEF_BUILTIN(BUILT_IN_ABS)
 DEF_BUILTIN(BUILT_IN_FABS)
 DEF_BUILTIN(BUILT_IN_LABS)
+DEF_BUILTIN(BUILT_IN_LLABS)
 DEF_BUILTIN(BUILT_IN_FFS)
 DEF_BUILTIN(BUILT_IN_DIV)
 DEF_BUILTIN(BUILT_IN_LDIV)
--- c-common.c.orig	Sat Sep 23 10:24:40 2000
+++ c-common.c	Sat Sep 23 14:19:45 2000
@@ -4020,6 +4020,7 @@ c_common_nodes_and_builtins (cplus_mode,
   tree int_ftype_cptr_cptr_sizet;
   tree int_ftype_string_string, string_ftype_ptr_ptr;
   tree long_ftype_long;
+  tree longlong_ftype_longlong;
   /* Either char* or void*.  */
   tree traditional_ptr_type_node;
   /* Either const char* or const void*.  */
@@ -4094,6 +4095,11 @@ c_common_nodes_and_builtins (cplus_mode,
 			   tree_cons (NULL_TREE, long_integer_type_node,
 				      endlink));
 
+  longlong_ftype_longlong
+    = build_function_type (long_long_integer_type_node,
+			   tree_cons (NULL_TREE, long_long_integer_type_node,
+				      endlink));
+
   int_ftype_cptr_cptr_sizet
     = build_function_type (integer_type_node,
 			   tree_cons (NULL_TREE, const_ptr_type_node,
@@ -4234,6 +4240,8 @@ c_common_nodes_and_builtins (cplus_mode,
 		    BUILT_IN_NORMAL, NULL_PTR);
   builtin_function ("__builtin_labs", long_ftype_long, BUILT_IN_LABS,
 		    BUILT_IN_NORMAL, NULL_PTR);
+  builtin_function ("__builtin_llabs", longlong_ftype_longlong, BUILT_IN_LLABS,
+		    BUILT_IN_NORMAL, NULL_PTR);
   builtin_function ("__builtin_saveregs", ptr_ftype, BUILT_IN_SAVEREGS,
 		    BUILT_IN_NORMAL, NULL_PTR);
   builtin_function ("__builtin_classify_type", default_function_type,
@@ -4400,6 +4408,9 @@ c_common_nodes_and_builtins (cplus_mode,
 			BUILT_IN_NORMAL, NULL_PTR);
       builtin_function ("labs", long_ftype_long, BUILT_IN_LABS,
 			BUILT_IN_NORMAL, NULL_PTR);
+      if (flag_isoc99 || ! no_nonansi_builtins)
+	builtin_function ("llabs", longlong_ftype_longlong, BUILT_IN_LLABS,
+			  BUILT_IN_NORMAL, NULL_PTR);
       builtin_function ("memcpy", memcpy_ftype, BUILT_IN_MEMCPY,
 			BUILT_IN_NORMAL, NULL_PTR);
       builtin_function ("memcmp", int_ftype_cptr_cptr_sizet, BUILT_IN_MEMCMP,
@@ -4578,6 +4589,7 @@ expand_tree_builtin (function, params, c
     {
     case BUILT_IN_ABS:
     case BUILT_IN_LABS:
+    case BUILT_IN_LLABS:
     case BUILT_IN_FABS:
       if (coerced_params == 0)
 	return integer_zero_node;

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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