[RFC] arch/x86/Kconfig.cpu: Update with new gcc disponible 64bits CPU uarchs.

From: Gustavo da Silva
Date: Mon Dec 19 2016 - 12:09:56 EST


Good afternon!

Are there reasons to 'Kconfig.cpu' and 'Makefile' not contains the
'gcc -mtune=???'
recent options?

Well, bellow I send some diffs (untested) just for clarifications.

Best regards,

Gustavo da Silva.

====================

--- old/arch/x86/Kconfig.cpu
+++ new/arch/x86/Kconfig.cpu
@@ -45,6 +45,14 @@
- "Core 2/newer Xeon" for all core2 and newer Intel CPUs.
- "Intel Atom" for the Atom-microarchitecture CPUs.
- "Generic-x86-64" for a kernel which runs on any x86-64 CPU.
+ - "Intel Nehalem" for the Nehalem-microarchitecture CPUs.
+ - "Intel Westmere" for the Westmere-microarchitecture CPUs.
+ - "Intel Sandy Bridge" for the Sandy Bridge-microarchitecture CPUs.
+ - "Intel Ivy Bridge" for the Ivy Bridge-microarchitecture CPUs.
+ - "Intel Haswell" for the Haswell-microarchitecture CPUs.
+ - "Intel Broadwell" for the Broadwell-microarchitecture CPUs.
+ - "Intel Skylake" for the Skylake-microarchitecture CPUs.
+ - "Intel Knight's Landing" for the Knight's Landing-microarchitecture CPUs.

See each option's help text for additional details. If you don't know
what to do, choose "486".
@@ -279,6 +287,62 @@
accordingly optimized code. Use a recent GCC with specific Atom
support in order to fully benefit from selecting this option.

+config MNEHALEM
+ bool "Intel Nehalem"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Nehalem-microarchitecture based CPUs.
+
+config MWESTMERE
+ bool "Intel Westmere"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Westmere-microarchitecture based CPUs.
+
+config MSANDYBRIDGE
+ bool "Intel Sandy Bridge"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Sandy Bridge-microarchitecture based CPUs.
+
+config MIVYBRIDGE
+ bool "Intel Ivy Bridge"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Ivy Bridge-microarchitecture based CPUs.
+
+config MHASWELL
+ bool "Intel Haswell"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Haswell-microarchitecture based CPUs.
+
+config MBROADWELL
+ bool "Intel Broadwell"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Broadwell-microarchitecture based CPUs.
+
+config MSKYLAKE
+ bool "Intel Skylake"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Skylake-microarchitecture based CPUs.
+
+config MKNL
+ bool "Intel Knight's Landing"
+ depends on X86_64
+ ---help---
+
+ Select this for Intel Knight's Landing-microarchitecture based CPUs.
+
config GENERIC_CPU
bool "Generic-x86-64"
depends on X86_64

====================

--- old/arch/x86/Makefile
+++ new/arch/x86/Makefile
@@ -103,15 +103,8 @@
# Use -mskip-rax-setup if supported.
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)

- # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
- cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
- cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
-
- cflags-$(CONFIG_MCORE2) += \
- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
- cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
- cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
+ # CPU-specific tuning. Anything which can be shared with UML
should go here.
+ include arch/x86/Makefile_64.cpu
KBUILD_CFLAGS += $(cflags-y)

KBUILD_CFLAGS += -mno-red-zone

====================

NEW FILE: new/arch/x86/Makefile_64.cpu

# CPU tuning section - shared with UML.
# Must change only cflags-y (or [yn]), not CFLAGS! That makes a
difference for UML.

#-mtune exists since gcc 3.4
HAS_MTUNE := $(call cc-option-yn, -mtune=i386)
ifeq ($(HAS_MTUNE),y)
tune = $(call cc-option,-mtune=$(1),$(2))
else
tune = $(call cc-option,-mcpu=$(1),$(2))
endif

align := $(cc-option-align)

cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
cflags-$(CONFIG_MCORE2) += $(call cc-option,-march=core2,$(call
cc-option,-mtune=generic))
cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
cflags-$(CONFIG_MNEHALEM) += $(call
cc-option,-march=nehalem,$(call cc-option,-mtune=nehalem))
cflags-$(CONFIG_MWESTMERE) += $(call
cc-option,-march=westmere,$(call cc-option,-mtune=westmere))
cflags-$(CONFIG_MSANDYBRIDGE) += $(call
cc-option,-march=sandybridge,$(call cc-option,-mtune=sandybridge))
cflags-$(CONFIG_MIVYBRIDGE) += $(call
cc-option,-march=ivybridge,$(call cc-option,-mtune=ivybridge))
cflags-$(CONFIG_MHASWELL) += $(call
cc-option,-march=haswell,$(call cc-option,-mtune=haswell))
cflags-$(CONFIG_MBROADWELL) += $(call
cc-option,-march=broadwell,$(call cc-option,-mtune=broadwell))
cflags-$(CONFIG_MSKYLAKE) += $(call
cc-option,-march=skylake,$(call cc-option,-mtune=skylake))
cflags-$(CONFIG_MKNL) += $(call cc-option,-march=knl,$(call
cc-option,-mtune=knl))
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)

--
Atenciosamente,

Gustavo da Silva
gustavodasilva@xxxxxxxxx