Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Preud'homme <thomas.preudhomme@foss.arm.com>2016-01-28 13:26:09 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-01-28 13:26:37 +0300
commit69f4c4029183fb26d2fcae00790881620c1978a3 (patch)
tree87f94f7e721f1f8b83117a9ffb1e007fc969f729 /libgloss/arm
parent0b42ea79606c46f730e4f2427cc8244f85bdac98 (diff)
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.
Diffstat (limited to 'libgloss/arm')
-rw-r--r--libgloss/arm/Makefile.in2
-rw-r--r--libgloss/arm/arm.h36
-rw-r--r--libgloss/arm/crt0.S18
-rw-r--r--libgloss/arm/linux-crt0.c2
-rw-r--r--libgloss/arm/redboot-crt0.S8
-rw-r--r--libgloss/arm/swi.h2
-rw-r--r--libgloss/arm/trap.S2
7 files changed, 37 insertions, 33 deletions
diff --git a/libgloss/arm/Makefile.in b/libgloss/arm/Makefile.in
index 6e89cfb03..3f87deae2 100644
--- a/libgloss/arm/Makefile.in
+++ b/libgloss/arm/Makefile.in
@@ -94,6 +94,8 @@ IQ80310_INSTALL = install-iq80310
# Host specific makefile fragment comes in here.
@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
# it to link is a good test, so we ignore all the errors for now.
diff --git a/libgloss/arm/arm.h b/libgloss/arm/arm.h
index 26a1ff110..0489f2d92 100644
--- a/libgloss/arm/arm.h
+++ b/libgloss/arm/arm.h
@@ -29,25 +29,27 @@
#ifndef _LIBGLOSS_ARM_H
#define _LIBGLOSS_ARM_H
-/* __thumb2__ stands for thumb on armva7(A/R/M/EM) architectures,
- __ARM_ARCH_6M__ stands for armv6-M(thumb only) architecture,
- __ARM_ARCH_7M__ stands for armv7-M(thumb only) architecture.
- __ARM_ARCH_7EM__ stands for armv7e-M(thumb only) architecture.
- There are some macro combinations used many times in libgloss/arm,
- like (__thumb2__ || (__thumb__ && __ARM_ARCH_6M__)), so factor
- it out and use THUMB_V7_V6M instead, which stands for thumb on
- v6-m/v7 arch as the combination does. */
-#if defined(__thumb2__) || (defined(__thumb__) && defined(__ARM_ARCH_6M__))
-# define THUMB_V7_V6M
+#include "acle-compat.h"
+
+/* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or
+ supporting Thumb-2 instructions, whether ARM instructions are available or
+ not, is done many times in libgloss/arm. So factor it out and use
+ PREFER_THUMB instead. */
+#if __thumb2__ || (__thumb__ && !__ARM_ARCH_ISA_ARM)
+# define PREFER_THUMB
+#endif
+
+/* Processor only capable of executing Thumb-1 instructions. */
+#if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM
+# define THUMB1_ONLY
#endif
-/* The (__ARM_ARCH_7EM__ || __ARM_ARCH_7M__ || __ARM_ARCH_6M__) combination
- stands for cortex-M profile architectures, which don't support ARM state.
- Factor it out and use THUMB_V7M_V6M instead. */
-#if defined(__ARM_ARCH_7M__) \
- || defined(__ARM_ARCH_7EM__) \
- || defined(__ARM_ARCH_6M__)
-# define THUMB_V7M_V6M
+/* M profile architectures. This is a different set of architectures than
+ 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
/* Defined if this target supports the BLX Rm instruction. */
diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S
index cb9021df3..7c662f915 100644
--- a/libgloss/arm/crt0.S
+++ b/libgloss/arm/crt0.S
@@ -44,7 +44,7 @@
/* .text is used instead of .section .text so it works with arm-aout too. */
.text
.syntax unified
-#ifdef THUMB_V7_V6M
+#ifdef PREFER_THUMB
.thumb
.macro FUNC_START name
.global \name
@@ -98,7 +98,7 @@
/* stack limit is at end of data */
/* allow slop for stack overflow handling and small frames */
-#ifdef __ARM_ARCH_6M__
+#ifdef THUMB1_ONLY
ldr r0, .LC2
adds r0, #128
adds r0, #128
@@ -112,7 +112,7 @@
/* Issue Angel SWI to read stack info */
movs r0, #AngelSWI_Reason_HeapInfo
adr r1, .LC0 /* point at ptr to 4 words to receive data */
-#ifdef THUMB_V7M_V6M
+#ifdef THUMB_VXM
bkpt AngelSWI
#elif defined(__thumb2__)
/* We are in thumb mode for startup on armv7 architectures. */
@@ -154,7 +154,7 @@
cmp r2, #0
beq .LC27
/* allow slop for stack overflow handling and small frames */
-#ifdef __ARM_ARCH_6M__
+#ifdef THUMB1_ONLY
adds r2, #128
adds r2, #128
mov sl, r2
@@ -180,7 +180,7 @@
#ifdef __thumb2__
it eq
#endif
-#ifdef __ARM_ARCH_6M__
+#ifdef THUMB1_ONLY
bne .LC28
ldr r3, .LC0
.LC28:
@@ -192,7 +192,7 @@
have somehow missed it below (in which case it gets the same
value as FIQ - not ideal, but better than nothing.) */
mov sp, r3
-#ifdef THUMB_V7_V6M
+#ifdef PREFER_THUMB
/* XXX Fill in stack assignments for interrupt modes. */
#else
mrs r2, CPSR
@@ -235,7 +235,7 @@
this default 64k is enough for the program being executed.
However, it ensures that this simple crt0 world will not
immediately cause an overflow event: */
-#ifdef __ARM_ARCH_6M__
+#ifdef THUMB1_ONLY
movs r2, #64
lsls r2, r2, #10
subs r2, r3, r2
@@ -255,7 +255,7 @@
subs a3, a3, a1 /* Third arg: length of block */
-#if defined(__thumb__) && !defined(THUMB_V7_V6M)
+#if __thumb__ && !defined(PREFER_THUMB)
/* Enter Thumb mode.... */
add a4, pc, #1 /* Get the address of the Thumb block */
bx a4 /* Go there and start Thumb decoding */
@@ -426,7 +426,7 @@ __change_mode:
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. */
mov a4, pc
diff --git a/libgloss/arm/linux-crt0.c b/libgloss/arm/linux-crt0.c
index c313d269f..878ece765 100644
--- a/libgloss/arm/linux-crt0.c
+++ b/libgloss/arm/linux-crt0.c
@@ -12,7 +12,7 @@
static int _main(int argc, char *argv[]) __attribute__((noreturn));
-#if defined(__thumb__) && !defined(THUMB_V7_V6M)
+#if __thumb__ && !defined(PREFER_THUMB)
asm("\n"
".code 32\n"
".global _start\n"
diff --git a/libgloss/arm/redboot-crt0.S b/libgloss/arm/redboot-crt0.S
index 1d902286e..0e3a9b4e2 100644
--- a/libgloss/arm/redboot-crt0.S
+++ b/libgloss/arm/redboot-crt0.S
@@ -14,7 +14,7 @@
.text
.syntax unified
/* Setup the assembly entry point. */
-#ifdef THUMB_V7_V6M
+#ifdef PREFER_THUMB
.macro FUNC_START name
.global \name
.thumb_func
@@ -31,13 +31,13 @@
FUNC_START SYM_NAME(_start)
/* Unnecessary to set fp for v6-m/v7-m, which don't support
ARM state. */
-#ifndef THUMB_V7M_V6M
+#if __ARM_ARCH_ISA_ARM
mov fp, #0 /* Null frame pointer. */
#endif
movs r7, #0 /* Null frame pointer for Thumb. */
/* Enable interrupts for gdb debugging. */
-#ifdef THUMB_V7_V6M
+#ifdef PREFER_THUMB
cpsie if
#else
mrs r0, cpsr
@@ -66,7 +66,7 @@
/* Nothing to left to clear. */
#endif
-#if defined(__thumb__) && !defined(THUMB_V7_V6M)
+#if __thumb__ && !defined(PREFER_THUMB)
/* Enter Thumb mode. */
add a4, pc, #1 /* Get the address of the Thumb block. */
bx a4 /* Go there and start Thumb decoding. */
diff --git a/libgloss/arm/swi.h b/libgloss/arm/swi.h
index 0f9313447..b7fa243f8 100644
--- a/libgloss/arm/swi.h
+++ b/libgloss/arm/swi.h
@@ -36,7 +36,7 @@
#define AngelSWI AngelSWI_ARM
#endif
/* For thumb only architectures use the BKPT instruction instead of SWI. */
-#ifdef THUMB_V7M_V6M
+#ifdef THUMB_VXM
#define AngelSWIInsn "bkpt"
#define AngelSWIAsm bkpt
#else
diff --git a/libgloss/arm/trap.S b/libgloss/arm/trap.S
index 9eb39069a..d854b57bb 100644
--- a/libgloss/arm/trap.S
+++ b/libgloss/arm/trap.S
@@ -1,6 +1,6 @@
#include "arm.h"
/* Run-time exception support */
-#ifndef THUMB_V7_V6M
+#ifndef PREFER_THUMB
#include "swi.h"
/* .text is used instead of .section .text so it works with arm-aout too. */