196625Stjr# SPDX-License-Identifier: GPL-2.0
296625Stjr# CPU tuning section - shared with UML.
396625Stjr# Must change only cflags-y (or [yn]), not CFLAGS! That makes a difference for UML.
496625Stjr
596625Stjrtune		= $(call cc-option,-mtune=$(1),$(2))
696625Stjr
796625Stjrifdef CONFIG_CC_IS_CLANG
896625Stjralign		:= -falign-functions=0 $(call cc-option,-falign-jumps=0) $(call cc-option,-falign-loops=0)
996625Stjrelse
1096625Stjralign		:= -falign-functions=0 -falign-jumps=0 -falign-loops=0
1196625Stjrendif
1296625Stjr
1396625Stjrcflags-$(CONFIG_M486SX)		+= -march=i486
1496625Stjrcflags-$(CONFIG_M486)		+= -march=i486
1596625Stjrcflags-$(CONFIG_M586)		+= -march=i586
1696625Stjrcflags-$(CONFIG_M586TSC)	+= -march=i586
1796625Stjrcflags-$(CONFIG_M586MMX)	+= -march=pentium-mmx
1896625Stjrcflags-$(CONFIG_M686)		+= -march=i686
1996625Stjrcflags-$(CONFIG_MPENTIUMII)	+= -march=i686 $(call tune,pentium2)
2096625Stjrcflags-$(CONFIG_MPENTIUMIII)	+= -march=i686 $(call tune,pentium3)
2196625Stjrcflags-$(CONFIG_MPENTIUMM)	+= -march=i686 $(call tune,pentium3)
2296625Stjrcflags-$(CONFIG_MPENTIUM4)	+= -march=i686 $(call tune,pentium4)
2396625Stjrcflags-$(CONFIG_MK6)		+= -march=k6
2496625Stjr# Please note, that patches that add -march=athlon-xp and friends are pointless.
2596625Stjr# They make zero difference whatsosever to performance at this time.
2696625Stjrcflags-$(CONFIG_MK7)		+= -march=athlon
2796625Stjrcflags-$(CONFIG_MK8)		+= $(call cc-option,-march=k8,-march=athlon)
2896625Stjrcflags-$(CONFIG_MCRUSOE)	+= -march=i686 $(align)
2996625Stjrcflags-$(CONFIG_MEFFICEON)	+= -march=i686 $(call tune,pentium3) $(align)
3096625Stjrcflags-$(CONFIG_MWINCHIPC6)	+= $(call cc-option,-march=winchip-c6,-march=i586)
3196625Stjrcflags-$(CONFIG_MWINCHIP3D)	+= $(call cc-option,-march=winchip2,-march=i586)
3296625Stjrcflags-$(CONFIG_MCYRIXIII)	+= $(call cc-option,-march=c3,-march=i486) $(align)
3396628Stjrcflags-$(CONFIG_MVIAC3_2)	+= $(call cc-option,-march=c3-2,-march=i686)
3496625Stjrcflags-$(CONFIG_MVIAC7)		+= -march=i686
3596625Stjrcflags-$(CONFIG_MCORE2)		+= -march=i686 $(call tune,core2)
3696625Stjrcflags-$(CONFIG_MATOM)		+= $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
3796625Stjr	$(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
3896625Stjr
3996625Stjr# AMD Elan support
4096625Stjrcflags-$(CONFIG_MELAN)		+= -march=i486
4196625Stjr
4296625Stjr# Geode GX1 support
4396625Stjrcflags-$(CONFIG_MGEODEGX1)	+= -march=pentium-mmx
4496625Stjrcflags-$(CONFIG_MGEODE_LX)	+= $(call cc-option,-march=geode,-march=pentium-mmx)
4596625Stjr# add at the end to overwrite eventual tuning options from earlier
4696625Stjr# cpu entries
4796625Stjrcflags-$(CONFIG_X86_GENERIC) 	+= $(call tune,generic,$(call tune,i686))
4896625Stjr
4996625Stjr# Bug fix for binutils: this option is required in order to keep
5096625Stjr# binutils from generating NOPL instructions against our will.
5197597Sruifneq ($(CONFIG_X86_P6_NOP),y)
5297597Srucflags-y			+= $(call cc-option,-Wa$(comma)-mtune=generic32,)
5397597Sruendif
5497597Sru