Граф коммитов

714 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
85108514df
compiler: fix indexing of strings on AVR
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.
2019-01-25 13:15:08 +01:00
Ayke van Laethem
589569fc35 loader: fix ARM compatibility
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).
2019-01-22 21:16:41 +01:00
Ayke van Laethem
2e4dd09bbc
compiler: add support for channel operations
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.
2019-01-21 22:09:37 +01:00
Ayke van Laethem
602c264749
all: rewrite goroutine lowering
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.
2019-01-21 22:09:33 +01:00
Ayke van Laethem
072ef603fe
wasm: add GOOS/GOARCH properties
This was an oversight in commit 107fccb288.
2019-01-21 22:08:12 +01:00
Ayke van Laethem
54baf48266
compiler/interface: fix LLVM context for boolean variable
Apparently the given code path was never properly tested.
2019-01-21 22:08:12 +01:00
Ayke van Laethem
072eb590a6
compiler/interface: correct comment on function 2019-01-21 22:08:12 +01:00
Ayke van Laethem
c0ab91a263
interp: extra safety check in string emulation 2019-01-21 22:08:12 +01:00
Ron Evans
3ebf464da2
machine/samd21: I2C implementation
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-21 21:54:43 +01:00
Ron Evans
38c5e384af
machine/itsybitsy-m0: specify which pins to use for UART0
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-21 21:14:06 +01:00
Ron Evans
65ea74bd84
machine/atsamd21: implements UART0 using the SERCOM0 interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-21 21:14:00 +01:00
Ron Evans
683e2a66e1 machine/atsamd21: correct clock calibration based on stored fuse value
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-20 20:26:54 +01:00
Ron Evans
8cbbbb0e76
machine/atsamd21: improve GPIO config to support all 32 pins on PORTA as well as correct handling for OUTPUT and SERCOM pin modes
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-20 18:42:52 +01:00
Ron Evans
f89c695c8c
generators: correctly handle clustered subtypes used in Atmel SAMD21 SVD for important peripherals
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-20 18:40:49 +01:00
Ron Evans
e2be7ccf76
sam: add support for Atmel SAMD21 based ItsyBitsy M0
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-18 18:30:27 +01:00
Ron Evans
1f511786d3
lib/cmsis-svd: update to latest release with updated SAMD21 and SAMD51 SVD files
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-18 18:30:27 +01:00
Seth Junot
c9f4e41073
wasm: fix typo in wasm_exec.js preventing memory import
Seems to have been left over from the original copy. This correction
should fix calls to the "memory" variable in syscall/js.
2019-01-18 13:30:17 +01:00
Seth Junot
67fbfe6305
runtime/wasm: add memset()
Copied from the ARM runtime and modified to return a pointer.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html
2019-01-18 13:20:22 +01:00
Ayke van Laethem
95e18f36d0
main: compile and run a program directly
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`.
2019-01-16 17:06:34 +01:00
Ron Evans
9ac2f39acc
tools/gen-device-svd: handle case with nested registers that have same address to avoid duplicates
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-15 11:00:56 +01:00
Wèi Cōngruì
2ba7a438c2 loader: remove redundant gateway function 2019-01-15 06:40:57 +00:00
Ayke van Laethem
b88180f8e6
runtime: remove ctx param from stub code
This was necessary before, when only some functions had a context
parameter. Now this is not necessary anymore because all functions
(independent of signature) have a context paramter at the end so the
signature always automatically matches.
2019-01-14 20:56:42 +01:00
Ayke van Laethem
c840757352
compiler/interface: fix comparison with error value 2019-01-14 20:56:05 +01:00
Ron Evans
b4dd2dbf60
docs: change links in README and remove old ReadTheDocs pages to point to TinyGo.org site
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-13 20:29:45 +01:00
Ron Evans
8d1284cfe7
generator: generate device wrappers for Atmel SAM family
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-13 18:59:56 +01:00
Ron Evans
b8c326d710
machine/stm32f103xx: implmentation for I2C interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-10 16:10:25 +01:00
j7b
fad4a735e6 tools: use env to search path for python3 2019-01-08 12:52:47 -08:00
Ayke
107fccb288 all: add support for more architectures and GOOS/GOARCH (#118)
This commit does two things:

  * It adds support for the GOOS and GOARCH environment variables. They
    fall back to runtime.GO* only when not available.
  * It adds support for 3 new architectures: 386, arm, and arm64. For
    now, this is Linux-only.
2019-01-05 11:46:25 +01:00
Konstantin Yegupov
f44dff6f59
compiler: allow slicing arrays of a named type 2019-01-04 15:55:57 +01:00
Ayke
873c1c3b4d Reduce code size for AVR (#116)
* all: add support for specifying target CPU in target config
* avr: specify the chip name in the target CPU

This reduces code size by a large margin. For examples/blinky, it
reduces code size from 1360 to 1266 when compiling for the Arduino Uno
(94 bytes, or ~7%).
2019-01-04 14:58:35 +01:00
Konstantin Yegupov
a8dd82538e
all: add flag to enable i64 parameters in WebAssembly 2019-01-03 18:09:33 +01:00
Ron Evans
dccfae485c
machine/stm32f103xx: support for SPI interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-31 14:59:07 +01:00
Ron Evans
f71e1bcf03
machine/stm32f103xx: implementation of RTC/TIM based timers
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-31 14:39:05 +01:00
kyegupov
fb8dcde2f9
runtime: update link to original Go hashmap source code 2018-12-31 13:33:18 +01:00
Ayke van Laethem
18b16fc151
compiler: run some optimizations after interface lowering
By running these interprocedural optimizations after interface lowering,
in particular the heap-to-stack transformation pass, interfaces can be
zero cost in some more cases.

For example, say you have the following interface:

    type Writer interface {
        Write([]byte) (int, error)
    }

and you do something with it:

    func foo(w io.Writer) {
        w.Write([]byte("foo"))
    }

this commit enables escape analysis across interface boundaries, which
means that the Write call does not cause an allocation if all
implementations of io.Writer do not let the slice escape. This enables
broader uses of interfaces, as they are now a zero-cost abstraction in
more cases.
2018-12-22 19:06:01 +01:00
Ayke van Laethem
5a15d4162d
compiler: add optsize function attr to reduce binary size
This is also added by Clang at -Oz and results in slightly smaller
binaries.
2018-12-22 18:58:43 +01:00
Ron Evans
5ff5873fe6
machine/microbit: add default pin mappings for SPI bus
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-22 17:20:40 +01:00
Ron Evans
47b667a4b8
machine/stm32: add support for stm32f103xx UART
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-18 17:17:18 +01:00
Johan Brandhorst
a830451426
Dockerfile, README, docs: Remove entrypoint
This was causing more trouble than it was helping,
so lets remove it.
2018-12-17 20:41:33 +01:00
Ron Evans
cb648d8ae1
compiler: pass -cflags and -ldflags to tinygo CLI command
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-13 20:10:27 +01:00
Ron Evans
8734732d0c
build: Makefile needs to look at changes in all needed sub-directories to decide if rebuild is required
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-11 12:55:03 +01:00
Ayke van Laethem
6cacafb8dc
cgo: add package directory to header include paths 2018-12-10 15:38:03 +01:00
Ayke van Laethem
c6069476a7
cgo: do not rely on stdint.h to be available 2018-12-10 15:38:03 +01:00
Ayke van Laethem
0af7da9bff
cgo: add support for C.int, c.uint, etc 2018-12-10 15:38:02 +01:00
Ayke van Laethem
e8c1b5ab6e
cgo: add support for C typedefs 2018-12-10 15:38:02 +01:00
Ayke van Laethem
ecf6ffa62e
all: add bare-bones Cgo support 2018-12-10 15:38:02 +01:00
Ayke van Laethem
b99bbc880a
main: add support for testing complete packages, not just .go files 2018-12-10 15:38:02 +01:00
Ayke van Laethem
8ee3267260
wasm: compile .c files in packages 2018-12-10 15:38:02 +01:00
Ayke van Laethem
dea660b21c
main: compile C source files in packages
TODO: C++ etc. files
2018-12-10 15:38:01 +01:00
Ayke van Laethem
e10d05c74f
loader: switch to custom program loader 2018-12-10 15:36:23 +01:00