summary refs log tree commit diff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2024-01-02 11:09:18 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2024-01-02 12:12:05 +0100
commit85287081c4a25785dec1ec48c488a5879b3c37ac (patch)
tree83387b773a127d32498d9c9b356ed150fd77a780
parent24d68e841f6c4adf0622b132f905e97d115a4e2d (diff)
downloadroux-85287081c4a25785dec1ec48c488a5879b3c37ac.tar.gz
dbgloc: add column argument
dbgloc line [col]

This is implemented in a backwards-compatible manner.
-rw-r--r--all.h2
-rw-r--r--amd64/emit.c2
-rw-r--r--arm64/emit.c2
-rw-r--r--emit.c7
-rw-r--r--ops.h2
-rw-r--r--parse.c8
-rw-r--r--rv64/emit.c2
7 files changed, 18 insertions, 7 deletions
diff --git a/all.h b/all.h
index 4d36314..e421b9c 100644
--- a/all.h
+++ b/all.h
@@ -569,7 +569,7 @@ void rega(Fn *);
 void emitfnlnk(char *, Lnk *, FILE *);
 void emitdat(Dat *, FILE *);
 void emitdbgfile(char *, FILE *);
-void emitdbgloc(uint, FILE *);
+void emitdbgloc(uint, uint, FILE *);
 int stashbits(void *, int);
 void elf_emitfnfin(char *, FILE *);
 void elf_emitfin(FILE *);
diff --git a/amd64/emit.c b/amd64/emit.c
index 297cc76..51d1a5c 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -548,7 +548,7 @@ emitins(Ins i, Fn *fn, FILE *f)
 		emitcopy(i.arg[1], TMP(XMM0+15), i.cls, fn, f);
 		break;
 	case Odbgloc:
-		emitdbgloc(i.arg[0].val, f);
+		emitdbgloc(i.arg[0].val, i.arg[1].val, f);
 		break;
 	}
 }
diff --git a/arm64/emit.c b/arm64/emit.c
index 78a0358..990d839 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -447,7 +447,7 @@ emitins(Ins *i, E *e)
 			emitf("mov %=, sp", i, e);
 		break;
 	case Odbgloc:
-		emitdbgloc(i->arg[0].val, e->f);
+		emitdbgloc(i->arg[0].val, i->arg[1].val, e->f);
 		break;
 	}
 }
diff --git a/emit.c b/emit.c
index b880d67..490628e 100644
--- a/emit.c
+++ b/emit.c
@@ -235,7 +235,10 @@ emitdbgfile(char *fn, FILE *f)
 }
 
 void
-emitdbgloc(uint loc, FILE *f)
+emitdbgloc(uint line, uint col, FILE *f)
 {
-	fprintf(f, "\t.loc %u %u\n", curfile, loc);
+	if (col != 0)
+		fprintf(f, "\t.loc %u %u %u\n", curfile, line, col);
+	else
+		fprintf(f, "\t.loc %u %u\n", curfile, line);
 }
diff --git a/ops.h b/ops.h
index b6b148a..8ccf80d 100644
--- a/ops.h
+++ b/ops.h
@@ -122,7 +122,7 @@ O(vastart, T(m,e,e,e, x,e,e,e), 0) X(0, 0, 0) V(0)
 O(copy,    T(w,l,s,d, x,x,x,x), 0) X(0, 0, 1) V(0)
 
 /* Debug */
-O(dbgloc,  T(w,l,s,d, x,x,x,x), 0) X(0, 0, 1) V(0)
+O(dbgloc,  T(w,e,e,e, w,e,e,e), 0) X(0, 0, 1) V(0)
 
 /****************************************/
 /* INTERNAL OPERATIONS (keep nop first) */
diff --git a/parse.c b/parse.c
index 33ed6ec..738ec5b 100644
--- a/parse.c
+++ b/parse.c
@@ -669,6 +669,14 @@ parseline(PState ps)
 		arg[0] = INT(tokval.num);
 		if (arg[0].val != tokval.num)
 			err("line number too big");
+		if (peek() == Tcomma) {
+			next();
+			expect(Tint);
+			arg[1] = INT(tokval.num);
+			if (arg[1].val != tokval.num)
+				err("column number too big");
+		} else
+			arg[1] = INT(0);
 		goto Ins;
 	}
 	if (op == Tcall) {
diff --git a/rv64/emit.c b/rv64/emit.c
index 23a8be8..a410ddf 100644
--- a/rv64/emit.c
+++ b/rv64/emit.c
@@ -406,7 +406,7 @@ emitins(Ins *i, Fn *fn, FILE *f)
 			emitf("mv %=, sp", i, fn, f);
 		break;
 	case Odbgloc:
-		emitdbgloc(i->arg[0].val, f);
+		emitdbgloc(i->arg[0].val, i->arg[1].val, f);
 		break;
 	}
 }