Skip to content

Commit b92c943

Browse files
Add configuration for ARMv7 softfloat build; update setjmp / longjmp ARMv7 implementation to handle the softfloat-mode properly.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
1 parent e39d0ce commit b92c943

File tree

6 files changed

+67
-30
lines changed

6 files changed

+67
-30
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2015 Samsung Electronics Co., Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
set(CMAKE_SYSTEM_NAME Linux)
16+
set(CMAKE_SYSTEM_PROCESSOR armv7l-el)
17+
18+
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
19+
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
20+
21+
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb)

build/configs/toolchain_linux_armv7l-hf.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
set(CMAKE_SYSTEM_NAME Linux)
16-
set(CMAKE_SYSTEM_PROCESSOR armv7l)
16+
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
1717

1818
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
1919
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)

build/configs/toolchain_mcu_stm32f3.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
include(CMakeForceCompiler)
1616

1717
set(CMAKE_SYSTEM_NAME MCU)
18-
set(CMAKE_SYSTEM_PROCESSOR armv7l)
18+
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
1919
set(CMAKE_SYSTEM_VERSION STM32F3)
2020

2121
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)

build/configs/toolchain_mcu_stm32f4.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
include(CMakeForceCompiler)
1616

1717
set(CMAKE_SYSTEM_NAME MCU)
18-
set(CMAKE_SYSTEM_PROCESSOR armv7l)
18+
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)
1919
set(CMAKE_SYSTEM_VERSION STM32F4)
2020

2121
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)

jerry-libc/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ set(COMPILE_FLAGS_LIBC "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
3030
# Architecture-specific
3131
# x86_64
3232
set(DEFINES_LIBC_X86_64 __TARGET_HOST_x64)
33-
# ARMv7
34-
set(DEFINES_LIBC_ARMV7 __TARGET_HOST_ARMv7)
33+
# ARMv7-hf
34+
set(DEFINES_LIBC_ARMV7_HF __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_HARD_FLOAT)
35+
# ARMv7-el
36+
set(DEFINES_LIBC_ARMV7_EL __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_SOFT_FLOAT)
3537
# x86
3638
set(DEFINES_LIBC_X86 __TARGET_HOST_x86)
3739

@@ -93,8 +95,10 @@ set(COMPILE_FLAGS_LIBC "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
9395
# Architecture-specific configuration
9496
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
9597
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_X86_64})
96-
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
97-
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7})
98+
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-hf")
99+
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7_HF})
100+
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-el")
101+
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7_EL})
98102
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
99103
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_X86})
100104
else()

jerry-libc/arch/arm-v7.h

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@
9999
1: \
100100
b 1b
101101

102+
/**
103+
* If hard-float mode:
104+
* store s16-s31 vfp registers to buffer, pointed with r0 register,
105+
* and increase the register on size of stored data.
106+
*/
107+
#ifdef __TARGET_HOST_ARMv7_HARD_FLOAT
108+
# define _STORE_VFP_S16_S31_IF_HARD_FLOAT \
109+
vstm r0!, {s16 - s31};
110+
# define _LOAD_VFP_S16_S31_IF_HARD_FLOAT \
111+
vldm r0!, {s16 - s31};
112+
#else /* !__TARGET_HOST_ARMv7_HARD_FLOAT */
113+
# define _STORE_VFP_S16_S31_IF_HARD_FLOAT
114+
# define _LOAD_VFP_S16_S31_IF_HARD_FLOAT
115+
#endif /* !__TARGET_HOST_ARMv7_HARD_FLOAT */
102116

103117
/*
104118
* setjmp
@@ -107,28 +121,27 @@
107121
* registers are callee-saved, and so need to be stored in context:
108122
* - r4 - r11
109123
* - sp
110-
* - s16-s31
124+
* - s16 - s31
111125
*
112126
* Also, we should store:
113127
* - lr
114128
*
115129
* stmia {r4-r11, sp, lr} -> jmp_buf_0 (r0)!
116130
*
117-
* FIXME:
118-
* vstm should not be performed in softfp mode
119-
* vstm {s16-s31} -> jmp_buf_32 (r0)!
131+
* If hard-float build
132+
* vstm {s16-s31} -> jmp_buf_32 (r0)!
120133
*
121134
* mov r0, #0
122135
*
123136
* bx lr
124137
*/
125138
#define _SETJMP \
126-
stmia r0!, {r4 - r11, sp, lr}; \
127-
\
128-
vstm r0!, {s16 - s31}; \
129-
\
130-
mov r0, #0; \
131-
\
139+
stmia r0!, {r4 - r11, sp, lr}; \
140+
\
141+
_STORE_VFP_S16_S31_IF_HARD_FLOAT \
142+
\
143+
mov r0, #0; \
144+
\
132145
bx lr;
133146

134147
/*
@@ -139,9 +152,8 @@
139152
*
140153
* ldmia jmp_buf_0 (r0)! -> {r4-r11, sp, lr}
141154
*
142-
* FIXME:
143-
* vstm should not be performed in softfp mode
144-
* vldm jmp_buf_32 (r0)! -> {s16-s31}
155+
* If hard-float build
156+
* vldm jmp_buf_32 (r0)! -> {s16-s31}
145157
*
146158
* mov r1 -> r0
147159
* cmp r0, #0
@@ -152,16 +164,16 @@
152164
* bx lr
153165
*/
154166
#define _LONGJMP \
155-
ldmia r0!, {r4 - r11, sp, lr}; \
156-
\
157-
vldm r0!, {s16 - s31}; \
158-
\
159-
mov r0, r1; \
160-
cmp r0, #0; \
161-
bne 1f; \
162-
mov r0, #1; \
163-
1: \
164-
\
167+
ldmia r0!, {r4 - r11, sp, lr}; \
168+
\
169+
_LOAD_VFP_S16_S31_IF_HARD_FLOAT \
170+
\
171+
mov r0, r1; \
172+
cmp r0, #0; \
173+
bne 1f; \
174+
mov r0, #1; \
175+
1: \
176+
\
165177
bx lr;
166178

167179
#endif /* !ASM_ARM_H */

0 commit comments

Comments
 (0)