~mpu/qbe

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 2

[PATCH] dbgloc: add column argument

Details
Message ID
<20240102100919.208532-1-sir@cmpwn.com>
DKIM signature
missing
Download raw message
Patch: +20 -9
dbgloc line [col]

This is implemented in a backwards-compatible manner.
---
 all.h        | 5 +++--
 amd64/emit.c | 2 +-
 arm64/emit.c | 2 +-
 emit.c       | 7 +++++--
 ops.h        | 2 +-
 parse.c      | 9 ++++++++-
 rv64/emit.c  | 2 +-
 7 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/all.h b/all.h
index 4d36314..fdda1cf 100644
--- a/all.h
+++ b/all.h
@@ -203,7 +203,8 @@ enum {
	Kw,
	Kl,
	Ks,
	Kd
	Kd,
	Ko /* optional argument */
};

#define KWIDE(k) ((k)&1)
@@ -569,7 +570,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..a43c7fd 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,l,s,d, o,o,o,o), 0) X(0, 0, 1) V(0)

/****************************************/
/* INTERNAL OPERATIONS (keep nop first) */
diff --git a/parse.c b/parse.c
index 33ed6ec..0976a50 100644
--- a/parse.c
+++ b/parse.c
@@ -669,6 +669,13 @@ parseline(PState ps)
		arg[0] = INT(tokval.num);
		if (arg[0].val != tokval.num)
			err("line number too big");
		if (peek() == Tcomma) {
			expect(Tcomma);
			expect(Tint);
			arg[1] = INT(tokval.num);
			if (arg[1].val != tokval.num)
				err("line number too big");
		};
		goto Ins;
	}
	if (op == Tcall) {
@@ -833,7 +840,7 @@ typecheck(Fn *fn)
					err("no %s operand expected in %s",
						n == 1 ? "second" : "first",
						optab[i->op].name);
				if (rtype(r) == -1 && k != Kx)
				if (rtype(r) == -1 && k != Kx && k != Ko)
					err("missing %s operand in %s",
						n == 1 ? "second" : "first",
						optab[i->op].name);
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;
	}
}
-- 
2.43.0
Details
Message ID
<636b8ea5-b3b0-4304-940b-3632759304aa@app.fastmail.com>
In-Reply-To
<20240102100919.208532-1-sir@cmpwn.com> (view parent)
DKIM signature
missing
Download raw message
On Tue, Jan 2, 2024, at 11:09, Drew DeVault wrote:
> This is implemented in a backwards-compatible manner.

dbgloc is still experimental and undocumented,
what would you think of breaking backwards
compatibility?
Details
Message ID
<CY458KQ7TVSW.3SDZ9HSPFINQ7@taiga>
In-Reply-To
<636b8ea5-b3b0-4304-940b-3632759304aa@app.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
On Tue Jan 2, 2024 at 11:19 AM CET, Quentin Carbonneaux wrote:
> On Tue, Jan 2, 2024, at 11:09, Drew DeVault wrote:
> > This is implemented in a backwards-compatible manner.
>
> dbgloc is still experimental and undocumented,
> what would you think of breaking backwards
> compatibility?

Even if we were to table that option, I'm not for it even without
compatibility concerns. Some compilers may not bother collecting
columns, and GNU as's .loc macro also makes the column optional. So it
makes sense for it to be an optional parameter.
Details
Message ID
<bb985df7-4d8f-45dc-9d3b-1f64773eefd6@app.fastmail.com>
In-Reply-To
<CY458KQ7TVSW.3SDZ9HSPFINQ7@taiga> (view parent)
DKIM signature
missing
Download raw message
On Tue, Jan 2, 2024, at 11:20, Drew DeVault wrote:
> Even if we were to table that option, I'm not for it even without
> compatibility concerns. Some compilers may not bother collecting
> columns, and GNU as's .loc macro also makes the column optional. So it
> makes sense for it to be an optional parameter.

Okay, I just pushed a simplified version.
Let me know how that works for you.
Details
Message ID
<CY4AVE5WJ9GI.11B27YGUULZXM@taiga>
In-Reply-To
<bb985df7-4d8f-45dc-9d3b-1f64773eefd6@app.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
LGTM, thanks!
Reply to thread Export thread (mbox)