diff options
Diffstat (limited to 'Sil/Compile.icl')
-rw-r--r-- | Sil/Compile.icl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Sil/Compile.icl b/Sil/Compile.icl index fab7643..d20eff1 100644 --- a/Sil/Compile.icl +++ b/Sil/Compile.icl @@ -56,6 +56,9 @@ where // Remove needless moves between A and B stacks opt ['ABC'.PushI_a 0:'ABC'.Pop_a 1:'ABC'.Create:'ABC'.FillI_b 0 0:'ABC'.Pop_b 1:ss] = opt ss opt ['ABC'.PushB_a 0:'ABC'.Pop_a 1:'ABC'.Create:'ABC'.FillB_b 0 0:'ABC'.Pop_b 1:ss] = opt ss + // Optimise negations + opt ['ABC'.NotB:'ABC'.JmpFalse l:ss] = ['ABC'.JmpTrue l:opt ss] + opt ['ABC'.NotB:'ABC'.JmpTrue l:ss] = ['ABC'.JmpFalse l:opt ss] // Base cases opt [s:ss] = [s:opt ss] opt [] = [] @@ -610,6 +613,9 @@ where instance gen Op2 where + gen Unequals = gen Equals *> tell ['ABC'.NotB] + gen CmpLe = gen CmpGt *> tell ['ABC'.NotB] + gen CmpGe = gen CmpLt *> tell ['ABC'.NotB] gen op = tell [instr] *> shrinkStack {zero & bsize=1} where instr = case op of @@ -619,6 +625,8 @@ where Div -> 'ABC'.DivI Rem -> 'ABC'.RemI Equals -> 'ABC'.EqI + CmpLt -> 'ABC'.LtI + CmpGt -> 'ABC'.GtI rettype = case op of Equals -> 'ABC'.BT_Bool _ -> 'ABC'.BT_Int |