arch:arc: use FLS instruction to get clz

Signed-off-by: Jingru <jingru@synopsys.com>
This commit is contained in:
Jingru
2020-05-25 17:25:52 +08:00
parent 204d269794
commit f8c58778bd
4 changed files with 7 additions and 5 deletions

View File

@@ -23,7 +23,7 @@
#endif
#if defined(TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT) && (TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT == 1u)
__PORT__ uint32_t port_clz(uint32_t val);
__PORT__ uint32_t port_cpu_clz(uint32_t);
#endif
__PORT__ void port_int_disable(void);
@@ -36,8 +36,6 @@ __PORT__ void port_cpsr_restore(cpu_cpsr_t cpsr);
__PORT__ void port_cpu_reset(void);
__PORT__ uint32_t port_cpu_clz(uint32_t);
__PORT__ void port_sched_start(void) __NO_RETURN__;
__PORT__ void port_context_switch(void);

View File

@@ -22,6 +22,6 @@
#define TOS_CFG_CPU_DATA_SIZE CPU_WORD_SIZE_32
#define TOS_CFG_CPU_STK_GROWTH CPU_STK_GROWTH_DESCENDING
#define TOS_CFG_CPU_HRTIMER_EN 0u
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 0u
#define TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT 1u
#endif /* _PORT_CONFIG_H_ */

View File

@@ -313,7 +313,7 @@ firq_return:
.align 4
port_cpu_clz:
breq r0, 0, cpu_clz_return
ffs r1, r0
fls r1, r0
add r0, r1, 1
cpu_clz_return:
j [blink]

View File

@@ -26,6 +26,7 @@ void tos_cpu_tick_handler(void)
__API__ uint32_t tos_cpu_clz(uint32_t val)
{
#if defined(TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT) && (TOS_CFG_CPU_LEAD_ZEROS_ASM_PRESENT == 0u)
uint32_t nbr_lead_zeros = 0;
if (!(val & 0XFFFF0000)) {
@@ -57,6 +58,9 @@ __API__ uint32_t tos_cpu_clz(uint32_t val)
}
return (nbr_lead_zeros);
#else
return (32 - port_cpu_clz(val));
#endif
}
__API__ void tos_cpu_int_disable(void)