diff --git a/lib/asm-parser.js b/lib/asm-parser.js index 2e6c30d54..3ca6b3289 100644 --- a/lib/asm-parser.js +++ b/lib/asm-parser.js @@ -218,7 +218,11 @@ class AsmParser extends AsmRegex { const files = this.parseFiles(asmLines); let prevLabel = ""; - const commentOnly = /^\s*(((#|@|;|\/\/).*)|(\/\*.*\*\/))$/; + // Lines matching the following pattern are considered comments: + // - starts with '#', '@', '//' or a single ';' (non repeated) + // - starts with ';;' and has non-whitespace before end of line + const commentOnly = /^\s*(((#|@|\/\/).*)|(\/\*.*\*\/)|(;\s*)|(;[^;].*)|(;;.*\S.*))$/; + const commentOnlyNvcc = /^\s*(((#|;|\/\/).*)|(\/\*.*\*\/))$/; const sourceTag = /^\s*\.loc\s+(\d+)\s+(\d+).*/; const source6502Dbg = /^\s*\.dbg\s+line,\s*"([^"]+)",\s*(\d+)/; diff --git a/test/cases/kalray-hellow.asm b/test/cases/kalray-hellow.asm index f7ff3cabe..1e22800fc 100644 --- a/test/cases/kalray-hellow.asm +++ b/test/cases/kalray-hellow.asm @@ -4,7 +4,7 @@ .LC0: .string "%s , %s , %lld , %d , %lld\n" .text - + ; This is a comment .align 8 .globl toto .type toto, @function @@ -12,6 +12,7 @@ toto: add $r12 = $r12, -16 get $r8 = $ra ;; + ;; This is also a comment sw 28[$r12] = $r10 add $r10 = $r12, 16 ;; @@ -40,7 +41,7 @@ toto: add $r12 = $r12, 16 ;; set $ra = $r1 - ;; /* Can't issue next in the same bundle */ + ;; ret ;; .size toto, .-toto @@ -74,7 +75,7 @@ main: sd 16[$r12] = $r0r1 make $r1 = .LC1 make $r0 = .LC0 - ;; /* Can't issue next in the same bundle */ + ;; call printf ;; add $r12 = $r10, -16 @@ -88,7 +89,7 @@ main: ;; .OTHERDUMMY: set $ra = $r1 - ;; /* Can't issue next in the same bundle */ + ;; ret ;; .size main, .-main diff --git a/test/cases/kalray-hellow.asm.directives b/test/cases/kalray-hellow.asm.directives index bd054580c..58f9ef625 100644 --- a/test/cases/kalray-hellow.asm.directives +++ b/test/cases/kalray-hellow.asm.directives @@ -1,10 +1,11 @@ .LC0: .string "%s , %s , %lld , %d , %lld\n" - + ; This is a comment toto: add $r12 = $r12, -16 get $r8 = $ra ;; + ;; This is also a comment sw 28[$r12] = $r10 add $r10 = $r12, 16 ;; @@ -33,7 +34,7 @@ toto: add $r12 = $r12, 16 ;; set $ra = $r1 - ;; /* Can't issue next in the same bundle */ + ;; ret ;; @@ -59,7 +60,7 @@ main: sd 16[$r12] = $r0r1 make $r1 = .LC1 make $r0 = .LC0 - ;; /* Can't issue next in the same bundle */ + ;; call printf ;; add $r12 = $r10, -16 @@ -73,6 +74,6 @@ main: ;; .OTHERDUMMY: set $ra = $r1 - ;; /* Can't issue next in the same bundle */ + ;; ret ;; diff --git a/test/cases/kalray-hellow.asm.directives.labels b/test/cases/kalray-hellow.asm.directives.labels index 35d3bf7eb..99f630a6e 100644 --- a/test/cases/kalray-hellow.asm.directives.labels +++ b/test/cases/kalray-hellow.asm.directives.labels @@ -1,10 +1,11 @@ .LC0: .string "%s , %s , %lld , %d , %lld\n" - + ; This is a comment toto: add $r12 = $r12, -16 get $r8 = $ra ;; + ;; This is also a comment sw 28[$r12] = $r10 add $r10 = $r12, 16 ;; @@ -33,7 +34,7 @@ toto: add $r12 = $r12, 16 ;; set $ra = $r1 - ;; /* Can't issue next in the same bundle */ + ;; ret ;; @@ -59,7 +60,7 @@ main: sd 16[$r12] = $r0r1 make $r1 = .LC1 make $r0 = .LC0 - ;; /* Can't issue next in the same bundle */ + ;; call printf ;; add $r12 = $r10, -16 @@ -71,6 +72,6 @@ main: add $r12 = $r12, 16 ;; set $ra = $r1 - ;; /* Can't issue next in the same bundle */ + ;; ret ;;