nios2: set appropriate compiler flags for math support
Nios II CPUs vary in configuration on whether they support 'mul', 'mulx', and 'div' family of instructions. The compiler can be told to use GCC integer library routines instead if needed. Ideally we would just pull the configuration out of system.h, but pulling include file #defines into the Make environment will involve some build system work that is best left to a later improvement. We've decided to take this build-time approach rather than handle unimplemented instruction exceptions, so remove the hook in exception.S Change-Id: I05be0d5ed4c1a49b23dca1550ee66fd5891044d2 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
ab5f6de4af
commit
a7b54980bd
5 changed files with 35 additions and 10 deletions
|
|
@ -55,6 +55,18 @@ config IRQ_OFFLOAD
|
|||
Enable irq_offload() API which allows functions to be synchronously
|
||||
run in interrupt context. Mainly useful for test cases.
|
||||
|
||||
config HAS_MUL_INSTRUCTION
|
||||
bool
|
||||
default n
|
||||
|
||||
config HAS_DIV_INSTRUCTION
|
||||
bool
|
||||
default n
|
||||
|
||||
config HAS_MULX_INSTRUCTION
|
||||
bool
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
source "arch/nios2/soc/*/Kconfig"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,24 @@ arch_cflags := $(call cc-option,-G0)
|
|||
arch_cflags += $(call cc-option,-ffunction-sections) \
|
||||
$(call cc-option,-fdata-sections)
|
||||
|
||||
# TODO Find a way to pull this out of system.h somehow
|
||||
# instead of having Kconfig for it
|
||||
ifdef CONFIG_HAS_MUL_INSTRUCTION
|
||||
arch_cflags += -mhw-mul
|
||||
else
|
||||
arch_cflags += -mno-hw-mul
|
||||
endif
|
||||
ifdef CONFIG_HAS_MULX_INSTRUCTION
|
||||
arch_cflags += -mhw-mulx
|
||||
else
|
||||
arch_cflags += -mno-hw-mulx
|
||||
endif
|
||||
ifdef CONFIG_HAS_DIV_INSTRUCTION
|
||||
arch_cflags += -mhw-div
|
||||
else
|
||||
arch_cflags += -mno-hw-div
|
||||
endif
|
||||
|
||||
# Nios II CPUs are configurable and we need to pull in the generated
|
||||
# headers system.h and linker.h which specify what is enabled and where
|
||||
# everything is.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ GTEXT(_exception_enter_fault)
|
|||
/* import */
|
||||
GTEXT(_Fault)
|
||||
GTEXT(_Swap)
|
||||
GTEXT(_exception_try_muldiv)
|
||||
#ifdef CONFIG_IRQ_OFFLOAD
|
||||
GTEXT(_irq_do_offload)
|
||||
GTEXT(_offload_routine)
|
||||
|
|
@ -189,15 +188,6 @@ BRANCH_LABEL(not_interrupt)
|
|||
bne r11, zero, is_interrupt
|
||||
#endif
|
||||
|
||||
#if 0 /* TODO: implement multiply/divide handling */
|
||||
/* Could be an unimplemented instruction we have to emulate.
|
||||
* Smaller Nios II cores don't have multiply or divide instructions.
|
||||
* This code comes back to either _exception_enter_fault or
|
||||
* _exception_exit
|
||||
*/
|
||||
jmpi _exception_try_muldiv
|
||||
#endif
|
||||
|
||||
SECTION_FUNC(exception.entry, _exception_enter_fault)
|
||||
/* If we get here, the exception wasn't in interrupt or an
|
||||
* unimplemented math instruction. Let _Fault() handle it in
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
config SOC_NIOS2_QEMU
|
||||
bool "Nios II - Experimental QEMU emulation"
|
||||
select HAS_MUL_INSTRUCTION
|
||||
select HAS_DIV_INSTRUCTION
|
||||
select HAS_MULX_INSTRUCTION
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
config SOC_NIOS2F_ZEPHYR
|
||||
bool "Nios IIf - Zephyr Golden Configuration"
|
||||
select HAS_MUL_INSTRUCTION
|
||||
select HAS_DIV_INSTRUCTION
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue