public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44037]  New: builtin ffs vs. renamed ffs (vms-crtl.h)‏
@ 2010-05-08  6:22 jay dot krell at cornell dot edu
  2010-05-10 22:53 ` [Bug c/44037] " jay dot krell at cornell dot edu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jay dot krell at cornell dot edu @ 2010-05-08  6:22 UTC (permalink / raw)
  To: gcc-bugs

In gcc for VMS there is some mechanism to rename functions.
See the files:

/src/gcc-4.5.0/gcc/config/vms/vms-crtl-64.h
/src/gcc-4.5.0/gcc/config/vms/vms-crtl.h


which are mostly just lists of function from/to.


As well in gcc there is a mechanism for optimizing various "builtin" functions,
like ffs.


These two mechanisms seem to conflict or be applied in the wrong order.
I didn't look at it deeply.


The symptom is that if you add ffs (to decc$ffs) to vms-crtl.h, the translation
is not done, and you end up with unresolved external ffs.


If you #if out the support for "builtin ffs", it works.


My local hack is below but obviously that's not the way.


I'll enter a bug.


Thanks,
 - Jay


diff -u /src/orig/gcc-4.5.0/gcc/builtins.c ./builtins.c
--- /src/orig/gcc-4.5.0/gcc/builtins.c    2010-04-13 06:47:11.000000000 -0700
+++ ./builtins.c    2010-05-07 23:11:30.000000000 -0700
@@ -51,6 +51,8 @@
 #include "value-prof.h"
 #include "diagnostic.h"

+#define DISABLE_FFS
+
 #ifndef SLOW_UNALIGNED_ACCESS
 #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT
 #endif
@@ -5899,6 +5901,7 @@
     return target;
       break;

+#ifndef DISABLE_FFS
     CASE_INT_FN (BUILT_IN_FFS):
     case BUILT_IN_FFSIMAX:
       target = expand_builtin_unop (target_mode, exp, target,
@@ -5906,6 +5909,7 @@
       if (target)
     return target;
       break;
+#endif

     CASE_INT_FN (BUILT_IN_CLZ):
     case BUILT_IN_CLZIMAX:
@@ -13612,6 +13616,7 @@
     case BUILT_IN_ABORT:
       abort_libfunc = set_user_assembler_libfunc ("abort", asmspec);
       break;
+#ifndef DISABLE_FFS
     case BUILT_IN_FFS:
       if (INT_TYPE_SIZE < BITS_PER_WORD)
     {
@@ -13620,6 +13625,7 @@
                                MODE_INT, 0), "ffs");
     }
       break;
+#endif
     default:
       break;
     }
diff -u /src/orig/gcc-4.5.0/gcc/optabs.c ./optabs.c
--- /src/orig/gcc-4.5.0/gcc/optabs.c    2010-03-19 12:45:01.000000000 -0700
+++ ./optabs.c    2010-05-07 23:11:36.000000000 -0700
@@ -45,6 +45,8 @@
 #include "basic-block.h"
 #include "target.h"

+#define DISABLE_FFS
+
 /* Each optab contains info on how this target machine
    can perform a particular operation
    for all sizes and kinds of operands.
@@ -3240,6 +3242,7 @@
     return temp;
     }

+#ifndef DISABLE_FFS
   /* Try implementing ffs (x) in terms of clz (x).  */
   if (unoptab == ffs_optab)
     {
@@ -3247,6 +3250,7 @@
       if (temp)
     return temp;
     }
+#endif

   /* Try implementing ctz (x) in terms of clz (x).  */
   if (unoptab == ctz_optab)
@@ -3268,7 +3272,11 @@

       /* All of these functions return small values.  Thus we choose to
      have them return something that isn't a double-word.  */
-      if (unoptab == ffs_optab || unoptab == clz_optab || unoptab == ctz_optab
+      if (
+#ifndef DISABLE_FFS
+      unoptab == ffs_optab ||
+#endif
+        unoptab == clz_optab || unoptab == ctz_optab
       || unoptab == popcount_optab || unoptab == parity_optab)
     outmode
       = GET_MODE (hard_libcall_value (TYPE_MODE (integer_type_node),
@@ -6301,7 +6309,9 @@
   init_optab (addcc_optab, UNKNOWN);
   init_optab (one_cmpl_optab, NOT);
   init_optab (bswap_optab, BSWAP);
+#ifndef DISABLE_FFS
   init_optab (ffs_optab, FFS);
+#endif
   init_optab (clz_optab, CLZ);
   init_optab (ctz_optab, CTZ);
   init_optab (popcount_optab, POPCOUNT);
@@ -6558,9 +6568,11 @@
   one_cmpl_optab->libcall_basename = "one_cmpl";
   one_cmpl_optab->libcall_suffix = '2';
   one_cmpl_optab->libcall_gen = gen_int_libfunc;
+#ifndef DISABLE_FFS
   ffs_optab->libcall_basename = "ffs";
   ffs_optab->libcall_suffix = '2';
   ffs_optab->libcall_gen = gen_int_libfunc;
+#endif
   clz_optab->libcall_basename = "clz";
   clz_optab->libcall_suffix = '2';
   clz_optab->libcall_gen = gen_int_libfunc;
@@ -6643,11 +6655,13 @@
   satfractuns_optab->libcall_basename = "satfractuns";
   satfractuns_optab->libcall_gen = gen_satfractuns_conv_libfunc;

+#ifndef DISABLE_FFS
   /* The ffs function operates on `int'.  Fall back on it if we do not
      have a libgcc2 function for that width.  */
   if (INT_TYPE_SIZE < BITS_PER_WORD)
     set_optab_libfunc (ffs_optab, mode_for_size (INT_TYPE_SIZE, MODE_INT, 0),
                "ffs");
+#endif

   /* Explicitly initialize the bswap libfuncs since we need them to be
      valid for things other than word_mode.  */


Thanks,
 - Jay


-- 
           Summary: builtin ffs vs. renamed ffs (vms-crtl.h)&#8207;
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jay dot krell at cornell dot edu
GCC target triplet: alpha-dec-vms


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44037


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/44037] builtin ffs vs. renamed ffs (vms-crtl.h)&#8207;
  2010-05-08  6:22 [Bug c/44037] New: builtin ffs vs. renamed ffs (vms-crtl.h)&#8207; jay dot krell at cornell dot edu
@ 2010-05-10 22:53 ` jay dot krell at cornell dot edu
  2010-05-22 12:16 ` [Bug target/44037] " jay dot krell at cornell dot edu
  2010-05-26  4:56 ` jay dot krell at cornell dot edu
  2 siblings, 0 replies; 4+ messages in thread
From: jay dot krell at cornell dot edu @ 2010-05-10 22:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jay dot krell at cornell dot edu  2010-05-10 22:53 -------
adding Andrew and his mail to bug:

For builtins you should look at how PowerPC Darwin handles the long double
builtins since they are renamed if long double is 128bit.

Thanks,
Andrew Pinski


-- 

jay dot krell at cornell dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44037


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/44037] builtin ffs vs. renamed ffs (vms-crtl.h)&#8207;
  2010-05-08  6:22 [Bug c/44037] New: builtin ffs vs. renamed ffs (vms-crtl.h)&#8207; jay dot krell at cornell dot edu
  2010-05-10 22:53 ` [Bug c/44037] " jay dot krell at cornell dot edu
@ 2010-05-22 12:16 ` jay dot krell at cornell dot edu
  2010-05-26  4:56 ` jay dot krell at cornell dot edu
  2 siblings, 0 replies; 4+ messages in thread
From: jay dot krell at cornell dot edu @ 2010-05-22 12:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jay dot krell at cornell dot edu  2010-05-22 12:16 -------
Thanks, good pointer. I found what you mean based on your recommendation. I
tried many things like it then. Nothing worked. I don't know why.


Notice that there is __builtin_foo and foo.
Darwin appears to only rename __builtin_foo.
I need to rename foo.
I didn't figure out what the "implicit" builtins are, but I don't think
figuring that out would help me.


This is a little bit lame but worked:

jbook2:gcc jay$ diff -u /src/orig/gcc-4.5.0/gcc/c-common.c c-common.c
--- /src/orig/gcc-4.5.0/gcc/c-common.c  2010-04-02 12:54:46.000000000 -0700
+++ c-common.c  2010-05-22 04:59:55.000000000 -0700
@@ -5181,6 +5181,7 @@
 {
   tree decl;
   const char *libname;
+  const char *libname2;

   if (fntype == error_mark_node)
     return;
@@ -5190,11 +5191,16 @@
                           strlen ("__builtin_")));

   libname = name + strlen ("__builtin_");
+  libname2 = libname;
+  if (TARGET_ABI_OPEN_VMS && strcmp(libname, "ffs") == 0)
+    libname = "decc$ffs";
+
   decl = add_builtin_function (name, fntype, fncode, fnclass,
                               (fallback_p ? libname : NULL),
                               fnattrs);
   if (both_p
       && !flag_no_builtin && !builtin_function_disabled_p (libname)
+      && !builtin_function_disabled_p (libname2)
       && !(nonansi_p && flag_no_nonansi_builtin))
     add_builtin_function (libname, libtype, fncode, fnclass,
                          NULL, fnattrs);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44037


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/44037] builtin ffs vs. renamed ffs (vms-crtl.h)&#8207;
  2010-05-08  6:22 [Bug c/44037] New: builtin ffs vs. renamed ffs (vms-crtl.h)&#8207; jay dot krell at cornell dot edu
  2010-05-10 22:53 ` [Bug c/44037] " jay dot krell at cornell dot edu
  2010-05-22 12:16 ` [Bug target/44037] " jay dot krell at cornell dot edu
@ 2010-05-26  4:56 ` jay dot krell at cornell dot edu
  2 siblings, 0 replies; 4+ messages in thread
From: jay dot krell at cornell dot edu @ 2010-05-26  4:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jay dot krell at cornell dot edu  2010-05-26 04:56 -------
Also this needed at top after #includes:
+#ifndef TARGET_ABI_OPEN_VMS
+#define TARGET_ABI_OPEN_VMS 0
+#endif


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44037


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-26  4:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-08  6:22 [Bug c/44037] New: builtin ffs vs. renamed ffs (vms-crtl.h)&#8207; jay dot krell at cornell dot edu
2010-05-10 22:53 ` [Bug c/44037] " jay dot krell at cornell dot edu
2010-05-22 12:16 ` [Bug target/44037] " jay dot krell at cornell dot edu
2010-05-26  4:56 ` jay dot krell at cornell dot edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).