From 230a50c532b0fde2ee36729960d19ef446213644 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 5 Aug 2018 13:36:54 -0700 Subject: [PATCH] Dedicate a throwaway register. --- src/chalk/codegen.cr | 4 +--- src/chalk/emitter.cr | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chalk/codegen.cr b/src/chalk/codegen.cr index 010724d..9c57b78 100644 --- a/src/chalk/codegen.cr +++ b/src/chalk/codegen.cr @@ -90,10 +90,8 @@ module Chalk generate! tree, entry.function, table, target, free when Trees::TreeBlock table = Table.new(table) - throwaway = free - free += 1 tree.children.each do |child| - free += generate! child, table, throwaway, free + free += generate! child, table, THROWAWAY_REG, free end when Trees::TreeVar entry = table[tree.name]? diff --git a/src/chalk/emitter.cr b/src/chalk/emitter.cr index 5dd106d..58a6d19 100644 --- a/src/chalk/emitter.cr +++ b/src/chalk/emitter.cr @@ -4,6 +4,8 @@ module Chalk RETURN_REG = 14 # The register into which the "stack pointer" is stored. STACK_REG = 13 + # Register used for throwing away values. + THROWAWAY_REG = 12 # Module to emit instructions and store # them into an existing array.