| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
|
|
When trying to determine if an expression is tail-recursive, this should
not error in the case that the expression is a string literal.
|
|
Sinter now has \n, \t, and \\ escape sequences.
|
|
Now the unit tests will run again! :)
|
|
The arity of the function should be cast to an integer type that's the
same size as a pointer.
|
|
Makes it possible to print to stderr in non-debug mode, for example to
warn the user of a possible error.
|
|
Adding attributes to functions/values has been broken by the upgrade.
Additionally, the debug builder wants more information which is
currently not being provided.
|
|
|
|
This prevents errors when using clang.
|
|
Whoops! Strings were getting their last characters chopped off.
No longer!
|
|
Previously, nested case statements would cause phis to be given
incorrect incoming blocks, causing issues when compiling the LLVMIR
with clang.
To fix this, all case branches are given a second "exit" block
that they jump to before jumping to the phi block. This way, we
always know the block that was just left to get to the phi.
|
|
escape slashes still need to be supported though!
|
|
Installing on Ubuntu requires editing the Makefile a little, and
also installing LLVM10 which is non-trivial.
|
|
Both this feature and "let" statements (committed previously) require
documentation.
|
|
|
|
|
|
Some of the functions generated by sinc can have attributes added to
them that might be difficult for the LLVM toolchain to infer.
Attribute generation can be turned off with `-O no-llvm-attributes`.
|
|
The tail recursion mod cons optimisation must now be enabled explicitly
using `-O tail-recursion-mod-cons`.
|
|
|
|
- Removed unused example files
- Removed redundant common.c
- Added extra files to make sure the current version compiles the
nqueens solution correctly
- Added extensionless files to .gitignore
- Added a way to install sinter
|
|
The width of an int can be specified at the site of its creation. For
example, the following function returns an int of width 2 bits and value
1:
[def two_bit_int []
(2 1)]
Ints can still be written the old way; in these cases the compiler looks
for a default int bit-width (specified with the -w flag). If a default
has not been defined, the compiler throws an error.
|
|
Only affects atomic types, not structs. Accepts three options:
- "-u always": always boxes
- "-u never": never boxes
- "-u smart": inserts a comparison of sizes, and boxes only if
the item is bigger than a pointer.
"smart" is smart in name only; I expected the comparison to be optimised
away (since the sizes of the types are known at compile-time), but it
seems to run significantly slower than the other options.
Steps to improve:
- try making the comparison compile-time (or, if it already is, find out
why it's so slow);
|
|
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
|
|
|