@@ -75,22 +75,28 @@ pub struct BranchEncoding {
7575
7676#[ derive( Clone ) ]
7777pub struct BlockInst {
78+ pub cond : Cond ,
7879 pub kind : BlockInstKind ,
7980 io_cache : RefCell < Option < ( BlockRegSet , BlockRegSet ) > > ,
8081}
8182
8283impl BlockInst {
83- pub fn new ( kind : BlockInstKind ) -> Self {
84- BlockInst { kind, io_cache : RefCell :: new ( None ) }
84+ pub fn new ( cond : Cond , kind : BlockInstKind ) -> Self {
85+ BlockInst {
86+ cond,
87+ kind,
88+ io_cache : RefCell :: new ( None ) ,
89+ }
8590 }
8691
8792 pub fn get_io ( & self ) -> ( BlockRegSet , BlockRegSet ) {
8893 let mut cached_io = self . io_cache . borrow_mut ( ) ;
8994 match * cached_io {
9095 None => {
91- let io = self . kind . get_io ( ) ;
92- * cached_io = Some ( io) ;
93- io
96+ let ( mut inputs, outputs) = self . kind . get_io ( ) ;
97+ inputs. add_guests ( outputs. get_guests ( ) ) ;
98+ * cached_io = Some ( ( inputs, outputs) ) ;
99+ ( inputs, outputs)
94100 }
95101 Some ( cache) => cache,
96102 }
@@ -109,13 +115,13 @@ impl BlockInst {
109115
110116impl From < BlockInstKind > for BlockInst {
111117 fn from ( value : BlockInstKind ) -> Self {
112- BlockInst :: new ( value)
118+ BlockInst :: new ( Cond :: AL , value)
113119 }
114120}
115121
116122impl Debug for BlockInst {
117123 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
118- write ! ( f, "{:?}" , self . kind)
124+ write ! ( f, "{:?} {:?}" , self . cond , self . kind)
119125 }
120126}
121127
@@ -186,7 +192,6 @@ pub enum BlockInstKind {
186192 Branch {
187193 label : BlockLabel ,
188194 block_index : usize ,
189- cond : Cond ,
190195 } ,
191196
192197 SaveContext {
@@ -679,10 +684,10 @@ impl BlockInstKind {
679684 }
680685 } ,
681686
682- BlockInstKind :: Branch { block_index, cond , .. } => {
687+ BlockInstKind :: Branch { block_index, .. } => {
683688 // Encode label
684689 // Branch offset can only be figured out later
685- opcodes. push ( BranchEncoding :: new ( u26:: new ( * block_index as u32 ) , false , false , u4:: new ( * cond as u8 ) ) . into ( ) ) ;
690+ opcodes. push ( BranchEncoding :: new ( u26:: new ( * block_index as u32 ) , false , false , u4:: new ( Cond :: AL as u8 ) ) . into ( ) ) ;
686691 branch_placeholders. push ( opcodes_offset + opcode_index) ;
687692 }
688693
@@ -860,7 +865,7 @@ impl Debug for BlockInstKind {
860865 } ;
861866 write ! ( f, "Label {label:?}{guest_pc}" )
862867 }
863- BlockInstKind :: Branch { label, block_index, cond } => write ! ( f, "B{cond:?} {label:?}, block index: {block_index}" ) ,
868+ BlockInstKind :: Branch { label, block_index } => write ! ( f, "B {label:?}, block index: {block_index}" ) ,
864869 BlockInstKind :: SaveContext { .. } => write ! ( f, "SaveContext" ) ,
865870 BlockInstKind :: SaveReg { guest_reg, reg_mapped, .. } => write ! ( f, "SaveReg {guest_reg:?}, mapped: {reg_mapped:?}" ) ,
866871 BlockInstKind :: RestoreReg { guest_reg, reg_mapped, .. } => write ! ( f, "RestoreReg {guest_reg:?}, mapped: {reg_mapped:?}" ) ,
0 commit comments