Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-27 Thread Gunther Nikl

Bernd Roesch schrieb:

without changed headers old ompiler and libs do not work, because for C
there is no
sqrtf and other C99 funcs and many C++ programs get also many errors.


Ok, you are trying to add C99 functions to your libc. Apparently you
made a mistake if you get linker errors.


i see old libstdc++ contain sqrtf but get many other linker errors.


What is an old libstdc++? AFAICT there was/is no sqrtf function in
libstdc++. In the sqrt case there are inline wrapper functions with
either a float or a double arg. These inlines use an appropriate sqrt
builtin. Since these builtins do not exist for your target the compiler
generates a call to the real function without the __builtin prefix.


there is also a sqrtf not undef in cmath as many other functions are.
When i define sqrtf in math.h then the sqrtf func in libstdc++ is maybe not
add and this strange linker error come.but wy it work not correct when i
add sqrtf to libc i dont know.only solution below work.


libstdc++ _requires_ real functions to be present in your libc. If you
get linker errors then the linker cannot locate functions. There really
is no need to play #define games on __builtin names to get it work.

Gunther


Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-22 Thread Gunther Nikl

Bernd Roesch wrote:

I see in my c++config.h file

this stand here

/* Define if the compiler/host combination has __builtin_sqrtf. */
/* #undef _GLIBCXX_HAVE___BUILTIN_SQRTF */ 


I find now a solution that work without change of cmath

when i add in math.h this line then it work.the function can too stand as
static inline in the math.h file.

#define __builtin_sqrtf sqrtf


How about using the original C-library of your system together with its
headers? After all the version you are currently using is an alien and
doesn't fit for your system despite the fact that it was based on your
systems C-library and its headers. Carefully merging changes back to the
original version would be the better solution.

Gunther


On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis dosr...@gmail.com
wrote:

On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch nospamn...@web.de wrote:

Hello Gabriel

[...]

You see there is the _ not in.normaly funcs that not find have a _
before

To get all work, it seem i need add the same function add in math.h and
in
the linker
lib or change cmath file and remove all __builtin_ commands the
architecture
not have.

I believe one should convince the middle end to emit libcall
for __builtin_xxx when the target has no builtint support.

It of course does.

Richard.

Regards







Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-22 Thread Bernd Roesch
Hallo Gunther

Am 22.03.09 schriebst Du

 How about using the original C-library of your system together with its
 headers? After all the version you are currently using is an alien and

without changed headers old ompiler and libs do not work, because for C
there is no
sqrtf and other C99 funcs and many C++ programs get also many errors.

i see old libstdc++ contain sqrtf but get many other linker errors.

there is also a sqrtf not undef in cmath as many other functions are.
When i define sqrtf in math.h then the sqrtf func in libstdc++ is maybe not
add and this strange linker error come.but wy it work not correct when i
add sqrtf to libc i dont know.only solution below work.

only this funcs are undef.

// Get rid of those macros defined in math.h in lieu of real functions.
#undef abs
#undef div
#undef acos
#undef asin
#undef atan
#undef atan2
#undef ceil
#undef cos
#undef cosh
#undef exp
#undef fabs
#undef floor
#undef fmod
#undef frexp
#undef ldexp
#undef log
#undef log10
#undef modf
#undef pow
#undef sin
#undef sinh
#undef sqrt
#undef tan
#undef tanh 

 Bernd Roesch wrote:
 I see in my c++config.h file
 
 this stand here
 
 /* Define if the compiler/host combination has __builtin_sqrtf. */
 /* #undef _GLIBCXX_HAVE___BUILTIN_SQRTF */ 
 
 I find now a solution that work without change of cmath
 
 when i add in math.h this line then it work.the function can too stand as
 static inline in the math.h file.
 
 #define __builtin_sqrtf sqrtf
 
 How about using the original C-library of your system together with its
 headers? After all the version you are currently using is an alien and
 doesn't fit for your system despite the fact that it was based on your
 systems C-library and its headers. Carefully merging changes back to the
 original version would be the better solution.
 
 Gunther
 
 On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis dosr...@gmail.com
 wrote:
 On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch nospamn...@web.de wrote:
 Hello Gabriel
 [...]
 You see there is the _ not in.normaly funcs that not find have a _
 before
 
 To get all work, it seem i need add the same function add in math.h
 and
 in
 the linker
 lib or change cmath file and remove all __builtin_ commands the
 architecture
 not have.
 I believe one should convince the middle end to emit libcall
 for __builtin_xxx when the target has no builtint support.
 It of course does.
 
 Richard.
 Regards
 
 
 
 
mfg Bernd



Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-10 Thread Bernd Roesch
Hello Richard

On 09.03.09, you wrote:

 I believe one should convince the middle end to emit libcall
 for __builtin_xxx when the target has no builtint support.
 
 It of course does.

On what codeplace is the redefine do in GCC source ?

I see in my c++config.h file

this stand here

/* Define if the compiler/host combination has __builtin_sqrtf. */
/* #undef _GLIBCXX_HAVE___BUILTIN_SQRTF */ 

I find now a solution that work without change of cmath

when i add in math.h this line then it work.the function can too stand as
static inline in the math.h file.

#define __builtin_sqrtf sqrtf

 On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis dosr...@gmail.com
 wrote:
 On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch nospamn...@web.de wrote:
 Hello Gabriel
 [...]
 
 You see there is the _ not in.normaly funcs that not find have a _
 before
 
 To get all work, it seem i need add the same function add in math.h and
 in
 the linker
 lib or change cmath file and remove all __builtin_ commands the
 architecture
 not have.
 
 I believe one should convince the middle end to emit libcall
 for __builtin_xxx when the target has no builtint support.
 
 It of course does.
 
 Richard.
Regards



Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-10 Thread Ian Lance Taylor
Bernd Roesch nospamn...@web.de writes:

 Hello Richard

 On 09.03.09, you wrote:

 I believe one should convince the middle end to emit libcall
 for __builtin_xxx when the target has no builtint support.
 
 It of course does.

 On what codeplace is the redefine do in GCC source ?

This is in optabs.c, as set up by gen_libfunc and friends.  A call to
__builtin_xxx, where xxx is a library function, is normally replaced by
a call to xxx.  Where xxx is not a library function, gcc normally
provides the function in libgcc.

Ian


cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-09 Thread Bernd Roesch
Hello Richard

On 06.03.09, you wrote:

ah thanks for info, i understand now too wy sqrtf, fmod (work in C programs)
get linker error on C++ programs but sqrt and some other work on platform
68k.
in c++/4.3.2/cmath include 

is this code.

using ::sqrt;

  inline float
  sqrt(float __x)
  { return __builtin_sqrtf(__x); }
 
But .md file of many architetures contain no entry for this.I see only i386,
rs6000, ia64, sh contain code for this.(I search for sqrtf and list files
that contain this) 
the header files are build during GCC build, i change nothing.

Is there something wrong during compiler Build process ?

 
 How can i then implement lrint func without asm Code ?
 
 If the backend does not support inlining lrint then you need to link
 against a C99 math library (-lm).  You can add lrintsrcmodedestmode
 patterns to m68k.md to provide inline expansions.
 
 Richard.
 
 please help
 
 
Regards



Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-09 Thread Bernd Roesch
Hello Gabriel

On 09.03.09, you wrote:

 The above sqrt() function is distinct from the C version, because
 it has a C++ linkage.  Consequently, I would expect that if
 __builtin_sqrtf() is not available, the compiler would emit a
 library call to the out-of-line C version.

But it dont work.

I have define in math.h this func.see my below
example source that show important parts.look a little ugly, but this is
done to avoid in -o3 the remove of some function calls.
real problem i see in libdirac

inline float sqrtf(float x)
{
 return sqrt(x);
}

...

int main(int argc, char** argv)
{

printf(%f\n,sqrtf((float)argc));// work
printf(%f\n,std::sqrt(static_castfloat(argc)));  // work not
printf(%f\n,std::sqrt(static_castdouble(argc))); // work

..

when i change c++/4.3.2/cmath to this code, then all work 


using ::sqrt;

  inline float
  sqrt(float __x)
-  { return __builtin_sqrtf(__x); }
+  { return sqrtf(__x); } 

.

now you can come to the idea and add it as link func, maybe then it work.

But then i get error at that line, but other lines work.

printf(%f\n,sqrtf((float)argc)); 

undefined reference to `sqrtf(float)'

You see there is the _ not in.normaly funcs that not find have a _ before

To get all work, it seem i need add the same function add in math.h and in
the linker
lib or change cmath file and remove all __builtin_ commands the architecture
not have.

 On Mon, Mar 9, 2009 at 2:42 AM, Bernd Roesch nospamn...@web.de wrote:
 Hello Richard
 
 On 06.03.09, you wrote:
 
 ah thanks for info, i understand now too wy sqrtf, fmod (work in C
 programs)
 get linker error on C++ programs but sqrt and some other work on
 platform
 68k.
 in c++/4.3.2/cmath include
 
 is this code.
 
 using ::sqrt;
 
  inline float
  sqrt(float __x)
  { return __builtin_sqrtf(__x); }
 
 But .md file of many architetures contain no entry for this.I see only
 i386,
 rs6000, ia64, sh contain code for this.(I search for sqrtf and list
 files
 that contain this)
 the header files are build during GCC build, i change nothing.
 
 Is there something wrong during compiler Build process ?
 
 The above sqrt() function is distinct from the C version, because
 it has a C++ linkage.  Consequently, I would expect that if
 __builtin_sqrtf() is not available, the compiler would emit a
 library call to the out-of-line C version.
 
 -- Gaby
Regards



Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-09 Thread Gabriel Dos Reis
On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch nospamn...@web.de wrote:
 Hello Gabriel
[...]

 You see there is the _ not in.normaly funcs that not find have a _ before

 To get all work, it seem i need add the same function add in math.h and in
 the linker
 lib or change cmath file and remove all __builtin_ commands the architecture
 not have.

I believe one should convince the middle end to emit libcall
for __builtin_xxx when the target has no builtint support.

-- Gaby


Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-09 Thread Richard Guenther
On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis dosr...@gmail.com wrote:
 On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch nospamn...@web.de wrote:
 Hello Gabriel
 [...]

 You see there is the _ not in.normaly funcs that not find have a _ before

 To get all work, it seem i need add the same function add in math.h and in
 the linker
 lib or change cmath file and remove all __builtin_ commands the architecture
 not have.

 I believe one should convince the middle end to emit libcall
 for __builtin_xxx when the target has no builtint support.

It of course does.

Richard.


Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )

2009-03-09 Thread Gabriel Dos Reis
On Mon, Mar 9, 2009 at 9:03 AM, Richard Guenther
richard.guent...@gmail.com wrote:

 I believe one should convince the middle end to emit libcall
 for __builtin_xxx when the target has no builtint support.

 It of course does.

Then, Bernd's report appears to be a mystery.

-- Gaby


lrint lrintf problems

2009-03-06 Thread Bernd Roesch
Hi, 

I see in compiler source there is in builtin.c lrint lrintf.so the gcc need
no extern linker lib when i understand right. 

But get linker error when use them.I test compiler 3.4.0 4.3.2 and 4.4.0

I also link with libgcc.but does not help

also my includes-fixed/math.h

contain a declaration but it is long int.
extern long int lrint _PARAMS((double)); 

This mean 64 bit int ?

But i use 32 bit 68k compiler and as far i see lrint return a long in docu.

only solution i find short is add in library.

 long lrintf(float x)
{
  return (long)x;
}

But when do this code, then there should be used current rounding.68k for
example support a simple fmove.l fp0,d0 and use current rounding to convert
from float.

But gcc (test with 4.3.2)output this code in -m68020 -m68881 -03.

FMOVE.S #+1.2344999E+4,FP0 
FADD.L  D4,FP0 
FINTRZ.X FP0   
FMOVE.L FP0,-(A7)  

But i think there is no fintrz need and this code do the same job and use
the correct rounding setting.

FMOVE.S #+1.2344999E+4,FP0 
FADD.L  D4,FP0 
FMOVE.L FP0,-(A7)  

Or i am wrong ?.Or is return (long)x; specified to always round to zero ?

How can i then implement lrint func without asm Code ? 

please help



Re: lrint lrintf problems

2009-03-06 Thread Richard Guenther
On Fri, Mar 6, 2009 at 12:27 PM, Bernd Roesch nospamn...@web.de wrote:
 Hi,

 I see in compiler source there is in builtin.c lrint lrintf.so the gcc need
 no extern linker lib when i understand right.

 But get linker error when use them.I test compiler 3.4.0 4.3.2 and 4.4.0

 I also link with libgcc.but does not help

 also my includes-fixed/math.h

 contain a declaration but it is long int.
 extern long int lrint _PARAMS((double));

 This mean 64 bit int ?

 But i use 32 bit 68k compiler and as far i see lrint return a long in docu.

 only solution i find short is add in library.

  long lrintf(float x)
 {
  return (long)x;
 }

 But when do this code, then there should be used current rounding.68k for
 example support a simple fmove.l fp0,d0 and use current rounding to convert
 from float.

 But gcc (test with 4.3.2)output this code in -m68020 -m68881 -03.

 FMOVE.S #+1.2344999E+4,FP0
 FADD.L  D4,FP0
 FINTRZ.X FP0
 FMOVE.L FP0,-(A7)

 But i think there is no fintrz need and this code do the same job and use
 the correct rounding setting.

 FMOVE.S #+1.2344999E+4,FP0
 FADD.L  D4,FP0
 FMOVE.L FP0,-(A7)

 Or i am wrong ?.Or is return (long)x; specified to always round to zero ?

 How can i then implement lrint func without asm Code ?

If the backend does not support inlining lrint then you need to link
against a C99 math library (-lm).  You can add lrintsrcmodedestmode
patterns to m68k.md to provide inline expansions.

Richard.

 please help