@@ -466,6 +466,7 @@ impl Func {
466466 let mut vregs_by_block_to_be_defined = vec ! [ ] ;
467467 let mut block_params = vec ! [ vec![ ] ; num_blocks] ;
468468 for block in 0 ..num_blocks {
469+ // Calculate the available vregs for this block.
469470 let mut vregs = vec ! [ ] ;
470471 for _ in 0 ..u. int_in_range ( opts. num_vregs_per_block . clone ( ) ) ? {
471472 let vreg = alloc_vreg ( & mut builder, u) ?;
@@ -478,6 +479,8 @@ impl Func {
478479 }
479480 }
480481 vregs_by_block. push ( vregs. clone ( ) ) ;
482+
483+ // Choose some of the vregs to be block parameters.
481484 let mut vregs_to_be_defined = vec ! [ ] ;
482485 let mut max_block_params = u. int_in_range ( 0 ..=core:: cmp:: min ( 3 , vregs. len ( ) / 3 ) ) ?;
483486 for & vreg in & vregs {
@@ -497,18 +500,15 @@ impl Func {
497500 let mut avail = block_params[ block] . clone ( ) ;
498501 let mut remaining_nonlocal_uses = u. int_in_range ( 0 ..=3 ) ?;
499502 while let Some ( vreg) = vregs_by_block_to_be_defined[ block] . pop ( ) {
500- let def_constraint = OperandConstraint :: arbitrary ( u) ?;
501- let def_pos = if bool:: arbitrary ( u) ? {
502- OperandPos :: Early
503- } else {
504- OperandPos :: Late
505- } ;
503+ // Start with a written-to vreg (`def`).
506504 let mut operands = vec ! [ Operand :: new(
507505 vreg,
508506 OperandConstraint :: arbitrary( u) ?,
509507 OperandKind :: Def ,
510508 OperandPos :: arbitrary( u) ?,
511509 ) ] ;
510+
511+ // Then add some read-from vregs (`uses`).
512512 let mut allocations = vec ! [ Allocation :: none( ) ] ;
513513 for _ in 0 ..u. int_in_range ( opts. num_uses_per_inst . clone ( ) ) ? {
514514 let vreg = if avail. len ( ) > 0
@@ -538,6 +538,9 @@ impl Func {
538538 ) ) ;
539539 allocations. push ( Allocation :: none ( ) ) ;
540540 }
541+
542+ // Convert some of the operands to have special constraints:
543+ // reuses, fixed, clobbers, etc.
541544 let mut clobbers: Vec < PReg > = vec ! [ ] ;
542545 if operands. len ( ) > 1 && opts. reused_inputs && bool:: arbitrary ( u) ? {
543546 convert_def_to_reuse ( u, & mut operands) ?;
@@ -552,18 +555,16 @@ impl Func {
552555 }
553556
554557 if opts. callsite_ish_constraints && bool:: arbitrary ( u) ? {
555- // Define some new vregs with `any`
556- // constraints.
558+ // Define some new vregs with `any` constraints.
557559 for _ in 0 ..u. int_in_range ( opts. num_callsite_ish_vregs_per_inst . clone ( ) ) ? {
558560 let vreg = alloc_vreg ( & mut builder, u) ?;
559561 operands. push ( Operand :: any_def ( vreg) ) ;
560562 }
561563
562- // Create some clobbers, avoiding regs named
563- // by operand constraints. Note that the sum
564- // of the maximum clobber count here (10) and
565- // maximum operand count above (10) is less
566- // than the number of registers in any single
564+ // Create some clobbers, avoiding regs named by operand
565+ // constraints. Note that the sum of the maximum clobber
566+ // count here (10) and maximum operand count above (10)
567+ // is less than the number of registers in any single
567568 // class, so the resulting problem is always
568569 // allocatable.
569570 for _ in 0 ..u. int_in_range ( opts. num_clobbers_per_inst . clone ( ) ) ? {
0 commit comments