summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-10-11 14:17:38 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-10-11 14:17:38 +0300
commit290a1c5179de0e3999527336495e6931950114bb (patch)
treec2d291d7f3a811b80eb4570c989c902a43789eb3
parent2198478cd22cec4ea2b645d4e9f31ee9c2508ff5 (diff)
compiler: save some bytes
When doing IO operation on field, ignore the calculation for field register if index == 0, as the offset is already enough.
-rw-r--r--src/compiler/compiler.lm6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/compiler.lm b/src/compiler/compiler.lm
index d0864b4..1ca7705 100644
--- a/src/compiler/compiler.lm
+++ b/src/compiler/compiler.lm
@@ -433,8 +433,10 @@ write_declaration(d:fspec::declaration::type, index:int)
if (!c) {
write_ins(INS_PUSHR, g_fcr)
- write_ins(INS_PUSH, index)
- write_ins(INS_OP, g_ops->find('#+'))
+ if (index != 0) {
+ write_ins(INS_PUSH, index)
+ write_ins(INS_OP, g_ops->find('#+'))
+ }
write_ins(INS_IO, d.primitive.bits)
} else {
write_ins(INS_PUSH, g_offs->find(%c))