sparse LLVM backend (was Re: [rfc] built-in native compiler for Linux?)
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 sparse LLVM backend (was Re: [rfc] built-in native compiler for Linux?)
(resent -- the mail monster apparently ate the first one)
Just to make this crazy thread even crazier, I have successfully gotten sparse to create a valid x86-64 object file from C source code (...which I then executed).
The attached patch adds a code generator backend to sparse, that generates LLVM bitcode. This bitcode can then be converted to ELF .o files using standard tools -- see instructions in the header of s2l.c.
Do I expect this to be used in the kernel? Not really. I'm just doing this for fun, to add a compiler backend to sparse. It was pretty easy to get integer and logical operations going.
The work is based on compile-i386; as it turns out, LLVM's bitcode can be made type-aware, so I wanted to see how things would turn out generating code at a higher level. Given the higher-level constructs, I didn't feel the need to bother with linearized form.
Caveats...
- don't stray too far from simple, integer types
- bitfields caused explosions, but you knew that anyway
Cheers all,
Jeff
.gitignore | 2 Makefile | 3 s2l-gen.c | 2101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ s2l.c | 77 ++ 4 files changed, 2182 insertions(+), 1 deletion(-)
.gitignore +2 -0
@@ -2,6 +2,7 @@ *.o *.a *.so +*.o.d # generated pre-process.h
@@ -20,6 +21,7 @@ example test-unssa ctags c2xml +s2l # tags tags
Makefile +2 -1
@@ -35,7 +35,7 @@ INCLUDEDIR=$(PREFIX)/include PKGCONFIGDIR=$(LIBDIR)/pkgconfig PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse \ - test-linearize example test-unssa test-dissect ctags + test-linearize example test-unssa test-dissect ctags s2l INST_PROGRAMS=sparse cgcc INST_MAN1=sparse.1 cgcc.1
@@ -108,6 +108,7 @@ sparse.pc: sparse.pc.in compile_EXTRA_DEPS = compile-i386.o +s2l_EXTRA_DEPS = s2l-gen.o PROG_LINK_CMD = $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $^ $($@_EXTRA_OBJS)
s2l-gen.c new file +2101 -0
2,101 lines not on this page · raw message
s2l.c new file +77 -0
77 lines not on this page · raw message
Re: [PATCH] sparse LLVM backend
From: Jeff Garzik <[email protected]>
Date: Fri, 24 Apr 2009 22:06:42 -0400
Quoted 1 line
(resent -- the mail monster apparently ate the first one)
The CC: line from hell was too long and thus getting rejected by vger