2016-06-30 17 views
1

使用gcc,您可以指定「-mtune =」或「-mtune = generic」哪些cpu的目標是gcc的-mtune = generic?

如何知道哪個體系結構針對gcc的「-mtune = generic」目標?它應該根據不同版本的GCC而變化?

該文檔https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/x86-Options.html#x86-Options說:

As new processors are deployed in the marketplace, the behavior of this option will change. Therefore, if you upgrade to a newer version of GCC, code generation controlled by this option will change to reflect the processors that are most common at the time that version of GCC is released.

我怎麼能知道哪一個的GCC目標每個版本?

文檔說:

https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/x86-Options.html#x86-Options

... 
‘i686’ 
When used with -march, the Pentium Pro instruction set is used, 
so the code runs on all i686 family chips. When used with -mtune, it has the same meaning as ‘generic’. 

所以我想一般的 「的意思是」 i686的,但是是一個特定的CPU?

+0

您可以嘗試添加'-fverbose-ASM -S',並檢查生成的ASM第一線查看選項...你想知道mtune = x86/x86_64的通用或任何gcc支持的arch? – osgx

+0

它不一定針對一個特定的CPU。這可能是一種妥協,避免代碼在某些CPU上會非常慢,避免其他代碼在某些intel cpu上會非常慢,最終會導致某些對於任何cpu都不是最佳的代碼,但仍然可以在任何地方使用。 –

回答

0

我怎樣才能知道哪個架構的目標是「-mtune = generic」的gcc?

通過閱讀真正文檔,GCC的源代碼(搜索PROCESSOR_GENERICswitch(tune)

對於x86(32/64位)gcc/config/i386/i386-c.c它不會限定建宏/拱宏,

/* Built-ins based on -mtune=. */ 
    switch (tune) 

    case PROCESSOR_GENERIC: 
     break; 

gcc/config/i386/driver-i386.c不會檢測本地CPU與CPUID(host_detect_local_cpu不會被調用,而不cpu=native/tune=native

您可以嘗試添加-fverbose-asm -S併爲您的選擇生成的ASM第一線..