2015-03-15 19:14:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								USING:  compiler.cfg  compiler.cfg.stacks.local  compiler.tree  help.markup 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-24 12:38:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								help.syntax literals make math multiline quotations sequences ;
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-18 13:45:09 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								IN:  compiler.cfg.builder.blocks 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								<<
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								STRING: ex-emit-trivial-block
							 
						 
					
						
							
								
									
										
										
										
											2015-03-24 12:38:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								USING:  compiler.cfg.builder.blocks  make  prettyprint  ;
 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-08 10:30:25 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								begin-stack-analysis <basic-block> dup  set-basic-block [ gensym ##call, drop  ] emit-trivial-block predecessors>> first  .
 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								T{ basic-block
							 
						 
					
						
							
								
									
										
										
										
											2016-03-08 10:30:25 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    { instructions
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        V{ T{ ##call { word (  gensym  )  } } T{ ##branch } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    { successors
							 
						 
					
						
							
								
									
										
										
										
											2016-03-08 10:30:25 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        V{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            T{ basic-block { predecessors V{ ~circularity~ } } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { predecessors
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        V{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            T{ basic-block
							 
						 
					
						
							
								
									
										
										
										
											2016-03-08 10:30:25 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                { instructions V{ T{ ##branch } } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                { successors V{ ~circularity~ } }
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								>>
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 13:01:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  begin-basic-block 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "block"  basic-block } { "block'"  basic-block } }
							 
						 
					
						
							
								
									
										
										
										
											2015-11-18 18:53:46 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $description "Terminates the given block and initializes a new "  { $link basic-block } " to begin outputting instructions to. The new block is included in the old blocks "  { $slot "successors"  } "."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 13:01:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  begin-branch 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "block"  "current "  { $link basic-block } }
							 
						 
					
						
							
								
									
										
										
										
											2016-03-08 08:38:48 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  { "block'"  basic-block }
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Used to begin emitting a branch."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 13:01:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  call-height 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "#call"  #call } { "n"  number  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Calculates how many items a "  { $link #call } " will add or remove from the data stack."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $examples
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { $example
							 
						 
					
						
							
								
									
										
										
										
											2014-06-08 21:20:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    "USING: compiler.cfg.builder.blocks compiler.tree.builder prettyprint sequences ;" 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 13:01:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    "[ 3append ] build-tree second call-height ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    "-2" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  emit-conditional 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "block"  basic-block }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "branches"  "sequence of pairs"  }
							 
						 
					
						
							
								
									
										
										
										
											2016-03-16 06:48:31 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  { "block'/f"  { $maybe basic-block } }
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Emits a sequence of conditional branches to the current "  { $link cfg } ". Each branch is a pair where the first item is the entry basic block and the second the branches "  { $link height-state } ". 'block' is the block in which the control flow is branched and \"block'\" the block in which it converges again."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  emit-trivial-block 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-07 00:40:27 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "block"  basic-block }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "quot"  quotation }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "block'"  basic-block }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2015-11-21 19:06:11 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $description "Combinator that emits a new trivial block, constructed by calling the supplied quotation. The quotation should not end the current block -- only add instructions to it."  }
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $examples { $unchecked-example $[ ex-emit-trivial-block ] } } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-15 19:14:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  end-branch 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-23 10:32:01 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "block"  basic-block } { "pair/f"  "two-tuple"  } }
							 
						 
					
						
							
								
									
										
										
										
											2015-03-15 19:14:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $description "pair is { final-bb final-height }"  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-18 04:47:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  make-kill-block 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-18 18:53:46 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "block"  basic-block } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Marks the block as a kill block."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-15 19:14:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-24 12:38:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  set-basic-block 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "basic-block"  basic-block } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Sets the given blocks as the current one by storing it in the basic-block dynamic variable. If it has any "  { $slot "instructions"  } " the current "  { $link building } " is set to those."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-15 19:14:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								HELP:  with-branch 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-07 00:40:27 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "block"  basic-block }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "quot"  quotation }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  { "pair/f"  { $maybe "pair"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2015-03-15 19:14:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $description "The pair is either "  { $link f  } " or a two-tuple containing a "  { $link basic-block } " and a "  { $link height-state } " two-tuple."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-08 08:38:48 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								ARTICLE: "compiler.cfg.builder.blocks"  "CFG construction utilities" 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								"This vocab contains utilities for that helps "  { $vocab-link "compiler.cfg.builder"  } " to construct CFG:s." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$nl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"Combinators:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  with-branch
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"Creating blocks:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  begin-basic-block
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  begin-branch
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  emit-call-block
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  emit-conditional
							 
						 
					
						
							
								
									
										
										
										
											2016-03-08 08:38:48 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  emit-trivial-call
							 
						 
					
						
							
								
									
										
										
										
											2016-03-06 22:42:28 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								ABOUT: "compiler.cfg.builder.blocks"