@@ -592,40 +592,51 @@ fn (mut p Parser) asm_ios(output bool) []ast.AsmIO {
592592 if p.tok.kind == .lpar {
593593 constraint = if output { '+r' } else { 'r' } // default constraint, though vfmt fmts to `+r` and `r`
594594 } else {
595- constraint + = match p.tok.kind {
596- .assign {
597- '='
598- }
599- .plus {
600- '+'
601- }
602- .mod {
603- '%'
595+ // https://gcc.gnu.org/onlinedocs/gcc/Modifiers.html
596+ if output {
597+ // Output constraint
598+ if p.tok.kind == .assign {
599+ constraint + = '='
600+ } else if p.tok.kind == .plus {
601+ constraint + = '+'
602+ } else {
603+ p.error_with_pos ('Output constraint must starts with `=` or `+`' ,
604+ pos)
605+ return []
604606 }
605- .amp {
606- '&'
607+ p.next ()
608+ if p.tok.kind == .amp {
609+ constraint + = '&'
610+ p.next ()
611+ } else if p.tok.kind == .mul {
612+ constraint + = '*'
613+ p.next ()
607614 }
608- else {
609- ''
615+ } else {
616+ // Input constraint
617+ if p.tok.kind == .mod {
618+ constraint + = '%'
619+ p.next ()
620+ } else if p.tok.kind == .mul {
621+ constraint + = '*'
622+ p.next ()
610623 }
611624 }
612- if constraint != '' {
613- p.next ()
614- }
615- constraint + = p.tok.lit
616625 if p.tok.kind == .at {
626+ // hack: `@ccl` is a single token .at, not .at + .name
627+ constraint + = p.tok.lit
617628 p.next ()
618- } else {
619- if p.tok.kind == .number {
620- // Numbered constraints - https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html
621- if p.tok.lit.int () > = 10 {
622- p.error_with_pos ('The digit must be between 0 and 9 only' , pos)
623- return []
624- }
625- p.check (.number)
626- } else {
627- p.check (.name)
629+ } else if p.tok.kind == .number && ! output {
630+ // Numbered constraints - https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html
631+ if p.tok.lit.int () > = 10 {
632+ p.error_with_pos ('The digit must be between 0 and 9 only' , pos)
633+ return []
628634 }
635+ constraint + = p.tok.lit
636+ p.check (.number)
637+ } else {
638+ constraint + = p.tok.lit
639+ p.check (.name)
629640 }
630641 }
631642 mut expr := p.expr (0 )
0 commit comments