sh-generic: add CPU capabilities for optimized SH4 code

On sh-generic targets, the headers <bits/cpucap.h> (in C) and
<bits/asm/cpucap.h> (in assembler) provide definitions to acces the
__cpucap symbol which provides information on the CPU.

Currently, a single capability __CPUCAP_SH4ALDSP is defined; it
represents the SH4 extended instructions together with the integrated
DSP instructions. The main uses of this capability are [movua.l]
(unaligned reads) and [ldrc] (built-in tight loops).

Capabilities are initialized to 0 (their safest default) and the runtime
can enable them based on what hardware is running.
This commit is contained in:
Lephenixnoir 2021-05-23 15:31:01 +02:00
parent 53751aa9a1
commit 591e453717
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
4 changed files with 23 additions and 1 deletions

View file

@ -168,7 +168,8 @@ if(sh-generic IN_LIST TARGET_FOLDERS)
list(APPEND SOURCES
src/libc/setjmp/target/sh-generic/setjmp.S
src/libc/setjmp/target/sh-generic/longjmp.S
src/libc/string/target/sh-generic/memchr.S)
src/libc/string/target/sh-generic/memchr.S
src/target/sh-generic/cpucap.c)
endif()
if(casiowin-fx IN_LIST TARGET_FOLDERS)

View file

@ -0,0 +1,9 @@
#ifndef __BITS_ASM_CPUCAP_H__
# define __BITS_ASM_CPUCAP_H__
/* CPU capabilities for assembler code. See also <bits/cpucap.h>. */
/* CPU supports the SH4AL-DSP instruction set (with DSP turned on). */
#define __CPUCAP_SH4ALDSP 0x01
#endif /*__BITS_ASM_CPUCAP_H__*/

View file

@ -0,0 +1,9 @@
#ifndef __BITS_CPUCAP_H__
# define __BITS_CPUCAP_H__
#include <bits/asm/cpucap.h>
/* CPU flags determined at runtime. */
extern int __cpucap;
#endif /*__BITS_CPUCAP_H__*/

View file

@ -0,0 +1,3 @@
#include <bits/cpucap.h>
int __cpucap = 0;