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

1180 коммитов

Автор SHA1 Сообщение Дата
Jaden Weiss
ad73a727a3 fix time on 32-bit arm on linux 2019-11-11 09:20:40 +01:00
Ayke van Laethem
efafda1d32 runtime: only implement CountString for required platforms 2019-11-10 21:33:11 +01:00
Ayke van Laethem
405c0263b0 runtime: add AdjustTimeOffset to update current time
This function adjusts the time returned by time.Now() and similar
functions. This is necessary on bare metal systems, where there would
not be a way to adjust the time otherwise.
2019-11-10 08:54:06 +01:00
Ayke van Laethem
45b5decb4e runtime: implement comparing uintptr values in interfaces
This was an oversight in https://github.com/tinygo-org/tinygo/pull/686.
With this PR, it's possible to compare interface values that contain
values/fields of type uintptr.
2019-11-09 13:41:27 -05:00
Ayke van Laethem
fb39e0917b cgo: add -update flag to tests
When this flag is set, the testdata/*.out.go files will be updated when
they have changed. This is very convenient for updating these files
after the expected output changes.

Of course, the updated output must still be checked for validity.
2019-11-08 16:36:00 +01:00
Ayke van Laethem
16fbf53ae2 nrf: add support for SoftDevices to PCA10040 board 2019-11-08 13:08:59 +01:00
Ayke van Laethem
b153bd63f2 cgo: add support for nested structs and unions 2019-11-08 08:38:50 +01:00
Ayke van Laethem
6108ee6859 cgo: refactor union support
Instead of putting the magic in the AST, generate regular accessor
methods. This avoids a number of special cases in the compiler, and
avoids missing any of them.

The resulting union accesses are somewhat clunkier to use, but the
compiler implementation has far less coupling between the CGo
implementation and the IR generator.
2019-11-07 21:39:29 +01:00
Ayke van Laethem
76c9f13e13 cgo: include all enums in the CGo Go AST
Not all enums may be used as a type anywhere, which was previously the
only way to include an enum in the AST. This commit makes sure all enums
are included.
2019-11-06 17:46:20 +01:00
Ayke van Laethem
d31deda1b5 main: add 'info' subcommand
It lists some information about the device that is useful for tools, in
a way that can be parsed easily.
2019-11-06 16:48:27 +01:00
Ayke van Laethem
473576e756 cgo: do type checking in CGo testing
Such type checking should hopefully catch more bugs.

This commit also fixes some existing type errors.
2019-11-06 16:30:07 +01:00
Ayke van Laethem
913131bf62 cgo: avoid '"unsafe" imported but not used' error
This can happen when not all CGo features are used.
2019-11-06 16:30:07 +01:00
Ayke van Laethem
b41e58bcb4 cgo: rename reserved field names like type
This commit renames reserved field names like `type` to `_type`, and in
turn renames those fields as well (recursively). This avoids name
clashes when a C struct contains a field named `type`, which is a
reserved keyword in Go.

For some details, see:
https://golang.org/cmd/cgo/#hdr-Go_references_to_C
2019-11-06 15:54:18 +01:00
BCG
0db403dc0c Adding Board: Feather M4 Express (#688)
* machine/feather-m4: Adding Feather M4
2019-11-05 15:34:46 +01:00
Ayke van Laethem
cadb75a4aa cgo: implement the constant parser as a real parser
Previously it was just a combination of heuristics to try to fit a
constant in an *ast.BasicLit. For more complex expressions, this is not
enough.

This change also introduces proper syntax error with locations, if
parsing a constant failed. For example, this will print a real error
message with source location:

    #define FOO 5)
2019-11-05 14:18:38 +01:00
Ayke van Laethem
5987233b99 cgo: refactor constant expressions
Put them in a separate file for separation of concerns (making them
testable) and add some tests.
2019-11-05 14:18:38 +01:00
Jaden Weiss
992f1fa248 make compiler test names clearer 2019-11-04 16:52:40 +01:00
Ayke van Laethem
1cbe09ee89 compileopts: add linkerscript key
Setting the linker script as one property (instead of as part of the
generic ldflags property) allows it to be overriden.

This is important for the SoftDevice on Nordic chips, because the
SoftDevice takes up a fixed part of the flash/RAM and the application
must be flashed at a different position. With this linkerscript option,
it is possible to create (for example) a pca10040-s132v6 that overrides
the default linker script.
2019-11-04 16:21:59 +01:00
Ayke van Laethem
18cce571a2 main: move ldflags to compileopts 2019-11-04 16:21:59 +01:00
Konstantin Itskov
ac330f4a70 runtime: implement interface equality
Code copied from Konstantin Itskov and modified by Ayke van Laethem.
For details: https://github.com/tinygo-org/tinygo/pull/569
2019-11-04 15:19:41 +01:00
Ayke van Laethem
e977276044 interp: fix "todo: store" panic
This is really just a simple workaround. When such an instruction is
encountered, it will just fall back to marking the entire function as
having side effects. Ideally it should trace all affected instructions
and check if they would have any side effects, but this at least fixes a
number of compile errors.

This commit gets the following packages to compile:

  * context
  * database/sql/driver
  * image/jpeg
  * image/png
2019-11-04 13:32:22 +01:00
Ayke van Laethem
feb2b4715b interp: fix scanning declarations
Declarations would enter an infinite loop when trying to loop over basic
blocks. That was probably an undefined operation, but still somehow
didn't crash the compiler.

Make sure that scanning declarations works as expected.
2019-11-04 13:32:22 +01:00
Ayke van Laethem
3b0ed63c29 all: refactor compile options
Move most of the logic of determining which compiler configuration to
use (such as GOOS/GOARCH, build tags, whether to include debug symbols,
panic strategy, etc.) into the compileopts package. This makes it a
single source of truth for anything related to compiler configuration.

It has a few advantages:

  * The compile configuration is independent of the compiler package.
    This makes it possible to move optimization passes out of the
    compiler, as they don't rely on compiler.Config anymore.
  * There is only one place to look if an incorrect compile option is
    used.
  * The compileopts provides some resistance against unintentionally
    picking the wrong option, such as with c.selectGC() vs c.GC() in the
    compiler.
  * It is now a lot easier to change compile options, as most options
    are getters now.
2019-11-04 11:45:35 +01:00
Ayke van Laethem
59cc901340 main: move compile options to compileopts package 2019-11-04 11:45:35 +01:00
Ayke van Laethem
ef600965aa compiler: move Config struct to compileopts 2019-11-04 11:45:35 +01:00
Ayke van Laethem
e7cf75030c main: move target specification into a separate package 2019-11-04 11:45:35 +01:00
Ron Evans
dff6e6566d go-llvm: update modules to use latest version
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-11-04 11:01:11 +01:00
Jaden Weiss
cdff0bd3ee add blocking select 2019-11-04 09:15:21 +01:00
Ayke van Laethem
fa25fa1b0c macos: use llvm@8 instead of just llvm in paths
This should hopefully avoid needing to use `brew switch`.
2019-11-03 21:02:39 +01:00
Ayke van Laethem
be7529b261 cgo: add tests for most C types 2019-11-03 19:15:38 +01:00
Ayke van Laethem
26bdfa9c84 cgo: add bare-bones test 2019-11-03 19:15:38 +01:00
Ayke van Laethem
b72f677310 cgo: create new GenDecl for every symbol
Previously, a GenDecl was shared between many different
consts/vars/types. However, it actually makes much more sense not to
bundle them as that is also the case in C.

This makes the printed output of the CGo AST much nicer, and works
around a bug in Go 1.11.
2019-11-03 19:15:38 +01:00
Ayke van Laethem
2a5ab2500d machine: add support for the X9 Pro smartwatch
This is a Chinese smart watch sold on AliExpress etc. It is based on a
nrf52832. More information:
https://github.com/curtpw/nRF5x-device-reverse-engineering/tree/master/X9-nrf52832-activity-tracker
2019-11-03 17:28:32 +01:00
Ayke van Laethem
c138a50457 cgo: improve diagnostics
This commit improves diagnostics in a few ways:

  * All panics apart from panics with no (easy) recovery are converted to
    regular errors with source location.
  * Some errors were improved slightly to give more information. For
    example, show the libclang type kind as a string instead of a
    number.
  * Improve source location by respecting line directives in the C
    preprocessor.
  * Refactor to unify error handling between libclang diagnostics and
    failures to parse the libclang AST.
2019-11-03 16:58:23 +01:00
Jaden Weiss
86ab03c999 fix miscompile of static goroutine calls to closures 2019-11-02 12:50:32 +01:00
Ayke van Laethem
923a6f5873 interp: add testing for scanning for side effects 2019-11-01 17:00:32 +01:00
Ayke van Laethem
071f863e5d qemu: rename assembly file
The name was cortex-m.s which looks like it is a generic assembly file
for all cortex-m targets. However, it really is only for qemu
simulation, because every chip has a slightly different interrupt vector
table.
2019-11-01 16:25:41 +01:00
Ayke van Laethem
b884db81ea cortexm: move SemihostingCall impl to the right asm file
This is the more correct location. The targets/cortex-m.s file is really
just for qemu, not for Cortex-M in general.
2019-11-01 16:25:41 +01:00
Ron Evans
41df9648a8 machine/samd51: correct channel init and pin map for ADC based on ItsyBitsy-M4
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-11-01 10:07:07 +01:00
Ron Evans
3ec94a06ed gen-device: correct source for SiFive SVD files
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-10-31 13:07:51 +01:00
Ron Evans
3777791aa3 machine/samd51: allow setting pinmode for each of the SPI pins
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-10-31 12:47:48 +01:00
Ayke van Laethem
96d4987345 main: remove ocd-daemon property
This fixes a crash crash with the -ocd-output flag.
2019-10-31 12:37:06 +01:00
Ayke van Laethem
66ed03faa2 machine/hifive1b: fix compiling in simulation (wasm) 2019-10-31 12:03:35 +01:00
Ron Evans
46d468b79d machine/hifive1b: add support for SPI1
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-10-29 13:25:13 +01:00
Ayke van Laethem
373fa6d69b main: halt GDB on start
Most programmers support the "reset halt" command, which resets the
target but keeps it halted at the first instruction. This is a much more
natural way of working with GDB, and allows setting breakpoints before
the program is started.

This commit switches to `reset halt` by default and also stops running
the program directly when debugging natively on the host.
2019-10-29 13:13:08 +01:00
Ayke van Laethem
a4642ddf59 Makefile: add simulated boards to smoke tests
One board (pca10040) was already tested. To make sure stuff doesn't
break in the future, test all the other boards too.
2019-10-29 13:10:50 +01:00
Ayke van Laethem
ceece08959 nrf: add support for the PineTime64 devkit
This smartwatch doesn't have an on-board debugger, so I picked the one I
was using while getting this smartwatch to run Go programs (the J-Link
EDU Mini).
2019-10-28 07:17:39 +01:00
Ron Evans
7014f90120 machine/samd21: correct handling of pins > 32 based on bugfix for samd51 submitted by @Infinoid
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-10-27 23:32:56 +01:00
Infinoid
f7dde33842 machine/atsamd51: pin method cleanup (#659)
* machine/samd51: pin method cleanups.
- Use bit-math to select the group in Pin methods.
- Move Pin methods to atsamd51. They are not chip-specific, they apply to the whole atsamd51 family.
- Move the group/pin-id calculation into a helper method.
- Add a Pin.Toggle() method.
2019-10-27 21:37:52 +01:00
Jun Takeda
2f059ac91e machine/atmega: add PORT C GPIO support 2019-10-26 11:35:52 +02:00