4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-20 05:19:21 +08:00

Make macro checks ARMv8-M baseline proof

libgloss:

        * arm/Makefile.in: Add newlib/libc/machine/arm to the include path if
        newlib is present.
        * arm/arm.h: Include acle-compat.h.
        (THUMB_V7_V6M): Rename to ...
        (PREFER_THUMB): This.  Use ACLE macros __ARM_ARCH_ISA_ARM instead of
        __ARM_ARCH_6M__ to decide whether to define it.
        (THUMB1_ONLY): Define for Thumb-1 only targets.
        (THUMB_V7M_V6M): Rename to ...
        (THUMB_VXM): This.  Defined based on __ARM_ARCH_ISA_ARM, excluding
        ARMv7.
        * arm/crt0.S: Use THUMB1_ONLY rather than __ARM_ARCH_6M__,
        !__ARM_ARCH_ISA_ARM rather than THUMB_V7M_V6M for fp enabling, and
        PREFER_THUMB rather than THUMB_V7_V6M.  Rename other occurences of
        THUMB_V7M_V6M to THUMB_VXM.
        * arm/linux-crt0.c: Likewise.
        * arm/redboot-crt0.S: Likewise.
        * arm/swi.h: Likewise.
        * arm/trap.S: Likewise.

newlib:

        * libc/machine/arm/memcpy-stub.c: Use ACLE macros __ARM_ARCH_ISA_THUMB
        and __ARM_ARCH_ISA_ARM to check for Thumb-2 only targets rather than
        __ARM_ARCH and __ARM_ARCH_PROFILE.
        * libc/machine/arm/memcpy.S: Likewise.
        * libc/machine/arm/setjmp.S: Likewise for Thumb-1 only target and
        include acle-compat.h.
        * libc/machine/arm/strcmp.S: Likewise for Thumb-1 and Thumb-2 only
        target and include acle-compat.h.
        * libc/sys/arm/arm.h: Include acle-compat.h.
        (THUMB_V7_V6M): Rename to ...
        (PREFER_THUMB): This.  Use ACLE macro __ARM_ARCH_ISA_ARM instead of
        __ARM_ARCH_6M__ to decide whether to define it.
        (THUMB1_ONLY): Define for Thumb-1 only targets.
        (THUMB_V7M_V6M): Rename to ...
        (THUMB_VXM): This.  Defined based on __ARM_ARCH_ISA_ARM, excluding
        ARMv7.
        * libc/sys/arm/crt0.S: Use PREFER_THUMB rather than THUMB_V7_V6M and
        rename THUMB_V7M_V6M into THUMB_VXM.
        * libc/sys/arm/swi.h: Likewise.
This commit is contained in:
Thomas Preud'homme 2016-01-28 11:26:09 +01:00 committed by Corinna Vinschen
parent 0b42ea7960
commit 69f4c40291
14 changed files with 72 additions and 63 deletions

View File

@ -94,6 +94,8 @@ IQ80310_INSTALL = install-iq80310
# Host specific makefile fragment comes in here. # Host specific makefile fragment comes in here.
@host_makefile_frag@ @host_makefile_frag@
INCLUDES += `if [ -d ${objroot}/newlib ]; then echo -I$(srcroot)/newlib/libc/machine/arm; fi`
# #
# build a test program for each target board. Just trying to get # build a test program for each target board. Just trying to get
# it to link is a good test, so we ignore all the errors for now. # it to link is a good test, so we ignore all the errors for now.

View File

@ -29,25 +29,27 @@
#ifndef _LIBGLOSS_ARM_H #ifndef _LIBGLOSS_ARM_H
#define _LIBGLOSS_ARM_H #define _LIBGLOSS_ARM_H
/* __thumb2__ stands for thumb on armva7(A/R/M/EM) architectures, #include "acle-compat.h"
__ARM_ARCH_6M__ stands for armv6-M(thumb only) architecture,
__ARM_ARCH_7M__ stands for armv7-M(thumb only) architecture. /* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or
__ARM_ARCH_7EM__ stands for armv7e-M(thumb only) architecture. supporting Thumb-2 instructions, whether ARM instructions are available or
There are some macro combinations used many times in libgloss/arm, not, is done many times in libgloss/arm. So factor it out and use
like (__thumb2__ || (__thumb__ && __ARM_ARCH_6M__)), so factor PREFER_THUMB instead. */
it out and use THUMB_V7_V6M instead, which stands for thumb on #if __thumb2__ || (__thumb__ && !__ARM_ARCH_ISA_ARM)
v6-m/v7 arch as the combination does. */ # define PREFER_THUMB
#if defined(__thumb2__) || (defined(__thumb__) && defined(__ARM_ARCH_6M__))
# define THUMB_V7_V6M
#endif #endif
/* The (__ARM_ARCH_7EM__ || __ARM_ARCH_7M__ || __ARM_ARCH_6M__) combination /* Processor only capable of executing Thumb-1 instructions. */
stands for cortex-M profile architectures, which don't support ARM state. #if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM
Factor it out and use THUMB_V7M_V6M instead. */ # define THUMB1_ONLY
#if defined(__ARM_ARCH_7M__) \ #endif
|| defined(__ARM_ARCH_7EM__) \
|| defined(__ARM_ARCH_6M__) /* M profile architectures. This is a different set of architectures than
# define THUMB_V7M_V6M those not having ARM ISA because it does not contain ARMv7. This macro is
necessary to test which architectures use bkpt as semihosting interface from
architectures using svc. */
#if !__ARM_ARCH_ISA_ARM && !__ARM_ARCH_7__
# define THUMB_VXM
#endif #endif
/* Defined if this target supports the BLX Rm instruction. */ /* Defined if this target supports the BLX Rm instruction. */

View File

@ -44,7 +44,7 @@
/* .text is used instead of .section .text so it works with arm-aout too. */ /* .text is used instead of .section .text so it works with arm-aout too. */
.text .text
.syntax unified .syntax unified
#ifdef THUMB_V7_V6M #ifdef PREFER_THUMB
.thumb .thumb
.macro FUNC_START name .macro FUNC_START name
.global \name .global \name
@ -98,7 +98,7 @@
/* stack limit is at end of data */ /* stack limit is at end of data */
/* allow slop for stack overflow handling and small frames */ /* allow slop for stack overflow handling and small frames */
#ifdef __ARM_ARCH_6M__ #ifdef THUMB1_ONLY
ldr r0, .LC2 ldr r0, .LC2
adds r0, #128 adds r0, #128
adds r0, #128 adds r0, #128
@ -112,7 +112,7 @@
/* Issue Angel SWI to read stack info */ /* Issue Angel SWI to read stack info */
movs r0, #AngelSWI_Reason_HeapInfo movs r0, #AngelSWI_Reason_HeapInfo
adr r1, .LC0 /* point at ptr to 4 words to receive data */ adr r1, .LC0 /* point at ptr to 4 words to receive data */
#ifdef THUMB_V7M_V6M #ifdef THUMB_VXM
bkpt AngelSWI bkpt AngelSWI
#elif defined(__thumb2__) #elif defined(__thumb2__)
/* We are in thumb mode for startup on armv7 architectures. */ /* We are in thumb mode for startup on armv7 architectures. */
@ -154,7 +154,7 @@
cmp r2, #0 cmp r2, #0
beq .LC27 beq .LC27
/* allow slop for stack overflow handling and small frames */ /* allow slop for stack overflow handling and small frames */
#ifdef __ARM_ARCH_6M__ #ifdef THUMB1_ONLY
adds r2, #128 adds r2, #128
adds r2, #128 adds r2, #128
mov sl, r2 mov sl, r2
@ -180,7 +180,7 @@
#ifdef __thumb2__ #ifdef __thumb2__
it eq it eq
#endif #endif
#ifdef __ARM_ARCH_6M__ #ifdef THUMB1_ONLY
bne .LC28 bne .LC28
ldr r3, .LC0 ldr r3, .LC0
.LC28: .LC28:
@ -192,7 +192,7 @@
have somehow missed it below (in which case it gets the same have somehow missed it below (in which case it gets the same
value as FIQ - not ideal, but better than nothing.) */ value as FIQ - not ideal, but better than nothing.) */
mov sp, r3 mov sp, r3
#ifdef THUMB_V7_V6M #ifdef PREFER_THUMB
/* XXX Fill in stack assignments for interrupt modes. */ /* XXX Fill in stack assignments for interrupt modes. */
#else #else
mrs r2, CPSR mrs r2, CPSR
@ -235,7 +235,7 @@
this default 64k is enough for the program being executed. this default 64k is enough for the program being executed.
However, it ensures that this simple crt0 world will not However, it ensures that this simple crt0 world will not
immediately cause an overflow event: */ immediately cause an overflow event: */
#ifdef __ARM_ARCH_6M__ #ifdef THUMB1_ONLY
movs r2, #64 movs r2, #64
lsls r2, r2, #10 lsls r2, r2, #10
subs r2, r3, r2 subs r2, r3, r2
@ -255,7 +255,7 @@
subs a3, a3, a1 /* Third arg: length of block */ subs a3, a3, a1 /* Third arg: length of block */
#if defined(__thumb__) && !defined(THUMB_V7_V6M) #if __thumb__ && !defined(PREFER_THUMB)
/* Enter Thumb mode.... */ /* Enter Thumb mode.... */
add a4, pc, #1 /* Get the address of the Thumb block */ add a4, pc, #1 /* Get the address of the Thumb block */
bx a4 /* Go there and start Thumb decoding */ bx a4 /* Go there and start Thumb decoding */
@ -426,7 +426,7 @@ __change_mode:
bl FUNCTION (exit) /* Should not return. */ bl FUNCTION (exit) /* Should not return. */
#if defined(__thumb__) && !defined(THUMB_V7_V6M) #if __thumb__ && !defined(PREFER_THUMB)
/* Come out of Thumb mode. This code should be redundant. */ /* Come out of Thumb mode. This code should be redundant. */
mov a4, pc mov a4, pc

View File

@ -12,7 +12,7 @@
static int _main(int argc, char *argv[]) __attribute__((noreturn)); static int _main(int argc, char *argv[]) __attribute__((noreturn));
#if defined(__thumb__) && !defined(THUMB_V7_V6M) #if __thumb__ && !defined(PREFER_THUMB)
asm("\n" asm("\n"
".code 32\n" ".code 32\n"
".global _start\n" ".global _start\n"

View File

@ -14,7 +14,7 @@
.text .text
.syntax unified .syntax unified
/* Setup the assembly entry point. */ /* Setup the assembly entry point. */
#ifdef THUMB_V7_V6M #ifdef PREFER_THUMB
.macro FUNC_START name .macro FUNC_START name
.global \name .global \name
.thumb_func .thumb_func
@ -31,13 +31,13 @@
FUNC_START SYM_NAME(_start) FUNC_START SYM_NAME(_start)
/* Unnecessary to set fp for v6-m/v7-m, which don't support /* Unnecessary to set fp for v6-m/v7-m, which don't support
ARM state. */ ARM state. */
#ifndef THUMB_V7M_V6M #if __ARM_ARCH_ISA_ARM
mov fp, #0 /* Null frame pointer. */ mov fp, #0 /* Null frame pointer. */
#endif #endif
movs r7, #0 /* Null frame pointer for Thumb. */ movs r7, #0 /* Null frame pointer for Thumb. */
/* Enable interrupts for gdb debugging. */ /* Enable interrupts for gdb debugging. */
#ifdef THUMB_V7_V6M #ifdef PREFER_THUMB
cpsie if cpsie if
#else #else
mrs r0, cpsr mrs r0, cpsr
@ -66,7 +66,7 @@
/* Nothing to left to clear. */ /* Nothing to left to clear. */
#endif #endif
#if defined(__thumb__) && !defined(THUMB_V7_V6M) #if __thumb__ && !defined(PREFER_THUMB)
/* Enter Thumb mode. */ /* Enter Thumb mode. */
add a4, pc, #1 /* Get the address of the Thumb block. */ add a4, pc, #1 /* Get the address of the Thumb block. */
bx a4 /* Go there and start Thumb decoding. */ bx a4 /* Go there and start Thumb decoding. */

View File

@ -36,7 +36,7 @@
#define AngelSWI AngelSWI_ARM #define AngelSWI AngelSWI_ARM
#endif #endif
/* For thumb only architectures use the BKPT instruction instead of SWI. */ /* For thumb only architectures use the BKPT instruction instead of SWI. */
#ifdef THUMB_V7M_V6M #ifdef THUMB_VXM
#define AngelSWIInsn "bkpt" #define AngelSWIInsn "bkpt"
#define AngelSWIAsm bkpt #define AngelSWIAsm bkpt
#else #else

View File

@ -1,6 +1,6 @@
#include "arm.h" #include "arm.h"
/* Run-time exception support */ /* Run-time exception support */
#ifndef THUMB_V7_V6M #ifndef PREFER_THUMB
#include "swi.h" #include "swi.h"
/* .text is used instead of .section .text so it works with arm-aout too. */ /* .text is used instead of .section .text so it works with arm-aout too. */

View File

@ -34,7 +34,7 @@
#elif (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A' \ #elif (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A' \
&& defined (__ARM_FEATURE_UNALIGNED)) && defined (__ARM_FEATURE_UNALIGNED))
/* Defined in memcpy.S. */ /* Defined in memcpy.S. */
#elif __ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'M' #elif __ARM_ARCH_ISA_THUMB == 2 && !__ARM_ARCH_ISA_ARM
/* Defined in memcpy.S. */ /* Defined in memcpy.S. */
#else #else
# include "../../string/memcpy.c" # include "../../string/memcpy.c"

View File

@ -38,7 +38,7 @@
&& defined (__ARM_FEATURE_UNALIGNED)) && defined (__ARM_FEATURE_UNALIGNED))
#include "memcpy-armv7a.S" #include "memcpy-armv7a.S"
#elif __ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'M' #elif __ARM_ARCH_ISA_THUMB == 2 && !__ARM_ARCH_ISA_ARM
#include "memcpy-armv7m.S" #include "memcpy-armv7m.S"
#else #else

View File

@ -2,6 +2,8 @@
Nick Clifton, Cygnus Solutions, 13 June 1997. */ Nick Clifton, Cygnus Solutions, 13 June 1997. */
#include "acle-compat.h"
/* ANSI concatenation macros. */ /* ANSI concatenation macros. */
#define CONCAT(a, b) CONCAT2(a, b) #define CONCAT(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a##b #define CONCAT2(a, b) a##b
@ -55,8 +57,8 @@
For Thumb-2 do everything in Thumb mode. */ For Thumb-2 do everything in Thumb mode. */
#if defined(__ARM_ARCH_6M__) #if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM
/* ARMv6-M has to be implemented in Thumb mode. */ /* ARMv6-M-like has to be implemented in Thumb mode. */
.thumb .thumb
.thumb_func .thumb_func

View File

@ -29,6 +29,7 @@
/* Wrapper for the various implementations of strcmp. */ /* Wrapper for the various implementations of strcmp. */
#include "arm_asm.h" #include "arm_asm.h"
#include "acle-compat.h"
#ifdef __ARM_BIG_ENDIAN #ifdef __ARM_BIG_ENDIAN
#define S2LO lsl #define S2LO lsl
@ -61,7 +62,7 @@
.endm .endm
#if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) \ #if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) \
|| (__ARM_ARCH == 6 && __ARM_ARCH_PROFILE == 'M') || (__ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM)
# if defined (__thumb__) && !defined (__thumb2__) # if defined (__thumb__) && !defined (__thumb2__)
/* Thumb1 only variant. If size is preferred, use strcmp-armv4t.S. /* Thumb1 only variant. If size is preferred, use strcmp-armv4t.S.
@ -78,7 +79,7 @@
# include "strcmp-arm-tiny.S" # include "strcmp-arm-tiny.S"
# endif # endif
#elif __ARM_ARCH >= 7 #elif __ARM_ARCH_ISA_THUMB == 2
# ifdef __ARM_FEATURE_SIMD32 # ifdef __ARM_FEATURE_SIMD32
# include "strcmp-armv7.S" # include "strcmp-armv7.S"

View File

@ -29,25 +29,27 @@
#ifndef _LIBGLOSS_ARM_H #ifndef _LIBGLOSS_ARM_H
#define _LIBGLOSS_ARM_H #define _LIBGLOSS_ARM_H
/* __thumb2__ stands for thumb on armva7(A/R/M/EM) architectures, #include "acle-compat.h"
__ARM_ARCH_6M__ stands for armv6-M(thumb only) architecture,
__ARM_ARCH_7M__ stands for armv7-M(thumb only) architecture. /* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or
__ARM_ARCH_7EM__ stands for armv7e-M(thumb only) architecture. supporting Thumb-2 instructions, whether ARM instructions are available or
There are some macro combinations used many times in libgloss/arm, not, is done many times in libgloss/arm. So factor it out and use
like (__thumb2__ || (__thumb__ && __ARM_ARCH_6M__)), so factor PREFER_THUMB instead. */
it out and use THUMB_V7_V6M instead, which stands for thumb on #if __thumb2__ || (__thumb__ && !__ARM_ARCH_ISA_ARM)
v6-m/v7 arch as the combination does. */ # define PREFER_THUMB
#if defined(__thumb2__) || (defined(__thumb__) && defined(__ARM_ARCH_6M__))
# define THUMB_V7_V6M
#endif #endif
/* The (__ARM_ARCH_7EM__ || __ARM_ARCH_7M__ || __ARM_ARCH_6M__) combination /* Processor only capable of executing Thumb-1 instructions. */
stands for cortex-M profile architectures, which don't support ARM state. #if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM
Factor it out and use THUMB_V7M_V6M instead. */ # define THUMB1_ONLY
#if defined(__ARM_ARCH_7M__) \ #endif
|| defined(__ARM_ARCH_7EM__) \
|| defined(__ARM_ARCH_6M__) /* M profile architectures. This is a different set of architectures than
# define THUMB_V7M_V6M those not having ARM ISA because it does not contain ARMv7. This macro is
necessary to test which architectures use bkpt as semihosting interface from
architectures using svc. */
#if !__ARM_ARCH_ISA_ARM && !__ARM_ARCH_7__
# define THUMB_VXM
#endif #endif
/* Defined if this target supports the BLX Rm instruction. */ /* Defined if this target supports the BLX Rm instruction. */

View File

@ -44,7 +44,7 @@
/* .text is used instead of .section .text so it works with arm-aout too. */ /* .text is used instead of .section .text so it works with arm-aout too. */
.text .text
.syntax unified .syntax unified
#ifdef THUMB_V7_V6M #ifdef PREFER_THUMB
.thumb .thumb
.macro FUNC_START name .macro FUNC_START name
.global \name .global \name
@ -99,7 +99,7 @@
/* Issue Angel SWI to read stack info. */ /* Issue Angel SWI to read stack info. */
movs r0, #AngelSWI_Reason_HeapInfo movs r0, #AngelSWI_Reason_HeapInfo
adr r1, .LC0 /* Point at ptr to 4 words to receive data. */ adr r1, .LC0 /* Point at ptr to 4 words to receive data. */
#ifdef THUMB_V7M_V6M #ifdef THUMB_VXM
bkpt AngelSWI bkpt AngelSWI
#elif defined(__thumb2__) #elif defined(__thumb2__)
/* We are in thumb mode for startup on armv7 architectures. */ /* We are in thumb mode for startup on armv7 architectures. */
@ -176,7 +176,7 @@
have somehow missed it below (in which case it gets the same have somehow missed it below (in which case it gets the same
value as FIQ - not ideal, but better than nothing). */ value as FIQ - not ideal, but better than nothing). */
mov sp, r3 mov sp, r3
#ifdef THUMB_V7_V6M #ifdef PREFER_THUMB
/* XXX Fill in stack assignments for interrupt modes. */ /* XXX Fill in stack assignments for interrupt modes. */
#else #else
mrs r2, CPSR mrs r2, CPSR
@ -239,7 +239,7 @@
subs a3, a3, a1 /* Third arg: length of block. */ subs a3, a3, a1 /* Third arg: length of block. */
#if defined(__thumb__) && !defined(THUMB_V7_V6M) #if __thumb__ && !defined(PREFER_THUMB)
/* Enter Thumb mode... */ /* Enter Thumb mode... */
add a4, pc, #1 /* Get the address of the Thumb block. */ add a4, pc, #1 /* Get the address of the Thumb block. */
bx a4 /* Go there and start Thumb decoding. */ bx a4 /* Go there and start Thumb decoding. */
@ -278,7 +278,7 @@ __change_mode:
#else #else
movs r0, #AngelSWI_Reason_GetCmdLine movs r0, #AngelSWI_Reason_GetCmdLine
adr r1, .LC30 /* Space for command line. */ adr r1, .LC30 /* Space for command line. */
#ifdef THUMB_V7M_V6M #ifdef THUMB_VXM
bkpt AngelSWI bkpt AngelSWI
#else #else
AngelSWIAsm AngelSWI AngelSWIAsm AngelSWI
@ -404,7 +404,7 @@ __change_mode:
bl FUNCTION (exit) /* Should not return. */ bl FUNCTION (exit) /* Should not return. */
#if defined(__thumb__) && !defined(THUMB_V7_V6M) #if __thumb__ && !defined(PREFER_THUMB)
/* Come out of Thumb mode. This code should be redundant. */ /* Come out of Thumb mode. This code should be redundant. */
mov a4, pc mov a4, pc
bx a4 bx a4

View File

@ -36,7 +36,7 @@
#define AngelSWI AngelSWI_ARM #define AngelSWI AngelSWI_ARM
#endif #endif
/* For thumb only architectures use the BKPT instruction instead of SWI. */ /* For thumb only architectures use the BKPT instruction instead of SWI. */
#ifdef THUMB_V7M_V6M #ifdef THUMB_VXM
#define AngelSWIInsn "bkpt" #define AngelSWIInsn "bkpt"
#define AngelSWIAsm bkpt #define AngelSWIAsm bkpt
#else #else