arch: arm: aarch32: Allow selecting compiler instruction set
This commit introduces the `COMPILER_ISA_THUMB2` symbol to allow choosing either the ARM or Thumb instruction set for C code compilation. In addition, this commit introduces the `ASSEMBLER_ISA_THUMB2` helper symbol to specify the default target instruction set for the assembler. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
parent
e89881f532
commit
0bd86f3604
4 changed files with 55 additions and 22 deletions
|
@ -76,6 +76,38 @@ config ISA_ARM
|
|||
processor start-up. Much of its functionality was subsumed into T32 with
|
||||
the introduction of Thumb-2 technology.
|
||||
|
||||
config ASSEMBLER_ISA_THUMB2
|
||||
bool
|
||||
default y if ISA_THUMB2 && !ISA_ARM
|
||||
depends on !ISA_ARM
|
||||
help
|
||||
This helper symbol specifies the default target instruction set for
|
||||
the assembler.
|
||||
|
||||
When only the Thumb-2 ISA is supported (i.e. on Cortex-M cores), the
|
||||
assembler must use the Thumb-2 instruction set.
|
||||
|
||||
When both the Thumb-2 and ARM ISAs are supported (i.e. on Cortex-A
|
||||
and Cortex-R cores), the assembler must use the ARM instruction set
|
||||
because the architecture assembly code makes use of the ARM
|
||||
instructions.
|
||||
|
||||
config COMPILER_ISA_THUMB2
|
||||
bool "Compile C/C++ functions using Thumb-2 instruction set"
|
||||
depends on ISA_THUMB2
|
||||
default y
|
||||
help
|
||||
This option configures the compiler to compile all C/C++ functions
|
||||
using the Thumb-2 instruction set.
|
||||
|
||||
N.B. The scope of this symbol is not necessarily limited to the C and
|
||||
C++ languages; in fact, this symbol refers to all forms of
|
||||
"compiled" code.
|
||||
|
||||
When an additional natively-compiled language support is added
|
||||
in the future, this symbol shall also specify the Thumb-2
|
||||
instruction set for that language.
|
||||
|
||||
config NUM_IRQS
|
||||
int
|
||||
|
||||
|
|
|
@ -135,9 +135,13 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
|||
thread->callee_saved.psp = (u32_t)pInitCtx;
|
||||
#if defined(CONFIG_CPU_CORTEX_R)
|
||||
pInitCtx->basic.lr = (u32_t)pInitCtx->basic.pc;
|
||||
thread->callee_saved.spsr = A_BIT | T_BIT | MODE_SYS;
|
||||
thread->callee_saved.lr = (u32_t)pInitCtx->basic.pc;
|
||||
thread->callee_saved.spsr = A_BIT | MODE_SYS;
|
||||
#if defined(CONFIG_COMPILER_ISA_THUMB2)
|
||||
thread->callee_saved.spsr |= T_BIT;
|
||||
#endif
|
||||
|
||||
thread->callee_saved.lr = (u32_t)pInitCtx->basic.pc;
|
||||
#endif /* CONFIG_CPU_CORTEX_R */
|
||||
thread->arch.basepri = 0;
|
||||
|
||||
#if defined(CONFIG_USERSPACE) || defined(CONFIG_FP_SHARING)
|
||||
|
|
|
@ -7,14 +7,13 @@ if(CONFIG_ARM64)
|
|||
-mcpu=${GCC_M_CPU}
|
||||
)
|
||||
else()
|
||||
list(APPEND TOOLCHAIN_C_FLAGS
|
||||
-mthumb
|
||||
-mcpu=${GCC_M_CPU}
|
||||
)
|
||||
list(APPEND TOOLCHAIN_LD_FLAGS
|
||||
-mthumb
|
||||
-mcpu=${GCC_M_CPU}
|
||||
)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mcpu=${GCC_M_CPU})
|
||||
list(APPEND TOOLCHAIN_LD_FLAGS -mcpu=${GCC_M_CPU})
|
||||
|
||||
if(CONFIG_COMPILER_ISA_THUMB2)
|
||||
list(APPEND TOOLCHAIN_C_FLAGS -mthumb)
|
||||
list(APPEND TOOLCHAIN_LD_FLAGS -mthumb)
|
||||
endif()
|
||||
|
||||
# Defines a mapping from GCC_M_CPU to FPU
|
||||
|
||||
|
|
|
@ -232,28 +232,24 @@ do { \
|
|||
|
||||
#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
|
||||
|
||||
#if defined(CONFIG_ISA_THUMB2)
|
||||
#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
|
||||
|
||||
#define FUNC_CODE() .thumb;
|
||||
#define FUNC_INSTR(a)
|
||||
|
||||
#elif defined(CONFIG_ISA_ARM)
|
||||
#else
|
||||
|
||||
#define FUNC_CODE() .code 32
|
||||
#define FUNC_INSTR(a)
|
||||
|
||||
#else
|
||||
|
||||
#error unknown instruction set
|
||||
|
||||
#endif /* ISA */
|
||||
#endif /* CONFIG_ASSEMBLER_ISA_THUMB2 */
|
||||
|
||||
#else
|
||||
|
||||
#define FUNC_CODE()
|
||||
#define FUNC_INSTR(a)
|
||||
|
||||
#endif /* !CONFIG_ARM */
|
||||
#endif /* CONFIG_ARM && !CONFIG_ARM64 */
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
|
@ -359,14 +355,16 @@ do { \
|
|||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#if defined(CONFIG_ARM) && defined(_ASMLANGUAGE)
|
||||
#if defined(CONFIG_ISA_THUMB2)
|
||||
#if defined(_ASMLANGUAGE)
|
||||
#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
|
||||
#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
|
||||
/* '.syntax unified' is a gcc-ism used in thumb-2 asm files */
|
||||
#define _ASM_FILE_PROLOGUE .text; .syntax unified; .thumb
|
||||
#else
|
||||
#define _ASM_FILE_PROLOGUE .text; .code 32
|
||||
#endif
|
||||
#endif
|
||||
#endif /* CONFIG_ASSEMBLER_ISA_THUMB2 */
|
||||
#endif /* CONFIG_ARM && !CONFIG_ARM64 */
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
/*
|
||||
* These macros generate absolute symbols for GCC
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue