VDBInstructionBasicBlock.st
changeset 98 8601c1b9e7ba
parent 96 40094b870074
child 237 53a7322c7128
equal deleted inserted replaced
97:f59fab5b1d0f 98:8601c1b9e7ba
    77     blocks copy do:[:bb | 
    77     blocks copy do:[:bb | 
    78         bb last isBranch ifTrue:[
    78         bb last isBranch ifTrue:[
    79             | targetAddress succBB |
    79             | targetAddress succBB |
    80 
    80 
    81             targetAddress := bb last branchTarget.
    81             targetAddress := bb last branchTarget.
    82             "/ Find successor block. Note, that we may found none if the branch target is
    82             targetAddress notNil ifTrue:[
    83             "/ outside given coce.
    83                 "/ Find successor block. Note, that we may found none if the branch target is
    84             succBB := blocks detect:[:e | e includesAddress: targetAddress ] ifNone: [ nil ].
    84                 "/ outside given coce.
    85             succBB notNil ifTrue:[ 
    85                 succBB := blocks detect:[:e | e includesAddress: targetAddress ] ifNone: [ nil ].
    86                 "/ If `targetAddress` points into the middle of `succBB` we have to split
    86                 succBB notNil ifTrue:[ 
    87                 "/ succBB into two.
    87                     "/ If `targetAddress` points into the middle of `succBB` we have to split
    88                 succBB firstAddress < targetAddress ifTrue:[ 
    88                     "/ succBB into two.
    89                     | succBBs |
    89                     succBB firstAddress < targetAddress ifTrue:[ 
    90 
    90                         | succBBs |
    91                     succBBs := succBB splitAtAddress: targetAddress.
    91 
    92                     blocks remove: succBB; addAll: succBBs.
    92                         succBBs := succBB splitAtAddress: targetAddress.
    93                     succBB := succBBs last.
    93                         blocks remove: succBB; addAll: succBBs.
       
    94                         succBB := succBBs last.
       
    95                     ].
       
    96                     bb setSuccessor2: succBB.
    94                 ].
    97                 ].
    95                 bb setSuccessor2: succBB.
    98             ]
    96             ].
       
    97         ].
    99         ].
    98     ].
   100     ].
    99 
   101 
   100     "/ Jo done!!
   102     "/ Jo done!!
   101     ^ blocks.
   103     ^ blocks.
   103 
   105 
   104 
   106 
   105     ^ blocks
   107     ^ blocks
   106 
   108 
   107     "Created: / 27-06-2018 / 13:03:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   109     "Created: / 27-06-2018 / 13:03:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   108     "Modified: / 16-08-2018 / 11:36:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   110     "Modified: / 31-08-2018 / 23:50:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   109 ! !
   111 ! !
   110 
   112 
   111 !VDBInstructionBasicBlock methodsFor:'accessing'!
   113 !VDBInstructionBasicBlock methodsFor:'accessing'!
   112 
   114 
   113 first
   115 first