~mcf

https://mforney.org

~mcf/cproc

Last active 9 hours ago

~mcf/oasis

Last active 8 days ago

~mcf/libtls-bearssl

Last active 1 year, 9 days ago

~mcf/dnssec-rr

Last active 1 year, 5 months ago

~mcf/test

Last active 1 year, 10 months ago
View more

Recent activity

[PATCH] Add support for C23 and GNU attribute specifier syntax 9 hours ago

From Michael Forney to ~mcf/cproc

Currently, no GNU attributes are supported, and all standard
attributes are ignored.
---
I had a go at implementing C23 attribute syntax, and handled GNU
__attribute__ syntax as well.

This will needed to support struct epoll_event on x86_64, which
uses a packed layout.

Any comments are welcome.

 Makefile                  |  2 ++
 attr.c                    | 76 +++++++++++++++++++++++++++++++++++++++
 cc.h                      |  6 ++++
[message trimmed]

Re: [PATCH] make variadic args explicit 21 hours ago

From Michael Forney to ~mpu/qbe

On 2021-10-18, Quentin Carbonneaux <quentin@c9x.me> wrote:
> Motivated by his riscv port, Michael Forney proposed in June
> to revise the call syntax for variadic functions. I am here
> reviving his patch so it applies nicely on master. My edits
> are often cosmetic (e.g., better readability in parsing code)
> but I also took the opportunity to remove Ovacall, which is
> made redundant by the new Oargv.
>
> I think this is a nice followup to the unbreakage of env
> calls I pushed recently.
>
> Tell me what you think!

Thanks for polishing this up, Quentin.

Re: Is the '-t' option still in use? a day ago

From Michael Forney to ~mcf/cproc

On 2021-10-24, rempas@tutanota.com <rempas@tutanota.com> wrote:
> After reading the code, the switch case in the "ARGBEGIN" seems to have a
> case for "t" but when I'm trying to pass the option when running "cproc", it
> says that the option is unknown. Maybe I don't understand something right?

You might be confusing the compiler driver (cproc) with the C-to-QBE
translator (cproc-qbe, analogous to gcc's cc1). -t is a valid option
for cproc-qbe, and is passed by cproc to control some
architecture-specific details like char signedness and the va_list
type.

At the moment, cproc as a whole can only be built as a single-target
cross compiler, though the cproc-qbe binary supports multiple targets.
If you want to target multiple architectures, you could do something

Re: Getting version info ? 3 days ago

From Michael Forney to ~mcf/cproc

On 2021-10-19, Marc <dkm@kataplop.net> wrote:
> Hi,

Hi Marc,

> I was wondering if having a command-line option for getting some version
> information would be something that you would consider ?
>
> I'm asking as I am a contributor to compiler-explorer (see
> http://godbolt.org) where cproc was added last summer.

I saw that! I use compiler-explorer a lot to compare what different
compilers generate for various C snippets. It was especially helpful
for fixing floating point equality with unordered operands in QBE.

[PATCH qbe] spill: add some comments describing functions 30 days ago

From Michael Forney to ~mpu/qbe

---
 spill.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/spill.c b/spill.c
index 132e0e9..ff3d189 100644
--- a/spill.c
+++ b/spill.c
@@ -155,6 +155,11 @@ slot(int t)
	return SLOT(s);
}

/* restrict b to at most k registers,
 * preferring those present in f (if
[message trimmed]

[PATCH qbe] util: fix typo preventing 4-byte copy in blit() 30 days ago

From Michael Forney to ~mpu/qbe

---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util.c b/util.c
index a28176d..9a3576a 100644
--- a/util.c
+++ b/util.c
@@ -384,7 +384,7 @@ blit(Ref rdst, uint doff, Ref rsrc, uint sz, Fn *fn)
{
	struct { int st, ld, cls, size; } *p, tbl[] = {
		{ Ostorel, Oload,   Kl, 8 },
		{ Ostorew, Oload,   Kw, 8 },
		{ Ostorew, Oload,   Kw, 4 },
[message trimmed]

[PATCH qbe] amd64: avoid reading past end of passed struct 30 days ago

From Michael Forney to ~mpu/qbe

If the size of the struct is not a multiple of 8, the actual struct
size may be different from the size reserved on the stack.

This fixes the case where the struct is passed in memory, but we
still may over-read a struct passed in registers. A TODO is added
for now.
---
 amd64/sysv.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/amd64/sysv.c b/amd64/sysv.c
index 045ec85..0142a34 100644
--- a/amd64/sysv.c
+++ b/amd64/sysv.c
[message trimmed]

[PATCH qbe] avoid some one last gcc truncation warning 30 days ago

From Michael Forney to ~mpu/qbe

---
 rega.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rega.c b/rega.c
index bd26f1c..0359d2b 100644
--- a/rega.c
+++ b/rega.c
@@ -667,7 +667,7 @@ rega(Fn *fn)
			b1->link = blist;
			blist = b1;
			fn->nblk++;
			sprintf(b1->name, "%s_%s", b->name, s->name);
			(void)!snprintf(b1->name, sizeof(b1->name), "%s_%s", b->name, s->name);
[message trimmed]

Re: chibicc can bootstrap cproc a month ago

From Michael Forney to ~mcf/cproc

On 2021-09-17, Seo Sanghyeon <sanxiyn@gmail.com> wrote:
> I am not sure whether this is of interest to anyone, but I already
> did debugging so I thought I'd let you know.

I am definitely interested in this, thanks for working on it! The more
compilers that can build cproc the better.

> There were four issues. Diff is attached.
>
> 1. chibicc does not understand -pipe option (see configure).

This one is mostly just habit, I don't think it makes any sort of
noticeable difference in compilation time when building with gcc, and
cproc always uses pipes.

[PATCH qbe] parse: fix loadw when assigned to l temporary a month ago

From Michael Forney to ~mpu/qbe

The documentation states that loadw is syntactic sugar for loadsw,
but it actually got parsed as Oload. If the result is an l temporary,
Oload behaves like Oloadl, not Oloadsw.

To fix this, parse Tloadw as Oloadsw explicitly.
---
I had a bug in cproc for struct copies, where I was emitting a
series of loadw/storew, but accidentally using l as the temporary
type instead of w. This was causing QBE to do 64-bit loads instead
of 32-bit as intended.

 parse.c        |  4 +++-
 test/loadw.ssa | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
[message trimmed]