@@ -142,7 +142,6 @@ impl BlockInst {
142142 guest_reg,
143143 reg_mapped,
144144 thread_regs_addr_reg,
145- tmp_guest_cpsr_reg,
146145 } => {
147146 let mut inputs = BlockRegSet :: new ( ) ;
148147 let mut outputs = BlockRegSet :: new ( ) ;
@@ -151,7 +150,6 @@ impl BlockInst {
151150 inputs += BlockReg :: Fixed ( Reg :: CPSR ) ;
152151 inputs += * thread_regs_addr_reg;
153152 outputs += * reg_mapped;
154- outputs += * tmp_guest_cpsr_reg;
155153 }
156154 _ => {
157155 inputs += * reg_mapped;
@@ -335,16 +333,10 @@ impl BlockInst {
335333 BlockInst :: Bfc { operand, .. } => Self :: replace_reg ( operand, old, new) ,
336334 BlockInst :: Bfi { operands, .. } => Self :: replace_reg ( & mut operands[ 0 ] , old, new) ,
337335 BlockInst :: SaveContext { tmp_guest_cpsr_reg, .. } => Self :: replace_reg ( tmp_guest_cpsr_reg, old, new) ,
338- BlockInst :: SaveReg {
339- guest_reg,
340- reg_mapped,
341- tmp_guest_cpsr_reg,
342- ..
343- } => {
336+ BlockInst :: SaveReg { guest_reg, reg_mapped, .. } => {
344337 if * guest_reg == Reg :: CPSR {
345338 Self :: replace_reg ( reg_mapped, old, new) ;
346339 }
347- Self :: replace_reg ( tmp_guest_cpsr_reg, old, new)
348340 }
349341 BlockInst :: RestoreReg {
350342 guest_reg,
@@ -384,13 +376,11 @@ impl BlockInst {
384376 BlockInst :: SaveContext { .. } => {
385377 unreachable ! ( )
386378 }
387- BlockInst :: SaveReg {
388- reg_mapped,
389- thread_regs_addr_reg,
390- tmp_guest_cpsr_reg,
391- ..
379+ BlockInst :: SaveReg { reg_mapped, thread_regs_addr_reg, .. } => {
380+ Self :: replace_reg ( reg_mapped, old, new) ;
381+ Self :: replace_reg ( thread_regs_addr_reg, old, new) ;
392382 }
393- | BlockInst :: RestoreReg {
383+ BlockInst :: RestoreReg {
394384 reg_mapped,
395385 thread_regs_addr_reg,
396386 tmp_guest_cpsr_reg,
@@ -411,26 +401,11 @@ impl BlockInst {
411401 }
412402 }
413403
414- fn save_guest_cpsr ( opcodes : & mut Vec < u32 > , thread_regs_addr_reg : Reg , host_reg : Reg , guest_reg : Reg ) {
404+ fn save_guest_cpsr ( opcodes : & mut Vec < u32 > , thread_regs_addr_reg : Reg , host_reg : Reg ) {
415405 opcodes. push ( Mrs :: cpsr ( host_reg, Cond :: AL ) ) ;
416- opcodes. push ( LdrStrImm :: ldr_offset_al ( guest_reg, thread_regs_addr_reg, Reg :: CPSR as u16 * 4 ) ) ;
417406 // Only copy the cond flags from host cpsr
418- opcodes. push ( AluImm :: and (
419- host_reg,
420- host_reg,
421- 0xF8 ,
422- 4 , // 8 Bytes, steps of 2
423- Cond :: AL ,
424- ) ) ;
425- opcodes. push ( AluImm :: bic (
426- guest_reg,
427- guest_reg,
428- 0xF8 ,
429- 4 , // 8 Bytes, steps of 2
430- Cond :: AL ,
431- ) ) ;
432- opcodes. push ( AluShiftImm :: orr_al ( guest_reg, host_reg, guest_reg) ) ;
433- opcodes. push ( LdrStrImm :: str_offset_al ( guest_reg, thread_regs_addr_reg, Reg :: CPSR as u16 * 4 ) ) ;
407+ opcodes. push ( AluShiftImm :: mov ( host_reg, host_reg, ShiftType :: Lsr , 16 , Cond :: AL ) ) ;
408+ opcodes. push ( LdrStrImmSBHD :: strh ( host_reg, thread_regs_addr_reg, Reg :: CPSR as u8 * 4 + 2 , Cond :: AL ) ) ;
434409 }
435410
436411 pub fn emit_opcode ( & mut self , opcodes : & mut Vec < u32 > , opcode_index : usize , branch_placeholders : & mut Vec < usize > , opcodes_offset : usize , used_host_regs : RegReserve ) {
@@ -588,9 +563,9 @@ impl BlockInst {
588563 guest_reg,
589564 reg_mapped,
590565 thread_regs_addr_reg,
591- tmp_guest_cpsr_reg ,
566+ ..
592567 } => match guest_reg {
593- Reg :: CPSR => Self :: save_guest_cpsr ( opcodes, thread_regs_addr_reg. as_fixed ( ) , reg_mapped. as_fixed ( ) , tmp_guest_cpsr_reg . as_fixed ( ) ) ,
568+ Reg :: CPSR => Self :: save_guest_cpsr ( opcodes, thread_regs_addr_reg. as_fixed ( ) , reg_mapped. as_fixed ( ) ) ,
594569 _ => opcodes. push ( LdrStrImm :: str_offset_al ( reg_mapped. as_fixed ( ) , thread_regs_addr_reg. as_fixed ( ) , * guest_reg as u16 * 4 ) ) ,
595570 } ,
596571 BlockInst :: RestoreReg {
@@ -769,7 +744,6 @@ pub enum BlockInst {
769744 guest_reg : Reg ,
770745 reg_mapped : BlockReg ,
771746 thread_regs_addr_reg : BlockReg ,
772- tmp_guest_cpsr_reg : BlockReg ,
773747 } ,
774748 RestoreReg {
775749 guest_reg : Reg ,
0 commit comments