Ayke van Laethem
1f2af7d848
compiler: do not remove dead globals
These were not removed when they contain data, and will be removed by
LLVM anyway.
6 years ago
Ayke van Laethem
b0aeaed635
compiler: allow a global to be defined multiple times
This is only possible when using compiler directives like the magic
_extern_ prefix on global variables.
6 years ago
Ayke van Laethem
77934f364f
avr: fix corrupted .data byte
The stack and the .data section shared the first byte, leading to
corruption of the first byte of .data.
6 years ago
Ron Evans
fc0ff3a987
avr: initial implementation for PWM
Signed-off-by: Ron Evans <ron@hybridgroup.com>
Edited slightly by Ayke van Laethem
6 years ago
Ayke van Laethem
94358959f5
compiler: fix unsafe.Sizeof and friends for AVR
This fixes runtime.printptr().
6 years ago
Ayke van Laethem
e04f0868ed
compiler: fix constant globals on AVR
Turn const globals into non-const globals, at least until pointers have
the correct address space attribute.
6 years ago
Ayke van Laethem
a02426948b
avr: implement .data section
This doesn't completely work for some reason as the first character of
.data is corrupted, but otherwise it works.
6 years ago
Ayke van Laethem
39e3fe28db
avr: convert initialization from asm to Go
This increases code size by 1 instruction (2 bytes) because LLVM isn't
yet smart enough to recognize that it doesn't need to clear a register
to use 0: it can just use r1 which is always 0 according to the
convention. It makes initialization a lot easier to read, however.
6 years ago
Ayke van Laethem
0d8a7e1666
avr: link with the GCC runtime library
This allows the use of some compiler-generated builtins that are
hopefully compatible with LLVM. Example: println(uint8(foo))
Code size is unchanged normally but of course compiler builtins will
increase code size when actually used (for example with division).
6 years ago
Ayke van Laethem
a25e598463
compiler: truncate output files before writing
6 years ago
Ayke van Laethem
35fe24981f
runtime/unix: panic: call abort() instead of exit(2)
abort() will cause gdb to show a backtrace when running inside the
debugger, and abort() seems more appropriate anyway for critical errors.
6 years ago
Ayke van Laethem
1484bb5c2c
all: basic support for the os package
The resulting binary is pretty big due to lacking optimizations
(probably because of interfaces), so that should be fixed.
6 years ago
Ayke van Laethem
c237633d34
all: use a custom sync package
The sync package is strongly tied to the runtime, so it's easier to
implement a new one. Besides, it's pretty big so it's better to replace
it.
6 years ago
Ayke van Laethem
94b18e2d79
compiler: support integer convert in interpreter
6 years ago
Ayke van Laethem
1d2e0cd259
compiler: don't show DebugRef with -dumpssa
6 years ago
Ayke van Laethem
2a20c0c7f0
all: rewrite sleep function
time.Sleep now compiles on all systems, so lets use that.
Additionally, do a few improvements in time unit handling for the
scheduler. This should lead to somewhat longer sleep durations without
wrapping (on some platforms).
Some examples got smaller, some got bigger. In particular, code using
the scheduler got bigger and the blinky1 example got smaller (especially
on Arduino: 380 -> 314 bytes).
6 years ago
Ayke van Laethem
1ac67cf8de
compiler: adding a few more ignored init calls
These calls are generated in the JavaScript target (syscall/js and
syscall with GOOS=js), but they are not used at the moment. So ignore
them until they're needed.
6 years ago
Ayke van Laethem
38efc5653d
compiler: support compile-time hashmap with int keys
6 years ago
Ayke van Laethem
152e12e4b0
all: implement iterating over hashmaps
Still no support for hashmaps > 8 entries, but this kind of works.
6 years ago
Ayke van Laethem
5b4b6cfee2
compiler: use -dumpssa flag in interpreter
This is useful for debugging.
6 years ago
Ayke van Laethem
866a6edb5f
compiler: fix word size for AVR
Using a word size less than 4 led to typechecker errors.
6 years ago
Ayke van Laethem
327076da39
examples/test: add slice-a-slice test
6 years ago
Ayke van Laethem
1387a1024d
examples/test: small cleanup
I forgot to remove some commented out code...
6 years ago
Ayke van Laethem
112f6dc01a
all: implement `tinygo flash` command
This will now just work:
tinygo flash -target=arduino examples/blinky1
6 years ago
Ayke van Laethem
6450daa3c8
runtime/cgo: go fmt
6 years ago
Ayke van Laethem
13633133a5
Makefile: simplify `make fmt`
There is no C source file anymore `go fmt` will complain about.
6 years ago
Ayke van Laethem
09cbd223c3
compiler: remove -runtime flag
It is not necessary anymore.
6 years ago
Ayke van Laethem
c763e9f1a6
compiler: produce .hex files directly
6 years ago
Ayke van Laethem
f41a8032e7
machine/dummy: add fake button pins
6 years ago
Ayke van Laethem
752332ff13
machine/nrf: implement reading GPIO pins
6 years ago
Ron Evans
ab6757fe11
avr: implement Get() function on AVR, and leave stubs for NRF and dummy machines
Signed-off-by: Ron Evans <ron@hybridgroup.com>
6 years ago
Ayke van Laethem
ec50db729d
compiler: implement slicing slices
6 years ago
Ayke van Laethem
5b3ef2c02f
compiler: fix unreachable type assert
The unreachable instruction is actually a block terminator so may only
be inserted at the end of a basic block. This is not always the case for
type asserts, so don't insert this instruction.
LLVM will hopefully optimize it anyway when it realizes anything after
the panic() call is unreachable.
6 years ago
Ayke van Laethem
9cd7c7f0ba
compiler: fix phi nodes for type asserts
Type asserts insert more basic block, causing phi node values to be
invalid. Fix this by remembering the outgoing LLVM basic block.
6 years ago
Ayke van Laethem
57661a3c76
compiler: fix typeassert without comma-ok for unused types
6 years ago
Ron Evans
d948abdf82
avr: correct register for Set() operation on pins 0-7
Signed-off-by: Ron Evans <ron@hybridgroup.com>
6 years ago
Ayke van Laethem
76e77917d8
targets: move target-specific files to this directory
6 years ago
Ayke van Laethem
e389d38dec
Makefile: improve gen-device* commands
6 years ago
Ayke van Laethem
18b3e8d156
gen-device: move to new tools directory
6 years ago
Ayke van Laethem
a46ed465c5
README: defer has been fully implemented
6 years ago
Ayke van Laethem
422c848163
README: fix nrf example and add arduino example
6 years ago
Ayke van Laethem
7e7502a990
README: update build instructions
6 years ago
Ayke van Laethem
5e9e3bd1a0
Makefile: use the compiler driver directly
6 years ago
Ayke van Laethem
76a513802f
targets/pca10040: support linking from within the compiler
This is kind of dirty with that huge list of linker params, but it works
and it produces smaller object files (probably because GCC is better
optimized for size).
6 years ago
Ayke van Laethem
8ce139284a
all: remove last traces of the C runtime
This increases code size on the nrf, but it is a fixed increase and can
hopefully be reduced in the future.
The Makefile gets a lot smaller with this which is a huge advantage
(less build time complexity).
6 years ago
Ayke van Laethem
f7f7d4cbbc
runtime/nrf: translate nrf sleep function from C to Go
This is the last critical part of the C runtime.
Code size is reduced by 4 bytes for examples/blinky2 (probably due to
inlining) and is unchanged for examples/test.
6 years ago
Ayke van Laethem
67e33ac30e
gen-device-svd: add _Pos and _Msk fields
Without these extra fields, it is impossible to read/write some register
bits correctly.
6 years ago
Ayke van Laethem
2788ab0172
all: rename __reg to __volatile
It is less magical now: it only marks loads and stores as volatile. So
the name '__reg' is a bit wrong now.
6 years ago
Ayke van Laethem
914cd56ca5
all: support Arduino in the compiler driver
This makes sure the compiler itself can build/link an ELF file that
works on an Arduino.
6 years ago
Ayke van Laethem
865520b571
compiler: act as a compiler driver (on unix systems)
As a final step, link the object file with the system compiler/linker.
TODO: cross compiling.
6 years ago