<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sinter/basic.c, branch master</title>
<subtitle>Intermediate functional language that compiles to LLVMIR</subtitle>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/'/>
<entry>
<title>checkpoint</title>
<updated>2019-12-23T01:32:39+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-12-23T01:32:39+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=7bc67b95161a34f8eca635d4000d9602508a9243'/>
<id>7bc67b95161a34f8eca635d4000d9602508a9243</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add basics for interpreter; add CLI options</title>
<updated>2019-11-10T03:18:30+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-11-09T19:47:29+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=58ab7191eecd6d1758356bafd40ff40b42daf3d0'/>
<id>58ab7191eecd6d1758356bafd40ff40b42daf3d0</id>
<content type='text'>
The compiler now accepts options on the command-line, such as whether to
interpret or compile, or what kind of output is desired.

Instead of mallocing (and creating a memory leak), generated code now
uses the Boehm garbage collector to allocate memory for boxes. I'm not
entirely sure how the GC works, but it does seem to be working (tested
by setting the environment variable GC_PRINT_STATS when running a
compiled program that calculates a Fibonacci number). More testing
relating to the GC should be created.

The basics for an interpreted mode has been started, but getting it to
work fully would be difficult: it would require figuring out how to
dynamically link LLVM modules/object files into the LLVM execution
engine, both for calling wrapper functions and for using the GC.

Removed -Weverything because it was finding problems in the GC code
despite it being included as a system library.

The main function of an inter program has been renamed to inter_main.
The GC requires GC_INIT is invoked at initialisation on some systems, so
common.c now contains the real main function, which runs GC_INIT
followed by inter_main. GC_INIT is a macro, so it cannot be called
easily from LLVMIR.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The compiler now accepts options on the command-line, such as whether to
interpret or compile, or what kind of output is desired.

Instead of mallocing (and creating a memory leak), generated code now
uses the Boehm garbage collector to allocate memory for boxes. I'm not
entirely sure how the GC works, but it does seem to be working (tested
by setting the environment variable GC_PRINT_STATS when running a
compiled program that calculates a Fibonacci number). More testing
relating to the GC should be created.

The basics for an interpreted mode has been started, but getting it to
work fully would be difficult: it would require figuring out how to
dynamically link LLVM modules/object files into the LLVM execution
engine, both for calling wrapper functions and for using the GC.

Removed -Weverything because it was finding problems in the GC code
despite it being included as a system library.

The main function of an inter program has been renamed to inter_main.
The GC requires GC_INIT is invoked at initialisation on some systems, so
common.c now contains the real main function, which runs GC_INIT
followed by inter_main. GC_INIT is a macro, so it cannot be called
easily from LLVMIR.
</pre>
</div>
</content>
</entry>
<entry>
<title>Enable -Weverything</title>
<updated>2019-10-30T14:38:00+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-10-30T14:38:00+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=935600fb9612ef569f1f68f60b0b7cdd57ce7af6'/>
<id>935600fb9612ef569f1f68f60b0b7cdd57ce7af6</id>
<content type='text'>
Clang has a -Weverything option, that enables all compile-time warnings
and elevates them all to errors. This option is now passed to the
compiler, and all warnings/errors the code produced have been addressed.

Using -Weverything locks the project into using clang as its compiler:
this should not be a problem since clang is probably being used to
compile the LLVM output of the project anyway. If support for other
compilers is required, it should be simple enough to replace
-Weverything with an equivalent collection of portable flags.

Explicit Makefile rules for compiling the C files produced by flex/bison
are now included in the project since these C files absolutely do not
pass -Weverything checks.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Clang has a -Weverything option, that enables all compile-time warnings
and elevates them all to errors. This option is now passed to the
compiler, and all warnings/errors the code produced have been addressed.

Using -Weverything locks the project into using clang as its compiler:
this should not be a problem since clang is probably being used to
compile the LLVM output of the project anyway. If support for other
compilers is required, it should be simple enough to replace
-Weverything with an equivalent collection of portable flags.

Explicit Makefile rules for compiling the C files produced by flex/bison
are now included in the project since these C files absolutely do not
pass -Weverything checks.
</pre>
</div>
</content>
</entry>
<entry>
<title>Box everything</title>
<updated>2019-10-29T17:14:56+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-10-29T17:14:56+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=42c26919532146b887b134430c4713709b7a4d75'/>
<id>42c26919532146b887b134430c4713709b7a4d75</id>
<content type='text'>
Everything now gets reduced to an i8*, either through placing on the
heap (in the case of primitives) or just through a simple pointer cast.

In the case of primitives, boxing might be avoided by casting the
primitive to an i8*, however this would only work for primitives with
sizes less than or equal to the size of a pointer on the system.

Boxing increases the generated LLVMIR size dramatically, so it is
probably worth looking into ways to reduce the frequency of boxing. One
option is to keep track of whether or not a value has been boxed, and
only boxing/unboxing it when necessary instead of all the time.

The current implementation uses LLVMBuildMalloc, which allocates memory,
but does not ever free this memory. Freeing boxes once its value is
extracted may be safe, though I'm not certain. It may be worth looking
into LLVM's garbage collection support at this point.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Everything now gets reduced to an i8*, either through placing on the
heap (in the case of primitives) or just through a simple pointer cast.

In the case of primitives, boxing might be avoided by casting the
primitive to an i8*, however this would only work for primitives with
sizes less than or equal to the size of a pointer on the system.

Boxing increases the generated LLVMIR size dramatically, so it is
probably worth looking into ways to reduce the frequency of boxing. One
option is to keep track of whether or not a value has been boxed, and
only boxing/unboxing it when necessary instead of all the time.

The current implementation uses LLVMBuildMalloc, which allocates memory,
but does not ever free this memory. Freeing boxes once its value is
extracted may be safe, though I'm not certain. It may be worth looking
into LLVM's garbage collection support at this point.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add struct type definitions</title>
<updated>2019-10-28T22:25:54+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-10-28T22:25:54+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=85093de7415e9410dc5917f8ef6ac489b8198b42'/>
<id>85093de7415e9410dc5917f8ef6ac489b8198b42</id>
<content type='text'>
Struct-like types can now be created using the `type` builtin.
This creates a constructor function as well as a function for accessing
each of the struct's properties.

LLVM's type checking makes using these structs a little awkward: they
currently cannot be returned by any functions (except the constructor).
The aim is to box everything, so that functions can return values they
don't know much about.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Struct-like types can now be created using the `type` builtin.
This creates a constructor function as well as a function for accessing
each of the struct's properties.

LLVM's type checking makes using these structs a little awkward: they
currently cannot be returned by any functions (except the constructor).
The aim is to box everything, so that functions can return values they
don't know much about.
</pre>
</div>
</content>
</entry>
<entry>
<title>Implement recursive definition support</title>
<updated>2019-10-12T01:41:50+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-10-12T01:41:50+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=417c0addcafe8bfd3d9305ab7d2fac207ad54700'/>
<id>417c0addcafe8bfd3d9305ab7d2fac207ad54700</id>
<content type='text'>
Enables definition of a recursive function through defining a base case
using an `if` statement. Previously, doing this would produce compilable
code, but running the product executable would cause a stack overflow,
since the executable would attempt to evaluate both sides of the branch.

Making the `if` statement a built-in part of the language is a bit
crude, but is simple and works. Maybe, if time allows, this will be
revisited.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Enables definition of a recursive function through defining a base case
using an `if` statement. Previously, doing this would produce compilable
code, but running the product executable would cause a stack overflow,
since the executable would attempt to evaluate both sides of the branch.

Making the `if` statement a built-in part of the language is a bit
crude, but is simple and works. Maybe, if time allows, this will be
revisited.
</pre>
</div>
</content>
</entry>
<entry>
<title>Implement function definitions</title>
<updated>2019-10-09T13:26:04+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-10-09T13:26:04+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=6d4925e61687c2221ab20a4dd2371d1a3e7acb2d'/>
<id>6d4925e61687c2221ab20a4dd2371d1a3e7acb2d</id>
<content type='text'>
Functions can now be defined using the "def" construct. A "main"
function has to be defined for LLVM to compile the program.

Recursive function definitions are not supported, since all values are
eagerly evaluated, causing infinite recursion of the non-base case.
Recursive definitions can be supported either by including an if
primitive that does not evaluate both sides, or by implementing support
for lazy evalution. I'm interested in exploring the latter, but will
probably implement the former for now.

Similar to the if primitive above, the def primitive is currently an
implementation which could potentially be altered into a function that
manipulates meta-variables at compile time. This would require
compile-time evaluation of functions, which would be really cool, but is
also superfluous to the current goal. I might return to this idea after
I'm happy with the base implementation of the language.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Functions can now be defined using the "def" construct. A "main"
function has to be defined for LLVM to compile the program.

Recursive function definitions are not supported, since all values are
eagerly evaluated, causing infinite recursion of the non-base case.
Recursive definitions can be supported either by including an if
primitive that does not evaluate both sides, or by implementing support
for lazy evalution. I'm interested in exploring the latter, but will
probably implement the former for now.

Similar to the if primitive above, the def primitive is currently an
implementation which could potentially be altered into a function that
manipulates meta-variables at compile time. This would require
compile-time evaluation of functions, which would be really cool, but is
also superfluous to the current goal. I might return to this idea after
I'm happy with the base implementation of the language.
</pre>
</div>
</content>
</entry>
<entry>
<title>Support + and * operations</title>
<updated>2019-10-03T01:42:28+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-10-03T01:42:28+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=64d093247985f759669b7726542291382c1e3fc5'/>
<id>64d093247985f759669b7726542291382c1e3fc5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Initial commit</title>
<updated>2019-09-30T00:56:15+00:00</updated>
<author>
<name>Tom Harley</name>
</author>
<published>2019-09-30T00:56:15+00:00</published>
<link rel='alternate' type='text/html' href='https://www.magnostherobot.co.uk/git.cgi/5th-year-coursework/sinter/commit/?id=fbe39f58fc0d757f8ffe54c6dc96bbc690862ded'/>
<id>fbe39f58fc0d757f8ffe54c6dc96bbc690862ded</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
