public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* pre-processor symbols and gcc -v
@ 2011-03-02 20:24 kevin diggs
  2011-03-02 20:54 ` Jonathan Wakely
  2011-03-02 21:15 ` Ian Lance Taylor
  0 siblings, 2 replies; 7+ messages in thread
From: kevin diggs @ 2011-03-02 20:24 UTC (permalink / raw)
  To: gcc-help

Hi,

If a pre-processor macro, say __m68k__ is defined shouldn't it show up
in gcc -v? gcc version is 3.4.6.

int main(int argc, char **argv)
{
void *handle;
double (*cosine)(double),arg,res;
char *error,*msg="cos(%f)=%.7f\n";

        handle = dlopen ("libm.so", RTLD_LAZY);
        if (!handle)
        {
                fputs (dlerror(), stderr);
                exit(1);
        }

        cosine = dlsym(handle, "cos");
        if ((error = dlerror()) != NULL)
        {
                fprintf (stderr, "%s\n", error);
                exit(1);
        }

        arg=2.0;
        res=(*cosine)(arg);
        printf(msg,arg,res);
        dlclose(handle);

        /*
         * 680x0 constraints are:
         *      a       address register
         *      d       data register
         *      f       floating point
         *      I       integer [1,8]
         *      J       16-bit signed integer
         *      K       signed number whose magnitude is > 0x80
         *      L       integer [-1,-8]
         *      M       signed number whose magnitude is > 0x100
         *      G       non 68881 rom float constant
         * '=' is used to indicate output, '&' means noclobber
         * Some floating point examples are:
         *      ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp))
         *      ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)")
         */
#ifdef __i386__
        __asm__ __volatile ("fldl (%%edi); fld %%st(0); fcos; "
                "leal -8(%%esp),%%esp; fstpl (%%esp); leal -8(%%esp),%%esp; "
                "fstpl (%%esp); pushl %%esi; call printf; leal 20(%%esp),%%esp"
                :
                :"D" (&arg), "S" (msg));
#elif defined(__m68k__)
#ifdef __HAVE_FPU__
#if defined(__mc68020__) || defined(__mc68030__)
        __asm__ __volatile ("fcos.x %1,%0"
                :"=f" (res)
                :"f" (arg));

        printf(msg,arg,res);
#elif defined(__mc68040__) || defined(__mc68060__)
        __asm__ __volatile ("fcos.x %1,%0"
                :"=f" (res)
                :"f" (arg));

        printf("Instruction implemented by trap:  ");
        printf(msg,arg,res);
#endif
#endif
#endif

#ifdef __m68k__
#error __m68k__ is defined!
#endif

        return 0;
}

Thanks!

kevin

P.S.:  Anyone point me to an example of how to use the 68k 'Q' constraint?

And while I'm here, anyway to see when an instruction causes an
unimplemented instruction trap (like fcos on a 68040)?

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

end of thread, other threads:[~2011-03-02 23:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02 20:24 pre-processor symbols and gcc -v kevin diggs
2011-03-02 20:54 ` Jonathan Wakely
2011-03-02 22:36   ` kevin diggs
2011-03-02 23:32     ` Ian Lance Taylor
2011-03-02 21:15 ` Ian Lance Taylor
2011-03-02 23:07   ` kevin diggs
2011-03-02 23:27     ` Ian Lance Taylor

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).