@@ -343,7 +343,7 @@ impl AllocatedAbstractInstructionSet {
343343 data_id,
344344 ) ,
345345 owning_span : owning_span. clone ( ) ,
346- comment : "load switch target table address" . into ( ) ,
346+ comment : "[switch] load switch targets table base address" . into ( ) ,
347347 } ) ;
348348 // Multiply discriminant by 8 (since each address is 8 bytes) and add to the base address.
349349 realized_ops. push ( RealizedOp {
@@ -353,7 +353,7 @@ impl AllocatedAbstractInstructionSet {
353353 VirtualImmediate12 :: new ( 3 ) ,
354354 ) ,
355355 owning_span : owning_span. clone ( ) ,
356- comment : "multiply discriminant by 8 " . into ( ) ,
356+ comment : "[switch] get discriminant's target offset (discriminant * 8) " . into ( ) ,
357357 } ) ;
358358 realized_ops. push ( RealizedOp {
359359 opcode : AllocatedInstruction :: ADD (
@@ -362,7 +362,7 @@ impl AllocatedAbstractInstructionSet {
362362 AllocatedRegister :: Constant ( ConstantRegister :: Scratch ) ,
363363 ) ,
364364 owning_span : owning_span. clone ( ) ,
365- comment : "add discriminant to switch target table address" . into ( ) ,
365+ comment : "[switch] add discriminant's target offset to targets base address" . into ( ) ,
366366 } ) ;
367367 realized_ops. push ( RealizedOp {
368368 opcode : AllocatedInstruction :: LW (
@@ -371,7 +371,7 @@ impl AllocatedAbstractInstructionSet {
371371 VirtualImmediate12 :: new ( 0 ) ,
372372 ) ,
373373 owning_span : owning_span. clone ( ) ,
374- comment : "load switch target address" . into ( ) ,
374+ comment : "[switch] load discriminant's target address" . into ( ) ,
375375 } ) ;
376376 // Finally, jump to the loaded address.
377377 realized_ops. push ( RealizedOp {
@@ -380,7 +380,7 @@ impl AllocatedAbstractInstructionSet {
380380 VirtualImmediate18 :: new ( 0 ) ,
381381 ) ,
382382 owning_span,
383- comment,
383+ comment : "[switch] jump to discriminant's target address" . into ( ) ,
384384 } ) ;
385385 }
386386 ControlFlowOp :: DataSectionOffsetPlaceholder => {
@@ -425,10 +425,10 @@ impl AllocatedAbstractInstructionSet {
425425 /// instructions to be added, and so on.
426426 ///
427427 /// For this reason, we take a two-pass approach. On the first pass, we pessimistically assume
428- /// that all jumps may require take two opcodes, and use this assumption to calculate the
428+ /// that all jumps may require two opcodes, and use this assumption to calculate the
429429 /// offsets of labels. Then we see which jumps actually require two opcodes and mark them as such.
430430 /// This approach is not optimal as it sometimes requires more opcodes than necessary,
431- /// but it is simple and quite works well in practice.
431+ /// but it is simple and works quite well in practice.
432432 fn resolve_labels ( & mut self , data_section : & mut DataSection ) -> LabeledBlocks {
433433 let far_jump_indices = self . collect_far_jumps ( ) ;
434434 self . map_label_offsets ( data_section, & far_jump_indices)
0 commit comments