Skip to content

Commit

Permalink
vfmt: fix asm volatile & goto (#9688)
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisSchmieder committed Apr 11, 2021
1 parent a851901 commit 273655e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 7 additions & 7 deletions vlib/builtin/linux_bare/linuxsys_bare.v
Expand Up @@ -228,7 +228,7 @@ pub enum Map_flags {
fn sys_call0(scn u64) u64 {
res := u64(0)
asm amd64 {
syscall
syscall
; =a (res)
; a (scn)
}
Expand All @@ -238,7 +238,7 @@ fn sys_call0(scn u64) u64 {
fn sys_call1(scn u64, arg1 u64) u64 {
res := u64(0)
asm amd64 {
syscall
syscall
; =a (res)
; a (scn)
D (arg1)
Expand All @@ -249,7 +249,7 @@ fn sys_call1(scn u64, arg1 u64) u64 {
fn sys_call2(scn u64, arg1 u64, arg2 u64) u64 {
res := u64(0)
asm amd64 {
syscall
syscall
; =a (res)
; a (scn)
D (arg1)
Expand All @@ -261,7 +261,7 @@ fn sys_call2(scn u64, arg1 u64, arg2 u64) u64 {
fn sys_call3(scn u64, arg1 u64, arg2 u64, arg3 u64) u64 {
res := u64(0)
asm amd64 {
syscall
syscall
; =a (res)
; a (scn)
D (arg1)
Expand All @@ -275,7 +275,7 @@ fn sys_call4(scn u64, arg1 u64, arg2 u64, arg3 u64, arg4 u64) u64 {
res := u64(0)
asm amd64 {
mov r10, arg4
syscall
syscall
; =a (res)
; a (scn)
D (arg1)
Expand All @@ -292,7 +292,7 @@ fn sys_call5(scn u64, arg1 u64, arg2 u64, arg3 u64, arg4 u64, arg5 u64) u64 {
asm amd64 {
mov r10, arg4
mov r8, arg5
syscall
syscall
; =a (res)
; a (scn)
D (arg1)
Expand All @@ -312,7 +312,7 @@ fn sys_call6(scn u64, arg1 u64, arg2 u64, arg3 u64, arg4 u64, arg5 u64, arg6 u64
mov r10, arg4
mov r8, arg5
mov r9, arg6
syscall
syscall
; =a (res)
; a (scn)
D (arg1)
Expand Down
12 changes: 10 additions & 2 deletions vlib/v/fmt/fmt.v
Expand Up @@ -668,7 +668,13 @@ fn expr_is_single_line(expr ast.Expr) bool {
//=== Specific Stmt methods ===//

fn (mut f Fmt) asm_stmt(stmt ast.AsmStmt) {
f.writeln('asm $stmt.arch {')
f.write('asm ')
if stmt.is_volatile {
f.write('volatile ')
} else if stmt.is_goto {
f.write('goto ')
}
f.writeln('$stmt.arch {')
f.indent++
for template in stmt.templates {
if template.is_directive {
Expand All @@ -678,7 +684,9 @@ fn (mut f Fmt) asm_stmt(stmt ast.AsmStmt) {
if template.is_label {
f.write(':')
} else {
f.write(' ')
if template.args.len > 0 {
f.write(' ')
}
}
for i, arg in template.args {
f.asm_arg(arg)
Expand Down

0 comments on commit 273655e

Please sign in to comment.