Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Add aPH for variable return
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Dec 6, 2017
1 parent 8fd5ab8 commit 43fdc31
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/code_optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,29 @@ void code_optimizer_add_advance_peep_hole_patterns(CodeOptimizer* optimizer) {
code_optimizer_add_replacement_instruction_to_ph_pattern(pattern, I_MOVE, "_1", "__1", NULL);
code_optimizer_add_replacement_instruction_to_ph_pattern(pattern, I_MOVE, "_2", "__2", NULL);

/**
* MOVE GF@%foo_a int@10
PUSHS GF@%foo_a
RETURN
*/
pattern = code_optimizer_new_ph_pattern(optimizer);
code_optimizer_add_matching_instruction_to_ph_pattern(pattern, I_MOVE, "!a", "b", NULL, -1, -1, 0);
code_optimizer_add_matching_instruction_to_ph_pattern(pattern, I_PUSH_STACK, "!a", NULL, NULL, -1, 0, 0);
code_optimizer_add_matching_instruction_to_ph_pattern(pattern, I_RETURN, NULL, NULL, NULL, 0, 0, 0);
code_optimizer_add_replacement_instruction_to_ph_pattern(pattern, I_PUSH_STACK, "b", NULL, NULL);
code_optimizer_add_replacement_instruction_to_ph_pattern(pattern, I_RETURN, NULL, NULL, NULL);

/**
* MOVE GF@%foo_a int@10
PUSHS GF@%foo_a
*/
pattern = code_optimizer_new_ph_pattern(optimizer);
code_optimizer_add_matching_instruction_to_ph_pattern(pattern, I_MOVE, "!a", "b", NULL, -1, -1, 0);
code_optimizer_add_matching_instruction_to_ph_pattern(pattern, I_PUSH_STACK, "!a", NULL, NULL, -1, 0, 0);
code_optimizer_add_replacement_instruction_to_ph_pattern(pattern, I_MOVE, "!a", "b", NULL);
code_optimizer_add_replacement_instruction_to_ph_pattern(pattern, I_PUSH_STACK, "b", NULL, NULL);


}

void code_optimizer_free(CodeOptimizer** optimizer) {
Expand Down

0 comments on commit 43fdc31

Please sign in to comment.