Skip to content

Commit 39ede67

Browse files
committed
Enable GP Relaxation optimization
- Enabled `-mrelax` compiler flag in CMake configuration. - Updated entry.s to correctly initialize the Global Pointer (`gp`) using the `__global_pointer$` symbol. - Verified that `gp` is treated as a constant and no longer saved/restored during context switches, improving performance.
1 parent ae13c5b commit 39ede67

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

cmake/riscv32_gnu.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(CMAKE_SYSTEM_PROCESSOR risc-v32)
44

55
set(THREADX_ARCH "risc-v32")
66
set(THREADX_TOOLCHAIN "gnu")
7-
set(ARCH_FLAGS "-g -march=rv32gc -mabi=ilp32d -mcmodel=medany")
7+
set(ARCH_FLAGS "-g -march=rv32gc -mabi=ilp32d -mcmodel=medany -mrelax")
88
set(CFLAGS "${ARCH_FLAGS}")
99
set(ASFLAGS "${ARCH_FLAGS}")
1010
set(LDFLAGS "${ARCH_FLAGS}")

ports/risc-v32/gnu/example_build/qemu_virt/entry.s

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ _start:
1111
bne t0, zero, 1f
1212
li x1, 0
1313
li x2, 0
14-
li x3, 0
14+
.option push
15+
.option norelax
16+
la gp, __global_pointer$
17+
.option pop
1518
li x4, 0
1619
li x5, 0
1720
li x6, 0

0 commit comments

Comments
 (0)