@@ -31,11 +31,11 @@ macro_rules! cfg_global_asm {
31
31
// - https://github.com/llvm/llvm-project/issues/61991
32
32
cfg_global_asm ! (
33
33
"// Provisional patch to avoid LLVM spurious errors when compiling in release mode." ,
34
- #[ cfg( all( riscv32, riscvm) ) ]
34
+ #[ cfg( all( target_arch = " riscv32" , riscvm) ) ]
35
35
".attribute arch, \" rv32im\" " ,
36
- #[ cfg( all( riscv64, riscvm, not( riscvg) ) ) ]
36
+ #[ cfg( all( target_arch = " riscv64" , riscvm, not( riscvg) ) ) ]
37
37
".attribute arch, \" rv64im\" " ,
38
- #[ cfg( all( riscv64, riscvg) ) ]
38
+ #[ cfg( all( target_arch = " riscv64" , riscvg) ) ]
39
39
".attribute arch, \" rv64g\" " ,
40
40
) ;
41
41
@@ -47,10 +47,10 @@ cfg_global_asm!(
47
47
.global _start
48
48
49
49
_start:" ,
50
- #[ cfg( riscv32) ]
50
+ #[ cfg( target_arch = " riscv32" ) ]
51
51
"lui ra, %hi(_abs_start)
52
52
jr %lo(_abs_start)(ra)" ,
53
- #[ cfg( riscv64) ]
53
+ #[ cfg( target_arch = " riscv64" ) ]
54
54
".option push
55
55
.option norelax // to prevent an unsupported R_RISCV_ALIGN relocation from being generated
56
56
1:
@@ -84,7 +84,9 @@ _abs_start:
84
84
// ZERO OUT GENERAL-PURPOSE REGISTERS
85
85
riscv_rt_macros:: loop_global_asm!( " li x{}, 0" , 1 , 10 ) ;
86
86
// 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 ) ;
88
90
89
91
// INITIALIZE GLOBAL POINTER, STACK POINTER, AND FRAME POINTER
90
92
cfg_global_asm ! (
@@ -125,12 +127,12 @@ cfg_global_asm!(
125
127
126
128
// STORE A0..A2 IN THE STACK, AS THEY WILL BE NEEDED LATER BY main
127
129
cfg_global_asm ! (
128
- #[ cfg( riscv32) ]
130
+ #[ cfg( target_arch = " riscv32" ) ]
129
131
"addi sp, sp, -4 * 3
130
132
sw a0, 4 * 0(sp)
131
133
sw a1, 4 * 1(sp)
132
134
sw a2, 4 * 2(sp)" ,
133
- #[ cfg( riscv64) ]
135
+ #[ cfg( target_arch = " riscv64" ) ]
134
136
"addi sp, sp, -8 * 3
135
137
sd a0, 8 * 0(sp)
136
138
sd a1, 8 * 1(sp)
@@ -202,22 +204,22 @@ cfg_global_asm!(
202
204
"fscsr x0" ,
203
205
) ;
204
206
// ZERO OUT FLOATING POINT REGISTERS
205
- #[ cfg( all( riscv32, riscvd) ) ]
207
+ #[ cfg( all( target_arch = " riscv32" , riscvd) ) ]
206
208
riscv_rt_macros:: loop_global_asm!( " fcvt.d.w f{}, x0" , 32 ) ;
207
- #[ cfg( all( riscv64, riscvd) ) ]
209
+ #[ cfg( all( target_arch = " riscv64" , riscvd) ) ]
208
210
riscv_rt_macros:: loop_global_asm!( " fmv.d.x f{}, x0" , 32 ) ;
209
211
#[ cfg( all( riscvf, not( riscvd) ) ) ]
210
212
riscv_rt_macros:: loop_global_asm!( " fmv.w.x f{}, x0" , 32 ) ;
211
213
212
214
// SET UP INTERRUPTS, RESTORE a0..a2, AND JUMP TO MAIN RUST FUNCTION
213
215
cfg_global_asm ! (
214
216
"call _setup_interrupts" ,
215
- #[ cfg( riscv32) ]
217
+ #[ cfg( target_arch = " riscv32" ) ]
216
218
"lw a0, 4 * 0(sp)
217
219
lw a1, 4 * 1(sp)
218
220
lw a2, 4 * 2(sp)
219
221
addi sp, sp, 4 * 3" ,
220
- #[ cfg( riscv64) ]
222
+ #[ cfg( target_arch = " riscv64" ) ]
221
223
"ld a0, 8 * 0(sp)
222
224
ld a1, 8 * 1(sp)
223
225
ld a2, 8 * 2(sp)
@@ -276,14 +278,14 @@ _pre_init_trap:
276
278
j _pre_init_trap" ,
277
279
) ;
278
280
279
- #[ cfg( riscv32) ]
281
+ #[ cfg( target_arch = " riscv32" ) ]
280
282
riscv_rt_macros:: weak_start_trap_riscv32!( ) ;
281
- #[ cfg( riscv64) ]
283
+ #[ cfg( target_arch = " riscv64" ) ]
282
284
riscv_rt_macros:: weak_start_trap_riscv64!( ) ;
283
285
284
- #[ cfg( all( riscv32, feature = "v-trap" ) ) ]
286
+ #[ cfg( all( target_arch = " riscv32" , feature = "v-trap" ) ) ]
285
287
riscv_rt_macros:: vectored_interrupt_trap_riscv32!( ) ;
286
- #[ cfg( all( riscv64, feature = "v-trap" ) ) ]
288
+ #[ cfg( all( target_arch = " riscv64" , feature = "v-trap" ) ) ]
287
289
riscv_rt_macros:: vectored_interrupt_trap_riscv64!( ) ;
288
290
289
291
#[ rustfmt:: skip]
0 commit comments