Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.nutz committed Oct 22, 2024
1 parent edd9139 commit b903fbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Binary file removed irparser/a.out
Binary file not shown.
Binary file removed irparser/core
Binary file not shown.
10 changes: 8 additions & 2 deletions irparser/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,20 @@ static bool try_match_at(OptPatternMatch* out, CompPattern pattern, vx_IrOp* iro
else if (current->is_any) {
out->matched_instrs[i].first = irop;
for (; irop; irop = irop->next);
out->matched_instrs[i].last = irop;
out->matched_instrs[i].last = vx_IrOp_predecessor(irop);
break; // no next
}
else {
if (!try_match_op(i, out, current, irop, placeholders_matched))
return false;
out->matched_instrs[i].first = irop;
out->matched_instrs[i].last = irop;
irop = irop->next;
}
}

out->found = true;
out->last = vx_IrOp_predecessor(irop);
return true;
}

Expand All @@ -90,9 +94,11 @@ OptPatternMatch Pattern_matchNext(vx_IrOp* first, CompPattern pattern)
match.matched_instrs = malloc(pattern.count * sizeof(PatternInstMatch));
bool *placeholders_matched = calloc(pattern.placeholders_count, sizeof(bool));

for (; first; first = first->next)
for (; first; first = first->next) {
memset(placeholders_matched, 0, pattern.placeholders_count * sizeof(bool));
if (try_match_at(&match, pattern, first, placeholders_matched))
break;
}

free(placeholders_matched);

Expand Down

0 comments on commit b903fbc

Please sign in to comment.