aboutsummaryrefslogtreecommitdiffstats
path: root/arch/xtensa/include/asm/asmmacro.h
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2021-10-18 04:29:27 -0700
committerMax Filippov <jcmvbkbc@gmail.com>2022-03-09 14:02:40 -0800
commitdbf4ed894c0fd85d421f7b3b9758ce95398d2925 (patch)
treebe741f6adb095349d4128f0b792a5b5637ab53b5 /arch/xtensa/include/asm/asmmacro.h
parentxtensa: add missing XCHAL_HAVE_WINDOWED check (diff)
downloadlinux-dev-dbf4ed894c0fd85d421f7b3b9758ce95398d2925.tar.xz
linux-dev-dbf4ed894c0fd85d421f7b3b9758ce95398d2925.zip
xtensa: add helpers for division, remainder and shifts
Don't rely on libgcc presence, build own versions of the helpers with correct ABI. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'arch/xtensa/include/asm/asmmacro.h')
-rw-r--r--arch/xtensa/include/asm/asmmacro.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/xtensa/include/asm/asmmacro.h b/arch/xtensa/include/asm/asmmacro.h
index 809c507d1825..3190157950fa 100644
--- a/arch/xtensa/include/asm/asmmacro.h
+++ b/arch/xtensa/include/asm/asmmacro.h
@@ -191,6 +191,40 @@
#endif
.endm
+ .macro do_nsau cnt, val, tmp, a
+#if XCHAL_HAVE_NSA
+ nsau \cnt, \val
+#else
+ mov \a, \val
+ movi \cnt, 0
+ extui \tmp, \a, 16, 16
+ bnez \tmp, 0f
+ movi \cnt, 16
+ slli \a, \a, 16
+0:
+ extui \tmp, \a, 24, 8
+ bnez \tmp, 1f
+ addi \cnt, \cnt, 8
+ slli \a, \a, 8
+1:
+ movi \tmp, __nsau_data
+ extui \a, \a, 24, 8
+ add \tmp, \tmp, \a
+ l8ui \tmp, \tmp, 0
+ add \cnt, \cnt, \tmp
+#endif /* !XCHAL_HAVE_NSA */
+ .endm
+
+ .macro do_abs dst, src, tmp
+#if XCHAL_HAVE_ABS
+ abs \dst, \src
+#else
+ neg \tmp, \src
+ movgez \tmp, \src, \src
+ mov \dst, \tmp
+#endif
+ .endm
+
#define XTENSA_STACK_ALIGNMENT 16
#if defined(__XTENSA_WINDOWED_ABI__)