| 1 | import os |
| 2 | import time |
| 3 | |
| 4 | const asm_file_content = ' |
| 5 | fn asm_fn() { |
| 6 | mut x := u64(0) |
| 7 | mut y := u64(0) |
| 8 | mut z := u64(0) |
| 9 | mut hi := u64(0) |
| 10 | mut lo := u64(0) |
| 11 | asm amd64 { |
| 12 | mulq rdx |
| 13 | addq rax, z |
| 14 | adcq rdx, 0 |
| 15 | ; =a (lo) |
| 16 | =d (hi) |
| 17 | ; a (x) |
| 18 | d (y) |
| 19 | r (z) |
| 20 | ; cc |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | fn main() { |
| 25 | asm_fn() |
| 26 | } |
| 27 | ' |
| 28 | |
| 29 | const vexe = os.getenv('VEXE') |
| 30 | const v_file = os.join_path(os.vtmp_dir(), 'generated_stmt_separator.amd64.v') |
| 31 | const genexe_file = os.join_path(os.vtmp_dir(), 'generated_stmt_separator.exe') |
| 32 | const c_file = os.join_path(os.vtmp_dir(), 'generated_stmt_separator.exe.tmp.c') |
| 33 | |
| 34 | fn test_stmt_separator() { |
| 35 | os.write_file(v_file, asm_file_content)! |
| 36 | eprintln('Compiling...') |
| 37 | compile_cmd := '${os.quoted_path(vexe)} -cg -skip-running -no-rsp -keepc -o ${os.quoted_path(genexe_file)} ${os.quoted_path(v_file)}' |
| 38 | eprintln('> compile_cmd: ${compile_cmd}') |
| 39 | time.sleep(1000 * time.millisecond) // improve chances of working on windows |
| 40 | compile_res := os.system(compile_cmd) |
| 41 | assert compile_res == 0 |
| 42 | |
| 43 | content := os.read_file(c_file)! |
| 44 | os.rm(v_file)! |
| 45 | os.rm(genexe_file)! |
| 46 | os.rm(c_file)! |
| 47 | assert content.contains(r'addq %[z], %%rax\n\t') |
| 48 | } |
| 49 | |