@@ -229,4 +229,33 @@ mod tests {
229229
230230 translate_to_file ( riscv_asm, "test_binary_translate_write.S" . to_string ( ) ) ;
231231 }
232+
233+ #[ test]
234+ fn test_loop ( ) {
235+ let riscv_asm: Vec < RiscVInstruction > = vec ! [
236+ RiscVInstruction :: Addi { dest: RiscVRegister :: SP , src: RiscVRegister :: SP , imm: -32 } ,
237+ RiscVInstruction :: S { width: RiscVWidth :: Double , src: RiscVRegister :: S0FP , dest: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: 24 } } ,
238+ RiscVInstruction :: Addi { dest: RiscVRegister :: SP , src: RiscVRegister :: SP , imm: 32 } ,
239+ RiscVInstruction :: S { width: RiscVWidth :: Word , src: RiscVRegister :: X0 , dest: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: -20 } } ,
240+ RiscVInstruction :: J { target: RiscVVal :: LabelOffset { label: ".L2" . to_string( ) , offset: 0 } } ,
241+ RiscVInstruction :: Label { name: ".L3" . to_string( ) } ,
242+ RiscVInstruction :: L { width: RiscVWidth :: Word , dest: RiscVRegister :: A5 , src: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: -24 } } ,
243+ RiscVInstruction :: Addi { dest: RiscVRegister :: A5 , src: RiscVRegister :: A5 , imm: 1 } ,
244+ RiscVInstruction :: S { width: RiscVWidth :: Word , src: RiscVRegister :: A5 , dest: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: -24 } } ,
245+ RiscVInstruction :: L { width: RiscVWidth :: Word , dest: RiscVRegister :: A5 , src: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: -20 } } ,
246+ RiscVInstruction :: Addi { dest: RiscVRegister :: A5 , src: RiscVRegister :: A5 , imm: 1 } ,
247+ RiscVInstruction :: S { width: RiscVWidth :: Word , src: RiscVRegister :: A5 , dest: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: -20 } } ,
248+ RiscVInstruction :: Label { name: ".L2" . to_string( ) } ,
249+ RiscVInstruction :: L { width: RiscVWidth :: Word , dest: RiscVRegister :: A5 , src: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: -20 } } ,
250+ RiscVInstruction :: SextW { dest: RiscVRegister :: A4 , src: RiscVRegister :: A5 } ,
251+ RiscVInstruction :: Li { dest: RiscVRegister :: A5 , imm: 4 } ,
252+ RiscVInstruction :: Ble { arg1: RiscVRegister :: A4 , arg2: RiscVRegister :: A5 , target: RiscVVal :: LabelOffset { label: ".L3" . to_string( ) , offset: 0 } } ,
253+ RiscVInstruction :: L { width: RiscVWidth :: Word , dest: RiscVRegister :: A5 , src: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: -24 } } ,
254+ RiscVInstruction :: Mv { dest: RiscVRegister :: A0 , src: RiscVRegister :: A5 } ,
255+ RiscVInstruction :: L { width: RiscVWidth :: Double , dest: RiscVRegister :: S0FP , src: RiscVVal :: Offset { register: RiscVRegister :: S0FP , offset: 24 } } ,
256+ RiscVInstruction :: Addi { dest: RiscVRegister :: SP , src: RiscVRegister :: SP , imm: 32 } ,
257+ RiscVInstruction :: Jr { target: RiscVRegister :: RA } ,
258+ ] ;
259+ translate_to_file ( riscv_asm, "test_binary_translate_loop.S" . to_string ( ) ) ;
260+ }
232261}
0 commit comments