File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use std:: fs;
22use std:: str:: FromStr ;
33mod instruction;
4- use instruction:: Instruction ;
4+ pub mod translate;
5+ use instruction:: RiscVInstruction ;
56
67/// Parse a text file into our enum.
7- fn parse_asm ( asm : & str ) -> Vec < Instruction > {
8+ fn parse_asm ( asm : & str ) -> Vec < RiscVInstruction > {
89 asm. lines ( )
910 . filter_map ( |line| {
1011 // TODO (Samir): Not sure that this will handle assembly labels
@@ -14,7 +15,7 @@ fn parse_asm(asm: &str) -> Vec<Instruction> {
1415 if parts. is_empty ( ) {
1516 None
1617 } else {
17- Instruction :: from_str ( parts[ 0 ] ) . ok ( )
18+ RiscVInstruction :: from_str ( parts[ 0 ] ) . ok ( )
1819 }
1920 } )
2021 . collect ( )
Original file line number Diff line number Diff line change 1+ use crate :: instruction:: { ArmInstruction , RiscVInstruction } ;
2+
3+ /// Run the core logic to match from RISC-V to ARM Instructions.
4+
5+ /// Translate one instruction at a time.
6+ pub fn translate ( riscv_instr : RiscVInstruction ) -> ArmInstruction {
7+ match riscv_instr {
8+ RiscVInstruction :: Addi => add,
9+ RiscVInstruction :: Sd => todo ! ( ) ,
10+ RiscVInstruction :: Ld => todo ! ( ) ,
11+ RiscVInstruction :: Sw => todo ! ( ) ,
12+ RiscVInstruction :: Lw => todo ! ( ) ,
13+ RiscVInstruction :: Mv => todo ! ( ) ,
14+ RiscVInstruction :: Addw => todo ! ( ) ,
15+ RiscVInstruction :: SextW => todo ! ( ) ,
16+ RiscVInstruction :: Jr => todo ! ( ) ,
17+ RiscVInstruction :: Li => todo ! ( ) ,
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments