mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 14:03:39 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb6edeae80 | |||
| 4517a0c17b | |||
| 6abaee4640 | |||
| 1270a50104 | |||
| 868262f4a7 | |||
| d33ace7b59 | |||
| dd6fa89aa6 | |||
| d513cae5d2 | |||
| e612f7cf3f | |||
| 385a7920e6 | |||
| 077b35e9ad | |||
| 880e940417 | |||
| ad6c89bf64 | |||
| ae6220262a | |||
| e731a31eb9 | |||
| 3023ba584b | |||
| 3a8ef33c72 |
@@ -98,9 +98,9 @@ commands:
|
|||||||
- /go/pkg/mod
|
- /go/pkg/mod
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-llvm15-go118:
|
test-llvm15-go119:
|
||||||
docker:
|
docker:
|
||||||
- image: golang:1.18-bullseye
|
- image: golang:1.19-bullseye
|
||||||
steps:
|
steps:
|
||||||
- test-linux:
|
- test-linux:
|
||||||
llvm: "15"
|
llvm: "15"
|
||||||
@@ -118,6 +118,6 @@ workflows:
|
|||||||
jobs:
|
jobs:
|
||||||
# This tests our lowest supported versions of Go and LLVM, to make sure at
|
# This tests our lowest supported versions of Go and LLVM, to make sure at
|
||||||
# least the smoke tests still pass.
|
# least the smoke tests still pass.
|
||||||
- test-llvm15-go118
|
- test-llvm15-go119
|
||||||
# This tests LLVM 18 support when linking against system libraries.
|
# This tests LLVM 18 support when linking against system libraries.
|
||||||
- test-llvm18-go122
|
- test-llvm18-go122
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ src/device/kendryte/*.go
|
|||||||
src/device/kendryte/*.s
|
src/device/kendryte/*.s
|
||||||
src/device/rp/*.go
|
src/device/rp/*.go
|
||||||
src/device/rp/*.s
|
src/device/rp/*.s
|
||||||
|
src/device/wch/*.go
|
||||||
|
src/device/wch/*.s
|
||||||
vendor
|
vendor
|
||||||
llvm-build
|
llvm-build
|
||||||
llvm-project
|
llvm-project
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ tarball. If you want to help with development of TinyGo itself, you should follo
|
|||||||
LLVM, Clang and LLD are quite light on dependencies, requiring only standard
|
LLVM, Clang and LLD are quite light on dependencies, requiring only standard
|
||||||
build tools to be built. Go is of course necessary to build TinyGo itself.
|
build tools to be built. Go is of course necessary to build TinyGo itself.
|
||||||
|
|
||||||
* Go (1.18+)
|
* Go (1.19+)
|
||||||
* GNU Make
|
* GNU Make
|
||||||
* Standard build tools (gcc/clang)
|
* Standard build tools (gcc/clang)
|
||||||
* git
|
* git
|
||||||
|
|||||||
@@ -1,3 +1,61 @@
|
|||||||
|
0.32.0
|
||||||
|
---
|
||||||
|
|
||||||
|
* **general**
|
||||||
|
- fix wasi-libc include headers on Nix
|
||||||
|
- apply OpenOCD commands after target configuration
|
||||||
|
- fix a minor race condition when determining the build tags
|
||||||
|
- support UF2 drives with a space in their name on Linux
|
||||||
|
- add LLVM 18 support
|
||||||
|
- drop support for Go 1.18 to be able to stay up to date
|
||||||
|
|
||||||
|
* **compiler**
|
||||||
|
- move `-panic=trap` support to the compiler/runtime
|
||||||
|
- fix symbol table index for WebAssembly archives
|
||||||
|
- fix ed25519 build errors by adjusting the alias names
|
||||||
|
- add aliases to generic AES functions
|
||||||
|
- fix race condition by temporarily applying a proposed patch
|
||||||
|
- `builder`: keep un-wasm-opt'd .wasm if -work was passed
|
||||||
|
- `builder`: make sure wasm-opt command line is printed if asked
|
||||||
|
- `cgo`: implement shift operations in preprocessor macros
|
||||||
|
- `interp`: checking for methodset existance
|
||||||
|
|
||||||
|
* **standard library**
|
||||||
|
- `machine`: add `__tinygo_spi_tx` function to simulator
|
||||||
|
- `machine`: fix simulator I2C support
|
||||||
|
- `machine`: add GetRNG support to simulator
|
||||||
|
- `machine`: add `TxFifoFreeLevel` for CAN
|
||||||
|
- `os`: add `Link`
|
||||||
|
- `os`: add `FindProcess` for posix
|
||||||
|
- `os`: add `Process.Release` for unix
|
||||||
|
- `os`: add `SetReadDeadline` stub
|
||||||
|
- `os`, `os/signal`: add signal stubs
|
||||||
|
- `os/user`: add stubs for `Lookup{,Group}` and `Group`
|
||||||
|
- `reflect`: use int in `StringHeader` and `SliceHeader` on non-AVR platforms
|
||||||
|
- `reflect`: fix `NumMethods` for Interface type
|
||||||
|
- `runtime`: skip negative sleep durations in sleepTicks
|
||||||
|
|
||||||
|
* **targets**
|
||||||
|
- `esp32`: add I2C support
|
||||||
|
- `rp2040`: move UART0 and UART1 to common file
|
||||||
|
- `rp2040`: make all RP2040 boards available for simulation
|
||||||
|
- `rp2040`: fix timeUnit type
|
||||||
|
- `stm32`: add i2c `Frequency` and `SetBaudRate` function for chips that were missing implementation
|
||||||
|
- `wasm-unknown`: add math and memory builtins that LLVM needs
|
||||||
|
- `wasip1`: replace existing `-target=wasi` support with wasip1 as supported in Go 1.21+
|
||||||
|
|
||||||
|
* **boards**
|
||||||
|
- `adafruit-esp32-feather-v2`: add the Adafruit ESP32 Feather V2
|
||||||
|
- `badger2040-w`: add support for the Badger2040 W
|
||||||
|
- `feather-nrf52840-sense`: fix lack of LXFO
|
||||||
|
- `m5paper`: add support for the M5 Paper
|
||||||
|
- `mksnanov3`: limit programming speed to 1800 kHz
|
||||||
|
- `nucleol476rg`: add stm32 nucleol476rg support
|
||||||
|
- `pico-w`: add the Pico W (which is near-idential to the pico target)
|
||||||
|
- `thingplus-rp2040`, `waveshare-rp2040-zero`: add WS2812 definition
|
||||||
|
- `pca10059-s140v7`: add this variant to the PCA10059 board
|
||||||
|
|
||||||
|
|
||||||
0.31.2
|
0.31.2
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+20
-14
@@ -185,7 +185,7 @@ fmt-check:
|
|||||||
@unformatted=$$(gofmt -l $(FMT_PATHS)); [ -z "$$unformatted" ] && exit 0; echo "Unformatted:"; for fn in $$unformatted; do echo " $$fn"; done; exit 1
|
@unformatted=$$(gofmt -l $(FMT_PATHS)); [ -z "$$unformatted" ] && exit 0; echo "Unformatted:"; for fn in $$unformatted; do echo " $$fn"; done; exit 1
|
||||||
|
|
||||||
|
|
||||||
gen-device: gen-device-avr gen-device-esp gen-device-nrf gen-device-sam gen-device-sifive gen-device-kendryte gen-device-nxp gen-device-rp
|
gen-device: gen-device-avr gen-device-esp gen-device-nrf gen-device-sam gen-device-sifive gen-device-kendryte gen-device-nxp gen-device-rp gen-device-wch
|
||||||
ifneq ($(STM32), 0)
|
ifneq ($(STM32), 0)
|
||||||
gen-device: gen-device-stm32
|
gen-device: gen-device-stm32
|
||||||
endif
|
endif
|
||||||
@@ -237,6 +237,10 @@ gen-device-renesas: build/gen-device-svd
|
|||||||
./build/gen-device-svd -source=https://github.com/tinygo-org/renesas-svd lib/renesas-svd/ src/device/renesas/
|
./build/gen-device-svd -source=https://github.com/tinygo-org/renesas-svd lib/renesas-svd/ src/device/renesas/
|
||||||
GO111MODULE=off $(GO) fmt ./src/device/renesas
|
GO111MODULE=off $(GO) fmt ./src/device/renesas
|
||||||
|
|
||||||
|
gen-device-wch: build/gen-device-svd
|
||||||
|
./build/gen-device-svd -source=https://github.com/ch32-rs/ch32-rs/ lib/cmsis-svd/data/WCH-Community/ src/device/wch
|
||||||
|
GO111MODULE=off $(GO) fmt ./src/device/wch
|
||||||
|
|
||||||
# Get LLVM sources.
|
# Get LLVM sources.
|
||||||
$(LLVM_PROJECTDIR)/llvm:
|
$(LLVM_PROJECTDIR)/llvm:
|
||||||
git clone -b tinygo_xtensa_release_18.1.2 --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)
|
git clone -b tinygo_xtensa_release_18.1.2 --depth=1 https://github.com/tinygo-org/llvm-project $(LLVM_PROJECTDIR)
|
||||||
@@ -491,7 +495,7 @@ smoketest:
|
|||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=nano-rp2040 examples/rtcinterrupt
|
$(TINYGO) build -size short -o test.hex -target=nano-rp2040 examples/rtcinterrupt
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=pca10040 examples/serial
|
$(TINYGO) build -size short -o test.hex -target=pca10040 examples/machinetest
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=pca10040 examples/systick
|
$(TINYGO) build -size short -o test.hex -target=pca10040 examples/systick
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
@@ -523,7 +527,7 @@ ifneq ($(WASM), 0)
|
|||||||
@$(MD5SUM) test.wasm
|
@$(MD5SUM) test.wasm
|
||||||
$(TINYGO) build -size short -o test.wasm -tags=circuitplay_bluefruit examples/blinky1
|
$(TINYGO) build -size short -o test.wasm -tags=circuitplay_bluefruit examples/blinky1
|
||||||
@$(MD5SUM) test.wasm
|
@$(MD5SUM) test.wasm
|
||||||
$(TINYGO) build -size short -o test.wasm -tags=mch2022 examples/serial
|
$(TINYGO) build -size short -o test.wasm -tags=mch2022 examples/machinetest
|
||||||
@$(MD5SUM) test.wasm
|
@$(MD5SUM) test.wasm
|
||||||
$(TINYGO) build -size short -o test.wasm -tags=gopher_badge examples/blinky1
|
$(TINYGO) build -size short -o test.wasm -tags=gopher_badge examples/blinky1
|
||||||
@$(MD5SUM) test.wasm
|
@$(MD5SUM) test.wasm
|
||||||
@@ -621,7 +625,7 @@ endif
|
|||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=itsybitsy-nrf52840 examples/blinky1
|
$(TINYGO) build -size short -o test.hex -target=itsybitsy-nrf52840 examples/blinky1
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=qtpy examples/serial
|
$(TINYGO) build -size short -o test.hex -target=qtpy examples/machinetest
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=teensy41 examples/blinky1
|
$(TINYGO) build -size short -o test.hex -target=teensy41 examples/blinky1
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
@@ -693,7 +697,7 @@ endif
|
|||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=feather-nrf52840 examples/usb-midi
|
$(TINYGO) build -size short -o test.hex -target=feather-nrf52840 examples/usb-midi
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=nrf52840-s140v6-uf2-generic examples/serial
|
$(TINYGO) build -size short -o test.hex -target=nrf52840-s140v6-uf2-generic examples/machinetest
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
ifneq ($(STM32), 0)
|
ifneq ($(STM32), 0)
|
||||||
$(TINYGO) build -size short -o test.hex -target=bluepill examples/blinky1
|
$(TINYGO) build -size short -o test.hex -target=bluepill examples/blinky1
|
||||||
@@ -735,7 +739,7 @@ ifneq ($(STM32), 0)
|
|||||||
endif
|
endif
|
||||||
$(TINYGO) build -size short -o test.hex -target=atmega328pb examples/blinkm
|
$(TINYGO) build -size short -o test.hex -target=atmega328pb examples/blinkm
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=atmega1284p examples/serial
|
$(TINYGO) build -size short -o test.hex -target=atmega1284p examples/machinetest
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=arduino examples/blinky1
|
$(TINYGO) build -size short -o test.hex -target=arduino examples/blinky1
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
@@ -762,27 +766,29 @@ ifneq ($(XTENSA), 0)
|
|||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target=nodemcu examples/blinky1
|
$(TINYGO) build -size short -o test.bin -target=nodemcu examples/blinky1
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target m5stack-core2 examples/serial
|
$(TINYGO) build -size short -o test.bin -target m5stack-core2 examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target m5stack examples/serial
|
$(TINYGO) build -size short -o test.bin -target m5stack examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target m5stick-c examples/serial
|
$(TINYGO) build -size short -o test.bin -target m5stick-c examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target m5paper examples/serial
|
$(TINYGO) build -size short -o test.bin -target m5paper examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target mch2022 examples/serial
|
$(TINYGO) build -size short -o test.bin -target mch2022 examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
endif
|
endif
|
||||||
$(TINYGO) build -size short -o test.bin -target=qtpy-esp32c3 examples/serial
|
$(TINYGO) build -size short -o test.bin -target=qtpy-esp32c3 examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target=m5stamp-c3 examples/serial
|
$(TINYGO) build -size short -o test.bin -target=m5stamp-c3 examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.bin -target=xiao-esp32c3 examples/serial
|
$(TINYGO) build -size short -o test.bin -target=xiao-esp32c3 examples/machinetest
|
||||||
@$(MD5SUM) test.bin
|
@$(MD5SUM) test.bin
|
||||||
$(TINYGO) build -size short -o test.hex -target=hifive1b examples/blinky1
|
$(TINYGO) build -size short -o test.hex -target=hifive1b examples/blinky1
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
$(TINYGO) build -size short -o test.hex -target=maixbit examples/blinky1
|
$(TINYGO) build -size short -o test.hex -target=maixbit examples/blinky1
|
||||||
@$(MD5SUM) test.hex
|
@$(MD5SUM) test.hex
|
||||||
|
$(TINYGO) build -size short -o test.hex -target=nanoch32v003 examples/blinky1
|
||||||
|
@$(MD5SUM) test.hex
|
||||||
ifneq ($(WASM), 0)
|
ifneq ($(WASM), 0)
|
||||||
$(TINYGO) build -size short -o wasm.wasm -target=wasm examples/wasm/export
|
$(TINYGO) build -size short -o wasm.wasm -target=wasm examples/wasm/export
|
||||||
$(TINYGO) build -size short -o wasm.wasm -target=wasm examples/wasm/main
|
$(TINYGO) build -size short -o wasm.wasm -target=wasm examples/wasm/main
|
||||||
|
|||||||
+3
-11
@@ -243,7 +243,6 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
// Create the *ssa.Program. This does not yet build the entire SSA of the
|
// Create the *ssa.Program. This does not yet build the entire SSA of the
|
||||||
// program so it's pretty fast and doesn't need to be parallelized.
|
// program so it's pretty fast and doesn't need to be parallelized.
|
||||||
program := lprogram.LoadSSA()
|
program := lprogram.LoadSSA()
|
||||||
program.Build()
|
|
||||||
|
|
||||||
// Add jobs to compile each package.
|
// Add jobs to compile each package.
|
||||||
// Packages that have a cache hit will not be compiled again.
|
// Packages that have a cache hit will not be compiled again.
|
||||||
@@ -355,8 +354,8 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
packageActionIDJobs[pkg.ImportPath] = packageActionIDJob
|
packageActionIDJobs[pkg.ImportPath] = packageActionIDJob
|
||||||
|
|
||||||
// Build the SSA for the given package.
|
// Build the SSA for the given package.
|
||||||
//ssaPkg := program.Package(pkg.Pkg)
|
ssaPkg := program.Package(pkg.Pkg)
|
||||||
//ssaPkg.Build()
|
ssaPkg.Build()
|
||||||
|
|
||||||
// Now create the job to actually build the package. It will exit early
|
// Now create the job to actually build the package. It will exit early
|
||||||
// if the package is already compiled.
|
// if the package is already compiled.
|
||||||
@@ -371,12 +370,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
|
|
||||||
if _, err := os.Stat(job.result); err == nil {
|
if _, err := os.Stat(job.result); err == nil {
|
||||||
// Already cached, don't recreate this package.
|
// Already cached, don't recreate this package.
|
||||||
switch pkg.ImportPath {
|
return nil
|
||||||
case "context": // seems to be needed
|
|
||||||
case "time": // often crashes in this package, so probably needed
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile AST to IR. The compiler.CompilePackage function will
|
// Compile AST to IR. The compiler.CompilePackage function will
|
||||||
@@ -523,8 +517,6 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
run: func(*compileJob) error {
|
run: func(*compileJob) error {
|
||||||
// Load and link all the bitcode files. This does not yet optimize
|
// Load and link all the bitcode files. This does not yet optimize
|
||||||
// anything, it only links the bitcode files together.
|
// anything, it only links the bitcode files together.
|
||||||
println("exit")
|
|
||||||
os.Exit(0)
|
|
||||||
ctx := llvm.NewContext()
|
ctx := llvm.NewContext()
|
||||||
mod = ctx.NewModule("main")
|
mod = ctx.NewModule("main")
|
||||||
for _, pkgJob := range packageJobs {
|
for _, pkgJob := range packageJobs {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ func TestClangAttributes(t *testing.T) {
|
|||||||
"cortex-m33",
|
"cortex-m33",
|
||||||
"cortex-m4",
|
"cortex-m4",
|
||||||
"cortex-m7",
|
"cortex-m7",
|
||||||
|
"ch32v003",
|
||||||
"esp32c3",
|
"esp32c3",
|
||||||
"fe310",
|
"fe310",
|
||||||
"gameboy-advance",
|
"gameboy-advance",
|
||||||
|
|||||||
+2
-2
@@ -27,10 +27,10 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if major != 1 || minor < 18 || minor > 22 {
|
if major != 1 || minor < 19 || minor > 22 {
|
||||||
// Note: when this gets updated, also update the Go compatibility matrix:
|
// Note: when this gets updated, also update the Go compatibility matrix:
|
||||||
// https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md
|
// https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md
|
||||||
return nil, fmt.Errorf("requires go version 1.18 through 1.22, got go%d.%d", major, minor)
|
return nil, fmt.Errorf("requires go version 1.19 through 1.22, got go%d.%d", major, minor)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &compileopts.Config{
|
return &compileopts.Config{
|
||||||
|
|||||||
+12
-2
@@ -17,6 +17,8 @@ var (
|
|||||||
token.OR: precedenceOr,
|
token.OR: precedenceOr,
|
||||||
token.XOR: precedenceXor,
|
token.XOR: precedenceXor,
|
||||||
token.AND: precedenceAnd,
|
token.AND: precedenceAnd,
|
||||||
|
token.SHL: precedenceShift,
|
||||||
|
token.SHR: precedenceShift,
|
||||||
token.ADD: precedenceAdd,
|
token.ADD: precedenceAdd,
|
||||||
token.SUB: precedenceAdd,
|
token.SUB: precedenceAdd,
|
||||||
token.MUL: precedenceMul,
|
token.MUL: precedenceMul,
|
||||||
@@ -25,11 +27,13 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// See: https://en.cppreference.com/w/c/language/operator_precedence
|
||||||
const (
|
const (
|
||||||
precedenceLowest = iota + 1
|
precedenceLowest = iota + 1
|
||||||
precedenceOr
|
precedenceOr
|
||||||
precedenceXor
|
precedenceXor
|
||||||
precedenceAnd
|
precedenceAnd
|
||||||
|
precedenceShift
|
||||||
precedenceAdd
|
precedenceAdd
|
||||||
precedenceMul
|
precedenceMul
|
||||||
precedencePrefix
|
precedencePrefix
|
||||||
@@ -82,7 +86,7 @@ func parseConstExpr(t *tokenizer, precedence int) (ast.Expr, *scanner.Error) {
|
|||||||
|
|
||||||
for t.peekToken != token.EOF && precedence < precedences[t.peekToken] {
|
for t.peekToken != token.EOF && precedence < precedences[t.peekToken] {
|
||||||
switch t.peekToken {
|
switch t.peekToken {
|
||||||
case token.OR, token.XOR, token.AND, token.ADD, token.SUB, token.MUL, token.QUO, token.REM:
|
case token.OR, token.XOR, token.AND, token.SHL, token.SHR, token.ADD, token.SUB, token.MUL, token.QUO, token.REM:
|
||||||
t.Next()
|
t.Next()
|
||||||
leftExpr, err = parseBinaryExpr(t, leftExpr)
|
leftExpr, err = parseBinaryExpr(t, leftExpr)
|
||||||
}
|
}
|
||||||
@@ -205,13 +209,19 @@ func (t *tokenizer) Next() {
|
|||||||
// https://en.cppreference.com/w/cpp/string/byte/isspace
|
// https://en.cppreference.com/w/cpp/string/byte/isspace
|
||||||
t.peekPos++
|
t.peekPos++
|
||||||
t.buf = t.buf[1:]
|
t.buf = t.buf[1:]
|
||||||
case len(t.buf) >= 2 && (string(t.buf[:2]) == "||" || string(t.buf[:2]) == "&&"):
|
case len(t.buf) >= 2 && (string(t.buf[:2]) == "||" || string(t.buf[:2]) == "&&" || string(t.buf[:2]) == "<<" || string(t.buf[:2]) == ">>"):
|
||||||
// Two-character tokens.
|
// Two-character tokens.
|
||||||
switch c {
|
switch c {
|
||||||
case '&':
|
case '&':
|
||||||
t.peekToken = token.LAND
|
t.peekToken = token.LAND
|
||||||
case '|':
|
case '|':
|
||||||
t.peekToken = token.LOR
|
t.peekToken = token.LOR
|
||||||
|
case '<':
|
||||||
|
t.peekToken = token.SHL
|
||||||
|
case '>':
|
||||||
|
t.peekToken = token.SHR
|
||||||
|
default:
|
||||||
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
t.peekValue = t.buf[:2]
|
t.peekValue = t.buf[:2]
|
||||||
t.buf = t.buf[2:]
|
t.buf = t.buf[2:]
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ func TestParseConst(t *testing.T) {
|
|||||||
{`5&5`, `5 & 5`},
|
{`5&5`, `5 & 5`},
|
||||||
{`5|5`, `5 | 5`},
|
{`5|5`, `5 | 5`},
|
||||||
{`5^5`, `5 ^ 5`},
|
{`5^5`, `5 ^ 5`},
|
||||||
|
{`5<<5`, `5 << 5`},
|
||||||
|
{`5>>5`, `5 >> 5`},
|
||||||
|
{`5>>5 + 3`, `5 >> (5 + 3)`},
|
||||||
|
{`5>>5 ^ 3`, `5>>5 ^ 3`},
|
||||||
{`5||5`, `error: 1:2: unexpected token ||, expected end of expression`}, // logical binops aren't supported yet
|
{`5||5`, `error: 1:2: unexpected token ||, expected end of expression`}, // logical binops aren't supported yet
|
||||||
{`(5/5)`, `(5 / 5)`},
|
{`(5/5)`, `(5 / 5)`},
|
||||||
{`1 - 2`, `1 - 2`},
|
{`1 - 2`, `1 - 2`},
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"tinygo.org/x/go-llvm"
|
"tinygo.org/x/go-llvm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,20 +12,6 @@ func (b *builder) createAtomicOp(name string) llvm.Value {
|
|||||||
case "AddInt32", "AddInt64", "AddUint32", "AddUint64", "AddUintptr":
|
case "AddInt32", "AddInt64", "AddUint32", "AddUint64", "AddUintptr":
|
||||||
ptr := b.getValue(b.fn.Params[0], getPos(b.fn))
|
ptr := b.getValue(b.fn.Params[0], getPos(b.fn))
|
||||||
val := b.getValue(b.fn.Params[1], getPos(b.fn))
|
val := b.getValue(b.fn.Params[1], getPos(b.fn))
|
||||||
if strings.HasPrefix(b.Triple, "avr") {
|
|
||||||
// AtomicRMW does not work on AVR as intended:
|
|
||||||
// - There are some register allocation issues (fixed by https://reviews.llvm.org/D97127 which is not yet in a usable LLVM release)
|
|
||||||
// - The result is the new value instead of the old value
|
|
||||||
vType := val.Type()
|
|
||||||
name := fmt.Sprintf("__sync_fetch_and_add_%d", vType.IntTypeWidth()/8)
|
|
||||||
fn := b.mod.NamedFunction(name)
|
|
||||||
if fn.IsNil() {
|
|
||||||
fn = llvm.AddFunction(b.mod, name, llvm.FunctionType(vType, []llvm.Type{ptr.Type(), vType}, false))
|
|
||||||
}
|
|
||||||
oldVal := b.createCall(fn.GlobalValueType(), fn, []llvm.Value{ptr, val}, "")
|
|
||||||
// Return the new value, not the original value returned.
|
|
||||||
return b.CreateAdd(oldVal, val, "")
|
|
||||||
}
|
|
||||||
oldVal := b.CreateAtomicRMW(llvm.AtomicRMWBinOpAdd, ptr, val, llvm.AtomicOrderingSequentiallyConsistent, true)
|
oldVal := b.CreateAtomicRMW(llvm.AtomicRMWBinOpAdd, ptr, val, llvm.AtomicOrderingSequentiallyConsistent, true)
|
||||||
// Return the new value, not the original value returned by atomicrmw.
|
// Return the new value, not the original value returned by atomicrmw.
|
||||||
return b.CreateAdd(oldVal, val, "")
|
return b.CreateAdd(oldVal, val, "")
|
||||||
|
|||||||
@@ -514,8 +514,7 @@ var basicTypeNames = [...]string{
|
|||||||
func getTypeCodeName(t types.Type) (string, bool) {
|
func getTypeCodeName(t types.Type) (string, bool) {
|
||||||
switch t := t.(type) {
|
switch t := t.(type) {
|
||||||
case *types.Named:
|
case *types.Named:
|
||||||
// Note: check for `t.Obj().Pkg() != nil` for Go 1.18 only.
|
if t.Obj().Parent() != t.Obj().Pkg().Scope() {
|
||||||
if t.Obj().Pkg() != nil && t.Obj().Parent() != t.Obj().Pkg().Scope() {
|
|
||||||
return "named:" + t.String() + "$local", true
|
return "named:" + t.String() + "$local", true
|
||||||
}
|
}
|
||||||
return "named:" + t.String(), false
|
return "named:" + t.String(), false
|
||||||
|
|||||||
+6
-3
@@ -33,18 +33,17 @@ func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
|
|||||||
"{r10}",
|
"{r10}",
|
||||||
"{r8}",
|
"{r8}",
|
||||||
"{r9}",
|
"{r9}",
|
||||||
"{r11}",
|
|
||||||
"{r12}",
|
|
||||||
"{r13}",
|
|
||||||
}[i]
|
}[i]
|
||||||
llvmValue := b.getValue(arg, getPos(call))
|
llvmValue := b.getValue(arg, getPos(call))
|
||||||
args = append(args, llvmValue)
|
args = append(args, llvmValue)
|
||||||
argTypes = append(argTypes, llvmValue.Type())
|
argTypes = append(argTypes, llvmValue.Type())
|
||||||
}
|
}
|
||||||
|
// rcx and r11 are clobbered by the syscall, so make sure they are not used
|
||||||
constraints += ",~{rcx},~{r11}"
|
constraints += ",~{rcx},~{r11}"
|
||||||
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
||||||
target := llvm.InlineAsm(fnType, "syscall", constraints, true, false, llvm.InlineAsmDialectIntel, false)
|
target := llvm.InlineAsm(fnType, "syscall", constraints, true, false, llvm.InlineAsmDialectIntel, false)
|
||||||
return b.CreateCall(fnType, target, args, ""), nil
|
return b.CreateCall(fnType, target, args, ""), nil
|
||||||
|
|
||||||
case b.GOARCH == "386" && b.GOOS == "linux":
|
case b.GOARCH == "386" && b.GOOS == "linux":
|
||||||
// Sources:
|
// Sources:
|
||||||
// syscall(2) man page
|
// syscall(2) man page
|
||||||
@@ -71,6 +70,7 @@ func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
|
|||||||
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
||||||
target := llvm.InlineAsm(fnType, "int 0x80", constraints, true, false, llvm.InlineAsmDialectIntel, false)
|
target := llvm.InlineAsm(fnType, "int 0x80", constraints, true, false, llvm.InlineAsmDialectIntel, false)
|
||||||
return b.CreateCall(fnType, target, args, ""), nil
|
return b.CreateCall(fnType, target, args, ""), nil
|
||||||
|
|
||||||
case b.GOARCH == "arm" && b.GOOS == "linux":
|
case b.GOARCH == "arm" && b.GOOS == "linux":
|
||||||
// Implement the EABI system call convention for Linux.
|
// Implement the EABI system call convention for Linux.
|
||||||
// Source: syscall(2) man page.
|
// Source: syscall(2) man page.
|
||||||
@@ -103,6 +103,7 @@ func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
|
|||||||
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
||||||
target := llvm.InlineAsm(fnType, "svc #0", constraints, true, false, 0, false)
|
target := llvm.InlineAsm(fnType, "svc #0", constraints, true, false, 0, false)
|
||||||
return b.CreateCall(fnType, target, args, ""), nil
|
return b.CreateCall(fnType, target, args, ""), nil
|
||||||
|
|
||||||
case b.GOARCH == "arm64" && b.GOOS == "linux":
|
case b.GOARCH == "arm64" && b.GOOS == "linux":
|
||||||
// Source: syscall(2) man page.
|
// Source: syscall(2) man page.
|
||||||
args := []llvm.Value{}
|
args := []llvm.Value{}
|
||||||
@@ -135,6 +136,7 @@ func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
|
|||||||
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
fnType := llvm.FunctionType(b.uintptrType, argTypes, false)
|
||||||
target := llvm.InlineAsm(fnType, "svc #0", constraints, true, false, 0, false)
|
target := llvm.InlineAsm(fnType, "svc #0", constraints, true, false, 0, false)
|
||||||
return b.CreateCall(fnType, target, args, ""), nil
|
return b.CreateCall(fnType, target, args, ""), nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return llvm.Value{}, b.makeError(call.Pos(), "unknown GOOS/GOARCH for syscall: "+b.GOOS+"/"+b.GOARCH)
|
return llvm.Value{}, b.makeError(call.Pos(), "unknown GOOS/GOARCH for syscall: "+b.GOOS+"/"+b.GOARCH)
|
||||||
}
|
}
|
||||||
@@ -217,6 +219,7 @@ func (b *builder) createSyscall(call *ssa.CallCommon) (llvm.Value, error) {
|
|||||||
retval = b.CreateInsertValue(retval, syscallResult, 0, "")
|
retval = b.CreateInsertValue(retval, syscallResult, 0, "")
|
||||||
retval = b.CreateInsertValue(retval, errResult, 2, "")
|
retval = b.CreateInsertValue(retval, errResult, 2, "")
|
||||||
return retval, nil
|
return retval, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return llvm.Value{}, b.makeError(call.Pos(), "unknown GOOS/GOARCH for syscall: "+b.GOOS+"/"+b.GOARCH)
|
return llvm.Value{}, b.makeError(call.Pos(), "unknown GOOS/GOARCH for syscall: "+b.GOOS+"/"+b.GOARCH)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/tinygo-org/tinygo
|
module github.com/tinygo-org/tinygo
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aykevl/go-wasm v0.0.2-0.20240312204833-50275154210c
|
github.com/aykevl/go-wasm v0.0.2-0.20240312204833-50275154210c
|
||||||
@@ -17,9 +17,9 @@ require (
|
|||||||
github.com/mgechev/revive v1.3.7
|
github.com/mgechev/revive v1.3.7
|
||||||
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3
|
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3
|
||||||
go.bug.st/serial v1.6.0
|
go.bug.st/serial v1.6.0
|
||||||
golang.org/x/net v0.20.0
|
golang.org/x/net v0.26.0
|
||||||
golang.org/x/sys v0.16.0
|
golang.org/x/sys v0.21.0
|
||||||
golang.org/x/tools v0.17.0
|
golang.org/x/tools v0.22.1-0.20240621165957-db513b091504
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
tinygo.org/x/go-llvm v0.0.0-20240518103902-697964f2a9dc
|
tinygo.org/x/go-llvm v0.0.0-20240518103902-697964f2a9dc
|
||||||
)
|
)
|
||||||
@@ -43,5 +43,5 @@ require (
|
|||||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/spf13/afero v1.11.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.16.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -82,9 +82,10 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
|
|||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
go.bug.st/serial v1.6.0 h1:mAbRGN4cKE2J5gMwsMHC2KQisdLRQssO9WSM+rbZJ8A=
|
go.bug.st/serial v1.6.0 h1:mAbRGN4cKE2J5gMwsMHC2KQisdLRQssO9WSM+rbZJ8A=
|
||||||
go.bug.st/serial v1.6.0/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
|
go.bug.st/serial v1.6.0/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
|
||||||
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
|
||||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
|
||||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
||||||
|
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -92,12 +93,12 @@ golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||||
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
|
golang.org/x/tools v0.22.1-0.20240621165957-db513b091504 h1:MMsD8mMfluf/578+3wrTn22pjI/Xkzm+gPW47SYfspY=
|
||||||
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
|
golang.org/x/tools v0.22.1-0.20240621165957-db513b091504/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
// Version of TinyGo.
|
// Version of TinyGo.
|
||||||
// Update this value before release of new version of software.
|
// Update this value before release of new version of software.
|
||||||
const version = "0.32.0-dev"
|
const version = "0.33.0-dev"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// This variable is set at build time using -ldflags parameters.
|
// This variable is set at build time using -ldflags parameters.
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
|
|||||||
"device/": false,
|
"device/": false,
|
||||||
"examples/": false,
|
"examples/": false,
|
||||||
"internal/": true,
|
"internal/": true,
|
||||||
|
"internal/binary/": false,
|
||||||
"internal/bytealg/": false,
|
"internal/bytealg/": false,
|
||||||
"internal/fuzz/": false,
|
"internal/fuzz/": false,
|
||||||
"internal/reflectlite/": false,
|
"internal/reflectlite/": false,
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// We don't support RV32E at the moment.
|
||||||
|
#if !defined(__riscv_32e)
|
||||||
|
|
||||||
#ifdef __riscv_flen
|
#ifdef __riscv_flen
|
||||||
#define NREG 48
|
#define NREG 48
|
||||||
#define LFREG flw
|
#define LFREG flw
|
||||||
@@ -128,3 +131,5 @@ handleInterruptASM:
|
|||||||
LREG ra, 0*REGSIZE(sp)
|
LREG ra, 0*REGSIZE(sp)
|
||||||
addi sp, sp, NREG*REGSIZE
|
addi sp, sp, NREG*REGSIZE
|
||||||
mret
|
mret
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
// This is the same as examples/serial, but it also imports the machine package.
|
||||||
|
// It is used as a smoke test for the machine package (for boards that don't
|
||||||
|
// have an on-board LED and therefore can't use examples/blinky1).
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "machine" // smoke test for the machine package
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
for {
|
||||||
|
println("hello world!")
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Package binary is a lightweight replacement package for encoding/binary.
|
||||||
|
package binary
|
||||||
|
|
||||||
|
// This file contains small helper functions for working with binary data.
|
||||||
|
|
||||||
|
var LittleEndian = littleEndian{}
|
||||||
|
|
||||||
|
type littleEndian struct{}
|
||||||
|
|
||||||
|
// Encode data like encoding/binary.LittleEndian.Uint16.
|
||||||
|
func (littleEndian) Uint16(b []byte) uint16 {
|
||||||
|
return uint16(b[0]) | uint16(b[1])<<8
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store data like binary.LittleEndian.PutUint16.
|
||||||
|
func (littleEndian) PutUint16(b []byte, v uint16) {
|
||||||
|
b[0] = byte(v)
|
||||||
|
b[1] = byte(v >> 8)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append data like binary.LittleEndian.AppendUint16.
|
||||||
|
func (littleEndian) AppendUint16(b []byte, v uint16) []byte {
|
||||||
|
return append(b,
|
||||||
|
byte(v),
|
||||||
|
byte(v>>8),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode data like encoding/binary.LittleEndian.Uint32.
|
||||||
|
func (littleEndian) Uint32(b []byte) uint32 {
|
||||||
|
return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
|
||||||
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
//go:build tinygo
|
//go:build tinygo
|
||||||
|
|
||||||
|
// We don't support RV32E at the moment.
|
||||||
|
#if !defined(__riscv_32e)
|
||||||
|
|
||||||
.section .text.tinygo_startTask
|
.section .text.tinygo_startTask
|
||||||
.global tinygo_startTask
|
.global tinygo_startTask
|
||||||
.type tinygo_startTask, %function
|
.type tinygo_startTask, %function
|
||||||
@@ -69,3 +72,5 @@ tinygo_swapTask:
|
|||||||
|
|
||||||
// Return into the task.
|
// Return into the task.
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
//go:build nanoch32v003
|
||||||
|
|
||||||
|
package machine
|
||||||
|
|
||||||
|
const LED = PD6
|
||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"device/arm"
|
"device/arm"
|
||||||
"device/sam"
|
"device/sam"
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"internal/binary"
|
||||||
"runtime/interrupt"
|
"runtime/interrupt"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"device/arm"
|
"device/arm"
|
||||||
"device/sam"
|
"device/sam"
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"internal/binary"
|
||||||
"runtime/interrupt"
|
"runtime/interrupt"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
//go:build ch32v003
|
||||||
|
|
||||||
|
package machine
|
||||||
|
|
||||||
|
import "device/wch"
|
||||||
|
|
||||||
|
const deviceName = wch.Device
|
||||||
|
|
||||||
|
const (
|
||||||
|
PA0 Pin = 0 + 0
|
||||||
|
PA1 Pin = 0 + 1
|
||||||
|
PA2 Pin = 0 + 2
|
||||||
|
PA3 Pin = 0 + 3
|
||||||
|
PA4 Pin = 0 + 4
|
||||||
|
PA5 Pin = 0 + 5
|
||||||
|
PA6 Pin = 0 + 6
|
||||||
|
PA7 Pin = 0 + 7
|
||||||
|
PC0 Pin = 16 + 0
|
||||||
|
PC1 Pin = 16 + 1
|
||||||
|
PC2 Pin = 16 + 2
|
||||||
|
PC3 Pin = 16 + 3
|
||||||
|
PC4 Pin = 16 + 4
|
||||||
|
PC5 Pin = 16 + 5
|
||||||
|
PC6 Pin = 16 + 6
|
||||||
|
PC7 Pin = 16 + 7
|
||||||
|
PD0 Pin = 24 + 0
|
||||||
|
PD1 Pin = 24 + 1
|
||||||
|
PD2 Pin = 24 + 2
|
||||||
|
PD3 Pin = 24 + 3
|
||||||
|
PD4 Pin = 24 + 4
|
||||||
|
PD5 Pin = 24 + 5
|
||||||
|
PD6 Pin = 24 + 6
|
||||||
|
PD7 Pin = 24 + 7
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PinInput PinMode = 0
|
||||||
|
PinOutput PinMode = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p Pin) getPortPin() (port *wch.GPIO_Type, pin uint32) {
|
||||||
|
portNum := uint32(p) >> 3
|
||||||
|
pin = uint32(p) & 0b111
|
||||||
|
switch portNum {
|
||||||
|
case 0:
|
||||||
|
port = wch.GPIOA
|
||||||
|
case 2:
|
||||||
|
port = wch.GPIOC
|
||||||
|
case 3:
|
||||||
|
port = wch.GPIOD
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Pin) Configure(config PinConfig) {
|
||||||
|
port, pin := p.getPortPin()
|
||||||
|
reg := port.CFGLR.Get()
|
||||||
|
reg &^= (0xf << (4 * pin))
|
||||||
|
reg |= 0b0000 << (4 * pin)
|
||||||
|
reg |= 0b11 << (4 * pin)
|
||||||
|
port.CFGLR.Set(reg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the pin to high or low.
|
||||||
|
func (p Pin) Set(high bool) {
|
||||||
|
port, pin := p.getPortPin()
|
||||||
|
if high {
|
||||||
|
port.BSHR.Set(1 << pin)
|
||||||
|
} else {
|
||||||
|
port.BCR.Set(1 << pin)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ package machine
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"device/nrf"
|
"device/nrf"
|
||||||
"encoding/binary"
|
"internal/binary"
|
||||||
"runtime/interrupt"
|
"runtime/interrupt"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ package machine
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"device/stm32"
|
"device/stm32"
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"internal/binary"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"runtime/interrupt"
|
"runtime/interrupt"
|
||||||
"runtime/volatile"
|
"runtime/volatile"
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ package machine
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"device/stm32"
|
"device/stm32"
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"internal/binary"
|
||||||
"runtime/interrupt"
|
"runtime/interrupt"
|
||||||
"runtime/volatile"
|
"runtime/volatile"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ package machine
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"device/stm32"
|
"device/stm32"
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"internal/binary"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"runtime/interrupt"
|
"runtime/interrupt"
|
||||||
"runtime/volatile"
|
"runtime/volatile"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package descriptor
|
package descriptor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"internal/binary"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package descriptor
|
package descriptor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"internal/binary"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package descriptor
|
package descriptor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"internal/binary"
|
||||||
)
|
)
|
||||||
|
|
||||||
var endpointEP1IN = [endpointTypeLen]byte{
|
var endpointEP1IN = [endpointTypeLen]byte{
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package descriptor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"internal/binary"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configurationCDCHID = [configurationTypeLen]byte{
|
var configurationCDCHID = [configurationTypeLen]byte{
|
||||||
|
|||||||
+16
-1
@@ -58,10 +58,13 @@ type Process struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error) {
|
func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error) {
|
||||||
return nil, &PathError{"fork/exec", name, ErrNotImplemented}
|
return nil, &PathError{Op: "fork/exec", Path: name, Err: ErrNotImplemented}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) Wait() (*ProcessState, error) {
|
func (p *Process) Wait() (*ProcessState, error) {
|
||||||
|
if p.Pid == -1 {
|
||||||
|
return nil, syscall.EINVAL
|
||||||
|
}
|
||||||
return nil, ErrNotImplemented
|
return nil, ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,3 +80,15 @@ func Ignore(sig ...Signal) {
|
|||||||
// leave all the signals unaltered
|
// leave all the signals unaltered
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release releases any resources associated with the Process p,
|
||||||
|
// rendering it unusable in the future.
|
||||||
|
// Release only needs to be called if Wait is not.
|
||||||
|
func (p *Process) Release() error {
|
||||||
|
return p.release()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep compatibility with golang and always succeed and return new proc with pid on Linux.
|
||||||
|
func FindProcess(pid int) (*Process, error) {
|
||||||
|
return findProcess(pid)
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
package os
|
package os
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,3 +20,16 @@ var (
|
|||||||
Interrupt Signal = syscall.SIGINT
|
Interrupt Signal = syscall.SIGINT
|
||||||
Kill Signal = syscall.SIGKILL
|
Kill Signal = syscall.SIGKILL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Keep compatible with golang and always succeed and return new proc with pid on Linux.
|
||||||
|
func findProcess(pid int) (*Process, error) {
|
||||||
|
return &Process{Pid: pid}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Process) release() error {
|
||||||
|
// NOOP for unix.
|
||||||
|
p.Pid = -1
|
||||||
|
// no need for a finalizer anymore
|
||||||
|
runtime.SetFinalizer(p, nil)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package os_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFindProcess(t *testing.T) {
|
||||||
|
// NOTE: For now, we only test the Linux case since only exec_posix.go is currently the only implementation.
|
||||||
|
// Linux guarantees that there is pid 0
|
||||||
|
proc, err := FindProcess(0)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("FindProcess(0): wanted err == nil, got %v:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if proc.Pid != 0 {
|
||||||
|
t.Error("Expected pid 0, got: ", proc.Pid)
|
||||||
|
}
|
||||||
|
|
||||||
|
pid0 := Process{Pid: 0}
|
||||||
|
if *proc != pid0 {
|
||||||
|
t.Error("Expected &Process{Pid: 0}, got", *proc)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Seek whence values.
|
// Seek whence values.
|
||||||
@@ -256,6 +257,12 @@ func (f *File) SyscallConn() (conn syscall.RawConn, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetReadDeadline sets the deadline for future Read calls and any
|
||||||
|
// currently-blocked Read call.
|
||||||
|
func (f *File) SetReadDeadline(t time.Time) error {
|
||||||
|
return f.setReadDeadline(t)
|
||||||
|
}
|
||||||
|
|
||||||
// fd is an internal interface that is used to try a type assertion in order to
|
// fd is an internal interface that is used to try a type assertion in order to
|
||||||
// call the Fd() method of the underlying file handle if it is implemented.
|
// call the Fd() method of the underlying file handle if it is implemented.
|
||||||
type fd interface {
|
type fd interface {
|
||||||
|
|||||||
@@ -8,3 +8,8 @@ import (
|
|||||||
func Chtimes(name string, atime time.Time, mtime time.Time) error {
|
func Chtimes(name string, atime time.Time, mtime time.Time) error {
|
||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setReadDeadline sets the read deadline, not yet implemented
|
||||||
|
func (f *File) setReadDeadline(_ time.Time) error {
|
||||||
|
return ErrNotImplemented
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// We don't support RV32E at the moment.
|
||||||
|
#if !defined(__riscv_32e)
|
||||||
|
|
||||||
#if __riscv_xlen==64
|
#if __riscv_xlen==64
|
||||||
#define REGSIZE 8
|
#define REGSIZE 8
|
||||||
#define SREG sd
|
#define SREG sd
|
||||||
@@ -50,3 +53,5 @@ tinygo_longjmp:
|
|||||||
lw sp, 0(a0) // jumpSP
|
lw sp, 0(a0) // jumpSP
|
||||||
lw a1, REGSIZE(a0) // jumpPC
|
lw a1, REGSIZE(a0) // jumpPC
|
||||||
jr a1
|
jr a1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
//go:build ch32v003
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
import (
|
||||||
|
"device/wch"
|
||||||
|
"runtime/volatile"
|
||||||
|
)
|
||||||
|
|
||||||
|
//export main
|
||||||
|
func main() {
|
||||||
|
// Initialize main clock.
|
||||||
|
wch.RCC.CTLR.Set(wch.RCC_CTLR_HSION | wch.RCC_CTLR_PLLON)
|
||||||
|
wch.RCC.CFGR0.Set(0<<wch.RCC_CFGR0_HPRE_Pos | 0<<wch.RCC_CFGR0_PLLSRC_Pos)
|
||||||
|
wch.FLASH.ACTLR.Set(1 << wch.FLASH_ACTLR_LATENCY_Pos)
|
||||||
|
wch.RCC.INTR.Set(0x009F0000)
|
||||||
|
for (wch.RCC.CTLR.Get() & wch.RCC_CTLR_PLLRDY) == 0 {
|
||||||
|
}
|
||||||
|
wch.RCC.SetCFGR0_SW(0b10)
|
||||||
|
for (wch.RCC.CFGR0.Get() & wch.RCC_CFGR0_SWS_Msk) != 0x08 {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable all GPIO pins (port A, C and D).
|
||||||
|
wch.RCC.APB2PCENR.SetBits(wch.RCC_APB2PCENR_IOPAEN | wch.RCC_APB2PCENR_IOPDEN | wch.RCC_APB2PCENR_IOPCEN)
|
||||||
|
|
||||||
|
run()
|
||||||
|
exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
type timeUnit int64
|
||||||
|
|
||||||
|
var currentTicks timeUnit
|
||||||
|
|
||||||
|
func putchar(c byte) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
func exit(code int) {
|
||||||
|
abort()
|
||||||
|
}
|
||||||
|
|
||||||
|
func ticks() timeUnit {
|
||||||
|
return currentTicks
|
||||||
|
}
|
||||||
|
|
||||||
|
// ticksToNanoseconds converts RTC ticks (at 32768Hz) to nanoseconds.
|
||||||
|
func ticksToNanoseconds(ticks timeUnit) int64 {
|
||||||
|
// The following calculation is actually the following, but with both sides
|
||||||
|
// reduced to reduce the risk of overflow:
|
||||||
|
// ticks * 1e9 / 32768
|
||||||
|
return int64(ticks) * 1953125 / 64
|
||||||
|
}
|
||||||
|
|
||||||
|
// nanosecondsToTicks converts nanoseconds to RTC ticks (running at 32768Hz).
|
||||||
|
func nanosecondsToTicks(ns int64) timeUnit {
|
||||||
|
// The following calculation is actually the following, but with both sides
|
||||||
|
// reduced to reduce the risk of overflow:
|
||||||
|
// ns * 32768 / 1e9
|
||||||
|
return timeUnit(ns * 64 / 1953125)
|
||||||
|
}
|
||||||
|
|
||||||
|
var dummyVolatile volatile.Register32
|
||||||
|
|
||||||
|
func sleepTicks(ticks timeUnit) {
|
||||||
|
// TODO: use a timer (using the low-speed clock)
|
||||||
|
loops := ticks * 70
|
||||||
|
for i := timeUnit(0); i < loops; i++ {
|
||||||
|
dummyVolatile.Get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func abort() {
|
||||||
|
for {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"rp2040"
|
"rp2040"
|
||||||
],
|
],
|
||||||
"serial-port": ["2e8a:0003"],
|
"serial-port": ["2e8a:0003"],
|
||||||
"build-tags": ["badger2040_w"],
|
"build-tags": ["badger2040_w", "cyw43439"],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"--defsym=__flash_size=1020K"
|
"--defsym=__flash_size=1020K"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"inherits": ["riscv32"],
|
||||||
|
"target-abi": "ilp32e",
|
||||||
|
"features": "+32bit,+c,+e,-a,-d,-experimental-zacas,-experimental-zcmop,-experimental-zfbfmin,-experimental-zicfilp,-experimental-zicfiss,-experimental-zimop,-experimental-ztso,-experimental-zvfbfmin,-experimental-zvfbfwma,-f,-h,-i,-m,-relax,-smaia,-smepmp,-ssaia,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-za128rs,-za64rs,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmp,-zcmt,-zdinx,-zfa,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zicsr,-zifencei,-zihintntl,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvbb,-zvbc,-zve32f,-zve32x,-zve64d,-zve64f,-zve64x,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl128b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl32b,-zvl4096b,-zvl512b,-zvl64b,-zvl65536b,-zvl8192b",
|
||||||
|
"build-tags": ["ch32v003", "ch32v00xxx", "wch"],
|
||||||
|
"scheduler": "none",
|
||||||
|
"gc": "leaking",
|
||||||
|
"rtlib": "compiler-rt",
|
||||||
|
"libc": "picolibc",
|
||||||
|
"cflags": [
|
||||||
|
"-march=rv32ec"
|
||||||
|
],
|
||||||
|
"linkerscript": "targets/ch32v003.ld",
|
||||||
|
"extra-files": [
|
||||||
|
],
|
||||||
|
"flash-command": "probe-rs download --chip=CH32V003 {elf}"
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH_TEXT (rw) : ORIGIN = 0x00000000, LENGTH = 16K
|
||||||
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2K
|
||||||
|
}
|
||||||
|
|
||||||
|
_stack_size = 1K;
|
||||||
|
|
||||||
|
INCLUDE "targets/riscv.ld"
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"inherits": ["ch32v003"],
|
||||||
|
"build-tags": ["nanoch32v003"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"inherits": ["pico"],
|
||||||
|
"build-tags": ["pico-w", "cyw43439"]
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ func OptimizeStringToBytes(mod llvm.Module) {
|
|||||||
if use.IsAExtractValueInst().IsNil() {
|
if use.IsAExtractValueInst().IsNil() {
|
||||||
// Expected an extractvalue, but this is something else.
|
// Expected an extractvalue, but this is something else.
|
||||||
canConvertPointer = false
|
canConvertPointer = false
|
||||||
continue
|
break
|
||||||
}
|
}
|
||||||
switch use.Type().TypeKind() {
|
switch use.Type().TypeKind() {
|
||||||
case llvm.IntegerTypeKind:
|
case llvm.IntegerTypeKind:
|
||||||
@@ -49,7 +49,7 @@ func OptimizeStringToBytes(mod llvm.Module) {
|
|||||||
// There is a store to the byte slice. This means that none
|
// There is a store to the byte slice. This means that none
|
||||||
// of the pointer uses can't be propagated.
|
// of the pointer uses can't be propagated.
|
||||||
canConvertPointer = false
|
canConvertPointer = false
|
||||||
continue
|
break
|
||||||
}
|
}
|
||||||
// It may be that the pointer value can be propagated, if all of
|
// It may be that the pointer value can be propagated, if all of
|
||||||
// the pointer uses are readonly.
|
// the pointer uses are readonly.
|
||||||
|
|||||||
Reference in New Issue
Block a user