OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc2/] [gcc/] [config/] [rs6000/] [driver-rs6000.c] - Diff between revs 282 and 384

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 282 Rev 384
/* Subroutines for the gcc driver.
/* Subroutines for the gcc driver.
   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
the Free Software Foundation; either version 3, or (at your option)
any later version.
any later version.
 
 
GCC is distributed in the hope that it will be useful,
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
#include <stdlib.h>
#include <stdlib.h>
 
 
#ifdef _AIX
#ifdef _AIX
# include <sys/systemcfg.h>
# include <sys/systemcfg.h>
#endif
#endif
 
 
#ifdef __linux__
#ifdef __linux__
# include <link.h>
# include <link.h>
#endif
#endif
 
 
#if defined (__APPLE__) || (__FreeBSD__)
#if defined (__APPLE__) || (__FreeBSD__)
# include <sys/types.h>
# include <sys/types.h>
# include <sys/sysctl.h>
# include <sys/sysctl.h>
#endif
#endif
 
 
const char *host_detect_local_cpu (int argc, const char **argv);
const char *host_detect_local_cpu (int argc, const char **argv);
 
 
#if GCC_VERSION >= 0
#if GCC_VERSION >= 0
 
 
/* Returns parameters that describe L1_ASSOC associative cache of size
/* Returns parameters that describe L1_ASSOC associative cache of size
   L1_SIZEKB with lines of size L1_LINE, and L2_SIZEKB.  */
   L1_SIZEKB with lines of size L1_LINE, and L2_SIZEKB.  */
 
 
static char *
static char *
describe_cache (unsigned l1_sizekb, unsigned l1_line,
describe_cache (unsigned l1_sizekb, unsigned l1_line,
                unsigned l1_assoc ATTRIBUTE_UNUSED, unsigned l2_sizekb)
                unsigned l1_assoc ATTRIBUTE_UNUSED, unsigned l2_sizekb)
{
{
  char l1size[1000], line[1000], l2size[1000];
  char l1size[1000], line[1000], l2size[1000];
 
 
  /* At the moment, gcc middle-end does not use the information about the
  /* At the moment, gcc middle-end does not use the information about the
     associativity of the cache.  */
     associativity of the cache.  */
 
 
  sprintf (l1size, "--param l1-cache-size=%u", l1_sizekb);
  sprintf (l1size, "--param l1-cache-size=%u", l1_sizekb);
  sprintf (line, "--param l1-cache-line-size=%u", l1_line);
  sprintf (line, "--param l1-cache-line-size=%u", l1_line);
  sprintf (l2size, "--param l2-cache-size=%u", l2_sizekb);
  sprintf (l2size, "--param l2-cache-size=%u", l2_sizekb);
 
 
  return concat (l1size, " ", line, " ", l2size, " ", NULL);
  return concat (l1size, " ", line, " ", l2size, " ", NULL);
}
}
 
 
#ifdef __APPLE__
#ifdef __APPLE__
 
 
/* Returns the description of caches on Darwin.  */
/* Returns the description of caches on Darwin.  */
 
 
static char *
static char *
detect_caches_darwin (void)
detect_caches_darwin (void)
{
{
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
  size_t len = 4;
  size_t len = 4;
  static int l1_size_name[2] = { CTL_HW, HW_L1DCACHESIZE };
  static int l1_size_name[2] = { CTL_HW, HW_L1DCACHESIZE };
  static int l1_line_name[2] = { CTL_HW, HW_CACHELINE };
  static int l1_line_name[2] = { CTL_HW, HW_CACHELINE };
  static int l2_size_name[2] = { CTL_HW, HW_L2CACHESIZE };
  static int l2_size_name[2] = { CTL_HW, HW_L2CACHESIZE };
 
 
  sysctl (l1_size_name, 2, &l1_sizekb, &len, NULL, 0);
  sysctl (l1_size_name, 2, &l1_sizekb, &len, NULL, 0);
  sysctl (l1_line_name, 2, &l1_line, &len, NULL, 0);
  sysctl (l1_line_name, 2, &l1_line, &len, NULL, 0);
  sysctl (l2_size_name, 2, &l2_sizekb, &len, NULL, 0);
  sysctl (l2_size_name, 2, &l2_sizekb, &len, NULL, 0);
  l1_assoc = 0;
  l1_assoc = 0;
 
 
  return describe_cache (l1_sizekb / 1024, l1_line, l1_assoc,
  return describe_cache (l1_sizekb / 1024, l1_line, l1_assoc,
                         l2_sizekb / 1024);
                         l2_sizekb / 1024);
}
}
 
 
static const char *
static const char *
detect_processor_darwin (void)
detect_processor_darwin (void)
{
{
  unsigned int proc;
  unsigned int proc;
  size_t len = 4;
  size_t len = 4;
 
 
  sysctlbyname ("hw.cpusubtype", &proc, &len, NULL, 0);
  sysctlbyname ("hw.cpusubtype", &proc, &len, NULL, 0);
 
 
  if (len > 0)
  if (len > 0)
    switch (proc)
    switch (proc)
      {
      {
      case 1:
      case 1:
        return "601";
        return "601";
      case 2:
      case 2:
        return "602";
        return "602";
      case 3:
      case 3:
        return "603";
        return "603";
      case 4:
      case 4:
      case 5:
      case 5:
        return "603e";
        return "603e";
      case 6:
      case 6:
        return "604";
        return "604";
      case 7:
      case 7:
        return "604e";
        return "604e";
      case 8:
      case 8:
        return "620";
        return "620";
      case 9:
      case 9:
        return "750";
        return "750";
      case 10:
      case 10:
        return "7400";
        return "7400";
      case 11:
      case 11:
        return "7450";
        return "7450";
      case 100:
      case 100:
        return "970";
        return "970";
      default:
      default:
        return "powerpc";
        return "powerpc";
      }
      }
 
 
  return "powerpc";
  return "powerpc";
}
}
 
 
#endif /* __APPLE__ */
#endif /* __APPLE__ */
 
 
#ifdef __FreeBSD__
#ifdef __FreeBSD__
 
 
/* Returns the description of caches on FreeBSD PPC.  */
/* Returns the description of caches on FreeBSD PPC.  */
 
 
static char *
static char *
detect_caches_freebsd (void)
detect_caches_freebsd (void)
{
{
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
  size_t len = 4;
  size_t len = 4;
 
 
  /* Currently, as of FreeBSD-7.0, there is only the cacheline_size
  /* Currently, as of FreeBSD-7.0, there is only the cacheline_size
     available via sysctl.  */
     available via sysctl.  */
  sysctlbyname ("machdep.cacheline_size", &l1_line, &len, NULL, 0);
  sysctlbyname ("machdep.cacheline_size", &l1_line, &len, NULL, 0);
 
 
  l1_sizekb = 32;
  l1_sizekb = 32;
  l1_assoc = 0;
  l1_assoc = 0;
  l2_sizekb = 512;
  l2_sizekb = 512;
 
 
  return describe_cache (l1_sizekb, l1_line, l1_assoc, l2_sizekb);
  return describe_cache (l1_sizekb, l1_line, l1_assoc, l2_sizekb);
}
}
 
 
/* Currently returns default powerpc.  */
/* Currently returns default powerpc.  */
static const char *
static const char *
detect_processor_freebsd (void)
detect_processor_freebsd (void)
{
{
  return "powerpc";
  return "powerpc";
}
}
 
 
#endif /* __FreeBSD__  */
#endif /* __FreeBSD__  */
 
 
#ifdef __linux__
#ifdef __linux__
 
 
/* Returns AT_PLATFORM if present, otherwise generic PowerPC.  */
/* Returns AT_PLATFORM if present, otherwise generic PowerPC.  */
 
 
static const char *
static const char *
elf_platform (void)
elf_platform (void)
{
{
  int fd;
  int fd;
 
 
  fd = open ("/proc/self/auxv", O_RDONLY);
  fd = open ("/proc/self/auxv", O_RDONLY);
 
 
  if (fd != -1)
  if (fd != -1)
    {
    {
      char buf[1024];
      char buf[1024];
      ElfW(auxv_t) *av;
      ElfW(auxv_t) *av;
      ssize_t n;
      ssize_t n;
 
 
      n = read (fd, buf, sizeof (buf));
      n = read (fd, buf, sizeof (buf));
      close (fd);
      close (fd);
 
 
      if (n > 0)
      if (n > 0)
        {
        {
          for (av = (ElfW(auxv_t) *) buf; av->a_type != AT_NULL; ++av)
          for (av = (ElfW(auxv_t) *) buf; av->a_type != AT_NULL; ++av)
            switch (av->a_type)
            switch (av->a_type)
              {
              {
              case AT_PLATFORM:
              case AT_PLATFORM:
                return (const char *) av->a_un.a_val;
                return (const char *) av->a_un.a_val;
 
 
              default:
              default:
                break;
                break;
              }
              }
        }
        }
    }
    }
  return NULL;
  return NULL;
}
}
 
 
/* Returns AT_PLATFORM if present, otherwise generic 32.  */
/* Returns AT_PLATFORM if present, otherwise generic 32.  */
 
 
static int
static int
elf_dcachebsize (void)
elf_dcachebsize (void)
{
{
  int fd;
  int fd;
 
 
  fd = open ("/proc/self/auxv", O_RDONLY);
  fd = open ("/proc/self/auxv", O_RDONLY);
 
 
  if (fd != -1)
  if (fd != -1)
    {
    {
      char buf[1024];
      char buf[1024];
      ElfW(auxv_t) *av;
      ElfW(auxv_t) *av;
      ssize_t n;
      ssize_t n;
 
 
      n = read (fd, buf, sizeof (buf));
      n = read (fd, buf, sizeof (buf));
      close (fd);
      close (fd);
 
 
      if (n > 0)
      if (n > 0)
        {
        {
          for (av = (ElfW(auxv_t) *) buf; av->a_type != AT_NULL; ++av)
          for (av = (ElfW(auxv_t) *) buf; av->a_type != AT_NULL; ++av)
            switch (av->a_type)
            switch (av->a_type)
              {
              {
              case AT_DCACHEBSIZE:
              case AT_DCACHEBSIZE:
                return av->a_un.a_val;
                return av->a_un.a_val;
 
 
              default:
              default:
                break;
                break;
              }
              }
        }
        }
    }
    }
  return 32;
  return 32;
}
}
 
 
/* Returns the description of caches on Linux.  */
/* Returns the description of caches on Linux.  */
 
 
static char *
static char *
detect_caches_linux (void)
detect_caches_linux (void)
{
{
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
  const char *platform;
  const char *platform;
 
 
  platform = elf_platform ();
  platform = elf_platform ();
 
 
  if (platform != NULL)
  if (platform != NULL)
    {
    {
      l1_line = 128;
      l1_line = 128;
 
 
      if (platform[5] == '6')
      if (platform[5] == '6')
        /* POWER6 and POWER6x */
        /* POWER6 and POWER6x */
        l1_sizekb = 64;
        l1_sizekb = 64;
      else
      else
        l1_sizekb = 32;
        l1_sizekb = 32;
    }
    }
  else
  else
    {
    {
      l1_line = elf_dcachebsize ();
      l1_line = elf_dcachebsize ();
      l1_sizekb = 32;
      l1_sizekb = 32;
    }
    }
 
 
  l1_assoc = 0;
  l1_assoc = 0;
  l2_sizekb = 512;
  l2_sizekb = 512;
 
 
  return describe_cache (l1_sizekb, l1_line, l1_assoc, l2_sizekb);
  return describe_cache (l1_sizekb, l1_line, l1_assoc, l2_sizekb);
}
}
 
 
static const char *
static const char *
detect_processor_linux (void)
detect_processor_linux (void)
{
{
  const char *platform;
  const char *platform;
 
 
  platform = elf_platform ();
  platform = elf_platform ();
 
 
  if (platform != NULL)
  if (platform != NULL)
    return platform;
    return platform;
  else
  else
    return "powerpc";
    return "powerpc";
}
}
 
 
#endif /* __linux__ */
#endif /* __linux__ */
 
 
#ifdef _AIX
#ifdef _AIX
/* Returns the description of caches on AIX.  */
/* Returns the description of caches on AIX.  */
 
 
static char *
static char *
detect_caches_aix (void)
detect_caches_aix (void)
{
{
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
  unsigned l1_sizekb, l1_line, l1_assoc, l2_sizekb;
 
 
  l1_sizekb = _system_configuration.dcache_size / 1024;
  l1_sizekb = _system_configuration.dcache_size / 1024;
  l1_line = _system_configuration.dcache_line;
  l1_line = _system_configuration.dcache_line;
  l1_assoc = _system_configuration.dcache_asc;
  l1_assoc = _system_configuration.dcache_asc;
  l2_sizekb = _system_configuration.L2_cache_size / 1024;
  l2_sizekb = _system_configuration.L2_cache_size / 1024;
 
 
  return describe_cache (l1_sizekb, l1_line, l1_assoc, l2_sizekb);
  return describe_cache (l1_sizekb, l1_line, l1_assoc, l2_sizekb);
}
}
 
 
 
 
/* Returns the processor implementation on AIX.  */
/* Returns the processor implementation on AIX.  */
 
 
static const char *
static const char *
detect_processor_aix (void)
detect_processor_aix (void)
{
{
  switch (_system_configuration.implementation)
  switch (_system_configuration.implementation)
    {
    {
    case 0x0001:
    case 0x0001:
      return "rios1";
      return "rios1";
 
 
    case 0x0002:
    case 0x0002:
      return "rsc";
      return "rsc";
 
 
    case 0x0004:
    case 0x0004:
      return "rios2";
      return "rios2";
 
 
    case 0x0008:
    case 0x0008:
      return "601";
      return "601";
 
 
    case 0x0020:
    case 0x0020:
      return "603";
      return "603";
 
 
    case 0x0010:
    case 0x0010:
      return "604";
      return "604";
 
 
    case 0x0040:
    case 0x0040:
      return "620";
      return "620";
 
 
    case 0x0080:
    case 0x0080:
      return "630";
      return "630";
 
 
    case 0x0100:
    case 0x0100:
    case 0x0200:
    case 0x0200:
    case 0x0400:
    case 0x0400:
      return "rs64";
      return "rs64";
 
 
    case 0x0800:
    case 0x0800:
      return "power4";
      return "power4";
 
 
    case 0x2000:
    case 0x2000:
      if (_system_configuration.version == 0x0F0000)
      if (_system_configuration.version == 0x0F0000)
        return "power5";
        return "power5";
      else
      else
        return "power5+";
        return "power5+";
 
 
    case 0x4000:
    case 0x4000:
      return "power6";
      return "power6";
 
 
    default:
    default:
      return "powerpc";
      return "powerpc";
    }
    }
}
}
#endif /* _AIX */
#endif /* _AIX */
 
 
 
 
/*
/*
 * Array to map -mcpu=native names to the switches passed to the assembler.
 * Array to map -mcpu=native names to the switches passed to the assembler.
 * This list mirrors the specs in ASM_CPU_SPEC, and any changes made here
 * This list mirrors the specs in ASM_CPU_SPEC, and any changes made here
 * should be made there as well.
 * should be made there as well.
 */
 */
 
 
struct asm_name {
struct asm_name {
  const char *cpu;
  const char *cpu;
  const char *asm_sw;
  const char *asm_sw;
};
};
 
 
static const struct asm_name asm_names[] = {
static const struct asm_name asm_names[] = {
#if defined (_AIX)
#if defined (_AIX)
  { "power3",   "-m620" },
  { "power3",   "-m620" },
  { "power4",   "-mpwr4" },
  { "power4",   "-mpwr4" },
  { "power5",   "-mpwr5" },
  { "power5",   "-mpwr5" },
  { "power5+",  "-mpwr5x" },
  { "power5+",  "-mpwr5x" },
  { "power6",   "-mpwr6" },
  { "power6",   "-mpwr6" },
  { "power6x",  "-mpwr6" },
  { "power6x",  "-mpwr6" },
  { "power7",   "-mpwr7" },
  { "power7",   "-mpwr7" },
  { "powerpc",  "-mppc" },
  { "powerpc",  "-mppc" },
  { "rs64a",    "-mppc" },
  { "rs64a",    "-mppc" },
  { "603",      "-m603" },
  { "603",      "-m603" },
  { "603e",     "-m603" },
  { "603e",     "-m603" },
  { "604",      "-m604" },
  { "604",      "-m604" },
  { "604e",     "-m604" },
  { "604e",     "-m604" },
  { "620",      "-m620" },
  { "620",      "-m620" },
  { "630",      "-m620" },
  { "630",      "-m620" },
  { "970",      "-m970" },
  { "970",      "-m970" },
  { "G5",       "-m970" },
  { "G5",       "-m970" },
  { NULL,       "\
  { NULL,       "\
%{!maix64: \
%{!maix64: \
%{mpowerpc64: -mppc64} \
%{mpowerpc64: -mppc64} \
%{maltivec: -m970} \
%{maltivec: -m970} \
%{!maltivec: %{!mpower64: %(asm_default)}}}" },
%{!maltivec: %{!mpower64: %(asm_default)}}}" },
 
 
#else
#else
  { "common",   "-mcom" },
  { "common",   "-mcom" },
  { "cell",     "-mcell" },
  { "cell",     "-mcell" },
  { "power",    "-mpwr" },
  { "power",    "-mpwr" },
  { "power2",   "-mpwrx" },
  { "power2",   "-mpwrx" },
  { "power3",   "-mppc64" },
  { "power3",   "-mppc64" },
  { "power4",   "-mpower4" },
  { "power4",   "-mpower4" },
  { "power5",   "%(asm_cpu_power5)" },
  { "power5",   "%(asm_cpu_power5)" },
  { "power5+",  "%(asm_cpu_power5)" },
  { "power5+",  "%(asm_cpu_power5)" },
  { "power6",   "%(asm_cpu_power6) -maltivec" },
  { "power6",   "%(asm_cpu_power6) -maltivec" },
  { "power6x",  "%(asm_cpu_power6) -maltivec" },
  { "power6x",  "%(asm_cpu_power6) -maltivec" },
  { "power7",   "%(asm_cpu_power7)" },
  { "power7",   "%(asm_cpu_power7)" },
  { "powerpc",  "-mppc" },
  { "powerpc",  "-mppc" },
  { "rios",     "-mpwr" },
  { "rios",     "-mpwr" },
  { "rios1",    "-mpwr" },
  { "rios1",    "-mpwr" },
  { "rios2",    "-mpwrx" },
  { "rios2",    "-mpwrx" },
  { "rsc",      "-mpwr" },
  { "rsc",      "-mpwr" },
  { "rsc1",     "-mpwr" },
  { "rsc1",     "-mpwr" },
  { "rs64a",    "-mppc64" },
  { "rs64a",    "-mppc64" },
  { "401",      "-mppc" },
  { "401",      "-mppc" },
  { "403",      "-m403" },
  { "403",      "-m403" },
  { "405",      "-m405" },
  { "405",      "-m405" },
  { "405fp",    "-m405" },
  { "405fp",    "-m405" },
  { "440",      "-m440" },
  { "440",      "-m440" },
  { "440fp",    "-m440" },
  { "440fp",    "-m440" },
  { "464",      "-m440" },
  { "464",      "-m440" },
  { "464fp",    "-m440" },
  { "464fp",    "-m440" },
  { "505",      "-mppc" },
  { "505",      "-mppc" },
  { "601",      "-m601" },
  { "601",      "-m601" },
  { "602",      "-mppc" },
  { "602",      "-mppc" },
  { "603",      "-mppc" },
  { "603",      "-mppc" },
  { "603e",     "-mppc" },
  { "603e",     "-mppc" },
  { "ec603e",   "-mppc" },
  { "ec603e",   "-mppc" },
  { "604",      "-mppc" },
  { "604",      "-mppc" },
  { "604e",     "-mppc" },
  { "604e",     "-mppc" },
  { "620",      "-mppc64" },
  { "620",      "-mppc64" },
  { "630",      "-mppc64" },
  { "630",      "-mppc64" },
  { "740",      "-mppc" },
  { "740",      "-mppc" },
  { "750",      "-mppc" },
  { "750",      "-mppc" },
  { "G3",       "-mppc" },
  { "G3",       "-mppc" },
  { "7400",     "-mppc -maltivec" },
  { "7400",     "-mppc -maltivec" },
  { "7450",     "-mppc -maltivec" },
  { "7450",     "-mppc -maltivec" },
  { "G4",       "-mppc -maltivec" },
  { "G4",       "-mppc -maltivec" },
  { "801",      "-mppc" },
  { "801",      "-mppc" },
  { "821",      "-mppc" },
  { "821",      "-mppc" },
  { "823",      "-mppc" },
  { "823",      "-mppc" },
  { "860",      "-mppc" },
  { "860",      "-mppc" },
  { "970",      "-mpower4 -maltivec" },
  { "970",      "-mpower4 -maltivec" },
  { "G5",       "-mpower4 -maltivec" },
  { "G5",       "-mpower4 -maltivec" },
  { "8540",     "-me500" },
  { "8540",     "-me500" },
  { "8548",     "-me500" },
  { "8548",     "-me500" },
  { "e300c2",   "-me300" },
  { "e300c2",   "-me300" },
  { "e300c3",   "-me300" },
  { "e300c3",   "-me300" },
  { "e500mc",   "-me500mc" },
  { "e500mc",   "-me500mc" },
  { NULL,       "\
  { NULL,       "\
%{mpower: %{!mpower2: -mpwr}} \
%{mpower: %{!mpower2: -mpwr}} \
%{mpower2: -mpwrx} \
%{mpower2: -mpwrx} \
%{mpowerpc64*: -mppc64} \
%{mpowerpc64*: -mppc64} \
%{!mpowerpc64*: %{mpowerpc*: -mppc}} \
%{!mpowerpc64*: %{mpowerpc*: -mppc}} \
%{mno-power: %{!mpowerpc*: -mcom}} \
%{mno-power: %{!mpowerpc*: -mcom}} \
%{!mno-power: %{!mpower*: %(asm_default)}}" },
%{!mno-power: %{!mpower*: %(asm_default)}}" },
#endif
#endif
};
};
 
 
/* This will be called by the spec parser in gcc.c when it sees
/* This will be called by the spec parser in gcc.c when it sees
   a %:local_cpu_detect(args) construct.  Currently it will be called
   a %:local_cpu_detect(args) construct.  Currently it will be called
   with either "arch" or "tune" as argument depending on if -march=native
   with either "arch" or "tune" as argument depending on if -march=native
   or -mtune=native is to be substituted.
   or -mtune=native is to be substituted.
 
 
   Additionally it will be called with "asm" to select the appropriate flags
   Additionally it will be called with "asm" to select the appropriate flags
   for the assembler.
   for the assembler.
 
 
   It returns a string containing new command line parameters to be
   It returns a string containing new command line parameters to be
   put at the place of the above two options, depending on what CPU
   put at the place of the above two options, depending on what CPU
   this is executed.
   this is executed.
 
 
   ARGC and ARGV are set depending on the actual arguments given
   ARGC and ARGV are set depending on the actual arguments given
   in the spec.  */
   in the spec.  */
const char *
const char *
host_detect_local_cpu (int argc, const char **argv)
host_detect_local_cpu (int argc, const char **argv)
{
{
  const char *cpu = NULL;
  const char *cpu = NULL;
  const char *cache = "";
  const char *cache = "";
  const char *options = "";
  const char *options = "";
  bool arch;
  bool arch;
  bool assembler;
  bool assembler;
  size_t i;
  size_t i;
 
 
  if (argc < 1)
  if (argc < 1)
    return NULL;
    return NULL;
 
 
  arch = strcmp (argv[0], "cpu") == 0;
  arch = strcmp (argv[0], "cpu") == 0;
  assembler = (!arch && strcmp (argv[0], "asm") == 0);
  assembler = (!arch && strcmp (argv[0], "asm") == 0);
  if (!arch && !assembler && strcmp (argv[0], "tune"))
  if (!arch && !assembler && strcmp (argv[0], "tune"))
    return NULL;
    return NULL;
 
 
  if (! assembler)
  if (! assembler)
    {
    {
#if defined (_AIX)
#if defined (_AIX)
      cache = detect_caches_aix ();
      cache = detect_caches_aix ();
#elif defined (__APPLE__)
#elif defined (__APPLE__)
      cache = detect_caches_darwin ();
      cache = detect_caches_darwin ();
#elif defined (__FreeBSD__)
#elif defined (__FreeBSD__)
      cache = detect_caches_freebsd ();
      cache = detect_caches_freebsd ();
      /* FreeBSD PPC does not provide any cache information yet.  */
      /* FreeBSD PPC does not provide any cache information yet.  */
      cache = "";
      cache = "";
#elif defined (__linux__)
#elif defined (__linux__)
      cache = detect_caches_linux ();
      cache = detect_caches_linux ();
      /* PPC Linux does not provide any cache information yet.  */
      /* PPC Linux does not provide any cache information yet.  */
      cache = "";
      cache = "";
#else
#else
      cache = "";
      cache = "";
#endif
#endif
    }
    }
 
 
#if defined (_AIX)
#if defined (_AIX)
  cpu = detect_processor_aix ();
  cpu = detect_processor_aix ();
#elif defined (__APPLE__)
#elif defined (__APPLE__)
  cpu = detect_processor_darwin ();
  cpu = detect_processor_darwin ();
#elif defined (__FreeBSD__)
#elif defined (__FreeBSD__)
  cpu = detect_processor_freebsd ();
  cpu = detect_processor_freebsd ();
#elif defined (__linux__)
#elif defined (__linux__)
  cpu = detect_processor_linux ();
  cpu = detect_processor_linux ();
#else
#else
  cpu = "powerpc";
  cpu = "powerpc";
#endif
#endif
 
 
  if (assembler)
  if (assembler)
    {
    {
      for (i = 0; i < sizeof (asm_names) / sizeof (asm_names[0]); i++)
      for (i = 0; i < sizeof (asm_names) / sizeof (asm_names[0]); i++)
        {
        {
          if (!asm_names[i].cpu || !strcmp (asm_names[i].cpu, cpu))
          if (!asm_names[i].cpu || !strcmp (asm_names[i].cpu, cpu))
            return asm_names[i].asm_sw;
            return asm_names[i].asm_sw;
        }
        }
 
 
      return NULL;
      return NULL;
    }
    }
 
 
  return concat (cache, "-m", argv[0], "=", cpu, " ", options, NULL);
  return concat (cache, "-m", argv[0], "=", cpu, " ", options, NULL);
}
}
 
 
#else /* GCC_VERSION */
#else /* GCC_VERSION */
 
 
/* If we aren't compiling with GCC we just provide a minimal
/* If we aren't compiling with GCC we just provide a minimal
   default value.  */
   default value.  */
const char *
const char *
host_detect_local_cpu (int argc, const char **argv)
host_detect_local_cpu (int argc, const char **argv)
{
{
  const char *cpu;
  const char *cpu;
  bool arch;
  bool arch;
 
 
  if (argc < 1)
  if (argc < 1)
    return NULL;
    return NULL;
 
 
  arch = strcmp (argv[0], "cpu") == 0;
  arch = strcmp (argv[0], "cpu") == 0;
  if (!arch && strcmp (argv[0], "tune"))
  if (!arch && strcmp (argv[0], "tune"))
    return NULL;
    return NULL;
 
 
  if (arch)
  if (arch)
    cpu = "powerpc";
    cpu = "powerpc";
 
 
  return concat ("-m", argv[0], "=", cpu, NULL);
  return concat ("-m", argv[0], "=", cpu, NULL);
}
}
 
 
#endif /* GCC_VERSION */
#endif /* GCC_VERSION */
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.