Minimize the number of hops when compiling to assembly

Suppose we compiled some program into some abstract intermediate language: our program is a sequence of operations and decisions (branches) that the next operation is executed (basically a tree). Example:

a();
if (bla) then c();
else b(); d();
e();

Now we need to "pack" this sequence into our linear memory, and thus, our code should fork (conditionally and not). For example, one of the possibilities:

      CALL A
      TEST bla
      BRANCH else
      CALL C
      JMP esc
else: CALL B
      CALL D
esc:  CALL E

, , /. - .
:
 ) ? ? ( BDD?)
 ) ( , / )?

+4
1

, .

. - . node (wlog) ( "" ) . , catch .

. , (, ).

, (, ), (, ) .

, , , , node, , . ( . ).

, : , .

, , , . , , , , , , , . ; "" . , , . , , .

. : , node .

"" .

" " , , . , , , " " , .

+6

Source: https://habr.com/ru/post/1655304/


All Articles