cgen: fix unknown labels in addressing (#10503)

pull/10506/head
crthpl 2021-06-18 03:03:38 -07:00 committed by GitHub
parent 3f5aa5e634
commit 4abb1a8b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -1967,7 +1967,7 @@ fn (mut g Gen) gen_asm_stmt(stmt ast.AsmStmt) {
}
g.writeln('"')
}
if !stmt.is_top_level {
if stmt.output.len != 0 || stmt.input.len != 0 || stmt.clobbered.len != 0 || stmt.is_goto {
g.write(': ')
}
g.gen_asm_ios(stmt.output)
@ -2008,7 +2008,8 @@ fn (mut g Gen) asm_arg(arg ast.AsmArg, stmt ast.AsmStmt) {
ast.AsmAlias {
name := arg.name
if name in stmt.local_labels || name in stmt.global_labels
|| name in g.file.global_labels || stmt.is_top_level {
|| name in g.file.global_labels || stmt.is_top_level
|| (name !in stmt.input.map(it.alias) && name !in stmt.output.map(it.alias)) {
asm_formatted_name := if name in stmt.global_labels { '%l[$name]' } else { name }
g.write(asm_formatted_name)
} else {

View File

@ -1382,7 +1382,7 @@ fn (mut p Parser) asm_ios(output bool) []ast.AsmIO {
mut constraint := ''
if p.tok.kind == .lpar {
constraint = if output { '+r' } else { 'r' } // default constraint
constraint = if output { '+r' } else { 'r' } // default constraint, though vfmt fmts to `+r` and `r`
} else {
constraint += match p.tok.kind {
.assign {

View File

@ -167,7 +167,7 @@ fn test_rip_relative_label_byte() {
$if !macos {
asm amd64 {
.global one_two_three
.global byte_sequence
byte_sequence:
.byte 0x27, 0x35, 0x0f, 0x48
}