Skip to content

Commit

Permalink
Codechange: Reduce register usage for BinOp
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Jul 9, 2024
1 parent 522d1bc commit 78ba688
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions nml/actions/action2var.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ def parse_binop(self, expr):
isinstance(expr.expr2, (expression.ConstantNumeric, expression.Variable))
or isinstance(expr.expr2, (VarAction2LoadTempVar, VarAction2LoadCallParam))
or (isinstance(expr.expr2, expression.Parameter) and isinstance(expr.expr2.num, expression.ConstantNumeric))
or (isinstance(expr.expr2, expression.StorageOp) and expr.expr2.name == "LOAD_TEMP")
or expr.op == nmlop.VAL2
):
expr2 = expr.expr2
Expand Down
Binary file modified regression/expected/example_industry.grf
Binary file not shown.
16 changes: 7 additions & 9 deletions regression/expected/example_industry.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@
"VALU"

// Name: consume_all_prod
5 * 17 02 0A FF 02 \b3 01 01 08 02 06 03 \b2 09 81 05 82 83
5 * 17 02 0A FF 02 \b3 01 01 08 02 06 03 \b2 09 80 05 81 82

// Name: consume_all_prod@registers
6 * 97 02 0A FF 89
7D 02 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000080
\2r 7D 01 20 \dxFFFFFFFF
6 * 82 02 0A FF 89
7D 01 20 \dxFFFFFFFF
\2/ 1A 20 \dx00000002
\2+ 7D 80 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000081
\2+ 7D 02 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000080
\2r 7D 03 20 \dxFFFFFFFF
\2* 1A 20 \dx00000002
\2sto 1A 20 \dx00000082
\2sto 1A 20 \dx00000081
\2r 1A 20 \dx00000000
\2sto 1A 00 \dx00000083
\2sto 1A 00 \dx00000082
\b1
\wx00FF \dx00000000 \dx00000000
\wx00FF //
Expand Down
Binary file modified regression/expected/example_object.grf
Binary file not shown.
18 changes: 7 additions & 11 deletions regression/expected/example_object.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,18 @@
29 cc_grid.png 8bpp 1437 1 64 31 -31 -8 normal

// Name: company_land_layout - feature 0F
30 * 31 02 0F FF \b66 \dx00000000 \wx0002 81
30 * 31 02 0F FF \b66 \dx00000000 \wx0002 80
\dxC0008000 \wx0002 \b0 \b0 80 00
\dx00000000 \wx0002 \b0 \b0 80 83
\dx00000000 \wx0002 \b0 \b0 80 81

// Name: company_land_layout@registers - feature 0F
31 * 92 02 0F FF 89
7D 01 20 \dxFFFFFFFF
31 * 62 02 0F FF 89
7D 00 20 \dxFFFFFFFF
\2+ 7D 01 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000080
\2r 7D 00 20 \dxFFFFFFFF
\2+ 7D 80 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000081
\2r 7D 01 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000082
\2r 7D 00 20 \dxFFFFFFFF
\2+ 7D 82 20 \dxFFFFFFFF
\2sto 1A 00 \dx00000083
\2+ 7D 01 20 \dxFFFFFFFF
\2sto 1A 00 \dx00000081
\b1
\wx00FF \dx00000000 \dx00000000
\wx00FF //
Expand Down

0 comments on commit 78ba688

Please sign in to comment.