aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/i386/driver-i386.c
diff options
context:
space:
mode:
authorUros Bizjak <uros@gcc.gnu.org>2009-06-03 08:33:31 +0200
committerUros Bizjak <uros@gcc.gnu.org>2009-06-03 08:33:31 +0200
commitf3afc8a7c4d49f1dfd815286c2d84d67eba836c7 (patch)
treec55e9c054e6a865f5290620a00932f06ea1dfc41 /gcc/config/i386/driver-i386.c
parent394e9195612ec301c18ae54d3d4b7f7a8c8b80f7 (diff)
downloadgcc-f3afc8a7c4d49f1dfd815286c2d84d67eba836c7.zip
gcc-f3afc8a7c4d49f1dfd815286c2d84d67eba836c7.tar.gz
gcc-f3afc8a7c4d49f1dfd815286c2d84d67eba836c7.tar.bz2
driver-i386.c (describe_cache): Optimize concatenation of strings.
* config/i386/driver-i386.c (describe_cache): Optimize concatenation of strings. Use snprintf instead of sprintf. (host_detect_local_cpu): Ditto. Ignore -march and -mtune for native target when not compiling with GCC. From-SVN: r148115
Diffstat (limited to 'gcc/config/i386/driver-i386.c')
-rw-r--r--gcc/config/i386/driver-i386.c62
1 files changed, 24 insertions, 38 deletions
diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c
index 0364beae..df0689d 100644
--- a/gcc/config/i386/driver-i386.c
+++ b/gcc/config/i386/driver-i386.c
@@ -46,12 +46,15 @@ describe_cache (struct cache_desc level1, struct cache_desc level2)
/* At the moment, gcc does not use the information
about the associativity of the cache. */
- sprintf (size, "--param l1-cache-size=%u", level1.sizekb);
- sprintf (line, "--param l1-cache-line-size=%u", level1.line);
+ snprintf (size, sizeof (size),
+ "--param l1-cache-size=%u ", level1.sizekb);
+ snprintf (line, sizeof (line),
+ "--param l1-cache-line-size=%u ", level1.line);
- sprintf (size2, "--param l2-cache-size=%u", level2.sizekb);
+ snprintf (size2, sizeof (size2),
+ "--param l2-cache-size=%u ", level2.sizekb);
- return concat (size, " ", line, " ", size2, " ", NULL);
+ return concat (size, line, size2, NULL);
}
/* Detect L2 cache parameters using CPUID extended function 0x80000006. */
@@ -608,55 +611,38 @@ const char *host_detect_local_cpu (int argc, const char **argv)
if (arch)
{
if (has_cmpxchg16b)
- options = concat (options, "-mcx16 ", NULL);
+ options = concat (options, " -mcx16", NULL);
if (has_lahf_lm)
- options = concat (options, "-msahf ", NULL);
+ options = concat (options, " -msahf", NULL);
if (has_movbe)
- options = concat (options, "-mmovbe ", NULL);
+ options = concat (options, " -mmovbe", NULL);
if (has_aes)
- options = concat (options, "-maes ", NULL);
+ options = concat (options, " -maes", NULL);
if (has_pclmul)
- options = concat (options, "-mpclmul ", NULL);
+ options = concat (options, " -mpclmul", NULL);
if (has_popcnt)
- options = concat (options, "-mpopcnt ", NULL);
+ options = concat (options, " -mpopcnt", NULL);
+
if (has_avx)
- options = concat (options, "-mavx ", NULL);
+ options = concat (options, " -mavx", NULL);
else if (has_sse4_2)
- options = concat (options, "-msse4.2 ", NULL);
+ options = concat (options, " -msse4.2", NULL);
else if (has_sse4_1)
- options = concat (options, "-msse4.1 ", NULL);
+ options = concat (options, " -msse4.1", NULL);
}
done:
- return concat (cache, "-m", argv[0], "=", cpu, " ", options, NULL);
+ return concat (cache, "-m", argv[0], "=", cpu, options, NULL);
}
#else
-/* If we aren't compiling with GCC we just provide a minimal
- default value. */
+/* If we aren't compiling with GCC then the driver will just ignore
+ -march and -mtune "native" target and will leave to the newly
+ built compiler to generate code for its default target. */
-const char *host_detect_local_cpu (int argc, const char **argv)
+const char *host_detect_local_cpu (int argc ATTRIBUTE_UNUSED,
+ const char **argv ATTRIBUTE_UNUSED)
{
- const char *cpu;
- bool arch;
-
- if (argc < 1)
- return NULL;
-
- arch = !strcmp (argv[0], "arch");
-
- if (!arch && strcmp (argv[0], "tune"))
- return NULL;
-
- if (arch)
- {
- /* FIXME: i386 is wrong for 64bit compiler. How can we tell if
- we are generating 64bit or 32bit code? */
- cpu = "i386";
- }
- else
- cpu = "generic";
-
- return concat ("-m", argv[0], "=", cpu, NULL);
+ return NULL;
}
#endif /* __GNUC__ */