Skip to content

Commit ee07eba

Browse files
fkokosinskikartben
authored andcommitted
arch/riscv: add Zaamo and Zlrsc extension subsets
The Zaamo and Zalrsc Extension (Version v1.0.0, 2024-04-25; Ratified) split the standard A extension into two subextensions. As of date, the `_zaamo` and `_zlrsc` extension specifications are accepted by the upstream in-development GCC through the `march` argument. This means that those subextensions are not yet supported by GCC shipped with Zephyr SDK. Signed-off-by: Filip Kokosinski <[email protected]>
1 parent a93a302 commit ee07eba

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

arch/riscv/Kconfig.isa

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ config RISCV_ISA_EXT_M
3333

3434
config RISCV_ISA_EXT_A
3535
bool
36+
imply RISCV_ISA_EXT_ZAAMO
37+
imply RISCV_ISA_EXT_ZLRSC
3638
help
3739
(A) - Standard Extension for Atomic Instructions
3840

@@ -111,6 +113,20 @@ config RISCV_ISA_EXT_ZIFENCEI
111113
provides explicit synchronization between writes to instruction
112114
memory and instruction fetches on the same hart.
113115

116+
config RISCV_ISA_EXT_ZAAMO
117+
bool
118+
help
119+
(Zaamo) - Atomic memory operation subset of the A extension
120+
121+
The Zaamo extension enables support for AMO*.W/D-style instructions.
122+
123+
config RISCV_ISA_EXT_ZLRSC
124+
bool
125+
help
126+
(Zlrsc) - Load-Reserved/Store-Conditional subset of the A extension
127+
128+
The Zlrsc extension enables support for LR.W/D and SC.W/D-style instructions.
129+
114130
config RISCV_ISA_EXT_ZBA
115131
bool
116132
help

cmake/compiler/gcc/target_riscv.cmake

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ if(CONFIG_RISCV_ISA_EXT_ZIFENCEI)
5353
string(CONCAT riscv_march ${riscv_march} "_zifencei")
5454
endif()
5555

56+
# Check whether we already imply Zaamo/Zlrsc by selecting the A extension; if not - check them
57+
# individually and enable them as needed
58+
if(NOT CONFIG_RISCV_ISA_EXT_A)
59+
if(CONFIG_RISCV_ISA_EXT_ZAAMO)
60+
string(CONCAT riscv_march ${riscv_march} "_zaamo")
61+
endif()
62+
63+
if(CONFIG_RISCV_ISA_EXT_ZLRSC)
64+
string(CONCAT riscv_march ${riscv_march} "_zlrsc")
65+
endif()
66+
endif()
67+
5668
if(CONFIG_RISCV_ISA_EXT_ZBA)
5769
string(CONCAT riscv_march ${riscv_march} "_zba")
5870
endif()
@@ -90,4 +102,4 @@ set(LLEXT_APPEND_FLAGS
90102
-mabi=${riscv_mabi}
91103
-march=${riscv_march}
92104
-mno-relax
93-
)
105+
)

0 commit comments

Comments
 (0)