[U-Boot] [PATCH] nios2: tune specific cpu features
Kirill Smirnov
kirill.k.smirnov at gmail.com
Wed Jul 26 12:27:05 UTC 2017
This patch allows developer to tell gcc which nios2 cpu features
he enabled in his design. This way gcc will generate more efficient
code for a specific platform.
Signed-off-by: Kirill Smirnov <kirill.k.smirnov at gmail.com>
---
arch/nios2/Kconfig | 31 +++++++++++++++++++++++++++++++
arch/nios2/config.mk | 22 ++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index bb4fb2ac3a..12be43343c 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -11,4 +11,35 @@ config SYS_CONFIG_NAME
The header file include/configs/<CONFIG_SYS_CONFIG_NAME>.h
should be included from include/config.h.
+config SYS_TUNE_CPU_FEATURES
+ bool "Tune cpu features"
+ default n
+ help
+ Tune gcc flags to reflect nios2 cpu features.
+ If a specific feature is enabled the corresponding
+ -mhw-<feature> flag is passed to gcc. Otherwise,
+ -mno-hw-<features> flag is passed.
+
+if SYS_TUNE_CPU_FEATURES
+
+config SYS_HW_DIV
+ bool "Enable div family of instructions"
+ default n
+ help
+ This options passes -mhw-div flag to gcc.
+
+config SYS_HW_MUL
+ bool "Enable mul family of instructions"
+ default y
+ help
+ This options passes -mhw-mul flag to gcc.
+
+config SYS_HW_MULX
+ bool "Enable mulx family of instructions"
+ default n
+ help
+ This options passes -mhw-mulx flag to gcc.
+
+endif
+
endmenu
diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index 82bd887961..bbb5d7f853 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -15,5 +15,27 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x02000000
PLATFORM_CPPFLAGS += -D__NIOS2__
PLATFORM_CPPFLAGS += -G0
+ifeq ($(CONFIG_SYS_TUNE_CPU_FEATURES),y)
+
+ifeq ($(CONFIG_SYS_HW_DIV),y)
+PLATFORM_CPPFLAGS += -mhw-div
+else
+PLATFORM_CPPFLAGS += -mno-hw-div
+endif
+
+ifeq ($(CONFIG_SYS_HW_MUL),y)
+PLATFORM_CPPFLAGS += -mhw-mul
+else
+PLATFORM_CPPFLAGS += -mno-hw-mul
+endif
+
+ifeq ($(CONFIG_SYS_HW_MULX),y)
+PLATFORM_CPPFLAGS += -mhw-mulx
+else
+PLATFORM_CPPFLAGS += -mno-hw-mulx
+endif
+
+endif
+
LDFLAGS_FINAL += --gc-sections
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
--
2.13.2
More information about the U-Boot
mailing list