Browse Source

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.
master
Lephenixnoir 8 months ago
parent
commit
591e453717
Signed by: Lephenixnoir GPG Key ID: 1BBA026E13FC0495
  1. 3
      CMakeLists.txt
  2. 9
      include/target/sh-generic/bits/asm/cpucap.h
  3. 9
      include/target/sh-generic/bits/cpucap.h
  4. 3
      src/target/sh-generic/cpucap.c

3
CMakeLists.txt

@ -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)

9
include/target/sh-generic/bits/asm/cpucap.h

@ -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__*/

9
include/target/sh-generic/bits/cpucap.h

@ -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__*/

3
src/target/sh-generic/cpucap.c

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