@@ -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
@@ -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
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@gmail.com> --- arch/nios2/Kconfig | 31 +++++++++++++++++++++++++++++++ arch/nios2/config.mk | 22 ++++++++++++++++++++++ 2 files changed, 53 insertions(+)