2014-05-22 13:01:57 -04:00
USING: assocs compiler.cfg compiler.cfg.builder.blocks
2015-11-21 19:06:11 -05:00
compiler.cfg.stacks.local compiler.tree help.markup help.syntax kernel
literals math multiline quotations sequences vectors words ;
2014-05-18 13:45:09 -04:00
IN: compiler.cfg.builder
2014-05-22 13:01:57 -04:00
<<
STRING: ex-emit-call
2014-07-18 04:47:08 -04:00
USING: compiler.cfg.builder compiler.cfg.builder.blocks compiler.cfg.stacks
kernel make prettyprint ;
2015-03-24 12:38:42 -04:00
begin-stack-analysis <basic-block> set-basic-block
\ dummy 3 [ emit-call ] { } make drop
2015-03-15 19:14:41 -04:00
height-state basic-block [ get . ] bi@
{ { 3 0 } { 0 0 } }
2014-05-22 13:01:57 -04:00
T{ basic-block
2015-03-15 19:14:41 -04:00
{ id 1903165 }
2014-05-22 13:01:57 -04:00
{ successors
V{
T{ basic-block
2015-03-15 19:14:41 -04:00
{ id 1903166 }
2014-05-22 13:01:57 -04:00
{ instructions
V{
T{ ##call { word dummy } }
T{ ##branch }
}
}
2015-03-15 19:14:41 -04:00
{ successors
V{ T{ basic-block { id 1903167 } } }
}
2014-05-22 13:01:57 -04:00
{ kill-block? t }
}
}
}
}
;
STRING: ex-make-input-map
USING: compiler.cfg.builder prettyprint ;
T{ #shuffle { in-d { 37 81 92 } } } make-input-map .
H{
{ 81 T{ ds-loc { n 1 } } }
{ 37 T{ ds-loc { n 2 } } }
{ 92 T{ ds-loc } }
}
;
>>
2015-11-21 19:06:11 -05:00
HELP: build-cfg
{ $values { "nodes" sequence } { "word" word } { "procedures" sequence } }
{ $description "Builds one or more cfgs from the given word." } ;
2014-05-22 13:01:57 -04:00
HELP: procedures
2014-12-18 11:38:09 -05:00
{ $var-description "A " { $link vector } " used as temporary storage during cfg construction for all procedures being built." } ;
2014-05-22 13:01:57 -04:00
HELP: make-input-map
2014-06-08 21:20:27 -04:00
{ $values { "#shuffle" #shuffle } { "assoc" assoc } }
2014-05-22 13:01:57 -04:00
{ $description "Creates an " { $link assoc } " that maps input values to the shuffle operation to stack locations." }
{ $examples { $unchecked-example $[ ex-make-input-map ] } } ;
HELP: emit-call
2016-03-05 02:30:00 -05:00
{ $values { "block" basic-block } { "word" word } { "height" number } }
2015-03-15 19:14:41 -04:00
{ $description "Emits a call to the given word to the " { $link cfg } " being constructed. \"height\" is the number of items being added to or removed from the data stack. Side effects of the word is that it modifies the \"basic-block\" and " { $link height-state } " variables." }
2014-05-22 13:01:57 -04:00
{ $examples
"In this example, a call to a dummy word is emitted which pushes three items onto the stack."
{ $unchecked-example $[ ex-emit-call ] }
}
{ $see-also call-height } ;
2015-04-08 02:20:55 -04:00
HELP: emit-loop-call
2015-11-18 18:53:46 -05:00
{ $values { "successor-block" basic-block } { "current-block" basic-block } }
2015-04-08 02:20:55 -04:00
{ $description "Sets the given block as the successor of the current block. Then ends the block." } ;
2014-05-18 13:45:09 -04:00
HELP: emit-node
2016-03-05 02:30:00 -05:00
{ $values { "block" basic-block } { "node" node } }
2014-07-18 04:47:08 -04:00
{ $description "Emits CFG instructions for the given SSA node." } ;
2014-05-18 13:45:09 -04:00
HELP: trivial-branch?
{ $values
{ "nodes" "a " { $link sequence } " of " { $link node } " instances" }
2015-05-13 19:09:14 -04:00
{ "value" { $maybe "the pushed value" } }
{ "?" boolean }
2014-05-18 13:45:09 -04:00
}
{ $description "Checks whether nodes is a trivial branch or not. The branch is counted as trivial if all it does is push a literal value on the stack." }
{ $examples
{ $example
2014-06-08 21:20:27 -04:00
"USING: compiler.cfg.builder compiler.tree prettyprint ;"
2014-05-18 13:45:09 -04:00
"{ T{ #push { literal 25 } } } trivial-branch? . ."
"t\n25"
}
} ;
2015-11-21 19:06:11 -05:00
HELP: with-cfg-builder
{ $values { "nodes" sequence } { "word" word } { "label" word } { "quot" quotation } }
{ $description "Combinator used to begin and end stack analysis so that the given quotation can build the cfg. The quotation is passed the initial basic block on the stack." } ;
2014-12-27 07:18:58 -05:00
ARTICLE: "compiler.cfg.builder"
"Final stage of compilation generates machine code from dataflow IR"
"Convert tree SSA IR to CFG IR. The result is not in SSA form; this is constructed later by calling compiler.cfg.ssa.construction:construct-ssa." ;
ABOUT: "compiler.cfg.builder"