Skip to content

Commit 6a806bc

Browse files
authored
cgen,slow_tests: improve loongarch64 inline asm, add test (#26083)
1 parent c5dd410 commit 6a806bc

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

vlib/v/gen/c/cgen.v

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,12 +3412,18 @@ fn (mut g Gen) asm_arg(arg ast.AsmArg, stmt ast.AsmStmt) {
34123412
.base {
34133413
if stmt.arch == .arm64 {
34143414
g.write('[')
3415+
}
3416+
if stmt.arch == .loongarch64 {
3417+
g.write('')
34153418
} else {
34163419
g.write('(')
34173420
}
34183421
g.asm_arg(base, stmt)
34193422
if stmt.arch == .arm64 {
34203423
g.write(']')
3424+
}
3425+
if stmt.arch == .loongarch64 {
3426+
g.write('')
34213427
} else {
34223428
g.write(')')
34233429
}

vlib/v/slow_tests/assembly/asm_test.loongarch64.v

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,15 @@ fn test_inline_asm() {
3434
assert d == 10
3535
assert e == 2
3636
assert f == 17
37+
38+
l := 5
39+
m := &l
40+
asm loongarch64 {
41+
li.w r20, 7
42+
st.w r20, [m], 0
43+
; ; r (m)
44+
; r20
45+
memory
46+
}
47+
assert l == 7
3748
}

0 commit comments

Comments
 (0)