diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-08-11 19:49:52 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:31 -0400 |
commit | 7ce4d334e54433f7e67d91baa9edb25adb26975b (patch) | |
tree | 55e3544fa1ddd75b6436760ccbd90c24eda8dd44 /lisc/emit.c | |
parent | d37db3970f06e46d1ea9b55084e065e799b09576 (diff) | |
download | roux-7ce4d334e54433f7e67d91baa9edb25adb26975b.tar.gz |
add a small size optimization to emit
Diffstat (limited to 'lisc/emit.c')
-rw-r--r-- | lisc/emit.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lisc/emit.c b/lisc/emit.c index d72ea79..80df768 100644 --- a/lisc/emit.c +++ b/lisc/emit.c @@ -141,6 +141,7 @@ eins(Ins i, Fn *fn, FILE *f) [OStoreb - OStorel] = "b", }; int r; + int64_t val; switch (i.op) { case OAdd: @@ -159,6 +160,14 @@ eins(Ins i, Fn *fn, FILE *f) eop(otoa[i.op], i.arg[1], i.to, fn, f); break; case OCopy: + if (i.to.val < EAX && rtype(i.arg[0]) == RCon) { + val = fn->con[i.arg[0].val].val; + if (0 <= val && val <= UINT32_MAX) { + fprintf(f, "\tmov $%"PRId64", %%%s\n", + val, rsub[i.to.val][SWord]); + break; + } + } if (!req(i.arg[0], i.to)) eop("mov", i.arg[0], i.to, fn, f); break; |