WASM_X64: Support if else - #1390
Merged
Merged
Conversation
certik
approved these changes
Jan 2, 2023
Collaborator
Author
|
I initially attempted to support the idea of using unique integers shared at #1264 (comment). For example using: void visit_If() {
unique_idx++;
std::string label = std::to_string(unique_idx);
m_a.asm_pop_r64(X64Reg::rax); // now `rax` contains the logical value (true = 1, false = 0) of the if condition
m_a.asm_cmp_r64_imm8(X64Reg::rax, 1);
m_a.asm_je_label(".then_" + label);
m_a.asm_jmp_label(".else_" + label);
m_a.add_label(".then_" + label);
{
decode_instructions();
}
m_a.add_label(".endif_" + label);
unique_idx--;
}
void visit_Else() {
std::string label = std::to_string(unique_idx);
m_a.asm_jmp_label(".endif_" + label);
m_a.add_label(".else_" + label);
}But it happens that the Thus, I used the stack approach similar to the |
Collaborator
Author
|
Thank you for the approval. I am adding it to auto-merge as it seems approved. |
ubaidsk
enabled auto-merge
January 2, 2023 04:00
ubaidsk
force-pushed
the
wasm_x64_if_else
branch
from
January 2, 2023 04:05
f081ad0 to
87fc74a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for
if-elsestatements in thewasm_x64backend.