@@ -32,7 +32,8 @@ class X86Visitor : public WASMDecoder<X86Visitor>,
32
32
public:
33
33
X86Assembler &m_a;
34
34
uint32_t cur_func_idx;
35
- std::vector<std::string> unique_id;
35
+ std::vector<std::string> if_unique_id;
36
+ std::vector<std::string> loop_unique_id;
36
37
int32_t last_vis_i32_const, last_last_vis_i32_const;
37
38
std::unordered_map<int32_t , std::string> loc_to_str;
38
39
@@ -135,7 +136,7 @@ class X86Visitor : public WASMDecoder<X86Visitor>,
135
136
}
136
137
137
138
void visit_Loop () {
138
- unique_id .push_back (std::to_string (offset));
139
+ loop_unique_id .push_back (std::to_string (offset));
139
140
/*
140
141
The loop statement starts with `loop.head`. The `loop.body` and
141
142
`loop.branch` are enclosed within the `if.block`. If the condition
@@ -148,34 +149,34 @@ class X86Visitor : public WASMDecoder<X86Visitor>,
148
149
.endIf
149
150
.end
150
151
*/
151
- m_a.add_label (" .loop.head_" + unique_id .back ());
152
+ m_a.add_label (" .loop.head_" + loop_unique_id .back ());
152
153
{
153
154
decode_instructions ();
154
155
}
155
156
// end
156
- m_a.add_label (" .loop.end_" + unique_id .back ());
157
- unique_id .pop_back ();
157
+ m_a.add_label (" .loop.end_" + loop_unique_id .back ());
158
+ loop_unique_id .pop_back ();
158
159
}
159
160
160
161
void visit_If () {
161
- unique_id .push_back (std::to_string (offset));
162
+ if_unique_id .push_back (std::to_string (offset));
162
163
// `eax` contains the logical value (true = 1, false = 0)
163
164
// of the if condition
164
165
m_a.asm_pop_r32 (X86Reg::eax);
165
166
m_a.asm_cmp_r32_imm8 (LFortran::X86Reg::eax, 1 );
166
- m_a.asm_je_label (" .then_" + unique_id .back ());
167
- m_a.asm_jmp_label (" .else_" + unique_id .back ());
168
- m_a.add_label (" .then_" + unique_id .back ());
167
+ m_a.asm_je_label (" .then_" + if_unique_id .back ());
168
+ m_a.asm_jmp_label (" .else_" + if_unique_id .back ());
169
+ m_a.add_label (" .then_" + if_unique_id .back ());
169
170
{
170
171
decode_instructions ();
171
172
}
172
- m_a.add_label (" .endif_" + unique_id .back ());
173
- unique_id .pop_back ();
173
+ m_a.add_label (" .endif_" + if_unique_id .back ());
174
+ if_unique_id .pop_back ();
174
175
}
175
176
176
177
void visit_Else () {
177
- m_a.asm_jmp_label (" .endif_" + unique_id .back ());
178
- m_a.add_label (" .else_" + unique_id .back ());
178
+ m_a.asm_jmp_label (" .endif_" + if_unique_id .back ());
179
+ m_a.add_label (" .else_" + if_unique_id .back ());
179
180
}
180
181
181
182
void visit_LocalGet (uint32_t localidx) {
0 commit comments