@@ -31,11 +31,11 @@ macro_rules! cfg_global_asm {
3131// - https://github.com/llvm/llvm-project/issues/61991
3232cfg_global_asm ! (
3333 "// Provisional patch to avoid LLVM spurious errors when compiling in release mode." ,
34- #[ cfg( all( riscv32, riscvm) ) ]
34+ #[ cfg( all( target_arch = " riscv32" , riscvm) ) ]
3535 ".attribute arch, \" rv32im\" " ,
36- #[ cfg( all( riscv64, riscvm, not( riscvg) ) ) ]
36+ #[ cfg( all( target_arch = " riscv64" , riscvm, not( riscvg) ) ) ]
3737 ".attribute arch, \" rv64im\" " ,
38- #[ cfg( all( riscv64, riscvg) ) ]
38+ #[ cfg( all( target_arch = " riscv64" , riscvg) ) ]
3939 ".attribute arch, \" rv64g\" " ,
4040) ;
4141
@@ -47,10 +47,10 @@ cfg_global_asm!(
4747 .global _start
4848
4949_start:" ,
50- #[ cfg( riscv32) ]
50+ #[ cfg( target_arch = " riscv32" ) ]
5151 "lui ra, %hi(_abs_start)
5252 jr %lo(_abs_start)(ra)" ,
53- #[ cfg( riscv64) ]
53+ #[ cfg( target_arch = " riscv64" ) ]
5454 ".option push
5555 .option norelax // to prevent an unsupported R_RISCV_ALIGN relocation from being generated
56561:
@@ -84,7 +84,9 @@ _abs_start:
8484// ZERO OUT GENERAL-PURPOSE REGISTERS
8585riscv_rt_macros:: loop_global_asm!( " li x{}, 0" , 1 , 10 ) ;
8686// a0..a2 (x10..x12) skipped
87- riscv_rt_macros:: loop_global_asm!( " li x{}, 0" , 13 , 32 ) ;
87+ riscv_rt_macros:: loop_global_asm!( " li x{}, 0" , 13 , 16 ) ;
88+ #[ cfg( not( riscve) ) ]
89+ riscv_rt_macros:: loop_global_asm!( " li x{}, 0" , 16 , 32 ) ;
8890
8991// INITIALIZE GLOBAL POINTER, STACK POINTER, AND FRAME POINTER
9092cfg_global_asm ! (
@@ -125,12 +127,12 @@ cfg_global_asm!(
125127
126128// STORE A0..A2 IN THE STACK, AS THEY WILL BE NEEDED LATER BY main
127129cfg_global_asm ! (
128- #[ cfg( riscv32) ]
130+ #[ cfg( target_arch = " riscv32" ) ]
129131 "addi sp, sp, -4 * 3
130132 sw a0, 4 * 0(sp)
131133 sw a1, 4 * 1(sp)
132134 sw a2, 4 * 2(sp)" ,
133- #[ cfg( riscv64) ]
135+ #[ cfg( target_arch = " riscv64" ) ]
134136 "addi sp, sp, -8 * 3
135137 sd a0, 8 * 0(sp)
136138 sd a1, 8 * 1(sp)
@@ -202,22 +204,22 @@ cfg_global_asm!(
202204 "fscsr x0" ,
203205) ;
204206// ZERO OUT FLOATING POINT REGISTERS
205- #[ cfg( all( riscv32, riscvd) ) ]
207+ #[ cfg( all( target_arch = " riscv32" , riscvd) ) ]
206208riscv_rt_macros:: loop_global_asm!( " fcvt.d.w f{}, x0" , 32 ) ;
207- #[ cfg( all( riscv64, riscvd) ) ]
209+ #[ cfg( all( target_arch = " riscv64" , riscvd) ) ]
208210riscv_rt_macros:: loop_global_asm!( " fmv.d.x f{}, x0" , 32 ) ;
209211#[ cfg( all( riscvf, not( riscvd) ) ) ]
210212riscv_rt_macros:: loop_global_asm!( " fmv.w.x f{}, x0" , 32 ) ;
211213
212214// SET UP INTERRUPTS, RESTORE a0..a2, AND JUMP TO MAIN RUST FUNCTION
213215cfg_global_asm ! (
214216 "call _setup_interrupts" ,
215- #[ cfg( riscv32) ]
217+ #[ cfg( target_arch = " riscv32" ) ]
216218 "lw a0, 4 * 0(sp)
217219 lw a1, 4 * 1(sp)
218220 lw a2, 4 * 2(sp)
219221 addi sp, sp, 4 * 3" ,
220- #[ cfg( riscv64) ]
222+ #[ cfg( target_arch = " riscv64" ) ]
221223 "ld a0, 8 * 0(sp)
222224 ld a1, 8 * 1(sp)
223225 ld a2, 8 * 2(sp)
@@ -276,14 +278,14 @@ _pre_init_trap:
276278 j _pre_init_trap" ,
277279) ;
278280
279- #[ cfg( riscv32) ]
281+ #[ cfg( target_arch = " riscv32" ) ]
280282riscv_rt_macros:: weak_start_trap_riscv32!( ) ;
281- #[ cfg( riscv64) ]
283+ #[ cfg( target_arch = " riscv64" ) ]
282284riscv_rt_macros:: weak_start_trap_riscv64!( ) ;
283285
284- #[ cfg( all( riscv32, feature = "v-trap" ) ) ]
286+ #[ cfg( all( target_arch = " riscv32" , feature = "v-trap" ) ) ]
285287riscv_rt_macros:: vectored_interrupt_trap_riscv32!( ) ;
286- #[ cfg( all( riscv64, feature = "v-trap" ) ) ]
288+ #[ cfg( all( target_arch = " riscv64" , feature = "v-trap" ) ) ]
287289riscv_rt_macros:: vectored_interrupt_trap_riscv64!( ) ;
288290
289291#[ rustfmt:: skip]
0 commit comments