Skip to content

Commit ed91c64

Browse files
XX debug the failure
1 parent 96c0252 commit ed91c64

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

integration_tests/if_02.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
from ltypes import bool, i32
22
def Test_if_01():
3-
x: bool = True
3+
# x: bool = True
44
y: i32 = 1
55

6-
if x:
7-
x = False
8-
if x:
9-
print(0)
10-
else:
11-
print(1)
6+
# if x:
7+
# x = False
8+
# if x:
9+
# print(0)
10+
# else:
11+
# print(1)
1212

13-
if y > 0:
14-
print(1)
15-
if y < 2:
16-
print(1)
17-
if y == 1:
18-
print(1)
13+
# if y > 0:
14+
# print(1)
15+
# if y < 2:
16+
# print(1)
17+
# if y == 1:
18+
# print(1)
19+
# print(y != 1)
1920
if y != 1:
2021
print(0)
2122
else:
2223
print(1)
2324
if y <= 1:
2425
print(1)
26+
print(y)
2527

26-
y = 5
27-
if y <= 10:
28-
print(1)
29-
if y >= 5:
30-
print(1)
31-
if y >= 1:
32-
print(1)
28+
# y = 5
29+
# if y <= 10:
30+
# print(1)
31+
# if y >= 5:
32+
# print(1)
33+
# if y >= 1:
34+
# print(1)
3335

3436
def Verify():
3537
Test_if_01()

src/libasr/codegen/wasm_to_x86.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,18 @@ class X86Visitor : public WASMDecoder<X86Visitor>,
186186
void visit_I32GeS() { handle_I32Compare("GtE"); }
187187
void visit_I32LtS() { handle_I32Compare("Lt"); }
188188
void visit_I32LeS() { handle_I32Compare("LtE"); }
189-
void visit_I32Ne() { handle_I32Compare("NotEq"); }
189+
void visit_I32Ne() {
190+
unique_id.push_back(std::to_string(offset));
191+
m_a.asm_pop_r32(X86Reg::ebx);
192+
m_a.asm_pop_r32(X86Reg::eax);
193+
m_a.asm_cmp_r32_r32(X86Reg::eax, X86Reg::ebx);
194+
m_a.asm_jne_label(".compare_1" + unique_id.back());
195+
m_a.asm_mov_r32_imm32(X86Reg::eax, 0);
196+
m_a.asm_jmp_label(".compare.end_" + unique_id.back());
197+
m_a.add_label(".compare_1" + unique_id.back());
198+
m_a.asm_mov_r32_imm32(X86Reg::eax, 1);
199+
m_a.add_label(".compare.end_" + unique_id.back());
200+
}
190201

191202
void gen_x86_bytes() {
192203
emit_elf32_header(m_a);

0 commit comments

Comments
 (0)