parser: asm: add support for memory clobbers (#9618)
parent
89838f2e21
commit
018a88c3ce
|
@ -1008,20 +1008,22 @@ fn (mut p Parser) asm_stmt(is_top_level bool) ast.AsmStmt {
|
|||
p.scope = scope
|
||||
p.check(.semicolon)
|
||||
for p.tok.kind == .name {
|
||||
reg := p.reg_or_alias()
|
||||
reg := ast.AsmRegister{
|
||||
name: p.tok.lit
|
||||
typ: 0
|
||||
size: -1
|
||||
}
|
||||
p.check(.name)
|
||||
|
||||
mut comments := []ast.Comment{}
|
||||
for p.tok.kind == .comment {
|
||||
comments << p.comment()
|
||||
}
|
||||
if reg is ast.AsmRegister {
|
||||
clobbered << ast.AsmClobbered{
|
||||
reg: reg
|
||||
comments: comments
|
||||
}
|
||||
} else {
|
||||
p.error('not a register: $reg')
|
||||
}
|
||||
|
||||
if p.tok.kind in [.rcbr, .semicolon] {
|
||||
break
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ fn test_inline_asm() {
|
|||
addq [in_data + rcx * 4 + 0], 2
|
||||
; ; c (n.len - 1) // c is counter (loop) register
|
||||
r (n.data) as in_data
|
||||
; memory
|
||||
}
|
||||
assert n == [7, 11, 2, 6]
|
||||
|
||||
|
|
Loading…
Reference in New Issue