Skip to content

Commit 57ad3fd

Browse files
committed
arch: microblaze: Toolchain: introduce MicroBlaze to build system
Internal references: FWRIVERHD-4980,FWRIVERHD-4991 Signed-off-by: Alp Sayin <alpsayin@gmail.com>
1 parent c3746d7 commit 57ad3fd

File tree

5 files changed

+60
-4
lines changed

5 files changed

+60
-4
lines changed

cmake/compiler/gcc/target.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ elseif("${ARCH}" STREQUAL "sparc")
7676
include(${CMAKE_CURRENT_LIST_DIR}/target_sparc.cmake)
7777
elseif("${ARCH}" STREQUAL "mips")
7878
include(${CMAKE_CURRENT_LIST_DIR}/target_mips.cmake)
79+
elseif("${ARCH}" STREQUAL "microblaze")
80+
include(${CMAKE_CURRENT_LIST_DIR}/target_microblaze.cmake)
7981
endif()
8082

8183
if(SYSROOT_DIR)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
7+
list(APPEND TOOLCHAIN_C_FLAGS -mcpu=${CONFIG_CPU_VERSION})
8+
9+
if(DEFINED CONFIG_DATA_IS_TEXT_RELATIVE)
10+
list(APPEND TOOLCHAIN_C_FLAGS -mpic-data-is-text-relative)
11+
endif()
12+
13+
if(DEFINED CONFIG_USE_BARREL_SHIFT_INSTR)
14+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-barrel-shift)
15+
endif()
16+
17+
if(DEFINED CONFIG_USE_MUL_INSTR)
18+
list(APPEND TOOLCHAIN_C_FLAGS -mno-xl-soft-mul)
19+
else()
20+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-soft-mul)
21+
endif()
22+
23+
if(NOT DEFINED CONFIG_USE_PATTERN_COMPARE_INSTR)
24+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-pattern-compare)
25+
endif()
26+
27+
if(DEFINED CONFIG_USE_MULHI_INSTR)
28+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-multiply-high)
29+
endif()
30+
31+
if(DEFINED CONFIG_USE_DIV_INSTR)
32+
list(APPEND TOOLCHAIN_C_FLAGS -mno-xl-soft-div)
33+
else()
34+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-soft-div)
35+
endif()
36+
37+
if(DEFINED CONFIG_USE_HARDWARE_FLOAT_INSTR)
38+
list(APPEND TOOLCHAIN_C_FLAGS -mhard-float)
39+
else()
40+
list(APPEND TOOLCHAIN_C_FLAGS -msoft-float)
41+
endif()
42+
43+
44+
# Common options
45+
list(APPEND TOOLCHAIN_C_FLAGS -fdollars-in-identifiers)
46+
# TODO: Remove this when gcc microblaze variant oddity is fixed
47+
list(APPEND TOOLCHAIN_C_FLAGS -mlittle-endian)
48+
list(APPEND TOOLCHAIN_LD_FLAGS -mlittle-endian)
49+
50+
# string(REPLACE ";" "\n " str "${TOOLCHAIN_C_FLAGS}")
51+
# message(STATUS "Final set of C Flags: ${str}")

include/zephyr/linker/utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ static inline bool linker_is_in_rodata(const void *addr)
3636
#if defined(CONFIG_ARM) || defined(CONFIG_ARC) || defined(CONFIG_X86) || \
3737
defined(CONFIG_ARM64) || defined(CONFIG_NIOS2) || \
3838
defined(CONFIG_RISCV) || defined(CONFIG_SPARC) || \
39-
defined(CONFIG_MIPS) || defined(CONFIG_XTENSA)
39+
defined(CONFIG_MIPS) || defined(CONFIG_XTENSA) || \
40+
defined(CONFIG_MICROBLAZE)
4041
extern char __rodata_region_start[];
4142
extern char __rodata_region_end[];
4243
#define RO_START __rodata_region_start

include/zephyr/toolchain/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
#define PERFOPT_ALIGN .align 4
8383

8484
#elif defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) || \
85-
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS)
85+
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS) || \
86+
defined(CONFIG_MICROBLAZE)
8687
#define PERFOPT_ALIGN .balign 4
8788

8889
#elif defined(CONFIG_ARCH_POSIX)

include/zephyr/toolchain/gcc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ do { \
337337

338338
#if defined(CONFIG_ARM) || defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) \
339339
|| defined(CONFIG_XTENSA) || defined(CONFIG_ARM64) \
340-
|| defined(CONFIG_MIPS)
340+
|| defined(CONFIG_MIPS) || defined(CONFIG_MICROBLAZE)
341341
#define GTEXT(sym) .global sym; .type sym, %function
342342
#define GDATA(sym) .global sym; .type sym, %object
343343
#define WTEXT(sym) .weak sym; .type sym, %function
@@ -519,7 +519,8 @@ do { \
519519
"\n\t.type\t" #name ",@object")
520520

521521
#elif defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) || \
522-
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS)
522+
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS) || \
523+
defined(CONFIG_MICROBLAZE)
523524

524525
/* No special prefixes necessary for constants in this arch AFAICT */
525526
#define GEN_ABSOLUTE_SYM(name, value) \

0 commit comments

Comments
 (0)