From 6a806bc7ed4e469fc93c01c1ff723832dd9acf0c Mon Sep 17 00:00:00 2001 From: Mike <45243121+tankf33der@users.noreply.github.com> Date: Tue, 23 Dec 2025 12:28:23 +0200 Subject: [PATCH] cgen,slow_tests: improve loongarch64 inline asm, add test (#26083) --- vlib/v/gen/c/cgen.v | 6 ++++++ vlib/v/slow_tests/assembly/asm_test.loongarch64.v | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index baf0f988f..05b19e605 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3412,12 +3412,18 @@ fn (mut g Gen) asm_arg(arg ast.AsmArg, stmt ast.AsmStmt) { .base { if stmt.arch == .arm64 { g.write('[') + } + if stmt.arch == .loongarch64 { + g.write('') } else { g.write('(') } g.asm_arg(base, stmt) if stmt.arch == .arm64 { g.write(']') + } + if stmt.arch == .loongarch64 { + g.write('') } else { g.write(')') } diff --git a/vlib/v/slow_tests/assembly/asm_test.loongarch64.v b/vlib/v/slow_tests/assembly/asm_test.loongarch64.v index ea70bcd3c..d30ee4970 100644 --- a/vlib/v/slow_tests/assembly/asm_test.loongarch64.v +++ b/vlib/v/slow_tests/assembly/asm_test.loongarch64.v @@ -34,4 +34,15 @@ fn test_inline_asm() { assert d == 10 assert e == 2 assert f == 17 + + l := 5 + m := &l + asm loongarch64 { + li.w r20, 7 + st.w r20, [m], 0 + ; ; r (m) + ; r20 + memory + } + assert l == 7 } -- 2.39.5