Skip to content

Commit 042c51d

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 6be0d41 commit 042c51d

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
@@ -78,6 +78,8 @@ elseif("${ARCH}" STREQUAL "mips")
7878
include(${CMAKE_CURRENT_LIST_DIR}/target_mips.cmake)
7979
elseif("${ARCH}" STREQUAL "xtensa")
8080
include(${CMAKE_CURRENT_LIST_DIR}/target_xtensa.cmake)
81+
elseif("${ARCH}" STREQUAL "microblaze")
82+
include(${CMAKE_CURRENT_LIST_DIR}/target_microblaze.cmake)
8183
endif()
8284

8385
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_MICROBLAZE_DATA_IS_TEXT_RELATIVE)
10+
list(APPEND TOOLCHAIN_C_FLAGS -mpic-data-is-text-relative)
11+
endif()
12+
13+
if(DEFINED CONFIG_MICROBLAZE_USE_BARREL_SHIFT_INSTR)
14+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-barrel-shift)
15+
endif()
16+
17+
if(DEFINED CONFIG_MICROBLAZE_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_MICROBLAZE_USE_PATTERN_COMPARE_INSTR)
24+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-pattern-compare)
25+
endif()
26+
27+
if(DEFINED CONFIG_MICROBLAZE_USE_MULHI_INSTR)
28+
list(APPEND TOOLCHAIN_C_FLAGS -mxl-multiply-high)
29+
endif()
30+
31+
if(DEFINED CONFIG_MICROBLAZE_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_MICROBLAZE_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
@@ -87,7 +87,8 @@
8787
#define PERFOPT_ALIGN .align 4
8888

8989
#elif defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) || \
90-
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS)
90+
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS) || \
91+
defined(CONFIG_MICROBLAZE)
9192
#define PERFOPT_ALIGN .balign 4
9293

9394
#elif defined(CONFIG_ARCH_POSIX)

include/zephyr/toolchain/gcc.h

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

353353
#if defined(CONFIG_ARM) || defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) \
354354
|| defined(CONFIG_XTENSA) || defined(CONFIG_ARM64) \
355-
|| defined(CONFIG_MIPS)
355+
|| defined(CONFIG_MIPS) || defined(CONFIG_MICROBLAZE)
356356
#define GTEXT(sym) .global sym; .type sym, %function
357357
#define GDATA(sym) .global sym; .type sym, %object
358358
#define WTEXT(sym) .weak sym; .type sym, %function
@@ -534,7 +534,8 @@ do { \
534534
"\n\t.type\t" #name ",@object")
535535

536536
#elif defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) || \
537-
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS)
537+
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS) || \
538+
defined(CONFIG_MICROBLAZE)
538539

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

0 commit comments

Comments
 (0)