From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH, i386-driver]: Ignore -march and -mtune for native target when not compiled with gcc
Date: Tue, 02 Jun 2009 11:16:00 -0000 [thread overview]
Message-ID: <5787cf470906020416v336c0afdiaf4906f833f15f51@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 710 bytes --]
Hello!
Attached patch teaches i386 driver to ignore -march and -mtune
switches for native target when the driver is not compiled with gcc.
By ignoring the switches, the compiler generates code for its default
target, which is max that we can do in this case (*). The driver also
optimizes concatenation of options a bit.
2009-06-02 Uros Bizjak <ubizjak@gmail.com>
* config/i386/driver-i386.c (describe_cache): Optimize
concatenation of strings.
(host_detect_local_cpu): Ditto.
(host_detect_local_cpu): Ignore -march and -mtune for native
target when not compiling with GCC.
Any comments on this approach?
(*) driver uses gcc specific asm to use cpuid insn, so it must be
compiled using gcc.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 3146 bytes --]
Index: driver-i386.c
===================================================================
--- driver-i386.c (revision 148080)
+++ driver-i386.c (working copy)
@@ -46,12 +46,12 @@ describe_cache (struct cache_desc level1
/* 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);
+ sprintf (size, "--param l1-cache-size=%u ", level1.sizekb);
+ sprintf (line, "--param l1-cache-line-size=%u ", level1.line);
- sprintf (size2, "--param l2-cache-size=%u", level2.sizekb);
+ sprintf (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 +608,38 @@ const char *host_detect_local_cpu (int a
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__ */
next reply other threads:[~2009-06-02 11:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-02 11:16 Uros Bizjak [this message]
2009-06-02 14:09 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5787cf470906020416v336c0afdiaf4906f833f15f51@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).