This commit makes sure all Go types can be encoded in the interface type
code, so that Type.Kind() always returns a proper type kind for any
non-nil interface.
Some instructions emitted by LLVM (like movaps) expect 16-byte
alignment, while the allocator assumed that 8-byte alignment is good
enough.
TODO: this issue came to light with LLVM optimizing a complex128 store
to the movaps instruction, which must be aligned. It looks like this
means that the <2 x double> IR type is actually 16-byte aligned instead
of 8-byte like a double. If this is the case, the alignment of complex
numbers needs to be updated in the whole compiler.
This makes sure the most commonly used types have the lowest type codes.
This was intended to be the case, but apparently I forgot to sort them
the right way.
Currently, if the user hasn't run
`git submodule update --init` beforehand, the docker build will fail
This little addition makes the build atomic and ready for automatic CI tests for the future
When building statically against LLVM, LLD is also included now. When
included, the built in wasm-ld will automatically be used instead of the
external command.
There is also support for linking ELF files but because lld does not
fully support armv6m this is not yet enabled (it produces a warning).
* machine/atsamd21: implement PWM interface for all pins that support it
* machine/atsamd21: correct PWM channel mapping for pin PA18
* machine/atsamd21: move clock init into InitPWM() to hopefully save power
Use stringIterator.byteindex as the loop index, and remove
stringIterator.rangeindex, as "the index of the loop is the starting
position of the current rune, measured in bytes". This patch also fixes
the current loop index returned by stringNext, using `it.byteindex'
before - not after - `length' is added.
* machine/uart: add core support for multiple UARTs by allowing for multiple RingBuffers
* machine/uart: complete core support for multiple UARTs
* machine/uart: no need to store pointer to UART, better to treat like I2C and SPI
* machine/uart: increase ring buffer size to 128 bytes
* machine/uart: improve godocs comments and use comma-ok idiom for buffer Put/Get methods
Extract directly from the string instead of calling the len() builtin.
This is both cleaner and avoids a zero-extension to an integer on AVR,
which led to a LLVM verification error.
The magic CGo construct to turn a C array into a slice turned out to be
not portable.
Note: this is not the only problem, there is also a bug in the Go
bindings for LLVM. With that one fixed, it is possible to build TinyGo
on a Raspberry Pi (32-bit).
Support for channels is not complete. The following pieces are missing:
* Channels with values bigger than int. An int in TinyGo can always
contain at least a pointer, so pointers are okay to send.
* Buffered channels.
* The select statement.
Before this commit, goroutine support was spread through the compiler.
This commit changes this support, so that the compiler itself only
generates simple intrinsics and leaves the real support to a compiler
pass that runs as one of the TinyGo-specific optimization passes.
The biggest change, that was done together with the rewrite, was support
for goroutines in WebAssembly for JavaScript. The challenge in
JavaScript is that in general no blocking operations are allowed, which
means that programs that call time.Sleep() but do not start goroutines
also have to be scheduled by the scheduler.
Do not try to use the ExectutionEngine of Go, instead compile the
program in the conventional way and run the binary.
This fixes some code duplication that causes slight (but problematic)
misbehavior between `tinygo build` and `tinygo run`.